The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): tell the user when a clarify request never reached the app
Hermes Agentf4795c922c2e
diff --git a/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx b/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsxindex b6d46bb00ac..bc22256d76b 100644--- a/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx+++ b/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx@@ -755,6 +755,99 @@ describe('ClarifyTool batch card', () => {expect((screen.getByRole('button', { name: /Confirm and continue/ }) as HTMLButtonElement).disabled).toBe(true)})+ // #98645: when the request never reaches this window the preview used to+ // sit disabled for the tool's whole 300s timeout with nothing said.+ it('asks the backend to re-deliver a request that never arrived, then says it did not reach the app', async () => {+ vi.useFakeTimers()++ try {+ const request = vi.fn(async (..._args: unknown[]) => ({ events: [], open_requests: [] }))+ $activeSessionId.set('session-1')+ $gateway.set({ request } as never)+ renderClarify(<ClarifyTool {...liveBatchProps()} />)++ expect(screen.queryByText(/didn't reach the app/)).toBeNull()++ await act(async () => {+ await vi.advanceTimersByTimeAsync(4_000)+ })++ expect(request.mock.calls[0]?.slice(0, 2)).toEqual([+ 'session.events.since',+ { last_seen: Number.MAX_SAFE_INTEGER, session_id: 'session-1' }+ ])+ expect(screen.getByRole('status').textContent).toMatch(/didn't reach the app.*Press Stop/)+ expect(document.querySelector('[data-clarify-batch-preview]')?.getAttribute('aria-busy')).toBeNull()+ // Nothing on the card can answer, so the actions go rather than sit disabled.+ expect(screen.queryByRole('button', { name: /Confirm and continue/ })).toBeNull()+ expect(screen.queryByRole('button', { name: /Skip/ })).toBeNull()+ } finally {+ vi.useRealTimers()+ }+ })++ it('goes live when the re-delivery finds the request still open on the backend', async () => {+ vi.useFakeTimers()++ try {+ liveServerRequest('request-batch')++ // The channel re-delivers `open_requests` to the request handlers (which+ // park the clarify) before the call resolves.+ const request = vi.fn(async (method: string) => {+ if (method === 'session.events.since') {+ setClarifyRequest({+ choices: null,+ multiSelect: false,+ question: '',+ questions: [+ { choices: ['red', 'blue'], multiSelect: false, qid: 'q0', question: 'Color?' },+ { choices: null, multiSelect: false, qid: 'q1', question: 'Name?' }+ ],+ requestId: 'request-batch',+ sessionId: 'session-1'+ })+ }++ return { events: [], open_requests: [] }+ })++ $activeSessionId.set('session-1')+ $gateway.set({ request } as never)+ renderClarify(<ClarifyTool {...liveBatchProps()} />)++ await act(async () => {+ await vi.advanceTimersByTimeAsync(4_000)+ })++ expect((screen.getByRole('button', { name: /red/ }) as HTMLButtonElement).disabled).toBe(false)+ expect(document.querySelector('[data-clarify-batch-preview]')).toBeNull()+ expect(screen.queryByText(/didn't reach the app/)).toBeNull()+ } finally {+ vi.useRealTimers()+ }+ })++ it('shows the same notice on a single-question card whose request never arrived', async () => {+ vi.useFakeTimers()++ try {+ $activeSessionId.set('session-1')+ $gateway.set({ request: vi.fn(async () => ({ events: [], open_requests: [] })) } as never)+ renderClarify(<ClarifyTool {...liveClarifyProps()} />)++ await act(async () => {+ await vi.advanceTimersByTimeAsync(4_000)+ })++ expect(screen.getByRole('status').textContent).toMatch(/didn't reach the app/)+ expect(screen.queryByRole('button', { name: /Continue/ })).toBeNull()+ expect(screen.queryByRole('button', { name: /Skip/ })).toBeNull()+ } finally {+ vi.useRealTimers()+ }+ })+it('swaps the preview for the live form and answers with the request qids', async () => {const request = vi.fn().mockResolvedValue({ ok: true, remaining: [] })$activeSessionId.set('session-1')diff --git a/apps/desktop/src/components/assistant-ui/clarify-tool.tsx b/apps/desktop/src/components/assistant-ui/clarify-tool.tsxindex a7542f1ddfc..e056a232395 100644--- a/apps/desktop/src/components/assistant-ui/clarify-tool.tsx+++ b/apps/desktop/src/components/assistant-ui/clarify-tool.tsx@@ -17,13 +17,14 @@ import { requestComposerFocus, requestComposerInsert } from '@/app/chat/composerimport { useSessionView } from '@/app/chat/session-view'import { ToolFallback } from '@/components/assistant-ui/tool/fallback'import { WIDGET_SHELL_CLASS } from '@/components/chat/widget-shell'+import { Alert, AlertDescription } from '@/components/ui/alert'import { Button } from '@/components/ui/button'import { Kbd } from '@/components/ui/kbd'import { Textarea } from '@/components/ui/textarea'import { Tip } from '@/components/ui/tooltip'import { useI18n } from '@/i18n'import { triggerHaptic } from '@/lib/haptics'-import { CircleLetterA, Loader2, MessageQuestion } from '@/lib/icons'+import { AlertTriangle, CircleLetterA, Loader2, MessageQuestion } from '@/lib/icons'import { isSubmitEnter } from '@/lib/ime'import { visibleClarifyCard } from '@/lib/keybinds/composer-focus-keys'import { cn } from '@/lib/utils'@@ -214,11 +215,24 @@ function ClarifyLine({)}-function KeyBadge({ char, preview, selected }: { char: string; preview?: boolean; selected: boolean }) {+function KeyBadge({+ char,+ disabled,+ preview,+ selected+}: {+ char: string+ disabled?: boolean+ preview?: boolean+ selected: boolean+}) {+ // The "Other" row is a <label>, which has no :disabled state of its own —+ // dim its badge alongside the disabled textarea so it matches the options.return (<KbdclassName={cn('mt-px',+ disabled && 'opacity-50',selected && 'border-primary bg-primary text-white shadow-none',!selected && preview && 'border-primary text-primary shadow-none')}@@ -372,6 +386,65 @@ function ClarifyToolSingleSettled({ args, result }: ToolCallMessagePartProps) {)}+/** How long a painted card may wait for its gateway request before asking the+ * backend to re-deliver it. `clarify.request` normally trails `tool.start` by+ * a tick; seconds of silence mean the frame was lost on the way. */+const CLARIFY_DELIVERY_GRACE_MS = 4_000++/**+ * True once the card has waited past the grace period for a request that+ * never arrived, and a re-delivery attempt found nothing (#98645).+ *+ * The attempt asks the owner socket for `session.events.since` from the end+ * of the ring: no events come back, but the channel re-delivers the+ * session's `open_requests` to the request handlers before the call+ * resolves, so a request the backend still holds parks and the card goes+ * live on its own.+ */+function useUndeliveredClarify(sessionId: null | string, waiting: boolean): boolean {+ const [undelivered, setUndelivered] = useState(false)++ useEffect(() => {+ if (!waiting || !sessionId) {+ return+ }++ let cancelled = false++ const timer = window.setTimeout(async () => {+ const gateway = $gateway.get()++ if (gateway) {+ try {+ await requestForOwnedSession(+ sessionId,+ gateway.request.bind(gateway) as typeof gateway.request,+ 'session.events.since',+ {+ last_seen: Number.MAX_SAFE_INTEGER,+ session_id: sessionId+ }+ )+ } catch {+ // An older backend or a dropped socket: the notice is still right.+ }+ }++ if (!cancelled && !sessionClarifyRequest(sessionId).get()) {+ setUndelivered(true)+ }+ }, CLARIFY_DELIVERY_GRACE_MS)++ return () => {+ cancelled = true+ window.clearTimeout(timer)+ setUndelivered(false)+ }+ }, [sessionId, waiting])++ return waiting && undelivered+}+function ClarifyToolPending(props: ToolCallMessagePartProps) {// The tool row is in whichever session's transcript rendered it — read THAT// session's clarify (primary or tile), not the globally-active one.@@ -384,6 +457,7 @@ function ClarifyToolPending(props: ToolCallMessagePartProps) {// settled card. Latch submit so that gap doesn't demote; Stop also clears// the request and must still collapse an unanswered card.const [answered, setAnswered] = useState(false)+ const undelivered = useUndeliveredClarify(sessionId, messageRunning && !request && !answered)// Stopped mid-prompt with no result — don't leave a dead interactive panel.// `session.info` reports running=false while clarify is blocking, so the@@ -399,20 +473,49 @@ function ClarifyToolPending(props: ToolCallMessagePartProps) {// disabled preview immediately instead of a spinner (the single-question// card does the same while request_id races the tool block).if (request?.questions?.length || fromArgs.questions) {- return <ClarifyToolBatchPending fromArgs={fromArgs} onAnswered={() => setAnswered(true)} request={request} />+ return (+ <ClarifyToolBatchPending+ fromArgs={fromArgs}+ onAnswered={() => setAnswered(true)}+ request={request}+ undelivered={undelivered}+ />+ )}- return <ClarifyToolSinglePending fromArgs={fromArgs} onAnswered={() => setAnswered(true)} request={request} />+ return (+ <ClarifyToolSinglePending+ fromArgs={fromArgs}+ onAnswered={() => setAnswered(true)}+ request={request}+ undelivered={undelivered}+ />+ )+}++/** Heads a card whose request never reached this window: nothing on it can+ * answer, so say so and point at the way out instead of a silent wait. */+function UndeliveredNotice() {+ const { t } = useI18n()++ return (+ <Alert className="gap-x-2 px-3 py-2 text-xs" role="status" variant="warning">+ <AlertTriangle />+ <AlertDescription>{t.assistant.clarify.notDelivered}</AlertDescription>+ </Alert>+ )}function ClarifyToolSinglePending({fromArgs,onAnswered,- request+ request,+ undelivered}: {fromArgs: ClarifyArgsonAnswered: () => voidrequest: ClarifyRequest | null+ undelivered: boolean}) {const { t } = useI18n()const copy = t.assistant.clarify@@ -747,12 +850,13 @@ function ClarifyToolSinglePending({</span><MessageQuestion aria-hidden className="mt-px size-4 shrink-0 text-(--ui-text-tertiary)" /></div>+ {undelivered ? <UndeliveredNotice /> : null}{hasChoices ? (<div className="grid gap-px" role="group">{choices.map((choice, index) => (<ChoiceButton- active={activeIndex === index}+ active={!undelivered && activeIndex === index}char={letterFor(index)}choice={choice}disabled={submitting || !ready}@@ -766,13 +870,14 @@ function ClarifyToolSinglePending({className={cn(OPTION_ROW_CLASS,'items-center',- activeIndex === choices.length && 'bg-(--chrome-action-hover)'+ !undelivered && activeIndex === choices.length && 'bg-(--chrome-action-hover)')}- data-highlighted={activeIndex === choices.length || undefined}+ data-highlighted={(!undelivered && activeIndex === choices.length) || undefined}><KeyBadgechar={letterFor(choices.length)}- preview={otherFocused || activeIndex === choices.length}+ disabled={submitting || !ready}+ preview={!undelivered && (otherFocused || activeIndex === choices.length)}selected={Boolean(trimmedDraft)}/><Textarea@@ -814,23 +919,33 @@ function ClarifyToolSinglePending({)}</ClarifyShell>- <div className="flex items-center justify-end gap-1">- <Button disabled={submitting || !ready} onClick={() => void respond('')} size="xs" type="button" variant="text">- {copy.skip}- </Button>- <Button disabled={submitting || !ready || !pendingAnswer} size="xs" type="submit">- {submitting ? (- <Loader2 className="size-3 animate-spin" />- ) : (- <>- {copy.continueLabel}- <span aria-hidden className="ml-0.5 text-[0.625rem] opacity-70">- ⏎- </span>- </>- )}- </Button>- </div>+ {/* Nothing here can answer an undelivered request — drop the actions+ like the settled card does rather than leave a dead primary button. */}+ {undelivered ? null : (+ <div className="flex items-center justify-end gap-1">+ <Button+ disabled={submitting || !ready}+ onClick={() => void respond('')}+ size="xs"+ type="button"+ variant="text"+ >+ {copy.skip}+ </Button>+ <Button disabled={submitting || !ready || !pendingAnswer} size="xs" type="submit">+ {submitting ? (+ <Loader2 className="size-3 animate-spin" />+ ) : (+ <>+ {copy.continueLabel}+ <span aria-hidden className="ml-0.5 text-[0.625rem] opacity-70">+ ⏎+ </span>+ </>+ )}+ </Button>+ </div>+ )}</form>)}@@ -921,7 +1036,7 @@ function BatchQuestionBlock({/>))}<label className={cn(OPTION_ROW_CLASS, 'items-center')}>- <KeyBadge char={letterFor(choices.length)} selected={Boolean(staged.draft.trim())} />+ <KeyBadge char={letterFor(choices.length)} disabled={disabled} selected={Boolean(staged.draft.trim())} /><TextareaclassName={CLARIFY_TEXTAREA_CLASS}disabled={disabled}@@ -960,11 +1075,13 @@ const emptyStage = { choices: [] as string[], draft: '' }function ClarifyToolBatchPending({fromArgs,onAnswered,- request+ request,+ undelivered}: {fromArgs?: ClarifyArgsonAnswered: () => voidrequest: ClarifyRequest | null+ undelivered: boolean}) {const { t } = useI18n()const copy = t.assistant.clarify@@ -1176,14 +1293,14 @@ function ClarifyToolBatchPending({return (<form- aria-busy={ready ? undefined : 'true'}+ aria-busy={ready || undelivered ? undefined : 'true'}className="my-1.5 grid gap-4"data-clarify-batch={questions.length}data-clarify-batch-preview={ready ? undefined : ''}onKeyDownCapture={handleClarifySubmitShortcut}onSubmit={handleSubmit}>- {ready ? null : (+ {ready || undelivered ? null : (<span className="sr-only" role="status">{copy.loadingQuestion}</span>@@ -1195,6 +1312,7 @@ function ClarifyToolBatchPending({</span><MessageQuestion aria-hidden className={CLARIFY_ICON_CLASS} /></div>+ {undelivered ? <UndeliveredNotice /> : null}{questions.map(question => (<BatchQuestionBlockdisabled={disabled}@@ -1208,23 +1326,25 @@ function ClarifyToolBatchPending({))}</ClarifyShell>- <div className="flex items-center justify-end gap-1">- <Button disabled={disabled} onClick={() => void cancelAll()} size="xs" type="button" variant="text">- {copy.skip}- </Button>- <Button disabled={disabled || !allStaged} size="xs" type="submit">- {submitting ? (- <Loader2 className="size-3 animate-spin" />- ) : (- <>- {copy.confirmAndContinueLabel}- <span aria-hidden className="ml-0.5 text-[0.625rem] opacity-70">- ⏎- </span>- </>- )}- </Button>- </div>+ {undelivered ? null : (+ <div className="flex items-center justify-end gap-1">+ <Button disabled={disabled} onClick={() => void cancelAll()} size="xs" type="button" variant="text">+ {copy.skip}+ </Button>+ <Button disabled={disabled || !allStaged} size="xs" type="submit">+ {submitting ? (+ <Loader2 className="size-3 animate-spin" />+ ) : (+ <>+ {copy.confirmAndContinueLabel}+ <span aria-hidden className="ml-0.5 text-[0.625rem] opacity-70">+ ⏎+ </span>+ </>+ )}+ </Button>+ </div>+ )}</form>)}diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.tsindex 79495c5e26b..092fa629052 100644--- a/apps/desktop/src/i18n/de.ts+++ b/apps/desktop/src/i18n/de.ts@@ -5643,7 +5643,9 @@ export const deOverrides = {questionProgress: (answered, total) => `${answered} von ${total} beantwortet`,lateAnswer: (question, choice) => `Re: „${question}“ — meine Antwort: ${choice}`,lateAnswerTip: 'Diese Antwort als Folgenachricht entwerfen',- lateAnswerHint: 'Dieser Prompt wartet nicht mehr. Wählen Sie eine Option, um sie als Folgenachricht zu entwerfen.'+ lateAnswerHint: 'Dieser Prompt wartet nicht mehr. Wählen Sie eine Option, um sie als Folgenachricht zu entwerfen.',+ notDelivered:+ 'Diese Frage hat die App nicht erreicht und kann hier nicht beantwortet werden. Klicken Sie auf Stopp, um den Durchgang zu beenden, und antworten Sie dann im Chat.'},catalogInstall: {preparing: 'Installation wird vorbereitet…',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 2176df7746a..25436e6ccca 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -5236,7 +5236,9 @@ export const en: Translations = {questionProgress: (answered, total) => `${answered} of ${total} answered`,lateAnswer: (question, choice) => `Re: "${question}" — my answer: ${choice}`,lateAnswerTip: 'Draft this answer as a follow-up message',- lateAnswerHint: 'This prompt is no longer waiting. Pick an option to draft it as a follow-up message.'+ lateAnswerHint: 'This prompt is no longer waiting. Pick an option to draft it as a follow-up message.',+ notDelivered:+ "This question didn't reach the app, so it can't be answered here. Press Stop to end the turn, then reply in chat."},catalogInstall: {preparing: 'Preparing the install…',diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.tsindex f8971e89e56..15f5c5b7b21 100644--- a/apps/desktop/src/i18n/es.ts+++ b/apps/desktop/src/i18n/es.ts@@ -5634,7 +5634,9 @@ export const esOverrides = {lateAnswer: (question, choice) => `Con respecto a “${question}”: mi respuesta es ${choice}`,lateAnswerTip: 'Redactar esta respuesta como mensaje de seguimiento',lateAnswerHint:- 'Este prompt ya no espera una respuesta. Elige una opción para redactarla como mensaje de seguimiento.'+ 'Este prompt ya no espera una respuesta. Elige una opción para redactarla como mensaje de seguimiento.',+ notDelivered:+ 'Esta pregunta no llegó a la app, así que no se puede responder aquí. Pulsa Detener para terminar el turno y luego responde en el chat.'},catalogInstall: {preparing: 'Preparando la instalación…',diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.tsindex a0c5eaf035c..1859ef62dd4 100644--- a/apps/desktop/src/i18n/fr.ts+++ b/apps/desktop/src/i18n/fr.ts@@ -5654,7 +5654,9 @@ export const frOverrides = {lateAnswer: (question, choice) => `Re : « ${question} » — ma réponse : ${choice}`,lateAnswerTip: 'Rédiger cette réponse comme message de suivi',lateAnswerHint:- "Cette invite n'attend plus de réponse. Choisissez une option pour la rédiger comme message de suivi."+ "Cette invite n'attend plus de réponse. Choisissez une option pour la rédiger comme message de suivi.",+ notDelivered:+ "Cette question n'a pas atteint l'app, elle ne peut donc pas être répondue ici. Appuyez sur Arrêter pour terminer le tour, puis répondez dans le chat."},catalogInstall: {preparing: 'Préparation de l’installation…',diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 4b65c90c687..784ac76764c 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -3872,7 +3872,9 @@ export const ja = defineLocale({questionProgress: (answered, total) => `${total}問中${answered}問回答済み`,lateAnswer: (question, choice) => `「${question}」について — 私の回答: ${choice}`,lateAnswerTip: 'この回答をフォローアップメッセージとして下書きします',- lateAnswerHint: 'この質問はもう回答を待っていません。選択肢を選ぶとフォローアップメッセージとして下書きされます。'+ lateAnswerHint: 'この質問はもう回答を待っていません。選択肢を選ぶとフォローアップメッセージとして下書きされます。',+ notDelivered:+ 'この質問はアプリに届かなかったため、ここでは回答できません。停止を押してターンを終了し、チャットで返信してください。'},tool: {copyCode: 'コードをコピー',diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex 0693f142eac..98490c38213 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -3994,7 +3994,9 @@ export const ru = defineLocale({questionProgress: (answered, total) => `Ответ дан на ${answered} из ${total}`,lateAnswer: (question, choice) => `Re: «${question}» — мой ответ: ${choice}`,lateAnswerTip: 'Составить этот ответ как продолжение',- lateAnswerHint: 'Этот промпт больше не ждёт. Выберите вариант, чтобы составить его как сообщение-продолжение.'+ lateAnswerHint: 'Этот промпт больше не ждёт. Выберите вариант, чтобы составить его как сообщение-продолжение.',+ notDelivered:+ 'Этот вопрос не дошёл до приложения, поэтому ответить здесь нельзя. Нажмите «Стоп», чтобы завершить ход, и ответьте в чате.'},catalogInstall: {preparing: 'Готовим установку…',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex f3a439e131b..00bbffa14d3 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -4363,6 +4363,7 @@ export interface Translations {lateAnswer: (question: string, choice: string) => stringlateAnswerTip: stringlateAnswerHint: string+ notDelivered: string}catalogInstall: {preparing: stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex ca87319adb8..04ac2cb2b7b 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -4043,7 +4043,8 @@ export const zhHant = defineLocale({questionProgress: (answered, total) => `已回答 ${answered}/${total}`,lateAnswer: (question, choice) => `關於「${question}」 — 我的回答: ${choice}`,lateAnswerTip: '將此回答起草為後續訊息',- lateAnswerHint: '此問題已不再等待回答。選擇一個選項會將其起草為後續訊息。'+ lateAnswerHint: '此問題已不再等待回答。選擇一個選項會將其起草為後續訊息。',+ notDelivered: '此問題未送達應用程式,無法在此回答。請按停止結束本輪,然後在聊天中回覆。'},tool: {copyCode: '複製程式碼',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 23f64de9dbc..43ad7ba5e87 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -4830,7 +4830,8 @@ export const zh = defineLocale({questionProgress: (answered, total) => `已回答 ${answered}/${total}`,lateAnswer: (question, choice) => `关于"${question}" — 我的回答: ${choice}`,lateAnswerTip: '将此回答起草为后续消息',- lateAnswerHint: '此问题已不再等待回答。选择一个选项会将其起草为后续消息。'+ lateAnswerHint: '此问题已不再等待回答。选择一个选项会将其起草为后续消息。',+ notDelivered: '此问题未送达应用,无法在此回答。请按停止结束本轮,然后在聊天中回复。'},catalogInstall: {preparing: '正在准备安装…',