diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsx index 59cef03961..913fff0264 100644 --- a/apps/mobile/src/features/threads/ThreadFeed.tsx +++ b/apps/mobile/src/features/threads/ThreadFeed.tsx @@ -110,6 +110,7 @@ import { useAtomCommand } from "../../state/use-atom-command"; import { useV2ItemSupport } from "../../state/v2-item-support"; import { resolveWorkspaceRelativeFilePath } from "../files/filePath"; import { waitForThreadShellReady } from "./threadForkNavigation"; +import { resolveUserMessageIntentBadge } from "./userMessageIntentBadge"; const WIDE_MARKDOWN_BLOCK_OPTIONS = { includeOrderedLists: Platform.OS === "android", @@ -992,6 +993,7 @@ function renderFeedEntry( if (isUser) { const enterAnimated = isFreshTimestamp(message.createdAt); + const intentBadge = resolveUserMessageIntentBadge(message.inputIntent); return ( {message.createdBy === "agent" ? ( @@ -1033,6 +1035,30 @@ function renderFeedEntry( })} + {intentBadge ? ( + + + {intentBadge.label} + + + ) : null} {timestampLabel} diff --git a/apps/mobile/src/features/threads/userMessageIntentBadge.test.ts b/apps/mobile/src/features/threads/userMessageIntentBadge.test.ts new file mode 100644 index 0000000000..f29c4bba16 --- /dev/null +++ b/apps/mobile/src/features/threads/userMessageIntentBadge.test.ts @@ -0,0 +1,34 @@ +import { describe, expect, it } from "@effect/vitest"; + +import { resolveUserMessageIntentBadge } from "./userMessageIntentBadge"; + +describe("user message intent badge", () => { + it("does not label ordinary turn-start messages", () => { + expect(resolveUserMessageIntentBadge(undefined)).toBeNull(); + expect(resolveUserMessageIntentBadge("turn_start")).toBeNull(); + }); + + it("labels messages waiting behind the active turn", () => { + expect(resolveUserMessageIntentBadge("queued_turn")).toEqual({ + label: "queued", + accessibilityLabel: "Queued behind the active turn", + tone: "queued", + }); + }); + + it("labels messages that steer the active turn", () => { + expect(resolveUserMessageIntentBadge("steer")).toEqual({ + label: "steer", + accessibilityLabel: "Steered the active turn", + tone: "steer", + }); + }); + + it("preserves the queued origin after promotion to steer", () => { + expect(resolveUserMessageIntentBadge("promoted_queued_to_steer")).toEqual({ + label: "queued → steer", + accessibilityLabel: "Originally queued, then promoted to steer the active turn", + tone: "steer", + }); + }); +}); diff --git a/apps/mobile/src/features/threads/userMessageIntentBadge.ts b/apps/mobile/src/features/threads/userMessageIntentBadge.ts new file mode 100644 index 0000000000..c72c1c342d --- /dev/null +++ b/apps/mobile/src/features/threads/userMessageIntentBadge.ts @@ -0,0 +1,35 @@ +import type { OrchestrationV2UserMessageInputIntent } from "@t3tools/contracts"; + +export interface UserMessageIntentBadgePresentation { + readonly label: string; + readonly accessibilityLabel: string; + readonly tone: "queued" | "steer"; +} + +export function resolveUserMessageIntentBadge( + intent: OrchestrationV2UserMessageInputIntent | undefined, +): UserMessageIntentBadgePresentation | null { + switch (intent) { + case "queued_turn": + return { + label: "queued", + accessibilityLabel: "Queued behind the active turn", + tone: "queued", + }; + case "steer": + return { + label: "steer", + accessibilityLabel: "Steered the active turn", + tone: "steer", + }; + case "promoted_queued_to_steer": + return { + label: "queued → steer", + accessibilityLabel: "Originally queued, then promoted to steer the active turn", + tone: "steer", + }; + case "turn_start": + case undefined: + return null; + } +}