Showing the changes to apps/web/src/diffPanelStore.ts (1 of 4 files). Show all
Unified · Split
| @@ -11,6 +11,7 @@ export type DiffPanelSelection = · 10 unmodified lines | |||
| 11 | | { kind: "turn"; turnId: TurnId; filePath: string | null; revealRequestId: number }; | 11 | | { kind: "turn"; turnId: TurnId; filePath: string | null; revealRequestId: number }; |
| 12 | 12 | ||
| 13 | const DEFAULT_SELECTION: DiffPanelSelection = { kind: "branch", baseRef: null }; | 13 | const DEFAULT_SELECTION: DiffPanelSelection = { kind: "branch", baseRef: null }; |
| 14 | const DEFAULT_WORKING_TREE_SELECTION: DiffPanelSelection = { kind: "unstaged" }; | ||
| 14 | 15 | ||
| 15 | interface DiffPanelStoreState { | 16 | interface DiffPanelStoreState { |
| 16 | byThreadKey: Record<string, DiffPanelSelection>; | 17 | byThreadKey: Record<string, DiffPanelSelection>; |
| @@ -133,7 +134,11 @@ export const useDiffPanelStore = create<DiffPanelStoreState>()( · 116 unmodified lines | |||
| 133 | export function selectThreadDiffPanelSelection( | 134 | export function selectThreadDiffPanelSelection( |
| 134 | byThreadKey: Record<string, DiffPanelSelection>, | 135 | byThreadKey: Record<string, DiffPanelSelection>, |
| 135 | ref: ScopedThreadRef | null | undefined, | 136 | ref: ScopedThreadRef | null | undefined, |
| 137 | hasWorkingTreeChanges = false, | ||
| 136 | ): DiffPanelSelection { | 138 | ): DiffPanelSelection { |
| 137 | if (!ref) return DEFAULT_SELECTION; | 139 | if (!ref) return DEFAULT_SELECTION; |
| 138 | return byThreadKey[scopedThreadKey(ref)] ?? DEFAULT_SELECTION; | 140 | return ( |
| 141 | byThreadKey[scopedThreadKey(ref)] ?? | ||
| 142 | (hasWorkingTreeChanges ? DEFAULT_WORKING_TREE_SELECTION : DEFAULT_SELECTION) | ||
| 143 | ); | ||
| 139 | } | 144 | } |