Skip to content
TypeScript

feat(web,mobile): queued messages show who sent them (#26159)

Julius Marmingeb31de684d22c
diff --git a/apps/mobile/src/features/threads/ThreadQueueControl.tsx b/apps/mobile/src/features/threads/ThreadQueueControl.tsx
index 093966bc2e6..c1abc19e9fd 100644
--- a/apps/mobile/src/features/threads/ThreadQueueControl.tsx
+++ b/apps/mobile/src/features/threads/ThreadQueueControl.tsx
@@ -4,6 +4,8 @@ import {
makeQueuedRunsAtom,
queuedRunEditBlockedReason,
} from "@t3tools/client-runtime/queued-run-edit";
+import { scopeThreadRef } from "@t3tools/client-runtime/environment";
+import { resolveUserMessagePresentation } from "@t3tools/client-runtime/user-message";
import type { ChatAttachment, EnvironmentId, RunId, ThreadId } from "@t3tools/contracts";
import { Atom } from "effect/reactivity";
import { Image } from "expo-image";
@@ -27,6 +29,9 @@ import { scopedThreadKey } from "../../lib/scopedEntities";
import { useUniwindTheme } from "../../lib/useUniwindTheme";
import { NativeStackScreenOptions, nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
import { useAssetUrl } from "../../state/assets";
+import { useQuietThreadShell } from "../../state/entities";
+import { useEnvironmentQuery } from "../../state/query";
+import { serverEnvironment } from "../../state/server";
import { assetImageSource } from "../../lib/assetImageSource";
import { beginQueuedRunEdit, useQueuedRunEdit } from "../../state/queued-run-edit";
import { environmentThreadDetails, threadEnvironment } from "../../state/threads";
@@ -58,6 +63,62 @@ export function useThreadQueuedCount(target: QueueTarget | null) {
);
}
+type QueuedRunMessage = NonNullable<
+ NonNullable<ReturnType<typeof useThreadQueueWorkflow>>["queuedRuns"][number]["message"]
+>;
+
+/** Who sent a queued message, as its sent form shows it in the thread. */
+function QueuedRunSender(props: {
+ readonly environmentId: EnvironmentId;
+ readonly message: QueuedRunMessage;
+}) {
+ const { attribution, scheduledTaskId } = resolveUserMessagePresentation(props.message);
+ const senderThreadId = attribution === "agent" ? props.message.senderThreadId : undefined;
+ const senderShell = useQuietThreadShell(
+ senderThreadId ? scopeThreadRef(props.environmentId, senderThreadId) : null,
+ );
+ const tasks = useEnvironmentQuery(
+ scheduledTaskId
+ ? serverEnvironment.scheduledTasksLive({ environmentId: props.environmentId, input: {} })
+ : null,
+ );
+ const sender =
+ attribution === "automation"
+ ? {
+ icon: "calendar.badge.clock" as const,
+ label:
+ tasks.data?.tasks.find((task) => task.id === scheduledTaskId)?.title ?? "Automation",
+ }
+ : attribution === "agent"
+ ? {
+ icon: "bubble.left.and.bubble.right" as const,
+ label: senderShell?.title.trim() || "Agent",
+ }
+ : attribution === "t3code"
+ ? { icon: null, label: "Sent by T3 Code" }
+ : null;
+ if (sender === null) return null;
+ return (
+ <View className="flex-row items-center gap-1">
+ {sender.icon ? (
+ <SymbolView
+ name={sender.icon}
+ size={11}
+ weight="medium"
+ tintColorClassName="accent-foreground-muted"
+ type="monochrome"
+ />
+ ) : null}
+ <Text
+ numberOfLines={1}
+ className="min-w-0 shrink font-t3-medium text-2xs text-foreground-muted"
+ >
+ {sender.label}
+ </Text>
+ </View>
+ );
+}
+
export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
const { layout } = useAdaptiveWorkspaceLayout();
const target = route.params;
@@ -173,7 +234,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
No messages waiting in this queue.
</Text>
) : null}
- {queuedRuns.map(({ run, text, attachments, context }, index) => {
+ {queuedRuns.map(({ run, text, attachments, context, message }, index) => {
const controls = resolveThreadQueueRowControls({
busy: busyRunId !== null,
canPromoteToSteer: workflow?.canPromoteToSteer ?? false,
@@ -240,21 +301,26 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
environmentId={target.environmentId}
attachments={attachments}
/>
- <Text
- className={
- controls.isEditing
- ? "min-w-0 flex-1 text-sm text-foreground-muted"
- : "min-w-0 flex-1 text-sm text-foreground"
- }
- numberOfLines={1}
- >
- {context?.guest === undefined ? null : (
- <Text className="font-t3-medium text-adaptive-fuchsia-600-300">
- {`${context.guest.name} `}
- </Text>
- )}
- {title}
- </Text>
+ <View className="min-w-0 flex-1 gap-0.5">
+ {message ? (
+ <QueuedRunSender environmentId={target.environmentId} message={message} />
+ ) : null}
+ <Text
+ className={
+ controls.isEditing
+ ? "text-sm text-foreground-muted"
+ : "text-sm text-foreground"
+ }
+ numberOfLines={1}
+ >
+ {context?.guest === undefined ? null : (
+ <Text className="font-t3-medium text-adaptive-fuchsia-600-300">
+ {`${context.guest.name} `}
+ </Text>
+ )}
+ {title}
+ </Text>
+ </View>
{controls.isEditing ? (
<Text className="shrink-0 text-2xs uppercase tracking-wide text-primary">
Editing
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index 5b44cc0b247..4e6a9918792 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -2907,6 +2907,8 @@ export default function ChatView(props: ChatViewProps) {
})}
onEditQueuedRun={queuedRunEdit.beginEdit}
onCancelEdit={queuedRunEdit.cancelEdit}
+ timestampFormat={timestampFormat}
+ onOpenThread={onOpenRelatedThreadStable}
/>
</>
) : null;
diff --git a/apps/web/src/components/chat/QueuedRunsControl.browser.test.tsx b/apps/web/src/components/chat/QueuedRunsControl.browser.test.tsx
index 5a31db26cf7..6a3a5d98131 100644
--- a/apps/web/src/components/chat/QueuedRunsControl.browser.test.tsx
+++ b/apps/web/src/components/chat/QueuedRunsControl.browser.test.tsx
@@ -1,5 +1,6 @@
import { EnvironmentId, MessageId, ThreadId } from "@t3tools/contracts";
import { serializeAssistantCitation } from "@t3tools/shared/assistantCitations";
+import * as DateTime from "effect/DateTime";
import type { ComponentProps } from "react";
import { expect, it, vi } from "vite-plus/test";
import { page } from "vite-plus/test/browser";
@@ -17,6 +18,15 @@ vi.mock(import("@t3tools/client-runtime/state/thread-workflows"), async (importO
vi.mock(import("../../state/entities"), async (importOriginal) => ({
...(await importOriginal()),
useThreadProjection: (() => state.projection) as never,
+ useQuietThreadShell: ((target: unknown) =>
+ target === null ? null : { title: "Release lead" }) as never,
+}));
+
+vi.mock(import("../../state/query"), async (importOriginal) => ({
+ ...(await importOriginal()),
+ useEnvironmentQuery: (() => ({
+ data: { tasks: [{ id: "task:webhook", title: "PR dispatcher" }] },
+ })) as never,
}));
vi.mock(import("../../state/use-atom-command"), async (importOriginal) => ({
@@ -46,6 +56,8 @@ const baseProps = {
editBlockedReason: null,
onEditQueuedRun: () => undefined,
onCancelEdit: () => undefined,
+ timestampFormat: "locale",
+ onOpenThread: () => undefined,
} satisfies ComponentProps<typeof QueuedRunsControl>;
async function renderQueue(props: Partial<ComponentProps<typeof QueuedRunsControl>> = {}) {
@@ -97,3 +109,66 @@ it("previews assistant quotes as readable text and preserves the citation when e
expect.objectContaining({ text: quoteAndText }),
);
});
+
+it("shows who sent a queued message and folds automation and agent prompts", async () => {
+ setup();
+ const message = (id: string, fields: Record<string, unknown>) => ({
+ id,
+ role: "user",
+ createdAt: DateTime.makeUnsafe("2026-10-27T12:00:00.000Z"),
+ ...fields,
+ });
+ state.projection = { projection: { messages: [] } };
+ state.workflow = {
+ activeRun: { id: "run:active" },
+ canPromoteToSteer: true,
+ queuedRuns: [
+ [
+ "run:automation",
+ "GitHub labeled a pull request.\nFollow the runbook.",
+ {
+ createdBy: "agent",
+ scheduledTaskId: "task:webhook",
+ },
+ ],
+ [
+ "run:agent",
+ "Review finished.",
+ {
+ createdBy: "agent",
+ creationSource: "provider",
+ senderThreadId: "thread:lead",
+ },
+ ],
+ [
+ "run:server",
+ "Continue where you left off.",
+ {
+ createdBy: "agent",
+ creationSource: "server",
+ },
+ ],
+ ].map(([runId, text, fields]) => ({
+ run: { id: runId, userMessageId: `${runId}:message` },
+ text,
+ attachments: [],
+ message: message(`${runId}:message`, { text, ...(fields as object) }),
+ })),
+ };
+ const onOpenThread = vi.fn();
+ await using _screen = await renderQueue({ onOpenThread });
+
+ const automation = page.getByRole("button", { name: /PR dispatcher/ });
+ await expect.element(automation).toHaveAttribute("aria-expanded", "false");
+ await expect.element(page.getByText(/Follow the runbook/)).not.toBeInTheDocument();
+ await automation.click();
+ await expect.element(page.getByText(/Follow the runbook/)).toBeVisible();
+ await expect.element(page.getByRole("link", { name: "Open automation" })).toBeInTheDocument();
+
+ await expect.element(page.getByRole("button", { name: /Release lead/ })).toBeVisible();
+ await page.getByRole("button", { name: "Open thread" }).click({ force: true });
+ expect(onOpenThread).toHaveBeenCalledExactlyOnceWith("thread:lead");
+
+ await expect.element(page.getByText("Sent by T3 Code")).toBeVisible();
+ await expect.element(page.getByText("Continue where you left off.")).toBeVisible();
+});
diff --git a/apps/web/src/components/chat/QueuedRunsControl.tsx b/apps/web/src/components/chat/QueuedRunsControl.tsx
index 763d3ab435e..850c38df79f 100644
--- a/apps/web/src/components/chat/QueuedRunsControl.tsx
+++ b/apps/web/src/components/chat/QueuedRunsControl.tsx
@@ -9,18 +9,32 @@ import type {
RunId,
ThreadId,
} from "@t3tools/contracts";
-import { ChevronDownIcon, Clock3Icon, ArrowUpIcon, PencilIcon, XIcon } from "lucide-react";
-import { useId, useImperativeHandle, useRef, useState, type Ref } from "react";
+import { resolveUserMessagePresentation } from "@t3tools/client-runtime/user-message";
+import { Link } from "@tanstack/react-router";
+import {
+ ArrowUpIcon,
+ CalendarClockIcon,
+ ChevronDownIcon,
+ Clock3Icon,
+ MessagesSquareIcon,
+ PencilIcon,
+ XIcon,
+} from "lucide-react";
+import * as DateTime from "effect/DateTime";
+import { useId, useImperativeHandle, useRef, useState, type ReactNode, type Ref } from "react";
import { useAssetUrls } from "../../assets/assetUrls";
import { threadEnvironment } from "../../state/threads";
-import { useThreadProjection } from "../../state/entities";
+import { useQuietThreadShell, useThreadProjection } from "../../state/entities";
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 { Separator } from "../ui/separator";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
+import type { TimestampFormat } from "@t3tools/contracts/settings";
+import { GuestMessageName } from "./guestMessageStyle";
+import { TimelineRowTimestamp } from "./TimelineRowParts";
+import { FoldedMessageHeader, useScheduledTaskTitle } from "./TimelineUserMessageRow";
export interface EditQueuedRunRequest {
readonly runId: RunId;
@@ -73,6 +87,8 @@ export function QueuedRunsControl({
readonly editBlockedReason: string | null;
readonly onEditQueuedRun: (request: EditQueuedRunRequest) => void;
readonly onCancelEdit: () => void;
+ readonly timestampFormat: TimestampFormat;
+ readonly onOpenThread: (threadId: ThreadId) => void;
}) {
const projection = useThreadProjection(
scopeThreadRef(props.environmentId, props.threadId),
@@ -105,15 +121,15 @@ export function QueuedRunsControl({
(message) => message.inputIntent === "queued_turn" && !acknowledgedMessageIds.has(message.id),
);
const items = [
- ...queued.map(({ run, text, attachments, context }, serverIndex) => ({
+ ...queued.map(({ run, text, attachments, context, message }, serverIndex) => ({
key: run.id,
+ message,
runId: run.id,
messageId: run.userMessageId,
serverIndex,
text,
// A guest's message keeps the guest's words; the owner can cancel it, not rewrite it.
editable: context?.guest === undefined,
- guestName: context?.guest?.name,
attachments,
thumbnails: attachments
.filter((attachment) => attachment.type === "image")
@@ -126,12 +142,12 @@ export function QueuedRunsControl({
})),
...optimisticQueued.map((message) => ({
key: message.id,
+ message: undefined,
runId: null,
messageId: null,
serverIndex: null,
text: message.text,
editable: true,
- guestName: undefined,
attachments: [] as ReadonlyArray<ContractChatAttachment>,
thumbnails: (message.attachments ?? [])
.filter(isImageAttachment)
@@ -233,51 +249,17 @@ export function QueuedRunsControl({
aria-posinset={position + 1}
aria-setsize={items.length}
aria-current={isEditing ? "true" : undefined}
- className="flex w-full flex-col items-end gap-1 transition-opacity duration-150 ease-out starting:opacity-0 motion-reduce:transition-none"
+ className="group/queued flex w-full flex-col items-end gap-1 transition-opacity duration-150 ease-out starting:opacity-0 motion-reduce:transition-none"
>
- {/* Dashed and unfilled: a turn that has not been sent yet. */}
- <div
- className={cn(
- "flex min-w-0 max-w-[80%] flex-col gap-2 rounded-2xl border border-dashed px-3 py-2 text-sm",
- isEditing
- ? "border-primary/60 text-foreground"
- : "border-muted-foreground/40 text-muted-foreground",
- )}
+ <QueuedMessage
+ environmentId={props.environmentId}
+ message={item.message}
+ previewText={previewText}
+ thumbnails={item.thumbnails}
+ isEditing={isEditing}
+ timestampFormat={props.timestampFormat}
+ onOpenThread={props.onOpenThread}
>
- {item.thumbnails.length > 0 ? (
- <span className="flex flex-wrap items-center gap-1">
- {item.thumbnails.map((thumbnail) => (
- <span
- key={thumbnail.key}
- className="size-8 overflow-hidden rounded-md border border-border/70 bg-background"
- >
- {thumbnail.url ? (
- <img
- src={thumbnail.url}
- alt={thumbnail.name}
- className="size-full object-cover"
- />
- ) : (
- <span
- aria-label={thumbnail.name}
- className="block size-full bg-muted/60"
- />
- )}
- </span>
- ))}
- </span>
- ) : null}
- {/* In full, like a sent turn: a queued message is read before it is sent. */}
- {previewText ? (
- <p className="whitespace-pre-wrap wrap-anywhere">
- {item.guestName === undefined ? null : (
- <span className="text-guest-foreground">{item.guestName} </span>
- )}
- {previewText}
- </p>
- ) : null}
- </div>
- <div className="flex items-center gap-0.5 pe-1 text-xs text-muted-foreground">
{canSend && !isEditing ? (
<>
<Tooltip>
@@ -300,7 +282,6 @@ export function QueuedRunsControl({
{`${workflow?.canSendNow ? "Start a turn with this message" : workflow?.promoteSkipsCompaction ? "Skip compaction and send this message" : "Send into the current turn"}${item.serverIndex === 0 && props.steerShortcutLabel ? ` (${props.steerShortcutLabel})` : ""}`}
</TooltipPopup>
</Tooltip>
- <Separator orientation="vertical" className="mx-2 h-4" />
</>
) : null}
{item.pending ? (
@@ -375,7 +356,7 @@ export function QueuedRunsControl({
</Tooltip>
</>
)}
- </div>
+ </QueuedMessage>
</li>
);
})}
@@ -404,3 +385,141 @@ export function QueuedRunsControl({
</section>
);
}
+
+type QueuedRunMessage = NonNullable<ThreadQueueProjection["messages"][number]>;
+
+/** A queued turn wears its sent form's attribution; only the dashed edge and controls differ. */
+function QueuedMessage(props: {
+ readonly environmentId: EnvironmentId;
+ readonly message: QueuedRunMessage | undefined;
+ readonly previewText: string;
+ readonly thumbnails: ReadonlyArray<QueuedRowThumbnail>;
+ readonly isEditing: boolean;
+ readonly timestampFormat: TimestampFormat;
+ readonly onOpenThread: (threadId: ThreadId) => void;
+ readonly children: ReactNode;
+}) {
+ const presentation = props.message ? resolveUserMessagePresentation(props.message) : null;
+ const attribution = presentation?.attribution ?? null;
+ const scheduledTaskId = presentation?.scheduledTaskId;
+ const senderThreadId = props.message?.senderThreadId;
+ const [expanded, setExpanded] = useState(false);
+ const taskTitle = useScheduledTaskTitle(props.environmentId, scheduledTaskId);
+ const senderShell = useQuietThreadShell(
+ attribution === "agent" && senderThreadId
+ ? { environmentId: props.environmentId, threadId: senderThreadId }
+ : null,
+ );
+ const fold =
+ attribution === "automation"
+ ? {
+ icon: CalendarClockIcon,
+ label: "Automation",
+ summary: taskTitle ?? props.previewText.split(/\r?\n/, 1)[0] ?? "",
+ }
+ : attribution === "agent"
+ ? {
+ icon: MessagesSquareIcon,
+ label: senderShell?.title.trim() || "Agent",
+ summary: props.previewText.split(/\r?\n/).find((line) => line.trim()) ?? "",
+ }
+ : null;
+ const bodyVisible = fold === null || expanded;
+
+ return (
+ <>
+ {attribution === "t3code" ? (
+ <p className="me-1 text-2xs text-muted-foreground/70">Sent by T3 Code</p>
+ ) : null}
+ {presentation?.guestName === undefined ? null : (
+ <GuestMessageName name={presentation.guestName} />
+ )}
+ {/* Dashed and unfilled: a turn that has not been sent yet. */}
+ <div
+ className={cn(
+ "flex min-w-0 max-w-[80%] flex-col rounded-2xl border border-dashed text-sm",
+ props.isEditing
+ ? "border-primary/60 text-foreground"
+ : attribution === "guest"
+ ? "border-guest/50 text-muted-foreground"
+ : "border-muted-foreground/40 text-muted-foreground",
+ fold === null && "px-3 py-2",
+ fold !== null && expanded && "w-full",
+ )}
+ >
+ {fold ? (
+ <FoldedMessageHeader
+ icon={fold.icon}
+ label={fold.label}
+ summary={fold.summary}
+ expanded={expanded}
+ onToggle={() => setExpanded((value) => !value)}
+ />
+ ) : null}
+ {bodyVisible ? (
+ <div
+ className={cn(
+ "flex flex-col gap-2",
+ fold !== null && "max-h-96 overflow-auto px-3 pb-2",
+ )}
+ >
+ {props.thumbnails.length > 0 ? (
+ <span className="flex flex-wrap items-center gap-1">
+ {props.thumbnails.map((thumbnail) => (
+ <span
+ key={thumbnail.key}
+ className="size-8 overflow-hidden rounded-md border border-border/70 bg-background"
+ >
+ {thumbnail.url ? (
+ <img
+ src={thumbnail.url}
+ alt={thumbnail.name}
+ className="size-full object-cover"
+ />
+ ) : (
+ <span aria-label={thumbnail.name} className="block size-full bg-muted/60" />
+ )}
+ </span>
+ ))}
+ </span>
+ ) : null}
+ {/* In full, like a sent turn: a queued message is read before it is sent. */}
+ {props.previewText ? (
+ <p className="whitespace-pre-wrap wrap-anywhere">{props.previewText}</p>
+ ) : null}
+ </div>
+ ) : null}
+ </div>
+ <div className="flex items-center gap-0.5 pe-1 text-xs text-muted-foreground">
+ {props.message ? (
+ <span className="me-1 flex items-center gap-2 px-1 opacity-0 transition-opacity duration-200 pointer-coarse:opacity-100 focus-within:opacity-100 group-hover/queued:opacity-100">
+ {attribution === "agent" && senderThreadId ? (
+ <InlineButton tone="muted" onClick={() => props.onOpenThread(senderThreadId)}>
+ Open thread
+ </InlineButton>
+ ) : null}
+ {scheduledTaskId ? (
+ <InlineButton
+ tone="muted"
+ render={
+ <Link
+ to="/settings/scheduled-tasks"
+ search={{ environmentId: props.environmentId, taskId: scheduledTaskId }}
+ />
+ }
+ >
+ Open automation
+ </InlineButton>
+ ) : null}
+ <TimelineRowTimestamp
+ createdAt={DateTime.formatIso(props.message.createdAt)}
+ timestampFormat={props.timestampFormat}
+ alwaysVisible
+ />
+ </span>
+ ) : null}
+ {props.children}
+ </div>
+ </>
+ );
+}
diff --git a/apps/web/src/components/chat/TimelineUserMessageRow.tsx b/apps/web/src/components/chat/TimelineUserMessageRow.tsx
index 342b903847c..0c459717e48 100644
--- a/apps/web/src/components/chat/TimelineUserMessageRow.tsx
+++ b/apps/web/src/components/chat/TimelineUserMessageRow.tsx
@@ -1,7 +1,13 @@
import { InlineAudioPreview } from "../files/InlineAudioPreview";
import { filePreviewKind } from "@t3tools/shared/filePreview";
import { findRevealRef } from "./markdownFindContext";
-import { type MessageId, type ServerProviderSkill, ThreadId } from "@t3tools/contracts";
+import {
+ type EnvironmentId,
+ type MessageId,
+ type ScheduledTaskId,
+ type ServerProviderSkill,
+ ThreadId,
+} from "@t3tools/contracts";
import { resolveUserMessagePresentation } from "@t3tools/client-runtime/user-message";
import { Link } from "@tanstack/react-router";
import { useQuietThreadShell } from "../../state/entities";
@@ -143,16 +149,10 @@ function AutomationMessageRow({ row }: { row: Extract<TimelineRow, { kind: "mess
const [expanded, setExpanded] = useState(false);
const revealRef = findRevealRef(() => setExpanded(true));
const { text, scheduledTaskId } = resolveUserMessagePresentation(row.message);
- const tasksQuery = useEnvironmentQuery(
- scheduledTaskId
- ? serverEnvironment.scheduledTasksLive({
- environmentId: ctx.activeThreadEnvironmentId,
- input: {},
- })
- : null,
- );
- const taskTitle = tasksQuery.data?.tasks.find((task) => task.id === scheduledTaskId)?.title;
- const summary = taskTitle ?? text.trim().split(/\r?\n/, 1)[0] ?? "";
+ const summary =
+ useScheduledTaskTitle(ctx.activeThreadEnvironmentId, scheduledTaskId) ??
+ text.trim().split(/\r?\n/, 1)[0] ??
+ "";
const revertTurnCount = row.revertTurnCount;
const promptLink = promptLinkFor(text);
@@ -231,7 +231,17 @@ function AutomationMessageRow({ row }: { row: Extract<TimelineRow, { kind: "mess
);
}
-function FoldedMessageHeader(props: {
+export function useScheduledTaskTitle(
+ environmentId: EnvironmentId,
+ scheduledTaskId: ScheduledTaskId | undefined,
+): string | undefined {
+ const tasksQuery = useEnvironmentQuery(
+ scheduledTaskId ? serverEnvironment.scheduledTasksLive({ environmentId, input: {} }) : null,
+ );
+ return tasksQuery.data?.tasks.find((task) => task.id === scheduledTaskId)?.title;
+}
+
+export function FoldedMessageHeader(props: {
icon: LucideIcon;
label: string;
summary: string;
diff --git a/packages/client-runtime/src/state/threadWorkflows.ts b/packages/client-runtime/src/state/threadWorkflows.ts
index 33bad92dab2..9e13b669a1d 100644
--- a/packages/client-runtime/src/state/threadWorkflows.ts
+++ b/packages/client-runtime/src/state/threadWorkflows.ts
@@ -27,6 +27,8 @@ export interface QueuedThreadRun {
readonly attachments: ReadonlyArray<ChatAttachment>;
readonly messageId: Message["id"];
readonly context?: Message["context"];
+ /** Carries the attribution a sent message shows: automation, agent sender, or guest. */
+ readonly message?: Message;
}
export interface ThreadQueueWorkflowState {
@@ -155,6 +157,7 @@ export function deriveThreadQueueWorkflowState(projection: Projection): ThreadQu
attachments: message?.attachments ?? [],
messageId: run.userMessageId,
...(message?.context ? { context: message.context } : {}),
+ ...(message ? { message } : {}),
};
});
diff --git a/packages/client-runtime/src/userMessage.ts b/packages/client-runtime/src/userMessage.ts
index 8f5eb2e2ffe..99e9841faaa 100644
--- a/packages/client-runtime/src/userMessage.ts
+++ b/packages/client-runtime/src/userMessage.ts
@@ -27,7 +27,7 @@ export function resolveUserMessagePresentation(message: {
readonly text: string;
readonly createdBy?: OrchestrationV2Actor;
readonly creationSource?: OrchestrationV2CreationSource;
- readonly scheduledTaskId?: ScheduledTaskId;
+ readonly scheduledTaskId?: ScheduledTaskId | undefined;
readonly context?: { readonly guest?: GuestMessageAttribution | undefined } | undefined;
}): {
readonly text: string;