Skip to content

Commit 271cabc

Browse files
committed
fix(web,mobile): hide the attachment-only prompt with an ultrathink prefix and in queue previews
1 parent e7c8b93 commit 271cabc

6 files changed

Lines changed: 34 additions & 14 deletions

File tree

‎apps/mobile/src/features/threads/threadQueueControlPresentation.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { EnvironmentId, RunId, ThreadId } from "@t3tools/contracts";
22
import { assistantCitationsToPlainText } from "@t3tools/shared/assistantCitations";
3+
import { isAttachmentOnlyBootstrapPrompt } from "@t3tools/shared/composerContextReferences";
34

45
export const REMOVE_QUEUED_MESSAGE_ACCESSIBILITY_LABEL = "Remove queued message";
56

@@ -35,7 +36,9 @@ export function resolveThreadQueueRowControls(input: {
3536
canSend: mutationEnabled && (input.canPromoteToSteer || input.canSendNow) && !isEditing,
3637
dismissAccessibilityLabel: REMOVE_QUEUED_MESSAGE_ACCESSIBILITY_LABEL,
3738
// Editing and sending keep the original text so quoted citations stay linked.
38-
displayText: assistantCitationsToPlainText(input.text),
39+
displayText: isAttachmentOnlyBootstrapPrompt(input.text)
40+
? ""
41+
: assistantCitationsToPlainText(input.text),
3942
isEditing,
4043
};
4144
}

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
22
import { deriveThreadQueueWorkflowState } from "@t3tools/client-runtime/state/thread-workflows";
33
import { assistantCitationsToPlainText } from "@t3tools/shared/assistantCitations";
4-
import { replaceComposerContextReferences } from "@t3tools/shared/composerContextReferences";
4+
import {
5+
isAttachmentOnlyBootstrapPrompt,
6+
replaceComposerContextReferences,
7+
} from "@t3tools/shared/composerContextReferences";
58
import type {
69
ChatAttachment as ContractChatAttachment,
710
EnvironmentId,
@@ -237,11 +240,13 @@ export function QueuedRunsControl({
237240
</span>
238241
<ol className="flex flex-col items-end gap-3" id={queueListId}>
239242
{visibleItems.map((item, position) => {
240-
const previewText = assistantCitationsToPlainText(
241-
replaceComposerContextReferences(item.text, (reference) =>
242-
reference.kind === "image" && item.thumbnails.length > 0 ? "" : reference.label,
243-
),
244-
).trim();
243+
const previewText = isAttachmentOnlyBootstrapPrompt(item.text)
244+
? ""
245+
: assistantCitationsToPlainText(
246+
replaceComposerContextReferences(item.text, (reference) =>
247+
reference.kind === "image" && item.thumbnails.length > 0 ? "" : reference.label,
248+
),
249+
).trim();
245250
const isEditing = item.runId !== null && item.runId === props.editingRunId;
246251
return (
247252
<li

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,16 @@ describe("resolveUserMessagePresentation", () => {
2323
});
2424

2525
it("hides the prompt that stands in for an attachment-only message", () => {
26-
expect(
27-
resolveUserMessagePresentation({ role: "user", text: ATTACHMENT_ONLY_BOOTSTRAP_PROMPT }),
28-
).toEqual({ text: "", attribution: null, scheduledTaskId: undefined });
26+
for (const text of [
27+
ATTACHMENT_ONLY_BOOTSTRAP_PROMPT,
28+
`Ultrathink:\n${ATTACHMENT_ONLY_BOOTSTRAP_PROMPT}`,
29+
]) {
30+
expect(resolveUserMessagePresentation({ role: "user", text })).toEqual({
31+
text: "",
32+
attribution: null,
33+
scheduledTaskId: undefined,
34+
});
35+
}
2936
});
3037

3138
it("shows a guest's own words and name, not the attributed text the agent reads", () => {

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

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

1010
/** The working row while T3 Code's own compaction runs. */
1111
export const IDLE_COMPACTING_LABELS = {
@@ -70,7 +70,7 @@ export function resolveUserMessagePresentation(message: {
7070
}
7171
return {
7272
// The agent needs words to start a turn; people sent only the attachments.
73-
text: message.text === ATTACHMENT_ONLY_BOOTSTRAP_PROMPT ? "" : message.text,
73+
text: isAttachmentOnlyBootstrapPrompt(message.text) ? "" : message.text,
7474
attribution:
7575
message.createdBy !== "agent"
7676
? null

‎packages/shared/src/composerContextReferences.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ export function collectComposerContextReferences(
132132
export const ATTACHMENT_ONLY_BOOTSTRAP_PROMPT =
133133
"[User attached one or more files without additional text. Respond using the conversation context and the attached files.]";
134134

135+
/** Claude's ultrathink effort sends the prompt as `Ultrathink:\n<prompt>`. */
136+
export function isAttachmentOnlyBootstrapPrompt(text: string): boolean {
137+
return text.replace(/^Ultrathink:\s*/i, "") === ATTACHMENT_ONLY_BOOTSTRAP_PROMPT;
138+
}
139+
135140
export function isImageReferencesOnly(text: string): boolean {
136141
const references = collectComposerContextReferences(text);
137142
return (

‎packages/shared/src/threadFindText.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
} from "./markdownLinks.ts";
2323
import { upgradeLegacyContextMessage } from "./composerContextLegacy.ts";
2424
import {
25-
ATTACHMENT_ONLY_BOOTSTRAP_PROMPT,
25+
isAttachmentOnlyBootstrapPrompt,
2626
parseComposerContextHref,
2727
} from "./composerContextReferences.ts";
2828
import { assistantCitationLabel, parseAssistantCitationHref } from "./assistantCitations.ts";
@@ -220,7 +220,7 @@ export function searchableMessageSegments(
220220
): readonly string[] | null {
221221
if (message.role === "user") {
222222
// Clients hide this prompt, so find must not match text nobody can see.
223-
if (message.text === ATTACHMENT_ONLY_BOOTSTRAP_PROMPT) return [];
223+
if (isAttachmentOnlyBootstrapPrompt(message.text)) return [];
224224
const text = message.context ? message.text : upgradeLegacyContextMessage(message.text).text;
225225
return markdownThreadFindText(text, true, cwd, skills);
226226
}

0 commit comments

Comments
 (0)