Skip to content

feat(agents): screen preview mode via minimal ANSI emulator (v toggle) - #27

Closed
takeshiD wants to merge 1 commit into
fix/dashboard-include-running-panesfrom
feature/agent-preview-vt100
Closed

takeshiD wants to merge 1 commit into
fix/dashboard-include-running-panesfrom
feature/agent-preview-vt100

Conversation

@takeshiD

Copy link
Copy Markdown
Owner

概要

Agent view のプレビューに「本物の画面再現(screen)」モードを追加します。既存の transcript モードと**v で切り替え**、config で既定を選べます。

Stacked PR: base は #26(fix/dashboard-include-running-panes)。#26 マージ後に base は繰り上がります。

背景(なぜ自前エミュレータか)

vt100 / vte / avt 等の端末エミュレータcrateはすべて unicode-width 0.1 を要求し、ratatui 0.29 の unicode-width = "=0.2.0" 固定と衝突して導入不可でした(各版で cargo build 解決失敗を確認)。そのため外部依存なしの最小ANSIエミュレータを自前実装しています。

実装

  • termscreen モジュール: 最小ANSI/VTスクリーンエミュレータ。SGR色(16/256/truecolor)・カーソル絶対/相対移動・消去(J/K)・CR/LF/BS/TAB・全角文字幅・代替画面クリアを処理し、その他(モード/OSC)は無視。グリッドを ratatui の色付き Text に変換。ユニットテスト付き。
  • screen モード: claude logs <id>(生PTYバイト列)をバックグラウンドで取得→エミュレータに通して描画。取得はセッション別キャッシュ + screenプレビュー表示中のみ ~3秒間隔にスロットリング。
  • 切り替え: [agents] preview_mode = "transcript" | "screen"(既定 transcript)+ 実行中 v キー。プレビュー枠タイトルに現在モード表示。
  • unicode-width を直接依存に追加(ratatui固定と同じ 0.2 系なので解決に影響なし)。

操作(Agent view)

p プレビュー / v モード切替(transcript ↔ screen)/ s サマリー / Enter アタッチ

限界(正直)

  • claude logs はフルスクリーンTUIの再描画ストリーム。元の端末サイズが不明なため、プレビュー枠サイズで再構成します。capture-pane(TreeView)ほど完璧ではなく、レイアウトに粗が出る場合あり。好みで v で transcript に戻せます。

テスト

  • エミュレータ単体4件 + 既存。実 claude logs 出力での再構成も確認(行番号/diff等が位置どおり再現)。
  • cargo test --all --locked 54件 / cargo clippy -D warnings クリーン
    🤖 Generated with Claude Code

…les)

Add a second agent-view preview mode that reconstructs the session's terminal
screen, alongside the existing transcript view.

- `termscreen`: a small self-contained ANSI/VT screen emulator (no external
  crate — vt100/vte all conflict with ratatui's pinned unicode-width=0.2).
  Handles SGR colours, absolute/relative cursor motion, erase, CR/LF/BS/TAB
  and wide chars; ignores modes/OSC. Renders a styled ratatui Text grid.
- Screen mode feeds `claude logs <id>` (raw PTY bytes) through the emulator.
  Logs are fetched in a background task, cached per session and throttled to
  ~3s while the screen preview is open.
- Toggle: `[agents] preview_mode` sets the default (transcript|screen); `v`
  switches at runtime. The preview title shows the active mode.

Adds `unicode-width` as a direct dep (same 0.2 version ratatui pins, so no
new resolution). Emulator unit tests + render wiring; cargo test 54 passing,
clippy clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@takeshiD takeshiD added the enhancement New feature or request label Jun 14, 2026
@takeshiD
takeshiD deleted the branch fix/dashboard-include-running-panes June 14, 2026 03:31
@takeshiD takeshiD closed this Jun 14, 2026
@takeshiD
takeshiD deleted the feature/agent-preview-vt100 branch November 4, 2026 12:04
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