windows: the dark theme's off and disabled controls readable; upgrades with tunnels up

Dark theme: a switch that is off has a lighter track (#737373, was #404040
under a near-black thumb), radio buttons, checkboxes and text fields a
lighter edge (#525252); a disabled button's text is the muted colour itself
rather than half of it (widgets::Inactive). The title bar is set again a
moment after Windows' appearance changes, as GPUI resets it to Windows' own.

Upgrades: a running system-wide AmneziaWG tunnel is stopped while the
release's newer amneziawg replaces bin\amneziawg, and started again;
WinDivert's driver is let go of before zapret or zapret2 is replaced. The
fetched setup program goes once the update it brought is running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 5.5 committed 2026-10-27 22:39:10 +03:00
1 parent 5bd47f7676
commit d33f05c62c
19 files changed
+101 -21

No files matched your search

+1
View File
@@ -48,6 +48,7 @@ fn main() {
gpui_kit::application().with_assets(assets::AppAssets).with_quit_mode(QuitMode::Explicit).run(move |cx| {
gpui_kit::init(cx);
cx.set_global(prefs::load());
prefs::tune_dark(cx);
prefs::apply_theme(None, cx);
let model = cx.new(|cx| model::Model::new(bridge, cx));
shell::start(model, !args.hidden, cx);
+13
View File
@@ -4,6 +4,7 @@
//! In `%APPDATA%\ProxySuite\app.json` (elsewhere `$XDG_CONFIG_HOME/proxy-suite/app.json`).
use std::path::PathBuf;
use std::rc::Rc;
use gpui_kit::component::{Theme, ThemeMode};
use gpui_kit::*;
@@ -76,6 +77,18 @@ pub fn change(cx: &mut App, edit: impl FnOnce(&mut Prefs)) {
cx.refresh_windows();
}
/// Controls that are off all but vanish on the dark theme's near-black page: its switch, a
/// near-black thumb on a #404040 track, gets a lighter track (the thumb stays dark: it is the
/// on switch's too, on a white track); unchecked radio buttons and checkboxes, and text
/// fields, a lighter edge than #2f2f2f.
pub fn tune_dark(cx: &mut App) {
let theme = Theme::global_mut(cx);
let mut dark = (*theme.dark_theme).clone();
dark.colors.switch = Some("#737373".into());
dark.colors.input = Some("#525252".into());
theme.dark_theme = Rc::new(dark);
}
/// The theme the preference picks: Windows' appearance (the window's, when there is one), or
/// the one chosen.
pub fn apply_theme(window: Option<&mut Window>, cx: &mut App) {
+3 -3
View File
@@ -16,7 +16,7 @@ use ps_client::edits;
use ps_ipc::Request;
use serde_json::{Value, json};
use super::widgets::{card, hint, page};
use super::widgets::{card, hint, page, Inactive as _};
use crate::model::Model;
pub struct AutoProxyPage {
@@ -218,10 +218,10 @@ impl Render for AutoProxyPage {
.small()
.icon(IconName::Gauge)
.label(if probing { "Probing…" } else { "Probe" })
.disabled(probing || !running)
.inactive(probing || !running, cx)
.on_click(cx.listener(|this, _, window, cx| this.probe(window, cx))),
)
.child(Button::new("ap-learn").small().primary().icon(IconName::Plus).label("Learn").disabled(!running).on_click(cx.listener(|this, _, window, cx| this.learn(window, cx)))),
.child(Button::new("ap-learn").small().primary().icon(IconName::Plus).label("Learn").inactive(!running, cx).on_click(cx.listener(|this, _, window, cx| this.learn(window, cx)))),
);
match &self.probe {
Some(Ok(p)) => {
+2 -2
View File
@@ -9,7 +9,7 @@ use gpui_kit::*;
use ps_ipc::Request;
use serde_json::Value;
use super::widgets::{card, hint, page};
use super::widgets::{card, hint, page, Inactive as _};
use crate::model::Model;
pub struct ComponentsPage {
@@ -72,7 +72,7 @@ impl Render for ComponentsPage {
.small()
.icon(IconName::Download)
.label(if self.installing { "Installing…" } else { "Fetch all again" })
.disabled(self.installing)
.inactive(self.installing, cx)
.on_click(cx.listener(|this, _, _, cx| this.install(Vec::new(), cx))),
);
let mut list = card("Programs", Some(actions.into_any_element()), cx).child(hint(
+8 -4
View File
@@ -103,11 +103,15 @@ impl AppView {
pub fn new(model: Entity<Model>, window: &mut Window, cx: &mut Context<Self>) -> Self {
let subscriptions = vec![
cx.observe(&model, |_, _, cx| cx.notify()),
// As Windows' appearance changes, when the theme follows it.
// As Windows' appearance changes: the theme, when it follows it; the title bar, which
// GPUI sets to Windows' own just after this, a moment later.
cx.observe_window_appearance(window, |_, window, cx| {
if cx.global::<crate::prefs::Prefs>().theme == crate::prefs::ThemeChoice::System {
crate::prefs::apply_theme(Some(window), cx);
}
crate::prefs::apply_theme(Some(window), cx);
cx.spawn_in(window, async move |_, cx| {
cx.background_executor().timer(std::time::Duration::from_millis(300)).await;
cx.update(|window, cx| crate::prefs::apply_theme(Some(window), cx)).ok();
})
.detach();
}),
cx.subscribe_in(&model, window, |_, _, outcome: &Outcome, window, cx| {
let note = match outcome {
+3 -3
View File
@@ -16,7 +16,7 @@ use ps_client::edits::{self, OutboundSource};
use ps_ipc::Request;
use serde_json::Value;
use super::widgets::{card, hint, page};
use super::widgets::{card, hint, page, Inactive as _};
use crate::model::Model;
const MODES: [(&str, &str); 5] = [
@@ -175,7 +175,7 @@ impl Render for OutboundsPage {
let mut list = card(
format!("Outbounds ({})", tags.len()),
Some(Button::new("test-all").small().icon(IconName::Gauge).label(if self.testing { "Testing…" } else { "Test all" }).disabled(self.testing || tags.is_empty()).on_click(cx.listener(|this, _, _, cx| this.test(Vec::new(), cx))).into_any_element()),
Some(Button::new("test-all").small().icon(IconName::Gauge).label(if self.testing { "Testing…" } else { "Test all" }).inactive(self.testing || tags.is_empty(), cx).on_click(cx.listener(|this, _, _, cx| this.test(Vec::new(), cx))).into_any_element()),
cx,
);
if let Some(Err(e)) = self.delays.get("") {
@@ -205,7 +205,7 @@ impl Render for OutboundsPage {
.small()
.icon(IconName::RefreshCw)
.label("Update all")
.disabled(subs.is_empty())
.inactive(subs.is_empty(), cx)
.on_click(move |_, _, cx| model.update(cx, |m, cx| m.request("Subscriptions updated", Request::SubsUpdate { tag: None }, cx)))
.into_any_element(),
),
+2 -2
View File
@@ -12,7 +12,7 @@ use ps_client::edits;
use serde_json::Value;
use super::AppView;
use super::widgets::{card, fact, hint, page, state_tag};
use super::widgets::{card, fact, hint, page, state_tag, Inactive as _};
use crate::model::{Connection, Model, Update};
fn text(v: &Value) -> SharedString {
@@ -155,7 +155,7 @@ fn updates(model: &Entity<Model>, cx: &mut Context<AppView>) -> Div {
.ghost()
.icon(IconName::RefreshCw)
.label("Check for updates")
.disabled(busy)
.inactive(busy, cx)
.on_click(move |_, _, cx| model.update(cx, |m, cx| m.check_update(cx)))
};
let card = card(format!("Proxy Suite {}", m.version()), Some(check.into_any_element()), cx);
+2 -2
View File
@@ -14,7 +14,7 @@ use ps_client::Issue;
use ps_ipc::Request;
use serde_json::Value;
use super::widgets::{card, hint, page};
use super::widgets::{card, hint, page, Inactive as _};
use crate::model::Model;
use crate::prefs::{self, Prefs, ThemeChoice};
@@ -189,7 +189,7 @@ impl Render for SettingsPage {
.gap_2()
.child(Button::new("cfg-reload").small().ghost().icon(IconName::RefreshCw).label("Reload").on_click(cx.listener(|this, _, window, cx| this.reload(window, cx))))
.child(Button::new("cfg-validate").small().label("Check").on_click(cx.listener(|this, _, _, cx| this.validate(cx))))
.child(Button::new("cfg-save").small().primary().icon(IconName::Save).label("Save").disabled(!changed).on_click(cx.listener(|this, _, _, cx| this.save(cx))));
.child(Button::new("cfg-save").small().primary().icon(IconName::Save).label("Save").inactive(!changed, cx).on_click(cx.listener(|this, _, _, cx| this.save(cx))));
let verdict = match &self.verdict {
Verdict::None => div(),
+16
View File
@@ -1,6 +1,8 @@
//! Pieces the pages share: the page frame, cards, a unit's state as a tag.
use gpui_kit::component::button::Button;
use gpui_kit::component::tag::Tag;
use gpui_kit::prelude::FluentBuilder as _;
use gpui_kit::assets::IconName;
use gpui_kit::component::*;
use gpui_kit::*;
@@ -48,3 +50,17 @@ pub fn hint(text: impl Into<SharedString>, cx: &App) -> Div {
pub fn fact(label: &'static str, value: impl Into<SharedString>, cx: &App) -> Div {
div().h_flex().gap_2().text_sm().child(div().w(px(110.)).text_color(cx.theme().muted_foreground).child(label)).child(value.into())
}
/// A button that cannot be pressed now. gpui-component draws a disabled button's text at half
/// the muted colour, which the dark theme all but hides: here at the muted colour itself (a
/// button's own style is laid over its disabled state's), still plainly dimmer than an active
/// button's.
pub trait Inactive: Sized {
fn inactive(self, disabled: bool, cx: &App) -> Self;
}
impl Inactive for Button {
fn inactive(self, disabled: bool, cx: &App) -> Self {
self.disabled(disabled).when(disabled, |b| b.text_color(cx.theme().muted_foreground))
}
}
+15
View File
@@ -293,6 +293,21 @@ pub fn state(_iface: &str) -> String {
"windows-only".into()
}
/// The tunnels this suite registered that run, stopped: their interface names.
pub fn stop_running(paths: &Paths) -> Vec<String> {
registered(paths)
.into_iter()
.filter(|iface| state(iface) == "active")
.filter(|iface| match stop(iface) {
Ok(()) => true,
Err(e) => {
tracing::warn!("stopping the AmneziaWG tunnel {iface}: {e:#}");
false
}
})
.collect()
}
/// Every tunnel this suite registered, stopped and deleted: on uninstall.
#[cfg_attr(not(windows), allow(dead_code))]
pub fn remove_all(paths: &Paths) {
+9 -4
View File
@@ -256,15 +256,20 @@ fn verify_all(dir: &Path) -> Result<()> {
/// Copies each component of `from` (the release's) into `bin` when `bin` lacks it or holds
/// another version: staged, verified file by file, swapped in. What it did, as lines.
/// Whether `seed` replaces `name` in `bin`: the release has the version the manifest wants,
/// and `bin` another (or none).
pub fn seeds(from: &Path, bin: &Path, name: &str) -> bool {
let manifest = ps_core::components::manifest();
let Some(comp) = manifest.components.get(name) else { return false };
installed_version(from, name).as_deref() == Some(comp.version.as_str()) && installed_version(bin, name).as_deref() != Some(comp.version.as_str())
}
pub fn seed(from: &Path, bin: &Path) -> Vec<String> {
let manifest = ps_core::components::manifest();
let mut notes = Vec::new();
for (name, comp) in &manifest.components {
let src = from.join(name);
if installed_version(from, name).as_deref() != Some(comp.version.as_str()) {
continue;
}
if installed_version(bin, name).as_deref() == Some(comp.version.as_str()) {
if !seeds(from, bin, name) {
continue;
}
let staging = bin.join(format!("{name}.staging"));
+13
View File
@@ -89,9 +89,22 @@ pub async fn run(
paths.create_all().with_context(|| format!("creating {}", paths.root.display()))?;
// The components the release carries, next to the program, into bin\ when they are newer.
if let Some(dir) = install::bundled_components_dir() {
// What runs from bin\ outside this service holds its files: a system-wide AmneziaWG
// tunnel (stopped while its program is replaced, started again after), WinDivert's
// driver (left loaded by a zapret stopped hard).
let tunnels = if install::seeds(&dir, &paths.bin(), "amneziawg") { awgvpn::stop_running(&paths) } else { Vec::new() };
#[cfg(windows)]
if ["zapret", "zapret2"].iter().any(|n| install::seeds(&dir, &paths.bin(), n)) {
winsvc::release_windivert();
}
for note in install::seed(&dir, &paths.bin()) {
tracing::info!("{note}");
}
for iface in tunnels {
if let Err(e) = awgvpn::start(&iface) {
tracing::warn!("the AmneziaWG tunnel {iface} did not start again: {e:#}");
}
}
}
let svc = service::Service::new(paths.clone()).with_context(|| format!("opening {}", paths.root.display()))?;
let interactive = svc.cfg().user_control.enable;
+7 -1
View File
@@ -194,7 +194,9 @@ fn published_sum(text: &[u8]) -> Result<String> {
}
}
/// The release's setup program in `dir` (older ones gone), once its SHA-256 matches.
/// The release's setup program in `dir` (older ones gone), once its SHA-256 matches. `dir` is
/// under the state root, whose protected DACL (SYSTEM and Administrators only, inherited)
/// keeps anyone else from replacing the file between this check and its run as SYSTEM.
async fn download(release: &Release, routes: &[Route], dir: &Path) -> Result<PathBuf> {
let sum = first(routes, |r| {
let url = release.checksum.clone();
@@ -295,6 +297,10 @@ pub fn report(dir: &Path) {
let _ = std::fs::remove_file(&path);
if wanted.trim() == env!("CARGO_PKG_VERSION") {
tracing::info!("updated to {}", env!("CARGO_PKG_VERSION"));
// Done with: ~80 MB.
for e in std::fs::read_dir(dir).into_iter().flatten().flatten() {
let _ = std::fs::remove_file(e.path());
}
} else {
tracing::warn!("the update to {} did not finish; this is still {}", wanted.trim(), env!("CARGO_PKG_VERSION"));
}
+7
View File
@@ -196,6 +196,13 @@ pub fn uninstall() -> Result<()> {
Ok(())
}
/// WinDivert's driver, if this suite's is still loaded: its files are about to be replaced.
pub fn release_windivert() {
if let Ok(manager) = ServiceManager::local_computer(None::<&str>, ServiceManagerAccess::CONNECT) {
remove_windivert(&manager);
}
}
/// The WinDivert driver zapret loaded from this suite's components, if it is still registered
/// (WinDivert removes its own service as it loads, but one stopped hard can stay): stopped and
/// deleted, as Flowseal's service.bat removes it. One from elsewhere is left alone.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB