Repository navigation
fix(server): prevent legacy terminal history collisions across threads - #24574
Conversation
The legacy history filename is the sanitized thread id, so a thread id such as "terminal_YQ" names thread "a"'s current history file. Opening that thread migrated thread "a"'s history into it and removed the original, and deleting its history removed thread "a"'s file. Skip the legacy lookup, migration, and deletion when the legacy name has the current "terminal_" prefix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ent threads A thread id such as "terminal_YQ" sanitizes to the same legacy filename that thread "a" uses today, so opening it migrated and deleted thread "a"'s history, and closing with deleteHistory removed it again. Legacy names now resolve to nothing when they carry the "terminal_" prefix, so read, delete, and thread-wide delete all leave the other thread's file alone. One test covers all three paths. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
On case-insensitive filesystems (macOS, Windows) a thread id such as "Terminal_YQ" produced a legacy name that did not match the "terminal_" prefix check yet resolved to another thread's current terminal_YQ.log, so readHistory migrated it and deleteHistory removed it. Compare the prefix without case so the reserved namespace covers every casing. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
# Conflicts: # apps/server/src/terminal/Manager.test.ts # apps/server/src/terminal/Manager.ts
…thread's file Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — The change prevents ambiguous legacy filenames from being read, migrated, or deleted as another thread's terminal history. Current history paths remain unchanged, and skipped legacy files are left intact. You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Main replaced the legacy size guard with historyPaths/historyExists; the terminal_ namespace guard now gates the legacy entry in historyPaths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EvidenceEvidence from the real server on Linux with a case-sensitive filesystem, driven through WebSocket RPC. Screenshots and recordings show the driver's live server-response transcript, not the web terminal UI. For each operation, use fresh data: open
Reproduction and capture driver · Base transcript · Head transcript All three reported collisions reproduced on base and were absent on head. The mixed-case Not shown:
|
Brings in upstream through 96051c6 (pingdotgg#24574). No conflicts. - WSL backends start in the Linux home (pingdotgg#35719); Cody's ~/.cody home and the forwarded Windows sign-in helper are unchanged. - OpenCode explicit background waits (pingdotgg#35272) sit beside Cody's fork cut in the OpenCode 2 adapter.
pingdotgg#24574) Co-authored-by: Batuhan1999 <Batuhan.Ckr@outlook.de> (cherry picked from commit 96051c6)
pingdotgg#24574) Co-authored-by: Batuhan1999 <Batuhan.Ckr@outlook.de> (cherry picked from commit 96051c6)






Legacy history lookup could resolve another thread’s current history file, exposing its scrollback or deleting it. The server now rejects legacy filenames in the case-insensitive
terminal_namespace across migration and both deletion paths.Original description by @Batuhan1999
Problem
A legacy terminal history filename can collide with another thread's current history file. Opening or deleting a terminal for a client-supplied ID such as
terminal_YQcan read or remove threada's history.Change
Reserve the
terminal_namespace, ignoring letter case, in one legacy-name resolver. History migration, individual terminal deletion and whole-thread deletion all use that resolver. Current history handling and ordinary legacy migration remain intact.Scope and approval
Preserves @Batuhan1999's original contribution in #18671, originally separated from #18669. Main snapshot a3ca1a57d6 is integrated with contributor ancestry retained. This changes the server's history filename handling; clients, contracts and providers are unchanged.
Verification
At 9f70943e77, based on a3ca1a57d6:
Filesystem behavior was exercised on Linux. The mixed-case protection for case-insensitive macOS/Windows filesystems was reviewed from source but was not run on those filesystems. No separate browser/device session was needed for this server filesystem change.
Implementation and tests: Claude Opus 5.5 and Claude Fable 5.1 through T3 Code. Independent review: Claude Opus 5.5 and GPT-6.1 Sol, standard service tiers.
Takeover
Credits @Batuhan1999’s original contribution in #18671; contributor ancestry is retained on this replacement branch.
Adapted the guard to main’s bounded-filename API and shared it with whole-thread deletion. Replaced the original regression with lowercase and mixed-case lifecycle cases.
Reserved-prefix legacy files are intentionally ignored because they can overlap encoded or hashed current history filenames.
Evidence
Fixture matrix · Runtime capture report · Public drivers, transcripts and logs
Captures: before 909e4c9482, after dc98776633. Linux x64 / Node 26.12.1; real files, inert-PTY service scenarios plus real node-pty and WebSocket RPC. All seeds are synthetic, in fresh homes under
/tmp/ev-18671; no live userdata. No render path changed, so UI captures and pixel diffs do not apply. What else changed: no behavior beyond guarded legacy resolution and deletion; ordinary/current-history controls agree.Verification log