feat(session): live marker, lastActivity, self fields; details on ⌘→
Summary
Three gaps found while first using the codev session command-line interface (CLI), batched in one pull request (PR), plus a key change for the session details panel. Version 1.0.99.
1. Which sessions are running (list, show). Every session in the JSON now carries live, and pid and status (busy / idle) when it is running. list --live shows only running sessions (all of them, not the newest 30); list --not-live shows the rest. Data comes from each account's sessions/<pid>.json, the same registration self already reads (src/cli/session-self.ts), now read for every pid with one ps call.
- A session counts as running only when its pid is alive and the process started at the time the file states (
procStart), so a leftover file whose pid was reused does not count. A file with noprocStart(older Claude Code) does not count either, the same ruleself'sproofForapplies. - Running sessions that
history.jsonldoes not have (a fresh/branchcopy before its first prompt) are now listed, shown and resumable too. --prettygains aLIVEcolumn, and its legend always explains✗(transcript gone, cannot be resumed). It was read as "not running" before.
2. lastActivity. lastActive is the last prompt: history.jsonl records only what the user types. So a session that worked for two hours after one prompt still showed the prompt time. lastActivity is the later of that and the last timestamped record in the transcript, read by scanning back from the end of the file (shared with view's reader). lastActive is unchanged.
- Why "the later of": one real session had a prompt in
history.jsonl16 hours after the last record in its transcript, so the transcript alone would show activity older than the last prompt. - A transcript usually ends in records that carry no timestamp (
cost-state,bridge-session,custom-title, …). The scan skips them and reads only a record's own top-leveltimestamp.
3. self JSON now has lastActive, promptCount, lastActivity and live: true. self --pretty already printed the first two.
4. Details panel under a row: ⌘→ opens, ⌘← closes (Esc too). ⌘↓ / ⌘↑ still work. ↑ / ↓ move between sessions, so the same arrows with ⌘ doing something else felt wrong. In the search box, ⌘→ keeps its usual "caret to the end" job until the caret is at the end, and only then opens the panel. Settings → Shortcuts gets a Selected Session section (⌘→ / ←, ⌘I, ⌘⇧C, right-click). None of these keys were listed anywhere in the app.
Measured
list --liveon a machine with two accounts listed 29 running sessions, the same count as the registration files whose process is alive.list --allover 844 sessions: 0.95 s → 1.45 s (reading each transcript's tail, plus oneps).- macOS
ps -pfails the whole call, printing nothing, when one pid is out of range (process id too large). Without a fallback, one odd file name would show every session as stopped. A real-pstest caught this; the reader now retries one pid at a time.
Tests
- 141 CLI tests pass (
yarn vitest run src/cli);tsc --noEmitis clean; the CLI also compiles with the packagingtscflags (--target es2020) and runs. - New tests: the live marker with a reused pid,
--live/--not-live, a running session that is not in history,lastActivityvslastActive, the--prettylegend,self's new fields,isLive,registrationFrom,readProcessesagainst the realps, andreadLastActivityat chunk sizes that split lines. - Mutation-checked: removing the start-time comparison, restoring the executable-name fallback for a file with no
procStart, removing the "later of" rule, and removing the--not-livefilter each turn tests red. - Follow-up: #175. The Sessions tab and this CLI use different rules for "running"; that issue proposes making them one.
- The CLI tests inject the process lookup, so a fixture pid can never match a real process on the test machine.
- The
⌘→/⌘←change has no automated test; the UI keys have none in this repo. A packaged 1.0.99 build is being tried by hand.
🤖 Generated with Claude Code
Summary by CodeRabbit
- New Features
- Session listings now identify currently running sessions, including sessions not yet present in history, and show last-prompt and last-activity times.
- Added
--liveand--not-livefilters, with updated default listing limits for live or path-based searches. - Updated session detail shortcuts and added selected-session shortcuts to the help panel.
- Documentation
- Updated session CLI, output fields, and keyboard shortcut guidance.
- Chores
- Updated the app version to 1.0.99.