Default diffs to working changes (#3974)

Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
Jake LeventhalandJulius Marminge authored and GitHub committed 2026-07-18 13:17:30 +02:00
1 parent 765e1b5fc0
commit 38e0bb07bb
4 files changed
+47 -9

No files matched your search

+6 -1
View File
@@ -11,6 +11,7 @@ export type DiffPanelSelection =
| { kind: "turn"; turnId: TurnId; filePath: string | null; revealRequestId: number };
const DEFAULT_SELECTION: DiffPanelSelection = { kind: "branch", baseRef: null };
const DEFAULT_WORKING_TREE_SELECTION: DiffPanelSelection = { kind: "unstaged" };
interface DiffPanelStoreState {
byThreadKey: Record<string, DiffPanelSelection>;
@@ -133,7 +134,11 @@ export const useDiffPanelStore = create<DiffPanelStoreState>()(
export function selectThreadDiffPanelSelection(
byThreadKey: Record<string, DiffPanelSelection>,
ref: ScopedThreadRef | null | undefined,
hasWorkingTreeChanges = false,
): DiffPanelSelection {
if (!ref) return DEFAULT_SELECTION;
return byThreadKey[scopedThreadKey(ref)] ?? DEFAULT_SELECTION;
return (
byThreadKey[scopedThreadKey(ref)] ??
(hasWorkingTreeChanges ? DEFAULT_WORKING_TREE_SELECTION : DEFAULT_SELECTION)
);
}