feat(sessions): session identity — shared resolver, codev session CLI, copy menu and details view
What
Ways to get at what identifies a Claude Code session — its title, full id, account, project path, transcript path and resume command — from the Sessions tab and from a terminal, across every account.
- One resolver (
src/cli/session-identity.ts) used by the app and by a new CLI. codev sessionCLI, next tocodev account:list,show,view,self,resume.- Copy actions in the Sessions tab: a right-click menu on a row, and
⌘⇧Cfor the selected row. - A details view of the same fields, each line click-to-copy, in two forms to try: an overlay (
⌘I) and a panel under the row (⌘↓).
Why
- To hand a session to another Claude Code session you need its title (its
/renamename); to read it you need its transcript path; to resume it somewhere else you need the resume command under the right account. Today each of these means digging in~/.claude. claude -rsees one config directory. CodeV already knows every account, so the CLI can list and resume across all of them.
The resolver
src/cli/session-identity.tsholds the history scan, the transcript lookup, the title rule (custom title over generated title), matching by id or title, and the resume command.src/cli/session-identity-fields.tsis the part with no Node imports, so the renderer can import it.- The main process now uses the same code for
readClaudeSessions, the title rule,buildResumeCommand,findTranscriptPathandcopyResumeCommand— one copy, not two. Everything the CLI imports lives insrc/cli/, because the CLI is compiled with plaintscintoresources/cli. - Behaviour change: the copied resume command now single-quotes the project path (
cd '…' && …) instead of double-quoting it, so a path with a space or a$pastes correctly.
Where a transcript lives (checked, not assumed)
The work started from a suspicion that the app looked for transcripts under the wrong projects/<slug> directory. It does not. A transcript is filed under the slug of the session's own working directory, not under the git common directory that auto-memory uses. Counts from 363 transcripts on one two-account machine:
| Where the session started | Filed under its own cwd slug |
|---|---|
| Repository subdirectory | 2 of 2 |
Linked worktree (not a /branch copy) | 18 of 18 |
Repository root (not a /branch copy) | 121 of 121 |
| Not a repository, or the directory is gone | 205 of 205 |
The 17 transcripts whose first recorded cwd did not match were all /branch copies, which begin with their parent's records. So the existing lookups are unchanged. The resolver additionally checks that the file exists, and for reading only it can fall back to searching every project directory.
codev session
| Command | What it does |
|---|---|
list [--path <dir>] [--account <name>] [--all | --limit N] | Sessions, newest first. --path . = sessions whose project is this directory |
show <title | id> | Every field, for every matching session |
view <title | id> [--last N] | The last N things the user and the assistant said (text only) |
self | The session this command is running in |
resume <title | id> | Resume in the current terminal, under the session's own account |
list,show,viewandselfprint one line of JSON on stdout (agents are the main consumer);--prettyprints text for people.resumeprints a shell command instead (see below). Errors go to stderr. Exit status: 0 found, 1 no match, 2 ambiguous or bad usage. An unknown option is bad usage, not ignored.<title | id>is a full session id, the first four or more hex characters of one (hyphens allowed), or a title — the/renamename or, when there is none, the generated title. Part of a title matches only when nothing matches outright.--pathlists every match unless--limitis given; without--paththe default is 30 rows.- A title is not unique (
/branchcopies share theirs), soshowlists every match, andview/resumelist the candidates and exit non-zero instead of picking one. resumeprints the command and thecodev()shell function evaluates it, soclaudeis a child of the user's shell and not of the app binary. Stdout carries only the command; a non-zero status evaluates nothing.resumerefuses when the transcript or the project directory is gone. A session id must be hex-shaped before any path or command is built from it.selfwalks parent process ids to the nearest one with asessions/<pid>.jsonin any account directory, and requires the file's recorded process start time to equal the live process's, so a leftover file from a reused pid is rejected. A registration with no recorded start time is trusted only when the environment's session id names the same session.viewreads back from the end of the file and skips tool calls, tool results, thinking and harness wrapper records.- Titles are read by scanning back from the end of the transcript, not by
grep: macOSgreptook about 1.5 s on one 255 MB transcript; the backward scan took about 0.55 s for all 363.
Sessions tab
- The copy menu is drawn inside the window, not as a native menu: in Menu Bar mode the window hides when it loses focus, and a native menu could trigger that. Each item shows a shortened preview of what it copies. Arrows, Enter and Esc work; a marked comment shows where a future "Hide session" item goes.
⌘⇧Ccopies the reference (title + full id) and confirms in the banner. Clipboard writes go through the main process.- One
SessionDetailcomponent, two thin hosts taggedHOST B(overlay) andHOST C(inline) so that either can be deleted once it is clear which one gets used.⌘↓used to behave like plain↓(the old handler ignored the modifier); it now opens the inline panel.
Verification
-
npx tsc --noEmit: 0 errors.yarn test: 320 tests pass on the branch withmainmerged in (which brings the Session Preview change, 1.0.95). Fixtures follow the shape of real transcript and history records, with invented values. Guards were mutation-checked (ambiguity refusal inpickOne,resumeandview; the shell function's|| return $?in zsh and bash;self's process-start comparison and its refusal of an untied registration; rejection of unknown options; the four-character minimum for an id prefix). -
CLI run against real config directories, read-only:
show,list --path .,list --all(836 rows, 1.3 s),view --last 4,self.resumewas run only to print its command. -
Run in the dev app (
yarn start), driven by events dispatched into the page: the Sessions list loads through the refactored history scan; right-click opens the menu with all items and previews; arrow + Enter copies and the banner confirms, with focus back in the search box;⌘⇧Ccopies the reference (clipboard content checked);⌘Iopens the overlay with all seven fields;⌘↓opens the inline panel. That run found that a row near the bottom opened its panel below the fold — fixed and re-run. After review round 1 the dev app was run again: the overlay takes focus, arrows move focus between rows, Enter copies and Esc returns focus to the search box; the menu's active item is exposed to assistive technology; a search that filters the expanded row away removes the inline panel and the next Esc clears the search; Esc with the panel open closes only the panel. -
The packaged app (
yarn make, built before review round 1) bundles the CLI:listandselfwere run through the app binary withELECTRON_RUN_AS_NODEand returned correct results. -
Tested by hand on a packaged build (
yarn make, at the round-2 head) in both Normal App and Menu Bar mode: the copy menu,⌘⇧C, the overlay, the inline panel (including the scroll into view), and the CLI through the generatedcodev()shell function —listwith--path,--account,--all,showby full id, id prefix and part of a title,view --last,selfinside a session of each of two accounts and in a plain terminal (not found, exit 1), a realresumeof a session of each account, the refusal on an ambiguous query (exit 2), an unknown option, an unknown command,help, andcodev account list. Duplicate titles were run through the packaged CLI directly:showlisted both sessions;viewandresumerefused with exit 2, full ids on stderr and nothing on stdout. -
That testing found one bug, fixed in review round 3 and re-run in the dev app: with the overlay (or the menu) open, hiding the window with the global shortcut and showing it again put focus back in the search box, and the next Esc hid the whole window with the overlay still open. Esc now closes the open layer first.
-
Round 3's other UI changes were run in the dev app too: hovering an overlay row moves focus to it and Enter copies that row; the overlay has a maximum height and scrolls.
Not verified:
- Round 3's changes on a packaged build (they were run in the dev app with events dispatched in the page, not typed).
- The inline panel's focus ring.
- Whether
selffollows a/branch.
Known limits
-
The resume command of a default-account session carries no
CLAUDE_CONFIG_DIR, so it fails (No conversation found) when run in a shell that already has the variable set for another account — for examplecodev session resumerun from inside another account's session. This is the existing command format, not new here; it is tracked in grimmerk/codev#172 (related, not resolved by this PR). -
For a session whose transcript is not under its own project slug, the app looks it up in an index of all project directories that is kept for 30 seconds, so a transcript that appears elsewhere can read as not found for up to that long.
-
In the inline details panel the rows can take focus but cannot be reached with Tab from the search box, because the app already uses Tab to switch between the Projects and Sessions tabs. The overlay (
⌘I) is the keyboard path. -
The CLI lists sessions that appear in
history.jsonl. A session that was never prompted, and VS Code or Desktop sessions, do not appear inlist/show/view/resume;selfworks for them. -
For an account that shares the anchor's auto-memory, building the resume command writes the same per-project settings file the app already writes.
Version 1.0.96, with CHANGELOG, README and design-doc entries. main (1.0.95) is merged in, with both CHANGELOG entries kept; the merged tree was run in the dev app (the Session Preview settings and the session details work side by side). One more open change takes 1.0.97.
🤖 Generated with Claude Code