fix(brain): emit user message_start for steer in Claude SDK brain#186
Open
jacoblee-io wants to merge 1 commit into
Open
fix(brain): emit user message_start for steer in Claude SDK brain#186jacoblee-io wants to merge 1 commit into
jacoblee-io wants to merge 1 commit into
Conversation
c8ec41b to
8f15f7a
Compare
Steer messages (sent during agent execution) were not showing in the chat. Two issues: 1. Frontend: steer messages were added to pendingMessages (amber chips) instead of messages (chat history). They relied on a message_start event echo from the brain to move from chip to chat, but pi-agent may not emit this event. Fix: add steer messages directly to the messages array, same as normal sends. 2. Gateway: chat.steer RPC didn't save the user message to the database. On page refresh, steer messages were lost. Fix: appendMessage to DB before forwarding to agentbox.
8f15f7a to
9b7043e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Steer messages sent during agent execution show as amber chips in the input area but never appear in the chat history. The chips stay forever.
Root Cause
The Claude SDK brain queues steer messages and runs them as follow-up queries via
runQuery(). ButrunQuery()only emitsturn_start→ assistant messages →turn_end. It never emits amessage_startwithrole: "user"for the steer text.The frontend (
usePilot.ts:521-538) listens formessage_startwithrole: "user"to match againstpendingMessages. Without this event, the match never happens → steer stays as amber chip.Pi-agent brain is not affected because the pi-agent session handles user message emission internally.
Solution
Emit
message_startwithrole: "user"and the steer text before callingrunQuery()for each queued steer message. Applied to both:Test plan