Repository navigation
fix(sessions): keep sibling dirs that share the home prefix unshortened in tool path display - #96562
Conversation
… path display shortenPath matched the home directory with a bare startsWith, so a path that only shares the home prefix as a substring (home /home/user vs /home/username, or C:\Users\He vs C:\Users\Helen) was rewritten to a bogus "~..." display. Gate the rewrite on a path separator after the home dir, matching shortenHomePath in src/utils.ts, and collapse the home directory itself to "~".
|
Codex review: needs maintainer review before merge. Reviewed June 24, 2026, 8:37 PM ET / 00:37 UTC. Summary PR surface: Source +3, Tests +27. Total +30 across 2 files. Reproducibility: yes. Source inspection shows current main and v2026.6.10 rewrite any string starting with Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Next step before merge
Security Review detailsBest possible solution: Land the narrow helper and regression-test fix after ordinary maintainer review, preserving copy-pasteable session tool paths without changing the broader path-display policy. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main and v2026.6.10 rewrite any string starting with Is this the best way to solve the issue? Yes. The PR fixes the local session renderer at the implicated helper and matches the separator-bounded behavior already used by AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8a5cb85c31e5. Label changesLabel justifications:
Evidence reviewedPR surface: Source +3, Tests +27. Total +30 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
What Problem This Solves
The
read(and other session tool) output in the TUI shortens home paths for display viashortenPath. It decided a path was "under home" with a barepath.startsWith(home), with no check for a path separator after the home directory. So a sibling directory that merely shares the home string as a prefix gets mangled:/home/me, the tool shows/home/metrics/out.logas~trics/out.logC:\Users\He, the tool showsC:\Users\Helen\notes.mdas~len\notes.mdThe displayed path is wrong and no longer copy-pasteable, which is the opposite of what the shortening is supposed to do.
Why This Change Was Made
src/utils.tsalready gets this right inshortenHomePath: it special-casesinput === homeand otherwise only rewrites when the home segment is followed by a separator (${home}/or${home}\\). The TUI helper just predated that and never picked up the boundary check. This change bringsshortenPathin line with the existing helper:~when the path is exactly the home directory/or\(so real subpaths still shorten, siblings don't)This is the same class of bug as #88449 (which fixes
shortenHomeInStringand the terminal-core display helper). That PR doesn't touchsrc/agents/sessions/tools/render-utils.ts, so this is a complementary fix for the one remaining helper with the naive prefix match.User Impact
Session tool output displays sibling-of-home paths verbatim instead of corrupting them. Real subpaths under home keep shortening to
~/...exactly as before, and the home directory itself now collapses to~.Evidence
Before/after behavior, captured by running the actual
shortenPathexported fromsrc/agents/sessions/tools/render-utils.tsin this PR's checkout (HEAD77137f14b) against the same helper onmain. I bundled each real module with esbuild and called the exported function directly.shortenPathonly depends onnode:os, so the unrelated TUI imports in that file are not in its call path; theos.homedir()value is redacted to/home/alicethrough the environment:mainmangles the two sibling paths that only share the home string as a prefix (~-backup/app.tsand~2/tmp/x.log). This PR leaves them intact while still shortening a real subpath and collapsing the home directory itself to~.The PR also adds a
shortenPathblock torender-utils.test.tscovering the same cases: a real subpath shortens, the home dir collapses to~, a sibling sharing the prefix is left untouched, an unrelated path is untouched, and non-string input returns"". I couldn't run the full vitest suite end to end on my Windows machine, since a clean install pulls several heavyweight native packages (including@rolldown/binding-win32-x64-msvc) that don't fetch reliably here, so that test runs in CI rather than locally.Note for maintainers
This PR was prepared with AI assistance (Claude Code). I verified the bug, the fix, and the tests myself before opening it.