fix: TUI agent:end handler calls setMessages inside setCurrentStreamText updater #63
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
In
app.tsx, theagent:endsocket handler callssetMessages()inside asetCurrentStreamText()updater function. React state updater functions should be pure — React 18 strict mode calls them twice in development, which would duplicate the assistant message. In concurrent mode, the intermediate state is not guaranteed to be stable.Location
packages/cli/src/tui/app.tsx—agent:endevent handlerFix
Option A: Use a ref to track currentStreamText so it can be read reliably at event time without nesting state setters.
Option B: Use
useReducerto handle both state updates in a single dispatch.Found by
Gatekeeper review (communication spine PR #61)