Skip to content

Commit 9005f64

Browse files
committed
fix(web): attachment-only messages no longer show the agent prompt
The prompt sent for attachment-only messages is for the agent. Clients now hide it in the timeline and queue.
1 parent e109dc8 commit 9005f64

6 files changed

Lines changed: 23 additions & 7 deletions

File tree

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ function renderFeedEntry(
16501650
})}
16511651
</View>
16521652
) : null}
1653-
{message.text.trim().length > 0 ? (
1653+
{presentation.text.trim().length > 0 ? (
16541654
<MarkdownImageAvailableWidthContext
16551655
value={props.userBubbleMaxWidth - USER_BUBBLE_HORIZONTAL_PADDING * 2}
16561656
>

‎apps/web/src/components/chat/QueuedRunsControl.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
22
import { deriveThreadQueueWorkflowState } from "@t3tools/client-runtime/state/thread-workflows";
3+
import { userVisibleMessageText } from "@t3tools/client-runtime/user-message";
34
import { assistantCitationsToPlainText } from "@t3tools/shared/assistantCitations";
45
import { replaceComposerContextReferences } from "@t3tools/shared/composerContextReferences";
56
import type {
@@ -129,7 +130,7 @@ export function QueuedRunsControl({
129130
runId: null,
130131
messageId: null,
131132
serverIndex: null,
132-
text: message.text,
133+
text: userVisibleMessageText(message.text),
133134
editable: true,
134135
guestName: undefined,
135136
attachments: [] as ReadonlyArray<ContractChatAttachment>,

‎apps/web/src/components/chat/TimelineUserMessageRow.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,8 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
313313
: null,
314314
);
315315
const senderLabel = senderShell?.title.trim() || "Agent";
316-
const resolvedContext = resolveUserMessageContext(
317-
userMessage.attribution === "guest" ? { ...row.message, text: userMessage.text } : row.message,
318-
);
316+
// Guest and attachment-only messages show different text than the agent received.
317+
const resolvedContext = resolveUserMessageContext({ ...row.message, text: userMessage.text });
319318
const previewImages = userImages.filter((image) => image.name.startsWith("preview-annotation-"));
320319
const revertTurnCount = row.revertTurnCount;
321320
const chippedAttachmentIds = new Set(

‎packages/client-runtime/src/state/threadWorkflows.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from "@t3tools/contracts";
77
import { copySorted } from "@t3tools/shared/Array";
88

9+
import { userVisibleMessageText } from "../userMessage.ts";
910
import type { ThreadStructure } from "./models.ts";
1011

1112
type Projection = ThreadStructure;
@@ -151,7 +152,9 @@ export function deriveThreadQueueWorkflowState(projection: Projection): ThreadQu
151152
return {
152153
run,
153154
// A queued guest message shows the guest's words; the agent still gets the attributed text.
154-
text: message?.context?.guest?.text ?? message?.text ?? "Queued message",
155+
text:
156+
message?.context?.guest?.text ??
157+
(message ? userVisibleMessageText(message.text) : "Queued message"),
155158
attachments: message?.attachments ?? [],
156159
messageId: run.userMessageId,
157160
...(message?.context ? { context: message.context } : {}),

‎packages/client-runtime/src/userMessage.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, expect, it } from "vite-plus/test";
22

33
import { GuestMessageId } from "@t3tools/contracts";
4+
import { ATTACHMENT_ONLY_BOOTSTRAP_PROMPT } from "@t3tools/shared/composerContextReferences";
45

56
import { resolveUserMessagePresentation } from "./userMessage.ts";
67

@@ -21,6 +22,12 @@ describe("resolveUserMessagePresentation", () => {
2122
}
2223
});
2324

25+
it("hides the prompt sent for attachment-only messages", () => {
26+
expect(
27+
resolveUserMessagePresentation({ role: "user", text: ATTACHMENT_ONLY_BOOTSTRAP_PROMPT }),
28+
).toEqual({ text: "", attribution: null, scheduledTaskId: undefined });
29+
});
30+
2431
it("shows a guest's own words and name, not the attributed text the agent reads", () => {
2532
expect(
2633
resolveUserMessagePresentation({

‎packages/client-runtime/src/userMessage.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
type OrchestrationV2IdleCompaction,
66
ScheduledTaskId,
77
} from "@t3tools/contracts";
8+
import { ATTACHMENT_ONLY_BOOTSTRAP_PROMPT } from "@t3tools/shared/composerContextReferences";
89

910
/** The working row while T3 Code's own compaction runs. */
1011
export const IDLE_COMPACTING_LABELS = {
@@ -18,6 +19,11 @@ export const IDLE_COMPACTION_TITLES = {
1819
onReturn: "Context compacted after being idle",
1920
} satisfies Record<OrchestrationV2IdleCompaction, string>;
2021

22+
/** Attachment-only sends carry a prompt for the agent; people see only the attachments. */
23+
export function userVisibleMessageText(text: string): string {
24+
return text.trim() === ATTACHMENT_ONLY_BOOTSTRAP_PROMPT ? "" : text;
25+
}
26+
2127
const LEGACY_AUTOMATION_PREFIX = /^\[Triggered by schedule task: [^\r\n]+\]\r?\n\r?\n/;
2228
const LEGACY_AUTOMATION_MESSAGE_ID = /^scheduled-task-message:(.+):\d+:(?:scheduled|manual)$/;
2329

@@ -68,7 +74,7 @@ export function resolveUserMessagePresentation(message: {
6874
};
6975
}
7076
return {
71-
text: message.text,
77+
text: userVisibleMessageText(message.text),
7278
attribution:
7379
message.createdBy !== "agent"
7480
? null

0 commit comments

Comments
 (0)