@devries-cameron20 / t3code Mirror · read-only / commits / 3ef1610079
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 14:30 UTC

fix(web): compaction row says "Compacting for 12s" instead of "after being idle" (#26299)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Oct 27, 2026 at 21:48 UTC 3ef16100796c77567ab8bdfeb05d77565ae02d53
6 files changed +43 -33
apps/mobile/src/lib/threadActivity.test.ts
+1 -1
@@ -280,7 +280,7 @@ it("binds a persisted resume answer only to the next compaction in its run", ()
280 expect(compactRows).toHaveLength(2);
281 expect(labels.get(compactRows[0]!.id)).toEqual({
282 title: "Context compacted after 2h 10m idle",
283 - compacting: "Compacting after 2h 10m idle…",
283 + compacting: "Compacting…",
284 });
285 expect(labels.get(compactRows[1]!.id)).toBeUndefined();
286 }
apps/mobile/src/lib/threadActivity.ts
+1 -1
@@ -359,7 +359,7 @@ export function threadFeedCompactionLabels(feed: ReadonlyArray<ThreadFeedEntry>)
359 ? undefined
360 : {
361 title: `Context compacted after ${age} idle`,
362 - compacting: `Compacting after ${age} idle…`,
362 + compacting: "Compacting…",
363 });
364 if (labels) labelsByEntryId.set(entry.id, labels);
365 pendingResumeAgeByRunId.delete(entry.runId);
apps/web/src/components/chat/MessagesTimeline.logic.test.ts
+11 -7
@@ -472,11 +472,7 @@ describe("deriveMessagesTimelineRows", () => {
472 },
473 "Context automatically compacted before cache expiry",
474 ],
475 - [
476 - "onReturn",
477 - { kind: "working", compacting: "Compacting after being idle…" },
478 - "Context compacted after being idle",
479 - ],
475 + ["onReturn", { kind: "working", compacting: true }, "Context compacted before sending"],
476 [undefined, { kind: "context-compaction", active: true }, undefined],
477 ] as const) {
478 const prompt = compactPrompt(reason);
@@ -629,9 +625,17 @@ describe("deriveMessagesTimelineRows", () => {
625 },
626 };
627 const assistantItem = liveAssistant.item;
628 + // The answer can come long after the turn starts; the row times the compaction itself.
629 + const compactionStartedAt = DateTime.makeUnsafe(fixture.time(65));
630 const compactionAt = (status: "running" | "completed") => ({
631 ...liveAssistant,
634 - item: { ...assistantItem, type: "compaction" as const, status, driver: null },
632 + item: {
633 + ...assistantItem,
634 + type: "compaction" as const,
635 + status,
636 + driver: null,
637 + startedAt: compactionStartedAt,
638 + },
639 });
640 const rowsFor = (status: "running" | "completed", laterCompaction = false) =>
641 deriveMessagesTimelineRows({
@@ -668,7 +672,7 @@ describe("deriveMessagesTimelineRows", () => {
672 return rows.slice(rows.findIndex((row) => row.id.includes("live-user")) + 1);
673 };
674 expect(liveRows("running")).toMatchObject([
671 - { kind: "working", compacting: "Compacting after 1h 5m idle…" },
675 + { kind: "working", compacting: true, createdAt: DateTime.formatIso(compactionStartedAt) },
676 ]);
677 expect(liveRows("completed")).toMatchObject([
678 { kind: "context-compaction", title: "Context compacted after 1h 5m idle" },
apps/web/src/components/chat/MessagesTimeline.logic.ts
+16 -16
@@ -527,7 +527,7 @@ type MessagesTimelineRowContent =
527 id: string;
528 createdAt: string | null;
529 /** A running compaction owns the working row, so its divider appears only once it ends. */
530 - compacting?: string;
530 + compacting?: true;
531 }
532 | {
533 kind: "thinking";
@@ -1569,28 +1569,28 @@ export function deriveMessagesTimelineRows(input: {
1569 activeRunIsCompaction && !compactionRunFinished ? unsettledRunId : null;
1570 // Compacting on return holds back the message the user just sent, so the working row says why
1571 // it is waiting. Any other compaction shows only its live divider, never both.
1572 - const activeCompactionRunId =
1573 - runningCompactionRunId !== null && compactionRuns.get(runningCompactionRunId) === "onReturn"
1574 - ? runningCompactionRunId
1575 - : activeCompactionEntry?.entry.runId != null &&
1576 - resumeCompactionAgeByEntryId.has(activeCompactionEntry.id)
1577 - ? activeCompactionEntry.entry.runId
1578 - : null;
1579 - const compactingLabel = (() => {
1580 - if (activeCompactionRunId === null) return undefined;
1581 - const age = activeCompactionEntry
1582 - ? resumeCompactionAgeByEntryId.get(activeCompactionEntry.id)
1572 + const compactsOnReturn =
1573 + runningCompactionRunId !== null && compactionRuns.get(runningCompactionRunId) === "onReturn";
1574 + // The question is answered mid-turn, so the row times this compaction, not the turn.
1575 + const resumeCompactionEntry =
1576 + activeCompactionEntry?.entry.runId != null &&
1577 + resumeCompactionAgeByEntryId.has(activeCompactionEntry.id)
1578 + ? activeCompactionEntry
1579 : undefined;
1584 - return age ? `Compacting after ${age} idle…` : IDLE_COMPACTING_LABELS.onReturn;
1585 - })();
1580 + const activeCompactionRunId = compactsOnReturn
1581 + ? runningCompactionRunId
1582 + : (resumeCompactionEntry?.entry.runId ?? null);
1583 const appendWorkingRow = () => {
1584 if (compactionOnlyRunFinished) return;
1585 if (runningCompactionRunId !== null && activeCompactionRunId === null) return;
1586 nextRows.push({
1587 kind: "working",
1588 id: "working-indicator-row",
1592 - createdAt: input.activeTurnStartedAt ?? null,
1593 - ...(compactingLabel ? { compacting: compactingLabel } : {}),
1589 + createdAt:
1590 + (compactsOnReturn ? undefined : resumeCompactionEntry?.entry.createdAt) ??
1591 + input.activeTurnStartedAt ??
1592 + null,
1593 + ...(activeCompactionRunId !== null ? { compacting: true as const } : {}),
1594 });
1595 };
1596 let hasActivityRow = false;
apps/web/src/components/chat/TimelineWorkGroupRows.tsx
+12 -6
@@ -271,12 +271,12 @@ const workEntryKey = (entry: TimelineWorkEntry) => entry.id;
271 export function WorkingTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "working" }> }) {
272 const { isCompacting, isPreparingWorktree, backgroundWorktreeSetup } =
273 use(TimelineRowActivityCtx);
274 - const compacting = row.compacting ?? (isCompacting ? "Compacting…" : undefined);
275 - const shimmer = isPreparingWorktree || compacting !== undefined;
274 + const compacting = row.compacting === true || isCompacting;
275 + const shimmer = isPreparingWorktree || compacting;
276 const label = isPreparingWorktree ? (
277 "Setting up worktree…"
278 - ) : compacting !== undefined ? (
279 - <CompactingLabel label={compacting} />
278 + ) : compacting ? (
279 + <CompactingLabel createdAt={row.createdAt} />
280 ) : row.createdAt ? (
281 <>
282 Working for <WorkingTimer createdAt={row.createdAt} />
@@ -336,11 +336,17 @@ function BackgroundWorktreeSetupChip({ snapshot }: { snapshot: WorktreeSetupSnap
336 );
337 }
338
339 -function CompactingLabel({ label }: { label: string }) {
339 +function CompactingLabel({ createdAt }: { createdAt: string | null }) {
340 return (
341 <span className="inline-flex items-center gap-1.5">
342 <Minimize2Icon aria-hidden="true" className="size-3" />
343 - {label}
343 + {createdAt ? (
344 + <span>
345 + Compacting for <WorkingTimer createdAt={createdAt} />
346 + </span>
347 + ) : (
348 + "Compacting…"
349 + )}
350 </span>
351 );
352 }
packages/client-runtime/src/userMessage.ts
+2 -2
@@ -9,13 +9,13 @@ import {
9 /** The working row while T3 Code's own compaction runs. */
10 export const IDLE_COMPACTING_LABELS = {
11 beforeCacheExpires: "Compacting before the cache expires…",
12 - onReturn: "Compacting after being idle…",
12 + onReturn: "Compacting…",
13 } satisfies Record<OrchestrationV2IdleCompaction, string>;
14
15 /** Leads the finished compaction's token counts, in place of "Context compacted". */
16 export const IDLE_COMPACTION_TITLES = {
17 beforeCacheExpires: "Context automatically compacted before cache expiry",
18 - onReturn: "Context compacted after being idle",
18 + onReturn: "Context compacted before sending",
19 } satisfies Record<OrchestrationV2IdleCompaction, string>;
20
21 const LEGACY_AUTOMATION_PREFIX = /^\[Triggered by schedule task: [^\r\n]+\]\r?\n\r?\n/;