M33: Claude Code conversations as blocks (index, read, continue, fork) #72

Closed
opened 2026-10-02 21:14:41 +00:00 by jhgaylor · 1 comment
Owner

Depends on: S20 (done 2026-10-02, spikes/s20-conversations, no ticket).

Conversations track. Every Claude Code conversation on a machine, from a terminal or the desktop app's Code tab, shows up in illogical as a block you can read and continue. Claude Desktop chats are out of scope (they live on claude.ai).

Most of it exists: an agent block whose config holds a session_id resumes that session, and Stopped is a block with no process. A past conversation is a stopped Claude agent block with that id and a transcript read from its jsonl. The plan's M33 section (PLAN.md, "Conversations track") is the full spec; S20's README has the evidence and fixtures/ the test data.


  1. The index (daemon).
    • Watch ~/.claude/projects (or $CLAUDE_CONFIG_DIR/projects) with inotify. Index each session's id, cwd (from its lines; the directory slug is lossy), git branch, entrypoint, title, first prompt, last activity, message count and size.
    • The title comes from custom-title or agent-name, else the latest ai-title, else the first prompt. relocated moves the cwd; continued-in and forkedFrom link sessions (the picker shows a fork under its original).
    • Read only the start and end of each file, as the SDK's listSessions does. Keep the index in the state directory, keyed by path with mtime and size, so a restart only rereads files that changed. The index builds in the background and never delays startup.
    • Sources: terminal (cli), desktop (claude-desktop; title, model and isArchived from the app's local_*.json by cliSessionId, archived ones hidden like missing folders) and other.
    • Left out:
      • sessions any agent block of this daemon has ever had (the daemon keeps a set of them, ended blocks included);
      • sidechain and subagent files;
      • sessions with no prompt;
      • sessions whose cwd no longer exists, which is how test daemons' /tmp/ilg-* sessions disappear, except desktop ones (their scratch workspace is deleted with the session; Continue creates the folder again, empty). Show all brings these back.
    • Liveness: a session is live while a process in ~/.claude/sessions holds it and that pid is still alive (procStart must equal field 22 of /proc/<pid>/stat, so a reused pid doesn't count). /proc/<pid>/cgroup then names its scope; illogical-pane-<N>-….scope is pane N. If it is, the pane's PaneInfo gets the session id, and the conversation says Live in pane %N.
    • Each daemon indexes its own machine. M25's fleet view gathers them from every host, the Mac included.
  2. The converter (jsonl to transcript::Entry).
    • File order, not the parentUuid chain (S20). A prompt whose parent already had a later child is a rewind and gets a Note before it.
    • user text becomes User, with a leading <system-reminder> (the desktop app puts one on the first prompt) removed. assistant content becomes Agent for text, Thought for thinking, and Tool for a tool_use (name, title, and for Bash the command). A tool_result fills in that tool's output and its status (completed, or failed when is_error is set). A compaction becomes a Note ("Conversation compacted"); its summary line (isCompactSummary) is skipped. Slash-command lines (<command-name>, <local-command-stdout>, <local-command-caveat>) become one Note (/model haiku), and the adapter's own /model lines are dropped. Lines of one API response share message.id; a subagent call is a Tool whose output is the agent's answer (its own transcript stays in subagents/).
    • Meta lines, attachments, bookkeeping and unknown types are skipped, so a new Claude Code version shows less rather than breaking.
    • It is pure and synchronous, and is unit tested against S20's fixtures.
  3. Conversations as stopped blocks.
    • Opening a conversation creates a Claude agent block that is Stopped. Its config holds cwd, session_id and imported: true, and its transcript comes from the converter. No process starts, so opening costs only the reading.
    • While the conversation is live elsewhere, the block reads its jsonl again on every change, so you can follow a terminal session from the phone, read-only.
    • The header names the source and where it is live (Live in pane %4, Live in Claude desktop, Live in a terminal, pid 1234). capture --text, history and search work on it like any agent block.
  4. Continue, or fork when it's live.
    • Not live: Continue starts claude-agent-acp through the existing start path. The block already has a transcript, so it sends session/resume with no replay. The block's log begins with the imported entries as one imported record, so a restart or reboot restores the block as M6b does.
    • Live in one of our panes: Go to pane is the main action.
    • Live anywhere else: Fork calls session/fork, then session/resume on the new id (fork doesn't open it), and the block's session_id becomes the fork's. The original is left alone. Continuing is offered again once that process exits. There's no Continue anyway: S20 lost a writer's turns that way.
    • Imported blocks pass settingSources: ["user","project","local"] and settings: {disableAllHooks: true} (S20 item 3), and set the session's last model (the last assistant line's message.model) after resuming, since a resume resets it.
  5. Pickers.
    • Web: a Conversations picker grouped by project (cwd). It searches titles and first prompts, filters by live, source and machine, and opens into a new tab or the focused pane.
    • TUI: the same picker on a key.
    • CLI:
      • illogical claude ls [--cwd D] [--live] [--json];
      • illogical claude open <id|prefix> prints the block id;
      • illogical agent --resume <id> and --fork <id> continue a conversation directly.
    • MCP: list_conversations and open_conversation.

Tests:

  • unit tests for the converter (S20's fixtures, branches, unknown line types) and the index (incremental rescans, what's left out, liveness with a reused pid);
  • a daemon test with a fake ~/.claude and the fake ACP agent: opening starts no process, Continue sends session/resume with the id, Fork sends session/fork, and the block restores after a restart;
  • web/e2e/conversations.spec.ts: a seeded ~/.claude shows up in the picker, opens and continues. Dev and test daemons always pass --socket.

Done when:

  • a Claude Code session run in a plain terminal outside illogical and then exited shows up in the picker within 2 s, with its title and folder, and opens with its whole transcript (tool calls and their output) without starting anything;
  • Continue gets a reply that uses the earlier context, and claude --resume <id> in a terminal then shows the new turns;
  • a session still open in a terminal shows as live, its block follows new turns, and Fork continues it without changing the terminal's jsonl;
  • a session in an illogical pane says which pane and jumps there;
  • a desktop Code tab session shows up as desktop and continues;
  • our own agent blocks and test daemons' sessions don't show up;
  • geek's 386-plus transcripts index cold in the background, with the time measured, and a restart only rereads files that changed;
  • a continued block survives a daemon restart and a reboot like any agent block.

Not in M33:

  • Claude Desktop chats;
  • cloud sessions (claude.ai/code);
  • full-text search across transcripts that aren't open;
  • Codex and other agents' histories (the same shape would fit, behind the index's source).
**Depends on:** S20 (done 2026-10-02, `spikes/s20-conversations`, no ticket). *Conversations track. Every Claude Code conversation on a machine, from a terminal or the desktop app's Code tab, shows up in illogical as a block you can read and continue. Claude Desktop chats are out of scope (they live on claude.ai).* Most of it exists: an agent block whose config holds a `session_id` resumes that session, and `Stopped` is a block with no process. A past conversation is a stopped Claude agent block with that id and a transcript read from its jsonl. The plan's M33 section (PLAN.md, "Conversations track") is the full spec; S20's README has the evidence and `fixtures/` the test data. --- 1. **The index (daemon).** - Watch `~/.claude/projects` (or `$CLAUDE_CONFIG_DIR/projects`) with inotify. Index each session's id, cwd (from its lines; the directory slug is lossy), git branch, entrypoint, title, first prompt, last activity, message count and size. - The title comes from `custom-title` or `agent-name`, else the latest `ai-title`, else the first prompt. `relocated` moves the cwd; `continued-in` and `forkedFrom` link sessions (the picker shows a fork under its original). - Read only the start and end of each file, as the SDK's `listSessions` does. Keep the index in the state directory, keyed by path with mtime and size, so a restart only rereads files that changed. The index builds in the background and never delays startup. - **Sources:** terminal (`cli`), desktop (`claude-desktop`; title, model and `isArchived` from the app's `local_*.json` by `cliSessionId`, archived ones hidden like missing folders) and other. - **Left out:** - sessions any agent block of this daemon has ever had (the daemon keeps a set of them, ended blocks included); - sidechain and subagent files; - sessions with no prompt; - sessions whose cwd no longer exists, which is how test daemons' `/tmp/ilg-*` sessions disappear, except desktop ones (their scratch workspace is deleted with the session; *Continue* creates the folder again, empty). *Show all* brings these back. - **Liveness:** a session is live while a process in `~/.claude/sessions` holds it and that pid is still alive (`procStart` must equal field 22 of `/proc/<pid>/stat`, so a reused pid doesn't count). `/proc/<pid>/cgroup` then names its scope; `illogical-pane-<N>-….scope` is pane N. If it is, the pane's `PaneInfo` gets the session id, and the conversation says *Live in pane %N*. - Each daemon indexes its own machine. M25's fleet view gathers them from every host, the Mac included. 2. **The converter (jsonl to `transcript::Entry`).** - **File order**, not the `parentUuid` chain (S20). A prompt whose parent already had a later child is a rewind and gets a `Note` before it. - `user` text becomes `User`, with a leading `<system-reminder>` (the desktop app puts one on the first prompt) removed. `assistant` content becomes `Agent` for text, `Thought` for thinking, and `Tool` for a tool_use (name, title, and for Bash the command). A `tool_result` fills in that tool's output and its status (completed, or failed when `is_error` is set). A compaction becomes a `Note` ("Conversation compacted"); its summary line (`isCompactSummary`) is skipped. Slash-command lines (`<command-name>`, `<local-command-stdout>`, `<local-command-caveat>`) become one `Note` (`/model haiku`), and the adapter's own `/model` lines are dropped. Lines of one API response share `message.id`; a subagent call is a `Tool` whose output is the agent's answer (its own transcript stays in `subagents/`). - Meta lines, attachments, bookkeeping and unknown types are skipped, so a new Claude Code version shows less rather than breaking. - It is pure and synchronous, and is unit tested against S20's fixtures. 3. **Conversations as stopped blocks.** - Opening a conversation creates a Claude agent block that is `Stopped`. Its config holds `cwd`, `session_id` and `imported: true`, and its transcript comes from the converter. No process starts, so opening costs only the reading. - While the conversation is live elsewhere, the block reads its jsonl again on every change, so you can follow a terminal session from the phone, read-only. - The header names the source and where it is live (*Live in pane %4*, *Live in Claude desktop*, *Live in a terminal, pid 1234*). `capture --text`, `history` and `search` work on it like any agent block. 4. **Continue, or fork when it's live.** - **Not live:** *Continue* starts `claude-agent-acp` through the existing start path. The block already has a transcript, so it sends `session/resume` with no replay. The block's log begins with the imported entries as one `imported` record, so a restart or reboot restores the block as M6b does. - **Live in one of our panes:** *Go to pane* is the main action. - **Live anywhere else:** *Fork* calls `session/fork`, then `session/resume` on the new id (fork doesn't open it), and the block's `session_id` becomes the fork's. The original is left alone. Continuing is offered again once that process exits. There's no *Continue anyway*: S20 lost a writer's turns that way. - Imported blocks pass `settingSources: ["user","project","local"]` and `settings: {disableAllHooks: true}` (S20 item 3), and set the session's last model (the last assistant line's `message.model`) after resuming, since a resume resets it. 5. **Pickers.** - **Web:** a *Conversations* picker grouped by project (cwd). It searches titles and first prompts, filters by live, source and machine, and opens into a new tab or the focused pane. - **TUI:** the same picker on a key. - **CLI:** - `illogical claude ls [--cwd D] [--live] [--json]`; - `illogical claude open <id|prefix>` prints the block id; - `illogical agent --resume <id>` and `--fork <id>` continue a conversation directly. - **MCP:** `list_conversations` and `open_conversation`. **Tests:** - unit tests for the converter (S20's fixtures, branches, unknown line types) and the index (incremental rescans, what's left out, liveness with a reused pid); - a daemon test with a fake `~/.claude` and the fake ACP agent: opening starts no process, *Continue* sends `session/resume` with the id, *Fork* sends `session/fork`, and the block restores after a restart; - `web/e2e/conversations.spec.ts`: a seeded `~/.claude` shows up in the picker, opens and continues. Dev and test daemons always pass `--socket`. **Done when:** - a Claude Code session run in a plain terminal outside illogical and then exited shows up in the picker within 2 s, with its title and folder, and opens with its whole transcript (tool calls and their output) without starting anything; - *Continue* gets a reply that uses the earlier context, and `claude --resume <id>` in a terminal then shows the new turns; - a session still open in a terminal shows as live, its block follows new turns, and *Fork* continues it without changing the terminal's jsonl; - a session in an illogical pane says which pane and jumps there; - a desktop Code tab session shows up as *desktop* and continues; - our own agent blocks and test daemons' sessions don't show up; - geek's 386-plus transcripts index cold in the background, with the time measured, and a restart only rereads files that changed; - a continued block survives a daemon restart and a reboot like any agent block. **Not in M33:** - Claude Desktop chats; - cloud sessions (claude.ai/code); - full-text search across transcripts that aren't open; - Codex and other agents' histories (the same shape would fit, behind the index's source).
jhgaylor referenced this issue from a commit 2026-10-02 21:21:15 +00:00
Author
Owner

Done and on main (e702056: f9011bb, 15be04c). PLAN.md's M33: as built has what landed, the decisions and what isn't covered; follow-ups are filed separately.

Done and on main (e702056: f9011bb, 15be04c). PLAN.md's *M33: as built* has what landed, the decisions and what isn't covered; follow-ups are filed separately.
Commenting is not possible because the repository is archived.
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jhgaylor/illogical#72
No description provided.