diff --git a/docs/webui.md b/docs/webui.md
index e3010056a..179a6403b 100644
--- a/docs/webui.md
+++ b/docs/webui.md
@@ -231,6 +231,8 @@ During a response, desktop Enter appends input to one waiting message, preservin
Automatic sending continues across topic switches and short reconnects while the page stays live. Reloading, reopening, leaving the page, or the browser freezing it restores waiting content for manual sending; choose **Send now** or edit and send it when ready.
+When you send a follow-up while the agent is busy, a dashed edge shows that the message is waiting for the model. The usual edge returns when the request that answers that message begins. This live hint is cleared on Stop or disconnect and is not restored from history.
+
For image generation, configure an image provider first and then use the WebUI image mode from the composer. See [`image-generation.md`](./image-generation.md) for provider setup and output behavior.
## Channels
diff --git a/nanobot/channels/websocket/tests/test_websocket_channel.py b/nanobot/channels/websocket/tests/test_websocket_channel.py
index a37de0b1f..41075043a 100644
--- a/nanobot/channels/websocket/tests/test_websocket_channel.py
+++ b/nanobot/channels/websocket/tests/test_websocket_channel.py
@@ -5434,6 +5434,7 @@ async def test_user_messages_fan_out_to_other_clients_on_the_same_chat(
"chat_id": "shared-chat",
"text": "one more detail",
"starts_turn": False,
+ "waiting_for_model": True,
"turn_id": "steer-a",
"input_id": "user:steer-a",
"active_turn_id": "turn-a",
@@ -5446,12 +5447,13 @@ async def test_user_messages_fan_out_to_other_clients_on_the_same_chat(
payload["turn_id"],
payload["starts_turn"],
payload["active_turn_id"],
+ payload.get("waiting_for_model"),
)
for payload in origin_payloads
if payload["event"] == "message_accepted"
] == [
- ("message_accepted", "turn-a", True, "turn-a"),
- ("message_accepted", "steer-a", False, "turn-a"),
+ ("message_accepted", "turn-a", True, "turn-a", None),
+ ("message_accepted", "steer-a", False, "turn-a", True),
]
outsider.send.assert_not_awaited()
assert bus.publish_inbound.await_count == 2
diff --git a/nanobot/webui/inbound_commands.py b/nanobot/webui/inbound_commands.py
index b5d931f4a..771ce3cbc 100644
--- a/nanobot/webui/inbound_commands.py
+++ b/nanobot/webui/inbound_commands.py
@@ -248,6 +248,7 @@ class WebUICommandRouter:
*,
turn_id: str | None,
starts_turn: bool,
+ waiting_for_model: bool,
media: list[dict[str, Any]],
cli_apps: list[dict[str, Any]],
mcp_presets: list[dict[str, Any]],
@@ -262,6 +263,8 @@ class WebUICommandRouter:
if turn_id is not None:
body["turn_id"] = turn_id
body["input_id"] = f"user:{turn_id}"
+ if waiting_for_model:
+ body["waiting_for_model"] = True
if media:
body["media_urls"] = media
if cli_apps:
@@ -812,6 +815,12 @@ class WebUICommandRouter:
if queued_owner is not None:
metadata[WEBSOCKET_TURN_OWNER_METADATA_KEY] = queued_owner
+ # Live presentation only: a follow-up accepted while another turn owns the chat.
+ waiting_for_model = (
+ is_webui and temporary_policy is None and turn_id is not None
+ and not restart_control and not is_user_shell and not content.lstrip().startswith("/")
+ and queued_owner is None and websocket_turn_id(chat_id) is not None
+ )
accepted = False
session_generation: str | None = None
session_created = False
@@ -905,6 +914,7 @@ class WebUICommandRouter:
content,
turn_id=turn_id,
starts_turn=queued_owner is not None,
+ waiting_for_model=waiting_for_model,
media=media,
cli_apps=cli_apps,
mcp_presets=mcp_presets,
@@ -919,6 +929,7 @@ class WebUICommandRouter:
chat_id=chat_id,
turn_id=turn_id,
starts_turn=queued_owner is not None,
+ **({"waiting_for_model": True} if waiting_for_model else {}),
**({"media_urls": media} if media else {}),
**(
{"active_turn_id": active_turn_id}
diff --git a/tests/agent/test_session_inputs.py b/tests/agent/test_session_inputs.py
index c64bf2d99..957d08fd7 100644
--- a/tests/agent/test_session_inputs.py
+++ b/tests/agent/test_session_inputs.py
@@ -102,11 +102,11 @@ async def test_session_message_text_is_not_dispatched_as_a_slash_command(
loop: AgentLoop,
) -> None:
loop.sessions.save(loop.sessions.get_or_create("telegram:target"))
- await loop._dispatch_inbound(_message("/stop"))
- await asyncio.wait_for(
- asyncio.gather(*loop._active_tasks["telegram:target"]), timeout=2,
- )
- response = await asyncio.wait_for(loop.bus.consume_outbound(), timeout=2)
+ # Bound hangs without imposing a tight deadline on SQLite checkpoint writes.
+ async with asyncio.timeout(10):
+ await loop._dispatch_inbound(_message("/stop"))
+ await asyncio.gather(*loop._active_tasks["telegram:target"])
+ response = loop.bus.outbound.get_nowait()
assert response.content == "Reviewed"
loop.provider.chat_stream_with_retry.assert_awaited_once()
diff --git a/webui/browser/attachment-layout-fixture.tsx b/webui/browser/attachment-layout-fixture.tsx
index b34f58201..a38c7b4a2 100644
--- a/webui/browser/attachment-layout-fixture.tsx
+++ b/webui/browser/attachment-layout-fixture.tsx
@@ -59,8 +59,16 @@ const samples: { label: string; message: UIMessage }[] = [
];
export function AttachmentLayoutFixture() {
+ const processingSamples: typeof samples = (["pending", "consumed"] as const).map((status) => ({
+ label: `Attachments: ${status}`,
+ message: {
+ id: `attachments-${status}`, role: "user", content: "", createdAt: 8, processingStatus: status,
+ media: [archive, image("Study.svg", "#83a9d8"), { kind: "video", name: "sample.webm", url: sampleVideo }],
+ },
+ }));
+ const messages = new URLSearchParams(window.location.search).has("processing") ? processingSamples : samples;
return
- {samples.map(({ label, message }) =>
+ {messages.map(({ label, message }) => )}
diff --git a/webui/browser/attachment-layout.spec.ts b/webui/browser/attachment-layout.spec.ts
index 11b1ca7ea..dd1db3248 100644
--- a/webui/browser/attachment-layout.spec.ts
+++ b/webui/browser/attachment-layout.spec.ts
@@ -150,6 +150,31 @@ for (const width of [1024, 360]) {
}
}
+test("attachment-only pending messages keep static dashed edges in forced colors", async ({ page }) => {
+ await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
+ await page.emulateMedia({ forcedColors: "active", reducedMotion: "no-preference", colorScheme: "dark" });
+ await page.goto("/browser/fixture.html?case=attachments&processing");
+
+ const solid = page.getByRole("region", { name: "Attachments: consumed" });
+ const fileSurface = "[data-file-attachment] > span";
+ await expect(solid.locator(fileSurface)).toHaveCSS("border-top-style", "solid");
+ await expect(solid.locator("[data-pending-edge-overlay]")).toHaveCount(0);
+
+ const region = page.getByRole("region", { name: "Attachments: pending" });
+ const card = region.locator(fileSurface);
+ await expect(card).toHaveCSS("border-top-style", "dashed");
+ await expect(card.locator("[data-pending-edge-overlay]")).toBeHidden();
+ const box = await bounds(card);
+ expect({ width: box.width, height: box.height }).toEqual({ width: 96, height: 96 });
+ const mediaEdges = region.locator('[data-solid-tone="media"] > .pending-edge-layer-dashed');
+ await expect(mediaEdges).toHaveCount(2);
+ for (const edge of await mediaEdges.all()) {
+ await expect(edge).toBeVisible();
+ await expect(edge).toHaveCSS("border-top-style", "dashed");
+ await expect(edge).toHaveCSS("animation-name", "none");
+ }
+});
+
test("image lightbox and file download remain keyboard accessible", async ({ page }, testInfo) => {
await page.route("**/fixture/retry.webm", (route) => route.fulfill({ status: 503, body: "Temporarily unavailable" }));
await openAttachments(page);
diff --git a/webui/src/components/AttachmentCard.tsx b/webui/src/components/AttachmentCard.tsx
index b896822f9..eff2c897b 100644
--- a/webui/src/components/AttachmentCard.tsx
+++ b/webui/src/components/AttachmentCard.tsx
@@ -2,6 +2,7 @@ import { useState, type ReactNode } from "react";
import { FileText, ImageIcon, Video } from "lucide-react";
import { useTranslation } from "react-i18next";
+import { PendingEdgeOverlay, type PendingEdgeState } from "@/components/PendingEdgeOverlay";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import type { UIMediaKind } from "@/lib/types";
@@ -10,12 +11,14 @@ import { cn } from "@/lib/utils";
export const attachmentCardActionClassName = "absolute right-0 top-0 grid h-11 w-11 place-items-center rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring";
/** The card owns only its information surface; callers own removal, download, and status. */
-export function AttachmentCard({ name, description, children, action, invalid = false }: {
+export function AttachmentCard({ name, description, children, action, invalid = false, edgeState = "solid", onSealEnd }: {
name: string;
description?: string;
children: ReactNode;
action?: ReactNode;
invalid?: boolean;
+ edgeState?: PendingEdgeState;
+ onSealEnd?: () => void;
}) {
const [detailsOpen, setDetailsOpen] = useState(false);
const [hintOpen, setHintOpen] = useState(false);
@@ -28,7 +31,9 @@ export function AttachmentCard({ name, description, children, action, invalid =
return
+
diff --git a/webui/src/components/AttachmentTile.tsx b/webui/src/components/AttachmentTile.tsx
index 0294f55c5..6387f24ab 100644
--- a/webui/src/components/AttachmentTile.tsx
+++ b/webui/src/components/AttachmentTile.tsx
@@ -8,6 +8,7 @@ import { ImageThumbnail } from "@/components/ImageGallery";
import { ImageLightbox } from "@/components/ImageLightbox";
import { useRegisterInlineImage } from "@/components/InlineImageContext";
import { AttachmentCard, AttachmentTypeFace, attachmentCardActionClassName } from "@/components/AttachmentCard";
+import { PendingEdgeOverlay, type PendingEdgeState } from "@/components/PendingEdgeOverlay";
interface AttachmentTileProps {
attachment: UIMediaAttachment;
@@ -15,9 +16,11 @@ interface AttachmentTileProps {
inline?: boolean;
variant?: "default" | "compact";
pending?: boolean;
+ edgeState?: PendingEdgeState;
+ onSealEnd?: () => void;
}
-export function AttachmentTile({ attachment, className, inline = false, variant = "default", pending = false }: AttachmentTileProps) {
+export function AttachmentTile({ attachment, className, inline = false, variant = "default", pending = false, edgeState = "solid", onSealEnd }: AttachmentTileProps) {
const { t } = useTranslation();
const videoUrl = attachment.url;
const [failedUrl, setFailedUrl] = useState(undefined);
@@ -31,7 +34,7 @@ export function AttachmentTile({ attachment, className, inline = false, variant
return (
setImageOpen(true)} onError={() => setFailedUrl(attachment.url)} />
{}} onOpenChange={setImageOpen} />
@@ -46,6 +49,8 @@ export function AttachmentTile({ attachment, className, inline = false, variant
className={className}
inline={inline}
variant={variant}
+ edgeState={edgeState}
+ onSealEnd={onSealEnd}
>
) : null}
+ {!showDeliveryStatus && showProcessingStatus ? (
+
+ {t("message.delivery.waiting")}
+
+ ) : null}
{showDeliveryStatus ? (
void;
}) {
const inlineImages = useInlineImages();
if (media.length === 0) return null;
@@ -681,6 +705,9 @@ function MessageMedia({
}
}
if (images.length === 0 && videos.length === 0 && files.length === 0) return null;
+ const attachSealToImages = images.length > 0;
+ const attachSealToVideos = !attachSealToImages && videos.length > 0;
+ const attachSealToFiles = !attachSealToImages && !attachSealToVideos;
return (
{images.length > 0 ? (
-
+
) : null}
{videos.map((item, i) => (
-
+
))}
{files.length > 0 ? (
{files.map((item, i) => (
-
+
))}
) : null}
diff --git a/webui/src/components/PendingEdgeOverlay.tsx b/webui/src/components/PendingEdgeOverlay.tsx
new file mode 100644
index 000000000..cf33e4361
--- /dev/null
+++ b/webui/src/components/PendingEdgeOverlay.tsx
@@ -0,0 +1,103 @@
+import { useCallback, useEffect, useState } from "react";
+import type { InputProcessingStatus } from "@/lib/types";
+import { cn } from "@/lib/utils";
+
+export type PendingEdgeState = "solid" | "pending" | "sealing";
+
+const SEAL_FALLBACK_MS = 560;
+
+/**
+ * Tracks the visual edge lifecycle for queued user messages:
+ * - "pending" while waiting in queue (dashed with subtle breathing)
+ * - "cancelled" when stopped before consumption (static dashed)
+ * - "sealing" for a single transition when a live message moves pending -> consumed
+ * - "solid" at rest (including historical messages loaded as consumed)
+ */
+export function usePendingEdgeState(
+ messageId: string,
+ processingStatus: InputProcessingStatus | undefined,
+ disabled: boolean,
+): { edgeState: PendingEdgeState; completeSeal: () => void } {
+ const [tracked, setTracked] = useState<{
+ id: string;
+ status: InputProcessingStatus | undefined;
+ sealing: boolean;
+ }>({
+ id: messageId,
+ status: processingStatus,
+ sealing: false,
+ });
+
+ if (tracked.id !== messageId || tracked.status !== processingStatus) {
+ const shouldSeal =
+ !disabled &&
+ tracked.id === messageId &&
+ ((tracked.status === "pending" && processingStatus === "consumed") ||
+ (tracked.sealing && processingStatus === undefined));
+ setTracked({
+ id: messageId,
+ status: processingStatus,
+ sealing: shouldSeal,
+ });
+ }
+
+ const edgeState: PendingEdgeState = disabled
+ ? "solid"
+ : processingStatus === "pending"
+ ? "pending"
+ : tracked.sealing
+ ? "sealing"
+ : "solid";
+
+ const completeSeal = useCallback(() => {
+ setTracked((prev) => (prev.sealing ? { ...prev, sealing: false } : prev));
+ }, []);
+
+ useEffect(() => {
+ if (edgeState !== "sealing") return;
+ const timer = window.setTimeout(completeSeal, SEAL_FALLBACK_MS);
+ return () => window.clearTimeout(timer);
+ }, [edgeState, completeSeal]);
+
+ return { edgeState, completeSeal };
+}
+
+export function PendingEdgeOverlay({
+ state,
+ solidTone = "bubble",
+ inset = "inset-0",
+ onSealEnd,
+}: {
+ state: PendingEdgeState;
+ solidTone?: "bubble" | "card" | "media";
+ inset?: string;
+ onSealEnd?: () => void;
+}) {
+ if (state === "solid") return null;
+
+ return (
+
{
+ if (
+ state === "sealing" &&
+ (event.animationName === "pending-edge-seal" ||
+ event.animationName === "pending-edge-fade-out")
+ ) {
+ onSealEnd?.();
+ }
+ }}
+ >
+
+ {state === "sealing" ? (
+ <>
+
+
+ >
+ ) : null}
+
+ );
+}
diff --git a/webui/src/globals.css b/webui/src/globals.css
index d818fc70d..095454f63 100644
--- a/webui/src/globals.css
+++ b/webui/src/globals.css
@@ -84,6 +84,11 @@
inherits: false;
initial-value: transparent;
}
+@property --pending-edge-progress {
+ syntax: "
";
+ inherits: true;
+ initial-value: -20%;
+}
/* Design tokens — HSL form, sourced from shadcn/ui's "neutral" palette. */
@layer base {
@@ -1237,10 +1242,167 @@
.user-message-surface,
.side-panel-surface {
--composer-shadow-color: 240 10% 16%;
- --tw-shadow: inset 0 0 0 1px hsl(var(--border) / 0.75), 0 4px 18px -8px hsl(var(--composer-shadow-color) / 0.12);
+ --surface-depth-shadow: 0 4px 18px -8px hsl(var(--composer-shadow-color) / 0.12);
+ --tw-shadow: inset 0 0 0 1px hsl(var(--border) / 0.75), var(--surface-depth-shadow);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}
+.user-message-surface-dashed,
+.user-message-surface[data-pending-edge="sealing"] {
+ --tw-shadow: var(--surface-depth-shadow);
+}
+
+.pending-edge-overlay {
+ --pending-edge-progress: -20%;
+ --pending-edge-solid-color: hsl(var(--border) / 0.75);
+ --pending-edge-sheen-color: hsl(var(--foreground) / 0.34);
+ position: absolute;
+ z-index: 1;
+ pointer-events: none;
+ border-radius: inherit;
+ corner-shape: inherit;
+}
+
+.dark .pending-edge-overlay {
+ --pending-edge-sheen-color: hsl(var(--foreground) / 0.42);
+}
+
+.pending-edge-overlay[data-solid-tone="card"] {
+ --pending-edge-solid-color: hsl(var(--border) / 0.70);
+}
+
+.pending-edge-overlay[data-solid-tone="media"] {
+ --pending-edge-solid-color: hsl(var(--border) / 0.60);
+}
+
+.pending-edge-overlay[data-pending-edge-overlay="sealing"] {
+ animation: pending-edge-seal 460ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
+}
+
+.pending-edge-layer {
+ position: absolute;
+ inset: 0;
+ border-radius: inherit;
+ corner-shape: inherit;
+}
+
+.pending-edge-layer-dashed {
+ border: 1px dashed hsl(var(--muted-foreground) / 0.30);
+}
+
+.pending-edge-overlay[data-pending-edge-overlay="pending"] .pending-edge-layer-dashed {
+ border-color: hsl(var(--muted-foreground) / 0.58);
+ animation: pending-edge-breathe 2s ease-in-out infinite;
+}
+
+.dark .pending-edge-overlay[data-pending-edge-overlay="pending"] .pending-edge-layer-dashed {
+ border-color: hsl(var(--muted-foreground) / 0.62);
+}
+
+.pending-edge-overlay[data-pending-edge-overlay="sealing"] .pending-edge-layer-dashed {
+ -webkit-mask-image: linear-gradient(
+ 105deg,
+ transparent 0%,
+ transparent calc(var(--pending-edge-progress) - 8%),
+ #000 calc(var(--pending-edge-progress) + 8%),
+ #000 100%
+ );
+ mask-image: linear-gradient(
+ 105deg,
+ transparent 0%,
+ transparent calc(var(--pending-edge-progress) - 8%),
+ #000 calc(var(--pending-edge-progress) + 8%),
+ #000 100%
+ );
+}
+
+.pending-edge-layer-solid {
+ border: 1px solid var(--pending-edge-solid-color);
+ -webkit-mask-image: linear-gradient(
+ 105deg,
+ #000 0%,
+ #000 calc(var(--pending-edge-progress) - 8%),
+ transparent calc(var(--pending-edge-progress) + 8%),
+ transparent 100%
+ );
+ mask-image: linear-gradient(
+ 105deg,
+ #000 0%,
+ #000 calc(var(--pending-edge-progress) - 8%),
+ transparent calc(var(--pending-edge-progress) + 8%),
+ transparent 100%
+ );
+}
+
+.pending-edge-layer-sheen {
+ border: 1px solid var(--pending-edge-sheen-color);
+ -webkit-mask-image: linear-gradient(
+ 105deg,
+ transparent calc(var(--pending-edge-progress) - 18%),
+ #000 var(--pending-edge-progress),
+ transparent calc(var(--pending-edge-progress) + 18%)
+ );
+ mask-image: linear-gradient(
+ 105deg,
+ transparent calc(var(--pending-edge-progress) - 18%),
+ #000 var(--pending-edge-progress),
+ transparent calc(var(--pending-edge-progress) + 18%)
+ );
+ animation: pending-edge-sheen-opacity 460ms ease-out forwards;
+}
+
+@keyframes pending-edge-breathe {
+ 0%,
+ 100% {
+ opacity: 1;
+ }
+ 50% {
+ opacity: 0.3;
+ }
+}
+
+@keyframes pending-edge-seal {
+ from {
+ --pending-edge-progress: -20%;
+ }
+ to {
+ --pending-edge-progress: 120%;
+ }
+}
+
+@keyframes pending-edge-sheen-opacity {
+ 0% {
+ opacity: 0;
+ }
+ 18% {
+ opacity: 1;
+ }
+ 78% {
+ opacity: 0.9;
+ }
+ 100% {
+ opacity: 0;
+ }
+}
+
+@keyframes pending-edge-fade-out {
+ from {
+ opacity: 1;
+ }
+ to {
+ opacity: 0;
+ }
+}
+
+@keyframes pending-edge-fade-in {
+ from {
+ opacity: 0;
+ }
+ to {
+ opacity: 1;
+ }
+}
+
.thread-composer-surface {
transition: var(--theme-paint-transition, background-color 160ms ease-out, box-shadow 160ms ease-out), opacity 160ms ease-out;
container-name: thread-composer;
@@ -1256,10 +1418,39 @@
@media (prefers-reduced-motion: reduce) {
.thread-composer-surface { transition: var(--theme-paint-transition, none); }
+ .pending-edge-overlay[data-pending-edge-overlay="pending"] .pending-edge-layer-dashed {
+ border-color: hsl(var(--muted-foreground) / 0.30);
+ animation: none;
+ }
+ .pending-edge-overlay[data-pending-edge-overlay="sealing"] { animation: none; }
+ .pending-edge-overlay[data-pending-edge-overlay="sealing"] .pending-edge-layer-dashed {
+ -webkit-mask-image: none;
+ mask-image: none;
+ animation: pending-edge-fade-out 160ms ease-out forwards;
+ }
+ .pending-edge-layer-solid {
+ -webkit-mask-image: none;
+ mask-image: none;
+ animation: pending-edge-fade-in 160ms ease-out forwards;
+ }
+ .pending-edge-layer-sheen { display: none; }
}
@media (forced-colors: active) {
.thread-composer-surface, .context-inspector-surface, .user-message-surface, .side-panel-surface { outline: 1px solid CanvasText; }
+ .user-message-surface-dashed { outline-style: dashed; }
+ .pending-edge-overlay { display: none; }
+ :has(> .pending-edge-overlay[data-solid-tone="card"][data-pending-edge-overlay="pending"]) {
+ border-color: CanvasText;
+ border-style: dashed;
+ }
+ .pending-edge-overlay[data-solid-tone="media"][data-pending-edge-overlay="pending"] {
+ display: block;
+ & .pending-edge-layer-dashed {
+ border-color: CanvasText;
+ animation: none;
+ }
+ }
.thread-composer-surface:focus-within { outline: 2px solid Highlight; }
[data-keyboard-focus] { outline: 2px solid Highlight; outline-offset: -2px; }
}
diff --git a/webui/src/hooks/useNanobotStream.ts b/webui/src/hooks/useNanobotStream.ts
index 3ebc9d440..4f691289b 100644
--- a/webui/src/hooks/useNanobotStream.ts
+++ b/webui/src/hooks/useNanobotStream.ts
@@ -183,6 +183,12 @@ export function useNanobotStream(
historyRunGenerationRef.current = { chatId, generation: chatId ? client.getRunGeneration(chatId) : 0 };
}
const [messages, setRenderedMessages] = useState(initialTranscript.messages);
+ const [liveInputs, setLiveInputs] = useState<{
+ chatId: string;
+ client: typeof client;
+ waiting: ReadonlySet;
+ consumed: ReadonlySet;
+ } | null>(null);
const [execSourceMessages, setExecSourceMessages] = useState(initialTranscript.messages);
const [modelRequests, setModelRequests] = useState(initialTranscript.modelRequests);
const messagesRef = useRef(messages);
@@ -686,6 +692,8 @@ export function useNanobotStream(
useEffect(() => {
if (!chatId) return;
+ // A request may start before its acceptance frame reaches this tab.
+ const startedInputs = new Set();
const handle = (ev: InboundEvent) => {
if (ev.event === "error") {
if (ev.detail === "message_too_big") {
@@ -716,6 +724,15 @@ export function useNanobotStream(
if (turnId) {
setMessages((prev) => transitionTurnDelivery(prev, turnId, "accepted"));
}
+ if ((ev.event === "message_accepted" || ev.event === "user_message") && ev.waiting_for_model === true) {
+ const id = ev.event === "user_message" ? ev.input_id : `user:${ev.turn_id}`;
+ if (id && !startedInputs.has(id)) {
+ setLiveInputs((prev) => {
+ const current = prev?.chatId === chatId && prev.client === client ? prev : null;
+ return { chatId, client, waiting: new Set([...(current?.waiting ?? []), id]), consumed: new Set() };
+ });
+ }
+ }
if (ev.event === "message_accepted") {
if (ev.media_urls?.length) {
setMessages((prev) => prev.map((message) => (
@@ -732,6 +749,16 @@ export function useNanobotStream(
return;
}
if (ev.event === "model_request") {
+ if (ev.phase === "started" && Array.isArray(ev.response_input_ids)) {
+ const ids = ev.response_input_ids;
+ ids.forEach((id) => startedInputs.add(id));
+ setLiveInputs((prev) => {
+ if (prev?.chatId !== chatId || prev.client !== client) return prev;
+ const consumed = new Set(ids.filter((id) => prev.waiting.has(id)));
+ if (!consumed.size) return prev;
+ return { ...prev, waiting: new Set([...prev.waiting].filter((id) => !consumed.has(id))), consumed };
+ });
+ }
flushPendingStreamEvents();
applyProjectionEvent(ev);
return;
@@ -844,6 +871,9 @@ export function useNanobotStream(
}
if (ev.event === "turn_end") {
+ if (!sideChannelEvent && (ev.outcome === "cancelled" || ev.outcome === "failed" || ev.outcome === "interrupted")) {
+ setLiveInputs(null);
+ }
if (typeof ev.turn_id === "string") transcriptRef.current.sideChannelTurnIds.delete(ev.turn_id);
if ("goal_state" in ev && ev.goal_state != null && typeof ev.goal_state === "object") {
setGoalState(ev.goal_state);
@@ -939,9 +969,14 @@ export function useNanobotStream(
}
};
+ const unsubStatus = client.onStatus((status) => {
+ if (status !== "open") setLiveInputs(null);
+ });
const unsub = client.onTranscript(chatId, handle);
return () => {
+ unsubStatus();
unsub();
+ setLiveInputs(null);
// Navigation may happen before the throttled paint. Snapshot the pending
// deltas synchronously while they still belong to this subscription.
const pending = pendingStreamEventsRef.current;
@@ -1061,6 +1096,7 @@ export function useNanobotStream(
const stop = useCallback(() => {
if (!chatId) return;
flushPendingStreamEvents();
+ setLiveInputs(null);
setRetryStatus(null);
setMessages((prev) => {
const settled = prev.map((m) => ({ ...m, isStreaming: false }));
@@ -1097,8 +1133,19 @@ export function useNanobotStream(
[recoveryAction],
);
+ const visibleMessages = useMemo(() => {
+ if (!liveInputs || liveInputs.chatId !== messageScope.chatId || liveInputs.client !== messageScope.client
+ || (!liveInputs.waiting.size && !liveInputs.consumed.size)) return messages;
+ return messages.map((row): UIMessage => {
+ if (row.role !== "user" || !row.inputId) return row;
+ if (liveInputs.waiting.has(row.inputId)) return { ...row, processingStatus: "pending" };
+ if (liveInputs.consumed.has(row.inputId)) return { ...row, processingStatus: "consumed" };
+ return row;
+ });
+ }, [liveInputs, messageScope, messages]);
+
return {
- messages,
+ messages: visibleMessages,
execSourceMessages,
modelRequests,
messagesKey: messageScope.historyKey ?? messageScope.chatId,
diff --git a/webui/src/i18n/locales/en/common.json b/webui/src/i18n/locales/en/common.json
index d140221b0..0206f9a9a 100644
--- a/webui/src/i18n/locales/en/common.json
+++ b/webui/src/i18n/locales/en/common.json
@@ -2364,6 +2364,7 @@
"actions": "Message actions",
"streaming": "streaming",
"delivery": {
+ "waiting": "Waiting to be processed",
"sending": "Sending",
"failed": "Not sent"
},
diff --git a/webui/src/i18n/locales/es/common.json b/webui/src/i18n/locales/es/common.json
index ceadcd335..f78214519 100644
--- a/webui/src/i18n/locales/es/common.json
+++ b/webui/src/i18n/locales/es/common.json
@@ -2182,6 +2182,7 @@
"actions": "Acciones del mensaje",
"streaming": "transmitiendo",
"delivery": {
+ "waiting": "Pendiente de procesar",
"sending": "Enviando",
"failed": "No enviado"
},
diff --git a/webui/src/i18n/locales/fr/common.json b/webui/src/i18n/locales/fr/common.json
index 750743258..0bdb587f6 100644
--- a/webui/src/i18n/locales/fr/common.json
+++ b/webui/src/i18n/locales/fr/common.json
@@ -2182,6 +2182,7 @@
"actions": "Actions du message",
"streaming": "en cours de génération",
"delivery": {
+ "waiting": "En attente de traitement",
"sending": "Envoi",
"failed": "Non envoyé"
},
diff --git a/webui/src/i18n/locales/id/common.json b/webui/src/i18n/locales/id/common.json
index a91fb31a6..ff2df77dd 100644
--- a/webui/src/i18n/locales/id/common.json
+++ b/webui/src/i18n/locales/id/common.json
@@ -2182,6 +2182,7 @@
"actions": "Tindakan pesan",
"streaming": "sedang mengalir",
"delivery": {
+ "waiting": "Menunggu diproses",
"sending": "Mengirim",
"failed": "Belum terkirim"
},
diff --git a/webui/src/i18n/locales/ja/common.json b/webui/src/i18n/locales/ja/common.json
index 9db514d4d..28d2a1127 100644
--- a/webui/src/i18n/locales/ja/common.json
+++ b/webui/src/i18n/locales/ja/common.json
@@ -2182,6 +2182,7 @@
"actions": "メッセージ操作",
"streaming": "生成中",
"delivery": {
+ "waiting": "処理待ち",
"sending": "送信中",
"failed": "未送信"
},
diff --git a/webui/src/i18n/locales/ko/common.json b/webui/src/i18n/locales/ko/common.json
index 2d05bc9c5..a022d518b 100644
--- a/webui/src/i18n/locales/ko/common.json
+++ b/webui/src/i18n/locales/ko/common.json
@@ -2182,6 +2182,7 @@
"actions": "메시지 작업",
"streaming": "생성 중",
"delivery": {
+ "waiting": "처리 대기 중",
"sending": "전송 중",
"failed": "전송되지 않음"
},
diff --git a/webui/src/i18n/locales/pt-BR/common.json b/webui/src/i18n/locales/pt-BR/common.json
index 932aa1a98..2fafb598d 100644
--- a/webui/src/i18n/locales/pt-BR/common.json
+++ b/webui/src/i18n/locales/pt-BR/common.json
@@ -2184,6 +2184,7 @@
"actions": "Ações da mensagem",
"streaming": "transmitindo",
"delivery": {
+ "waiting": "Aguardando processamento",
"sending": "Enviando",
"failed": "Não enviada"
},
diff --git a/webui/src/i18n/locales/vi/common.json b/webui/src/i18n/locales/vi/common.json
index 5e871793e..82860549f 100644
--- a/webui/src/i18n/locales/vi/common.json
+++ b/webui/src/i18n/locales/vi/common.json
@@ -2182,6 +2182,7 @@
"actions": "Thao tác tin nhắn",
"streaming": "đang truyền",
"delivery": {
+ "waiting": "Đang chờ xử lý",
"sending": "Đang gửi",
"failed": "Chưa gửi"
},
diff --git a/webui/src/i18n/locales/zh-CN/common.json b/webui/src/i18n/locales/zh-CN/common.json
index ae5f2543c..38789047b 100644
--- a/webui/src/i18n/locales/zh-CN/common.json
+++ b/webui/src/i18n/locales/zh-CN/common.json
@@ -2364,6 +2364,7 @@
"actions": "消息操作",
"streaming": "流式输出中",
"delivery": {
+ "waiting": "等待处理",
"sending": "发送中",
"failed": "未发送"
},
diff --git a/webui/src/i18n/locales/zh-TW/common.json b/webui/src/i18n/locales/zh-TW/common.json
index cf7683ef0..42ed06151 100644
--- a/webui/src/i18n/locales/zh-TW/common.json
+++ b/webui/src/i18n/locales/zh-TW/common.json
@@ -2182,6 +2182,7 @@
"actions": "訊息操作",
"streaming": "串流輸出中",
"delivery": {
+ "waiting": "等待處理",
"sending": "傳送中",
"failed": "未傳送"
},
diff --git a/webui/src/lib/types.ts b/webui/src/lib/types.ts
index 75e2369af..d3446fd34 100644
--- a/webui/src/lib/types.ts
+++ b/webui/src/lib/types.ts
@@ -17,6 +17,7 @@ export interface UIContextCompaction extends ContextCompaction {
export type UITurnPhase = "user" | "reasoning" | "activity" | "answer" | "complete";
export type MessageDeliveryStatus = "sending" | "accepted" | "failed";
+export type InputProcessingStatus = "pending" | "consumed";
export type MessageDeliveryErrorKind =
| "message_too_big"
| "workspace_scope_rejected"
@@ -184,6 +185,8 @@ export interface UIMessage {
reasoningStreamId?: string;
/** Ephemeral delivery lifecycle for optimistic user messages. */
deliveryStatus?: MessageDeliveryStatus;
+ /** Live UI hint; not part of the persisted transcript. */
+ processingStatus?: InputProcessingStatus;
deliveryErrorKind?: MessageDeliveryErrorKind;
}
@@ -1569,6 +1572,7 @@ export type InboundEvent =
event: "message_accepted";
chat_id: string;
turn_id: string;
+ waiting_for_model?: true;
media_urls?: UIMediaAttachment[];
starts_turn?: boolean;
active_turn_id?: string;
@@ -1578,6 +1582,7 @@ export type InboundEvent =
event: "user_message";
chat_id: string;
text: string;
+ waiting_for_model?: true;
turn_id?: string;
active_turn_id?: string;
starts_turn: boolean;
diff --git a/webui/src/tests/message-bubble.test.tsx b/webui/src/tests/message-bubble.test.tsx
index 27e5306ad..9cbe77e6b 100644
--- a/webui/src/tests/message-bubble.test.tsx
+++ b/webui/src/tests/message-bubble.test.tsx
@@ -376,6 +376,91 @@ describe("MessageBubble", () => {
expect(bubble).toHaveClass("user-message-surface", "bg-secondary/70");
});
+ it("seals the dashed edge into a solid border when the agent picks up a waiting message", () => {
+ const message: UIMessage = {
+ id: "u-pending",
+ role: "user",
+ content: "One more detail",
+ createdAt: Date.now(),
+ deliveryStatus: "accepted",
+ };
+ const { rerender } = render();
+ const bubble = screen.getByText(message.content);
+ const originalClasses = bubble.className;
+
+ rerender();
+ expect(bubble).toHaveClass("user-message-surface-dashed");
+ expect(bubble).toHaveAttribute("data-pending-edge", "pending");
+ expect(bubble.querySelector("[data-pending-edge-overlay='pending']")).toBeInTheDocument();
+ const waitingStatus = screen.getByRole("status");
+ expect(waitingStatus).toHaveClass("sr-only");
+ expect(waitingStatus).toHaveTextContent("Waiting to be processed");
+
+ rerender();
+ expect(bubble.className).toBe(originalClasses);
+ expect(bubble).toHaveAttribute("data-pending-edge", "sealing");
+ const sealingOverlay = bubble.querySelector("[data-pending-edge-overlay='sealing']");
+ expect(sealingOverlay).toBeInTheDocument();
+ expect(screen.queryByRole("status")).not.toBeInTheDocument();
+
+ const endEvent = new Event("animationend", { bubbles: true });
+ Object.defineProperty(endEvent, "animationName", { value: "pending-edge-seal" });
+ fireEvent(sealingOverlay!, endEvent);
+
+ expect(bubble).not.toHaveAttribute("data-pending-edge");
+ expect(bubble.querySelector("[data-pending-edge-overlay]")).not.toBeInTheDocument();
+ });
+
+ it("does not play the seal transition for already-consumed or cancelled user messages", () => {
+ const { container, rerender } = render(
+ ,
+ );
+ expect(container.querySelector("[data-pending-edge-overlay]")).not.toBeInTheDocument();
+
+ const pending: UIMessage = {
+ id: "u-waiting",
+ role: "user",
+ content: "Never picked up",
+ createdAt: Date.now(),
+ processingStatus: "pending",
+ };
+ rerender();
+ expect(container.querySelector("[data-pending-edge-overlay='pending']")).toBeInTheDocument();
+
+ rerender();
+ expect(container.querySelector("[data-pending-edge-overlay]")).not.toBeInTheDocument();
+ });
+
+ it("seals media-only waiting user messages when consumed", () => {
+ const mediaMessage: UIMessage = {
+ id: "u-media-pending",
+ role: "user",
+ content: "",
+ createdAt: Date.now(),
+ processingStatus: "pending",
+ media: [{ kind: "file", name: "notes.txt", url: "/api/files/notes.txt" }],
+ };
+ const { container, rerender } = render();
+ expect(container.querySelector("[data-pending-edge-overlay='pending']")).toBeInTheDocument();
+
+ rerender();
+ const sealingOverlay = container.querySelector("[data-pending-edge-overlay='sealing']");
+ expect(sealingOverlay).toBeInTheDocument();
+
+ const endEvent = new Event("animationend", { bubbles: true });
+ Object.defineProperty(endEvent, "animationName", { value: "pending-edge-seal" });
+ fireEvent(sealingOverlay!, endEvent);
+ expect(container.querySelector("[data-pending-edge-overlay]")).not.toBeInTheDocument();
+ });
+
it("renders completed message branches with static wrapper classes", async () => {
const messages: UIMessage[] = [
{
diff --git a/webui/src/tests/useNanobotStream.test.tsx b/webui/src/tests/useNanobotStream.test.tsx
index 7a7b7f792..453011278 100644
--- a/webui/src/tests/useNanobotStream.test.tsx
+++ b/webui/src/tests/useNanobotStream.test.tsx
@@ -2564,6 +2564,57 @@ describe("useNanobotStream", () => {
]);
});
+ it("ends the live waiting hint only when a request starts for that input", () => {
+ const fake = fakeClient();
+ const chat = "chat-processing";
+ const { result } = renderHook(() => useNanobotStream(chat, EMPTY_MESSAGES), { wrapper: wrap(fake.client) });
+ const peerInput = (id: string, waiting = false) => fake.emit(chat, {
+ event: "user_message", chat_id: chat, turn_id: id, input_id: `user:${id}`,
+ starts_turn: !waiting, text: "identical prompt", ...(waiting ? { waiting_for_model: true } : {}),
+ });
+ let sequence = 0;
+ const request = (id: string, phase: "started" | "completed" = "started") => fake.emit(chat, {
+ event: "model_request", chat_id: chat, turn_id: "first", request_id: id, run_id: "run",
+ sequence: ++sequence, phase, response_input_ids: [`user:${id}`],
+ });
+ const state = (id: string) => result.current.messages.find((row) => row.inputId === `user:${id}`)?.processingStatus;
+ act(() => {
+ peerInput("first");
+ peerInput("followup", true);
+ request("first");
+ request("first", "completed");
+ });
+ expect(state("first")).toBeUndefined();
+ expect(state("followup")).toBe("pending");
+ act(() => request("followup"));
+ expect(state("followup")).toBe("consumed");
+
+ act(() => {
+ request("late-echo");
+ peerInput("late-echo", true);
+ });
+ expect(state("late-echo")).toBeUndefined();
+ });
+
+ it.each(["stop", "cancelled by another tab", "disconnect"])("drops the temporary waiting hint on %s", (event) => {
+ const fake = fakeClient();
+ const chat = "chat-processing";
+ const { result } = renderHook(() => useNanobotStream(chat, EMPTY_MESSAGES), { wrapper: wrap(fake.client) });
+ let turnId = "";
+ act(() => { turnId = result.current.send("follow-up")!.turnId; });
+ act(() => fake.emit(chat, {
+ event: "message_accepted", chat_id: chat, turn_id: turnId, active_turn_id: "active", waiting_for_model: true,
+ }));
+ expect(result.current.messages[0]).toMatchObject({ processingStatus: "pending", deliveryStatus: "accepted" });
+ act(() => {
+ if (event === "stop") result.current.stop();
+ else if (event === "disconnect") fake.emitStatus("reconnecting");
+ else fake.emit(chat, { event: "turn_end", chat_id: chat, turn_id: "active", outcome: "cancelled" });
+ });
+ expect(result.current.messages[0]).toMatchObject({ content: "follow-up", deliveryStatus: "accepted" });
+ expect(result.current.messages[0].processingStatus).toBeUndefined();
+ });
+
it("projects a user turn submitted from another attached client exactly once", () => {
const fake = fakeClient();
const { result } = renderHook(