Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/desktop-gpui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ mod meetings;
mod meetings_ui;
mod menus;
mod mode_select_window;
mod network_health;
mod notifications;
mod onboarding_audio;
mod onboarding_doodles;
Expand Down Expand Up @@ -564,6 +565,7 @@ fn main() {
single_instance::init_linux_reopen(cx);
updates::schedule_startup_check(cx);
app_windows::schedule_launch_render_warmup(cx);
network_health::schedule_startup_check(cx);
upload::queue::init(cx);
upload::instant_cleanup::init(cx);
automation::init(cx);
Expand Down
74 changes: 74 additions & 0 deletions apps/desktop-gpui/src/main_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4182,6 +4182,10 @@ impl MainWindow {
},
)),
)
.when_some(
self.render_upload_health_indicator(cx),
|this, indicator| this.child(indicator),
)
.when(
self.session.read(cx).editor_recording_target().is_none(),
|this| this.child(self.render_plan_badge()),
Expand Down Expand Up @@ -4223,6 +4227,76 @@ impl MainWindow {
actions
}

fn render_upload_health_indicator(&self, cx: &mut Context<Self>) -> Option<gpui::AnyElement> {
use crate::network_health::{UploadHealthTone, status, upload_health_summary};

let theme = self.theme;
let keyboard_nav = self.keyboard_nav;
let summary = upload_health_summary(&status())?;
let disabled = summary.disabled;
let label = summary.label;
let tooltip_text = summary.tooltip;
let (border_color, bg_color, text_color, dot_color) = match summary.tone {
UploadHealthTone::Healthy => (theme.gray_5, theme.gray_2, theme.gray_11, rgb(0x22c55e)),
UploadHealthTone::Warning => {
(theme.amber_6, theme.amber_3, theme.amber_11, theme.amber_11)
}
UploadHealthTone::Danger => (theme.red_4, theme.red_3, theme.red_11, theme.red_9),
UploadHealthTone::Neutral => (theme.gray_5, theme.gray_2, theme.gray_11, theme.gray_9),
};
let tone = summary.tone;

Some(
div()
.id("upload-health-indicator")
.group("upload-health-indicator")
.when(cfg!(target_os = "windows"), |this| this.occlude())
.when(!disabled && keyboard_nav, ui::keyboard_nav::stop)
.role(gpui::Role::Button)
.aria_label(label.clone())
.flex()
.items_center()
.gap(px(5.))
.h(px(20.))
.max_w(px(124.))
.px(px(6.))
.flex_shrink_0()
.rounded_full()
.border_1()
.border_color(border_color)
.bg(bg_color)
.text_color(text_color)
.text_size(px(10.))
.line_height(px(12.))
.font_weight(FontWeight::MEDIUM)
.when(!disabled, |this| {
this.cursor_pointer().hover(move |style| match tone {
UploadHealthTone::Healthy | UploadHealthTone::Neutral => {
style.bg(theme.gray_3).text_color(theme.gray_12)
}
UploadHealthTone::Warning => style.border_color(theme.amber_11),
UploadHealthTone::Danger => style.border_color(theme.red_9),
})
})
.tooltip(move |_, cx| ui::Tooltip::new(&theme, tooltip_text.clone()).view(cx))
.tooltip_show_delay(ui::TOOLTIP_SHOW_DELAY)
.child(
div()
.size(px(6.))
.rounded_full()
.flex_shrink_0()
.bg(dot_color),
)
.child(div().truncate().child(label))
.when(!disabled, |this| {
this.on_click(cx.listener(|_, _, _window, cx| {
crate::network_health::run_upload_health_check(cx);
}))
})
.into_any_element(),
)
}

/// Notes, labelled like Library beside it. Opens the note being
/// recorded when there is one, else the notes home.
fn render_notes_button(&self, cx: &mut Context<Self>) -> impl IntoElement {
Expand Down
Loading