From b2f23d318dd8145373fdfee2e4788552b5069792 Mon Sep 17 00:00:00 2001 From: Jordon Date: Fri, 8 May 2026 07:47:28 +0100 Subject: [PATCH 1/3] Fixed issue --- Frontend/src/modals/settings.html | 8 ----- .../src/scripts/features/newBranch.test.ts | 36 +++++++++++++++++++ Frontend/src/scripts/features/settings.ts | 2 -- .../scripts/features/settingsGeneral.test.ts | 5 --- .../src/scripts/features/settingsGeneral.ts | 3 -- docs/Features.md | 2 +- 6 files changed, 37 insertions(+), 19 deletions(-) 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..9af0626 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: () => {} }; @@ -63,4 +68,35 @@ describe('wireNewBranch', () => { const checkout = document.getElementById('new-branch-checkout') as HTMLInputElement; expect(checkout.checked).toBe(false); }); + + it('passes the checkout choice to branch creation', async () => { + const invoke = vi.fn(async (cmd: string) => { + if (cmd === 'get_global_settings') { + return { general: { checkout_new_branch: true } }; + } + return 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/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/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 From f88fc419fa9db31e7375a52a0ba75c62a08e92c4 Mon Sep 17 00:00:00 2001 From: Jordon Date: Fri, 8 May 2026 08:05:08 +0100 Subject: [PATCH 2/3] Removed old setting --- Backend/src/settings.rs | 18 ----------------- .../src/scripts/features/newBranch.test.ts | 20 ++++++------------- Frontend/src/scripts/features/newBranch.ts | 10 ++-------- Frontend/src/scripts/types.d.ts | 1 - 4 files changed, 8 insertions(+), 41 deletions(-) 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/scripts/features/newBranch.test.ts b/Frontend/src/scripts/features/newBranch.test.ts index 9af0626..bd2e5f4 100644 --- a/Frontend/src/scripts/features/newBranch.test.ts +++ b/Frontend/src/scripts/features/newBranch.test.ts @@ -26,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; }), }, @@ -58,24 +55,19 @@ 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 (cmd: string) => { - if (cmd === 'get_global_settings') { - return { general: { checkout_new_branch: true } }; - } - return null; - }); + const invoke = vi.fn(async () => null); (window as any).__TAURI__ = { core: { invoke }, event: { listen: vi.fn() }, diff --git a/Frontend/src/scripts/features/newBranch.ts b/Frontend/src/scripts/features/newBranch.ts index 4286d37..8417cd0 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. */ +/** Applies the default checkout choice to the create-branch form. */ async 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/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; From 493f86968c96535937c4f0fe7e55e37519d15f66 Mon Sep 17 00:00:00 2001 From: Jordon Date: Fri, 8 May 2026 08:45:10 +0100 Subject: [PATCH 3/3] Update newBranch.ts --- Frontend/src/scripts/features/newBranch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Frontend/src/scripts/features/newBranch.ts b/Frontend/src/scripts/features/newBranch.ts index 8417cd0..f3e01fa 100644 --- a/Frontend/src/scripts/features/newBranch.ts +++ b/Frontend/src/scripts/features/newBranch.ts @@ -55,7 +55,7 @@ function populateBaseSelect(modal: HTMLElement) { } /** Applies the default checkout choice to the create-branch form. */ -async function loadCheckoutDefault(modal: HTMLElement) { +function loadCheckoutDefault(modal: HTMLElement) { const checkoutEl = modal.querySelector('#new-branch-checkout'); if (!checkoutEl) return; checkoutEl.checked = true;