Skip to content

Commit b4c42b1

Browse files
committed
fix(cli): prevent message queue interleaving by awaiting tool result submission
1 parent b703c87 commit b4c42b1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/cli/src/ui/hooks/useGeminiStream.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const MockedGeminiClientClass = vi.hoisted(() =>
5656
this.startChat = mockStartChat;
5757
this.sendMessageStream = mockSendMessageStream;
5858
this.addHistory = vi.fn();
59+
this.getCurrentSequenceModel = vi.fn().mockReturnValue('gemini-2.0-flash');
5960
this.getChat = vi.fn().mockReturnValue({
6061
recordCompletedToolCalls: vi.fn(),
6162
});
@@ -84,6 +85,9 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
8485
UserPromptEvent: MockedUserPromptEvent,
8586
parseAndFormatApiError: mockParseAndFormatApiError,
8687
tokenLimit: vi.fn().mockReturnValue(100), // Mock tokenLimit
88+
ValidationRequiredError: class {
89+
userHandled = false;
90+
},
8791
};
8892
});
8993

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ export const useGeminiStream = (
10651065
loopDetectedRef.current = false;
10661066
// Show the confirmation dialog to choose whether to disable loop detection
10671067
setLoopDetectionConfirmationRequest({
1068-
onComplete: (result: {
1068+
onComplete: async (result: {
10691069
userSelection: 'disable' | 'keep';
10701070
}) => {
10711071
setLoopDetectionConfirmationRequest(null);
@@ -1081,8 +1081,7 @@ export const useGeminiStream = (
10811081
});
10821082

10831083
if (lastQueryRef.current && lastPromptIdRef.current) {
1084-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
1085-
submitQuery(
1084+
await submitQuery(
10861085
lastQueryRef.current,
10871086
{ isContinuation: true },
10881087
lastPromptIdRef.current,
@@ -1318,8 +1317,7 @@ export const useGeminiStream = (
13181317
return;
13191318
}
13201319

1321-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
1322-
submitQuery(
1320+
await submitQuery(
13231321
responsesToSend,
13241322
{
13251323
isContinuation: true,

0 commit comments

Comments
 (0)