Repository navigation
Show streamed reply text formatted before its line ends - #2252
Merged
Merged
Conversation
Formatted words now appear as they stream, so bold, code, links, lists, tables, and code blocks show their final look while their line is still open. Committed output and scrollback are unchanged. Terminal fx ask shows the same live text.
…ss core The reply preview now counts its link ids in its own counter instead of saving and restoring the shared one. A stream with no preview consumer builds no preview. Command output and a hidden main agent's due preview are handled like other appends, and test writes go to /dev/null. The fx-term size budget rises because the terminal draws the preview.
…words-formatted # Conflicts: # src/ui/ask_presentation.zig
The test now passes the ask header that main introduced, as the file's other ask tests do. The fx-core budget rises by the shared code that build runs, while the preview itself is compiled out of it.
A geometry rebase can push native history past an active finality floor, and growth during the hold then left rows in neither history nor the screen. Floors that history has passed are now ignored, while the provisional tail still never enters history. The preview loses an unused helper, logs a dropped tail at deinit, and is cleared with the transcript. Streaming tests now wait for the turn to end instead of for a final line the preview shows early, and benchmarks/stream_latency.ts measures the streaming latency.
A reply's last line now shows before its turn ends, so tests that waited for that line and then read saved state, compared turn-end rows, or typed the next prompt raced the turn end. They now also wait for `turnSettled`, which checks that the live "Generating" row is gone.
…words-formatted # Conflicts: # sdk/tests/package-size-budgets.json
Tests that pressed a key or sent a command such as Ctrl+G, Ctrl+O, /compact, or /quit right after a reply's last line appeared could land before the turn ended, now that the line shows early. They now also wait for `turnSettled` first, and tests that act during a running turn on purpose are unchanged.
fazxes
marked this pull request as ready for review
November 24, 2026 21:43
This was referenced Nov 24, 2026
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.
Summary
**and backticks, link syntax, and pipe rows do not show while their line is open. A stray marker that will stay in the text shows as it will commit.fx askshows the same live text. Piped and JSON output do not.Design
Today a line stays hidden until it ends. A paragraph line also waits for the next line, because an underline such as
===can turn it into a heading. The first diagram shows that hold.After this change the markdown processor still commits as before. After each update it also renders a provisional tail from a copy of its state. The open line uses an open-end mode of the inline parser, so it follows the same rules as committed text. The tail travels with committed text through the same queue, and the pacer applies it only after the committed bytes before it have left the queue. The transcript store keeps the tail outside its committed entries, and the renderer draws it after them. A tail row is never final, so it never enters native terminal history.
Checks
Latency. Times come from
benchmarks/stream_latency.ts, run asbun benchmarks/stream_latency.ts --binary <base> --binary <head> --runs 20 --scenario s1 --scenario s2 --scenario s3 --scenario s4 --json <path>. The base isorigin/mainate1703a338c, and the head is067cca3385. The next commit,011c82a6c6, changes only test files, so the product source is the same. Both are ReleaseSafe builds, and the two binaries take turns run by run after two warm-up runs each. The script drives each build in tmux against a fake gateway that sends one word every 30 ms, and it polls the pane every 5 ms, so each time is an upper bound. The figures are medians of 20 runs. On the first commit of this change, measured against base commitf39cc4b729, the final screen and the full scrollback matched the base in 80 of 80 runs (four scenarios, 20 runs each), after masking elapsed time and token counts.Committed output. The head matches its base commit
e1703a338cbyte for byte over 104,496 outputs, with 0 differing. The outputs come from two corpora of 21,124 and 5,000 documents, each run in four chunkings, on067cca3385.Finality holds. A geometry rebase can push native history past an active finality floor, and growth during the hold then left rows in neither native history nor the screen.
finality_floor_at_or_afterinsrc/core/output/transcript_release.zignow ignores a floor that history has already passed. The provisional tail still never enters history.mainhas the same gap with committed growth alone. The new testa picker close past a tool finality floor keeps all rows visible during committed growthfails onorigin/mainate1703a338cand passes on this head. The preview made the case frequent, because it grows the screen during every hold.TLA+.
check.shintests/tla/assistant_stream/runs ten configs, and each gives its expected verdict. The driver intests/tla/drivers/assistant_stream/runs the model's sequences against the built binary. Result on the head build: all 27 sequences pass fordesign_a, and thecurrentvariant fails all 27, as expected.Fuzz.
inline_open_endandprovisional_previewsare registered intests/fuzz/targets.jsonandsrc/fuzz_targets.zig. Seven of the fuzz targets that this change reaches ran for 60 seconds each on the first commit of this change, and each finished with status ok:switch_order,agents_menu_selection,transcript_paint,markdown_lists,inline_open_end,provisional_previews, andrequest_wrapper_text. After the follow-up fixes,inline_open_end,provisional_previews, andmarkdown_listsran again for 30 seconds each with status ok. The Fuzz workflow runs on this pull request and covers the remaining reached targets.E2E. With
FX_SOUND=0and Bun 1.4.2, each file ran once on the merged head067cca3385, before the test-only commit011c82a6c6:tui-gateway-stream-lifecycle.test.ts113 pass,ask-presentation.test.ts29 pass,tui-resume.test.ts98 pass,vision-route-fake-gateway.test.ts64 pass, andtui-auth-source-selection.test.ts236 pass, all with 0 failures.gateway-stream-lifecycle.test.tshas 268 tests: 265 pass and 1 fails. That test,default fx ask starts fresh network pacing after explicitly timed provider retries, failed three times in a row in our sandbox, and it also failed three times in the same sandbox onorigin/mainate1703a338c. Main's CI run 45334067388 one1703a338cis green, so this is treated as a sandbox environment failure, and CI decides on this head. CI runs every E2E file on this head.Changed tests. In
tests/e2e/tui-gateway-stream-lifecycle.test.ts, the token counter test no longer requires the final marker to be absent from the screen, because the open line now shows. The cancel test checks that the buffered tail appears after the visible prefix, instead of checking that it is absent before steering. Both keep their goals. Intests/e2e/tui-resize.test.ts, three checks that a streamed line is absent during the stream now allow one copy, because the open line shows in the tail while it streams. A second copy still fails. The vision, command-permissions, and resume tests waited for a final line without a newline as the end of the turn. They now wait for the live status row to go away, and six dead"Streaming ("checks now name"Generating (". A reply's last line now shows before its turn ends, so tests that waited for that line and then read saved state, compared turn-end rows, or typed the next prompt raced the turn end. TheturnSettledhelper intests/e2e/tmux-helpers.tschecks that the liveGeneratingrow is gone, and 153 waits in 19 test files now also wait for it. A second pass covers keys and commands after a reply (Ctrl+G, Ctrl+O, Ctrl+X, /compact, /quit and others) at 115 sites in 25 files. Each changed test passed 5 of 5 repeated runs, and every changed file was green.Model areas. The check lists seven TLA+ model areas near code that this change touches:
agent_runtime,auth,saved_turn, andtoolbox(throughorchestrator.zig),agents_menu(throughapp_agents_runtime.zig), andsubagentandturn_clock(throughapp_worker_runtime.zig). The edits in those files add small steps for the tail: an empty tail after each flush, a held tail that counts as unapplied work for a hidden child agent, and a tail event that child agents drop. None of them changes a turn, a login, a saved message, or a menu state that these models describe, so the models are unchanged.Sleeps. The stream driver polls the pane every 50 ms until it has been unchanged for 200 ms. The pane gives no change signal, so this is the same pattern as
waitForStableGrid.SDK sizes. The terminal wasm draws the live text. On the merged head,
fx-term.wasmmeasures 4,271,883 bytes, abovemain's budget of 4,254,000, so its budget insdk/tests/package-size-budgets.jsonrises from 4,254,000 to 4,276,000. The headless core never shows live text.builds_previewsininline_render.zigcompiles the preview out offx-core.wasm, which measures 2,470,506 bytes, within the 2,475,000 budget thatmainalready sets. The constant is true for the native binary andfx-term.wasm, so their code is unchanged by it.Format.
zig fmt --check src/passes.Linear: FXC-345