The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): setup card review fixes
alt-glitch6c7ef487b51c
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/tools.ts b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/tools.tsindex 81d5e626011..35aed4a0063 100644--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/tools.ts+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/tools.ts@@ -5,8 +5,8 @@ import { invalidateSlashCompletions } from '@/lib/slash-completion-cache'import { refreshBackgroundProcesses } from '@/store/composer-status'import { flashPetActivity, setPetActivity } from '@/store/pet'import { recordPreviewArtifact, reofferPreviewArtifact } from '@/store/preview-status'-import { $sessionStates, isSessionInForeground, storedSessionIdForRuntimeId } from '@/store/session-states'-import { markLiveStartChat, readStartChatResult } from '@/store/start-chat'+import { $sessionStates, storedSessionIdForRuntimeId } from '@/store/session-states'+import { isStartChatCallerWatched, markLiveStartChat, readStartChatResult } from '@/store/start-chat'import { pruneDelegateFallbackSubagents, upsertSubagent } from '@/store/subagents'import { reportMcpToolResult } from '@/store/suggestion-providers/repair'import { invalidateSkillSuggestionIndex } from '@/store/suggestion-providers/skill'@@ -105,7 +105,7 @@ export function handleToolEvent(ctx: GatewayEventContext): boolean {!event.replayed &&payload?.name === 'start_chat' &&readStartChatResult(payload.result)?.status === 'started' &&- isSessionInForeground(storedSessionIdForRuntimeId(sessionId) ?? sessionId)+ isStartChatCallerWatched(storedSessionIdForRuntimeId(sessionId) ?? sessionId)) {markLiveStartChat(payload.tool_id || payload.tool_call_id || payload.id || '')}diff --git a/apps/desktop/src/components/assistant-ui/clarify/core/use-clarify-keys.ts b/apps/desktop/src/components/assistant-ui/clarify/core/use-clarify-keys.tsindex d8740f083e5..def633a46dd 100644--- a/apps/desktop/src/components/assistant-ui/clarify/core/use-clarify-keys.ts+++ b/apps/desktop/src/components/assistant-ui/clarify/core/use-clarify-keys.ts@@ -12,6 +12,7 @@ interface ClarifyKeysOptions {onToggle: (question: ClarifyQuestion, choice: string) => voidother?: booleanquestions: ClarifyQuestion[]+ shortcuts?: number}export function useClarifyKeys({@@ -22,13 +23,15 @@ export function useClarifyKeys({onConfirm,onToggle,other = true,- questions+ questions,+ shortcuts}: ClarifyKeysOptions) {const [cursor, setCursor] = useState({ question: 0, row: 0 })const questionIndex = Math.min(cursor.question, Math.max(questions.length - 1, 0))const active = questions[questionIndex]const choices = active?.choices ?? []const otherRows = other ? 1 : 0+ const shortcutRows = shortcuts ?? choices.lengthconst row = Math.min(cursor.row, choices.length - 1 + otherRows)const focusQuestion = useCallback(@@ -142,7 +145,7 @@ export function useClarifyKeys({}const pickByIndex = (event: globalThis.KeyboardEvent, index: number) => {- if (index < choices.length) {+ if (index < shortcutRows) {event.preventDefault()pick(questionIndex, index)} else if (other && index === choices.length) {@@ -214,7 +217,7 @@ export function useClarifyKeys({window.addEventListener('keydown', onKeyDown)return () => window.removeEventListener('keydown', onKeyDown)- }, [activate, active, choices.length, enabled, focusOther, formRef, move, other, pick, questionIndex])+ }, [activate, active, choices.length, enabled, focusOther, formRef, move, other, pick, questionIndex, shortcutRows])return { activeQuestion: questionIndex, cursorRow: row, focusQuestion, onOtherFocus, pick }}diff --git a/apps/desktop/src/components/assistant-ui/clarify/setup-pending.tsx b/apps/desktop/src/components/assistant-ui/clarify/setup-pending.tsxindex 354cd1e6bb8..39046b865d0 100644--- a/apps/desktop/src/components/assistant-ui/clarify/setup-pending.tsx+++ b/apps/desktop/src/components/assistant-ui/clarify/setup-pending.tsx@@ -18,7 +18,7 @@ import { ClarifyConfirmBar } from './core/confirm-bar'import { QuestionBlock } from './core/question-block'import { CLARIFY_ICON_CLASS, ClarifyShell } from './core/shell'import { useClarifyKeys } from './core/use-clarify-keys'-import { SETUP_PICKERS, SetupIntentRows } from './setup-pickers'+import { pickerShortcutCount, SETUP_PICKERS, SetupIntentRows } from './setup-pickers'import { LIVE_APPLY, useSetupRows } from './setup-rows'import { handleClarifySubmitShortcut } from './submit-shortcut'import { UndeliveredNotice } from './undelivered-notice'@@ -168,6 +168,7 @@ export function SetupChoosePending({const formRef = useRef<HTMLFormElement | null>(null)const questions = useMemo(() => [question], [question])+ const shortcuts = pickerKind === null ? (question.choices?.length ?? 0) : pickerShortcutCount(rows ?? [])const keys = useClarifyKeys({enabled: ready,@@ -177,7 +178,8 @@ export function SetupChoosePending({onConfirm: confirm,onToggle: toggle,other: freeText,- questions+ questions,+ shortcuts})const cursor = ready ? keys.cursorRow : null@@ -191,7 +193,7 @@ export function SetupChoosePending({className="my-1.5 grid gap-4"data-clarify-batch={1}data-clarify-batch-preview={ready ? undefined : ''}- data-clarify-choices={ready ? question.choices?.length || undefined : undefined}+ data-clarify-choices={ready ? shortcuts || undefined : undefined}data-clarify-other={freeText ? undefined : 'false'}data-setup-choose={kind}onKeyDownCapture={handleClarifySubmitShortcut}diff --git a/apps/desktop/src/components/assistant-ui/clarify/setup-pickers.tsx b/apps/desktop/src/components/assistant-ui/clarify/setup-pickers.tsxindex 55ea3d0bc2e..12548c9222d 100644--- a/apps/desktop/src/components/assistant-ui/clarify/setup-pickers.tsx+++ b/apps/desktop/src/components/assistant-ui/clarify/setup-pickers.tsx@@ -28,6 +28,10 @@ const SEARCH_THRESHOLD = 12const INTENTS: readonly SetupChooseIntent[] = ['now', 'later', 'save']+export function pickerShortcutCount(rows: SetupRow[]): number {+ return rows.length > SEARCH_THRESHOLD ? 0 : rows.length+}+function PickerItem({active,children,@@ -37,11 +41,11 @@ function PickerItem({active: booleanchildren: ReactNodeclassName?: string- index: number+ index: null | number}) {return (<div- aria-keyshortcuts={`${letterFor(index)} ${index + 1}`}+ aria-keyshortcuts={index === null ? undefined : `${letterFor(index)} ${index + 1}`}className={cn('min-w-0', active && 'ring-2 ring-primary/40', className)}data-highlighted={active || undefined}onMouseDown={event => event.preventDefault()}@@ -120,6 +124,7 @@ function ChipPicker({const { t } = useI18n()const [query, setQuery] = useState('')const search = query.trim().toLowerCase()+ const shortcuts = pickerShortcutCount(rows)return (<div className="grid gap-2">@@ -129,7 +134,12 @@ function ChipPicker({<div className="grid max-h-72 grid-cols-3 gap-2 overflow-y-auto p-1" role="group">{rows.map((row, index) =>search && !row.label.toLowerCase().includes(search) ? null : (- <PickerItem active={cursor === index} className="rounded-[6px]" index={index} key={row.id}>+ <PickerItem+ active={cursor === index}+ className="rounded-[6px]"+ index={index < shortcuts ? index : null}+ key={row.id}+ ><ChipclassName="w-full"icon={icon(row)}diff --git a/apps/desktop/src/components/assistant-ui/start-chat-tool.tsx b/apps/desktop/src/components/assistant-ui/start-chat-tool.tsxindex bc30d68f369..32769844081 100644--- a/apps/desktop/src/components/assistant-ui/start-chat-tool.tsx+++ b/apps/desktop/src/components/assistant-ui/start-chat-tool.tsx@@ -18,8 +18,7 @@ import { notifyError } from '@/store/notifications'import { $profiles, profileLabel } from '@/store/profile'import { setSessionOwnerHint } from '@/store/session'import { isSessionOwnerRoute } from '@/store/session-request-router'-import { isSessionInForeground } from '@/store/session-states'-import { readStartChatResult, takeLiveStartChat } from '@/store/start-chat'+import { isStartChatCallerWatched, readStartChatResult, takeLiveStartChat } from '@/store/start-chat'const TITLE_LIMIT = 40@@ -61,7 +60,7 @@ export function StartChatTool(props: ToolCallMessagePartProps) {return}- const watching = () => Boolean(callerId) && isSessionInForeground(callerId!)+ const watching = () => Boolean(callerId) && isStartChatCallerWatched(callerId!)void openStartedChat(started, callerId, navigate, watching).catch(error => notifyError(error, copy.openFailed))}, [callerId, copy.openFailed, navigate, props.toolCallId, started])diff --git a/apps/desktop/src/components/onboarding-chat/cards/setup.tsx b/apps/desktop/src/components/onboarding-chat/cards/setup.tsxindex 95c0e69b54b..51d07acfa4e 100644--- a/apps/desktop/src/components/onboarding-chat/cards/setup.tsx+++ b/apps/desktop/src/components/onboarding-chat/cards/setup.tsx@@ -22,7 +22,7 @@ import { connectorIconUrl, connectorTitle } from '@/lib/connector-tools'import { cn } from '@/lib/utils'import { type ConnectorCatalog, useConnectorCatalog } from '@/store/connector-catalog'import { $onboardingAnswers, setOnboardingAnswers } from '@/store/onboarding-answers'-import { type OnboardingPlugin, pluginNeedsApp, useOnboardingPlugins } from '@/store/onboarding-plugins'+import { type OnboardingPlugin, pluginNeedsApp, useOnboardingPluginList } from '@/store/onboarding-plugins'import { useTheme } from '@/themes'import { setAccentOverride } from '@/themes/accent-override'import { normalizeHex } from '@/themes/color'@@ -33,7 +33,7 @@ export function ConnectorsCard({ locked }: CardProps) {const runtimeId = useStore(view.$runtimeId)const { commit, done } = useCardCommit('connectors')const catalog = useConnectorCatalog(storedId, runtimeId)- const plugins = useOnboardingPlugins(storedId)+ const plugins = useOnboardingPluginList(storedId) ?? []return <ConnectorPicks catalog={catalog} commit={commit} done={done} locked={locked} plugins={plugins} />}diff --git a/apps/desktop/src/lib/chat-messages/tool-parts.ts b/apps/desktop/src/lib/chat-messages/tool-parts.tsindex c0f1f130189..fb756b5de48 100644--- a/apps/desktop/src/lib/chat-messages/tool-parts.ts+++ b/apps/desktop/src/lib/chat-messages/tool-parts.ts@@ -464,7 +464,7 @@ interface PendingClarifyLocation {function findPendingClarifyLocation(messages: ChatMessage[],payload: GatewayEventPayload,- toolName = 'clarify'+ toolNames: ReadonlySet<string>): PendingClarifyLocation | null {const stableId = toolId(payload)const matchValues = toolPayloadMatchValues(payload)@@ -477,7 +477,7 @@ function findPendingClarifyLocation(for (let partIndex = message.parts.length - 1; partIndex >= 0; partIndex -= 1) {const part = message.parts[partIndex]- if (part.type !== 'tool-call' || part.toolName !== toolName || part.result !== undefined) {+ if (part.type !== 'tool-call' || !toolNames.has(part.toolName) || part.result !== undefined) {continue}@@ -530,8 +530,11 @@ export function settlePendingClarifyToolCall(keepMessageRunning: boolean,occurredAt = Date.now() / 1000): SettledClarifyProjection {- const clarifyPayload = { name: 'clarify', ...payload }- const location = findPendingClarifyLocation(messages, clarifyPayload, clarifyPayload.name)+ const location = findPendingClarifyLocation(+ messages,+ payload,+ payload.name ? new Set([payload.name]) : QUESTION_CARD_TOOLS+ )if (!location) {return { messages, streamId: null }@@ -626,7 +629,7 @@ export function restorePendingBlockingToolCall(clarifyPayload: GatewayEventPayload & { name: string },occurredAt = Date.now() / 1000): PendingClarifyProjection {- const location = findPendingClarifyLocation(messages, clarifyPayload, clarifyPayload.name)+ const location = findPendingClarifyLocation(messages, clarifyPayload, new Set([clarifyPayload.name]))if (location) {const message = messages[location.messageIndex]diff --git a/apps/desktop/src/lib/keybinds/composer-focus-keys.ts b/apps/desktop/src/lib/keybinds/composer-focus-keys.tsindex 7e7e9406d52..c55fb4f9fa2 100644--- a/apps/desktop/src/lib/keybinds/composer-focus-keys.ts+++ b/apps/desktop/src/lib/keybinds/composer-focus-keys.ts@@ -99,8 +99,8 @@ export function isActivateOnEnterTarget(target: EventTarget | null): boolean {/*** True when a live clarify card binds THIS key, so type-to-focus must yield it.*- * The card owns Enter plus the shortcuts it actually renders — `1..N+1` and- * `A..` for its N choices and the trailing "Other" row. It does NOT own the+ * The card owns Enter plus the shortcuts it actually renders — `1..N` and+ * `A..` for its N choices. It does NOT own the* rest of the alphabet: typing a real message instead of picking an option is a* legitimate answer ("none of these"), and blanket-blocking every printable* left the user unable to start that message at all — the first letter vanished@@ -121,7 +121,7 @@ export function clarifyCardOwnsKey(event: KeyboardEvent): boolean {return true}- // "Other" is the row past the last choice, hence the +1.+ // "Other" is the row past the last choice.const rows =Number(card.getAttribute('data-clarify-choices')) + (card.getAttribute('data-clarify-other') === 'false' ? 0 : 1)diff --git a/apps/desktop/src/store/onboarding-plugins.ts b/apps/desktop/src/store/onboarding-plugins.tsindex 307b2a9341e..f5413abc050 100644--- a/apps/desktop/src/store/onboarding-plugins.ts+++ b/apps/desktop/src/store/onboarding-plugins.ts@@ -51,7 +51,3 @@ export function useOnboardingPluginList(storedId: null | string): null | Onboardreturn query.data ?? null}--export function useOnboardingPlugins(storedId: null | string): OnboardingPlugin[] {- return useOnboardingPluginList(storedId) ?? []-}diff --git a/apps/desktop/src/store/start-chat.ts b/apps/desktop/src/store/start-chat.tsindex 5a6c8f9018e..ecb0204a11c 100644--- a/apps/desktop/src/store/start-chat.ts+++ b/apps/desktop/src/store/start-chat.ts@@ -1,4 +1,5 @@import { parseMaybeObject } from '@/components/assistant-ui/tool/fallback-model/format'+import { $focusedStoredSessionId, isSessionInForeground } from '@/store/session-states'export type StartChatOutcome =| { profile: string; sessionId: string; status: 'started'; title: null | string }@@ -32,3 +33,7 @@ export function markLiveStartChat(toolCallId: string): void {export function takeLiveStartChat(toolCallId: string): boolean {return liveStarts.delete(toolCallId)}++export function isStartChatCallerWatched(storedId: string): boolean {+ return $focusedStoredSessionId.get() !== null && isSessionInForeground(storedId)+}