Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(gpui): open onboarding without flashing the main window, match the Space hint to the glass button

Richie McIlroye27a3bda0044
diff --git a/apps/desktop-gpui/src/main.rs b/apps/desktop-gpui/src/main.rs
index fb6b1615e..8a7e21433 100644
--- a/apps/desktop-gpui/src/main.rs
+++ b/apps/desktop-gpui/src/main.rs
@@ -328,6 +328,13 @@ fn main() {
.as_ref()
.and_then(|restore| restore.main_window_bounds(main_size, cx))
.unwrap_or_else(|| Bounds::centered(None, main_size, cx));
+ // A first run always lands in onboarding, and these two flags are a
+ // store read rather than the gate's TCC queries -- so the main window
+ // starts hidden instead of flashing up before onboarding replaces it.
+ // Linux keeps the gate: its main window tracks retained visibility.
+ let first_run = cfg!(not(target_os = "linux"))
+ && (!crate::store::has_completed_startup()
+ || !crate::store::has_completed_onboarding());
let window_handle = cx
.open_window(
WindowOptions {
@@ -373,6 +380,8 @@ fn main() {
},
is_resizable: false,
is_minimizable: cfg!(target_os = "windows"),
+ focus: !first_run,
+ show: !first_run,
..Default::default()
},
{
@@ -430,17 +439,21 @@ fn main() {
// are ~30ms of synchronous XPC on this Mac -- the whole startup delta
// between the 08-17 and 08-18 builds. Both are thread-safe reads, so
// the gate runs off-main and onboarding opens a beat after the main
- // window instead of holding it back.
- cx.spawn(async move |cx| {
- let show_onboarding = cx
- .background_executor()
- .spawn(async { crate::store::should_show_onboarding() })
- .await;
- if show_onboarding {
- cx.update(app_windows::open_onboarding);
- }
- })
- .detach();
+ // window instead of holding it back. A first run skips the gate.
+ if first_run {
+ app_windows::open_onboarding(cx);
+ } else {
+ cx.spawn(async move |cx| {
+ let show_onboarding = cx
+ .background_executor()
+ .spawn(async { crate::store::should_show_onboarding() })
+ .await;
+ if show_onboarding {
+ cx.update(app_windows::open_onboarding);
+ }
+ })
+ .detach();
+ }
// `CAP_GPUI_AUTO_TRAY` / `CAP_GPUI_TRAY_DUMP`: the tray's harness path.
tray::drive_from_env(cx);
// `CAP_GPUI_AUTO_CLOSE=settings|main:<secs>`: run the ⌘W body against
diff --git a/apps/desktop-gpui/src/onboarding_window.rs b/apps/desktop-gpui/src/onboarding_window.rs
index cdee4fea2..a95f130bb 100644
--- a/apps/desktop-gpui/src/onboarding_window.rs
+++ b/apps/desktop-gpui/src/onboarding_window.rs
@@ -927,6 +927,25 @@ impl OnboardingWindow {
let button_text = glass
.map(|material| Hsla::from(material.text))
.unwrap_or_else(|| rgb(0x161b26).into());
+ // The hint under the label tracks the label: on the Liquid Glass
+ // control that text is light, so the white button's navy would vanish.
+ let hint_text = button_text.opacity(0.58);
+ let (kbd_text, kbd_border, kbd_fill) = match glass {
+ Some(_) => (
+ button_text,
+ button_text.opacity(0.3),
+ gpui::transparent_black(),
+ ),
+ None => (
+ Hsla::from(theme.gray_11),
+ Hsla::from(theme.gray_6),
+ if theme.is_dark() {
+ Hsla::from(theme.body_fill(3))
+ } else {
+ gpui::white()
+ },
+ ),
+ };
let logo = img("onboarding/logo.svg")
.w(px(80.))
.h(px(96.))
@@ -1018,24 +1037,20 @@ impl OnboardingWindow {
.justify_center()
.gap(px(4.))
.child(
- copy("Click here, or press", 11., rgba(0x161b2694))
+ copy("Click here, or press", 11., hint_text)
.font_weight(FontWeight::NORMAL)
.line_height(px(14.)),
)
.child(
- copy("Space", 10., theme.gray_11)
+ copy("Space", 10., kbd_text)
.font_weight(FontWeight::MEDIUM)
.line_height(px(14.))
.px(px(4.))
.py(px(1.))
.rounded(px(3.))
.border_1()
- .border_color(theme.gray_6)
- .bg(if theme.is_dark() {
- theme.body_fill(3)
- } else {
- gpui::white()
- }),
+ .border_color(kbd_border)
+ .bg(kbd_fill),
),
),
)