Repository navigation
fix(tui): clear model status rows once the connection recovers - #223
Merged
Merged
Conversation
A `model_request_failed` event with `retryable: false` does not end the turn: when streamed output was already committed the runtime disables the attempt-level retry and then recovers the same request at the turn level (stream recovery / model fallback). The transcript rendered a permanent error row per such attempt, so every dropped stream left a stale "Model request failed" row behind and they accumulated. Model network status is per-attempt turn status, not a transcript record: stalled, failed, retrying and recovering events now share one per-turn status row that is replaced in place, and the row is removed as soon as a model request completes, so nothing is left behind after reconnecting. Unrecoverable failures still keep their row, and cancellations are still ignored. Adds an end-to-end scenario that recovers two stalled/failed attempts and asserts no status row survives, while a terminal failure stays visible.
Contributor
|
pkg-pr-new preview for commit npx --yes https://pkg.pr.new/zcode-app-cli@dd2c4a5This preview uses the selected commit. PR updates publish automatically after CI succeeds; kingsword09 can also request a preview with |
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.
Problem
When a model request fails, the TUI prints
Model request failed(red,Ctrl+O to expand). The row survives a successful retry, and every failure appends a new one, so a single turn can pile up several of them.The cause is not "retry failed" — the TUI treated each failed attempt as a permanent transcript record:
model_request_failedwithretryable !== trueappended a row under a random block id (packages/zcode-tui/src/index.ts).retryable: falsedoes not end the turn. When streamed output was already committed, the runtime retry gate returns "not retryable" (emittedRetryBoundaryEvent), and the turn level then recovers the same request viarecoverFromModelFailure(stream recovery, surfaced asRecovering model stream) or a model fallback, and continues successfully with a new attempt.Same class of problem:
model_stream_stalledalso appended a new row per stall.Change
Model network status is per-attempt turn status, not a transcript record:
stalled/failed/retrying/recoveringshare one per-turn status row (renamedmodelRetryBlockIdtomodelStatusBlockId) that is replaced in place instead of appending.model_request_completed(clearModelStatus()): once the connection is back, nothing is left behind.Model request failedrow; cancellations (AbortError) are still ignored;retryable: truefailures still only update the activity line so they do not flicker against the retry row that follows.Result:
Model stream stalled · idle 60s->Retrying model request · 1/5 · in 1s-> request completes -> the row disappears.Tests
test/tui/model-status.test.tsplustest/tui/fixtures/model-status.ts(registered intest:tui:e2e).Model request failed,Model stream stalled,Retrying model request,Recovering model stream; the stalled status is still visible while the attempt is unresolved.Model request failedrow.clearModelStatus()makes the test fail (row stays); reverting the whole change makes it fail (rows accumulate).test/fixtures/tui-features.ts: the status row is now cleared on success, sostalledandretryingget 400 ms observation windows to keep thescripts/smoke-tui-features.tsassertions valid.bun run typecheck;bun run test:tui:e2e(35 passed);bun scripts/smoke-tui-features.ts(several runs);bun scripts/smoke-tui-pressure.ts;bun run test:unit(851 passed, 2 failures are local environment issues from a missing synced runtime metadata manifest, unrelated to this change).Known gap
If a turn is cancelled with Esc while waiting for a retry, no
model_request_completedarrives and theRetrying model requestrow remains (same as before this change). Clearing it would require distinguishing "in progress" from "failed" status rows at turn end, which is a reasonable follow-up.