Skip to content

Fix session restoration for all tab types and extension tab timing#303

Merged
Stasshe merged 8 commits intomainfrom
copilot/fix-content-restoration-issue
Feb 1, 2026
Merged

Fix session restoration for all tab types and extension tab timing#303
Stasshe merged 8 commits intomainfrom
copilot/fix-content-restoration-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 1, 2026

Session restoration only worked for code editor tabs. Other tab types (diff, ai, webPreview, extension tabs) either failed to restore or opened empty. Extension tabs showed "no active tab" due to race between session restore and extension registration.

Root Causes

  • DataCloneError: tabState.panes is a Valtio proxy—can't be cloned by IndexedDB's Structured Clone Algorithm
  • File-centric restoration: Only matched tabs by path, ignoring tab types with different data structures (diffs, suggestedContent, etc.)
  • Extension timing: Tab restoration completes before extensions register their tab types

Changes

Tab-type driven restoration (TabTypeDefinition)

  • needsSessionRestore?: boolean — tabs declare if they need content restoration
  • serializeForSession?: (tab) => Tab — custom serialization logic
  • restoreContent?: (tab, context) => Promise<Tab> — custom restoration logic

Session storage fixes

  • Use snapshot(tabState.panes) before saving to IndexedDB
  • Extension tabs preserve all data (including code, bundledPages) during serialization
  • Simplified SessionRestoreContext to use getFileByPath() instead of passing projectFiles array

Extension tab UX

  • Added addChangeListener to TabRegistry for registration notifications
  • PaneContainer subscribes and re-renders when extension registers
  • DraggableTab shows spinner icon while extension is loading
// Extension tabs now preserve all data during session save
if (tab.kind.startsWith('extension:')) {
  const { needsContentRestore, ...rest } = tab;
  return rest; // keeps code, bundledPages, etc.
}

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:

  • cdn.jsdelivr.net
    • Triggering command: /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1208/chrome-headless-shell-linux64/chrome-headless-shell /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1208/chrome-headless-shell-linux64/chrome-headless-shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AvoidUnnecessaryBeforeUnloadCheckSync,BoundaryEventDispatchTracksNodeRemoval,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Transl (dns block)
  • www.googletagmanager.com
    • Triggering command: /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1208/chrome-headless-shell-linux64/chrome-headless-shell /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1208/chrome-headless-shell-linux64/chrome-headless-shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AvoidUnnecessaryBeforeUnloadCheckSync,BoundaryEventDispatchTracksNodeRemoval,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Transl (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>コンテンツ復元・セッション保存</issue_title>
<issue_description>コンテンツの復元がコードエディターしかできてない。
他の種類のタブが復元できない。
復元できるタブもあるが、空のタブが開くだけで、中身は何も表示されない。

difftabなども。

無駄なサニタイズやフォールバックもいらない。エラーやバグが潰されてしまい、余計デバッグがややこしくなる。

セッション復元系を一新する必要があるかもしれない。
それぞれのタブで、復元するときの動作を定義するか?でも、これなら単純にタブを開く時に毎回filereoository から使用するか?

コードエディタのコンテンツはvaltioで上位レイヤーとしてメモリで管理し、そのあとデバウンスでidbに保存するという仕組み。

拡張機能によって登録されるタブも考慮する必要がある。

バイナリタブやコンテンツのストリングは、セッションストアに保存するべきではない。SSOTがわからんくなるから。

appinitializerも注目。
ここにセツション復元系の処理を集約したほうが良いか?

しかし、page.tsxでもしているしなぁ…
loading...のとこは残した方が良さそうやし。</issue_description>

<agent_instructions>かなり難しい問題です。いきなり取り掛かるのではなく、十分すぎるくらいに調査と研究を繰り返し、体系的かつ洗練された、拡張性ある対症療法的でない、完璧な計画を立ててから、高度な修正を。無駄なコードはあまり増やしたくないが、それが本当に必要なコードならば問題ない。時間はどれだけかかってもいい。型の修正が必要ならばしても良い。実装の前に、本当にそれで良いのか、一度考え直すという姿勢が大事です。拡張機能タブのテストはreact-previewが良いかも。src/homepageにすでにあるし、react-build src/homepage --tailwindとしたらタブが開くから、それから数秒したらセッションが保存されるから、それでもう一度再読み込みして内容が表示されるか。</agent_instructions>

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
@Stasshe Stasshe temporarily deployed to copilot/fix-content-restoration-issue - pyxis-code PR #303 February 1, 2026 04:26 — with Render Destroyed
Copilot AI changed the title Add tab-type driven session restoration system Fix session restoration for non-editor tabs and DataCloneError Feb 1, 2026
…oration

Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
Copilot AI changed the title Fix session restoration for non-editor tabs and DataCloneError Fix session restoration for non-editor tabs and extension tab timing Feb 1, 2026
…tension tab data

Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
@Stasshe Stasshe temporarily deployed to copilot/fix-content-restoration-issue - pyxis-code PR #303 February 1, 2026 05:09 — with Render Destroyed
Copilot AI changed the title Fix session restoration for non-editor tabs and extension tab timing Fix session restoration for all tab types and extension tab timing Feb 1, 2026
@Stasshe Stasshe marked this pull request as ready for review February 1, 2026 05:16
@Stasshe Stasshe merged commit 91bd1e8 into main Feb 1, 2026
@Stasshe Stasshe deleted the copilot/fix-content-restoration-issue branch February 1, 2026 05:17
@Stasshe Stasshe mentioned this pull request Feb 5, 2026
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