Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});

Expand Down
7 changes: 2 additions & 5 deletions apps/mobile/src/features/threads/threadAgentsPresentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/client-runtime/src/state/subagentRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading