Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

feat(window): set the Dock badge on macOS

RoversX1ec917cf9afb
diff --git a/Cargo.lock b/Cargo.lock
index 720a07e8..c592cd61 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2609,7 +2609,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
- "windows-sys 0.52.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -4021,7 +4021,7 @@ dependencies = [
"libc",
"percent-encoding",
"pin-project-lite",
- "socket2 0.5.10",
+ "socket2 0.6.1",
"system-configuration",
"tokio",
"tower-service",
@@ -4394,7 +4394,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"
dependencies = [
"hermit-abi 0.5.2",
"libc",
- "windows-sys 0.52.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -5869,6 +5869,17 @@ dependencies = [
"objc2-encode",
]
+[[package]]
+name = "objc2-app-kit"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
+dependencies = [
+ "bitflags 2.13.1",
+ "objc2",
+ "objc2-foundation",
+]
+
[[package]]
name = "objc2-core-foundation"
version = "0.3.2"
@@ -7744,7 +7755,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.11.0",
- "windows-sys 0.52.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -9091,7 +9102,7 @@ dependencies = [
"getrandom 0.3.4",
"once_cell",
"rustix 1.1.2",
- "windows-sys 0.52.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -12578,7 +12589,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
- "windows-sys 0.48.0",
+ "windows-sys 0.61.2",
]
[[package]]
@@ -12622,7 +12633,9 @@ dependencies = [
"mio 0.8.11",
"objc",
"objc2",
+ "objc2-app-kit",
"objc2-core-graphics",
+ "objc2-foundation",
"plist",
"promise",
"raw-window-handle",
diff --git a/Cargo.toml b/Cargo.toml
index c4f5ca6f..89d6de86 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -297,6 +297,7 @@ num-derive = "0.4"
num-traits = {version="0.2", default-features=false }
objc = "0.2"
objc2 = "0.6"
+objc2-app-kit = { version = "0.3", default-features = false, features = ["std", "NSApplication", "NSDockTile", "NSResponder"] }
objc2-core-graphics = "0.3"
objc2-foundation = "0.3"
objc2-user-notifications = "0.3"
diff --git a/window/Cargo.toml b/window/Cargo.toml
index 964762be..ec0f6ec8 100644
--- a/window/Cargo.toml
+++ b/window/Cargo.toml
@@ -102,6 +102,8 @@ core-graphics.workspace = true
foreign-types.workspace = true
objc.workspace = true
objc2.workspace = true
+objc2-app-kit.workspace = true
objc2-core-graphics.workspace = true
+objc2-foundation.workspace = true
plist.workspace = true
thinkterm-i18n.workspace = true
diff --git a/window/src/connection.rs b/window/src/connection.rs
index 266c05a5..4f79ad03 100644
--- a/window/src/connection.rs
+++ b/window/src/connection.rs
@@ -175,6 +175,10 @@ pub trait ConnectionOps {
/// callers nothing and removes the lifetime hazard entirely.
fn play_sound(&self, _wav: &'static [u8]) {}
+ /// Show `label` on the application's Dock icon, or clear it with `None`.
+ /// A platform without one ignores it.
+ fn set_dock_badge(&self, _label: Option<&str>) {}
+
/// Returns information about the screens
fn screens(&self) -> anyhow::Result<Screens> {
anyhow::bail!("Unable to query screen information");
diff --git a/window/src/os/macos/connection.rs b/window/src/os/macos/connection.rs
index 119f68b8..84e1b7f3 100644
--- a/window/src/os/macos/connection.rs
+++ b/window/src/os/macos/connection.rs
@@ -246,6 +246,16 @@ impl ConnectionOps for Connection {
}
}
+ fn set_dock_badge(&self, label: Option<&str>) {
+ let Some(mtm) = objc2::MainThreadMarker::new() else {
+ log::debug!("Dock badge set off the main thread; left as it was");
+ return;
+ };
+ let app = objc2_app_kit::NSApplication::sharedApplication(mtm);
+ let label = label.map(objc2_foundation::NSString::from_str);
+ app.dockTile().setBadgeLabel(label.as_deref());
+ }
+
fn screens(&self) -> anyhow::Result<Screens> {
let mut by_name = HashMap::new();
let mut virtual_rect = euclid::rect(0, 0, 0, 0);