From a33473a2b5ed8dec7432221490030057259cfec3 Mon Sep 17 00:00:00 2001 From: Divyanshu Dhruv <71079602+divyanshudhruv@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:51:04 +0530 Subject: [PATCH] Windows: the app opens without a terminal and shows its icon --- Cargo.lock | 19 +++++++++++++++++++ crates/athas/Cargo.toml | 3 +++ crates/athas/build.rs | 10 ++++++++++ crates/athas/src/main.rs | 3 +++ 4 files changed, 35 insertions(+) create mode 100644 crates/athas/build.rs diff --git a/Cargo.lock b/Cargo.lock index 7f9c2ca45..40c3e5f5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -646,6 +646,7 @@ dependencies = [ "theme", "ui", "ureq", + "winres", "workbench", "workspace", ] @@ -9282,6 +9283,15 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + [[package]] name = "toml" version = "0.8.23" @@ -11338,6 +11348,15 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "winres" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c" +dependencies = [ + "toml 0.5.11", +] + [[package]] name = "winsafe" version = "0.0.19" diff --git a/crates/athas/Cargo.toml b/crates/athas/Cargo.toml index 1dd7ae322..82f79d516 100644 --- a/crates/athas/Cargo.toml +++ b/crates/athas/Cargo.toml @@ -5,6 +5,9 @@ version.workspace = true license.workspace = true publish.workspace = true +[target.'cfg(windows)'.build-dependencies] +winres = "0.1" + [dependencies] gpui.workspace = true gpui_platform.workspace = true diff --git a/crates/athas/build.rs b/crates/athas/build.rs new file mode 100644 index 000000000..65f397e08 --- /dev/null +++ b/crates/athas/build.rs @@ -0,0 +1,10 @@ +// GPUI loads icon resource 1 from the exe on Windows. +#[cfg(windows)] +fn main() { + let mut res = winres::WindowsResource::new(); + res.set_icon("../../packaging/icons/icon.ico"); + res.compile().expect("could not embed the Windows app icon"); +} + +#[cfg(not(windows))] +fn main() {} diff --git a/crates/athas/src/main.rs b/crates/athas/src/main.rs index 2cf0d04e8..55d1b313b 100644 --- a/crates/athas/src/main.rs +++ b/crates/athas/src/main.rs @@ -1,3 +1,6 @@ +// Release builds on Windows are GUI apps; a console window would stream logs and close the app with it. +#![cfg_attr(all(windows, not(debug_assertions)), windows_subsystem = "windows")] + use std::io::IsTerminal as _; use gpui::App;