Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Scope diff patch cache key by theme

Julius Marminge5ec8c9f79d4a
diff --git a/apps/web/src/components/DiffPanel.tsx b/apps/web/src/components/DiffPanel.tsx
index 7abe27fe8..9120e5b82 100644
--- a/apps/web/src/components/DiffPanel.tsx
+++ b/apps/web/src/components/DiffPanel.tsx
@@ -29,13 +29,19 @@ type RenderablePatch =
reason: string;
};
-function getRenderablePatch(patch: string | undefined): RenderablePatch | null {
+function getRenderablePatch(
+ patch: string | undefined,
+ cacheScope = "diff-panel",
+): RenderablePatch | null {
if (!patch) return null;
const normalizedPatch = patch.trim();
if (normalizedPatch.length === 0) return null;
try {
- const parsedPatches = parsePatchFiles(normalizedPatch, buildPatchCacheKey(normalizedPatch));
+ const parsedPatches = parsePatchFiles(
+ normalizedPatch,
+ buildPatchCacheKey(normalizedPatch, cacheScope),
+ );
const files = parsedPatches.flatMap((parsedPatch) => parsedPatch.files);
if (files.length > 0) {
return { kind: "files", files };
@@ -190,7 +196,10 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
const selectedPatch = selectedTurn ? selectedTurnCheckpointDiff : conversationCheckpointDiff;
const hasResolvedPatch = typeof selectedPatch === "string";
const hasNoNetChanges = hasResolvedPatch && selectedPatch.trim().length === 0;
- const renderablePatch = useMemo(() => getRenderablePatch(selectedPatch), [selectedPatch]);
+ const renderablePatch = useMemo(
+ () => getRenderablePatch(selectedPatch, `diff-panel:${resolvedTheme}`),
+ [resolvedTheme, selectedPatch],
+ );
const renderableFiles = useMemo(() => {
if (!renderablePatch || renderablePatch.kind !== "files") {
return [];
diff --git a/apps/web/src/lib/diffRendering.test.ts b/apps/web/src/lib/diffRendering.test.ts
index 08bc25b69..9fd7045ff 100644
--- a/apps/web/src/lib/diffRendering.test.ts
+++ b/apps/web/src/lib/diffRendering.test.ts
@@ -20,4 +20,12 @@ describe("buildPatchCacheKey", () => {
expect(buildPatchCacheKey(before)).not.toBe(buildPatchCacheKey(after));
});
+
+ it("changes when cache scope changes", () => {
+ const patch = "diff --git a/a.ts b/a.ts\n+console.log('hello')";
+
+ expect(buildPatchCacheKey(patch, "diff-panel:light")).not.toBe(
+ buildPatchCacheKey(patch, "diff-panel:dark"),
+ );
+ });
});