Skip to content

fix(extension): Vivaldi でサイドパネル表示モードが動作しない問題を修正 - #560

Draft
ujiro99 wants to merge 2 commits into
mainfrom
fix/vivaldi-side-panel
Draft

ujiro99 wants to merge 2 commits into
mainfrom
fix/vivaldi-side-panel

Conversation

@ujiro99

@ujiro99 ujiro99 commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

概要

Vivaldi で結果をサイドパネルに表示しようとすると、ERR_FILE_NOT_FOUND になる問題を修正します(サポート問い合わせ。Vivaldi 8.3.4191.44 / Selection Command 1.4.1)。

原因

chrome.sidePanel.setOptions({ path }) に外部 URL(https://...)をそのまま渡していました。path は仕様上、拡張パッケージ内のリソースを指定するものです。

ブラウザ path に外部 URL を渡した場合 拡張ページから外部 URL への移動
Chrome URL として解決され、表示される(仕様外の挙動) 止められる(エラーも出ない)
Vivaldi 拡張のオリジンの後ろに連結され chrome-extension://<id>/https://... → ERR_FILE_NOT_FOUND 許可される

対応

サイドパネルではまず拡張内の中継ページ(src/side_panel_relay.html)を開き、そこから表示先 URL に切り替えます。

  • 中継ページはまず chrome.tabs.getCurrent() でサイドパネルがタブとして扱われているかを調べます。Vivaldi ではタブが返り、Chrome では undefined が返ります。
    • タブとして扱われている場合(Vivaldi): location.replace(url) で自分で移動します。
    • タブではない場合(Chrome など): Service Worker に sidePanelRelayFallback を送り、Service Worker が path に URL を直接設定します。
  • 直接設定できることが分かったら、その結果を chrome.storage.local(sidePanelDirectUrl)とメモリに保存します。2 回目以降は中継ページを経由せず、従来どおり直接設定します。つまり Chrome で中継ページを経由するのは最初の 1 回だけです。
    • sidePanel.open() をユーザー操作の扱いのまま呼ぶ必要があり、setOptions は同期的に呼ばなければなりません。そのため判定結果は Service Worker 起動時にメモリに読み込んでおきます。
  • sidePanelRelayFallback は、送信元が自分の拡張の中継ページで、URL が http(s) の場合にだけ受け付けます。

タイムアウトで判定しなかった理由: Chrome では移動を止められても何のシグナルも出ません。Navigation API の committed / navigateerror も発火しません。タイムアウトで判定すると、Vivaldi で表示に時間がかかるサイト(Gemini など)を「移動できなかった」と誤判定してしまいます。

動作確認

ヘッドレス起動のブラウザで、ビルド済みの拡張を読み込んで確認しました。どちらのブラウザでも、サイドパネルの表示先が http://127.0.0.1:8765/target.html になることを確認しています。

  • Chrome(Playwright 付属 Chromium): 1 回目は中継ページから直接設定に切り替わり、2 回目は直接設定で表示される
  • Vivaldi 8.3.4191.44(Linux 版): 1 回目、2 回目とも中継ページ経由で表示される
  • 修正前の方式では、Vivaldi でサイドパネルの URL が chrome-extension://<id>/http://... になることを再現(問い合わせ内容と一致)
  • yarn test / yarn lint が通る(lint は既存の warning のみ)
  • Windows 版 Vivaldi で、Gemini などの実サービスを使って表示されることを確認
  • Chrome の通常起動(ヘッドあり)で、初回に表示がちらつかないことを確認

補足・未対応

  • Vivaldi ではサイドパネル内のコンテンツスクリプトにも sender.tab が付きます。そのため isSidePanel() は「サイドパネルではない」と判定し、useSidePanelNavigation によるリンクの横取りは働きません。ただし Vivaldi ではサイドパネル内の通常の遷移がそのまま動くので、実害はないと考えています。
  • サイドパネルを使うページアクション(serviceWorker-sidePanel.ts)は、Vivaldi では確認していません。

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pd1sH5ArKQDueJGVC1vMCK

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
@ujiro99

ujiro99 commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

@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>

Copilot AI commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

main をマージし、service_worker.ts の競合を解消しました。マージコミットは 148282b です。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants