Repository navigation
feat(extension): reuse existing options page tab when opening settings - #515
Conversation
Use chrome.runtime.openOptionsPage() for the action icon click and the openOption command so an already opened options page in the current window is activated instead of opening a duplicate tab. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…terized URLs Replace chrome.runtime.openOptionsPage() with an openOptionPage() helper that searches all windows for an existing options page tab, and use it for the action icon, the openOption command, adding/editing page rules, and editing a command from the Hub. When a query is given, the existing tab is navigated to it so the target dialog opens. When the Hub edit reuses an existing tab, the tab is kept open after the edit instead of being closed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Match options page tabs that are still loading via pendingUrl - Prefer the options page tab in the last focused window - Do not reuse the edit tab of a cancelled Hub edit session - Catch errors from openOptionPage() in the service worker - Update stale comments on reading location.search - Await the opened tab in tests instead of a fixed number of ticks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
レビュー結果設定画面タブの再利用という目的に対して、実装は素直で読みやすく、テストも追加されています。全体として良い PR です。以下、指摘と提案です。 指摘(軽微〜中)
良い点
テスト
セキュリティ上の懸念は見当たりません(対象は拡張機能自身の URL のみ)。 |
概要
設定画面を開く操作で、すでに設定画面のタブが開いていれば重複して開かず、既存のタブを再利用するようにしました。
変更内容
src/services/chrome.tsにopenOptionPage(path?)を追加?addPageRule=...など)が渡された場合は、既存タブをそのURLへ遷移させるopenOptionPage()に置き換えchrome.action.onClicked)ServiceWorkerCommand.openOptionServiceWorkerCommand.addPageRule)handleEditCommand)handleEditCommandでは、既存タブを再利用した場合は編集完了後もそのタブを閉じない(新規に作成したタブのみ閉じる)補足
確認
tsc --noEmitが通ること🤖 Generated with Claude Code