Skip to content

feat: agent view of Claude Code background sessions (claude agents) - #26

Merged
takeshiD merged 7 commits into
mainfrom
fix/dashboard-include-running-panes
Jun 14, 2026
Merged

takeshiD merged 7 commits into
mainfrom
fix/dashboard-include-running-panes

Conversation

@takeshiD

@takeshiD takeshiD commented Jun 13, 2026 •

Copy link
Copy Markdown
Owner

概要

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ラベル / 経過時間。プロセス終了済みは ∙。
  • アタッチ(Enter): TUI を一時退避 → claude attach <id> に端末を明け渡し → デタッチで TUI 復帰。j/k 選択、d でツリーに戻る。
  • 表示中は毎tick ~/.claude/jobs から再読込。

スコープ(今回)

表示 + アタッチまで(合意どおり)。停止・返信・ディスパッチは未実装。

実データ検証

ローカルの ~/.claude/jobs(8セッション)を読み、名前・状態・PR・cwd・経過・生存を正しく取得することを確認済み。

テスト

  • state パース / ディレクトリ・グルーピングのソート / パス短縮 / エージェントビュー描画スモーク
  • cargo test --all --locked 50件 / cargo clippy -D warnings クリーン

補足

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>
@takeshiD takeshiD added the bug Something isn't working label Jun 13, 2026
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>
@takeshiD takeshiD added enhancement New feature or request and removed bug Something isn't working labels Jun 13, 2026
@takeshiD takeshiD changed the title fix(ui): show Claude-running panes in dashboard without a hook state feat(ui): live mirror grid fleet dashboard (replaces state list) Jun 13, 2026
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>
@takeshiD takeshiD changed the title feat(ui): live mirror grid fleet dashboard (replaces state list) feat(ui): agent-view-style fleet dashboard (grouped list + peek & reply) Jun 13, 2026
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>
@takeshiD takeshiD changed the title feat(ui): agent-view-style fleet dashboard (grouped list + peek & reply) feat: agent view of Claude Code background sessions (claude agents) Jun 14, 2026
takeshiD and others added 3 commits June 14, 2026 11:54
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>
@takeshiD
takeshiD merged commit 0485f27 into main Jun 14, 2026
4 checks passed
@takeshiD
takeshiD deleted the fix/dashboard-include-running-panes branch June 14, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant