Skip to content

refactor: implement stateful Display and inject io.Writer#84

Open
anj-s wants to merge 1 commit into
mainfrom
u/anj/issue-64-stream-concat
Open

refactor: implement stateful Display and inject io.Writer#84
anj-s wants to merge 1 commit into
mainfrom
u/anj/issue-64-stream-concat

Conversation

@anj-s

@anj-s anj-s commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Refactored Display in the AX CLI client to implement a state machine that tracks the type of last printed chunk (stateNone, stateText, stateThought). This enables real-time concatenation of streamed output blocks (text and reasoning logs) and correctly places separating newlines.
  • Injected io.Writer interface dependency into Display (defaulting to os.Stdout).
  • Eliminated global standard output redirection pipes in tests, replacing them with a local thread-safe bytes.Buffer wrapper.
  • Enabled safe parallel execution of tests (t.Parallel()).
  • Removed redundant and performance-blocking os.Stdout.Sync() calls on TTY devices.
  • Cleaned up legacy unused dead code fields loadingVisible and loadingStopCh.

Type of Change

  • Refactor
  • Bug fix

Related Issues

Closes #64

Test Plan

  • Unit tests pass: go test -v ./cmd/ax/internal passes.
  • Integration tests pass: go test ./... passes.
  • Manually verified: Streamed model and thought chunks print concatenated on a single line sequentially, transitioning to newlines only on state changes.

Closes #64. Adds stateful Display printing for streaming outputs. Removes os.Stdout.Sync() overhead and cleans up dead code. Replaces global stdout redirecting with injected io.Writer dependency, enabling safe parallel unit tests.
@anj-s anj-s requested a review from wjjclaud June 13, 2026 06:44
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.

Issue with model response concatenation

1 participant