BlueGit

ict rusty-teams

feat(macos): tray, close-to-tray, packaging, Chromium-fork kill match

Share the Windows tray-icon path on macOS and reuse Linux close-to-tray
(ADR 0015). Sign/notarize helpers, entitlements, and updater asset
matching for *-macos-universal. Treat Edge/Brave/Helium/Vivaldi as
managed browsers when killing the debug-port session. Live smoke still
pending; Notification Center follows after Linux desktop toasts.

metis Joachim Mild · pushed by metis

Authored 2026-11-15 · 2 weeks ago

Hash
db0a2be0864a5fd2fa75c4551db3a4fbce8d023a
Parent
4e96335d
16 files changed +429 −260
ROADMAP.md +1 −1
@@ -33,7 +33,7 @@ Feature parity with the Microsoft Teams desktop client.
33 33 | Sign in on Windows through embedded WebView2, single sign-on | Done | |
34 34 | Start from the local cache, no spinner | Done | |
35 35 | Self-update | Done | |
36 | Tray icon, close to tray | Done | Linux: StatusNotifierItem tray (KDE, GNOME with AppIndicator); close really closes the window and the tray opens a new one, since GPUI cannot hide a Wayland window |
36 | Tray icon, close to tray | Done | Linux: StatusNotifierItem (KDE, GNOME with AppIndicator). macOS: menu-bar via `tray-icon`, same close-to-tray path as Linux. Windows: `tray-icon` |
37 37 | Linux install, menu entry and self-update | Done | Offers to install itself to `~/.local/share/rusty-teams` with a `.desktop` entry (Settings > General to install, replace, remove or ask again); the installed release build offers new GitHub releases in a dialog (download with progress, then Restart now); the Teams icon is downloaded from Microsoft, not shipped |
38 38 | Sign in on Linux without starting Chrome by hand | Done | The app starts Chrome or Chromium headless with its own profile, shows the window for the login and hides it again afterwards; a watchdog restarts a dead or hung Chrome |
39 39 | Single instance, second start brings the window to front | Done | |
@@ -33,7 +33,7 @@ Feature parity with the Microsoft Teams desktop client.
33| Sign in on Windows through embedded WebView2, single sign-on | Done | |
33| Sign in on Windows through embedded WebView2, single sign-on | Done | |
34| Start from the local cache, no spinner | Done | |
34| Start from the local cache, no spinner | Done | |
35| Self-update | Done | |
35| Self-update | Done | |
36| Tray icon, close to tray | Done | Linux: StatusNotifierItem tray (KDE, GNOME with AppIndicator); close really closes the window and the tray opens a new one, since GPUI cannot hide a Wayland window |
36| Tray icon, close to tray | Done | Linux: StatusNotifierItem (KDE, GNOME with AppIndicator). macOS: menu-bar via `tray-icon`, same close-to-tray path as Linux. Windows: `tray-icon` |
37| Linux install, menu entry and self-update | Done | Offers to install itself to `~/.local/share/rusty-teams` with a `.desktop` entry (Settings > General to install, replace, remove or ask again); the installed release build offers new GitHub releases in a dialog (download with progress, then Restart now); the Teams icon is downloaded from Microsoft, not shipped |
37| Linux install, menu entry and self-update | Done | Offers to install itself to `~/.local/share/rusty-teams` with a `.desktop` entry (Settings > General to install, replace, remove or ask again); the installed release build offers new GitHub releases in a dialog (download with progress, then Restart now); the Teams icon is downloaded from Microsoft, not shipped |
38| Sign in on Linux without starting Chrome by hand | Done | The app starts Chrome or Chromium headless with its own profile, shows the window for the login and hides it again afterwards; a watchdog restarts a dead or hung Chrome |
38| Sign in on Linux without starting Chrome by hand | Done | The app starts Chrome or Chromium headless with its own profile, shows the window for the login and hides it again afterwards; a watchdog restarts a dead or hung Chrome |
39| Single instance, second start brings the window to front | Done | |
39| Single instance, second start brings the window to front | Done | |
crates/app-base/Cargo.toml +3 −1
@@ -41,10 +41,12 @@ x11rb = { version = "0.13", features = ["shape"] }
41 41 ksni = { version = "0.3", features = ["blocking"] }
42 42 zbus = { version = "5", default-features = false, features = ["tokio"] }
43 43
44 [target.'cfg(any(windows, target_os = "macos"))'.dependencies]
45 tray-icon = { version = "0.21", default-features = false }
46
44 47 [target.'cfg(windows)'.dependencies]
45 48 libc = "0.2"
46 49 rodio = { version = "0.22", default-features = false, features = ["playback", "mp3"] }
47 tray-icon = { version = "0.21", default-features = false }
48 50 windows = { version = "0.62", features = [
49 51 "Win32_Foundation",
50 52 "Win32_Graphics_Dwm",
@@ -41,10 +41,12 @@ x11rb = { version = "0.13", features = ["shape"] }
41ksni = { version = "0.3", features = ["blocking"] }
41ksni = { version = "0.3", features = ["blocking"] }
42zbus = { version = "5", default-features = false, features = ["tokio"] }
42zbus = { version = "5", default-features = false, features = ["tokio"] }
43
43
44[target.'cfg(any(windows, target_os = "macos"))'.dependencies]
45tray-icon = { version = "0.21", default-features = false }
46
44[target.'cfg(windows)'.dependencies]
47[target.'cfg(windows)'.dependencies]
45libc = "0.2"
48libc = "0.2"
46rodio = { version = "0.22", default-features = false, features = ["playback", "mp3"] }
49rodio = { version = "0.22", default-features = false, features = ["playback", "mp3"] }
47tray-icon = { version = "0.21", default-features = false }
48windows = { version = "0.62", features = [
50windows = { version = "0.62", features = [
49 "Win32_Foundation",
51 "Win32_Foundation",
50 "Win32_Graphics_Dwm",
52 "Win32_Graphics_Dwm",
crates/app-base/src/notify/platform/mod.rs +5 −0
@@ -5,6 +5,11 @@ pub use windows_impl::*;
5 5
6 6 #[cfg(target_os = "linux")]
7 7 mod linux_notifications;
8 #[cfg(any(windows, target_os = "macos"))]
9 mod tray_icon_impl;
10 #[cfg(any(windows, target_os = "macos"))]
11 pub use tray_icon_impl::Tray;
12
8 13 #[cfg(any(target_os = "linux", target_os = "macos"))]
9 14 mod linux_sound;
10 15 #[cfg(target_os = "linux")]
@@ -5,6 +5,11 @@ pub use windows_impl::*;
5
5
6#[cfg(target_os = "linux")]
6#[cfg(target_os = "linux")]
7mod linux_notifications;
7mod linux_notifications;
8#[cfg(any(windows, target_os = "macos"))]
9mod tray_icon_impl;
10#[cfg(any(windows, target_os = "macos"))]
11pub use tray_icon_impl::Tray;
12
8#[cfg(any(target_os = "linux", target_os = "macos"))]
13#[cfg(any(target_os = "linux", target_os = "macos"))]
9mod linux_sound;
14mod linux_sound;
10#[cfg(target_os = "linux")]
15#[cfg(target_os = "linux")]
crates/app-base/src/notify/platform/stub.rs +2 −2
@@ -112,10 +112,10 @@ pub fn play_mp3(_bytes: Vec<u8>) {}
112 112 #[cfg(not(any(target_os = "linux", target_os = "macos")))]
113 113 pub fn play_mp3_until(_bytes: Vec<u8>, _looped: bool, _stop: Arc<AtomicBool>) {}
114 114
115 #[cfg(not(target_os = "linux"))]
115 #[cfg(not(any(target_os = "linux", target_os = "macos")))]
116 116 pub struct Tray;
117 117
118 #[cfg(not(target_os = "linux"))]
118 #[cfg(not(any(target_os = "linux", target_os = "macos")))]
119 119 impl Tray {
120 120 pub fn new(_presence: super::TrayPresence, _icon_png: &[u8]) -> Option<Self> {
121 121 None
@@ -112,10 +112,10 @@ pub fn play_mp3(_bytes: Vec<u8>) {}
112#[cfg(not(any(target_os = "linux", target_os = "macos")))]
112#[cfg(not(any(target_os = "linux", target_os = "macos")))]
113pub fn play_mp3_until(_bytes: Vec<u8>, _looped: bool, _stop: Arc<AtomicBool>) {}
113pub fn play_mp3_until(_bytes: Vec<u8>, _looped: bool, _stop: Arc<AtomicBool>) {}
114
114
115#[cfg(not(target_os = "linux"))]
115#[cfg(not(any(target_os = "linux", target_os = "macos")))]
116pub struct Tray;
116pub struct Tray;
117
117
118#[cfg(not(target_os = "linux"))]
118#[cfg(not(any(target_os = "linux", target_os = "macos")))]
119impl Tray {
119impl Tray {
120 pub fn new(_presence: super::TrayPresence, _icon_png: &[u8]) -> Option<Self> {
120 pub fn new(_presence: super::TrayPresence, _icon_png: &[u8]) -> Option<Self> {
121 None
121 None
crates/app-base/src/notify/platform/tray_icon_impl.rs added +240 −0
@@ -0,0 +1,240 @@
1 //! Menu-bar / system-tray icon via `tray-icon` (Windows and macOS).
2
3 use tray_icon::menu::{CheckMenuItem, Menu, MenuEvent, MenuItem, PredefinedMenuItem, Submenu};
4 use tray_icon::{Icon, MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent};
5
6 use super::{TrayCommand, TrayPresence};
7 use crate::notify::tray_status;
8
9 const TRAY_ICON_SIZE: u32 = 32;
10 const TRAY_DOT_RADIUS: f32 = 6.;
11
12 const ID_OPEN: &str = "open";
13 const ID_NOTIFICATIONS: &str = "notifications";
14 const ID_QUIT: &str = "quit";
15 const ID_RESET_STATUS: &str = "status:reset";
16
17 pub struct Tray {
18 icon: TrayIcon,
19 open: MenuItem,
20 status: Submenu,
21 status_items: Vec<CheckMenuItem>,
22 duration_items: Vec<MenuItem>,
23 duration_menu: Submenu,
24 reset: MenuItem,
25 notifications: MenuItem,
26 quit: MenuItem,
27 plain: Icon,
28 with_dot: Icon,
29 }
30
31 fn tray_menu_label(key: &str) -> String {
32 crate::ui_locale::tr(key)
33 }
34
35 impl Tray {
36 pub fn new(presence: TrayPresence, icon_png: &[u8]) -> Option<Self> {
37 let (plain, with_dot) = tray_icons(icon_png)?;
38 let open = MenuItem::with_id(ID_OPEN, tray_menu_label("tray.open"), true, None);
39 let status_items: Vec<CheckMenuItem> = tray_status::STATUS_CHOICES
40 .into_iter()
41 .map(|kind| {
42 CheckMenuItem::with_id(
43 tray_status::kind_id(kind),
44 tray_status::choice_label(kind),
45 true,
46 presence.forced == Some(kind),
47 None,
48 )
49 })
50 .collect();
51 let duration_enabled = tray_status::duration_target(presence.forced).is_some();
52 let duration_items: Vec<MenuItem> = tray_status::STATUS_DURATIONS
53 .into_iter()
54 .map(|duration| {
55 MenuItem::with_id(
56 tray_status::duration_id(duration),
57 duration.label(),
58 duration_enabled,
59 None,
60 )
61 })
62 .collect();
63 let duration_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = duration_items
64 .iter()
65 .map(|item| item as &dyn tray_icon::menu::IsMenuItem)
66 .collect();
67 let duration_menu = Submenu::with_items(
68 tray_status::duration_menu_label(),
69 duration_enabled,
70 &duration_refs,
71 )
72 .ok()?;
73 let reset = MenuItem::with_id(ID_RESET_STATUS, tray_status::reset_label(), true, None);
74 let mut status_entry_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = status_items
75 .iter()
76 .map(|item| item as &dyn tray_icon::menu::IsMenuItem)
77 .collect();
78 let separator = PredefinedMenuItem::separator();
79 status_entry_refs.push(&separator);
80 status_entry_refs.push(&duration_menu);
81 status_entry_refs.push(&reset);
82 let status = Submenu::with_items(&presence.title, true, &status_entry_refs).ok()?;
83 let notifications = MenuItem::with_id(
84 ID_NOTIFICATIONS,
85 tray_menu_label("tray.notifications"),
86 true,
87 None,
88 );
89 let quit = MenuItem::with_id(ID_QUIT, tray_menu_label("tray.quit"), true, None);
90 let menu = Menu::new();
91 menu.append_items(&[
92 &open,
93 &PredefinedMenuItem::separator(),
94 &status,
95 &notifications,
96 &PredefinedMenuItem::separator(),
97 &quit,
98 ])
99 .ok()?;
100 let icon = TrayIconBuilder::new()
101 .with_icon(plain.clone())
102 .with_tooltip(crate::APP_NAME)
103 .with_menu(Box::new(menu))
104 .with_menu_on_left_click(false)
105 .build()
106 .ok()?;
107 Some(Tray {
108 icon,
109 open,
110 status,
111 status_items,
112 duration_items,
113 duration_menu,
114 reset,
115 notifications,
116 quit,
117 plain,
118 with_dot,
119 })
120 }
121
122 pub fn relocalize(&self) {
123 let _ = self.open.set_text(tray_menu_label("tray.open"));
124 let _ = self
125 .notifications
126 .set_text(tray_menu_label("tray.notifications"));
127 let _ = self.quit.set_text(tray_menu_label("tray.quit"));
128 let _ = self.reset.set_text(tray_status::reset_label());
129 let _ = self
130 .duration_menu
131 .set_text(tray_status::duration_menu_label());
132 for (item, kind) in self
133 .status_items
134 .iter()
135 .zip(tray_status::STATUS_CHOICES.into_iter())
136 {
137 let _ = item.set_text(tray_status::choice_label(kind));
138 }
139 for (item, duration) in self
140 .duration_items
141 .iter()
142 .zip(tray_status::STATUS_DURATIONS.into_iter())
143 {
144 let _ = item.set_text(duration.label());
145 }
146 }
147
148 pub fn poll(&self) -> Vec<TrayCommand> {
149 let mut commands = Vec::new();
150 while let Ok(event) = MenuEvent::receiver().try_recv() {
151 let id = event.id.0.as_str();
152 let command = match id {
153 ID_OPEN => TrayCommand::Open,
154 ID_NOTIFICATIONS => TrayCommand::Notifications,
155 ID_QUIT => TrayCommand::Quit,
156 ID_RESET_STATUS => TrayCommand::ResetStatus,
157 other => {
158 if let Some(kind) = tray_status::parse_kind_id(other) {
159 TrayCommand::SetStatus(kind)
160 } else if let Some(duration) = tray_status::parse_duration_id(other) {
161 TrayCommand::SetStatusDuration(duration)
162 } else {
163 continue;
164 }
165 }
166 };
167 commands.push(command);
168 }
169 while let Ok(event) = TrayIconEvent::receiver().try_recv() {
170 if let TrayIconEvent::Click {
171 button: MouseButton::Left,
172 button_state: MouseButtonState::Up,
173 ..
174 } = event
175 {
176 commands.push(TrayCommand::Toggle);
177 }
178 }
179 commands
180 }
181
182 pub fn set_app_icon(&mut self, icon_png: &[u8], mention: bool) {
183 let Some((plain, with_dot)) = tray_icons(icon_png) else {
184 return;
185 };
186 self.plain = plain;
187 self.with_dot = with_dot;
188 let icon = if mention { &self.with_dot } else { &self.plain };
189 let _ = self.icon.set_icon(Some(icon.clone()));
190 }
191
192 pub fn sync(&self, presence: TrayPresence) {
193 self.relocalize();
194 let _ = self.status.set_text(&presence.title);
195 for (item, kind) in self
196 .status_items
197 .iter()
198 .zip(tray_status::STATUS_CHOICES.into_iter())
199 {
200 item.set_checked(presence.forced == Some(kind));
201 }
202 let duration_enabled = tray_status::duration_target(presence.forced).is_some();
203 let _ = self.duration_menu.set_enabled(duration_enabled);
204 for item in &self.duration_items {
205 let _ = item.set_enabled(duration_enabled);
206 }
207 let icon = if presence.mention {
208 &self.with_dot
209 } else {
210 &self.plain
211 };
212 let _ = self.icon.set_icon(Some(icon.clone()));
213 }
214 }
215
216 fn tray_icons(icon_png: &[u8]) -> Option<(Icon, Icon)> {
217 let decoded = image::load_from_memory(icon_png).ok()?;
218 let resized = decoded
219 .resize_exact(
220 TRAY_ICON_SIZE,
221 TRAY_ICON_SIZE,
222 image::imageops::FilterType::Lanczos3,
223 )
224 .to_rgba8();
225 let plain = resized.clone().into_raw();
226 let mut dotted = resized;
227 let size = TRAY_ICON_SIZE as f32;
228 let center = (size - TRAY_DOT_RADIUS - 1., size - TRAY_DOT_RADIUS - 1.);
229 for (column, row, pixel) in dotted.enumerate_pixels_mut() {
230 let distance =
231 ((column as f32 - center.0).powi(2) + (row as f32 - center.1).powi(2)).sqrt();
232 if distance <= TRAY_DOT_RADIUS {
233 *pixel = image::Rgba([0xef, 0x44, 0x44, 0xff]);
234 }
235 }
236 Some((
237 Icon::from_rgba(plain, TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
238 Icon::from_rgba(dotted.into_raw(), TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
239 ))
240 }
@@ -0,0 +1,240 @@
1//! Menu-bar / system-tray icon via `tray-icon` (Windows and macOS).
2
3use tray_icon::menu::{CheckMenuItem, Menu, MenuEvent, MenuItem, PredefinedMenuItem, Submenu};
4use tray_icon::{Icon, MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent};
5
6use super::{TrayCommand, TrayPresence};
7use crate::notify::tray_status;
8
9const TRAY_ICON_SIZE: u32 = 32;
10const TRAY_DOT_RADIUS: f32 = 6.;
11
12const ID_OPEN: &str = "open";
13const ID_NOTIFICATIONS: &str = "notifications";
14const ID_QUIT: &str = "quit";
15const ID_RESET_STATUS: &str = "status:reset";
16
17pub struct Tray {
18 icon: TrayIcon,
19 open: MenuItem,
20 status: Submenu,
21 status_items: Vec<CheckMenuItem>,
22 duration_items: Vec<MenuItem>,
23 duration_menu: Submenu,
24 reset: MenuItem,
25 notifications: MenuItem,
26 quit: MenuItem,
27 plain: Icon,
28 with_dot: Icon,
29}
30
31fn tray_menu_label(key: &str) -> String {
32 crate::ui_locale::tr(key)
33}
34
35impl Tray {
36 pub fn new(presence: TrayPresence, icon_png: &[u8]) -> Option<Self> {
37 let (plain, with_dot) = tray_icons(icon_png)?;
38 let open = MenuItem::with_id(ID_OPEN, tray_menu_label("tray.open"), true, None);
39 let status_items: Vec<CheckMenuItem> = tray_status::STATUS_CHOICES
40 .into_iter()
41 .map(|kind| {
42 CheckMenuItem::with_id(
43 tray_status::kind_id(kind),
44 tray_status::choice_label(kind),
45 true,
46 presence.forced == Some(kind),
47 None,
48 )
49 })
50 .collect();
51 let duration_enabled = tray_status::duration_target(presence.forced).is_some();
52 let duration_items: Vec<MenuItem> = tray_status::STATUS_DURATIONS
53 .into_iter()
54 .map(|duration| {
55 MenuItem::with_id(
56 tray_status::duration_id(duration),
57 duration.label(),
58 duration_enabled,
59 None,
60 )
61 })
62 .collect();
63 let duration_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = duration_items
64 .iter()
65 .map(|item| item as &dyn tray_icon::menu::IsMenuItem)
66 .collect();
67 let duration_menu = Submenu::with_items(
68 tray_status::duration_menu_label(),
69 duration_enabled,
70 &duration_refs,
71 )
72 .ok()?;
73 let reset = MenuItem::with_id(ID_RESET_STATUS, tray_status::reset_label(), true, None);
74 let mut status_entry_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = status_items
75 .iter()
76 .map(|item| item as &dyn tray_icon::menu::IsMenuItem)
77 .collect();
78 let separator = PredefinedMenuItem::separator();
79 status_entry_refs.push(&separator);
80 status_entry_refs.push(&duration_menu);
81 status_entry_refs.push(&reset);
82 let status = Submenu::with_items(&presence.title, true, &status_entry_refs).ok()?;
83 let notifications = MenuItem::with_id(
84 ID_NOTIFICATIONS,
85 tray_menu_label("tray.notifications"),
86 true,
87 None,
88 );
89 let quit = MenuItem::with_id(ID_QUIT, tray_menu_label("tray.quit"), true, None);
90 let menu = Menu::new();
91 menu.append_items(&[
92 &open,
93 &PredefinedMenuItem::separator(),
94 &status,
95 &notifications,
96 &PredefinedMenuItem::separator(),
97 &quit,
98 ])
99 .ok()?;
100 let icon = TrayIconBuilder::new()
101 .with_icon(plain.clone())
102 .with_tooltip(crate::APP_NAME)
103 .with_menu(Box::new(menu))
104 .with_menu_on_left_click(false)
105 .build()
106 .ok()?;
107 Some(Tray {
108 icon,
109 open,
110 status,
111 status_items,
112 duration_items,
113 duration_menu,
114 reset,
115 notifications,
116 quit,
117 plain,
118 with_dot,
119 })
120 }
121
122 pub fn relocalize(&self) {
123 let _ = self.open.set_text(tray_menu_label("tray.open"));
124 let _ = self
125 .notifications
126 .set_text(tray_menu_label("tray.notifications"));
127 let _ = self.quit.set_text(tray_menu_label("tray.quit"));
128 let _ = self.reset.set_text(tray_status::reset_label());
129 let _ = self
130 .duration_menu
131 .set_text(tray_status::duration_menu_label());
132 for (item, kind) in self
133 .status_items
134 .iter()
135 .zip(tray_status::STATUS_CHOICES.into_iter())
136 {
137 let _ = item.set_text(tray_status::choice_label(kind));
138 }
139 for (item, duration) in self
140 .duration_items
141 .iter()
142 .zip(tray_status::STATUS_DURATIONS.into_iter())
143 {
144 let _ = item.set_text(duration.label());
145 }
146 }
147
148 pub fn poll(&self) -> Vec<TrayCommand> {
149 let mut commands = Vec::new();
150 while let Ok(event) = MenuEvent::receiver().try_recv() {
151 let id = event.id.0.as_str();
152 let command = match id {
153 ID_OPEN => TrayCommand::Open,
154 ID_NOTIFICATIONS => TrayCommand::Notifications,
155 ID_QUIT => TrayCommand::Quit,
156 ID_RESET_STATUS => TrayCommand::ResetStatus,
157 other => {
158 if let Some(kind) = tray_status::parse_kind_id(other) {
159 TrayCommand::SetStatus(kind)
160 } else if let Some(duration) = tray_status::parse_duration_id(other) {
161 TrayCommand::SetStatusDuration(duration)
162 } else {
163 continue;
164 }
165 }
166 };
167 commands.push(command);
168 }
169 while let Ok(event) = TrayIconEvent::receiver().try_recv() {
170 if let TrayIconEvent::Click {
171 button: MouseButton::Left,
172 button_state: MouseButtonState::Up,
173 ..
174 } = event
175 {
176 commands.push(TrayCommand::Toggle);
177 }
178 }
179 commands
180 }
181
182 pub fn set_app_icon(&mut self, icon_png: &[u8], mention: bool) {
183 let Some((plain, with_dot)) = tray_icons(icon_png) else {
184 return;
185 };
186 self.plain = plain;
187 self.with_dot = with_dot;
188 let icon = if mention { &self.with_dot } else { &self.plain };
189 let _ = self.icon.set_icon(Some(icon.clone()));
190 }
191
192 pub fn sync(&self, presence: TrayPresence) {
193 self.relocalize();
194 let _ = self.status.set_text(&presence.title);
195 for (item, kind) in self
196 .status_items
197 .iter()
198 .zip(tray_status::STATUS_CHOICES.into_iter())
199 {
200 item.set_checked(presence.forced == Some(kind));
201 }
202 let duration_enabled = tray_status::duration_target(presence.forced).is_some();
203 let _ = self.duration_menu.set_enabled(duration_enabled);
204 for item in &self.duration_items {
205 let _ = item.set_enabled(duration_enabled);
206 }
207 let icon = if presence.mention {
208 &self.with_dot
209 } else {
210 &self.plain
211 };
212 let _ = self.icon.set_icon(Some(icon.clone()));
213 }
214}
215
216fn tray_icons(icon_png: &[u8]) -> Option<(Icon, Icon)> {
217 let decoded = image::load_from_memory(icon_png).ok()?;
218 let resized = decoded
219 .resize_exact(
220 TRAY_ICON_SIZE,
221 TRAY_ICON_SIZE,
222 image::imageops::FilterType::Lanczos3,
223 )
224 .to_rgba8();
225 let plain = resized.clone().into_raw();
226 let mut dotted = resized;
227 let size = TRAY_ICON_SIZE as f32;
228 let center = (size - TRAY_DOT_RADIUS - 1., size - TRAY_DOT_RADIUS - 1.);
229 for (column, row, pixel) in dotted.enumerate_pixels_mut() {
230 let distance =
231 ((column as f32 - center.0).powi(2) + (row as f32 - center.1).powi(2)).sqrt();
232 if distance <= TRAY_DOT_RADIUS {
233 *pixel = image::Rgba([0xef, 0x44, 0x44, 0xff]);
234 }
235 }
236 Some((
237 Icon::from_rgba(plain, TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
238 Icon::from_rgba(dotted.into_raw(), TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
239 ))
240}
crates/app-base/src/notify/platform/windows_impl.rs +1 −236
@@ -7,8 +7,6 @@ use std::time::Duration;
7 7 use calling::ShareKind;
8 8 use gpui_kit::Window;
9 9 use raw_window_handle::{HasWindowHandle, RawWindowHandle};
10 use tray_icon::menu::{CheckMenuItem, Menu, MenuEvent, MenuItem, PredefinedMenuItem, Submenu};
11 use tray_icon::{Icon, MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent};
12 10 use windows::Win32::Foundation::{COLORREF, HWND, LPARAM, POINT, RECT, WPARAM};
13 11 use windows::Win32::Graphics::Dwm::{
14 12 DWMWA_BORDER_COLOR, DWMWA_CLOAKED, DWMWA_COLOR_NONE, DWMWA_EXTENDED_FRAME_BOUNDS,
@@ -43,15 +41,12 @@ use windows::Win32::UI::WindowsAndMessaging::{
43 41 use windows::core::{BOOL, PCWSTR, w};
44 42
45 43 use super::stack_plan::{StackPlan, stack_plan};
46 use super::{NativeHandle, ScreenRect, ShareGeometry, TrayCommand, TrayPresence, WorkArea};
44 use super::{NativeHandle, ScreenRect, ShareGeometry, WorkArea};
47 45 use crate::notify::badge::{Badge, render_badge};
48 use crate::notify::tray_status;
49 46
50 47 const SOUND_BYTES: &[u8] = include_bytes!("../../../../app/assets/sounds/notification.mp3");
51 const TRAY_ICON_SIZE: u32 = 32;
52 48 const WINDOW_ICON_SIZE: f32 = 32.;
53 49 const WINDOW_SMALL_ICON_SIZE: f32 = 16.;
54 const TRAY_DOT_RADIUS: f32 = 6.;
55 50 const BASE_DPI: f32 = 96.;
56 51 const RING_POLL: Duration = Duration::from_millis(20);
57 52
@@ -652,236 +647,6 @@ pub fn play_sound() {
652 647 });
653 648 }
654 649
655 const ID_OPEN: &str = "open";
656 const ID_NOTIFICATIONS: &str = "notifications";
657 const ID_QUIT: &str = "quit";
658 const ID_RESET_STATUS: &str = "status:reset";
659
660 pub struct Tray {
661 icon: TrayIcon,
662 open: MenuItem,
663 status: Submenu,
664 status_items: Vec<CheckMenuItem>,
665 duration_items: Vec<MenuItem>,
666 duration_menu: Submenu,
667 reset: MenuItem,
668 notifications: MenuItem,
669 quit: MenuItem,
670 plain: Icon,
671 with_dot: Icon,
672 }
673
674 fn tray_menu_label(key: &str) -> String {
675 crate::ui_locale::tr(key)
676 }
677
678 impl Tray {
679 pub fn new(presence: TrayPresence, icon_png: &[u8]) -> Option<Self> {
680 let (plain, with_dot) = tray_icons(icon_png)?;
681 let open = MenuItem::with_id(ID_OPEN, tray_menu_label("tray.open"), true, None);
682 let status_items: Vec<CheckMenuItem> = tray_status::STATUS_CHOICES
683 .into_iter()
684 .map(|kind| {
685 CheckMenuItem::with_id(
686 tray_status::kind_id(kind),
687 tray_status::choice_label(kind),
688 true,
689 presence.forced == Some(kind),
690 None,
691 )
692 })
693 .collect();
694 let duration_enabled = tray_status::duration_target(presence.forced).is_some();
695 let duration_items: Vec<MenuItem> = tray_status::STATUS_DURATIONS
696 .into_iter()
697 .map(|duration| {
698 MenuItem::with_id(
699 tray_status::duration_id(duration),
700 duration.label(),
701 duration_enabled,
702 None,
703 )
704 })
705 .collect();
706 let duration_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = duration_items
707 .iter()
708 .map(|item| item as &dyn tray_icon::menu::IsMenuItem)
709 .collect();
710 let duration_menu = Submenu::with_items(
711 tray_status::duration_menu_label(),
712 duration_enabled,
713 &duration_refs,
714 )
715 .ok()?;
716 let reset = MenuItem::with_id(ID_RESET_STATUS, tray_status::reset_label(), true, None);
717 let mut status_entry_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = status_items
718 .iter()
719 .map(|item| item as &dyn tray_icon::menu::IsMenuItem)
720 .collect();
721 let separator = PredefinedMenuItem::separator();
722 status_entry_refs.push(&separator);
723 status_entry_refs.push(&duration_menu);
724 status_entry_refs.push(&reset);
725 let status = Submenu::with_items(&presence.title, true, &status_entry_refs).ok()?;
726 let notifications = MenuItem::with_id(
727 ID_NOTIFICATIONS,
728 tray_menu_label("tray.notifications"),
729 true,
730 None,
731 );
732 let quit = MenuItem::with_id(ID_QUIT, tray_menu_label("tray.quit"), true, None);
733 let menu = Menu::new();
734 menu.append_items(&[
735 &open,
736 &PredefinedMenuItem::separator(),
737 &status,
738 &notifications,
739 &PredefinedMenuItem::separator(),
740 &quit,
741 ])
742 .ok()?;
743 let icon = TrayIconBuilder::new()
744 .with_icon(plain.clone())
745 .with_tooltip(crate::APP_NAME)
746 .with_menu(Box::new(menu))
747 .with_menu_on_left_click(false)
748 .build()
749 .ok()?;
750 Some(Tray {
751 icon,
752 open,
753 status,
754 status_items,
755 duration_items,
756 duration_menu,
757 reset,
758 notifications,
759 quit,
760 plain,
761 with_dot,
762 })
763 }
764
765 pub fn relocalize(&self) {
766 let _ = self.open.set_text(tray_menu_label("tray.open"));
767 let _ = self
768 .notifications
769 .set_text(tray_menu_label("tray.notifications"));
770 let _ = self.quit.set_text(tray_menu_label("tray.quit"));
771 let _ = self.reset.set_text(tray_status::reset_label());
772 let _ = self
773 .duration_menu
774 .set_text(tray_status::duration_menu_label());
775 for (item, kind) in self
776 .status_items
777 .iter()
778 .zip(tray_status::STATUS_CHOICES.into_iter())
779 {
780 let _ = item.set_text(tray_status::choice_label(kind));
781 }
782 for (item, duration) in self
783 .duration_items
784 .iter()
785 .zip(tray_status::STATUS_DURATIONS.into_iter())
786 {
787 let _ = item.set_text(duration.label());
788 }
789 }
790
791 pub fn poll(&self) -> Vec<TrayCommand> {
792 let mut commands = Vec::new();
793 while let Ok(event) = MenuEvent::receiver().try_recv() {
794 let id = event.id.0.as_str();
795 let command = match id {
796 ID_OPEN => TrayCommand::Open,
797 ID_NOTIFICATIONS => TrayCommand::Notifications,
798 ID_QUIT => TrayCommand::Quit,
799 ID_RESET_STATUS => TrayCommand::ResetStatus,
800 other => {
801 if let Some(kind) = tray_status::parse_kind_id(other) {
802 TrayCommand::SetStatus(kind)
803 } else if let Some(duration) = tray_status::parse_duration_id(other) {
804 TrayCommand::SetStatusDuration(duration)
805 } else {
806 continue;
807 }
808 }
809 };
810 commands.push(command);
811 }
812 while let Ok(event) = TrayIconEvent::receiver().try_recv() {
813 if let TrayIconEvent::Click {
814 button: MouseButton::Left,
815 button_state: MouseButtonState::Up,
816 ..
817 } = event
818 {
819 commands.push(TrayCommand::Toggle);
820 }
821 }
822 commands
823 }
824
825 pub fn set_app_icon(&mut self, icon_png: &[u8], mention: bool) {
826 let Some((plain, with_dot)) = tray_icons(icon_png) else {
827 return;
828 };
829 self.plain = plain;
830 self.with_dot = with_dot;
831 let icon = if mention { &self.with_dot } else { &self.plain };
832 let _ = self.icon.set_icon(Some(icon.clone()));
833 }
834
835 pub fn sync(&self, presence: TrayPresence) {
836 self.relocalize();
837 let _ = self.status.set_text(&presence.title);
838 for (item, kind) in self
839 .status_items
840 .iter()
841 .zip(tray_status::STATUS_CHOICES.into_iter())
842 {
843 item.set_checked(presence.forced == Some(kind));
844 }
845 let duration_enabled = tray_status::duration_target(presence.forced).is_some();
846 let _ = self.duration_menu.set_enabled(duration_enabled);
847 for item in &self.duration_items {
848 let _ = item.set_enabled(duration_enabled);
849 }
850 let icon = if presence.mention {
851 &self.with_dot
852 } else {
853 &self.plain
854 };
855 let _ = self.icon.set_icon(Some(icon.clone()));
856 }
857 }
858
859 fn tray_icons(icon_png: &[u8]) -> Option<(Icon, Icon)> {
860 let decoded = image::load_from_memory(icon_png).ok()?;
861 let resized = decoded
862 .resize_exact(
863 TRAY_ICON_SIZE,
864 TRAY_ICON_SIZE,
865 image::imageops::FilterType::Lanczos3,
866 )
867 .to_rgba8();
868 let plain = resized.clone().into_raw();
869 let mut dotted = resized;
870 let size = TRAY_ICON_SIZE as f32;
871 let center = (size - TRAY_DOT_RADIUS - 1., size - TRAY_DOT_RADIUS - 1.);
872 for (column, row, pixel) in dotted.enumerate_pixels_mut() {
873 let distance =
874 ((column as f32 - center.0).powi(2) + (row as f32 - center.1).powi(2)).sqrt();
875 if distance <= TRAY_DOT_RADIUS {
876 *pixel = image::Rgba([0xef, 0x44, 0x44, 0xff]);
877 }
878 }
879 Some((
880 Icon::from_rgba(plain, TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
881 Icon::from_rgba(dotted.into_raw(), TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
882 ))
883 }
884
885 650 pub fn animations_enabled() -> bool {
886 651 let mut enabled = BOOL(1);
887 652 let read = unsafe {
@@ -7,8 +7,6 @@ use std::time::Duration;
7use calling::ShareKind;
7use calling::ShareKind;
8use gpui_kit::Window;
8use gpui_kit::Window;
9use raw_window_handle::{HasWindowHandle, RawWindowHandle};
9use raw_window_handle::{HasWindowHandle, RawWindowHandle};
10use tray_icon::menu::{CheckMenuItem, Menu, MenuEvent, MenuItem, PredefinedMenuItem, Submenu};
11use tray_icon::{Icon, MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent};
12use windows::Win32::Foundation::{COLORREF, HWND, LPARAM, POINT, RECT, WPARAM};
10use windows::Win32::Foundation::{COLORREF, HWND, LPARAM, POINT, RECT, WPARAM};
13use windows::Win32::Graphics::Dwm::{
11use windows::Win32::Graphics::Dwm::{
14 DWMWA_BORDER_COLOR, DWMWA_CLOAKED, DWMWA_COLOR_NONE, DWMWA_EXTENDED_FRAME_BOUNDS,
12 DWMWA_BORDER_COLOR, DWMWA_CLOAKED, DWMWA_COLOR_NONE, DWMWA_EXTENDED_FRAME_BOUNDS,
@@ -43,15 +41,12 @@ use windows::Win32::UI::WindowsAndMessaging::{
43use windows::core::{BOOL, PCWSTR, w};
41use windows::core::{BOOL, PCWSTR, w};
44
42
45use super::stack_plan::{StackPlan, stack_plan};
43use super::stack_plan::{StackPlan, stack_plan};
46use super::{NativeHandle, ScreenRect, ShareGeometry, TrayCommand, TrayPresence, WorkArea};
44use super::{NativeHandle, ScreenRect, ShareGeometry, WorkArea};
47use crate::notify::badge::{Badge, render_badge};
45use crate::notify::badge::{Badge, render_badge};
48use crate::notify::tray_status;
49
46
50const SOUND_BYTES: &[u8] = include_bytes!("../../../../app/assets/sounds/notification.mp3");
47const SOUND_BYTES: &[u8] = include_bytes!("../../../../app/assets/sounds/notification.mp3");
51const TRAY_ICON_SIZE: u32 = 32;
52const WINDOW_ICON_SIZE: f32 = 32.;
48const WINDOW_ICON_SIZE: f32 = 32.;
53const WINDOW_SMALL_ICON_SIZE: f32 = 16.;
49const WINDOW_SMALL_ICON_SIZE: f32 = 16.;
54const TRAY_DOT_RADIUS: f32 = 6.;
55const BASE_DPI: f32 = 96.;
50const BASE_DPI: f32 = 96.;
56const RING_POLL: Duration = Duration::from_millis(20);
51const RING_POLL: Duration = Duration::from_millis(20);
57
52
@@ -652,236 +647,6 @@ pub fn play_sound() {
652 });
647 });
653}
648}
654
649
655const ID_OPEN: &str = "open";
656const ID_NOTIFICATIONS: &str = "notifications";
657const ID_QUIT: &str = "quit";
658const ID_RESET_STATUS: &str = "status:reset";
659
660pub struct Tray {
661 icon: TrayIcon,
662 open: MenuItem,
663 status: Submenu,
664 status_items: Vec<CheckMenuItem>,
665 duration_items: Vec<MenuItem>,
666 duration_menu: Submenu,
667 reset: MenuItem,
668 notifications: MenuItem,
669 quit: MenuItem,
670 plain: Icon,
671 with_dot: Icon,
672}
673
674fn tray_menu_label(key: &str) -> String {
675 crate::ui_locale::tr(key)
676}
677
678impl Tray {
679 pub fn new(presence: TrayPresence, icon_png: &[u8]) -> Option<Self> {
680 let (plain, with_dot) = tray_icons(icon_png)?;
681 let open = MenuItem::with_id(ID_OPEN, tray_menu_label("tray.open"), true, None);
682 let status_items: Vec<CheckMenuItem> = tray_status::STATUS_CHOICES
683 .into_iter()
684 .map(|kind| {
685 CheckMenuItem::with_id(
686 tray_status::kind_id(kind),
687 tray_status::choice_label(kind),
688 true,
689 presence.forced == Some(kind),
690 None,
691 )
692 })
693 .collect();
694 let duration_enabled = tray_status::duration_target(presence.forced).is_some();
695 let duration_items: Vec<MenuItem> = tray_status::STATUS_DURATIONS
696 .into_iter()
697 .map(|duration| {
698 MenuItem::with_id(
699 tray_status::duration_id(duration),
700 duration.label(),
701 duration_enabled,
702 None,
703 )
704 })
705 .collect();
706 let duration_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = duration_items
707 .iter()
708 .map(|item| item as &dyn tray_icon::menu::IsMenuItem)
709 .collect();
710 let duration_menu = Submenu::with_items(
711 tray_status::duration_menu_label(),
712 duration_enabled,
713 &duration_refs,
714 )
715 .ok()?;
716 let reset = MenuItem::with_id(ID_RESET_STATUS, tray_status::reset_label(), true, None);
717 let mut status_entry_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = status_items
718 .iter()
719 .map(|item| item as &dyn tray_icon::menu::IsMenuItem)
720 .collect();
721 let separator = PredefinedMenuItem::separator();
722 status_entry_refs.push(&separator);
723 status_entry_refs.push(&duration_menu);
724 status_entry_refs.push(&reset);
725 let status = Submenu::with_items(&presence.title, true, &status_entry_refs).ok()?;
726 let notifications = MenuItem::with_id(
727 ID_NOTIFICATIONS,
728 tray_menu_label("tray.notifications"),
729 true,
730 None,
731 );
732 let quit = MenuItem::with_id(ID_QUIT, tray_menu_label("tray.quit"), true, None);
733 let menu = Menu::new();
734 menu.append_items(&[
735 &open,
736 &PredefinedMenuItem::separator(),
737 &status,
738 &notifications,
739 &PredefinedMenuItem::separator(),
740 &quit,
741 ])
742 .ok()?;
743 let icon = TrayIconBuilder::new()
744 .with_icon(plain.clone())
745 .with_tooltip(crate::APP_NAME)
746 .with_menu(Box::new(menu))
747 .with_menu_on_left_click(false)
748 .build()
749 .ok()?;
750 Some(Tray {
751 icon,
752 open,
753 status,
754 status_items,
755 duration_items,
756 duration_menu,
757 reset,
758 notifications,
759 quit,
760 plain,
761 with_dot,
762 })
763 }
764
765 pub fn relocalize(&self) {
766 let _ = self.open.set_text(tray_menu_label("tray.open"));
767 let _ = self
768 .notifications
769 .set_text(tray_menu_label("tray.notifications"));
770 let _ = self.quit.set_text(tray_menu_label("tray.quit"));
771 let _ = self.reset.set_text(tray_status::reset_label());
772 let _ = self
773 .duration_menu
774 .set_text(tray_status::duration_menu_label());
775 for (item, kind) in self
776 .status_items
777 .iter()
778 .zip(tray_status::STATUS_CHOICES.into_iter())
779 {
780 let _ = item.set_text(tray_status::choice_label(kind));
781 }
782 for (item, duration) in self
783 .duration_items
784 .iter()
785 .zip(tray_status::STATUS_DURATIONS.into_iter())
786 {
787 let _ = item.set_text(duration.label());
788 }
789 }
790
791 pub fn poll(&self) -> Vec<TrayCommand> {
792 let mut commands = Vec::new();
793 while let Ok(event) = MenuEvent::receiver().try_recv() {
794 let id = event.id.0.as_str();
795 let command = match id {
796 ID_OPEN => TrayCommand::Open,
797 ID_NOTIFICATIONS => TrayCommand::Notifications,
798 ID_QUIT => TrayCommand::Quit,
799 ID_RESET_STATUS => TrayCommand::ResetStatus,
800 other => {
801 if let Some(kind) = tray_status::parse_kind_id(other) {
802 TrayCommand::SetStatus(kind)
803 } else if let Some(duration) = tray_status::parse_duration_id(other) {
804 TrayCommand::SetStatusDuration(duration)
805 } else {
806 continue;
807 }
808 }
809 };
810 commands.push(command);
811 }
812 while let Ok(event) = TrayIconEvent::receiver().try_recv() {
813 if let TrayIconEvent::Click {
814 button: MouseButton::Left,
815 button_state: MouseButtonState::Up,
816 ..
817 } = event
818 {
819 commands.push(TrayCommand::Toggle);
820 }
821 }
822 commands
823 }
824
825 pub fn set_app_icon(&mut self, icon_png: &[u8], mention: bool) {
826 let Some((plain, with_dot)) = tray_icons(icon_png) else {
827 return;
828 };
829 self.plain = plain;
830 self.with_dot = with_dot;
831 let icon = if mention { &self.with_dot } else { &self.plain };
832 let _ = self.icon.set_icon(Some(icon.clone()));
833 }
834
835 pub fn sync(&self, presence: TrayPresence) {
836 self.relocalize();
837 let _ = self.status.set_text(&presence.title);
838 for (item, kind) in self
839 .status_items
840 .iter()
841 .zip(tray_status::STATUS_CHOICES.into_iter())
842 {
843 item.set_checked(presence.forced == Some(kind));
844 }
845 let duration_enabled = tray_status::duration_target(presence.forced).is_some();
846 let _ = self.duration_menu.set_enabled(duration_enabled);
847 for item in &self.duration_items {
848 let _ = item.set_enabled(duration_enabled);
849 }
850 let icon = if presence.mention {
851 &self.with_dot
852 } else {
853 &self.plain
854 };
855 let _ = self.icon.set_icon(Some(icon.clone()));
856 }
857}
858
859fn tray_icons(icon_png: &[u8]) -> Option<(Icon, Icon)> {
860 let decoded = image::load_from_memory(icon_png).ok()?;
861 let resized = decoded
862 .resize_exact(
863 TRAY_ICON_SIZE,
864 TRAY_ICON_SIZE,
865 image::imageops::FilterType::Lanczos3,
866 )
867 .to_rgba8();
868 let plain = resized.clone().into_raw();
869 let mut dotted = resized;
870 let size = TRAY_ICON_SIZE as f32;
871 let center = (size - TRAY_DOT_RADIUS - 1., size - TRAY_DOT_RADIUS - 1.);
872 for (column, row, pixel) in dotted.enumerate_pixels_mut() {
873 let distance =
874 ((column as f32 - center.0).powi(2) + (row as f32 - center.1).powi(2)).sqrt();
875 if distance <= TRAY_DOT_RADIUS {
876 *pixel = image::Rgba([0xef, 0x44, 0x44, 0xff]);
877 }
878 }
879 Some((
880 Icon::from_rgba(plain, TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
881 Icon::from_rgba(dotted.into_raw(), TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
882 ))
883}
884
885pub fn animations_enabled() -> bool {
650pub fn animations_enabled() -> bool {
886 let mut enabled = BOOL(1);
651 let mut enabled = BOOL(1);
887 let read = unsafe {
652 let read = unsafe {
crates/app-base/src/release_feed.rs +11 −3
@@ -1,4 +1,7 @@
1 #![cfg_attr(not(any(windows, target_os = "linux")), allow(dead_code))]
1 #![cfg_attr(
2 not(any(windows, target_os = "linux", target_os = "macos")),
3 allow(dead_code)
4 )]
2 5
3 6 use std::cmp::Ordering;
4 7 use std::fs;
@@ -17,14 +20,19 @@ pub const CHECK_INTERVAL: Duration = Duration::from_secs(6 * 60 * 60);
17 20 const RELEASES_URL: &str =
18 21 "https://api.github.com/repos/danieldaeschle/rusty-teams/releases?per_page=10";
19 22 /// The release asset this platform installs, and the magic bytes it must start with.
20 #[cfg(not(target_os = "linux"))]
23 #[cfg(windows)]
21 24 const ASSET_SUFFIX: &str = "-windows-amd64.exe";
22 #[cfg(not(target_os = "linux"))]
25 #[cfg(windows)]
23 26 const EXECUTABLE_MAGIC: &[u8] = b"MZ";
24 27 #[cfg(target_os = "linux")]
25 28 const ASSET_SUFFIX: &str = "-linux-amd64";
26 29 #[cfg(target_os = "linux")]
27 30 const EXECUTABLE_MAGIC: &[u8] = b"\x7fELF";
31 /// Universal Mach-O from `scripts/build-macos.sh` (lipo fat binary, not the .app zip).
32 #[cfg(target_os = "macos")]
33 const ASSET_SUFFIX: &str = "-macos-universal";
34 #[cfg(target_os = "macos")]
35 const EXECUTABLE_MAGIC: &[u8] = b"\xca\xfe\xba\xbe";
28 36 const PARTIAL_SUFFIX: &str = ".partial";
29 37 const DOWNLOAD_CHUNK: usize = 64 * 1024;
30 38 const SHA256_PREFIX: &str = "sha256:";
@@ -1,4 +1,7 @@
1#![cfg_attr(not(any(windows, target_os = "linux")), allow(dead_code))]
1#![cfg_attr(
2 not(any(windows, target_os = "linux", target_os = "macos")),
3 allow(dead_code)
4)]
2
5
3use std::cmp::Ordering;
6use std::cmp::Ordering;
4use std::fs;
7use std::fs;
@@ -17,14 +20,19 @@ pub const CHECK_INTERVAL: Duration = Duration::from_secs(6 * 60 * 60);
17const RELEASES_URL: &str =
20const RELEASES_URL: &str =
18 "https://api.github.com/repos/danieldaeschle/rusty-teams/releases?per_page=10";
21 "https://api.github.com/repos/danieldaeschle/rusty-teams/releases?per_page=10";
19/// The release asset this platform installs, and the magic bytes it must start with.
22/// The release asset this platform installs, and the magic bytes it must start with.
20#[cfg(not(target_os = "linux"))]
23#[cfg(windows)]
21const ASSET_SUFFIX: &str = "-windows-amd64.exe";
24const ASSET_SUFFIX: &str = "-windows-amd64.exe";
22#[cfg(not(target_os = "linux"))]
25#[cfg(windows)]
23const EXECUTABLE_MAGIC: &[u8] = b"MZ";
26const EXECUTABLE_MAGIC: &[u8] = b"MZ";
24#[cfg(target_os = "linux")]
27#[cfg(target_os = "linux")]
25const ASSET_SUFFIX: &str = "-linux-amd64";
28const ASSET_SUFFIX: &str = "-linux-amd64";
26#[cfg(target_os = "linux")]
29#[cfg(target_os = "linux")]
27const EXECUTABLE_MAGIC: &[u8] = b"\x7fELF";
30const EXECUTABLE_MAGIC: &[u8] = b"\x7fELF";
31/// Universal Mach-O from `scripts/build-macos.sh` (lipo fat binary, not the .app zip).
32#[cfg(target_os = "macos")]
33const ASSET_SUFFIX: &str = "-macos-universal";
34#[cfg(target_os = "macos")]
35const EXECUTABLE_MAGIC: &[u8] = b"\xca\xfe\xba\xbe";
28const PARTIAL_SUFFIX: &str = ".partial";
36const PARTIAL_SUFFIX: &str = ".partial";
29const DOWNLOAD_CHUNK: usize = 64 * 1024;
37const DOWNLOAD_CHUNK: usize = 64 * 1024;
30const SHA256_PREFIX: &str = "sha256:";
38const SHA256_PREFIX: &str = "sha256:";
crates/app-base/src/updater.rs +26 −7
@@ -1,4 +1,7 @@
1 #![cfg_attr(not(any(windows, target_os = "linux")), allow(dead_code))]
1 #![cfg_attr(
2 not(any(windows, target_os = "linux", target_os = "macos")),
3 allow(dead_code)
4 )]
2 5
3 6 use std::io;
4 7 use std::path::{Path, PathBuf};
@@ -266,12 +269,28 @@ mod platform {
266 269 /// build folder or a package location is left alone.
267 270 pub fn self_update_allowed() -> bool {
268 271 #[cfg(target_os = "linux")]
269 return std::env::current_exe().is_ok_and(|executable| {
270 crate::linux_desktop::Layout::current()
271 .is_some_and(|layout| crate::linux_desktop::is_installed(&executable, &layout))
272 });
273 #[cfg(not(target_os = "linux"))]
274 true
272 {
273 return std::env::current_exe().is_ok_and(|executable| {
274 crate::linux_desktop::Layout::current()
275 .is_some_and(|layout| crate::linux_desktop::is_installed(&executable, &layout))
276 });
277 }
278 #[cfg(target_os = "macos")]
279 {
280 return std::env::current_exe().is_ok_and(|executable| {
281 executable
282 .components()
283 .any(|part| part.as_os_str().to_string_lossy().ends_with(".app"))
284 });
285 }
286 #[cfg(windows)]
287 {
288 return true;
289 }
290 #[cfg(not(any(windows, target_os = "linux", target_os = "macos")))]
291 {
292 false
293 }
275 294 }
276 295
277 296 /// Reading the new exe once lets the virus scanner finish before the restart, which otherwise blocks process start for seconds.
@@ -1,4 +1,7 @@
1#![cfg_attr(not(any(windows, target_os = "linux")), allow(dead_code))]
1#![cfg_attr(
2 not(any(windows, target_os = "linux", target_os = "macos")),
3 allow(dead_code)
4)]
2
5
3use std::io;
6use std::io;
4use std::path::{Path, PathBuf};
7use std::path::{Path, PathBuf};
@@ -266,12 +269,28 @@ mod platform {
266/// build folder or a package location is left alone.
269/// build folder or a package location is left alone.
267pub fn self_update_allowed() -> bool {
270pub fn self_update_allowed() -> bool {
268 #[cfg(target_os = "linux")]
271 #[cfg(target_os = "linux")]
269 return std::env::current_exe().is_ok_and(|executable| {
272 {
270 crate::linux_desktop::Layout::current()
273 return std::env::current_exe().is_ok_and(|executable| {
271 .is_some_and(|layout| crate::linux_desktop::is_installed(&executable, &layout))
274 crate::linux_desktop::Layout::current()
272 });
275 .is_some_and(|layout| crate::linux_desktop::is_installed(&executable, &layout))
273 #[cfg(not(target_os = "linux"))]
276 });
274 true
277 }
278 #[cfg(target_os = "macos")]
279 {
280 return std::env::current_exe().is_ok_and(|executable| {
281 executable
282 .components()
283 .any(|part| part.as_os_str().to_string_lossy().ends_with(".app"))
284 });
285 }
286 #[cfg(windows)]
287 {
288 return true;
289 }
290 #[cfg(not(any(windows, target_os = "linux", target_os = "macos")))]
291 {
292 false
293 }
275}
294}
276
295
277/// Reading the new exe once lets the virus scanner finish before the restart, which otherwise blocks process start for seconds.
296/// Reading the new exe once lets the virus scanner finish before the restart, which otherwise blocks process start for seconds.
crates/app/src/main_window.rs +4 −3
@@ -1,8 +1,9 @@
1 1 //! Owns the main window so it can be closed into the tray and opened again.
2 2 //!
3 //! GPUI cannot hide a window on Wayland, so on Linux "close to tray" really closes
4 //! the main window while the app (tray, notifications, calls) keeps running; the tray
5 //! or a second start opens a fresh one. Windows hides the window natively instead.
3 //! GPUI cannot hide a window on Wayland, so on Linux (and macOS, which reuses this
4 //! path) "close to tray" really closes the main window while the app (tray,
5 //! notifications, calls) keeps running; the tray or a second start opens a fresh one.
6 //! Windows hides the window natively instead.
6 7
7 8 use std::rc::Rc;
8 9
@@ -1,8 +1,9 @@
1//! Owns the main window so it can be closed into the tray and opened again.
1//! Owns the main window so it can be closed into the tray and opened again.
2//!
2//!
3//! GPUI cannot hide a window on Wayland, so on Linux "close to tray" really closes
3//! GPUI cannot hide a window on Wayland, so on Linux (and macOS, which reuses this
4//! the main window while the app (tray, notifications, calls) keeps running; the tray
4//! path) "close to tray" really closes the main window while the app (tray,
5//! or a second start opens a fresh one. Windows hides the window natively instead.
5//! notifications, calls) keeps running; the tray or a second start opens a fresh one.
6//! Windows hides the window natively instead.
6
7
7use std::rc::Rc;
8use std::rc::Rc;
8
9
crates/app/src/notify/center.rs +4 −4
@@ -359,7 +359,7 @@ impl NotificationCenter {
359 359 pub fn start_in_background(&self, window: &mut Window, cx: &mut App) {
360 360 match (&self.tray, self.main_native) {
361 361 (Some(_), Some(native)) => platform::hide_window(native),
362 #[cfg(target_os = "linux")]
362 #[cfg(any(target_os = "linux", target_os = "macos"))]
363 363 (Some(_), None) => crate::main_window::hide(cx),
364 364 _ => window.minimize_window(),
365 365 }
@@ -374,7 +374,7 @@ impl NotificationCenter {
374 374 platform::hide_window(native);
375 375 true
376 376 }
377 #[cfg(target_os = "linux")]
377 #[cfg(any(target_os = "linux", target_os = "macos"))]
378 378 (true, Some(_), None) => {
379 379 crate::main_window::mark_hiding(cx);
380 380 false
@@ -1552,7 +1552,7 @@ impl NotificationCenter {
1552 1552 if let Some(native) = self.main_native {
1553 1553 platform::hide_window(native);
1554 1554 } else {
1555 #[cfg(target_os = "linux")]
1555 #[cfg(any(target_os = "linux", target_os = "macos"))]
1556 1556 crate::main_window::hide(cx);
1557 1557 }
1558 1558 } else {
@@ -1567,7 +1567,7 @@ impl NotificationCenter {
1567 1567 }
1568 1568
1569 1569 fn raise_main_window(&mut self, cx: &mut Context<Self>) {
1570 #[cfg(target_os = "linux")]
1570 #[cfg(any(target_os = "linux", target_os = "macos"))]
1571 1571 if crate::main_window::is_hidden(cx) {
1572 1572 crate::main_window::show(cx);
1573 1573 return;
@@ -359,7 +359,7 @@ impl NotificationCenter {
359 pub fn start_in_background(&self, window: &mut Window, cx: &mut App) {
359 pub fn start_in_background(&self, window: &mut Window, cx: &mut App) {
360 match (&self.tray, self.main_native) {
360 match (&self.tray, self.main_native) {
361 (Some(_), Some(native)) => platform::hide_window(native),
361 (Some(_), Some(native)) => platform::hide_window(native),
362 #[cfg(target_os = "linux")]
362 #[cfg(any(target_os = "linux", target_os = "macos"))]
363 (Some(_), None) => crate::main_window::hide(cx),
363 (Some(_), None) => crate::main_window::hide(cx),
364 _ => window.minimize_window(),
364 _ => window.minimize_window(),
365 }
365 }
@@ -374,7 +374,7 @@ impl NotificationCenter {
374 platform::hide_window(native);
374 platform::hide_window(native);
375 true
375 true
376 }
376 }
377 #[cfg(target_os = "linux")]
377 #[cfg(any(target_os = "linux", target_os = "macos"))]
378 (true, Some(_), None) => {
378 (true, Some(_), None) => {
379 crate::main_window::mark_hiding(cx);
379 crate::main_window::mark_hiding(cx);
380 false
380 false
@@ -1552,7 +1552,7 @@ impl NotificationCenter {
1552 if let Some(native) = self.main_native {
1552 if let Some(native) = self.main_native {
1553 platform::hide_window(native);
1553 platform::hide_window(native);
1554 } else {
1554 } else {
1555 #[cfg(target_os = "linux")]
1555 #[cfg(any(target_os = "linux", target_os = "macos"))]
1556 crate::main_window::hide(cx);
1556 crate::main_window::hide(cx);
1557 }
1557 }
1558 } else {
1558 } else {
@@ -1567,7 +1567,7 @@ impl NotificationCenter {
1567 }
1567 }
1568
1568
1569 fn raise_main_window(&mut self, cx: &mut Context<Self>) {
1569 fn raise_main_window(&mut self, cx: &mut Context<Self>) {
1570 #[cfg(target_os = "linux")]
1570 #[cfg(any(target_os = "linux", target_os = "macos"))]
1571 if crate::main_window::is_hidden(cx) {
1571 if crate::main_window::is_hidden(cx) {
1572 crate::main_window::show(cx);
1572 crate::main_window::show(cx);
1573 return;
1573 return;
crates/browser/src/process.rs +15 −0
@@ -67,6 +67,11 @@ pub(crate) fn is_chrome_image(image_name: &str) -> bool {
67 67 lowered.starts_with("chrome")
68 68 || lowered.starts_with("google chrome")
69 69 || lowered.starts_with("chromium")
70 || lowered.starts_with("microsoft edge")
71 || lowered.starts_with("msedge")
72 || lowered.starts_with("brave")
73 || lowered.starts_with("helium")
74 || lowered.starts_with("vivaldi")
70 75 }
71 76
72 77 pub(crate) fn is_firefox_image(image_name: &str) -> bool {
@@ -168,6 +173,16 @@ mod tests {
168 173 "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
169 174 ));
170 175 assert!(is_chrome_image("/usr/bin/chromium"));
176 assert!(is_chrome_image(
177 "/Applications/Helium.app/Contents/MacOS/Helium"
178 ));
179 assert!(is_chrome_image(
180 "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
181 ));
182 assert!(is_chrome_image(
183 "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
184 ));
185 assert!(is_chrome_image("Vivaldi"));
171 186 assert!(!is_chrome_image("\"wslrelay.exe\""));
172 187 assert!(!is_chrome_image(
173 188 "/Applications/Firefox.app/Contents/MacOS/firefox"
@@ -67,6 +67,11 @@ pub(crate) fn is_chrome_image(image_name: &str) -> bool {
67 lowered.starts_with("chrome")
67 lowered.starts_with("chrome")
68 || lowered.starts_with("google chrome")
68 || lowered.starts_with("google chrome")
69 || lowered.starts_with("chromium")
69 || lowered.starts_with("chromium")
70 || lowered.starts_with("microsoft edge")
71 || lowered.starts_with("msedge")
72 || lowered.starts_with("brave")
73 || lowered.starts_with("helium")
74 || lowered.starts_with("vivaldi")
70}
75}
71
76
72pub(crate) fn is_firefox_image(image_name: &str) -> bool {
77pub(crate) fn is_firefox_image(image_name: &str) -> bool {
@@ -168,6 +173,16 @@ mod tests {
168 "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
173 "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
169 ));
174 ));
170 assert!(is_chrome_image("/usr/bin/chromium"));
175 assert!(is_chrome_image("/usr/bin/chromium"));
176 assert!(is_chrome_image(
177 "/Applications/Helium.app/Contents/MacOS/Helium"
178 ));
179 assert!(is_chrome_image(
180 "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
181 ));
182 assert!(is_chrome_image(
183 "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
184 ));
185 assert!(is_chrome_image("Vivaldi"));
171 assert!(!is_chrome_image("\"wslrelay.exe\""));
186 assert!(!is_chrome_image("\"wslrelay.exe\""));
172 assert!(!is_chrome_image(
187 assert!(!is_chrome_image(
173 "/Applications/Firefox.app/Contents/MacOS/firefox"
188 "/Applications/Firefox.app/Contents/MacOS/firefox"
docs/decisions/0018-macos-tray-and-close-to-tray.md added +26 −0
@@ -0,0 +1,26 @@
1 ---
2 status: proposed
3 date: 2026-11-15
4 ---
5
6 # ADR 0018: macOS tray and close-to-tray match Linux
7
8 Upstream already shipped Linux desktop toasts as ADR 0015, so this macOS tray note is 0018.
9
10 ## Context
11
12 Linux already has a StatusNotifierItem tray and closes the main window into the tray because GPUI cannot hide a Wayland window (ADR 0012). macOS daily-driver use needs the same affordances: a menu-bar icon with presence / Open / Quit, and Settings → Close to tray. Native window hide is unreliable enough across GPUI versions that reusing the Linux “really close, reopen from tray” path is simpler than a separate Cocoa hide path.
13
14 Windows already uses `tray-icon`; macOS can share that crate instead of inventing a third tray stack.
15
16 ## Decision
17
18 - On macOS, the tray is `tray-icon` (same implementation as Windows).
19 - Close to tray on macOS follows the Linux path: the main window closes for real; the tray (or a second start) opens a fresh one.
20 - Message toasts stay on the existing GPUI / Windows card path for now. macOS Notification Center is a follow-up once the shared desktop-notification policy from the Linux toast work lands.
21
22 ## Consequences
23
24 - One close-to-tray mental model for Linux and macOS.
25 - Signing / notarization still matter for TCC and Gatekeeper; packaging scripts may ship a bare Mach-O or a signed `.app`.
26 - Contributors should not add a macOS-only hide path without revisiting this ADR.
@@ -0,0 +1,26 @@
1---
2status: proposed
3date: 2026-11-15
4---
5
6# ADR 0018: macOS tray and close-to-tray match Linux
7
8Upstream already shipped Linux desktop toasts as ADR 0015, so this macOS tray note is 0018.
9
10## Context
11
12Linux already has a StatusNotifierItem tray and closes the main window into the tray because GPUI cannot hide a Wayland window (ADR 0012). macOS daily-driver use needs the same affordances: a menu-bar icon with presence / Open / Quit, and Settings → Close to tray. Native window hide is unreliable enough across GPUI versions that reusing the Linux “really close, reopen from tray” path is simpler than a separate Cocoa hide path.
13
14Windows already uses `tray-icon`; macOS can share that crate instead of inventing a third tray stack.
15
16## Decision
17
18- On macOS, the tray is `tray-icon` (same implementation as Windows).
19- Close to tray on macOS follows the Linux path: the main window closes for real; the tray (or a second start) opens a fresh one.
20- Message toasts stay on the existing GPUI / Windows card path for now. macOS Notification Center is a follow-up once the shared desktop-notification policy from the Linux toast work lands.
21
22## Consequences
23
24- One close-to-tray mental model for Linux and macOS.
25- Signing / notarization still matter for TCC and Gatekeeper; packaging scripts may ship a bare Mach-O or a signed `.app`.
26- Contributors should not add a macOS-only hide path without revisiting this ADR.
docs/decisions/README.md +2 −1
@@ -33,5 +33,6 @@ Statuses: `proposed`, `accepted`, `superseded`.
33 33 | [0015](0015-linux-desktop-toasts-use-freedesktop-notifications.md) | Linux desktop toasts use freedesktop Notifications |
34 34 | [0016](0016-calendar-week-start-and-time-scale-stay-local.md) | Calendar work hours go to the mailbox, week start and time scale stay local |
35 35 | [0017](0017-guest-orgs-switch-by-restart.md) | Guest orgs, one org per window, switch by restart |
36 | [0018](0018-macos-tray-and-close-to-tray.md) | macOS tray and close-to-tray match Linux |
36 37
37 Records `0001` to `0017` are the decisions already shipped. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.
38 Records `0001` to `0017` are the decisions already shipped. `0018` is proposed with the macOS tray PR. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.
@@ -33,5 +33,6 @@ Statuses: `proposed`, `accepted`, `superseded`.
33| [0015](0015-linux-desktop-toasts-use-freedesktop-notifications.md) | Linux desktop toasts use freedesktop Notifications |
33| [0015](0015-linux-desktop-toasts-use-freedesktop-notifications.md) | Linux desktop toasts use freedesktop Notifications |
34| [0016](0016-calendar-week-start-and-time-scale-stay-local.md) | Calendar work hours go to the mailbox, week start and time scale stay local |
34| [0016](0016-calendar-week-start-and-time-scale-stay-local.md) | Calendar work hours go to the mailbox, week start and time scale stay local |
35| [0017](0017-guest-orgs-switch-by-restart.md) | Guest orgs, one org per window, switch by restart |
35| [0017](0017-guest-orgs-switch-by-restart.md) | Guest orgs, one org per window, switch by restart |
36| [0018](0018-macos-tray-and-close-to-tray.md) | macOS tray and close-to-tray match Linux |
36
37
37Records `0001` to `0017` are the decisions already shipped. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.
38Records `0001` to `0017` are the decisions already shipped. `0018` is proposed with the macOS tray PR. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.
docs/macos-smoke.md added +34 −0
@@ -0,0 +1,34 @@
1 # macOS smoke checklist
2
3 Run on a real Mac (`.app` from `scripts/build-macos.sh` or a release zip). Unit tests on the `macos-arm64` Forgejo runner cover picker frames and browser discovery; this list is the live gate for a daily-driver RC.
4
5 ## Sign-in
6
7 1. No Google Chrome installed (or rename it) — only Helium / Edge / Brave / Vivaldi under `/Applications`.
8 2. Cold start without `--endpoint`: managed browser opens, splash shows a connecting phase, Microsoft login completes.
9 3. Quit and start again: sidebar paints from cache without a spinner wall; browser stays headless.
10 4. Second Dock click focuses the existing window (single instance).
11
12 ## Calls and screen share
13
14 1. Echo / test call: mic and speaker work; hang up cleans up.
15 2. Start screen share: ScreenCaptureKit picker stays open until you pick or cancel (no portal-unavailable flash).
16 3. Pick a display or window: share banner shows; stop share leaves the call up.
17 4. Cancel the picker: no share, call stays connected, no error toast.
18 5. Prefer a second person for 1:1 ring / accept when available (ROADMAP still Partial without that).
19
20 ## Desktop integration
21
22 1. Menu-bar tray icon appears; Open / presence / Quit work.
23 2. Settings → General → Close to tray: close hides/reopens via the tray (new window path like Linux).
24 3. Incoming chat still uses in-app toasts on this branch (Notification Center is a follow-up after the Linux desktop-toast path).
25 4. From an installed `.app` under `/Applications` (or any `*.app/Contents/MacOS/…` path), Settings can offer a self-update when a newer `*-macos-universal` release asset exists.
26
27 ## Packaging
28
29 1. Unsigned local build: TCC prompts for mic / camera / screen when first used.
30 2. Signed + notarized build (when `MACOS_CODESIGN_IDENTITY` / `MACOS_NOTARY_PROFILE` are set): Gatekeeper opens without a right-click override.
31
32 ## Report
33
34 Note OS version, browser used for sign-in, which checklist rows passed, and anything skipped. No real names, chats, ids or tokens in tickets or screenshots — use `--demo` for UI shots.
@@ -0,0 +1,34 @@
1# macOS smoke checklist
2
3Run on a real Mac (`.app` from `scripts/build-macos.sh` or a release zip). Unit tests on the `macos-arm64` Forgejo runner cover picker frames and browser discovery; this list is the live gate for a daily-driver RC.
4
5## Sign-in
6
71. No Google Chrome installed (or rename it) — only Helium / Edge / Brave / Vivaldi under `/Applications`.
82. Cold start without `--endpoint`: managed browser opens, splash shows a connecting phase, Microsoft login completes.
93. Quit and start again: sidebar paints from cache without a spinner wall; browser stays headless.
104. Second Dock click focuses the existing window (single instance).
11
12## Calls and screen share
13
141. Echo / test call: mic and speaker work; hang up cleans up.
152. Start screen share: ScreenCaptureKit picker stays open until you pick or cancel (no portal-unavailable flash).
163. Pick a display or window: share banner shows; stop share leaves the call up.
174. Cancel the picker: no share, call stays connected, no error toast.
185. Prefer a second person for 1:1 ring / accept when available (ROADMAP still Partial without that).
19
20## Desktop integration
21
221. Menu-bar tray icon appears; Open / presence / Quit work.
232. Settings → General → Close to tray: close hides/reopens via the tray (new window path like Linux).
243. Incoming chat still uses in-app toasts on this branch (Notification Center is a follow-up after the Linux desktop-toast path).
254. From an installed `.app` under `/Applications` (or any `*.app/Contents/MacOS/…` path), Settings can offer a self-update when a newer `*-macos-universal` release asset exists.
26
27## Packaging
28
291. Unsigned local build: TCC prompts for mic / camera / screen when first used.
302. Signed + notarized build (when `MACOS_CODESIGN_IDENTITY` / `MACOS_NOTARY_PROFILE` are set): Gatekeeper opens without a right-click override.
31
32## Report
33
34Note OS version, browser used for sign-in, which checklist rows passed, and anything skipped. No real names, chats, ids or tokens in tickets or screenshots — use `--demo` for UI shots.
scripts/build-macos.sh +39 −2
@@ -1,6 +1,13 @@
1 1 #!/usr/bin/env bash
2 2 # Build a universal macOS binary (arm64 + x86_64) from a crate. Needs Xcode CLT only.
3 3 # Wraps it in a .app bundle (icon, Info.plist) and zips that for distribution.
4 # Also keeps the bare lipo binary for self-update (release asset *-macos-universal).
5 #
6 # Optional signing / notarization when Apple credentials are present:
7 # MACOS_CODESIGN_IDENTITY e.g. "Developer ID Application: …"
8 # MACOS_NOTARY_PROFILE notarytool keychain profile (from `xcrun notarytool store-credentials`)
9 # Without those env vars the .app stays unsigned (fine for local / internal RC).
10 #
4 11 # Usage: scripts/build-macos.sh [crate-dir, default crates/app] [binary-or-example-name, default: the crate's only binary]
5 12 set -euo pipefail
6 13 repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -8,6 +15,7 @@ crateDir="$(realpath "${1:-$repoRoot/crates/app}")"
8 15 binaryName="${2:-}"
9 16 export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$repoRoot/target}"
10 17 export PATH="$HOME/.cargo/bin:$PATH"
18 entitlements="$repoRoot/scripts/macos/RustyTeams.entitlements"
11 19 targets=(aarch64-apple-darwin x86_64-apple-darwin)
12 20
13 21 rustup target add "${targets[@]}" >/dev/null
@@ -98,8 +106,37 @@ cp "$iconset/icon_64x64.png" "$iconset/icon_32x32@2x.png"
98 106 cp "$iconset/icon_256x256.png" "$iconset/icon_128x128@2x.png"
99 107 iconutil -c icns "$iconset" -o "$app/Contents/Resources/icon.icns"
100 108
101 # ditto keeps the bundle intact (plain zip would not); the result is the release asset.
109 # Developer ID signing when a certificate is configured in the build environment.
110 if [ -n "${MACOS_CODESIGN_IDENTITY:-}" ]; then
111 echo "codesign with $MACOS_CODESIGN_IDENTITY"
112 codesign --force --options runtime --timestamp \
113 --entitlements "$entitlements" \
114 --sign "$MACOS_CODESIGN_IDENTITY" \
115 "$app/Contents/MacOS/$binary"
116 codesign --force --options runtime --timestamp \
117 --entitlements "$entitlements" \
118 --sign "$MACOS_CODESIGN_IDENTITY" \
119 "$app"
120 codesign --verify --deep --strict --verbose=2 "$app"
121 fi
122
123 # ditto keeps the bundle intact (plain zip would not); the result is the .app release asset.
102 124 ditto -c -k --keepParent "$app" "$outputDirectory/teams-macos.zip"
103 125
126 # Bare universal binary for in-app self-update (Mach-O fat; magic cafe babe).
127 cp "$output" "$outputDirectory/teams-macos-universal"
128 chmod +x "$outputDirectory/teams-macos-universal"
129
130 if [ -n "${MACOS_CODESIGN_IDENTITY:-}" ] && [ -n "${MACOS_NOTARY_PROFILE:-}" ]; then
131 echo "notarize with profile $MACOS_NOTARY_PROFILE"
132 xcrun notarytool submit "$outputDirectory/teams-macos.zip" \
133 --keychain-profile "$MACOS_NOTARY_PROFILE" \
134 --wait
135 xcrun stapler staple "$app"
136 # Re-zip after staple so the published .app zip carries the ticket.
137 ditto -c -k --keepParent "$app" "$outputDirectory/teams-macos.zip"
138 fi
139
104 140 file "$output"
105 ls -la "$output" "$app/Contents/MacOS/$binary" "$outputDirectory/teams-macos.zip"
141 ls -la "$output" "$app/Contents/MacOS/$binary" \
142 "$outputDirectory/teams-macos.zip" "$outputDirectory/teams-macos-universal"
@@ -1,6 +1,13 @@
1#!/usr/bin/env bash
1#!/usr/bin/env bash
2# Build a universal macOS binary (arm64 + x86_64) from a crate. Needs Xcode CLT only.
2# Build a universal macOS binary (arm64 + x86_64) from a crate. Needs Xcode CLT only.
3# Wraps it in a .app bundle (icon, Info.plist) and zips that for distribution.
3# Wraps it in a .app bundle (icon, Info.plist) and zips that for distribution.
4# Also keeps the bare lipo binary for self-update (release asset *-macos-universal).
5#
6# Optional signing / notarization when Apple credentials are present:
7# MACOS_CODESIGN_IDENTITY e.g. "Developer ID Application: …"
8# MACOS_NOTARY_PROFILE notarytool keychain profile (from `xcrun notarytool store-credentials`)
9# Without those env vars the .app stays unsigned (fine for local / internal RC).
10#
4# Usage: scripts/build-macos.sh [crate-dir, default crates/app] [binary-or-example-name, default: the crate's only binary]
11# Usage: scripts/build-macos.sh [crate-dir, default crates/app] [binary-or-example-name, default: the crate's only binary]
5set -euo pipefail
12set -euo pipefail
6repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
13repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -8,6 +15,7 @@ crateDir="$(realpath "${1:-$repoRoot/crates/app}")"
8binaryName="${2:-}"
15binaryName="${2:-}"
9export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$repoRoot/target}"
16export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$repoRoot/target}"
10export PATH="$HOME/.cargo/bin:$PATH"
17export PATH="$HOME/.cargo/bin:$PATH"
18entitlements="$repoRoot/scripts/macos/RustyTeams.entitlements"
11targets=(aarch64-apple-darwin x86_64-apple-darwin)
19targets=(aarch64-apple-darwin x86_64-apple-darwin)
12
20
13rustup target add "${targets[@]}" >/dev/null
21rustup target add "${targets[@]}" >/dev/null
@@ -98,8 +106,37 @@ cp "$iconset/icon_64x64.png" "$iconset/icon_32x32@2x.png"
98cp "$iconset/icon_256x256.png" "$iconset/icon_128x128@2x.png"
106cp "$iconset/icon_256x256.png" "$iconset/icon_128x128@2x.png"
99iconutil -c icns "$iconset" -o "$app/Contents/Resources/icon.icns"
107iconutil -c icns "$iconset" -o "$app/Contents/Resources/icon.icns"
100
108
101# ditto keeps the bundle intact (plain zip would not); the result is the release asset.
109# Developer ID signing when a certificate is configured in the build environment.
110if [ -n "${MACOS_CODESIGN_IDENTITY:-}" ]; then
111 echo "codesign with $MACOS_CODESIGN_IDENTITY"
112 codesign --force --options runtime --timestamp \
113 --entitlements "$entitlements" \
114 --sign "$MACOS_CODESIGN_IDENTITY" \
115 "$app/Contents/MacOS/$binary"
116 codesign --force --options runtime --timestamp \
117 --entitlements "$entitlements" \
118 --sign "$MACOS_CODESIGN_IDENTITY" \
119 "$app"
120 codesign --verify --deep --strict --verbose=2 "$app"
121fi
122
123# ditto keeps the bundle intact (plain zip would not); the result is the .app release asset.
102ditto -c -k --keepParent "$app" "$outputDirectory/teams-macos.zip"
124ditto -c -k --keepParent "$app" "$outputDirectory/teams-macos.zip"
103
125
126# Bare universal binary for in-app self-update (Mach-O fat; magic cafe babe).
127cp "$output" "$outputDirectory/teams-macos-universal"
128chmod +x "$outputDirectory/teams-macos-universal"
129
130if [ -n "${MACOS_CODESIGN_IDENTITY:-}" ] && [ -n "${MACOS_NOTARY_PROFILE:-}" ]; then
131 echo "notarize with profile $MACOS_NOTARY_PROFILE"
132 xcrun notarytool submit "$outputDirectory/teams-macos.zip" \
133 --keychain-profile "$MACOS_NOTARY_PROFILE" \
134 --wait
135 xcrun stapler staple "$app"
136 # Re-zip after staple so the published .app zip carries the ticket.
137 ditto -c -k --keepParent "$app" "$outputDirectory/teams-macos.zip"
138fi
139
104file "$output"
140file "$output"
105ls -la "$output" "$app/Contents/MacOS/$binary" "$outputDirectory/teams-macos.zip"
141ls -la "$output" "$app/Contents/MacOS/$binary" \
142 "$outputDirectory/teams-macos.zip" "$outputDirectory/teams-macos-universal"
scripts/macos/RustyTeams.entitlements added +16 −0
@@ -0,0 +1,16 @@
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3 <plist version="1.0">
4 <dict>
5 <!-- Hardened Runtime for notarization; keep JIT off. -->
6 <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
7 <false/>
8 <key>com.apple.security.device.audio-input</key>
9 <true/>
10 <key>com.apple.security.device.camera</key>
11 <true/>
12 <!-- ScreenCaptureKit system picker; not the legacy screen-capture entitlement alone. -->
13 <key>com.apple.security.cs.disable-library-validation</key>
14 <true/>
15 </dict>
16 </plist>
@@ -0,0 +1,16 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <!-- Hardened Runtime for notarization; keep JIT off. -->
6 <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
7 <false/>
8 <key>com.apple.security.device.audio-input</key>
9 <true/>
10 <key>com.apple.security.device.camera</key>
11 <true/>
12 <!-- ScreenCaptureKit system picker; not the legacy screen-capture entitlement alone. -->
13 <key>com.apple.security.cs.disable-library-validation</key>
14 <true/>
15</dict>
16</plist>