From 718d61da56c5db45a621abc8ea31e32b15fbe753 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 5 Nov 2026 02:12:51 +0000 Subject: [PATCH 1/3] test(web): reproduce #31236, rejected Send now shows no reason A queued message's "Send now" whose promote command is rejected by the server (e.g. "Target run ... is stopping and cannot be steered.") leaves the row unchanged and tells the user nothing. This browser test fails on main until the reason is shown. Co-Authored-By: Claude Opus 5.5 --- .../chat/QueuedRunsControl.browser.test.tsx | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/chat/QueuedRunsControl.browser.test.tsx b/apps/web/src/components/chat/QueuedRunsControl.browser.test.tsx index 7e25e84135ba5..0ab25eeadc184 100644 --- a/apps/web/src/components/chat/QueuedRunsControl.browser.test.tsx +++ b/apps/web/src/components/chat/QueuedRunsControl.browser.test.tsx @@ -1,6 +1,14 @@ -import { EnvironmentId, MessageId, ThreadId } from "@t3tools/contracts"; +import { + CommandId, + EnvironmentId, + MessageId, + OrchestrationV2DispatchCommandError, + ThreadId, +} from "@t3tools/contracts"; import { serializeAssistantCitation } from "@t3tools/shared/assistantCitations"; +import * as Cause from "effect/Cause"; import * as DateTime from "effect/DateTime"; +import { AsyncResult } from "effect/reactivity"; import type { ComponentProps } from "react"; import { expect, it, vi } from "vite-plus/test"; import { page } from "vite-plus/test/browser"; @@ -8,6 +16,7 @@ import { page } from "vite-plus/test/browser"; const state = vi.hoisted(() => ({ projection: null as unknown, workflow: null as unknown, + commandResult: undefined as unknown, })); vi.mock(import("@t3tools/client-runtime/state/thread-workflows"), async (importOriginal) => ({ @@ -31,7 +40,7 @@ vi.mock(import("../../state/query"), async (importOriginal) => ({ vi.mock(import("../../state/use-atom-command"), async (importOriginal) => ({ ...(await importOriginal()), - useAtomCommand: (() => async () => undefined) as never, + useAtomCommand: (() => async () => state.commandResult) as never, })); vi.mock(import("../../assets/assetUrls"), async (importOriginal) => ({ @@ -42,11 +51,13 @@ vi.mock(import("../../assets/assetUrls"), async (importOriginal) => ({ import "~/index.css"; import { render as renderUi } from "../../../test/render"; +import { ToastProvider } from "../ui/toast"; import { QueuedRunsControl } from "./QueuedRunsControl"; function setup() { state.projection = null; state.workflow = null; + state.commandResult = undefined; } const baseProps = { @@ -203,3 +214,38 @@ it("stays inside the timeline scroller instead of growing the chat column", asyn const column = screen.getByTestId("column").element(); expect(column.scrollHeight).toBe(column.clientHeight); }); + +it("tells the user why Send now was rejected", async () => { + setup(); + const reason = "Target run run:active is stopping and cannot be steered."; + state.projection = { projection: { messages: [] } }; + state.workflow = { + activeRun: { id: "run:active" }, + canPromoteToSteer: true, + queuedRuns: [ + { + run: { id: "run:queued", userMessageId: "message:queued" }, + text: "Follow up", + attachments: [], + }, + ], + }; + state.commandResult = AsyncResult.failure( + Cause.fail( + new OrchestrationV2DispatchCommandError({ + commandId: CommandId.make("command:promote"), + commandType: "queued-message.promote-to-steer", + message: reason, + detail: reason, + }), + ), + ); + await using _screen = await renderUi( + + + , + ); + + await page.getByRole("button", { name: "Send now" }).click(); + await vi.waitFor(() => expect(page.getByText(reason).element()).toBeVisible()); +}); From 61ce489e42594f5cf4f2276773d7a6549af3b716 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 5 Nov 2026 02:17:38 +0000 Subject: [PATCH 2/3] fix(web,mobile): Send now tells you why it could not send When the server rejected "Send now" on a queued message (for example, the active run is stopping and cannot be steered), the row stayed put and the reason only reached the console. Web now shows the server's message in an error toast; mobile shows it in the existing Dialog.alert. Interrupted commands stay silent, and a short generic fallback covers failures without a message. Co-Authored-By: Claude Opus 5.5 --- .../features/threads/ThreadQueueControl.tsx | 41 ++++++++++++------- .../src/components/chat/QueuedRunsControl.tsx | 35 +++++++++++----- 2 files changed, 51 insertions(+), 25 deletions(-) diff --git a/apps/mobile/src/features/threads/ThreadQueueControl.tsx b/apps/mobile/src/features/threads/ThreadQueueControl.tsx index 3d26799c45036..b8fae5a8e0859 100644 --- a/apps/mobile/src/features/threads/ThreadQueueControl.tsx +++ b/apps/mobile/src/features/threads/ThreadQueueControl.tsx @@ -5,6 +5,10 @@ import { queuedRunEditBlockedReason, } from "@t3tools/client-runtime/queued-run-edit"; import { scopeThreadRef } from "@t3tools/client-runtime/environment"; +import { + isAtomCommandInterrupted, + squashAtomCommandFailure, +} from "@t3tools/client-runtime/state/runtime"; import { resolveUserMessagePresentation } from "@t3tools/client-runtime/user-message"; import type { ChatAttachment, EnvironmentId, RunId, ThreadId } from "@t3tools/contracts"; import { Atom } from "effect/reactivity"; @@ -21,6 +25,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context"; import { Button } from "../../components/ui/Button"; import { AppBar } from "../../components/ui/AppBar"; +import * as Dialog from "../../components/ui/Dialog"; import { AppText as Text } from "../../components/ui/AppText"; import { SymbolView } from "../../components/ui/AppSymbol"; import { Menu } from "../../components/ui/Menu"; @@ -183,22 +188,30 @@ export function ThreadQueueSheet({ route }: StaticScreenProps) { busyRef.current = true; setBusyRunId(runId); void Haptics.selectionAsync(); - if (action === "remove") { - await cancel(buildCancelQueuedRunCommand({ ...target, runId })); - } else if (workflow?.canSendNow) { - await resume({ ...target, input: { threadId: target.threadId, runId } }); - } else if (workflow?.activeRun && workflow.canPromoteToSteer) { - await promote({ - ...target, - input: { - threadId: target.threadId, - queuedRunId: runId, - targetRunId: workflow.activeRun.id, - }, - }); - } + const result = + action === "remove" + ? await cancel(buildCancelQueuedRunCommand({ ...target, runId })) + : workflow?.canSendNow + ? await resume({ ...target, input: { threadId: target.threadId, runId } }) + : workflow?.activeRun && workflow.canPromoteToSteer + ? await promote({ + ...target, + input: { + threadId: target.threadId, + queuedRunId: runId, + targetRunId: workflow.activeRun.id, + }, + }) + : null; busyRef.current = false; setBusyRunId(null); + if (action === "steer" && result?._tag === "Failure" && !isAtomCommandInterrupted(result)) { + const error = squashAtomCommandFailure(result); + Dialog.alert( + "Couldn't send queued message", + error instanceof Error ? error.message : "Try again.", + ); + } }; const content = ( diff --git a/apps/web/src/components/chat/QueuedRunsControl.tsx b/apps/web/src/components/chat/QueuedRunsControl.tsx index 97b74a75a73dc..9b86f181ba582 100644 --- a/apps/web/src/components/chat/QueuedRunsControl.tsx +++ b/apps/web/src/components/chat/QueuedRunsControl.tsx @@ -1,4 +1,8 @@ import { scopeThreadRef } from "@t3tools/client-runtime/environment"; +import { + isAtomCommandInterrupted, + squashAtomCommandFailure, +} from "@t3tools/client-runtime/state/runtime"; import { deriveThreadQueueWorkflowState } from "@t3tools/client-runtime/state/thread-workflows"; import { assistantCitationsToPlainText } from "@t3tools/shared/assistantCitations"; import { @@ -33,6 +37,7 @@ import { useAtomCommand } from "../../state/use-atom-command"; import { isImageAttachment, type ChatMessage } from "../../types"; import { cn } from "~/lib/utils"; import { Button, InlineButton } from "../ui/button"; +import { toastManager } from "../ui/toast"; import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; import type { TimestampFormat } from "@t3tools/contracts/settings"; import { GuestMessageName } from "./guestMessageStyle"; @@ -167,19 +172,27 @@ export function QueuedRunsControl({ if (!canSend || steerInFlightRef.current) return; steerInFlightRef.current = true; setBusyRunId(queuedRunId); - if (workflow?.canSendNow) { - await resume({ - environmentId: props.environmentId, - input: { threadId: props.threadId, runId: queuedRunId }, - }); - } else if (activeRun !== null) { - await promote({ - environmentId: props.environmentId, - input: { threadId: props.threadId, queuedRunId, targetRunId: activeRun.id }, - }); - } + const result = workflow?.canSendNow + ? await resume({ + environmentId: props.environmentId, + input: { threadId: props.threadId, runId: queuedRunId }, + }) + : activeRun !== null + ? await promote({ + environmentId: props.environmentId, + input: { threadId: props.threadId, queuedRunId, targetRunId: activeRun.id }, + }) + : null; steerInFlightRef.current = false; setBusyRunId(null); + if (result?._tag === "Failure" && !isAtomCommandInterrupted(result)) { + const error = squashAtomCommandFailure(result); + toastManager.add({ + type: "error", + title: "Could not send queued message", + description: error instanceof Error ? error.message : "An error occurred.", + }); + } }; useImperativeHandle(ref, () => ({ From 84a4f8f38b8240cc1be5e2309a5a48152e0ab5e8 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 5 Nov 2026 02:23:36 +0000 Subject: [PATCH 3/3] fix(mobile): match the queued-message alert title to the app's wording Co-Authored-By: Claude Opus 5.5 --- apps/mobile/src/features/threads/ThreadQueueControl.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/mobile/src/features/threads/ThreadQueueControl.tsx b/apps/mobile/src/features/threads/ThreadQueueControl.tsx index b8fae5a8e0859..20e2aba91acb8 100644 --- a/apps/mobile/src/features/threads/ThreadQueueControl.tsx +++ b/apps/mobile/src/features/threads/ThreadQueueControl.tsx @@ -208,7 +208,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps) { if (action === "steer" && result?._tag === "Failure" && !isAtomCommandInterrupted(result)) { const error = squashAtomCommandFailure(result); Dialog.alert( - "Couldn't send queued message", + "Could not send queued message", error instanceof Error ? error.message : "Try again.", ); }