fix(cli): ensure correct ordering of hook system messages and AI responses

Commit pending AI response before adding HookSystemMessage to history
to prevent "Stop says:" block from appearing above the AI's reply.
This commit is contained in:
思晗 2026-04-03 15:45:47 +08:00
parent 76e52a51db
commit 7c1fe2d938

View file

@ -1101,6 +1101,11 @@ export const useGeminiStream = (
break;
case ServerGeminiEventType.HookSystemMessage:
// Display system message from Stop hooks with "Stop says:" prefix
// First commit any pending AI response to ensure correct ordering
if (pendingHistoryItemRef.current) {
addItem(pendingHistoryItemRef.current, userMessageTimestamp);
setPendingHistoryItem(null);
}
addItem(
{
type: 'stop_hook_system_message',