Skip to content
TypeScript

fix(mobile): long commands no longer freeze Android work-log taps (#19238)

Quy Ngoc Nguyena086be029c50
diff --git a/apps/mobile/src/lib/threadActivity.test.ts b/apps/mobile/src/lib/threadActivity.test.ts
index ca1638b7fbe..6a31998b7a5 100644
--- a/apps/mobile/src/lib/threadActivity.test.ts
+++ b/apps/mobile/src/lib/threadActivity.test.ts
@@ -2430,6 +2430,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",
diff --git a/apps/mobile/src/lib/threadActivity.ts b/apps/mobile/src/lib/threadActivity.ts
index fb8bbe29aaa..1b811bb8171 100644
--- a/apps/mobile/src/lib/threadActivity.ts
+++ b/apps/mobile/src/lib/threadActivity.ts
@@ -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 {
@@ -249,8 +250,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);
}
export function workEntryRowLabel(entry: WorkLogPresentationEntry, expanded = false): string {
@@ -289,7 +297,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;
}
@@ -862,7 +870,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 {