diff --git a/apps/mobile/src/features/threads/threadAgentsPresentation.test.ts b/apps/mobile/src/features/threads/threadAgentsPresentation.test.ts index 171d73a14859..e0771be61c5e 100644 --- a/apps/mobile/src/features/threads/threadAgentsPresentation.test.ts +++ b/apps/mobile/src/features/threads/threadAgentsPresentation.test.ts @@ -64,10 +64,15 @@ describe("resolveSubagentRowPresentation", () => { it("falls back to a trimmed prompt when the agent has no title", () => { const long = resolveSubagentRowPresentation({ ...base, prompt: "x".repeat(200) }); + const emoji = resolveSubagentRowPresentation({ + ...base, + prompt: `${"x".repeat(76)}😀 and more`, + }); const titled = resolveSubagentRowPresentation({ ...base, title: "Subagent: /root/my_worker" }); expect(long.title).toHaveLength(80); expect(long.title.endsWith("...")).toBe(true); + expect(emoji.title).toBe(`${"x".repeat(76)}...`); expect(titled.title).toBe("My Worker"); }); diff --git a/apps/mobile/src/features/threads/threadAgentsPresentation.ts b/apps/mobile/src/features/threads/threadAgentsPresentation.ts index 270cc1f3d7fb..a5af5b0e6c5e 100644 --- a/apps/mobile/src/features/threads/threadAgentsPresentation.ts +++ b/apps/mobile/src/features/threads/threadAgentsPresentation.ts @@ -7,6 +7,7 @@ import { } from "@t3tools/client-runtime/state/subagent-display"; import { isActiveSubagentStatus, + promptTitle, type RuntimeSubagent, type SubagentWorkflowGroup, } from "@t3tools/client-runtime/state/subagentRuntime"; @@ -22,8 +23,6 @@ import { msg } from "gt-react-native"; import { m, type MessageResolver } from "../../i18n/messages"; -const PROMPT_TITLE_LIMIT = 80; - export type SubagentRowTone = "working" | "completed" | "failed" | "stopped"; export interface SubagentRowPresentation { @@ -82,9 +81,7 @@ function rowTitle( if (title) return formatSubagentDisplayTitle(title); const prompt = subagent.prompt.trim(); if (prompt.length === 0) return resolve(msg("Subagent")); - return prompt.length > PROMPT_TITLE_LIMIT - ? `${prompt.slice(0, PROMPT_TITLE_LIMIT - 3)}...` - : prompt; + return promptTitle(prompt); } function rowTone(status: OrchestrationV2Subagent["status"]): SubagentRowTone { diff --git a/packages/client-runtime/src/state/subagentRuntime.ts b/packages/client-runtime/src/state/subagentRuntime.ts index 44c1ea98064b..b6efb9cac132 100644 --- a/packages/client-runtime/src/state/subagentRuntime.ts +++ b/packages/client-runtime/src/state/subagentRuntime.ts @@ -186,7 +186,7 @@ function workflowMembersToRuntime( }); } -function promptTitle(prompt: string): string { +export function promptTitle(prompt: string): string { if (prompt.length <= 80) return prompt; let end = 77; const previous = prompt.charCodeAt(end - 1);