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
16 changes: 16 additions & 0 deletions apps/mobile/src/lib/threadActivity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2322,6 +2322,22 @@ it("uses a compact reasoning preview and a short expanded heading", () => {
expect(workEntryRowLabel({ ...entry, toolLifecycleStatus: "completed" }, true)).toBe("Thought");
});

it("caps one-line work-log labels for multi-kilobyte commands", () => {
const command = `cd /repo && python3 - <<'PY'\n${"print('x')\n".repeat(400)}PY`;
const entry = {
id: "heredoc",
label: "Ran command",
createdAt: "2026-09-17T12:00:00Z",
itemType: "command_execution" as const,
tone: "tool" as const,
command,
};
for (const label of [workEntryRowLabel(entry), workEntryRowLabel(entry, true)]) {
expect(label.startsWith("cd /repo && python3 - <<'PY' print('x')")).toBe(true);
expect(label.length).toBeLessThanOrEqual(203);
}
});

it("keeps search output in expanded details rather than the compact label", () => {
const entry = {
id: "search",
Expand Down
14 changes: 11 additions & 3 deletions apps/mobile/src/lib/threadActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
formatSearchToolLabel,
} from "@t3tools/shared/toolActivity";
import { formatDuration } from "@t3tools/shared/orchestrationTiming";
import { truncate } from "@t3tools/shared/String";
import type { HtmlRenderReference } from "@t3tools/shared/htmlRender";
import type { McpAppReference } from "@t3tools/shared/mcpApp";
import {
Expand Down Expand Up @@ -254,8 +255,15 @@ export interface AgentSpawnSummary {
}>;
}

/**
* Work-log headers render one line, but Android still lays out and hit-tests
* the whole string, so a multi-kilobyte heredoc stalls touch dispatch until
* the app ANRs. Expanded bodies and copy keep the full text.
*/
const WORK_LOG_LABEL_MAX_LENGTH = 200;

function compactWorkEntryText(value: string): string {
return value.replace(/\s+/gu, " ").trim();
return truncate(value.replace(/\s+/gu, " "), WORK_LOG_LABEL_MAX_LENGTH);
}

/** Expanded work rows keep their detail while compact rows show a stable one-line label. */
Expand Down Expand Up @@ -296,7 +304,7 @@ export function workEntryRowLabel(entry: WorkLogPresentationEntry, expanded = fa
? entry.changedFiles[0]!
: `${entry.changedFiles[0]!} +${entry.changedFiles.length - 1} more`
: null);
if (expanded) return preview?.trim() || entry.label;
if (expanded) return preview?.trim() ? truncate(preview, WORK_LOG_LABEL_MAX_LENGTH) : entry.label;
return preview ? compactWorkEntryText(preview) || entry.label : entry.label;
}

Expand Down Expand Up @@ -872,7 +880,7 @@ function singleToolCallLabel(activity: ThreadFeedActivity, expanded: boolean): s
const presentation = resolveWorkEntryToolPresentation(activity.workEntry, "completed");
if (presentation) return presentation.displayName;
const command = activity.workEntry.command?.trim();
return command || activity.summary;
return command ? truncate(command, WORK_LOG_LABEL_MAX_LENGTH) : activity.summary;
}

function isEmptyMessage(entry: RawThreadFeedEntry): boolean {
Expand Down
Loading