Add sidePanel open mode with focus-based auto-hide#274
Conversation
Co-authored-by: ujiro99 <677231+ujiro99@users.noreply.github.com>
Co-authored-by: ujiro99 <677231+ujiro99@users.noreply.github.com>
Co-authored-by: ujiro99 <677231+ujiro99@users.noreply.github.com>
プルリクエストレビューこのPRは、ChromeのサイドパネルAPIを使用してURLを開く新しい機能を追加しています。全体的な実装は良好ですが、いくつかの改善点とセキュリティ上の懸念があります。 ✅ 良い点
🔴 重大な問題1. セキュリティ上の懸念: XSS脆弱性のリスク// packages/extension/src/services/chrome.ts:611-614
chrome.sidePanel.setOptions({
tabId: targetTabId,
path: toUrl(url), // ⚠️ ユーザー入力が直接pathに使用されている
enabled: true,
})問題点: 推奨される修正:
2. リソースリークの可能性// packages/extension/src/services/chrome.ts:630-653
export const closeSidePanel = async (tabId: number): Promise<void> => {
const cleanup = async () => {
try {
await BgData.update((data) => ({
sidePanelTabs: data.sidePanelTabs.filter((id) => id !== tabId),
}))
await chrome.sidePanel.setOptions({
tabId: tabId,
enabled: false,
})
} catch (e) {
console.warn("Failed to cleanup side panel:", e)
} finally {
chrome.sidePanel.onClosed.removeListener(cleanup) // ⚠️
}
}
try {
chrome.sidePanel.onClosed.addListener(cleanup)
await chrome.sidePanel.close({ tabId: tabId })
} catch (e) {
console.warn("Failed to close side panel:", e)
}
}問題点:
推奨される修正: export const closeSidePanel = async (tabId: number): Promise<void> => {
const cleanup = () => {
chrome.sidePanel.onClosed.removeListener(cleanup)
BgData.update((data) => ({
sidePanelTabs: data.sidePanelTabs.filter((id) => id !== tabId),
})).catch(console.error)
}
try {
chrome.sidePanel.onClosed.addListener(cleanup)
await chrome.sidePanel.close({ tabId: tabId })
} catch (e) {
chrome.sidePanel.onClosed.removeListener(cleanup) // エラー時も確実に削除
console.warn("Failed to close side panel:", e)
}
}
|
Adds
OPEN_MODE.SIDE_PANELto open URLs in Chrome's side panel API, enabling side-by-side viewing with the current page. Side panels auto-hide when window focus changes, configurable viasidePanelAutoHidesetting (default: enabled).Core Implementation
OPEN_MODE.SIDE_PANELin shared constants and extension mappingsaction/sidePanel.tswith IPC integration viaBgCommand.openSidePanelopenSidePanel()inservices/chrome.tsusingchrome.sidePanel.setOptions()andchrome.sidePanel.open()Auto-Hide Mechanism
BgData.sidePanelTabs[]chrome.windows.onFocusChangedlistener closes side panel for focused tab whensidePanelAutoHideis enabledchrome.tabs.onRemovedandchrome.tabs.onUpdatedincludes()check before adding tab IDsConfiguration
sidePanelAutoHide?: booleantoUserSettingstypetrueindefaultSettings.tsPermissions
"sidePanel"tomanifest.jsonpermissions arrayWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
www.google-analytics.com/opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions node --conditions development /home/REDACTED/work/selection-command/selection-command/node_modules/tinypool/dist/entry/process.js +ujiro99@users.noreply.github.com> tnet/tools/git(dns block)/opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node --conditions node --conditions development /home/REDACTED/work/selection-command/selection-command/node_modules/tinypool/dist/entry/process.js --global k/_temp/ghcca-node/node/bin/bash/var/lib/dpkg/info/libgpm2:amd64.list pull.rebase(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.