@devries-cameron20 / t3code Mirror · read-only / commits / abfc5727bf
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 23, 04:15 UTC

fix(web): show a real arrow in the context compacted divider (#20326)

Abdullah Al Zawad committed Oct 19, 2026 at 01:12 UTC abfc5727bf10ac018ef847392699fec3af0b2394
4 files changed +47 -22
apps/web/src/components/chat/MessagesTimeline.logic.test.ts
+2
@@ -1095,6 +1095,7 @@ describe("deriveMessagesTimelineRows", () => {
1095 id: "compaction-entry",
1096 createdAt: "2026-01-01T00:00:00Z",
1097 label: "Compacted context 899K → 19K tokens",
1098 + tokenCounts: null,
1099 active: false,
1100 },
1101 ]);
@@ -1148,6 +1149,7 @@ describe("deriveMessagesTimelineRows", () => {
1149 expect(completedRows.find((row) => row.kind === "context-compaction")).toMatchObject({
1150 active: false,
1151 label: "Context compacted 899K → 19K tokens",
1152 + tokenCounts: { before: "899K", after: "19K" },
1153 });
1154 expect(completedRows.at(-1)?.kind).toBe("thinking");
1155
apps/web/src/components/chat/MessagesTimeline.logic.ts
+5
@@ -20,6 +20,7 @@ import {
20 summarizeToolGroup,
21 toolGroupAction,
22 toolGroupSummaryKind,
23 + contextCompactionTokenCounts,
24 type ToolGroupSummaryKind,
25 } from "@t3tools/client-runtime/work-log/presentation";
26 export {
@@ -554,6 +555,7 @@ type MessagesTimelineRowContent =
555 id: string;
556 createdAt: string;
557 label: string;
558 + tokenCounts: ReturnType<typeof contextCompactionTokenCounts>;
559 active: boolean;
560 }
561 | {
@@ -1562,11 +1564,14 @@ export function deriveMessagesTimelineRows(input: {
1564 ) {
1565 const active = workEntryIsInActiveRun(timelineEntry.entry);
1566 hasActiveCompaction ||= active;
1567 + const compaction = timelineEntry.entry.structuredPayload;
1568 nextRows.push({
1569 kind: "context-compaction",
1570 id: timelineEntry.id,
1571 createdAt: timelineEntry.createdAt,
1572 label: timelineEntry.entry.label,
1573 + tokenCounts:
1574 + compaction?.type === "compaction" ? contextCompactionTokenCounts(compaction) : null,
1575 active,
1576 });
1577 continue;
apps/web/src/components/chat/MessagesTimeline.tsx
+17 -12
@@ -121,6 +121,7 @@ import type { Root, RootContent } from "mdast";
121 import { T3Wordmark } from "../T3Wordmark";
122 import { ThreadContextChip } from "../ThreadContextChip";
123 import {
124 + ArrowRightIcon,
125 BotIcon,
126 BrainIcon,
127 CheckIcon,
@@ -1995,6 +1996,20 @@ function ContextCompactionTimelineRow({
1996 }: {
1997 row: Extract<TimelineRow, { kind: "context-compaction" }>;
1998 }) {
1999 + const content = (
2000 + <span className="flex items-center gap-1.5">
2001 + <Minimize2Icon aria-hidden="true" className="size-3" />
2002 + {row.tokenCounts ? (
2003 + <>
2004 + Context compacted {row.tokenCounts.before}
2005 + <ArrowRightIcon aria-hidden="true" className="size-3" />
2006 + {row.tokenCounts.after} tokens
2007 + </>
2008 + ) : (
2009 + row.label
2010 + )}
2011 + </span>
2012 + );
2013 return (
2014 <div
2015 role="separator"
@@ -2006,18 +2021,8 @@ function ContextCompactionTimelineRow({
2021 ref={row.active ? observeVisibleAnimation : undefined}
2022 className="relative shrink-0 overflow-hidden"
2023 >
2009 - <span className="flex items-center gap-1.5">
2010 - <Minimize2Icon aria-hidden="true" className="size-3" />
2011 - {row.label}
2012 - </span>
2013 - {row.active ? (
2014 - <ActivityShimmerOverlay>
2015 - <span className="flex items-center gap-1.5">
2016 - <Minimize2Icon aria-hidden="true" className="size-3" />
2017 - {row.label}
2018 - </span>
2019 - </ActivityShimmerOverlay>
2020 - ) : null}
2024 + {content}
2025 + {row.active ? <ActivityShimmerOverlay>{content}</ActivityShimmerOverlay> : null}
2026 </span>
2027 <span className="h-px flex-1 bg-border/70" />
2028 </div>
packages/client-runtime/src/work-log/presentation.ts
+23 -10
@@ -48,17 +48,30 @@ export function toolItemForDisplay(item: OrchestrationV2TurnItem): Orchestration
48 }
49 }
50
51 -export function contextCompactionLabel(
52 - item: Pick<
53 - Extract<OrchestrationV2TurnItem, { type: "compaction" }>,
54 - "status" | "beforeTokenCount" | "afterTokenCount"
55 - >,
56 -): string {
57 - if (item.status === "running") return "Compacting context";
58 - if (item.beforeTokenCount !== undefined && item.afterTokenCount !== undefined) {
59 - return `Context compacted ${formatTokens(item.beforeTokenCount)} → ${formatTokens(item.afterTokenCount)} tokens`;
51 +type CompactionLabelItem = Pick<
52 + Extract<OrchestrationV2TurnItem, { type: "compaction" }>,
53 + "status" | "beforeTokenCount" | "afterTokenCount"
54 +>;
55 +
56 +export function contextCompactionTokenCounts(
57 + item: CompactionLabelItem,
58 +): { readonly before: string; readonly after: string } | null {
59 + if (
60 + item.status === "running" ||
61 + item.beforeTokenCount === undefined ||
62 + item.afterTokenCount === undefined
63 + ) {
64 + return null;
65 }
61 - return "Context compacted";
66 + return { before: formatTokens(item.beforeTokenCount), after: formatTokens(item.afterTokenCount) };
67 +}
68 +
69 +export function contextCompactionLabel(item: CompactionLabelItem): string {
70 + if (item.status === "running") return "Compacting context";
71 + const tokens = contextCompactionTokenCounts(item);
72 + return tokens
73 + ? `Context compacted ${tokens.before} → ${tokens.after} tokens`
74 + : "Context compacted";
75 }
76
77 export interface WorkLogPresentationEntry {