Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(desktop-gpui): closing the sign-in prompt only cancels the sign-in it started

Richie McIlroydd397e9c9d88
diff --git a/apps/desktop-gpui/src/main_window.rs b/apps/desktop-gpui/src/main_window.rs
index c72418869..831878bbd 100644
--- a/apps/desktop-gpui/src/main_window.rs
+++ b/apps/desktop-gpui/src/main_window.rs
@@ -2868,8 +2868,13 @@ impl MainWindow {
if self.sign_in_prompt.take().is_none() {
return;
}
+ // Only the attempt this prompt started; one from Settings or an
+ // editor keeps running.
let sign_in = SignIn::global(cx);
- if sign_in.read(cx).is_pending() {
+ if matches!(
+ sign_in.read(cx).pending_origin(),
+ Some(SignInOrigin::Overlay(_))
+ ) {
sign_in.update(cx, |sign_in, cx| sign_in.cancel(cx));
}
cx.notify();
diff --git a/apps/desktop-gpui/src/sign_in.rs b/apps/desktop-gpui/src/sign_in.rs
index 04b08781f..dd49f994a 100644
--- a/apps/desktop-gpui/src/sign_in.rs
+++ b/apps/desktop-gpui/src/sign_in.rs
@@ -73,6 +73,10 @@ impl SignIn {
self.attempt.is_some()
}
+ pub fn pending_origin(&self) -> Option<SignInOrigin> {
+ self.attempt.as_ref().map(|attempt| attempt.origin)
+ }
+
/// Open the browser sign-in. A second call while an attempt is pending
/// re-opens that attempt's page (the user may have closed the tab) and
/// moves the attempt to the newer origin.