Skip to content

fix(sessions): a link to a gone session shows no other session (#1168) - #1180

Merged
agegr merged 1 commit into
mainfrom
fix/1168-gone-session-link
Oct 11, 2026
Merged

agegr merged 1 commit into
mainfrom
fix/1168-gone-session-link

Conversation

@agegr

@agegr agegr commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Closes #1168.

Problem

Opening /?session=<id> for a session that no longer exists, in a browser profile that already has workspace memory, showed the project's last open session instead, and the URL changed to /. Nothing said the linked session was gone. The path, as the reporter traced it:

  1. SessionSidebar calls onInitialRestoreDone() when the id isn't in its list, then adopts the most recent project.
  2. That cwd change reaches AppShell.handleCwdChange().
  3. restoreWorkspaceContext() there picks up pi-web:last-open-by-workspace.

Change

  • lib/initial-navigation.ts: withTabOpen() marks an id that came from this tab's memory (sessionFromTab). linkedSessionId() returns the id only when it came from the URL.
  • components/AppShell.tsx: when the linked id is missing, handleInitialRestoreDone sets a one-shot skipWorkspaceRestoreRef. The next handleCwdChange (the sidebar adopting its project) then shows a fresh composer instead of restoring that project's last session. Later project switches restore as before.
  • components/SessionSidebar.tsx: shows a "This session no longer exists" toast in that case. The string is added to en / zh-CN / zh-TW.
  • A gone session that only this tab remembered (URL /) still falls back as before.
  • demo/lib/initial-navigation.ts is mirrored, and docs/agents/sessions.md has a short note.

Verification

  • The new test in components/AppShell.workspace-memory.test.mjs drives the real AppShell callbacks the way the sidebar calls them on first load. The URL case fails against main (it restores p1-last) and passes here; the tab-memory case keeps its fallback. lib/initial-navigation.test.mjs covers linkedSessionId().
  • tsc --noEmit, eslint, and 151 unit tests (initial-navigation, the AppShell tests, the SessionSidebar tests, i18n, tab-session) pass.
  • node e2e/run.mjs passed 19/19 in 4 of 7 runs on this branch: 3/3 in a clean clone, plus a later run in my worktree. The 3 failures were all at e2e/run.mjs:492, waiting for "Hide sidebar" after returning from the 320px viewport. That is a known flaky step. In the same worktree, main passed 3/3 at that point, and the branch passed there later once .next was rebuilt.
  • Not checked by hand in a browser. On phones the toast sits in the closed drawer, as every sidebar toast does.

🤖 Generated with Claude Code

Opening /?session=<id> for a session that no longer exists, in a browser
profile with workspace memory, showed the project's last open session and
replaced the URL with it. The sidebar reported the missing session
(onInitialRestoreDone), adopted its most recent project, and that cwd change
went through handleCwdChange's cross-project branch, which restores the
workspace's last open session.

When the missing id came from the URL (linkedSessionId(); withTabOpen() now
marks a tab-memory id with sessionFromTab), handleInitialRestoreDone sets
skipWorkspaceRestoreRef and the next handleCwdChange keeps a fresh
composer. The sidebar toasts "This session no longer exists". Later project
switches restore as before; a gone session only this tab remembered still
falls back as a fresh tab does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@agegr
agegr merged commit e83280e into main Oct 11, 2026
4 checks passed
@agegr
agegr deleted the fix/1168-gone-session-link branch October 29, 2026 13:01
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 6, 2026
…#1168) (agegr#1180)

Opening /?session=<id> for a session that no longer exists, in a browser
profile with workspace memory, showed the project's last open session and
replaced the URL with it. The sidebar reported the missing session
(onInitialRestoreDone), adopted its most recent project, and that cwd change
went through handleCwdChange's cross-project branch, which restores the
workspace's last open session.

When the missing id came from the URL (linkedSessionId(); withTabOpen() now
marks a tab-memory id with sessionFromTab), handleInitialRestoreDone sets
skipWorkspaceRestoreRef and the next handleCwdChange keeps a fresh
composer. The sidebar toasts "This session no longer exists". Later project
switches restore as before; a gone session only this tab remembered still
falls back as a fresh tab does.

Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
…#1168) (agegr#1180)

Opening /?session=<id> for a session that no longer exists, in a browser
profile with workspace memory, showed the project's last open session and
replaced the URL with it. The sidebar reported the missing session
(onInitialRestoreDone), adopted its most recent project, and that cwd change
went through handleCwdChange's cross-project branch, which restores the
workspace's last open session.

When the missing id came from the URL (linkedSessionId(); withTabOpen() now
marks a tab-memory id with sessionFromTab), handleInitialRestoreDone sets
skipWorkspaceRestoreRef and the next handleCwdChange keeps a fresh
composer. The sidebar toasts "This session no longer exists". Later project
switches restore as before; a gone session only this tab remembered still
falls back as a fresh tab does.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

A link to a deleted session opens the project's last session instead

1 participant