fix(web): persist diff view mode (#5731)

This commit is contained in:
Leonel Rivas authored and GitHub committed 2026-08-08 17:02:51 -04:00
1 parent a20923ce46
commit 89ee692bf0
3 files changed
+36 -3

No files matched your search

+7
View File
@@ -10,12 +10,16 @@ export type DiffPanelSelection =
| { kind: "unstaged" }
| { kind: "turn"; turnId: TurnId; filePath: string | null; revealRequestId: number };
export type DiffRenderMode = "stacked" | "split";
const DEFAULT_SELECTION: DiffPanelSelection = { kind: "branch", baseRef: null };
const DEFAULT_WORKING_TREE_SELECTION: DiffPanelSelection = { kind: "unstaged" };
interface DiffPanelStoreState {
byThreadKey: Record<string, DiffPanelSelection>;
branchBaseRefByThreadKey: Record<string, string | null>;
diffRenderMode: DiffRenderMode;
setDiffRenderMode: (mode: DiffRenderMode) => void;
selectGitScope: (ref: ScopedThreadRef, scope: "branch" | "unstaged") => void;
selectBranchBaseRef: (ref: ScopedThreadRef, baseRef: string | null) => void;
selectTurn: (ref: ScopedThreadRef, turnId: TurnId, filePath?: string) => void;
@@ -33,6 +37,8 @@ export const useDiffPanelStore = create<DiffPanelStoreState>()(
(set) => ({
byThreadKey: {},
branchBaseRefByThreadKey: {},
diffRenderMode: "stacked",
setDiffRenderMode: (diffRenderMode) => set({ diffRenderMode }),
selectGitScope: (ref, scope) =>
set((state) => {
const threadKey = scopedThreadKey(ref);
@@ -126,6 +132,7 @@ export const useDiffPanelStore = create<DiffPanelStoreState>()(
partialize: (state) => ({
byThreadKey: state.byThreadKey,
branchBaseRefByThreadKey: state.branchBaseRefByThreadKey,
diffRenderMode: state.diffRenderMode,
}),
},
),