fix(desktop): a file Luke showed opens at the commit his checkout read it at, not main's head
Summary
Dean: "Can we avoid the 'This file is not on main' issue? Can we read from whatever the sandbox has checked out?"
Where it came from. Only one way of opening a file hits it: a show_code card (and the "+" menu's rows for files Luke showed). The tree and ⌘K list main itself, and inbox items already pin their commit (#2228). Agents' work doesn't open the File tab. show_code reads the planning sandbox's checkout. That checkout is a depth-1 clone of the default branch, made at the session's first read and kept for the whole session. The File tab read GitHub's default-branch head instead, so a file main had moved or deleted since then showed "This file is not on main", and lit lines could drift.
Fix (no sandbox is woken):
show_code's probe already runs once per call. It now also printsgit rev-parse HEAD, so there is no extra sandbox call.ShownCodeandPlanCodecarry the result as an optionalcommit(commitShaSchemaon the wire). The JSON-schema goldens were re-recorded: the only change is the new optionalcommitkey.- A card's Open file / path, and the "+" menu's shown-file rows, pass that commit to the existing
onOpenFile(ref, commit)path that inbox items use. The tab reads the file at that commit through the sameGET /api/plans/{id}/file?ref=…read, so the GitHub link and copy use that commit too. - The bar quietly shows the short SHA (tooltip "Read at commit …") whenever a read is pinned to a commit. This includes inbox opens.
- Luke's notes and his snippet now show on a pinned tab when they were read at that same commit. Before this, a pinned tab hid them all.
- No ref known (code shown before this change, tree, ⌘K) behaves as before: it reads the default branch and still says "not on main" when the file is missing there. A missing file at a commit says "This file is not at commit … on GitHub, or the commit was never pushed."
Tests
apps/web/tests/show-code.test.ts: the answer carries the commit the checkout stands at. A checkout where git names no commit still shows the lines, with no commit. The sandbox double now prints a commit, as a real checkout does.packages/host/src/plan-code.test.ts: the coloured code keeps the commit.code-pane.test.ts: a card opens its file at its recorded commit, and with none when none was recorded.file-view.test.ts: a pinned read names its short SHA in the bar, and a head read names none. A pinned tab shows only the notes read at that commit.file-tab.test.ts: the snippet comes only from showings read at the tab's commit. The existing "not on main" test still passes unchanged for a read with no ref.
Evidence
- Platform-independent checks:
./scripts/check.shgreen locally (exit 0). - macOS Electron verification (
./scripts/verify.sh): not run. This was built on a Linux cloud VM, and CI cannot verify the Mac UI. LUKE-159 is the manual Mac pass. No screenshot is attached. The only visual change is a short monospace SHA in tertiary text, placed after the breadcrumbs in the File tab's bar.
🤖 Generated with Claude Code