From 57dd1ada569735740ee0210af578e109e5098a07 Mon Sep 17 00:00:00 2001 From: theguy000 Date: Wed, 18 Mar 2026 07:26:53 +0600 Subject: [PATCH 1/3] refactor(instance-settings): streamline modal state and save flow Streamlined instance settings and fingerprint update flow to reduce state mismatch between UI and backend. --- src-tauri/src/auto_fingerprint.rs | 54 +++++++++++------ src-tauri/src/instances.rs | 8 ++- .../instance/InstanceSettingsModal.svelte | 59 +++++++++++++++++++ src/lib/store.ts | 1 + 4 files changed, 104 insertions(+), 18 deletions(-) diff --git a/src-tauri/src/auto_fingerprint.rs b/src-tauri/src/auto_fingerprint.rs index 66c4f75..24471ca 100644 --- a/src-tauri/src/auto_fingerprint.rs +++ b/src-tauri/src/auto_fingerprint.rs @@ -210,7 +210,11 @@ fn generate_random_voice_subset(target_os: &str) -> Vec { // ── Main generation function ──────────────────────────────────────────────── /// Build a complete CAMOU_CONFIG JSON from a random preset. -pub fn generate_auto_config() -> serde_json::Value { +pub fn generate_auto_config( + change_window_size: bool, + default_outer_width: Option, + default_outer_height: Option, +) -> serde_json::Value { let presets = fingerprint_presets::get_presets(); let mut rng = rand::thread_rng(); @@ -311,16 +315,26 @@ pub fn generate_auto_config() -> serde_json::Value { // (any value other than 1.0 is suspicious) // ── Derive window dimensions from screen ──────────────────────── - // Browsers don't usually run maximized — pick a random fraction of - // the available screen area to feel realistic. + // Browsers don't usually run maximized. When enabled, vary window + // geometry per launch; otherwise keep deterministic geometry. let avail_w = screen.avail_width.or(screen.width).unwrap_or(1920); let avail_h = screen.avail_height.or(screen.height).unwrap_or(1080); - // Random outer size: 75-100% of available dimensions - let pct_w = rng.gen_range(75..=100) as f64 / 100.0; - let pct_h = rng.gen_range(75..=100) as f64 / 100.0; - let outer_w = ((avail_w as f64 * pct_w) as u32).max(800); - let outer_h = ((avail_h as f64 * pct_h) as u32).max(600); + let (outer_w, outer_h) = if change_window_size { + let pct_w = rng.gen_range(75..=100) as f64 / 100.0; + let pct_h = rng.gen_range(75..=100) as f64 / 100.0; + ( + ((avail_w as f64 * pct_w) as u32).max(800), + ((avail_h as f64 * pct_h) as u32).max(600), + ) + } else if let (Some(w), Some(h)) = (default_outer_width, default_outer_height) { + (w.min(avail_w), h.min(avail_h)) + } else { + ( + ((avail_w as f64 * 0.9) as u32).max(800), + ((avail_h as f64 * 0.9) as u32).max(600), + ) + }; config.insert("window.outerWidth".into(), serde_json::json!(outer_w)); config.insert("window.outerHeight".into(), serde_json::json!(outer_h)); @@ -331,18 +345,24 @@ pub fn generate_auto_config() -> serde_json::Value { config.insert("window.innerWidth".into(), serde_json::json!(inner_w)); config.insert("window.innerHeight".into(), serde_json::json!(inner_h)); - // screenX/screenY: random position within remaining space + // screenX/screenY: random position or centered fallback let max_x = avail_w.saturating_sub(outer_w); let max_y = avail_h.saturating_sub(outer_h); - let screen_x = if max_x > 0 { - rng.gen_range(0..=max_x) as i32 - } else { - 0 - }; - let screen_y = if max_y > 0 { - rng.gen_range(0..=max_y) as i32 + let (screen_x, screen_y) = if change_window_size { + ( + if max_x > 0 { + rng.gen_range(0..=max_x) as i32 + } else { + 0 + }, + if max_y > 0 { + rng.gen_range(0..=max_y) as i32 + } else { + 0 + }, + ) } else { - 0 + ((max_x / 2) as i32, (max_y / 2) as i32) }; config.insert("window.screenX".into(), serde_json::json!(screen_x)); config.insert("window.screenY".into(), serde_json::json!(screen_y)); diff --git a/src-tauri/src/instances.rs b/src-tauri/src/instances.rs index cc3ff6f..85f8648 100644 --- a/src-tauri/src/instances.rs +++ b/src-tauri/src/instances.rs @@ -112,6 +112,7 @@ pub struct FingerprintConfig { // AUTO mode: let camoufox's built-in browserforge handle all fingerprinting pub auto_fingerprint: Option, + pub auto_change_window_size: Option, } /// Convert a FingerprintConfig into a JSON object that camoufox understands @@ -482,7 +483,12 @@ pub async fn launch_instance(app: &AppHandle, id: String) -> Result<(), String> // Build the CAMOU_CONFIG JSON from fingerprint settings let camou_config_json = if let Some(fp) = config.as_ref().and_then(|c| c.fingerprint.as_ref()) { if fp.auto_fingerprint == Some(true) { - crate::auto_fingerprint::generate_auto_config().to_string() + crate::auto_fingerprint::generate_auto_config( + fp.auto_change_window_size.unwrap_or(true), + fp.outer_width, + fp.outer_height, + ) + .to_string() } else { build_camou_config(fp).to_string() } diff --git a/src/lib/components/instance/InstanceSettingsModal.svelte b/src/lib/components/instance/InstanceSettingsModal.svelte index 859c351..6b68818 100644 --- a/src/lib/components/instance/InstanceSettingsModal.svelte +++ b/src/lib/components/instance/InstanceSettingsModal.svelte @@ -20,6 +20,7 @@ import MediaDevicesSection from "./settings/MediaDevicesSection.svelte"; import BehaviorSection from "./settings/BehaviorSection.svelte"; import AdvancedSection from "./settings/AdvancedSection.svelte"; + import { WINDOW_PRESETS } from "./settings/constants"; import { fingerprintPresets } from "$lib/store"; import type { Preset } from "$lib/store"; @@ -47,6 +48,8 @@ // AUTO mode state let autoMode = false; + let autoChangeWindowSize = true; + let autoWindowPresetIndex = -1; const accentGreen = '#10b981'; const accentGreenBg = 'rgba(16, 185, 129, 0.05)'; @@ -62,6 +65,12 @@ globalCategory = instance.fingerprint?.global_category ?? ""; globalPresetIndex = instance.fingerprint?.global_preset_index ?? -1; autoMode = instance.fingerprint?.auto_fingerprint === true; + autoChangeWindowSize = instance.fingerprint?.auto_change_window_size !== false; + autoWindowPresetIndex = WINDOW_PRESETS.findIndex( + (p) => + p.w === instance.fingerprint?.outer_width && + p.h === instance.fingerprint?.outer_height + ); } // ── Save / Reset ─────────────────────────────────────────────────────────── @@ -118,6 +127,19 @@ fp.global_preset_index = globalPresetIndex >= 0 ? globalPresetIndex : null; // Persist AUTO mode settings fp.auto_fingerprint = autoMode || null; + fp.auto_change_window_size = autoMode ? autoChangeWindowSize : null; + if (autoMode && !autoChangeWindowSize && autoWindowPresetIndex >= 0 && WINDOW_PRESETS[autoWindowPresetIndex]) { + const preset = WINDOW_PRESETS[autoWindowPresetIndex]; + fp.outer_width = preset.w; + fp.outer_height = preset.h; + fp.inner_width = null; + fp.inner_height = null; + } else if (autoMode) { + fp.outer_width = null; + fp.outer_height = null; + fp.inner_width = null; + fp.inner_height = null; + } await updateInstanceSettings(instance.id, fp); dispatch("close"); } catch (e) { @@ -135,6 +157,8 @@ globalCategory = ""; globalPresetIndex = -1; autoMode = false; + autoChangeWindowSize = true; + autoWindowPresetIndex = -1; } function handleClose() { dispatch("close"); @@ -190,6 +214,41 @@

Camoufox's built-in browserforge will automatically generate a unique fingerprint on each launch. All fields — navigator, screen, WebGL, fonts, audio, canvas, and more — are handled automatically.

+
+
+ CHANGE WINDOW SIZE EACH LAUNCH + + {autoChangeWindowSize + ? 'Randomizes window size and position every launch.' + : 'Keeps window size and position deterministic for the selected profile.'} + +
+ +
+
+ + + + Applies when window-size changing is OFF. + +
{/if} diff --git a/src/lib/store.ts b/src/lib/store.ts index 681c162..a5a8911 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -107,6 +107,7 @@ export interface FingerprintConfig { // AUTO mode: let camoufox's browserforge handle all fingerprinting auto_fingerprint?: boolean | null; + auto_change_window_size?: boolean | null; } export interface InstanceConfig { From d082f8c08b4e7f7f00c2aa8ab313ae38fa65a378 Mon Sep 17 00:00:00 2001 From: theguy000 Date: Wed, 18 Mar 2026 07:53:32 +0600 Subject: [PATCH 2/3] refactor(instance-settings): simplify auto mode window size logic --- .../instance/InstanceSettingsModal.svelte | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/components/instance/InstanceSettingsModal.svelte b/src/lib/components/instance/InstanceSettingsModal.svelte index 6b68818..200536e 100644 --- a/src/lib/components/instance/InstanceSettingsModal.svelte +++ b/src/lib/components/instance/InstanceSettingsModal.svelte @@ -128,15 +128,15 @@ // Persist AUTO mode settings fp.auto_fingerprint = autoMode || null; fp.auto_change_window_size = autoMode ? autoChangeWindowSize : null; - if (autoMode && !autoChangeWindowSize && autoWindowPresetIndex >= 0 && WINDOW_PRESETS[autoWindowPresetIndex]) { - const preset = WINDOW_PRESETS[autoWindowPresetIndex]; - fp.outer_width = preset.w; - fp.outer_height = preset.h; - fp.inner_width = null; - fp.inner_height = null; - } else if (autoMode) { - fp.outer_width = null; - fp.outer_height = null; + if (autoMode) { + const preset = !autoChangeWindowSize && autoWindowPresetIndex >= 0 ? WINDOW_PRESETS[autoWindowPresetIndex] : null; + if (preset) { + fp.outer_width = preset.w; + fp.outer_height = preset.h; + } else { + fp.outer_width = null; + fp.outer_height = null; + } fp.inner_width = null; fp.inner_height = null; } From be9037b38b3ccec1ea065ab2eece33bcde9a3c5c Mon Sep 17 00:00:00 2001 From: theguy000 Date: Wed, 18 Mar 2026 08:02:42 +0600 Subject: [PATCH 3/3] refactor(instance-settings): update window width to enhance layout --- src-tauri/tauri.conf.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index ca00857..547d476 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -13,7 +13,7 @@ "windows": [ { "title": "Anon", - "width": 800, + "width": 1100, "height": 600 } ],