Follow-up to Koohoko's 3d6f8b8e, after review.
- Cost: assemble asks DesktopTitles once per native Claude Desktop
session, and each call globbed and stat'ed every local_*.json, so a
list of N Cowork sessions looked at the metadata N times. The names
are now one index, rebuilt at most once a second (desktopTitlesHeld);
a rename in Desktop shows within that second. Files are read through
filememo, the shared reader the usage resolver already uses for these
same files, which also catches a same-size rewrite inside one mtime
tick (the patch's own size+mtime cache didn't).
- A record that is there but doesn't parse (Desktop midway through a
write) keeps its last parse instead of dropping to the bare id; a
record gone still takes its names with it.
- Handles: Claude.app 2.7032's LocalSessionManager (app.asar, read-only)
counts unarchivedCliSessionId as a live handle beside cliSessionId and
preClearCliSessionId as lineage beside priorCliSessionIds, and runs a
record with no cliSessionId under its sessionId without "local_".
All are named now; the raw "local_..." id no longer is (no usage
record carries it).
- Siblings: MergeExternalStats (the Sessions page's stats summaries)
and the Context page named gateway-only Desktop sessions by the
recorded prompt or nothing; both use the Desktop name now.
- docs/subsystems/gateway-sessions.md says all of the above.
Real layout: no Desktop session records exist on this Mac or the
Windows box (only claude_desktop_config.json), so field names and types
were checked against Claude.app 2.7032's own reader/writer code: a
string title, string cliSessionId/unarchivedCliSessionId/
preClearCliSessionId, an array priorCliSessionIds, files
<account>/<org>/local_*.json under claude-code-sessions and
local-agent-mode-sessions. Dirs come from desktopdir.Everywhere, the
resolver the other Desktop session readers use (Windows %APPDATA% and
MSIX LocalCache, Linux ~/.config); Windows/Linux not run.
Run: new tests TestDesktopSessionTitleHandles, TestDesktopSessionTitleInStats,
TestDesktopTitlesReadOncePerList, and context checks in
TestDesktopSessionTitlesOnPages. Each broken by hand went red:
rescan per call -> "metadata looked at 12 times, want once"; no
last-good -> "a half-written file lost its names"; no unarchived/stem ->
missing ids; stats without the name -> "stats titles map[cli-s:Recorded
prompt ...]"; Context without it -> "context titles map[...: ...]".
go test -race -count=20 -run TestDesktop ./internal/sessions;
go test -tags nogui ./... (sandbox HOME, pinned caches): all ok but
internal/plugin's TestPiPackage (pi-codemode export missing; passes
alone, doesn't import sessions or gui), filed as #1879; gofmt -l;
go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./...; go build, GOOS=linux go build -tags nogui, GOOS=windows go build.
GUI: routing-sessions, session-identity, sessions-overview,
sessions-bar-names, sessions-gateway-delete, sessions-manage,
context-window in Chromium and WebKit (84/84 each).
Real binary: magpie web under a sandbox HOME with Claude-3p Code and
Claude Cowork fixture records and five claude-desktop usage records;
the Sessions page (Chromium, WebKit) showed both titles on current,
prior and unarchived ids and the bare id on the unmatched one;
/api/gateway/session-titles named them; a rename showed after 1.3s;
a half-written file kept the name; deleting the record went back to
the id.
Co-authored-by: Koohoko <koohoko@gmail.com>