Repository navigation
fix(client): a re-pair drops the last person's thread state kept in memory - #1156
Merged
Merged
Conversation
…emory A thread's last state is retained in memory so a reopen paints at once, and that object outlived a re-pair: opening one of the last person's threads by link could briefly show it. A state retained before the credential was replaced is now dropped where it is read. Fixes #1147 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
This review includes 4 billable files and costs up to $1.00.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 49 minutes for your next included review. View limit details
|
…'s ownership The old thread state could write its snapshot back between the thread atom's early drop and the successor taking ownership. The drop now clears the owner with the snapshot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jacksondr5
enabled auto-merge (squash)
November 22, 2026 16:59
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A thread's last state is retained in memory (
ThreadResumeCacheinpackages/client-runtime/src/state/threads.ts), so a reopen paints at once. That object is keyed by environment and thread, not by credential, and it outlived a re-pair. After an Owner phone re-paired as a narrower person, opening one of the Owner's threads by link could briefly paint the Owner's retained state of it. Closes #1147.What changed
J5-owned
dropReplacedRetainedState(packages/client-runtime/src/j5/replacedCredential.ts) reuses #1146's replaced-credential count. It records the count each retained state was last read under, and drops the state when a re-pair has bumped the count since.threads.tscalls it at the two places the retained state is read:makeEnvironmentThreadState, which seeds a new thread state from it, and the thread atom, which paints it before the live stream. Dropping a state also clears itsowner, so upstream'sownerchecks refuse the old thread state's writes from the drop onward, before the successor takes ownership.Web shares
threads.ts, so its saved remote servers get the same behaviour.UI changes
None captured. The leak is a single paint before the server refuses the new credential, and reproducing it on a device needs a re-pair followed by a deep link to one of the previous person's threads within the same launch. Per the Captain, the test is the proof here.
Upstream impact
packages/client-runtime/src/state/threads.ts: FORK.md case 125, whose row this file already has. Two calls plus the import.Council review
Checklist
threads-sync.test.ts, "does not recreate a cache a re-pair cleared from its finalizer", now checks that the successor starts with no retained data; it fails on j5/mainFORK.md(case text and file-table row) in this PRdocs/j5/product/upstream.md(none: upstream's credentials all read the whole server)AGENTS.md): web and mobile sharethreads.tsdocs/j5/product/and user docs rewritten where this changes them (no change needed)Built by Claude Opus 5.5 in Claude Code (J5 Code Crew builder seat).
🤖 Generated with Claude Code