You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(native): stream a command's output live into its expanded row - #66
Expanding a command row in the native transcript showed only the output persisted on the item (or fetched with getTurnItem), so a running command showed nothing until it settled, and ANSI output was not normalized or coloured. The web streams it (CommandOutputPanel.tsx): live while the command runs, final once it settles.
Approach
crates/core/src/terminal_output.rs: a line-for-line port of packages/shared/src/terminalOutput.ts (the fold the server also runs): the 64-line live window, cursor moves, erases, save/restore, hidden OSC/DCS strings, pending escapes across chunks, the 64K tail with its newline-preferring and style-preserving cuts, and lengths counted in UTF-16 units so cuts land where the server's do. Also terminalOutputSpans with both TERMINAL_PALETTES, inverse, the badge contrast fix and the 2,000-span cap.
crates/core/src/command_output.rs: the frame wire type, applyCommandOutputFrame (replace resets, append folds, truncated sticks until a replace), and the panel's branches with the web's copy: "Loading output…", "No output.", "Couldn't load output: …", "Earlier output not shown", nothing while a running command has printed nothing.
crates/client/src/command_output.rs: orchestration.subscribeCommandOutput decoded and folded on the network runtime; the row reads only the newest result from a watch. It stops when the server ends the stream after settling, reports server failures, resubscribes after a dropped connection, and dropping the handle interrupts it.
crates/app/src/transcript/command_output.rs + work.rs/thread_view.rs: only when the server advertises commandOutputStreaming, an open command row subscribes and skips the getTurnItem fetch, as the web does. Closing the row, folding its group, switching thread or connection drops the subscription. Output scrolls in its own 20rem panel pinned to the tail while the reader stays within 8px of the bottom. Rows redraw only when a frame lands; nothing ticks. Older servers keep the old path.
The probe gains --command-output (stream every command of the watched thread) and --delete-after (remove a scratch launch).
Not ported: ShellCommandBlock's syntax highlighting of the command line (still plain mono), so the ledger row is partial.
Ledger
TR-CMDOUT: partial, Native = the four modules above, Issue #64. #64 stays open for the command highlighting gap.
Evidence
Conformance: new conformance/commandOutputCases.ts writes crates/core/tests/conformance/command-output.jsonl from the real TypeScript (52 seeded cases, 1,336 states: chunked folds under 16–2,000 char budgets, astral text, and frames built the way CommandOutputHub builds them, with resume-text replaces); command_output_matches_typescript replays them and compares text, truncated, pending, running and spans. A deliberate one-character drift in the tail cut fails it with 19 divergences.
Screenshots (smoke server, "Native client showcase", vp test run expanded): /private/tmp/claude-501/-Volumes-DevSSD-t3code-native/3ca997f3-68be-482e-8fff-7893917dbe2a/scratchpad/after-dark.png, /private/tmp/claude-501/-Volumes-DevSSD-t3code-native/3ca997f3-68be-482e-8fff-7893917dbe2a/scratchpad/after-light.png (crops: /private/tmp/claude-501/-Volumes-DevSSD-t3code-native/3ca997f3-68be-482e-8fff-7893917dbe2a/scratchpad/crop-dark.png, /private/tmp/claude-501/-Volumes-DevSSD-t3code-native/3ca997f3-68be-482e-8fff-7893917dbe2a/scratchpad/crop-light.png). A settled row looks as it did before; the change is what happens while it runs.
Review round 1, addressed in d7a7ff7 (rebased on fork/native).
1. [P2] Folding a group or turn didn't resync subscriptions. Fixed.rederive now reconciles subscriptions whenever the rows change (crates/app/src/thread_view.rs:243). Every fold toggle (toggle_group, toggle_run, toggle_attempt) and every thread update goes through rederive, so folding drops the slot and reopening recreates it. The desired set is now a pure selector, t3_core::timeline::open_command_items (crates/core/src/timeline/detail.rs:74). It includes only open command entries that a drawn RowKind::Work row shows. Test: timeline::tests::open_command_items_follow_folded_groups (crates/core/src/timeline/tests.rs:1303) folds and reopens the group and the turn. The missing call was inside a GPUI view the app crate has no test harness for, so the test covers the selector it now calls.
2. [P2] Every frame invalidated every row. Fixed.
remeasure_entry (thread_view.rs:393) now remeasures only the row that draws the entry, and only the open group list that holds it.
A frame triggers it only when the height can change (thread_view.rs:378, transcript/command_output.rs:64). Once the output fills its capped scroller, a frame with the same notice and at least as many lines as the cap shows keeps the same height, whatever the wrapping. Fewer lines, a new truncation notice, or a branch change still remeasure. See CommandOutputStatus::keeps_capped_height (crates/core/src/command_output.rs:119). Test: command_output::tests::a_filled_panel_keeps_its_height_until_its_lines_or_notice_change.
3. [P3] Output can't be selected or copied. Recorded as a gap, not built. Native has no selectable plain or styled text element. The only selectable text is gpui-component's markdown TextViewState (crates/app/src/transcript/markdown.rs:93,142), which can't carry ANSI runs. Other mono tool output in work rows isn't selectable either. The TR-CMDOUT ledger row now names the gap ("the output cannot be selected or copied yet").
Gates: clippy -D warnings, cargo test --workspace, gen-theme --check, parity/sync.test.ts, conformance --check all pass. Re-checked in a real window: expand vp test run, fold its group, reopen it, and the output shows again.
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
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.
Problem
Expanding a command row in the native transcript showed only the output persisted on the item (or fetched with
getTurnItem), so a running command showed nothing until it settled, and ANSI output was not normalized or coloured. The web streams it (CommandOutputPanel.tsx): live while the command runs, final once it settles.Approach
crates/core/src/terminal_output.rs: a line-for-line port ofpackages/shared/src/terminalOutput.ts(the fold the server also runs): the 64-line live window, cursor moves, erases, save/restore, hidden OSC/DCS strings, pending escapes across chunks, the 64K tail with its newline-preferring and style-preserving cuts, and lengths counted in UTF-16 units so cuts land where the server's do. AlsoterminalOutputSpanswith bothTERMINAL_PALETTES, inverse, the badge contrast fix and the 2,000-span cap.crates/core/src/command_output.rs: the frame wire type,applyCommandOutputFrame(replaceresets,appendfolds,truncatedsticks until a replace), and the panel's branches with the web's copy: "Loading output…", "No output.", "Couldn't load output: …", "Earlier output not shown", nothing while a running command has printed nothing.crates/client/src/command_output.rs:orchestration.subscribeCommandOutputdecoded and folded on the network runtime; the row reads only the newest result from awatch. It stops when the server ends the stream after settling, reports server failures, resubscribes after a dropped connection, and dropping the handle interrupts it.crates/app/src/transcript/command_output.rs+work.rs/thread_view.rs: only when the server advertisescommandOutputStreaming, an open command row subscribes and skips thegetTurnItemfetch, as the web does. Closing the row, folding its group, switching thread or connection drops the subscription. Output scrolls in its own 20rem panel pinned to the tail while the reader stays within 8px of the bottom. Rows redraw only when a frame lands; nothing ticks. Older servers keep the old path.--command-output(stream every command of the watched thread) and--delete-after(remove a scratch launch).Not ported:
ShellCommandBlock's syntax highlighting of the command line (still plain mono), so the ledger row ispartial.Ledger
TR-CMDOUT:
partial, Native = the four modules above, Issue #64. #64 stays open for the command highlighting gap.Evidence
conformance/commandOutputCases.tswritescrates/core/tests/conformance/command-output.jsonlfrom the real TypeScript (52 seeded cases, 1,336 states: chunked folds under 16–2,000 char budgets, astral text, and frames built the wayCommandOutputHubbuilds them, with resume-text replaces);command_output_matches_typescriptreplays them and compares text, truncated, pending, running and spans. A deliberate one-character drift in the tail cut fails it with 19 divergences.terminal_output::tests::*(redraws, cursor moves, split strings, pending limit, every truncation path, spans),command_output::tests::{a_replace_after_appends_starts_over, truncated_sticks_until_a_replace_clears_it, appends_past_the_tail_truncate_on_the_client, continues_an_escape_and_a_redraw_split_across_appends, panel_follows_the_web_branches},t3-client command_output::tests::{folds_frames_until_the_command_settles_then_stops, collapsing_interrupts_and_a_lost_connection_resubscribes, a_server_failure_is_reported_and_not_retried}.vp test runexpanded):/private/tmp/claude-501/-Volumes-DevSSD-t3code-native/3ca997f3-68be-482e-8fff-7893917dbe2a/scratchpad/after-dark.png,/private/tmp/claude-501/-Volumes-DevSSD-t3code-native/3ca997f3-68be-482e-8fff-7893917dbe2a/scratchpad/after-light.png(crops:/private/tmp/claude-501/-Volumes-DevSSD-t3code-native/3ca997f3-68be-482e-8fff-7893917dbe2a/scratchpad/crop-dark.png,/private/tmp/claude-501/-Volumes-DevSSD-t3code-native/3ca997f3-68be-482e-8fff-7893917dbe2a/scratchpad/crop-light.png). A settled row looks as it did before; the change is what happens while it runs.devReplayshowcase launch, deleted afterwards):Gates:
cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace,node scripts/gen-theme.ts --check,node --test parity/sync.test.ts,node ../../apps/native/conformance/generate.ts --checkall pass.