Commit Graph
3419 Commits
Author SHA1 Message Date
Slinetrac e582cf4a65 tmp 2025-10-27 15:46:34 +08:00
Slinetrac 9a3598513b feat(profile-switch): unify post-switch cleanup handling
- workflow.rs (25-427) returns `SwitchWorkflowResult` (success + CleanupHandle) or `SwitchWorkflowError`.
  All failure/timeout paths stash post-switch work into a single CleanupHandle.
  Cleanup helpers (`notify_profile_switch_finished` and `close_connections_after_switch`) run inside that task for proper lifetime handling.

- driver.rs (29-439) propagates CleanupHandle through `SwitchJobOutcome`, spawns a bridge to wait for completion, and blocks `start_next_job` until done.
  Direct driver-side panics now schedule failure cleanup via the shared helper.
2025-10-27 13:53:03 +08:00
Slinetrac f1bc704e16 feat(profile-switch): track cleanup and coordinate pipeline
- Add explicit cleanup tracking in the driver (`cleanup_profiles` map + `CleanupDone` messages) to know when background post-switch work is still running before starting a new workflow. (driver.rs:29-50)
- Update `handle_enqueue` to detect “cleanup in progress”: same-profile retries are short-circuited; other requests collapse the pending queue, cancelling old tokens so only the latest intent survives. (driver.rs:176-247)
- Rework scheduling helpers: `start_next_job` refuses to start while cleanup is outstanding; discarded requests release cancellation tokens; cleanup completion explicitly restarts the pipeline. (driver.rs:258-442)
2025-10-27 13:41:23 +08:00
Slinetrac f88e848452 refactor(profile-switch): async post-switch tasks, early lock release, and spawn_blocking for IO 2025-10-27 11:53:31 +08:00
Slinetrac 9ab80cd7a4 refactor(profile-switch): add watchdog, heartbeat, and async timeout guards
- Introduce SwitchHeartbeat for stage tracking and timing; log stage transitions with elapsed durations.
- Add watchdog in driver to cancel stalled switches (5s heartbeat timeout).
- Wrap blocking ops (Config::apply, tray updates, profiles_save_file_safe, etc.) with time::timeout to prevent async stalls.
- Improve logs for stage transitions and watchdog timeouts to clarify cancellation points.
2025-10-27 10:58:07 +08:00
Slinetrac b3e234e9cc refactor(profile-switch): integrate stage-aware panic handling
- src-tauri/src/cmd/profile_switch/workflow/state_machine.rs:1
  Defines SwitchStage and SwitchPanicInfo as crate-visible, wraps each transition in with_stage(...) with catch_unwind, and propagates CmdResult<bool> to distinguish validation failures from panics while keeping cancellation semantics.

- src-tauri/src/cmd/profile_switch/workflow.rs:25
  Updates run_switch_job to return Result<bool, SwitchPanicInfo>, routing timeout, validation, config, and stage panic cases separately. Reuses SwitchPanicInfo for logging/UI notifications; patch_profiles_config maps state-machine panics into user-facing error strings.

- src-tauri/src/cmd/profile_switch/driver.rs:1
  Adds SwitchJobOutcome to unify workflow results: normal completions carry bool, and panics propagate SwitchPanicInfo. The driver loop now logs panics explicitly and uses AssertUnwindSafe(...).catch_unwind() to guard setup-phase panics.
2025-10-27 10:03:12 +08:00
Slinetrac 9de5866efa feat(profile_switch): integrate explicit state machine for profile switching
- workflow.rs:24 now delegates each switch to SwitchStateMachine, passing an owned SwitchRequest.
  Queue cancellation and state-sequence checks are centralized inside the machine instead of scattered guards.
- workflow.rs:176 replaces the old helper with `SwitchStateMachine::new(manager(), None, profiles).run().await`,
  ensuring manual profile patches follow the same workflow (locking, validation, rollback) as queued switches.
- workflow.rs:180 & 275 expose `validate_profile_yaml` and `restore_previous_profile` for reuse inside the state machine.

