mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 13:53:02 -07:00
fix: properly use systemMessage for hooks in UI (#16250)
This commit is contained in:
@@ -2800,7 +2800,38 @@ describe('useGeminiStream', () => {
|
||||
});
|
||||
|
||||
describe('Agent Execution Events', () => {
|
||||
it('should handle AgentExecutionStopped event', async () => {
|
||||
it('should handle AgentExecutionStopped event with systemMessage', async () => {
|
||||
mockSendMessageStream.mockReturnValue(
|
||||
(async function* () {
|
||||
yield {
|
||||
type: ServerGeminiEventType.AgentExecutionStopped,
|
||||
value: {
|
||||
reason: 'hook-reason',
|
||||
systemMessage: 'Custom stop message',
|
||||
},
|
||||
};
|
||||
})(),
|
||||
);
|
||||
|
||||
const { result } = renderTestHook();
|
||||
|
||||
await act(async () => {
|
||||
await result.current.submitQuery('test stop');
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockAddItem).toHaveBeenCalledWith(
|
||||
{
|
||||
type: MessageType.INFO,
|
||||
text: 'Agent execution stopped: Custom stop message',
|
||||
},
|
||||
expect.any(Number),
|
||||
);
|
||||
expect(result.current.streamingState).toBe(StreamingState.Idle);
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle AgentExecutionStopped event by falling back to reason when systemMessage is missing', async () => {
|
||||
mockSendMessageStream.mockReturnValue(
|
||||
(async function* () {
|
||||
yield {
|
||||
@@ -2828,7 +2859,37 @@ describe('useGeminiStream', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle AgentExecutionBlocked event', async () => {
|
||||
it('should handle AgentExecutionBlocked event with systemMessage', async () => {
|
||||
mockSendMessageStream.mockReturnValue(
|
||||
(async function* () {
|
||||
yield {
|
||||
type: ServerGeminiEventType.AgentExecutionBlocked,
|
||||
value: {
|
||||
reason: 'hook-reason',
|
||||
systemMessage: 'Custom block message',
|
||||
},
|
||||
};
|
||||
})(),
|
||||
);
|
||||
|
||||
const { result } = renderTestHook();
|
||||
|
||||
await act(async () => {
|
||||
await result.current.submitQuery('test block');
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockAddItem).toHaveBeenCalledWith(
|
||||
{
|
||||
type: MessageType.WARNING,
|
||||
text: 'Agent execution blocked: Custom block message',
|
||||
},
|
||||
expect.any(Number),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle AgentExecutionBlocked event by falling back to reason when systemMessage is missing', async () => {
|
||||
mockSendMessageStream.mockReturnValue(
|
||||
(async function* () {
|
||||
yield {
|
||||
|
||||
Reference in New Issue
Block a user