The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): the composer shows send, not stop, while a card waits
alt-glitch6e8e3783b8d6
diff --git a/apps/desktop/src/app/chat/composer/controls.tsx b/apps/desktop/src/app/chat/composer/controls.tsxindex dc278982791..5f7a124361a 100644--- a/apps/desktop/src/app/chat/composer/controls.tsx+++ b/apps/desktop/src/app/chat/composer/controls.tsx@@ -40,6 +40,7 @@ export function ComposerControls({busy,busyAction,canSubmit,+ cardWaiting = false,compactModelPill = false,conversation,disabled,@@ -57,6 +58,8 @@ export function ComposerControls({busy: booleanbusyAction: 'steer' | 'queue' | 'stop'canSubmit: boolean+ /** A card parked on the session takes typed text as its answer, so the button sends rather than stops. */+ cardWaiting?: booleancompactModelPill?: booleanconversation: ConversationPropsdisabled: boolean@@ -81,7 +84,7 @@ export function ComposerControls({const showVoicePrimary = !busy && !hasComposerPayload// Steer is just send: a payload keeps the Send affordance mid-turn. Stop// only when the composer is empty and a turn is running.- const showStop = busy && !hasComposerPayload+ const showStop = busy && !hasComposerPayload && !cardWaitingconst showQueueButton = busy && busyAction !== 'stop' && hasComposerPayload// The HUD is a Spotlight bar a few hundred pixels wide, so the four separate// voice toggles fold into one menu there and leave the row to the input. Adiff --git a/apps/desktop/src/app/chat/composer/index.tsx b/apps/desktop/src/app/chat/composer/index.tsxindex 42dd963cbc8..bdfd66a79a2 100644--- a/apps/desktop/src/app/chat/composer/index.tsx+++ b/apps/desktop/src/app/chat/composer/index.tsx@@ -33,6 +33,7 @@ import { parkQueuedPrompts, removeQueuedPrompt, unparkQueuedPrompts } from '@/stimport { $hudMode } from '@/store/hud'import { $showsAdvancedChrome } from '@/store/interface-mode'import { $chatOnboardingSolo } from '@/store/onboarding-intro'+import { sessionParkedCardWaiting } from '@/store/parked-card-answers'import { sessionBlockingPrompt } from '@/store/prompts'import { toggleReview } from '@/store/review'import { $gatewayState } from '@/store/session'@@ -173,6 +174,7 @@ export function ChatBar({// prompt owns its own dismissal (Skip, Reject, dialog close).const awaitingInput = useStore(scope.$awaitingInput)const blockingPrompt = useStore(useMemo(() => sessionBlockingPrompt(sessionId ?? null), [sessionId]))+ const cardWaiting = useStore(useMemo(() => sessionParkedCardWaiting(sessionId ?? null), [sessionId]))const activeQueueSessionKey = queueSessionKey || sessionId || freshDraftKey || nullconst { collapsed: statusDrawerCollapsed, toggle: toggleStatusDrawer } = useStatusDrawer(activeQueueSessionKey)const statusDrawerId = useId()@@ -381,7 +383,8 @@ export function ChatBar({})const hasComposerPayload = hasText || attachments.length > 0- const canSubmit = busy || hasComposerPayload+ // A waiting card turns the stop button into send, which has nothing to send while the draft is empty.+ const canSubmit = (busy && !cardWaiting) || hasComposerPayload// Steer only makes sense mid-turn, text-only (the gateway can't carry images// into a tool result) and never for a slash command (those execute inline).@@ -1108,6 +1111,7 @@ export function ChatBar({busy={busy}busyAction={busyAction}canSubmit={canSubmit}+ cardWaiting={cardWaiting}compactModelPill={poppedOut || compactPill}conversation={{active: voiceConversationActive,diff --git a/apps/desktop/src/store/clarify.ts b/apps/desktop/src/store/clarify.tsindex 6197959cb5e..c0154830bfb 100644--- a/apps/desktop/src/store/clarify.ts+++ b/apps/desktop/src/store/clarify.ts@@ -271,7 +271,7 @@ function answerClarifyText(sessionId: string, text: string): boolean {return lockTypedAnswer(request, text)}-registerParkedCardAnswer('clarify', answerClarifyText)+registerParkedCardAnswer('clarify', { $requests: $clarifyRequests, answer: answerClarifyText, waiting: hasClarifyRequest })/** The choice typed text names (any case, as the messaging path matches labels), else the words themselves. */function typedAnswer(question: ClarifyQuestion, text: string): string {diff --git a/apps/desktop/src/store/connection-request.ts b/apps/desktop/src/store/connection-request.tsindex a1b41d48b4c..98a489c986d 100644--- a/apps/desktop/src/store/connection-request.ts+++ b/apps/desktop/src/store/connection-request.ts@@ -527,7 +527,15 @@ export function answerConnectorDirectory(sessionId: string, text: string): boolereturn true}-registerParkedCardAnswer('connector-directory', answerConnectorDirectory)+registerParkedCardAnswer('connector-directory', {+ $requests: $connectionRequests,+ answer: answerConnectorDirectory,+ waiting: sessionId => {+ const request = $connectionRequests.get()[keyFor(sessionId)]++ return Boolean(request?.display && !request.settled)+ }+})// Typing a message while the card is open ends the operation, otherwise the typed message waits behind// the blocked tool until the deadline.diff --git a/apps/desktop/src/store/parked-card-answers.test.ts b/apps/desktop/src/store/parked-card-answers.test.tsindex 9e86a658d33..84502c1cc9e 100644--- a/apps/desktop/src/store/parked-card-answers.test.ts+++ b/apps/desktop/src/store/parked-card-answers.test.ts@@ -1,6 +1,9 @@+import { atom } from 'nanostores'import { afterEach, describe, expect, it, vi } from 'vitest'-import { answerParkedCard, registerParkedCardAnswer } from './parked-card-answers'+import { answerParkedCard, type ParkedCardAnswer, registerParkedCardAnswer } from './parked-card-answers'++const kind = (answer: ParkedCardAnswer) => ({ $requests: atom({}), answer, waiting: () => false })describe('parked card answers', () => {const unregister: Array<() => void> = []@@ -14,9 +17,9 @@ describe('parked card answers', () => {const takes = vi.fn((sessionId: string) => sessionId === 'session-a')const later = vi.fn(() => true)- unregister.push(registerParkedCardAnswer('test-declines', declines))- const offTakes = registerParkedCardAnswer('test-takes', takes)- unregister.push(registerParkedCardAnswer('test-later', later))+ unregister.push(registerParkedCardAnswer('test-declines', kind(declines)))+ const offTakes = registerParkedCardAnswer('test-takes', kind(takes))+ unregister.push(registerParkedCardAnswer('test-later', kind(later)))expect(answerParkedCard('session-a', 'hello')).toBe(true)expect(declines).toHaveBeenCalledWith('session-a', 'hello')diff --git a/apps/desktop/src/store/parked-card-answers.ts b/apps/desktop/src/store/parked-card-answers.tsindex e9bb3410da0..cbd9e0b4970 100644--- a/apps/desktop/src/store/parked-card-answers.ts+++ b/apps/desktop/src/store/parked-card-answers.ts@@ -1,15 +1,34 @@+import { atom, computed, type ReadableAtom } from 'nanostores'+/** Answers a card parked on `sessionId` with composer text; true when the text answered it. */export type ParkedCardAnswer = (sessionId: string, text: string) => boolean-const answers = new Map<string, ParkedCardAnswer>()+/** One card kind: its typed-answer handler, whether a card of it waits on a session, and the store that+ * predicate reads (watched so the composer redraws when a card parks or settles). */+export interface ParkedCardKind {+ $requests: ReadableAtom<object>+ answer: ParkedCardAnswer+ waiting: (sessionId: string) => boolean+}++const kinds = new Map<string, ParkedCardKind>()++// Bumped when a kind registers, unregisters or its store changes, so per-session views re-ask every kind.+const $revision = atom(0)+const bump = () => $revision.set($revision.get() + 1)-/** Register a card kind's typed-answer handler under `id`. Returns the unregister function. */-export function registerParkedCardAnswer(id: string, answer: ParkedCardAnswer): () => void {- answers.set(id, answer)+/** Register a card kind under `id`. Returns the unregister function. */+export function registerParkedCardAnswer(id: string, kind: ParkedCardKind): () => void {+ kinds.set(id, kind)+ const unlisten = kind.$requests.listen(bump)+ bump()return () => {- if (answers.get(id) === answer) {- answers.delete(id)+ unlisten()++ if (kinds.get(id) === kind) {+ kinds.delete(id)+ bump()}}}@@ -19,11 +38,20 @@ export function registerParkedCardAnswer(id: string, answer: ParkedCardAnswer):* took it as its answer: the composer then neither sends nor steers the text.*/export function answerParkedCard(sessionId: string, text: string): boolean {- for (const answer of answers.values()) {- if (answer(sessionId, text)) {+ for (const kind of kinds.values()) {+ if (kind.answer(sessionId, text)) {return true}}return false}++/** Whether any card waits on `sessionId`, so typed text would answer it. */+export function parkedCardWaiting(sessionId: string): boolean {+ return [...kinds.values()].some(kind => kind.waiting(sessionId))+}++/** `parkedCardWaiting` for one session, as a store the composer can subscribe to. */+export const sessionParkedCardWaiting = (sessionId: null | string) =>+ computed($revision, () => (sessionId ? parkedCardWaiting(sessionId) : false))diff --git a/apps/desktop/src/store/setup-beat.test.ts b/apps/desktop/src/store/setup-beat.test.tsindex ea882307471..479358bcc00 100644--- a/apps/desktop/src/store/setup-beat.test.ts+++ b/apps/desktop/src/store/setup-beat.test.ts@@ -3,7 +3,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'import { setupBeatOutcome } from '@/components/assistant-ui/setup-beat/receipt'-import { answerParkedCard } from './parked-card-answers'+import { answerParkedCard, parkedCardWaiting, sessionParkedCardWaiting } from './parked-card-answers'import { rememberServerRequest, resetServerRequestsForTests } from './server-requests'import { $setupBeatRequests, clearSetupBeat, parkSetupBeat } from './setup-beat'@@ -37,6 +37,21 @@ describe('setup_beat card', () => {expect(answerParkedCard('rt-1', 'again')).toBe(false)})+ it('reports a card waiting on the session while a beat is parked, and none once it settles', () => {+ const $waiting = sessionParkedCardWaiting('rt-1')+ const seen: boolean[] = []+ const off = $waiting.subscribe(value => seen.push(value))++ expect(parkedCardWaiting('rt-1')).toBe(false)+ parkNameCard('srq-3')+ expect(parkedCardWaiting('rt-1')).toBe(true)+ expect(parkedCardWaiting('rt-2')).toBe(false)+ expect(answerParkedCard('rt-1', 'Sid')).toBe(true)+ expect(parkedCardWaiting('rt-1')).toBe(false)+ expect(seen).toEqual([false, true, false])+ off()+ })+it('collapses every way a card can close to a receipt, and draws nothing for a card-less call', () => {expect(setupBeatOutcome({ answer: { name: 'Sid' }, beat: 'name' })).toMatchObject({ kind: 'answer' })expect(setupBeatOutcome({ beat: 'theme', said: 'make it violet' })).toMatchObject({ kind: 'said' })diff --git a/apps/desktop/src/store/setup-beat.ts b/apps/desktop/src/store/setup-beat.tsindex 25f8d90928b..44e48788654 100644--- a/apps/desktop/src/store/setup-beat.ts+++ b/apps/desktop/src/store/setup-beat.ts@@ -108,4 +108,8 @@ export function sayToSetupBeat(sessionId: string, text: string): boolean {return Boolean(text.trim()) && respond(sessionId, { said: text.trim() })}-registerParkedCardAnswer('setup_beat', sayToSetupBeat)+registerParkedCardAnswer('setup_beat', {+ $requests: $setupBeatRequests,+ answer: sayToSetupBeat,+ waiting: sessionId => Boolean($setupBeatRequests.get()[sessionId])+})diff --git a/apps/desktop/src/store/theme-pick.ts b/apps/desktop/src/store/theme-pick.tsindex 820c6bf0301..a9b55b3442a 100644--- a/apps/desktop/src/store/theme-pick.ts+++ b/apps/desktop/src/store/theme-pick.ts@@ -67,4 +67,8 @@ export function sayToThemePick(sessionId: string, text: string): boolean {return Boolean(text.trim()) && answer(sessionId, { said: text.trim() })}-registerParkedCardAnswer('theme-pick', sayToThemePick)+registerParkedCardAnswer('theme-pick', {+ $requests: $themePicks,+ answer: sayToThemePick,+ waiting: sessionId => Boolean($themePicks.get()[sessionId])+})