refactor(backend): share single-owner drivers for background tasks (#8759)

* docs(backend): define background task ownership

* refactor(backend): give background operations single task owners

* test(backend): remove actor migration regression cases

* docs(changelog): drop backend actor migration entry

* refactor(backend): extract workspace task drivers

* fix(timer): omit profile identifier from panic log

* docs(backend): define workspace crate boundaries

* refactor(lightweight): use the task countdown driver

* refactor(lightweight): name countdown callbacks

* refactor(task): simplify driver startup and coalescing requests

* refactor(core): bind service handoff to the sidecar generation

* refactor(tun): coalesce background run state reconciliation

* refactor(core): own sidecar exit resources in one session

* refactor(core): remove automatic Windows service handoff

* refactor(task): simplify coalescing job signals

* refactor(runstate): keep operation status with service state

* refactor(dns): coalesce background override synchronization

* refactor(sysproxy): own the local guard under its operation lock

* fix(tray): read menu settings at publication

* fix(dns): retain script lock across caller cancellation

* refactor(profiles): own selected node restoration in one task

* refactor(timer): own subscription schedules in the scheduler

* test(timer): remove the added application test

* fix(service): renew provider sync retry budget on refresh
This commit is contained in:
Tunglies
2026-11-29 00:42:52 +00:00
committed by GitHub
parent 9724aa6d4d
commit 929bb6a0a1
37 changed files with 1671 additions and 1291 deletions
+12 -26
View File
@@ -212,22 +212,9 @@ impl Tray {
return Ok(());
};
let verge = Config::verge().await.latest_arc();
let system_proxy = verge.enable_system_proxy.unwrap_or(false);
let tun_mode = verge.enable_tun_mode.unwrap_or(false);
let mode = {
Config::clash()
.await
.latest_arc()
.0
.get("mode")
.map_or("rule", |val| val.as_str().unwrap_or("rule"))
.to_owned()
};
let is_lightweight_mode = is_in_lightweight_mode();
let verge = Config::verge().await;
let fetch_proxy_groups =
include_proxy_groups && verge.tray_proxy_groups_display_mode.as_deref() != Some("disable");
include_proxy_groups && verge.latest_arc().tray_proxy_groups_display_mode.as_deref() != Some("disable");
// TODO: should update tray menu again when it was timeout error
let (proxy_nodes_data, runtime_proxy_groups_order) = if fetch_proxy_groups {
@@ -257,29 +244,28 @@ impl Tray {
(None, None)
};
let verge = if fetch_proxy_groups {
Config::verge().await.latest_arc()
} else {
verge
};
let profiles = Config::profiles().await.latest_arc();
let clash = Config::clash().await;
let profiles = Config::profiles().await;
let (tx, rx) = tokio::sync::oneshot::channel();
let dispatch_handle = app_handle.clone();
app_handle
.run_on_main_thread(move || {
let _ = tx.send((|| -> Result<()> {
let verge = verge.latest_arc();
let clash = clash.latest_arc();
let mode = clash.0.get("mode").and_then(|mode| mode.as_str()).unwrap_or("rule");
let menu = build_tray_menu(
&dispatch_handle,
TrayMenuOptions {
mode: Some(mode.as_str()),
system_proxy_enabled: system_proxy,
tun_mode_enabled: tun_mode,
is_lightweight_mode,
mode: Some(mode),
system_proxy_enabled: verge.enable_system_proxy.unwrap_or(false),
tun_mode_enabled: verge.enable_tun_mode.unwrap_or(false),
is_lightweight_mode: is_in_lightweight_mode(),
include_proxy_groups,
},
&verge,
&profiles,
&profiles.latest_arc(),
runtime_proxy_groups_order,
proxy_nodes_data,
)?;