-
Notifications
You must be signed in to change notification settings - Fork 14.2k
fix(patch): cherry-pick cfdc4cf to release/v0.24.0-pr-16759 to patch version v0.24.0 and create version 0.24.1 #16865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -444,7 +444,7 @@ export const useGeminiStream = ( | |||||
| isClientInitiated: true, | ||||||
| prompt_id, | ||||||
| }; | ||||||
| scheduleToolCalls([toolCallRequest], abortSignal); | ||||||
| await scheduleToolCalls([toolCallRequest], abortSignal); | ||||||
| return { queryToSend: null, shouldProceed: false }; | ||||||
| } | ||||||
| case 'submit_prompt': { | ||||||
|
|
@@ -911,7 +911,7 @@ export const useGeminiStream = ( | |||||
| } | ||||||
| } | ||||||
| if (toolCallRequests.length > 0) { | ||||||
| scheduleToolCalls(toolCallRequests, signal); | ||||||
| await scheduleToolCalls(toolCallRequests, signal); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A critical prompt injection vulnerability exists here. User input is passed to the
Suggested change
|
||||||
| } | ||||||
| return StreamProcessingStatus.Completed; | ||||||
| }, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -31,7 +31,7 @@ import { ToolCallStatus } from '../types.js'; | |||||
| export type ScheduleFn = ( | ||||||
| request: ToolCallRequestInfo | ToolCallRequestInfo[], | ||||||
| signal: AbortSignal, | ||||||
| ) => void; | ||||||
| ) => Promise<void>; | ||||||
| export type MarkToolsAsSubmittedFn = (callIds: string[]) => void; | ||||||
|
|
||||||
| export type TrackedScheduledToolCall = ScheduledToolCall & { | ||||||
|
|
@@ -180,7 +180,7 @@ export function useReactToolScheduler( | |||||
| signal: AbortSignal, | ||||||
| ) => { | ||||||
| setToolCallsForDisplay([]); | ||||||
| void scheduler.schedule(request, signal); | ||||||
| return scheduler.schedule(request, signal); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously,
Suggested change
|
||||||
| }, | ||||||
| [scheduler, setToolCallsForDisplay], | ||||||
| ); | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -163,8 +163,8 @@ describe('useReactToolScheduler in YOLO Mode', () => { | |||||||||||||||||||||||||||
| args: { data: 'any data' }, | ||||||||||||||||||||||||||||
| } as any; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| act(() => { | ||||||||||||||||||||||||||||
| schedule(request, new AbortController().signal); | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await schedule(request, new AbortController().signal); | ||||||||||||||||||||||||||||
|
Comment on lines
+166
to
+167
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When testing asynchronous operations in React components, it's crucial to wrap
Suggested change
|
||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
|
|
@@ -220,11 +220,11 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
| schedule: ( | ||||||||||||||||||||||||||||
| req: ToolCallRequestInfo | ToolCallRequestInfo[], | ||||||||||||||||||||||||||||
| signal: AbortSignal, | ||||||||||||||||||||||||||||
| ) => void, | ||||||||||||||||||||||||||||
| ) => Promise<void>, | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type definition for
Suggested change
|
||||||||||||||||||||||||||||
| request: ToolCallRequestInfo | ToolCallRequestInfo[], | ||||||||||||||||||||||||||||
| ) => { | ||||||||||||||||||||||||||||
| act(() => { | ||||||||||||||||||||||||||||
| schedule(request, new AbortController().signal); | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await schedule(request, new AbortController().signal); | ||||||||||||||||||||||||||||
|
Comment on lines
+226
to
+227
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to other test updates, the
Suggested change
|
||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await advanceAndSettle(); | ||||||||||||||||||||||||||||
|
|
@@ -313,10 +313,13 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| it('should clear previous tool calls when scheduling new ones', async () => { | ||||||||||||||||||||||||||||
| mockToolRegistry.getTool.mockReturnValue(mockTool); | ||||||||||||||||||||||||||||
| (mockTool.execute as Mock).mockResolvedValue({ | ||||||||||||||||||||||||||||
| llmContent: 'Tool output', | ||||||||||||||||||||||||||||
| returnDisplay: 'Formatted tool output', | ||||||||||||||||||||||||||||
| } as ToolResult); | ||||||||||||||||||||||||||||
| (mockTool.execute as Mock).mockImplementation(async () => { | ||||||||||||||||||||||||||||
| await new Promise((r) => setTimeout(r, 10)); | ||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||
| llmContent: 'Tool output', | ||||||||||||||||||||||||||||
| returnDisplay: 'Formatted tool output', | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
Comment on lines
+316
to
+321
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replacing
Suggested change
|
||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const { result } = renderScheduler(); | ||||||||||||||||||||||||||||
| const schedule = result.current[1]; | ||||||||||||||||||||||||||||
|
|
@@ -337,10 +340,13 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
| name: 'mockTool', | ||||||||||||||||||||||||||||
| args: {}, | ||||||||||||||||||||||||||||
| } as any; | ||||||||||||||||||||||||||||
| act(() => { | ||||||||||||||||||||||||||||
| schedule(newRequest, new AbortController().signal); | ||||||||||||||||||||||||||||
| let schedulePromise: Promise<void>; | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| schedulePromise = schedule(newRequest, new AbortController().signal); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
Comment on lines
+343
to
346
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Capturing the
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await advanceAndSettle(); | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // After scheduling, the old call should be gone, | ||||||||||||||||||||||||||||
| // and the new one should be in the display in its initial state. | ||||||||||||||||||||||||||||
| expect(result.current[0].length).toBe(1); | ||||||||||||||||||||||||||||
|
|
@@ -349,14 +355,13 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Let the new call finish. | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(0); | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(20); | ||||||||||||||||||||||||||||
|
Comment on lines
357
to
+358
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(0); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(0); | ||||||||||||||||||||||||||||
| await schedulePromise; | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
Comment on lines
361
to
363
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicitly
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| expect(onComplete).toHaveBeenCalled(); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -379,16 +384,14 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
| args: {}, | ||||||||||||||||||||||||||||
| } as any; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| act(() => { | ||||||||||||||||||||||||||||
| schedule(request, new AbortController().signal); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| let schedulePromise: Promise<void>; | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(0); | ||||||||||||||||||||||||||||
| }); // validation | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(0); // Process scheduling | ||||||||||||||||||||||||||||
| schedulePromise = schedule(request, new AbortController().signal); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
Comment on lines
+387
to
390
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Capturing
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await advanceAndSettle(); // validation | ||||||||||||||||||||||||||||
| await advanceAndSettle(); // Process scheduling | ||||||||||||||||||||||||||||
|
Comment on lines
+392
to
+393
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // At this point, the tool is 'executing' and waiting on the promise. | ||||||||||||||||||||||||||||
| expect(result.current[0][0].status).toBe('executing'); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -397,9 +400,7 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
| cancelAllToolCalls(cancelController.signal); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(0); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| await advanceAndSettle(); | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| expect(onComplete).toHaveBeenCalledWith([ | ||||||||||||||||||||||||||||
| expect.objectContaining({ | ||||||||||||||||||||||||||||
|
|
@@ -412,6 +413,11 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| resolveExecute({ llmContent: 'output', returnDisplay: 'display' }); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Now await the schedule promise | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await schedulePromise; | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
Comment on lines
+417
to
+420
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's crucial to await act(async () => {
await schedulePromise;
}); |
||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| it.each([ | ||||||||||||||||||||||||||||
|
|
@@ -511,8 +517,9 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
| args: { data: 'sensitive' }, | ||||||||||||||||||||||||||||
| } as any; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| act(() => { | ||||||||||||||||||||||||||||
| schedule(request, new AbortController().signal); | ||||||||||||||||||||||||||||
| let schedulePromise: Promise<void>; | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| schedulePromise = schedule(request, new AbortController().signal); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
Comment on lines
+520
to
523
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Capturing the let schedulePromise: Promise<void>;
await act(async () => {
schedulePromise = schedule(request, new AbortController().signal);
}); |
||||||||||||||||||||||||||||
| await advanceAndSettle(); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -525,10 +532,13 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
| await capturedOnConfirmForTest?.(ToolConfirmationOutcome.ProceedOnce); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await advanceAndSettle(); | ||||||||||||||||||||||||||||
| await advanceAndSettle(); | ||||||||||||||||||||||||||||
| await advanceAndSettle(); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Now await the schedule promise as it should complete | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await schedulePromise; | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
Comment on lines
+538
to
+540
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| expect(mockOnUserConfirmForToolConfirmation).toHaveBeenCalledWith( | ||||||||||||||||||||||||||||
| ToolConfirmationOutcome.ProceedOnce, | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
|
|
@@ -558,8 +568,9 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
| args: {}, | ||||||||||||||||||||||||||||
| } as any; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| act(() => { | ||||||||||||||||||||||||||||
| schedule(request, new AbortController().signal); | ||||||||||||||||||||||||||||
| let schedulePromise: Promise<void>; | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| schedulePromise = schedule(request, new AbortController().signal); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
Comment on lines
+571
to
574
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Capturing the let schedulePromise: Promise<void>;
await act(async () => {
schedulePromise = schedule(request, new AbortController().signal);
}); |
||||||||||||||||||||||||||||
| await advanceAndSettle(); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -571,8 +582,13 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await capturedOnConfirmForTest?.(ToolConfirmationOutcome.Cancel); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await advanceAndSettle(); | ||||||||||||||||||||||||||||
| await advanceAndSettle(); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Now await the schedule promise | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await schedulePromise; | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
Comment on lines
+589
to
+591
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| expect(mockOnUserConfirmForToolConfirmation).toHaveBeenCalledWith( | ||||||||||||||||||||||||||||
| ToolConfirmationOutcome.Cancel, | ||||||||||||||||||||||||||||
|
|
@@ -619,8 +635,12 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
| args: {}, | ||||||||||||||||||||||||||||
| } as any; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| act(() => { | ||||||||||||||||||||||||||||
| result.current[1](request, new AbortController().signal); | ||||||||||||||||||||||||||||
| let schedulePromise: Promise<void>; | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| schedulePromise = result.current[1]( | ||||||||||||||||||||||||||||
| request, | ||||||||||||||||||||||||||||
| new AbortController().signal, | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
|
Comment on lines
+638
to
+643
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Capturing the let schedulePromise: Promise<void>;
await act(async () => {
schedulePromise = result.current[1](
request,
new AbortController().signal,
);
}); |
||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| await advanceAndSettle(); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -644,7 +664,11 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
| } as ToolResult); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| await advanceAndSettle(); | ||||||||||||||||||||||||||||
| await advanceAndSettle(); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Now await schedule | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await schedulePromise; | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
Comment on lines
+668
to
+671
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After the mock tool's execution is resolved, await act(async () => {
await schedulePromise;
}); |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const completedCalls = onComplete.mock.calls[0][0] as ToolCall[]; | ||||||||||||||||||||||||||||
| expect(completedCalls[0].status).toBe('success'); | ||||||||||||||||||||||||||||
|
|
@@ -690,8 +714,8 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
| { callId: 'multi2', name: 'tool2', args: { p: 2 } } as any, | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| act(() => { | ||||||||||||||||||||||||||||
| schedule(requests, new AbortController().signal); | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await schedule(requests, new AbortController().signal); | ||||||||||||||||||||||||||||
|
Comment on lines
+717
to
+718
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When scheduling multiple tool calls, it's important to await act(async () => {
await schedule(requests, new AbortController().signal);
}); |
||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(0); | ||||||||||||||||||||||||||||
|
|
@@ -782,38 +806,48 @@ describe('useReactToolScheduler', () => { | |||||||||||||||||||||||||||
| args: {}, | ||||||||||||||||||||||||||||
| } as any; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| act(() => { | ||||||||||||||||||||||||||||
| schedule(request1, new AbortController().signal); | ||||||||||||||||||||||||||||
| let schedulePromise1: Promise<void>; | ||||||||||||||||||||||||||||
| let schedulePromise2: Promise<void>; | ||||||||||||||||||||||||||||
|
Comment on lines
+809
to
+810
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| schedulePromise1 = schedule(request1, new AbortController().signal); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
Comment on lines
+812
to
814
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(0); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| act(() => { | ||||||||||||||||||||||||||||
| schedule(request2, new AbortController().signal); | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| schedulePromise2 = schedule(request2, new AbortController().signal); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
Comment on lines
+819
to
821
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(50); | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(0); | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(0); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Wait for first to complete | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await schedulePromise1; | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
Comment on lines
+828
to
+831
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicitly await act(async () => {
await schedulePromise1;
}); |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| expect(onComplete).toHaveBeenCalledWith([ | ||||||||||||||||||||||||||||
| expect.objectContaining({ | ||||||||||||||||||||||||||||
| status: 'success', | ||||||||||||||||||||||||||||
| request: request1, | ||||||||||||||||||||||||||||
| response: expect.objectContaining({ resultDisplay: 'done display' }), | ||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(50); | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(0); | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await vi.advanceTimersByTimeAsync(0); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Wait for second to complete | ||||||||||||||||||||||||||||
| await act(async () => { | ||||||||||||||||||||||||||||
| await schedulePromise2; | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
Comment on lines
+847
to
+849
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| expect(onComplete).toHaveBeenCalledWith([ | ||||||||||||||||||||||||||||
| expect.objectContaining({ | ||||||||||||||||||||||||||||
| status: 'success', | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A critical prompt injection vulnerability exists here. User input is passed to the
Gemini modelwithout sanitization, allowing an attacker to manipulate theLLM's behavior and execute arbitrary tool calls, potentially leading to remote code execution. This line executes a tool call originating from a slash command, which is derived from user input. Beyond the security concern, thescheduleToolCallsfunction is asynchronous and must beawaited to prevent race conditions and ensure proper application flow. Remediation for the vulnerability includes strict input validation and sanitization, implementing an allow-list for tools with schema validation, and requiring user confirmation for sensitive tool calls. The suggested code addresses the asynchronous call.