Repository navigation
Show file learnings in worktree sessions - #741
anirudhkumar-nanonets wants to merge 1 commit into
Conversation
trail check flags TELEMETRY.md:71 and hooks.ts:175 against the Oct 27 learning on Claude's real HOME (word matches on "Claude ... copy ... project"), and hooks.ts:187 against the Oct 22 learning on filtering inside listNotes: this only changes which checkout listNotes reads, no filter is added.
🌱 graft blast radius3 areas changed → 9 areas can be affected. 26 dependent symbols, depth 2. flowchart TB
A0(("Claude Session State<br/>12 symbols"))
A1(("Initialization Flow<br/>3 symbols"))
A2(("Cloud Collaboration<br/>3 symbols"))
A3(("Notes Storage<br/>2 symbols"))
A4(("Event Telemetry<br/>2 symbols"))
AX(("4 smaller areas<br/>4 symbols"))
classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
class A0,A1,A2,A3,A4 reached;
classDef tail fill:#EEF2F3,stroke:#9AA4A9,stroke-width:1px,color:#3A4247;
class AX tail;
Who knows this code — 2 people across 12 areas
Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no All 26 dependent symbols, grouped by areaClaude Session State — 12 symbols in 12 files
Initialization Flow — 3 symbols in 3 files
Cloud Collaboration — 3 symbols in 3 files
Notes Storage — 2 symbols in 2 files
Event Telemetry — 2 symbols in 2 files
CLI Skills — 1 symbol in 1 file
CLI Entry Point — 1 symbol in 1 file
Learning Sessions — 1 symbol in 1 file
MCP Tools — 1 symbol in 1 file
Test signal per changed area — 1 ✓ · 1 ✗ · 1 –Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.
54 test suites also reference this code54 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.
Open the interactive graph → — click an area to see its dependent symbols at file:line. |
The issue: in a Claude Desktop worktree session, learnings never reached Claude when it opened or edited a file they list.
Why: the hooks take the main checkout as the project (
CLAUDE_PROJECT_DIR), solearningsOnTouchnamed the worktree's file.claude/worktrees/<name>/src/..., which matches no learning'stouches. It also read learnings from the main checkout instead of the worktree's branch.The fix: when the file is in another checkout of the same repo,
learningsOnTouchnames the file and reads learnings from that checkout. A newlearnings_on_touchevent counts each learning shown this way, and whether it came through a worktree.Moves: learnings that reach Claude on file touch in worktree sessions =
learnings_on_touchwithworktree=truein PostHog (Metabase db 11,posthog_event_full_view). Today: 0. No event existed. In a worktree session the true value was also 0, because of this bug.What changed
src/notes/home.ts:otherCheckout(checkout, file)returns the checkoutfileis in when it's another checkout of the same repo (a linked worktree), comparing the shared git dirs by real path. A file in the project's own checkout, outside git, or in another repo (a submodule included) gives null, so those cases behave as before.src/claude/hooks.tslearningsOnTouch: names the file, and reads the learnings, from that checkout. Session state still lives with the project.learnings_on_touchevent (via: read, edit or command;worktree: true or false) incontract.tsandTELEMETRY.md.Tests
worktree=truefor the worktree's copy andfalsefor the main checkout's.npm testwith a scratch HOME: 4,134 pass and 3 fail (graft-to-trail,hosts-trail,upkeep-hooks). The same 3 fail on unchanged main.trail check: 3 conflicts, none of them real.TELEMETRY.md:71andhooks.ts:175are word matches ("Claude … copy … project") against the Oct 27 learning on Claude's real HOME.hooks.ts:187matches the Oct 22 learning on filtering insidelistNotes; this only changes which checkoutlistNotesreads, and adds no filter.End to end, on an isolated machine
This uses the scratch "Priya" machine from the #738 test: its own HOME, git identity, clone and
trail init, with trail installed from a packed build. Claude runs from her main clone and reads her worktree's copy ofsrc/retry.ts, the way the desktop app works. A learning on the worktree's branch lists that file.learnings_on_touchwas queued with via=read and worktree=true.Notes for review
learningsOnTouch(it passesdirtonotesOnTouchfor its stale check). The two merge cleanly. Once both are in, that call should passrepo, so the stale check looks at the worktree's code.editOverlap). It usescheckoutRootwithout the same-repo check, which is fine there because another repo's git has none of the cached branches.🤖 Generated with Claude Code