- workflow/state_machine.rs:1 introduces a dedicated state machine module.
  It manages global mutex acquisition, request/cancellation state, YAML validation, draft patching,
  `CoreManager::update_config`, failure rollback, and tray/notification side-effects.
  Transitions check for cancellations and stale sequences; completions release guards via `SwitchScope` drop.
2025-10-26 23:58:43 +08:00
Slinetrac f90a8a4534 refactor(profile_switch): centralize state management and add cancellation flow
- Introduced SwitchManager in state.rs to unify mutex, sequencing, and SwitchScope handling.
- Added SwitchCancellation and SwitchRequest wrappers to encapsulate cancel tokens and notifications.
- Updated driver to allocate task IDs via SwitchManager, cancel old tokens, and queue next jobs in order.
- Updated workflow to check cancellation and sequence at each phase, replacing global flags with manager APIs.
2025-10-26 23:02:26 +08:00
Slinetrac 32ff1b759f refactor(profile_switch): modularize switch handler
- Break monolithic switch handler into proper module hierarchy
- Move shared globals, constants, and SwitchScope guard to state.rs
- Isolate queue orchestration and async task spawning in driver.rs
- Consolidate switch pipeline and config patching in workflow.rs
- Extract request pre-checks/YAML validation into validation.rs
2025-10-26 21:01:51 +08:00
Slinetrac 14eb733f51 refactor(profile): modularize switch logic into profile_switch.rs 2025-10-26 20:12:17 +08:00
Slinetrac 59f4dbe16d refactor(cmd): move switch-validation helper into new profile_switch module 2025-10-26 17:39:30 +08:00
Slinetrac fb7250cc6b refactor(profile): make switch driver fully async and handle panics safely 2025-10-26 16:06:50 +08:00
Slinetrac fc10fff920 fix(profile): unify error string types in validation helper 2025-10-26 15:40:46 +08:00
Slinetrac ceec922887 refactor: migrate backend queue to SwitchDriver actor 2025-10-26 15:04:03 +08:00
Slinetrac de35fef450 chore: translate comments and log messages to English to avoid encoding issues 2025-10-26 13:39:00 +08:00
Slinetrac bf61f3828c feat(profiles): centralize profile switching with reducer/driver queue to fix stuck UI on rapid toggles 2025-10-26 12:40:37 +08:00
Slinetrac a889d0b1e5 refactor(profile-switch): serialize switches with async queue and enrich frontend events 2025-10-26 11:53:15 +08:00
Slinetrac 49926b4823 refactor: hooked up a backend-driven profile switch flow 2025-10-25 15:06:46 +08:00
Slinetrac cc39dcdc09 refactor:introduce a profile switch worker 2025-10-25 10:55:09 +08:00
Slinetrac 1beeb3f804 refactor:replace state machine with reducer 2025-10-25 10:35:35 +08:00
Slinetrac b627da32ac Merge branch 'dev' into refactor/proxy-refresh 2025-10-25 10:05:48 +08:00
Slinetrac 0867c713f7 refactor(profiles): introduce a state machine 2025-10-25 10:04:19 +08:00
renovate[bot]andrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com> ed9eed226d chore(deps): update npm dependencies (#5198)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-25 09:59:54 +08:00
Slinetrac f79c2bfdff fix(proxy-groups): restrict reduced-height viewport to chain-mode column 2025-10-24 21:57:01 +08:00
Slinetrac 89d7c7c3e5 fix(proxy): merge static and provider entries in snapshot; fix Virtuoso viewport height 2025-10-24 21:48:54 +08:00
Slinetrac ead312090d fix(proxy-snapshot, proxy-groups): restore last-selected proxy and group info 2025-10-24 21:32:34 +08:00
Slinetrac 547cf89190 docs: UPDATELOG.md 2025-10-24 20:59:33 +08:00
Slinetrac 760956786f fix(proxy-store): tweak fetch sequencing guard to prevent snapshot invalidation from wiping fast responses 2025-10-24 20:40:56 +08:00
Slinetrac 35c7d01cd0 fix(proxy-store): add monotonic fetch guard and event bridge cleanup 2025-10-24 20:25:06 +08:00
Slinetrac f4022e612e fix(proxy-store): properly hydrate and filter backend provider snapshots 2025-10-24 20:01:41 +08:00
Slinetrac 65076c801a refactor: proxy refresh 2025-10-24 19:46:11 +08:00
renovate[bot]andrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com> 806769b307 chore(deps): update npm dependencies (#5185)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-24 09:55:18 +08:00
Tunglies d291fc5c64 chore(dependencies): update clash_verge_logger source to specific commit 2025-10-24 00:08:10 +08:00
Tunglies bf45e487f9 feat(tauri-plugin-mihomo): configure IPC pool settings with connection limits and health checks 2025-10-23 22:32:23 +08:00
Tunglies 99ef0e51fc feat(init_logger): improve log level retrieval from environment variable 2025-10-23 22:13:43 +08:00
oomeow cc2dc66d5f chore: update tauri-plugin-mihomo dep 2025-10-23 20:45:34 +08:00
renovate[bot]andrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com> 001c11913a chore(deps): update dependency vite to ^7.1.12 (#5180)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-23 16:25:38 +08:00
Tunglies f061bce2a1 refactor(window_manager): simplify window state handling and improve method organization 2025-10-23 16:21:51 +08:00
oomeowandTunglies d7859b07a6 fix: parse hotkey (#5167)
* fix: incorrectly parse hotkey

* refactor: parse hotkey

* fix: panic on linux

* chore: update

* chore: update style

* fix: register hotkey error on windows

* chore: update style

---------

Co-authored-by: Tunglies <tunglies.dev@outlook.com>
2025-10-23 15:54:48 +08:00
renovate[bot]andrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com> 585963e751 chore(deps): update dependency lint-staged to ^16.2.6 (#5175)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-23 13:18:51 +08:00
renovate[bot]andrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com> d84b762ef3 chore(deps): update dependency vitest to v4 (#5176)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-23 13:18:30 +08:00
Sline 8657cedca0 feat: add configurable hover jump navigator delay (#5178)
* fix: hover options

* feat: add configurable hover jump navigator delay

- Added `hover_jump_navigator_delay` to Verge config defaults, patch flow, and response payload for persistent app-wide settings.
- Made proxy navigator respect configurable delay via `DEFAULT_HOVER_DELAY` and new `hoverDelay` prop.
- Threaded stored delay through proxy list so hover scrolling uses Verge-configured value.
- Added "Hover Jump Navigator Delay" control in Layout settings with clamped numeric input, tooltip, and toggle-aware disabling.
- Localized new labels in English, Simplified Chinese, and Traditional Chinese.
- Extended frontend Verge config type to include delay field for type-safe access.

* docs: UPDATELOG.md
2025-10-23 13:14:01 +08:00
Tunglies 9ea9704bbf refactor(sysopt): replace Arc<TokioMutex> with AtomicBool for sysproxy state management 2025-10-23 00:53:57 +08:00
renovate[bot]andrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com> 302677aed0 chore(deps): update dependency react-i18next to v16.1.5 (#5171)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-22 22:01:37 +08:00
renovate[bot]andrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com> 1415df1d23 chore(deps): update cargo dependencies (#5169)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-22 21:59:53 +08:00
renovate[bot]andrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com> b7d2bc7c74 chore(deps): update dependency @tauri-apps/cli to v2.9.1 (#5170)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-22 21:59:31 +08:00
Sline 4f7d069f19 feat(ui): add left menu lock/unlock with reorder mode and context menu (#5168)
* feat: free menu

* feat(ui): add left menu lock/unlock with reorder mode and context menu

* docs: UPDATELOG.md
2025-10-22 21:39:12 +08:00
Sline 3bedf7ec35 feat(backup): add dns_config into backup (#5166) 2025-10-22 19:52:44 +08:00
Sline c4c37bf291 feat(tray): close all connections (#5165) 2025-10-22 19:28:00 +08:00
Tunglies 815a865265 perf(tray): ignore unnecessary tray icon events to reduce refreshes 2025-10-22 18:49:28 +08:00