@devries-cameron20 / t3code Mirror · read-only / commits / ed866ae148
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, 06:45 UTC

perf(web): useTurnDiffSummaries compiles without manual memoization (#20591)

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

Julius Marminge committed Oct 16, 2026 at 22:03 UTC ed866ae1489b84d5e0a81f49749111b735a66654
1 file changed +5 -12
apps/web/src/hooks/useTurnDiffSummaries.ts
+5 -12
@@ -1,21 +1,14 @@
1 -import { useMemo } from "react";
1 import { deriveThreadCheckpointSummaries } from "@t3tools/client-runtime/state/thread-checkpoints";
2 import type { OrchestrationV2ThreadProjection } from "@t3tools/contracts";
3 import { inferCheckpointTurnCountByRunId } from "../session-logic";
4 import type { TurnDiffSummary } from "../types";
5
6 export function useTurnDiffSummaries(projection: OrchestrationV2ThreadProjection | null) {
8 - const turnDiffSummaries = useMemo<ReadonlyArray<TurnDiffSummary>>(() => {
9 - if (projection === null) {
10 - return [];
11 - }
12 - return deriveThreadCheckpointSummaries(projection);
13 - }, [projection]);
14 -
15 - const inferredCheckpointTurnCountByRunId = useMemo(
16 - () => inferCheckpointTurnCountByRunId(turnDiffSummaries),
17 - [turnDiffSummaries],
18 - );
7 + // No hook calls here, so the compiler only memoizes it when asked.
8 + "use memo";
9 + const turnDiffSummaries: ReadonlyArray<TurnDiffSummary> =
10 + projection === null ? [] : deriveThreadCheckpointSummaries(projection);
11 + const inferredCheckpointTurnCountByRunId = inferCheckpointTurnCountByRunId(turnDiffSummaries);
12
13 return { turnDiffSummaries, inferredCheckpointTurnCountByRunId };
14 }