Repository navigation
fix(cli): keep TUI event streams alive - #215
Conversation
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
|
Droid encountered an error —— View job |
There was a problem hiding this comment.
ℹ️ No critical issues — one minor test nit inline, plus a scope note below.
Reviewed changes
- Idle SSE heartbeats (Go):
streamEventsnow runs a per-connection ticker writing": heartbeat\n\n"comment blocks every 15s (configurable viaOptions.EventHeartbeatInterval), keeping idle/eventsconnections byte-active. Ticker is handler-local with a deferredStop— no leak, no cross-connection state. - Sidecar error fidelity:
#requestpreserves the underlying fetch failure as the errorcause, and the startup-failure handler now printsinspect(error)after the stage line, so the swallowed-error symptom from #196 is diagnosed on stderr. - Tests: a Go idle-heartbeat test with a real failure path, a comment-interleaved SSE fixture pinning the client parser's comment tolerance, and a cause-preservation test.
Cross-checks: the client parser already tolerated comment-only blocks (parseEventBlock keeps only data: lines), so no parsing change was needed — the fixture change pins that. The session http.Server sets no WriteTimeout, so heartbeats aren't fighting a server-side deadline. I verified the load-bearing runtime contract against Bun's sources: the fetch idle timeout defaults to 300s and re-arms on body-phase bytes (bun#36145, bun#33338), so a 15s keepalive holds with ~20x margin. go test ./internal/tuisession -count=1 passes locally; bun isn't available in this review environment, so the UI tests were reviewed statically rather than executed.
ℹ️ Timeout remains a fatal crash path — this fix is prevention-only
Issue #196's expected behavior included "a timeout is not a fatal renderer crash", but runInteractive still races consumeEvents and a TimeoutError on the events fetch still tears down the renderer. With heartbeats verified to re-arm Bun's idle timer with wide margin on a loopback connection, the residual risk is low, so this is a scope question rather than a defect — worth deciding deliberately whether crash resilience belongs here or in a later PR in the stack.
Technical details
# Timeout crash path remains fatal
## Affected sites
- `ui/src/main.ts` `runInteractive` — still races `consumeEvents`; any throw from the events generator destroys the renderer and exits 1.
- `internal/tuisession/events.go` — heartbeats prevent the idle condition but cannot help if the stream dies for another reason (e.g. a `BUN_CONFIG_HTTP_IDLE_TIMEOUT` env override below ~15s re-enables the crash).
## Required outcome
- Decide (and record in the PR or the stacked plan) whether the events fetch should be retried/reconnected instead of being fatal, or that prevention-only is the accepted contract for the loopback transport.
## Suggested approach (optional)
- If resilience is deferred, a one-line note in the PR body tying it to the stacked plan (`PR-tui-events`, issue #196 T1) is enough for now.
## Open questions for the human (optional)
- Bun evidence for the keepalive contract: `IDLE_TIMEOUT_SECONDS = 300` re-armed on body reads — https://github.com/oven-sh/bun/pull/36145, https://github.com/oven-sh/bun/pull/33338@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using openai-compatible/glm-5.3 | 𝕏
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (6 files)
Reviewed by glm-5.3 · Input: 52.3K · Output: 19.8K · Cached: 409.4K Review guidance: REVIEW.md from base branch |

Summary
Error.causeCloses #196.
Validation
go test ./internal/tuisession -count=1go test ./... -count=1make lint— 0 issuesgit diff --checkIndependent review evidence
Exact range:
218288e129181c7a508c83d0091651cf246d37df..c706c56c68a0ae159100c749be30dfb79b79c327opencode/muse-spark-1.2-contributor-free— default variant: SHIPCode verdict: SHIP. The requested four-reviewer evidence gate remains incomplete because Grok did not produce a technical review after the permitted retry. A Pullfrog assertion-strength nit was documented and skipped as nonblocking. Live six-minute dogfood remains unavailable without a real account. Hosted checks remain a separate merge gate.