Skip to content

fix(sessions): keep selectSession from reverting edits made during its detail read - #2358

Merged
vastsa merged 4 commits into
mainfrom
fix/select-session-stale-read
Nov 15, 2026
Merged

vastsa merged 4 commits into
mainfrom
fix/select-session-stale-read

Conversation

@vastsa

@vastsa vastsa commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Completes #2274 (author's two commits preserved) with the review feedback addressed.

  • The stale-read baseline is captured before workspace alignment (after the selection's own provisional commits), so an idle edit made while the project activates is no longer reverted.
  • Why not reuse a stale flag from loadSessionDetail: its baseline predates selectSession's provisional commits (retained pane / reusable empty), which move the cache entry themselves. Honoring it would commit the retained pane instead of the fresh detail; a regression test pins this.
  • A cache entry that vanished (eviction) is not treated as an edit.

Tests: session-select-stale-read 7/7 (adds the alignment-window edit, which fails on the previous head, and the retained-pane hydration guard); full apps/desktop node suite matches main apart from tests that need a built out/renderer (not built in the worktree); tsc --noEmit clean.

fixes #2273
Supersedes #2274

SeanLiu326 and others added 4 commits November 15, 2026 18:16
…s detail read

selectSession awaited the bounded detail read and then re-cached and committed its window unconditionally. An idle-session edit (message delete, revision switch) that landed while the read was in flight replaces the transcript cache entry, so committing the stale window reverted the edit on screen and in the cache. #2233 taught loadSessionDetail itself to refuse caching such a read; the caller-level commit now applies the same guard: when the cache entry moved during the read for an idle session, the commit keeps the edit writer's cache content and cached window instead.

Pinned by session-select-stale-read.test.mjs driving the real slice (superseded read keeps the edit; uneventful re-select still hydrates; running sessions still merge the live tail).
…e compare

The guard required a captured cache entry before comparing, so a read
that started with no transcript cache entry could never see the movement
an in-flight idle edit makes (undefined -> entry). The runtime guard
this mirrors (#2233) needs no such precondition; dropping it keeps the
caller-level compare aligned with that semantics. Warm re-selects are
unaffected: the comparison is the same reference check it always was,
and a quiet read whose runtime write replaces the entry still resolves
to the same window content.
The guard captured the cache entry just before awaiting the detail, but
the read starts earlier and selectSession awaits workspace alignment in
between, so an idle edit made while the project activated still got
reverted by the stale window.

The baseline is now taken right after the selection's own provisional
commits and before alignment. It cannot come from loadSessionDetail's
own refusal signal: that baseline predates those provisional commits,
which move the cache entry themselves, so a retained background pane
would be mistaken for an edit and the fresh detail never committed. A
cache entry that disappears (eviction) is no longer treated as an edit.

fixes #2273
@vercel

vercel Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
pi-desktop Error Error Nov 15, 2026 1:18pm UTC
pi-desktop-1794748666713-wLQJ Canceled Canceled Nov 15, 2026 1:18pm UTC

@vercel
vercel Bot temporarily deployed to Preview – pi-desktop-docs November 15, 2026 10:32 Inactive
@vastsa
vastsa merged commit 043d11c into main Nov 15, 2026
7 of 8 checks passed

This branch was previously deployed

1 inactive deployment
Preview – pi-desktop-docs — 2dccb6f6 Deployed Nov 15, 2026 by vercel[bot]
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.

selectSession re-caches and commits a stale detail window, reverting an idle edit made during the read

2 participants