Skip to content

fix(cli): keep TUI event streams alive - #215

Merged
rabesss merged 5 commits into
mainfrom
codex/dogfood-196-tui-events
Aug 28, 2026
Merged

rabesss merged 5 commits into
mainfrom
codex/dogfood-196-tui-events

Conversation

@rabesss

@rabesss rabesss commented Aug 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • keep idle TUI SSE connections byte-active with heartbeat comments
  • preserve the underlying fetch failure as Error.cause
  • surface the inspected startup error without exposing unvalidated HTTP bodies
  • pin SSE comment parsing and heartbeat delivery

Closes #196.

Validation

  • go test ./internal/tuisession -count=1
  • heartbeat race test, 10 repetitions
  • go test ./... -count=1
  • make lint — 0 issues
  • UI typecheck and 84 tests at this stacked head
  • exact-range git diff --check

Independent review evidence

Exact range: 218288e129181c7a508c83d0091651cf246d37df..c706c56c68a0ae159100c749be30dfb79b79c327

  • Z.AI GLM-5.3 — max reasoning: SHIP
  • Grok 4.6 — high reasoning: incomplete; broad and focused attempts returned a placeholder before inspecting the bundle
  • opencode/muse-spark-1.2-contributor-free — default variant: SHIP
  • Devin Review — model and reasoning not exposed: completed, zero bugs, vulnerabilities, or flags

Code 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.

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@factory-droid

factory-droid Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Droid encountered an error —— View job

Droid Exec exited with code 1:
Tool "Edit" skipped (GPT-5.2 uses ApplyPatch instead).
Tool "Create" skipped (GPT-5.2 uses ApplyPatch instead).

Security Review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor test nit inline, plus a scope note below.

Reviewed changes

  • Idle SSE heartbeats (Go): streamEvents now runs a per-connection ticker writing ": heartbeat\n\n" comment blocks every 15s (configurable via Options.EventHeartbeatInterval), keeping idle /events connections byte-active. Ticker is handler-local with a deferred Stop — no leak, no cross-connection state.
  • Sidecar error fidelity: #request preserves the underlying fetch failure as the error cause, and the startup-failure handler now prints inspect(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

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using openai-compatible/glm-5.3 | 𝕏

Comment thread ui/test/client.test.ts Resolved
@kilo-code-bot

kilo-code-bot Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (6 files)
  • internal/tuisession/events.go
  • internal/tuisession/session.go
  • internal/tuisession/session_test.go
  • ui/src/client.ts
  • ui/src/main.ts
  • ui/test/client.test.ts

Reviewed by glm-5.3 · Input: 52.3K · Output: 19.8K · Cached: 409.4K

Review guidance: REVIEW.md from base branch codex/dogfood-194-watch-budget

@rabesss
rabesss changed the base branch from codex/dogfood-194-watch-budget to main August 28, 2026 04:34
@rabesss
rabesss merged commit d24ba2a into main Aug 28, 2026
10 checks passed
@rabesss
rabesss deleted the codex/dogfood-196-tui-events branch August 29, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TUI dies with TimeoutError after a few idle minutes

1 participant