The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 14:30 UTC
feat(web,mobile): queued messages show who sent them (#26159)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 27, 2026 at 15:23 UTC
b31de684d22c9a5f8912748e5dae9376c3f6a635
7 files changed
+356
-81
apps/mobile/src/features/threads/ThreadQueueControl.tsx
+82
-16
@@ -4,6 +4,8 @@ import {
4
makeQueuedRunsAtom,
5
queuedRunEditBlockedReason,
6
} from "@t3tools/client-runtime/queued-run-edit";
7
+import { scopeThreadRef } from "@t3tools/client-runtime/environment";
8
+import { resolveUserMessagePresentation } from "@t3tools/client-runtime/user-message";
9
import type { ChatAttachment, EnvironmentId, RunId, ThreadId } from "@t3tools/contracts";
10
import { Atom } from "effect/reactivity";
11
import { Image } from "expo-image";
@@ -27,6 +29,9 @@ import { scopedThreadKey } from "../../lib/scopedEntities";
29
import { useUniwindTheme } from "../../lib/useUniwindTheme";
30
import { NativeStackScreenOptions, nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
31
import { useAssetUrl } from "../../state/assets";
32
+import { useQuietThreadShell } from "../../state/entities";
33
+import { useEnvironmentQuery } from "../../state/query";
34
+import { serverEnvironment } from "../../state/server";
35
import { assetImageSource } from "../../lib/assetImageSource";
36
import { beginQueuedRunEdit, useQueuedRunEdit } from "../../state/queued-run-edit";
37
import { environmentThreadDetails, threadEnvironment } from "../../state/threads";
@@ -58,6 +63,62 @@ export function useThreadQueuedCount(target: QueueTarget | null) {
63
);
64
}
65
66
+type QueuedRunMessage = NonNullable<
67
+ NonNullable<ReturnType<typeof useThreadQueueWorkflow>>["queuedRuns"][number]["message"]
68
+>;
69
+
70
+/** Who sent a queued message, as its sent form shows it in the thread. */
71
+function QueuedRunSender(props: {
72
+ readonly environmentId: EnvironmentId;
73
+ readonly message: QueuedRunMessage;
74
+}) {
75
+ const { attribution, scheduledTaskId } = resolveUserMessagePresentation(props.message);
76
+ const senderThreadId = attribution === "agent" ? props.message.senderThreadId : undefined;
77
+ const senderShell = useQuietThreadShell(
78
+ senderThreadId ? scopeThreadRef(props.environmentId, senderThreadId) : null,
79
+ );
80
+ const tasks = useEnvironmentQuery(
81
+ scheduledTaskId
82
+ ? serverEnvironment.scheduledTasksLive({ environmentId: props.environmentId, input: {} })
83
+ : null,
84
+ );
85
+ const sender =
86
+ attribution === "automation"
87
+ ? {
88
+ icon: "calendar.badge.clock" as const,
89
+ label:
90
+ tasks.data?.tasks.find((task) => task.id === scheduledTaskId)?.title ?? "Automation",
91
+ }
92
+ : attribution === "agent"
93
+ ? {
94
+ icon: "bubble.left.and.bubble.right" as const,
95
+ label: senderShell?.title.trim() || "Agent",
96
+ }
97
+ : attribution === "t3code"
98
+ ? { icon: null, label: "Sent by T3 Code" }
99
+ : null;
100
+ if (sender === null) return null;
101
+ return (
102
+ <View className="flex-row items-center gap-1">
103
+ {sender.icon ? (
104
+ <SymbolView
105
+ name={sender.icon}
106
+ size={11}
107
+ weight="medium"
108
+ tintColorClassName="accent-foreground-muted"
109
+ type="monochrome"
110
+ />
111
+ ) : null}
112
+ <Text
113
+ numberOfLines={1}
114
+ className="min-w-0 shrink font-t3-medium text-2xs text-foreground-muted"
115
+ >
116
+ {sender.label}
117
+ </Text>
118
+ </View>
119
+ );
120
+}
121
+
122
export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
123
const { layout } = useAdaptiveWorkspaceLayout();
124
const target = route.params;
@@ -173,7 +234,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
234
No messages waiting in this queue.
235
</Text>
236
) : null}
176
- {queuedRuns.map(({ run, text, attachments, context }, index) => {
237
+ {queuedRuns.map(({ run, text, attachments, context, message }, index) => {
238
const controls = resolveThreadQueueRowControls({
239
busy: busyRunId !== null,
240
canPromoteToSteer: workflow?.canPromoteToSteer ?? false,
@@ -240,21 +301,26 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
301
environmentId={target.environmentId}
302
attachments={attachments}
303
/>
243
- <Text
244
- className={
245
- controls.isEditing
246
- ? "min-w-0 flex-1 text-sm text-foreground-muted"
247
- : "min-w-0 flex-1 text-sm text-foreground"
248
- }
249
- numberOfLines={1}
250
- >
251
- {context?.guest === undefined ? null : (
252
- <Text className="font-t3-medium text-adaptive-fuchsia-600-300">
253
- {`${context.guest.name} `}
254
- </Text>
255
- )}
256
- {title}
257
- </Text>
304
+ <View className="min-w-0 flex-1 gap-0.5">
305
+ {message ? (
306
+ <QueuedRunSender environmentId={target.environmentId} message={message} />
307
+ ) : null}
308
+ <Text
309
+ className={
310
+ controls.isEditing
311
+ ? "text-sm text-foreground-muted"
312
+ : "text-sm text-foreground"
313
+ }
314
+ numberOfLines={1}
315
+ >
316
+ {context?.guest === undefined ? null : (
317
+ <Text className="font-t3-medium text-adaptive-fuchsia-600-300">
318
+ {`${context.guest.name} `}
319
+ </Text>
320
+ )}
321
+ {title}
322
+ </Text>
323
+ </View>
324
{controls.isEditing ? (
325
<Text className="shrink-0 text-2xs uppercase tracking-wide text-primary">
326
Editing
apps/web/src/components/ChatView.tsx
+2
@@ -2907,6 +2907,8 @@ export default function ChatView(props: ChatViewProps) {
2907
})}
2908
onEditQueuedRun={queuedRunEdit.beginEdit}
2909
onCancelEdit={queuedRunEdit.cancelEdit}
2910
+ timestampFormat={timestampFormat}
2911
+ onOpenThread={onOpenRelatedThreadStable}
2912
/>
2913
</>
2914
) : null;
apps/web/src/components/chat/QueuedRunsControl.browser.test.tsx
+75
@@ -1,5 +1,6 @@
1
import { EnvironmentId, MessageId, ThreadId } from "@t3tools/contracts";
2
import { serializeAssistantCitation } from "@t3tools/shared/assistantCitations";
3
+import * as DateTime from "effect/DateTime";
4
import type { ComponentProps } from "react";
5
import { expect, it, vi } from "vite-plus/test";
6
import { page } from "vite-plus/test/browser";
@@ -17,6 +18,15 @@ vi.mock(import("@t3tools/client-runtime/state/thread-workflows"), async (importO
18
vi.mock(import("../../state/entities"), async (importOriginal) => ({
19
...(await importOriginal()),
20
useThreadProjection: (() => state.projection) as never,
21
+ useQuietThreadShell: ((target: unknown) =>
22
+ target === null ? null : { title: "Release lead" }) as never,
23
+}));
24
+
25
+vi.mock(import("../../state/query"), async (importOriginal) => ({
26
+ ...(await importOriginal()),
27
+ useEnvironmentQuery: (() => ({
28
+ data: { tasks: [{ id: "task:webhook", title: "PR dispatcher" }] },
29
+ })) as never,
30
}));
31
32
vi.mock(import("../../state/use-atom-command"), async (importOriginal) => ({
@@ -46,6 +56,8 @@ const baseProps = {
56
editBlockedReason: null,
57
onEditQueuedRun: () => undefined,
58
onCancelEdit: () => undefined,
59
+ timestampFormat: "locale",
60
+ onOpenThread: () => undefined,
61
} satisfies ComponentProps<typeof QueuedRunsControl>;
62
63
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
109
expect.objectContaining({ text: quoteAndText }),
110
);
111
});
112
+
113
+it("shows who sent a queued message and folds automation and agent prompts", async () => {
114
+ setup();
115
+ const message = (id: string, fields: Record<string, unknown>) => ({
116
+ id,
117
+ role: "user",
118
+ createdAt: DateTime.makeUnsafe("2026-10-27T12:00:00.000Z"),
119
+ ...fields,
120
+ });
121
+ state.projection = { projection: { messages: [] } };
122
+ state.workflow = {
123
+ activeRun: { id: "run:active" },
124
+ canPromoteToSteer: true,
125
+ queuedRuns: [
126
+ [
127
+ "run:automation",
128
+ "GitHub labeled a pull request.\nFollow the runbook.",
129
+ {
130
+ createdBy: "agent",
131
+ scheduledTaskId: "task:webhook",
132
+ },
133
+ ],
134
+ [
135
+ "run:agent",
136
+ "Review finished.",
137
+ {
138
+ createdBy: "agent",
139
+ creationSource: "provider",
140
+ senderThreadId: "thread:lead",
141
+ },
142
+ ],
143
+ [
144
+ "run:server",
145
+ "Continue where you left off.",
146
+ {
147
+ createdBy: "agent",
148
+ creationSource: "server",
149
+ },
150
+ ],
151
+ ].map(([runId, text, fields]) => ({
152
+ run: { id: runId, userMessageId: `${runId}:message` },
153
+ text,
154
+ attachments: [],
155
+ message: message(`${runId}:message`, { text, ...(fields as object) }),
156
+ })),
157
+ };
158
+ const onOpenThread = vi.fn();
159
+ await using _screen = await renderQueue({ onOpenThread });
160
+
161
+ const automation = page.getByRole("button", { name: /PR dispatcher/ });
162
+ await expect.element(automation).toHaveAttribute("aria-expanded", "false");
163
+ await expect.element(page.getByText(/Follow the runbook/)).not.toBeInTheDocument();
164
+ await automation.click();
165
+ await expect.element(page.getByText(/Follow the runbook/)).toBeVisible();
166
+ await expect.element(page.getByRole("link", { name: "Open automation" })).toBeInTheDocument();
167
+
168
+ await expect.element(page.getByRole("button", { name: /Release lead/ })).toBeVisible();
169
+ await page.getByRole("button", { name: "Open thread" }).click({ force: true });
170
+ expect(onOpenThread).toHaveBeenCalledExactlyOnceWith("thread:lead");
171
+
172
+ await expect.element(page.getByText("Sent by T3 Code")).toBeVisible();
173
+ await expect.element(page.getByText("Continue where you left off.")).toBeVisible();
174
+});
apps/web/src/components/chat/QueuedRunsControl.tsx
+171
-52
@@ -9,18 +9,32 @@ import type {
9
RunId,
10
ThreadId,
11
} from "@t3tools/contracts";
12
-import { ChevronDownIcon, Clock3Icon, ArrowUpIcon, PencilIcon, XIcon } from "lucide-react";
13
-import { useId, useImperativeHandle, useRef, useState, type Ref } from "react";
12
+import { resolveUserMessagePresentation } from "@t3tools/client-runtime/user-message";
13
+import { Link } from "@tanstack/react-router";
14
+import {
15
+ ArrowUpIcon,
16
+ CalendarClockIcon,
17
+ ChevronDownIcon,
18
+ Clock3Icon,
19
+ MessagesSquareIcon,
20
+ PencilIcon,
21
+ XIcon,
22
+} from "lucide-react";
23
+import * as DateTime from "effect/DateTime";
24
+import { useId, useImperativeHandle, useRef, useState, type ReactNode, type Ref } from "react";
25
26
import { useAssetUrls } from "../../assets/assetUrls";
27
import { threadEnvironment } from "../../state/threads";
17
-import { useThreadProjection } from "../../state/entities";
28
+import { useQuietThreadShell, useThreadProjection } from "../../state/entities";
29
import { useAtomCommand } from "../../state/use-atom-command";
30
import { isImageAttachment, type ChatMessage } from "../../types";
31
import { cn } from "~/lib/utils";
32
import { Button, InlineButton } from "../ui/button";
22
-import { Separator } from "../ui/separator";
33
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
34
+import type { TimestampFormat } from "@t3tools/contracts/settings";
35
+import { GuestMessageName } from "./guestMessageStyle";
36
+import { TimelineRowTimestamp } from "./TimelineRowParts";
37
+import { FoldedMessageHeader, useScheduledTaskTitle } from "./TimelineUserMessageRow";
38
39
export interface EditQueuedRunRequest {
40
readonly runId: RunId;
@@ -73,6 +87,8 @@ export function QueuedRunsControl({
87
readonly editBlockedReason: string | null;
88
readonly onEditQueuedRun: (request: EditQueuedRunRequest) => void;
89
readonly onCancelEdit: () => void;
90
+ readonly timestampFormat: TimestampFormat;
91
+ readonly onOpenThread: (threadId: ThreadId) => void;
92
}) {
93
const projection = useThreadProjection(
94
scopeThreadRef(props.environmentId, props.threadId),
@@ -105,15 +121,15 @@ export function QueuedRunsControl({
121
(message) => message.inputIntent === "queued_turn" && !acknowledgedMessageIds.has(message.id),
122
);
123
const items = [
108
- ...queued.map(({ run, text, attachments, context }, serverIndex) => ({
124
+ ...queued.map(({ run, text, attachments, context, message }, serverIndex) => ({
125
key: run.id,
126
+ message,
127
runId: run.id,
128
messageId: run.userMessageId,
129
serverIndex,
130
text,
131
// A guest's message keeps the guest's words; the owner can cancel it, not rewrite it.
132
editable: context?.guest === undefined,
116
- guestName: context?.guest?.name,
133
attachments,
134
thumbnails: attachments
135
.filter((attachment) => attachment.type === "image")
@@ -126,12 +142,12 @@ export function QueuedRunsControl({
142
})),
143
...optimisticQueued.map((message) => ({
144
key: message.id,
145
+ message: undefined,
146
runId: null,
147
messageId: null,
148
serverIndex: null,
149
text: message.text,
150
editable: true,
134
- guestName: undefined,
151
attachments: [] as ReadonlyArray<ContractChatAttachment>,
152
thumbnails: (message.attachments ?? [])
153
.filter(isImageAttachment)
@@ -233,51 +249,17 @@ export function QueuedRunsControl({
249
aria-posinset={position + 1}
250
aria-setsize={items.length}
251
aria-current={isEditing ? "true" : undefined}
236
- className="flex w-full flex-col items-end gap-1 transition-opacity duration-150 ease-out starting:opacity-0 motion-reduce:transition-none"
252
+ 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"
253
>
238
- {/* Dashed and unfilled: a turn that has not been sent yet. */}
239
- <div
240
- className={cn(
241
- "flex min-w-0 max-w-[80%] flex-col gap-2 rounded-2xl border border-dashed px-3 py-2 text-sm",
242
- isEditing
243
- ? "border-primary/60 text-foreground"
244
- : "border-muted-foreground/40 text-muted-foreground",
245
- )}
254
+ <QueuedMessage
255
+ environmentId={props.environmentId}
256
+ message={item.message}
257
+ previewText={previewText}
258
+ thumbnails={item.thumbnails}
259
+ isEditing={isEditing}
260
+ timestampFormat={props.timestampFormat}
261
+ onOpenThread={props.onOpenThread}
262
>
247
- {item.thumbnails.length > 0 ? (
248
- <span className="flex flex-wrap items-center gap-1">
249
- {item.thumbnails.map((thumbnail) => (
250
- <span
251
- key={thumbnail.key}
252
- className="size-8 overflow-hidden rounded-md border border-border/70 bg-background"
253
- >
254
- {thumbnail.url ? (
255
- <img
256
- src={thumbnail.url}
257
- alt={thumbnail.name}
258
- className="size-full object-cover"
259
- />
260
- ) : (
261
- <span
262
- aria-label={thumbnail.name}
263
- className="block size-full bg-muted/60"
264
- />
265
- )}
266
- </span>
267
- ))}
268
- </span>
269
- ) : null}
270
- {/* In full, like a sent turn: a queued message is read before it is sent. */}
271
- {previewText ? (
272
- <p className="whitespace-pre-wrap wrap-anywhere">
273
- {item.guestName === undefined ? null : (
274
- <span className="text-guest-foreground">{item.guestName} </span>
275
- )}
276
- {previewText}
277
- </p>
278
- ) : null}
279
- </div>
280
- <div className="flex items-center gap-0.5 pe-1 text-xs text-muted-foreground">
263
{canSend && !isEditing ? (
264
<>
265
<Tooltip>
@@ -300,7 +282,6 @@ export function QueuedRunsControl({
282
{`${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})` : ""}`}
283
</TooltipPopup>
284
</Tooltip>
303
- <Separator orientation="vertical" className="mx-2 h-4" />
285
</>
286
) : null}
287
{item.pending ? (
@@ -375,7 +356,7 @@ export function QueuedRunsControl({
356
</Tooltip>
357
</>
358
)}
378
- </div>
359
+ </QueuedMessage>
360
</li>
361
);
362
})}
@@ -404,3 +385,141 @@ export function QueuedRunsControl({
385
</section>
386
);
387
}
388
+
389
+type QueuedRunMessage = NonNullable<ThreadQueueProjection["messages"][number]>;
390
+
391
+/** A queued turn wears its sent form's attribution; only the dashed edge and controls differ. */
392
+function QueuedMessage(props: {
393
+ readonly environmentId: EnvironmentId;
394
+ readonly message: QueuedRunMessage | undefined;
395
+ readonly previewText: string;
396
+ readonly thumbnails: ReadonlyArray<QueuedRowThumbnail>;
397
+ readonly isEditing: boolean;
398
+ readonly timestampFormat: TimestampFormat;
399
+ readonly onOpenThread: (threadId: ThreadId) => void;
400
+ readonly children: ReactNode;
401
+}) {
402
+ const presentation = props.message ? resolveUserMessagePresentation(props.message) : null;
403
+ const attribution = presentation?.attribution ?? null;
404
+ const scheduledTaskId = presentation?.scheduledTaskId;
405
+ const senderThreadId = props.message?.senderThreadId;
406
+ const [expanded, setExpanded] = useState(false);
407
+ const taskTitle = useScheduledTaskTitle(props.environmentId, scheduledTaskId);
408
+ const senderShell = useQuietThreadShell(
409
+ attribution === "agent" && senderThreadId
410
+ ? { environmentId: props.environmentId, threadId: senderThreadId }
411
+ : null,
412
+ );
413
+ const fold =
414
+ attribution === "automation"
415
+ ? {
416
+ icon: CalendarClockIcon,
417
+ label: "Automation",
418
+ summary: taskTitle ?? props.previewText.split(/\r?\n/, 1)[0] ?? "",
419
+ }
420
+ : attribution === "agent"
421
+ ? {
422
+ icon: MessagesSquareIcon,
423
+ label: senderShell?.title.trim() || "Agent",
424
+ summary: props.previewText.split(/\r?\n/).find((line) => line.trim()) ?? "",
425
+ }
426
+ : null;
427
+ const bodyVisible = fold === null || expanded;
428
+
429
+ return (
430
+ <>
431
+ {attribution === "t3code" ? (
432
+ <p className="me-1 text-2xs text-muted-foreground/70">Sent by T3 Code</p>
433
+ ) : null}
434
+ {presentation?.guestName === undefined ? null : (
435
+ <GuestMessageName name={presentation.guestName} />
436
+ )}
437
+ {/* Dashed and unfilled: a turn that has not been sent yet. */}
438
+ <div
439
+ className={cn(
440
+ "flex min-w-0 max-w-[80%] flex-col rounded-2xl border border-dashed text-sm",
441
+ props.isEditing
442
+ ? "border-primary/60 text-foreground"
443
+ : attribution === "guest"
444
+ ? "border-guest/50 text-muted-foreground"
445
+ : "border-muted-foreground/40 text-muted-foreground",
446
+ fold === null && "px-3 py-2",
447
+ fold !== null && expanded && "w-full",
448
+ )}
449
+ >
450
+ {fold ? (
451
+ <FoldedMessageHeader
452
+ icon={fold.icon}
453
+ label={fold.label}
454
+ summary={fold.summary}
455
+ expanded={expanded}
456
+ onToggle={() => setExpanded((value) => !value)}
457
+ />
458
+ ) : null}
459
+ {bodyVisible ? (
460
+ <div
461
+ className={cn(
462
+ "flex flex-col gap-2",
463
+ fold !== null && "max-h-96 overflow-auto px-3 pb-2",
464
+ )}
465
+ >
466
+ {props.thumbnails.length > 0 ? (
467
+ <span className="flex flex-wrap items-center gap-1">
468
+ {props.thumbnails.map((thumbnail) => (
469
+ <span
470
+ key={thumbnail.key}
471
+ className="size-8 overflow-hidden rounded-md border border-border/70 bg-background"
472
+ >
473
+ {thumbnail.url ? (
474
+ <img
475
+ src={thumbnail.url}
476
+ alt={thumbnail.name}
477
+ className="size-full object-cover"
478
+ />
479
+ ) : (
480
+ <span aria-label={thumbnail.name} className="block size-full bg-muted/60" />
481
+ )}
482
+ </span>
483
+ ))}
484
+ </span>
485
+ ) : null}
486
+ {/* In full, like a sent turn: a queued message is read before it is sent. */}
487
+ {props.previewText ? (
488
+ <p className="whitespace-pre-wrap wrap-anywhere">{props.previewText}</p>
489
+ ) : null}
490
+ </div>
491
+ ) : null}
492
+ </div>
493
+ <div className="flex items-center gap-0.5 pe-1 text-xs text-muted-foreground">
494
+ {props.message ? (
495
+ <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">
496
+ {attribution === "agent" && senderThreadId ? (
497
+ <InlineButton tone="muted" onClick={() => props.onOpenThread(senderThreadId)}>
498
+ Open thread
499
+ </InlineButton>
500
+ ) : null}
501
+ {scheduledTaskId ? (
502
+ <InlineButton
503
+ tone="muted"
504
+ render={
505
+ <Link
506
+ to="/settings/scheduled-tasks"
507
+ search={{ environmentId: props.environmentId, taskId: scheduledTaskId }}
508
+ />
509
+ }
510
+ >
511
+ Open automation
512
+ </InlineButton>
513
+ ) : null}
514
+ <TimelineRowTimestamp
515
+ createdAt={DateTime.formatIso(props.message.createdAt)}
516
+ timestampFormat={props.timestampFormat}
517
+ alwaysVisible
518
+ />
519
+ </span>
520
+ ) : null}
521
+ {props.children}
522
+ </div>
523
+ </>
524
+ );
525
+}
apps/web/src/components/chat/TimelineUserMessageRow.tsx
+22
-12
@@ -1,7 +1,13 @@
1
import { InlineAudioPreview } from "../files/InlineAudioPreview";
2
import { filePreviewKind } from "@t3tools/shared/filePreview";
3
import { findRevealRef } from "./markdownFindContext";
4
-import { type MessageId, type ServerProviderSkill, ThreadId } from "@t3tools/contracts";
4
+import {
5
+ type EnvironmentId,
6
+ type MessageId,
7
+ type ScheduledTaskId,
8
+ type ServerProviderSkill,
9
+ ThreadId,
10
+} from "@t3tools/contracts";
11
import { resolveUserMessagePresentation } from "@t3tools/client-runtime/user-message";
12
import { Link } from "@tanstack/react-router";
13
import { useQuietThreadShell } from "../../state/entities";
@@ -143,16 +149,10 @@ function AutomationMessageRow({ row }: { row: Extract<TimelineRow, { kind: "mess
149
const [expanded, setExpanded] = useState(false);
150
const revealRef = findRevealRef(() => setExpanded(true));
151
const { text, scheduledTaskId } = resolveUserMessagePresentation(row.message);
146
- const tasksQuery = useEnvironmentQuery(
147
- scheduledTaskId
148
- ? serverEnvironment.scheduledTasksLive({
149
- environmentId: ctx.activeThreadEnvironmentId,
150
- input: {},
151
- })
152
- : null,
153
- );
154
- const taskTitle = tasksQuery.data?.tasks.find((task) => task.id === scheduledTaskId)?.title;
155
- const summary = taskTitle ?? text.trim().split(/\r?\n/, 1)[0] ?? "";
152
+ const summary =
153
+ useScheduledTaskTitle(ctx.activeThreadEnvironmentId, scheduledTaskId) ??
154
+ text.trim().split(/\r?\n/, 1)[0] ??
155
+ "";
156
157
const revertTurnCount = row.revertTurnCount;
158
const promptLink = promptLinkFor(text);
@@ -231,7 +231,17 @@ function AutomationMessageRow({ row }: { row: Extract<TimelineRow, { kind: "mess
231
);
232
}
233
234
-function FoldedMessageHeader(props: {
234
+export function useScheduledTaskTitle(
235
+ environmentId: EnvironmentId,
236
+ scheduledTaskId: ScheduledTaskId | undefined,
237
+): string | undefined {
238
+ const tasksQuery = useEnvironmentQuery(
239
+ scheduledTaskId ? serverEnvironment.scheduledTasksLive({ environmentId, input: {} }) : null,
240
+ );
241
+ return tasksQuery.data?.tasks.find((task) => task.id === scheduledTaskId)?.title;
242
+}
243
+
244
+export function FoldedMessageHeader(props: {
245
icon: LucideIcon;
246
label: string;
247
summary: string;
packages/client-runtime/src/state/threadWorkflows.ts
+3
@@ -27,6 +27,8 @@ export interface QueuedThreadRun {
27
readonly attachments: ReadonlyArray<ChatAttachment>;
28
readonly messageId: Message["id"];
29
readonly context?: Message["context"];
30
+ /** Carries the attribution a sent message shows: automation, agent sender, or guest. */
31
+ readonly message?: Message;
32
}
33
34
export interface ThreadQueueWorkflowState {
@@ -155,6 +157,7 @@ export function deriveThreadQueueWorkflowState(projection: Projection): ThreadQu
157
attachments: message?.attachments ?? [],
158
messageId: run.userMessageId,
159
...(message?.context ? { context: message.context } : {}),
160
+ ...(message ? { message } : {}),
161
};
162
});
163
packages/client-runtime/src/userMessage.ts
+1
-1
@@ -27,7 +27,7 @@ export function resolveUserMessagePresentation(message: {
27
readonly text: string;
28
readonly createdBy?: OrchestrationV2Actor;
29
readonly creationSource?: OrchestrationV2CreationSource;
30
- readonly scheduledTaskId?: ScheduledTaskId;
30
+ readonly scheduledTaskId?: ScheduledTaskId | undefined;
31
readonly context?: { readonly guest?: GuestMessageAttribution | undefined } | undefined;
32
}): {
33
readonly text: string;