Skip to content

リンクプレビューの開き方にSidePanel選択肢を追加#299

Open
Copilot wants to merge 8 commits intomainfrom
copilot/add-sidepanel-link-preview
Open

リンクプレビューの開き方にSidePanel選択肢を追加#299
Copilot wants to merge 8 commits intomainfrom
copilot/add-sidepanel-link-preview

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

リンクプレビューの開き方がPopupとWindowのみだったところに、SidePanelを追加。また、SidePanel使用時の自動非表示動作をオプションページから制御できるUIを追加。

変更点

新しいプレビューモード

  • DRAG_OPEN_MODEPREVIEW_SIDE_PANEL = "previewSidePanel" を追加(const.ts
  • linkPreview.ts: PREVIEW_SIDE_PANEL 選択時は既存の BgCommand.openSidePanel IPC コマンドを使用してSidePanelを開く
if (command.openMode === DRAG_OPEN_MODE.PREVIEW_SIDE_PANEL) {
  if (!isEmpty(href)) {
    Ipc.send<OpenSidePanelProps>(BgCommand.openSidePanel, { url: href })
  }
  return
}

設定UI

  • SettingForm.tsx のウィンドウ設定セクションに windowOption.sidePanelAutoHide のSwitchFieldを追加
  • 既存の closeSidePanel ハンドラ(action/helper.ts)がこの設定を参照してSidePanelを自動的に閉じる動作は実装済みだったが、設定UIが未実装だった

i18n

  • 全14言語ロケールに Option_openMode_previewSidePanelOption_sidePanelAutoHideOption_sidePanelAutoHide_desc を追加(各言語で翻訳済み)

Warning

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
    • Triggering command: /opt/hostedtoolcache/node/24.13.1/x64/bin/node /opt/hostedtoolcache/node/24.13.1/x64/bin/node --conditions node --conditions development /home/REDACTED/work/selection-command/selection-command/node_modules/tinypool/dist/entry/process.js (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.13.1/x64/bin/node /opt/hostedtoolcache/node/24.13.1/x64/bin/node --conditions node --conditions development /home/REDACTED/work/selection-command/selection-command/node_modules/tinypool/dist/entry/process.js main tnet/tools/git (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>リンクプレビューの開き方の選択肢に、sidePanelを追加する</issue_title>
<issue_description>- [ ] リンクプレビューの開き方の選択肢として、Popup, Windowに加えてSidePanelを追加する

  • SidePaneでプレビューした場合は、メインのパネルをクリックしたらプレビューを非表示にする
  • この自動でサイドパネルを閉じる動作は、設定により無効化できる</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits February 27, 2026 23:26
Co-authored-by: ujiro99 <677231+ujiro99@users.noreply.github.com>
… keys

Co-authored-by: ujiro99 <677231+ujiro99@users.noreply.github.com>
Copilot AI changed the title [WIP] Add sidePanel option for link preview display リンクプレビューの開き方にSidePanel選択肢を追加 Feb 27, 2026
# Conflicts:
#	packages/extension/src/components/option/SettingForm.tsx
@codecov
Copy link

codecov bot commented Feb 28, 2026

Codecov Report

❌ Patch coverage is 7.80142% with 130 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.99%. Comparing base (9f3f13e) to head (eb6f85c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...kages/extension/src/hooks/useSidePanelAutoClose.ts 0.00% 39 Missing ⚠️
packages/extension/src/action/helper.ts 7.69% 24 Missing ⚠️
...ension/src/components/option/field/SwitchField.tsx 0.00% 23 Missing ⚠️
...es/extension/src/components/option/SettingForm.tsx 0.00% 19 Missing ⚠️
...ckages/extension/src/services/settings/settings.ts 16.66% 10 Missing ⚠️
packages/extension/src/action/linkPreview.ts 0.00% 9 Missing ⚠️
packages/extension/src/components/Popup.tsx 0.00% 2 Missing ⚠️
packages/extension/src/services/chrome.ts 0.00% 2 Missing ⚠️
packages/extension/src/background_script.ts 75.00% 1 Missing ⚠️
packages/extension/src/services/backgroundData.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #299      +/-   ##
==========================================
- Coverage   19.03%   18.99%   -0.05%     
==========================================
  Files         312      313       +1     
  Lines       28845    28949     +104     
  Branches     1322     1324       +2     
==========================================
+ Hits         5490     5498       +8     
- Misses      23355    23451      +96     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ujiro99 ujiro99 marked this pull request as ready for review March 1, 2026 13:08
@ujiro99 ujiro99 requested a review from Copilot March 1, 2026 13:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

リンクプレビューの開き方に「SidePanel」モードを追加し、SidePanel 表示時の自動非表示(オートクローズ)挙動を設定画面から制御できるようにする変更です。既存の SidePanel IPC を活用しつつ、タブ追跡データ(BgData)に「リンクプレビュー由来かどうか」を持たせて設定分岐できるようにしています。

Changes:

  • リンクプレビューの新規モード PREVIEW_SIDE_PANEL を追加し、選択時に SidePanel を開く処理を実装
  • SidePanel の自動非表示設定(通常コマンド用 / リンクプレビュー用)を UI・設定型・デフォルト・移行に追加
  • SidePanel のタブ追跡を拡張(tabId に加えて isLinkCommand を保持)し、onClosed 等でクリーンアップ

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/extension/src/types/index.ts LinkCommand 設定に sidePanelAutoHide を追加
packages/extension/src/test/setup.ts chrome.sidePanel.onClosed のテスト用モックを追加
packages/extension/src/services/sidePanelDetector.ts sidePanelTabs の新型に追従(some で判定)
packages/extension/src/services/sidePanelDetector.test.ts sidePanelTabs の新型に合わせてテスト更新
packages/extension/src/services/settings/settings.ts 0.15.0 向け移行(linkCommand.sidePanelAutoHide)を追加
packages/extension/src/services/option/defaultSettings.ts sidePanelAutoHide のデフォルト値を追加
packages/extension/src/services/chrome.ts OpenSidePanelPropsisLinkCommand を追加 / close の後処理を整理
packages/extension/src/services/backgroundData.ts sidePanelTabs をオブジェクト配列化(isLinkCommand を保持)
packages/extension/src/hooks/useSidePanelAutoClose.ts SidePanel 表示中のクリックで自動クローズする hook を新規追加
packages/extension/src/hooks/useSettings.test.tsx LinkCommand 設定のモックに sidePanelAutoHide を追加
packages/extension/src/const.ts DRAG_OPEN_MODE.PREVIEW_SIDE_PANEL を追加
packages/extension/src/components/option/field/SwitchField.tsx SwitchField に tooltip 表示を追加
packages/extension/src/components/option/SettingForm.tsx SidePanel 自動非表示の設定 UI を追加(link/window)
packages/extension/src/components/Popup.tsx useSidePanelAutoClose を組み込み
packages/extension/src/background_script.ts SidePanel close イベント等で追跡データをクリーンアップ
packages/extension/src/action/linkPreview.ts LinkPreview の SidePanel オープン分岐を追加(isLinkCommand: true
packages/extension/src/action/helper.ts SidePanel の open/close とクリーンアップを isLinkCommand 対応で拡張
packages/extension/src/action/helper.test.ts sidePanelTabs 新型に合わせてテスト更新
packages/extension/public/_locales/zh_CN/messages.json SidePanel 新規UI/モード文言を追加
packages/extension/public/_locales/ru/messages.json SidePanel 新規UI/モード文言を追加
packages/extension/public/_locales/pt_PT/messages.json SidePanel 新規UI/モード文言を追加
packages/extension/public/_locales/pt_BR/messages.json SidePanel 新規UI/モード文言を追加
packages/extension/public/_locales/ms/messages.json SidePanel 新規UI/モード文言を追加
packages/extension/public/_locales/ko/messages.json SidePanel 新規UI/モード文言を追加
packages/extension/public/_locales/ja/messages.json SidePanel 新規UI/モード文言を追加(既存表記も調整)
packages/extension/public/_locales/it/messages.json SidePanel 新規UI/モード文言を追加
packages/extension/public/_locales/id/messages.json SidePanel 新規UI/モード文言を追加
packages/extension/public/_locales/hi/messages.json SidePanel 新規UI/モード文言を追加
packages/extension/public/_locales/fr/messages.json SidePanel 新規UI/モード文言を追加
packages/extension/public/_locales/es/messages.json SidePanel 新規UI/モード文言を追加
packages/extension/public/_locales/en/messages.json SidePanel 新規UI/モード文言を追加
packages/extension/public/_locales/de/messages.json SidePanel 新規UI/モード文言を追加

Comment on lines +31 to +49
useEffect(() => {
if (tabId == null) return
if (!sidePanelVisible) return

// Determine which setting to use based on whether this is a link command
const autoHideEnabled = isLinkCommand
? userSettings?.linkCommand?.sidePanelAutoHide
: userSettings?.windowOption?.sidePanelAutoHide

// Only enable auto-close if the setting is enabled
if (!autoHideEnabled) return

const close = () => Ipc.send(BgCommand.closeSidePanel)

window.addEventListener("click", close)
return () => {
window.removeEventListener("click", close)
}
}, [tabId, sidePanelVisible, userSettings, isLinkCommand])
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • useSidePanelAutoClose はクリックイベントの登録/解除と、設定値(linkCommand.sidePanelAutoHide / windowOption.sidePanelAutoHide)の分岐という挙動が追加されていますが、同種の hook(例: useSidePanelNavigation)にはテストがある一方で本 hook にはテストがありません。
  • BgData.watch の更新に応じてリスナーが付く/外れること、isLinkCommand によって参照設定が切り替わること、クリックで BgCommand.closeSidePanel が送信されることを最低限カバーするテストを追加してください。

Copilot generated this review using guidance from repository custom instructions.
Comment on lines 245 to +249
}
if (versionDiff(data.settingVersion, "0.15.0") === VersionDiff.Old) {
data.settingVersion = VERSION as Version
data = migrate0_15_0(data)
}
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • migrate() 内で settingVersion を先に VERSION に更新しているため、0.14.3 の移行が走ったケース(=古い設定)では、その直後の 0.15.0 判定が Old にならず migrate0_15_0() がスキップされる可能性があります。
  • その結果、linkCommand.sidePanelAutoHide が追加されず、SettingFormz.boolean() で読み込み時に不整合が起き得ます。
  • 対応案: 移行判定は「元の settingVersion」を基準にする / settingVersion の更新は全移行の最後にまとめて行う / もしくは各ブロックで VERSION ではなく対象バージョン(例: "0.14.3")へ段階的に更新する、のいずれかに揃えると安全です。

Copilot uses AI. Check for mistakes.
Comment on lines +180 to +186
BgData.update((data) => {
const { [tabId]: _, ...rest } = data.sidePanelUrls
return {
sidePanelTabs: data.sidePanelTabs.filter((t) => t.tabId !== tabId),
sidePanelUrls: rest,
}
})
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • sidePanelClosed() 内の BgData.update(...)await されていないため、更新が完了する前に関数が終了します。
  • BgData.updatePromise を返すので、例外も try/catch で拾えず(未処理の Promise rejection になり得ます)、タブ削除/サイドパネル閉鎖時のクリーンアップが不安定になります。
  • await BgData.update(...) として、必要なら呼び出し側(イベントリスナ)でも非同期の完了を待たない前提でエラーハンドリングだけ担保してください。

Copilot uses AI. Check for mistakes.
Comment on lines 9 to 23
@@ -14,7 +19,7 @@ export class BgData {
public pageActionStop: boolean
public activeScreenId: string | null
public connectedTabs: number[]
public sidePanelTabs: number[]
public sidePanelTabs: SidePanelTab[]
public sidePanelUrls: Record<number, string>
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • sidePanelTabs の型が number[] から SidePanelTab[] に変わっていますが、chrome.storage.sessionSESSION_STORAGE_KEY.BG)に旧形式の配列が残っている場合、t.tabId アクセスで実行時エラー/判定ミスになります。
  • 対応案: BgData の constructor で sidePanelTabs を正規化し、要素が number の場合は { tabId: n, isLinkCommand: false } に変換して後方互換を確保してください。

Copilot uses AI. Check for mistakes.
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.

リンクプレビューの開き方の選択肢に、sidePanelを追加する

3 participants