fix: properly use systemMessage for hooks in UI (#16250)

This commit is contained in:
Jack Wotherspoon
2026-01-09 15:47:14 -05:00
committed by GitHub
parent 9d187e041c
commit c7d17dda49
6 changed files with 88 additions and 19 deletions
@@ -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 {