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

+15 -1
View File
@@ -9,12 +9,26 @@ const THREAD_REF = scopeThreadRef(EnvironmentId.make("environment-1"), ThreadId.
describe("diffPanelStore", () => {
beforeEach(() => useDiffPanelStore.setState({ byThreadKey: {}, branchBaseRefByThreadKey: {} }));
it("defaults each thread to branch changes with automatic base selection", () => {
it("defaults each thread to branch changes when the working tree is clean", () => {
expect(
selectThreadDiffPanelSelection(useDiffPanelStore.getState().byThreadKey, THREAD_REF),
).toEqual({ kind: "branch", baseRef: null });
});
it("defaults each thread to working changes when the working tree is dirty", () => {
expect(
selectThreadDiffPanelSelection(useDiffPanelStore.getState().byThreadKey, THREAD_REF, true),
).toEqual({ kind: "unstaged" });
});
it("preserves an explicit scope selection when the working tree state changes", () => {
useDiffPanelStore.getState().selectGitScope(THREAD_REF, "branch");
expect(
selectThreadDiffPanelSelection(useDiffPanelStore.getState().byThreadKey, THREAD_REF, true),
).toEqual({ kind: "branch", baseRef: null });
});
it("clears incompatible selection fields when changing scopes", () => {
const store = useDiffPanelStore.getState();
store.selectTurn(THREAD_REF, TurnId.make("turn-1"), "src/app.ts");