diff --git a/Backend/src/settings.rs b/Backend/src/settings.rs
index 2e3c64c..1f937c6 100644
--- a/Backend/src/settings.rs
+++ b/Backend/src/settings.rs
@@ -96,9 +96,6 @@ pub struct General {
/// When enabled, commit hooks may not rewrite the user-entered commit summary.
#[serde(default = "default_true")]
pub restrict_commit_summary: bool,
- /// When enabled, new branch creation defaults to checking out the branch.
- #[serde(default = "default_true")]
- pub checkout_new_branch: bool,
}
impl Default for General {
/// Returns default general settings values.
@@ -117,7 +114,6 @@ impl Default for General {
telemetry: false,
crash_reports: true,
restrict_commit_summary: true,
- checkout_new_branch: true,
}
}
}
@@ -847,17 +843,3 @@ impl AppConfig {
self.logging.retain_archives = self.logging.retain_archives.clamp(1, 100);
}
}
-
-#[cfg(test)]
-mod tests {
- use super::{AppConfig, General};
-
- #[test]
- /// Verifies new branch creation checks out by default for existing configs.
- fn checkout_new_branch_defaults_true() {
- assert!(General::default().checkout_new_branch);
-
- let cfg: AppConfig = toml::from_str("schema_version = 1\n[general]\n").expect("config");
- assert!(cfg.general.checkout_new_branch);
- }
-}
diff --git a/Frontend/src/modals/settings.html b/Frontend/src/modals/settings.html
index e9c5a13..199d68f 100644
--- a/Frontend/src/modals/settings.html
+++ b/Frontend/src/modals/settings.html
@@ -105,14 +105,6 @@
Settings
-
-
-
-
diff --git a/Frontend/src/scripts/features/newBranch.test.ts b/Frontend/src/scripts/features/newBranch.test.ts
index de63f1a..bd2e5f4 100644
--- a/Frontend/src/scripts/features/newBranch.test.ts
+++ b/Frontend/src/scripts/features/newBranch.test.ts
@@ -2,6 +2,11 @@
// SPDX-License-Identifier: GPL-3.0-or-later
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+vi.mock('../lib/notify', () => ({ notify: vi.fn() }));
+vi.mock('../ui/modals', () => ({ closeModal: vi.fn() }));
+vi.mock('../plugins', () => ({ runHook: vi.fn(async () => ({ cancelled: false })) }));
+vi.mock('../state/state', () => ({ state: { branch: 'main', branches: [] } }));
+
/** Provides a minimal `matchMedia` test shim used by state imports. */
function createMatchMediaMock(query: string) {
return { matches: false, media: query, addListener: () => {}, removeListener: () => {} };
@@ -21,13 +26,10 @@ function mountNewBranchModal() {
}
/** Installs a mocked Tauri runtime before modules capture it at import time. */
-function installTauriMock(checkoutNewBranch: boolean) {
+function installTauriMock() {
(window as any).__TAURI__ = {
core: {
- invoke: vi.fn(async (cmd: string) => {
- if (cmd === 'get_global_settings') {
- return { general: { checkout_new_branch: checkoutNewBranch } };
- }
+ invoke: vi.fn(async () => {
return null;
}),
},
@@ -53,14 +55,40 @@ afterEach(() => {
});
describe('wireNewBranch', () => {
- it('uses the persisted checkout-new-branch setting as the checkbox default', async () => {
- installTauriMock(false);
+ it('defaults the checkout checkbox to enabled', async () => {
+ installTauriMock();
const { wireNewBranch } = await import('./newBranch');
wireNewBranch();
await flushPromises();
const checkout = document.getElementById('new-branch-checkout') as HTMLInputElement;
- expect(checkout.checked).toBe(false);
+ expect(checkout.checked).toBe(true);
+ });
+
+ it('passes the checkout choice to branch creation', async () => {
+ const invoke = vi.fn(async () => null);
+ (window as any).__TAURI__ = {
+ core: { invoke },
+ event: { listen: vi.fn() },
+ };
+
+ const { wireNewBranch } = await import('./newBranch');
+ wireNewBranch();
+ await flushPromises();
+
+ const name = document.getElementById('new-branch-name') as HTMLInputElement;
+ const checkout = document.getElementById('new-branch-checkout') as HTMLInputElement;
+ const create = document.getElementById('new-branch-create') as HTMLButtonElement;
+
+ name.value = 'feature/test';
+ name.dispatchEvent(new Event('input'));
+ await flushPromises();
+ checkout.checked = false;
+ create.disabled = false;
+ create.click();
+ await flushPromises();
+
+ expect(invoke).toHaveBeenCalledWith('vcs_create_branch', { name: 'feature/test', from: 'main', checkout: false });
});
});
diff --git a/Frontend/src/scripts/features/newBranch.ts b/Frontend/src/scripts/features/newBranch.ts
index 4286d37..f3e01fa 100644
--- a/Frontend/src/scripts/features/newBranch.ts
+++ b/Frontend/src/scripts/features/newBranch.ts
@@ -6,7 +6,6 @@ import { notify } from "../lib/notify";
import { state } from "../state/state";
import { closeModal } from "../ui/modals";
import { runHook } from "../plugins";
-import type { GlobalSettings } from "../types";
function fixBranchName(raw: string): string {
// Keep the user's input intact; only normalize for creation.
@@ -55,16 +54,11 @@ function populateBaseSelect(modal: HTMLElement) {
}
}
-/** Applies the persisted default checkout choice to the create-branch form. */
-async function loadCheckoutDefault(modal: HTMLElement) {
+/** Applies the default checkout choice to the create-branch form. */
+function loadCheckoutDefault(modal: HTMLElement) {
const checkoutEl = modal.querySelector('#new-branch-checkout');
if (!checkoutEl) return;
- try {
- const cfg = await TAURI.invoke('get_global_settings');
- checkoutEl.checked = cfg.general?.checkout_new_branch !== false;
- } catch {
- checkoutEl.checked = true;
- }
+ checkoutEl.checked = true;
}
export function wireNewBranch() {
diff --git a/Frontend/src/scripts/features/settings.ts b/Frontend/src/scripts/features/settings.ts
index 9272b05..1ddcf7d 100644
--- a/Frontend/src/scripts/features/settings.ts
+++ b/Frontend/src/scripts/features/settings.ts
@@ -755,7 +755,6 @@ export function wireSettings() {
telemetry: false,
crash_reports: true,
restrict_commit_summary: true,
- checkout_new_branch: true,
};
cur.diff = { tab_width: 4, ignore_whitespace: 'none', max_file_size_mb: 10, intraline: true, show_binary_placeholders: true, external_diff: {enabled:false,path:'',args:''}, external_merge: {enabled:false,path:'',args:''}, binary_exts: ['png','jpg','dds','uasset'] };
cur.lfs = { enabled: true, concurrency: 4, require_lock_before_edit: false, background_fetch_on_checkout: true };
@@ -912,7 +911,6 @@ export async function loadSettingsIntoForm(root?: HTMLElement) {
const elIn = get('#set-intraline'); if (elIn) elIn.checked = !!cfg.diff?.intraline;
const elBp = get('#set-binary-placeholders'); if (elBp) elBp.checked = !!cfg.diff?.show_binary_placeholders;
const elRestrict = get('#set-restrict-commit-summary'); if (elRestrict) elRestrict.checked = cfg.general?.restrict_commit_summary !== false;
- const elCheckoutNewBranch = get('#set-checkout-new-branch'); if (elCheckoutNewBranch) elCheckoutNewBranch.checked = cfg.general?.checkout_new_branch !== false;
const elMm = get('#set-merge-mode');
const elMp = get('#set-merge-path');
const elMa = get('#set-merge-args');
diff --git a/Frontend/src/scripts/features/settingsGeneral.test.ts b/Frontend/src/scripts/features/settingsGeneral.test.ts
index 26c834b..000fd55 100644
--- a/Frontend/src/scripts/features/settingsGeneral.test.ts
+++ b/Frontend/src/scripts/features/settingsGeneral.test.ts
@@ -18,7 +18,6 @@ describe('collectGeneralSettings', () => {
-
`;
@@ -26,7 +25,6 @@ describe('collectGeneralSettings', () => {
const general = collectGeneralSettings(root, {}, () => 'dark');
expect(general?.crash_reports).toBe(true);
expect(general?.restrict_commit_summary).toBe(true);
- expect(general?.checkout_new_branch).toBe(true);
expect(general?.theme).toBe('system');
});
});
@@ -41,7 +39,6 @@ describe('loadGeneralSettingsIntoForm', () => {
-
`;
@@ -57,7 +54,6 @@ describe('loadGeneralSettingsIntoForm', () => {
checks_on_launch: true,
crash_reports: true,
restrict_commit_summary: true,
- checkout_new_branch: true,
},
},
(value) => String(value ?? ''),
@@ -68,6 +64,5 @@ describe('loadGeneralSettingsIntoForm', () => {
expect(refreshDefaultBackendOptions).toHaveBeenCalledWith(root, expect.any(Object));
expect((root.querySelector('#set-crash-reports') as HTMLInputElement).checked).toBe(true);
expect((root.querySelector('#set-restrict-commit-summary') as HTMLInputElement).checked).toBe(true);
- expect((root.querySelector('#set-checkout-new-branch') as HTMLInputElement).checked).toBe(true);
});
});
diff --git a/Frontend/src/scripts/features/settingsGeneral.ts b/Frontend/src/scripts/features/settingsGeneral.ts
index 695d24a..ec373b1 100644
--- a/Frontend/src/scripts/features/settingsGeneral.ts
+++ b/Frontend/src/scripts/features/settingsGeneral.ts
@@ -27,7 +27,6 @@ export function collectGeneralSettings(
checks_on_launch: !!get('#set-checks-on-launch')?.checked,
crash_reports: !!get('#set-crash-reports')?.checked,
restrict_commit_summary: !!get('#set-restrict-commit-summary')?.checked,
- checkout_new_branch: !!get('#set-checkout-new-branch')?.checked,
};
}
@@ -77,6 +76,4 @@ export async function loadGeneralSettingsIntoForm(
if (elCrash) elCrash.checked = !!cfg.general?.crash_reports;
const elRestrict = get('#set-restrict-commit-summary');
if (elRestrict) elRestrict.checked = cfg.general?.restrict_commit_summary !== false;
- const elCheckoutNewBranch = get('#set-checkout-new-branch');
- if (elCheckoutNewBranch) elCheckoutNewBranch.checked = cfg.general?.checkout_new_branch !== false;
}
diff --git a/Frontend/src/scripts/types.d.ts b/Frontend/src/scripts/types.d.ts
index 8f6878e..80e877c 100644
--- a/Frontend/src/scripts/types.d.ts
+++ b/Frontend/src/scripts/types.d.ts
@@ -73,7 +73,6 @@ export interface GlobalSettings {
telemetry?: boolean;
crash_reports?: boolean;
restrict_commit_summary?: boolean;
- checkout_new_branch?: boolean;
};
git?: {
backend?: string;
diff --git a/docs/Features.md b/docs/Features.md
index ababbf2..9b10c74 100644
--- a/docs/Features.md
+++ b/docs/Features.md
@@ -45,7 +45,7 @@ OpenVCS is plugin-first and VCS-agnostic. Features, themes, UI changes, and VCS
| List local branches | ✅ | Local branch visibility |
| List remote branches | ✅ | Remote branch visibility |
- | Create branch | ✅ | Create from current branch; optional auto-checkout default in Settings; non-current base refs require backend support |
+ | Create branch | ✅ | Create from current branch; optional checkout toggle in the Create Branch dialog; non-current base refs require backend support |
| Checkout branch | ✅ | Switch active branch |
| Rename branch | ✅ | Local branch rename |
| Delete branch | ✅ | Branch cleanup |