Skip to content

The agent that grows with you

[verified] fix(desktop): reveal active clarify prompts

Richard Howes34d76a1df081
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/clarify-hydration.test.tsx b/apps/desktop/src/app/session/hooks/use-message-stream/clarify-hydration.test.tsx
index 6af488231fe..de0819561df 100644
--- a/apps/desktop/src/app/session/hooks/use-message-stream/clarify-hydration.test.tsx
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/clarify-hydration.test.tsx
@@ -6,6 +6,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { ClientSessionState } from '@/app/types'
import { createClientSessionState } from '@/lib/chat-runtime'
import { clearClarifyRequest } from '@/store/clarify'
+import { onScrollToBottomRequest } from '@/store/thread-scroll'
import type { RpcEvent } from '@/types/hermes'
import { useMessageStream } from './index'
@@ -19,6 +20,9 @@ const SID = 'session-1'
let handleEvent: ((event: RpcEvent) => void) | null = null
let stateRef: MutableRefObject<Map<string, ClientSessionState>> | null = null
+let stopScrollListener: (() => void) | null = null
+
+const scrollToBottom = vi.fn()
function Harness() {
const activeSessionIdRef = useRef<string | null>(SID)
@@ -71,11 +75,15 @@ describe('clarify.request stream hydration', () => {
handleEvent = null
stateRef = null
clearClarifyRequest()
+ scrollToBottom.mockClear()
+ stopScrollListener = onScrollToBottomRequest(scrollToBottom)
})
afterEach(() => {
cleanup()
clearClarifyRequest()
+ stopScrollListener?.()
+ stopScrollListener = null
vi.restoreAllMocks()
})
@@ -93,6 +101,28 @@ describe('clarify.request stream hydration', () => {
})
})
+ it('reveals a clarify prompt raised by the active session', async () => {
+ await mountStream()
+
+ clarifyRequest({ choices: ['yes', 'no'], question: 'Ship it?', request_id: 'req-reveal' })
+
+ expect(scrollToBottom).toHaveBeenCalledOnce()
+ })
+
+ it('does not move the active thread for a background session clarify', async () => {
+ await mountStream()
+
+ act(() =>
+ handleEvent!({
+ payload: { choices: ['yes', 'no'], question: 'Ship it?', request_id: 'req-background' },
+ session_id: 'session-background',
+ type: 'clarify.request'
+ })
+ )
+
+ expect(scrollToBottom).not.toHaveBeenCalled()
+ })
+
it('merges with the real tool.start row even though its id differs from the request id', async () => {
await mountStream()
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event.ts b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event.ts
index a9cd1c82677..19cae174633 100644
--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event.ts
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event.ts
@@ -75,6 +75,7 @@ import { dropSessionState } from '@/store/session-states'
import { pruneDelegateFallbackSubagents, pruneFinishedSessionSubagents, upsertSubagent } from '@/store/subagents'
import { reportMcpToolResult } from '@/store/suggestion-providers/repair'
import { invalidateSkillSuggestionIndex } from '@/store/suggestion-providers/skill'
+import { requestScrollToBottom } from '@/store/thread-scroll'
import { clearActiveSessionTodos } from '@/store/todos'
import { recordToolDiff } from '@/store/tool-diffs'
import { setSessionDraftingTool } from '@/store/tool-drafting'
@@ -985,6 +986,10 @@ export function useGatewayEventHandler(deps: GatewayEventDeps) {
// "needs input" indicator on its row — works for the active session
// too, and survives alt-tab / window blur (unlike a toast).
updateSessionState(sessionId, state => ({ ...state, needsInput: true }))
+
+ if (sessionId === activeSessionIdRef.current) {
+ requestScrollToBottom()
+ }
}
dispatchNativeNotification({