Skip to content

feat(sessions): restore saved terminal tabs on startup - #287

Open
xsq15788 wants to merge 1 commit into
mainfrom
feat/session-restore
Open

xsq15788 wants to merge 1 commit into
mainfrom
feat/session-restore

Conversation

@xsq15788

Copy link
Copy Markdown
Contributor

No description provided.

@shihuili1218

Copy link
Copy Markdown
Collaborator

@codex

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T15:44:12.812619Z 27157ab Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27157abbf0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +251 to +252
} else {
void sessionRestore.initializeSecondaryWindow();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Synchronize restore toggles from secondary windows

When Shell Settings is opened in a clone or AI-handoff window, this initializes a separate webview-local store and leaves the restore switch editable. Toggling it writes the shared database, but the primary window's _enabled value is never updated; for example, enabling restoration from the secondary window leaves the primary window unable to persist its current tabs, so the next startup restores nothing despite the option being enabled. Either synchronize this preference between windows or prevent secondary windows from changing it.

Useful? React with 👍 / 👎.

Comment on lines +104 to +105
// Do not take over tabs the user opened while the backend was loading.
if (signal?.aborted || app.tabs().length !== 1) return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid auto-opening a second manually opened local tab

When a saved snapshot requires profile loading, resource panes have already been released, so the user can open a local terminal while these awaits are pending. This branch then returns false because tabs changed, which initializePrimarySessionWindow interprets as “no local terminal was restored” and follows with the open_local_on_startup action; if that preference is enabled, the manually opened local terminal is duplicated. The takeover result needs to suppress auto-open when a local tab already exists, or otherwise distinguish user takeover from an empty restore.

Useful? React with 👍 / 👎.

Comment on lines +73 to +74
const data = JSON.parse(raw);
if (data?.version !== 1 || !Array.isArray(data.terminals)) return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve snapshots with unsupported versions

If a user starts this build against a data directory previously used by a newer release whose snapshot version is not 1, this returns null while leaving _enabled true. restore() then marks the store ready, causing AppShell's persistence effect to immediately replace the unsupported snapshot with a version-1 empty/current snapshot. That destroys the newer release's saved session data on downgrade; an unknown version should disable persistence for the run or otherwise be preserved until it can be migrated.

Useful? React with 👍 / 👎.

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