Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix: commit tray mode on pointer-up and scope the update harness
Ilya1b9edc9e95d9
diff --git a/apps/desktop-gpui/src/tray.rs b/apps/desktop-gpui/src/tray.rsindex 930ea3343..07759f849 100644--- a/apps/desktop-gpui/src/tray.rs+++ b/apps/desktop-gpui/src/tray.rs@@ -1569,7 +1569,7 @@ mod mac {menu_item.setKeyEquivalentModifierMask(NSEventModifierFlags::Command);}if *item == Some(TrayItem::Quit) {- menu_item.setKeyEquivalent(&NSString::from_str("Q"));+ menu_item.setKeyEquivalent(&NSString::from_str("q"));menu_item.setKeyEquivalentModifierMask(NSEventModifierFlags::Command);}// Previous's rows are photo thumbnails; every other iconed rowdiff --git a/apps/desktop-gpui/src/tray/mac_mode_picker.rs b/apps/desktop-gpui/src/tray/mac_mode_picker.rsindex dcc6d3d55..84458af3b 100644--- a/apps/desktop-gpui/src/tray/mac_mode_picker.rs+++ b/apps/desktop-gpui/src/tray/mac_mode_picker.rs@@ -99,6 +99,7 @@ impl PillAccessibilityElement {struct PickerIvars {selected: Cell<usize>,focused: Cell<Option<usize>>,+ pressed: Cell<Option<usize>>,flash: Cell<bool>,/// `actions` index of the first pill; pill `i` posts `tag_base + i`.tag_base: isize,@@ -177,10 +178,15 @@ define_class!(#[unsafe(method(mouseDown:))]fn mouse_down(&self, event: &NSEvent) {- // Commit and update the visuals in the same event: a release- // outside the menu never reaches this view, which used to leave- // the subtitle showing a mode that was never applied.- if let Some(i) = self.pill_at(event) {+ // Only remember the press. The selection and the commit happen+ // together on mouse-up, so a release that never reaches this view+ // cannot leave the picker showing an unapplied mode.+ self.ivars().pressed.set(self.pill_at(event));+ }++ #[unsafe(method(mouseUp:))]+ fn mouse_up(&self, _event: &NSEvent) {+ if let Some(i) = self.ivars().pressed.take() {self.choose(i);}}@@ -198,6 +204,7 @@ impl ModePickerView {let this = mtm.alloc::<Self>().set_ivars(PickerIvars {selected: Cell::new(selected),focused: Cell::new(None),+ pressed: Cell::new(None),flash: Cell::new(false),tag_base,capsule: RefCell::new(None),diff --git a/apps/desktop-gpui/src/updates.rs b/apps/desktop-gpui/src/updates.rsindex f4834e189..cf24d93b6 100644--- a/apps/desktop-gpui/src/updates.rs+++ b/apps/desktop-gpui/src/updates.rs@@ -263,42 +263,50 @@ fn busy_alert(cx: &mut App) {.detach();}-/// `CAP_GPUI_AUTO_UPDATE=<state>`: skip the network check and put the menu-/// into a fixed update state for verification.-///-/// States: `checking`, `downloading:<version>[:<fraction>]`, `ready:<version>`,-/// `installing:<version>`, `installed:<version>`.-fn harness_status() -> Option<UpdateStatus> {+/// `CAP_GPUI_AUTO_UPDATE=<version>` (debug builds only): skip the network+/// check and play a fake download of a newer version, then stop at Ready+/// without installing anything.+#[cfg(debug_assertions)]+fn harness_update_version() -> Option<Version> {let value = std::env::var("CAP_GPUI_AUTO_UPDATE").ok()?;- let mut parts = value.split(':');- let state = parts.next()?;- let version = |parts: &mut std::str::Split<'_, char>| {- parts.next().and_then(|value| Version::parse(value).ok())- };- match state {- "checking" => Some(UpdateStatus::Checking),- "downloading" => {- let version = version(&mut parts)?;- let fraction = parts.next().and_then(|value| value.parse::<f32>().ok());- Some(UpdateStatus::Downloading { version, fraction })- }- "ready" => Some(UpdateStatus::Ready {- version: version(&mut parts)?,- }),- "installing" => Some(UpdateStatus::Installing {- version: version(&mut parts)?,- }),- "installed" => Some(UpdateStatus::Installed {- version: version(&mut parts)?,- executable: PathBuf::from("/Applications/Cap.app"),- }),- _ => {- tracing::warn!(value, "CAP_GPUI_AUTO_UPDATE: unknown state");- None- }+ let version = Version::parse(&value).ok()?;+ if current_version().is_ok_and(|current| version > current) {+ Some(version)+ } else {+ tracing::warn!(+ version = %version,+ "CAP_GPUI_AUTO_UPDATE must be newer than the running version"+ );+ None}}+#[cfg(debug_assertions)]+fn simulate_update(version: Version, cx: &mut App) {+ cx.spawn(async move |cx| {+ cx.background_executor()+ .timer(Duration::from_millis(400))+ .await;+ cx.update(|cx| set_status(UpdateStatus::Checking, cx));+ for step in 0..=10u8 {+ cx.background_executor()+ .timer(Duration::from_millis(120))+ .await;+ cx.update(|cx| {+ set_status(+ UpdateStatus::Downloading {+ version: version.clone(),+ fraction: Some(step as f32 / 10.0),+ },+ cx,+ );+ });+ }+ cx.update(|cx| set_status(UpdateStatus::Ready { version }, cx));+ })+ .detach();+}+pub(crate) fn schedule_startup_check(cx: &mut App) {let (wake, requests) = flume::bounded(1);cx.set_global(UpdateScheduler {@@ -311,8 +319,9 @@ pub(crate) fn schedule_startup_check(cx: &mut App) {download_epoch: 0,});- if let Some(status) = harness_status() {- set_status(status, cx);+ #[cfg(debug_assertions)]+ if let Some(version) = harness_update_version() {+ simulate_update(version, cx);return;}