From 5a510582f1b6bb46e53b8ab9eca19fc19b32c513 Mon Sep 17 00:00:00 2001 From: umutcagand Date: Mon, 24 Aug 2026 00:28:36 +0300 Subject: [PATCH 1/2] fix(cli): queue custom reviews while busy --- cli/src/commands/router.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cli/src/commands/router.ts b/cli/src/commands/router.ts index d9b08aa766..dde9d76ec4 100644 --- a/cli/src/commands/router.ts +++ b/cli/src/commands/router.ts @@ -352,7 +352,18 @@ export async function routeUserPrompt( setInputFocused(true) inputRef.current?.focus() - sendMessage({ content: buildReviewPrompt('custom', trimmed), agentMode }) + const reviewPrompt = buildReviewPrompt('custom', trimmed) + if ( + isStreaming || + streamMessageIdRef.current || + isChainInProgressRef.current + ) { + const pendingAttachmentsForQueue = capturePendingAttachments() + addToQueue(reviewPrompt, pendingAttachmentsForQueue) + return + } + + sendMessage({ content: reviewPrompt, agentMode }) setTimeout(() => { scrollToLatest() }, 0) From 57152d1cbfbbbc5e81bd006bfd3cd38920e56aee Mon Sep 17 00:00:00 2001 From: umutcagand Date: Mon, 24 Aug 2026 00:28:37 +0300 Subject: [PATCH 2/2] test(cli): cover queued custom reviews --- .../commands/__tests__/review-queue.test.ts | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 cli/src/commands/__tests__/review-queue.test.ts diff --git a/cli/src/commands/__tests__/review-queue.test.ts b/cli/src/commands/__tests__/review-queue.test.ts new file mode 100644 index 0000000000..2f9f13f846 --- /dev/null +++ b/cli/src/commands/__tests__/review-queue.test.ts @@ -0,0 +1,84 @@ +import { afterEach, describe, expect, mock, test } from 'bun:test' + +import { buildReviewPrompt } from '../prompt-builders' +import { routeUserPrompt } from '../router' +import { useChatStore } from '../../state/chat-store' + +import type { RouterParams } from '../command-registry' + +const createMockParams = ( + overrides: Partial = {}, +): RouterParams => ({ + agentMode: 'DEFAULT', + inputRef: { current: null }, + inputValue: 'focus on the authentication flow', + isChainInProgressRef: { current: false }, + isStreaming: false, + logoutMutation: {} as RouterParams['logoutMutation'], + streamMessageIdRef: { current: null }, + addToQueue: mock(() => {}), + clearMessages: mock(() => {}), + saveToHistory: mock(() => {}), + scrollToLatest: mock(() => {}), + sendMessage: mock(async () => {}), + setCanProcessQueue: mock(() => {}), + setInputFocused: mock(() => {}), + setInputValue: mock(() => {}), + setIsAuthenticated: mock(() => {}), + setMessages: mock(() => {}), + setUser: mock(() => {}), + ...overrides, +}) + +describe('custom review routing', () => { + afterEach(() => { + useChatStore.getState().reset() + }) + + test('queues a custom review while a response is in progress', async () => { + const attachment = { + kind: 'text' as const, + id: 'requirements', + content: 'Review the login requirements.', + preview: 'Review the login requirements.', + charCount: 32, + } + const addToQueue = mock(() => {}) + const sendMessage = mock(async () => {}) + useChatStore.setState({ + inputMode: 'review', + pendingAttachments: [attachment], + }) + + const params = createMockParams({ + addToQueue, + isStreaming: true, + sendMessage, + }) + + await routeUserPrompt(params) + + expect(addToQueue).toHaveBeenCalledWith( + buildReviewPrompt('custom', params.inputValue), + [attachment], + ) + expect(sendMessage).not.toHaveBeenCalled() + expect(useChatStore.getState().pendingAttachments).toEqual([]) + }) + + test('sends a custom review immediately when idle', async () => { + const addToQueue = mock(() => {}) + const sendMessage = mock(async () => {}) + useChatStore.setState({ inputMode: 'review' }) + + const params = createMockParams({ addToQueue, sendMessage }) + + await routeUserPrompt(params) + + expect(sendMessage).toHaveBeenCalledWith({ + content: buildReviewPrompt('custom', params.inputValue), + agentMode: params.agentMode, + }) + expect(addToQueue).not.toHaveBeenCalled() + }) +})