Repository navigation
feat(agents): screen preview mode via minimal ANSI emulator (v toggle) - #28
Merged
Merged
Conversation
…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>
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.
概要
Agent view のプレビューに「本物の画面再現(screen)」モードを追加します。既存の transcript モードと**
vで切り替え**、config で既定を選べます。背景(なぜ自前エミュレータか)
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に変換。ユニットテスト付き。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 に戻せます。テスト
claude logs出力での再構成も確認(行番号/diff等が位置どおり再現)。cargo test --all --locked54件 /cargo clippy -D warningsクリーン🤖 Generated with Claude Code