Repository navigation
Conversation
Vivaldi appends an absolute URL passed to chrome.sidePanel.setOptions({ path })
to the extension origin, so the side panel showed ERR_FILE_NOT_FOUND
(chrome-extension://<id>/https://...). Chrome resolves it as a URL instead,
but blocks a side panel extension page from navigating to a web URL.
Open a relay page bundled with the extension first. When the side panel is
hosted as a tab (Vivaldi), it navigates to the target URL by itself.
Otherwise (Chrome), it asks the service worker to set the URL as the path
directly, and the result is cached so later opens skip the relay page.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pd1sH5ArKQDueJGVC1vMCK
|
@copilot resolve the merge conflicts in this pull request |
# Conflicts: # packages/extension/src/service_worker.ts Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
|
- Store the user agent instead of a boolean when the direct URL mode is detected, and ignore the cached result on a different browser version, so that the mode is detected again if the browser behavior changes. - Persist the detection result in parallel with setOptions so that showing the page is not delayed by the storage write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
レビュー結果Vivaldi で 良い点
指摘・提案
セキュリティ
全体として、方針も実装も妥当だと考えます。1 の Service Worker 再起動時の挙動を確認し、2 と 3 を対応すれば、マージして問題ないと思います。 |
- Reject a missing, empty or non-positive tabId in both the relay page and the service worker fallback handler. - Export relay() from the relay page so that it can be tested, and add tests for the relay page, sender/tabId validation and setOptions failure. - Document that a side panel opened right after the service worker wakes up may still go through the relay page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
レビューありがとうございます。14a5268f で対応しました。 1. Service Worker 再起動直後に中継ページを経由する修正はせず、既知の制限として受け入れます。この場合も中継ページ → フォールバック → 2.
|
レビュー結果Vivaldi での 指摘事項
セキュリティ
テストユニットテストは分岐を網羅しており十分です。上記 1 の「失敗時に永続化しない」ケースのテストを追加することをお勧めします。 全体としては、指摘 1 の修正を済ませればマージして問題ないと考えます。 |
- Persist the direct URL mode only after setOptions succeeds, so that a failure does not lock later calls into the direct mode. - Accept the relay fallback only from the exact relay page path. - Move the relay logic to services/sidePanelRelay.ts so that importing it has no side effects, and keep side_panel_relay.ts as a thin entry point. - Document the assumption that non-tab side panels accept a web URL as path, and that Chrome re-detects only on major updates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
2 件目のレビューありがとうございます。502ef32a で対応しました。 1.
|
レビュー結果Vivaldi の 要確認・改善提案
軽微な指摘
テストユニットテストは分岐(Vivaldi/Chrome 判定、sender 検証、似たパス、不正 tabId、UA 変更)を網羅しており良好です。追加するなら次のとおりです。
セキュリティhttp(s) 限定、sender の id と URL の厳密比較(クエリ・ハッシュ除去)、 全体として、方針・実装・テストとも良好です。上記 1 のみ、ブラウザの誤検出が固定化するリスクがあるため、対応を検討してもらえると安心です。 |
Vivaldi hosts the side panel as a tab, so content scripts in the side panel connect with sender.tab like normal tabs. The service worker treated them as normal tabs and never ran the pending side panel page action steps. - The relay page registers its own tab as a side panel host tab before navigating to the target URL. - onConnect treats connections from registered host tabs as side panel connections, and does not add them to connectedTabs so that they reconnect after navigation. - The registrations are kept in session storage and removed when the tab is closed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
レビュー結果Vivaldi でサイドパネルが マージをブロックする問題は見つかりませんでした。以下は改善提案と確認事項です。 指摘事項1.
2. 中継ページ直接アクセス時の誤登録(低)
3. Chrome 初回のみ中継ページを経由することについて(情報)
4. User-Agent をキーにしたキャッシュ(低)
5.
テストについて
その他
|
概要
Vivaldi で結果をサイドパネルに表示しようとすると、
ERR_FILE_NOT_FOUNDになる問題を修正します(サポート問い合わせ。Vivaldi 8.3.4191.44 / Selection Command 1.4.1)。原因
chrome.sidePanel.setOptions({ path })に外部 URL(https://...)をそのまま渡していました。pathは仕様上、拡張パッケージ内のリソースを指定するものです。pathに外部 URL を渡した場合chrome-extension://<id>/https://...→ ERR_FILE_NOT_FOUND対応
サイドパネルではまず拡張内の中継ページ(
src/side_panel_relay.html)を開き、そこから表示先 URL に切り替えます。chrome.tabs.getCurrent()でサイドパネルがタブとして扱われているかを調べます。Vivaldi ではタブが返り、Chrome ではundefinedが返ります。location.replace(url)で自分で移動します。sidePanelRelayFallbackを送り、Service Worker がpathに URL を直接設定します。chrome.storage.local(sidePanelDirectUrl)とメモリに保存します。2 回目以降は中継ページを経由せず、従来どおり直接設定します。つまり Chrome で中継ページを経由するのは、基本的に最初の 1 回だけです。sidePanel.open()をユーザー操作の扱いのまま呼ぶ必要があり、setOptionsは同期的に呼ばなければなりません。そのため判定結果は Service Worker 起動時にメモリに読み込んでおきます。setOptionsが成功した後にだけ保存します。失敗しても直接設定モードに固定されることはありません。navigator.userAgentです。ブラウザが更新されて userAgent が変わったら判定をやり直します(Chrome ではメジャーバージョンの更新時)。sidePanelRelayFallbackは、送信元が自分の拡張の中継ページ(クエリと#以降を除いて完全一致)で、URL が http(s)、tabIdが正の整数の場合にだけ受け付けます。pathに外部 URL を受け付けるとみなしています。確認したのは Chrome と Vivaldi だけで、Edge / Brave / Opera などは未確認です。Vivaldi でサイドパネルのページアクションが動かない問題
Vivaldi ではサイドパネルがタブとして扱われるため、サイドパネル内の content script が Service Worker に接続するときにも
sender.tabが付きます。Service Worker のonConnectは「sender.tabが無い接続 = サイドパネル」という前提で振り分けていたので、通常のタブとして登録するだけで、実行待ちのステップ(PA_SIDE_PANEL_PENDING)を実行していませんでした。エラーにはならず、何も起きないだけでした。タブの情報(active、index、windowIdなど)は裏で開いている普通のタブと区別がつかないため、次の方法で見分けます。registerSidePanelHostTabを Service Worker に送り、自分のタブ ID をサイドパネルのタブとして登録します。登録の完了を待ってから移動します。sender.tab.idを登録します。Service Worker が停止しても消えないよう、session storage(sidePanelHostTabs)にも保存し、タブが閉じられたら登録を消します。onConnectは、登録済みのタブからの接続をサイドパネルの接続としてhandleSidePanelConnectに回します。このときconnectedTabsには登録しません。登録すると、navigate ステップでページが移動した後に content script が再接続しなくなるためです。これで、サイドパネルで開く PageAction と AI サービスのコマンド(どちらも
PA_SIDE_PANEL_PENDINGを使う)が Vivaldi でも動くようになります。タイムアウトで判定しなかった理由: Chrome では移動を止められても何のシグナルも出ません。Navigation API の
committed/navigateerrorも発火しません。タイムアウトで判定すると、Vivaldi で表示に時間がかかるサイト(Gemini など)を「移動できなかった」と誤判定してしまいます。動作確認
ヘッドレス起動のブラウザで、ビルド済みの拡張を読み込んで確認しました。どちらのブラウザでも、サイドパネルの表示先が
http://127.0.0.1:8765/target.htmlになることを確認しています。chrome-extension://<id>/http://...になることを再現(問い合わせ内容と一致)yarn test/yarn lintが通る(lint は既存の warning のみ)chrome.tabs.getCurrent()が毎回タブを返すことを確認(5 回)。Chrome ではundefinedになりフォールバックに進むことも確認補足・未対応
sender.tabが付きます。そのためisSidePanel()は「サイドパネルではない」と判定し、useSidePanelNavigationによるリンクの横取りは働きません。ただし Vivaldi ではサイドパネル内の通常の遷移がそのまま動くので、実害はないと考えています。isSidePanel()の判定は、このPRでは対象外としています。🤖 Generated with Claude Code
https://claude.ai/code/session_01Pd1sH5ArKQDueJGVC1vMCK