Skip to content

fix(workbench): handle stale workspace resume memory - #1271

Merged
wyuc merged 2 commits into
mainfrom
fix/workspace-stale-session-resume
Aug 29, 2026
Merged

fix(workbench): handle stale workspace resume memory#1271
wyuc merged 2 commits into
mainfrom
fix/workspace-stale-session-resume

Conversation

@wyuc

@wyuc wyuc commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Closes #1270.

Problem

Entering the Pro workspace from classic mode resumes the last-opened conversation from localStorage. Two rough edges: a remembered session that no longer exists still navigates to /workspace?session=<id> and fails to load with no fallback; and returning to the workspace home is never remembered, so the next entry resumes the last session again.

Change

  1. Stale resume guardWorkspaceShell validates the session that matched entry memory against the owner session list it already loads (no new endpoint, no duplicate fetch, entry is not blocked). On a miss, validateRememberedWorkspaceSession() forgets the stale id and replaces the route with the clean /workspace home. Direct (unremembered) session links are not affected.
  2. Home memory — the existing storage key now accepts a private home sentinel. rememberWorkspaceHome() writes it when both workspace panes are absent; readLastWorkspaceSessionId() maps it back to null, so the classic entry and workspaceResumeHref() keep their existing contracts and resolve to /workspace. Opening a conversation overwrites the sentinel.

All reads/writes/deletes retain best-effort storage-unavailable handling.

Tests

Added unit coverage for the home sentinel and stale-id forget-on-miss in workspace-session-memory, plus shell-level guard coverage. Typecheck, touched-file lint/prettier all clean.

Remember explicit workspace home visits and validate remembered session entries against the existing workspace session list before resuming. Stale entries now fall back to the workspace home and are forgotten.

Closes #1270
@wyuc
wyuc requested a review from CXuPercy August 28, 2026 08:45

@CXuPercy CXuPercy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified locally against the PR head (worktree + both touched test files, 34/34). This is a clean, well-scoped fix — every load-bearing assumption checked out:

The stale-resume guard triggers exactly where it should. rememberedResumeSessionId is armed only when the URL's session param equals the localStorage memory value — i.e., only memory-driven resumes get validated. A shared deep link to an unremembered session leaves the guard inert, and there's a dedicated test pinning that distinction.

No partial-list false positive — the property I was most worried about. The guard waits for sessionState === 'ready', and in OwnerSessionClient 'ready' is emitted only after a successful full REST fetch ("this snapshot is a full read of the list... Unconditionally authoritative"), so the membership check always sees the complete owner session list, never a partial or stream-only view.

The home sentinel is collision-free and contract-preserving. Real session ids can't equal the sentinel string; readLastWorkspaceSessionId maps it back to null so workspaceResumeHref and the classic entry keep their existing behavior; forgetWorkspaceSession's match-only-delete semantics coexist with the sentinel correctly; opening a conversation overwrites it naturally. The behavior is also self-consistent after the guard fires: the replace-to-home transition lands in the memory effect and writes the home sentinel, which matches "the user's last state was home."

Storage-unavailable handling is retained on every new read/write path, and the "course open without a conversation writes nothing" middle state is documented as deliberate in the description. Nothing to change from my side.

@wyuc
wyuc merged commit 64cfb3c into main Aug 29, 2026
5 checks passed
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.

Pro workspace resumes a stale session on entry and never remembers "home"

2 participants