fix(cli): remove side-effect from agent:end state updater (#133) #147

Merged
jason.woltje merged 3 commits from fix/tui-agent-end-state into main 2026-03-15 19:09:14 +00:00
Owner

Summary

  • Fixes React rule violation in Socket.IO handler in TUI app
  • The original code called (a side effect) inside a state updater, which violates React's requirement that state updaters be pure functions
  • Fix: use a to track current stream text so can read the final value and update state outside any updater callback

Changes

  • : Added to mirror state; refactored , , and handlers to use ref-based approach; now performs all state updates at the top level without nesting

Test plan

  • TUI connects to gateway and streams agent responses correctly
  • Streaming text accumulates and is committed to messages list on
  • Model switching () and provider switching () work as before
  • Session management (conversationId tracking) works as before

Closes #133

🤖 Generated with Claude Code

## Summary - Fixes React rule violation in Socket.IO handler in TUI app - The original code called (a side effect) inside a state updater, which violates React's requirement that state updaters be pure functions - Fix: use a to track current stream text so can read the final value and update state outside any updater callback ## Changes - : Added to mirror state; refactored , , and handlers to use ref-based approach; now performs all state updates at the top level without nesting ## Test plan - [ ] TUI connects to gateway and streams agent responses correctly - [ ] Streaming text accumulates and is committed to messages list on - [ ] Model switching () and provider switching () work as before - [ ] Session management (conversationId tracking) works as before Closes #133 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jason.woltje added 3 commits 2026-03-15 19:09:01 +00:00
Use a ref to track current stream text so agent:end can commit the
final message without calling setMessages inside a setCurrentStreamText
updater function, which violates React's rule that state updaters must
be pure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
style(gateway): fix prettier formatting in coord.controller
Some checks failed
ci/woodpecker/push/ci Pipeline failed
8820299301
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jason.woltje merged commit 76abf11eba into main 2026-03-15 19:09:14 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mosaicstack/stack#147