Repository navigation
feat: agent view of Claude Code background sessions (claude agents) - #26
Merged
Merged
Conversation
The fleet dashboard only listed panes that carried a hook state (working/waiting/done), so it appeared empty whenever Claude was running but no hook event had fired yet — or when the hooks were not installed at all. Include panes where a Claude process is detected (`has_claude`) even with no hook state; those render as `RUNNING` and rank below any known state. `DashboardRow.state` becomes `Option<ClaudeState>` accordingly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rework the fleet dashboard from a state-summary list into a grid of live mirrors — one tile per Claude pane, each showing the agent's real captured screen — so it acts as an alternative front-end to the Claude Code TUIs rather than just an index. - Capture: while the dashboard is open, every Claude pane is captured each tick (not just the TreeView-selected one); results are cached per target in `dashboard_captures` and rendered tail-first in each tile. - Layout: near-square grid (ceil(sqrt(n)) columns). Each tile is a bordered block titled with session:pane, state marker and elapsed time; the focused tile is highlighted. - Navigation: Tab/BackTab/arrows/hjkl move tile focus (wrapping); Enter attaches to the focused agent via the existing SwitchClient path. - Pane set still includes Claude-running panes without a hook state (shown as RUNNING), so the grid is useful even before hooks fire. Tests: grid render smoke test with multiple tiles; existing sort/inclusion tests retained. cargo test 49 passing; clippy clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rework the fleet dashboard to mirror Claude Code's `claude agents` view: a list of Claude panes grouped by attention rather than a mirror grid. - Grouping: rows are grouped under "Needs input" / "Working" / "Completed" headers (attention first), longest-in-state first within a group. - Peek (Space): opens a centred overlay with the selected pane's latest captured output and a reply line; typing + Enter sends the reply to that pane via send-keys. Up/Down peek neighbouring rows, Right attaches, Esc closes. Only the selected pane is captured each tick (cheap). - Attach (Enter) and list navigation (j/k) unchanged. - Panes running Claude without a hook state still appear (RUNNING), so the list is useful before hooks fire. This supersedes the short-lived mirror-grid take. Dispatch/supervisor/PR status and Haiku summaries from the real agent view are Claude-Code-specific and intentionally out of scope. Tests: grouped list + peek render smoke test, sort/inclusion tests. cargo test 49 passing; clippy clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the tmux-pane-based fleet dashboard with a real agent view that reads Claude Code's background-session state from ~/.claude/jobs/*/state.json (the same source `claude agents` renders) and shows those sessions — not tmux panes. - New `agents` module: reads each job's state.json (state/name/needs/detail/ cwd/children) plus daemon/roster.json for liveness, using the state file mtime as "last changed". Honours CLAUDE_CONFIG_DIR. - Dashboard (`d`) now lists background sessions grouped by working directory (directory with the most-pressing session first), with a summary header (N awaiting input · M working · K completed). Each row: state marker, name, one-line summary, PR labels, elapsed time; exited workers show a dot. - Enter attaches: the TUI suspends, runs `claude attach <id>` with the terminal handed over, then restores on detach. j/k select, d toggles back. - Sessions refresh from disk each tick while the view is open. The pane/hook integration (#19/#20) still collects per-pane Claude context; it is no longer shown in this view (reserved for a future inline indicator). Tests: state parsing, directory grouping/sort, path abbreviation, and an agent-view render smoke test. cargo test 50 passing; clippy clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add two agent-view features for the selected background session: - Preview panel (`p`): splits the agent view into list | preview and shows a tail of the session's conversation transcript (read from the state file's `linkScanPath` JSONL — assistant text, tool calls and user prompts; thinking/internal records skipped). - Execution summary (`s`): runs `claude -p` against a transcript digest in a background task and shows a 3–5 line summary at the top of the preview. Stateless (no `--resume`), so it never touches the live session. The model is configurable via `[agents] summary_model` (default `haiku`). Results arrive over a channel; status shows summarizing… / the summary / an error. Adds `[agents]` config, transcript parsing helpers in the `agents` module, and a summary result channel on the UI actor. Tests/clippy green. (Send-to-session without attaching is intentionally not included — Claude Code exposes no public API for it; see the PR discussion.) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…nscript - Summary (`s`) is now an independent centred popup, so it works whether or not the transcript preview (`p`) is open. `Esc` closes the popup (handled before the quit binding); `s` regenerates. The preview panel no longer carries a summary section. - Transcript preview lines are coloured by role (user / assistant / tool), improving readability over the previous plain text. Note on preview fidelity: unlike the TreeView preview (which renders a tmux `capture-pane` *screen snapshot* via ansi-to-tui), background sessions have no pane to capture. `claude logs <id>` emits a raw PTY byte stream (cursor moves + SGR), which needs a vt100 emulator to render faithfully; for now the preview reconstructs the conversation from the transcript JSONL. A vt100-based preview can be a follow-up. Tests/clippy green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The transcript markers (●/⏺/▸) are East Asian *Ambiguous* width: some terminals (e.g. CJK locales) render them 2 cells wide while unicode-width counts 1, so the following text drew over the icon. Use two spaces after the marker so a gap survives in both cases. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
dのフリートビューを、Claude Code のバックグラウンドセッション(claude agentsのエージェントビュー)を表示・管理するビューに作り直しました。tmux ペインではなく、~/.claude/jobs/<id>/state.json(claude agentsと同じソース)を読みます。スクリーンショットで頂いた「こういうセッションを表示して管理したい」に対応するものです。当初 tmux ペインを対象にしていたのが根本的な間違いでした。
実装
agentsモジュール: 各jobs/<id>/state.json(state / name / needs / detail / cwd / children=PR)+daemon/roster.json(プロセス生存)を読む。「最終更新」は state.json の mtime。CLAUDE_CONFIG_DIR対応。d): バックグラウンドセッションを作業ディレクトリでグループ化(最も要対応のディレクトリが上)。ヘッダーに集計(N awaiting input · M working · K completed)。各行: 状態マーカー / 名前 / 1行要約 / PRラベル / 経過時間。プロセス終了済みは∙。claude attach <id>に端末を明け渡し → デタッチで TUI 復帰。j/k選択、dでツリーに戻る。~/.claude/jobsから再読込。スコープ(今回)
表示 + アタッチまで(合意どおり)。停止・返信・ディスパッチは未実装。
実データ検証
ローカルの
~/.claude/jobs(8セッション)を読み、名前・状態・PR・cwd・経過・生存を正しく取得することを確認済み。テスト
cargo test --all --locked50件 /cargo clippy -D warningsクリーン補足
blocked(=入力待ち)/working/idle/done/failed/stopped。🤖 Generated with Claude Code