Skip to content

Commit 514cbd4

Browse files
authored
Merge pull request #2848 from pic4xiu/main
fix(cli): commit pending AI response before adding hook system message
2 parents 76e52a5 + 7c1fe2d commit 514cbd4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/cli/src/ui/hooks/useGeminiStream.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,11 @@ export const useGeminiStream = (
11011101
break;
11021102
case ServerGeminiEventType.HookSystemMessage:
11031103
// Display system message from Stop hooks with "Stop says:" prefix
1104+
// First commit any pending AI response to ensure correct ordering
1105+
if (pendingHistoryItemRef.current) {
1106+
addItem(pendingHistoryItemRef.current, userMessageTimestamp);
1107+
setPendingHistoryItem(null);
1108+
}
11041109
addItem(
11051110
{
11061111
type: 'stop_hook_system_message',

0 commit comments

Comments
 (0)