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.
Fix reopening existing Diff tab (#3973)
Jake Leventhal31caa5652b0d
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsxindex 69292e7e6..8d39c6b69 100644--- a/apps/web/src/components/ChatView.tsx+++ b/apps/web/src/components/ChatView.tsx@@ -2916,9 +2916,19 @@ function ChatViewContent(props: ChatViewProps) {}, [activeThreadRef, openPreview]);const addDiffSurface = useCallback(() => {if (!activeThreadRef || !isServerThread || !isGitRepo) return;+ if (planSidebarOpen) {+ dismissPlanSidebarForCurrentTurn();+ }useRightPanelStore.getState().open(activeThreadRef, "diff");onDiffPanelOpen?.();- }, [activeThreadRef, isGitRepo, isServerThread, onDiffPanelOpen]);+ }, [+ activeThreadRef,+ dismissPlanSidebarForCurrentTurn,+ isGitRepo,+ isServerThread,+ onDiffPanelOpen,+ planSidebarOpen,+ ]);const addFilesSurface = useCallback(() => {if (!activeThreadRef || !activeProject) return;useRightPanelStore.getState().open(activeThreadRef, "files");diff --git a/apps/web/src/rightPanelStore.test.ts b/apps/web/src/rightPanelStore.test.tsindex b48f6e7eb..c7457cfd3 100644--- a/apps/web/src/rightPanelStore.test.ts+++ b/apps/web/src/rightPanelStore.test.ts@@ -117,6 +117,21 @@ describe("rightPanelStore", () => {).toHaveLength(2);});+ it("reopening an inactive singleton activates its existing surface", () => {+ useRightPanelStore.getState().open(refA, "diff");+ useRightPanelStore.getState().open(refA, "plan");+ useRightPanelStore.getState().open(refA, "diff");++ expect(selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA)).toEqual({+ isOpen: true,+ activeSurfaceId: "diff",+ surfaces: [+ { id: "diff", kind: "diff" },+ { id: "plan", kind: "plan" },+ ],+ });+ });+it("keeps files as a singleton surface", () => {useRightPanelStore.getState().open(refA, "files");useRightPanelStore.getState().open(refA, "files");