Skip to content

fix(tui): stop stale instances from erasing pinned sessions - #45117

Open
rareboe wants to merge 1 commit into
anomalyco:devfrom
rareboe:fix/44736-pin-race
Open

rareboe wants to merge 1 commit into
anomalyco:devfrom
rareboe:fix/44736-pin-race

Conversation

@rareboe

@rareboe rareboe commented Aug 26, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #44736

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Each TUI instance loads session.json once and rewrites the whole pin list from its own copy, so a stale instance erases pins added by another one.

Pin/unpin is now applied to the file's current contents under Flock, the same approach createModelPreferenceRepository already uses for model preferences. The UI still updates immediately.

Retargeted from dev to v2 and reimplemented on top of the current code.

How did you verify your code works?

Added a concurrent-writers test in test/context/local.test.ts: the old snapshot write ends up with a single pin, the new code keeps all of them. bun run check passes. bun test in packages/tui matches clean v2 (the only two failures are the shell-output timeout tests, which also fail without this change).

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Each TUI instance loaded session.json once and rewrote the whole pin list from
its own copy, so an instance holding a stale snapshot erased pins added by
another one. Two writers starting from an empty list end up with a single pin.

Apply each pin or unpin to the file's current contents under Flock, the same
approach createModelPreferenceRepository already uses for model preferences.
The store still updates immediately and is reconciled once the write lands.
@rareboe
rareboe force-pushed the fix/44736-pin-race branch from f80db4d to 0d757e6 Compare October 7, 2026 09:23
@rareboe
rareboe changed the base branch from dev to v2 October 7, 2026 09:24
@thdxr
thdxr changed the base branch from v2 to dev October 10, 2026 19:06

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.

Pinned sessions can be lost when multiple TUI instances write session.json

1 participant