Skip to content

fix(tui): stabilize terminal startup and streaming rendering - #618

Merged
san-ci[bot] merged 2 commits into
genai-io:mainfrom
yanmxa:fix/tui-first-turn-and-stream-handoff
Oct 12, 2026
Merged

san-ci[bot] merged 2 commits into
genai-io:mainfrom
yanmxa:fix/tui-first-turn-and-stream-handoff

Conversation

@yanmxa

@yanmxa yanmxa commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

What & why

Starting the first assistant reply moved the first user message upward and left a gap before the response spinner. Streaming history handoffs could also briefly hide reply text or move it up and back down.

Match welcome spacing across live and settled messages, show the waiting spinner immediately, and enqueue nonblocking sends before cancellation can run. Write each temporary redraw and history insert together, and cache parsed history rows instead of reparsing the remainder for every inserted row. Preserve resize, clear, and output-error handling.

The output wrapper also forwards the full terminal-file interface (Read, Write, Close, and Fd). Bubble Tea requires that interface to detect a real TTY and its window size; preserving only Fd left ordinary interactive startup with a zero-size frame. The terminal-file regression test checks the exact interface and forwarded operations.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Docs
  • Other:

Testing

go test ./...
make lint
go test -race ./internal/app -run '^Test(.*Scrollback.*|FixedComposer.*|WaitingSubmissionCanBeCancelled|FirstReply.*|StreamingHistory.*|TerminalOutput.*)$' -count=1
go test ./internal/app -run '^$' -bench '^BenchmarkScrollbackHistoryDrain$' -benchtime=1x -count=1
make build

Terminal-frame tests cover first-turn row positions, streaming handoffs with synchronized output enabled and disabled, native-history integrity, and clearing during an insert. A live-session test covers cancelling before inference and then sending the next message. Allocation-growth and resize tests cover the cached history rows.

The compiled binary was also launched in a real PTY with a 100x40 window, without supplying Bubble Tea a fixed window size. Repeated launches showed the input prompt in about 0.16-0.31 seconds and exited normally on Ctrl+D. Startup also passed when the terminal did not answer capability queries. Visual validation in the user's terminal application is pending.

The 2,048-row history-drain benchmark took about 0.47 seconds locally on Apple M5. This measures local rendering and queue processing.

Checklist

  • Follows Conventional Commits
  • All commits signed off (git commit -s)
  • Tests pass locally
  • Docs updated
  • Read and follow the Code of Conduct

Signed-off-by: Meng Yan <yanmxa@gmail.com>
@san-ci san-ci Bot added the dco:yes label Oct 12, 2026
@san-ci

san-ci Bot commented Oct 12, 2026

Copy link
Copy Markdown

[REVIEW NOTIFIER] This PR requires a review from @ldpliu.

Once this PR has been reviewed and has the lgtm label, it will be automatically squash-merged.

Suggested reviewer

Based on OWNERS, @ldpliu is suggested to review this PR.

How to get your PR reviewed:

  • Address reviewer feedback and push changes
  • Reviewer adds lgtm label when satisfied
  • An approving review + lgtm will trigger auto-merge

@san-ci san-ci Bot added the approved label Oct 12, 2026
@san-ci

san-ci Bot commented Oct 12, 2026

Copy link
Copy Markdown

[REVIEW NOTIFIER] This PR requires a review from @ldpliu.

Once this PR has been reviewed and has the lgtm label, it will be automatically squash-merged.

Suggested reviewer

Based on OWNERS, @ldpliu is suggested to review this PR.

How to get your PR reviewed:

  • Address reviewer feedback and push changes
  • Reviewer adds lgtm label when satisfied
  • An approving review + lgtm will trigger auto-merge

Signed-off-by: Meng Yan <yanmxa@gmail.com>
@yanmxa yanmxa changed the title fix(tui): stabilize first-turn and streaming history rendering fix(tui): stabilize terminal startup and streaming rendering Oct 12, 2026
@zhujian7

Copy link
Copy Markdown
Contributor

/lgtm

@san-ci san-ci Bot added the lgtm label Oct 12, 2026
@san-ci
san-ci Bot merged commit 9e0cba1 into genai-io:main Oct 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants