forge
Explore
Log in

Don't you dare go Hollow

Build status in the sidebar: a row above your name shows Building n/5, Done, Build failed or Cancelled with a progress line, and opens a popover with both lanes, per-job timers, total time, Open Releases and Cancel/Dismiss. Every job row now has its own timer (seconds follow the clock setting). 💄 style: per-release Required switch is labeled

Browse files at this commit

9bc7ef65111efbe3b993b36301c472a018c2be3fAhmet Kaan GümüşParent: 2d06f82
  • feat
    • build status in the sidebar: a row above your name shows Building n/5, Done, Build failed or Cancelled with a progress line, and opens a popover with both lanes, per-job timers, total time, Open Releases and Cancel/Dismiss. Every job row now has its own timer (seconds follow the clock setting). 💄 style: per-release Required switch is labeled
Show full message
✨ feat: build status in the sidebar: a row above your name shows Building n/5, Done, Build failed or Cancelled with a progress line, and opens a popover with both lanes, per-job timers, total time, Open Releases and Cancel/Dismiss. Every job row now has its own timer (seconds follow the clock setting). 💄 style: per-release Required switch is labeled
crates/client/lang/en/builder_release.txtmodified+5 -0
@@ -23,3 +23,8 @@ this_machine = This machine
23 prepare = Prepare23 prepare = Prepare
24 windows_v1 = Windows v124 windows_v1 = Windows v1
25 windows_v3 = Windows v325 windows_v3 = Windows v3
26+building = Building
27+build_failed = Build failed
28+cancelled = Cancelled
29+open_releases = Open Releases
30+dismiss = Dismiss
crates/client/lang/tr/builder_release.txtmodified+5 -0
@@ -23,3 +23,8 @@ this_machine = Bu makine
23 prepare = Hazırlık23 prepare = Hazırlık
24 windows_v1 = Windows v124 windows_v1 = Windows v1
25 windows_v3 = Windows v325 windows_v3 = Windows v3
26+building = Derleniyor
27+build_failed = Derleme başarısız
28+cancelled = İptal edildi
29+open_releases = Sürümleri aç
30+dismiss = Kapat
crates/client/src/gui/builder/releases.rsmodified+263 -30
@@ -3,23 +3,28 @@ use common::{
3 model::{ReleaseInfo, Staged},3 model::{ReleaseInfo, Staged},
4 };4 };
5 use gpui_kit::{5 use gpui_kit::{
6- AnyElement, Context, Div, Entity, Hsla, IntoElement, ParentElement, PathPromptOptions, Styled,6+ Anchor, AnyElement, Context, Div, Entity, Hsla, IntoElement, ParentElement, PathPromptOptions,
7- Window, div, px,7+ Styled, Window, component::popover::Popover, div, px,
8 };8 };
9 use std::path::PathBuf;9 use std::path::PathBuf;
10+use std::time::{Duration, Instant};
10 11
11 use super::ui::{card, card_header, confirmed, delete_icon_button, list_row, rows_body};12 use super::ui::{card, card_header, confirmed, delete_icon_button, list_row, rows_body};
13+use crate::gui::builder::BuilderTab;
14+use crate::gui::chat::View;
12 use crate::gui::{15 use crate::gui::{
13- Palette, Yumush, entity_action, millis_time, notify_error,16+ Palette, Trigger, Yumush, entity_action, hoverable, millis_time, notify_error,
14 parts::{self, Fill, Press},17 parts::{self, Fill, Press},
18+ profile::yumush_action,
15 storage,19 storage,
16- style::{space, text},20+ style::{radius, size, space, text},
17 text,21 text,
18 };22 };
19 use crate::lang::w;23 use crate::lang::w;
20 use crate::release::{Build, Event, Job, LANES, Lane, Level, is_source};24 use crate::release::{Build, Event, Job, LANES, Lane, Level, is_source};
21 25
22 const METER: f32 = 140.;26 const METER: f32 = 140.;
27+const TICK: Duration = Duration::from_secs(1);
23 28
24 #[derive(Default)]29 #[derive(Default)]
25 pub(crate) struct Desk {30 pub(crate) struct Desk {
@@ -34,12 +39,54 @@ pub(crate) struct Desk {
34 failed: bool,39 failed: bool,
35 cancelled: bool,40 cancelled: bool,
36 auto_publish: bool,41 auto_publish: bool,
42+ began: Option<Instant>,
43+ ended: Option<Instant>,
44+ dismissed: bool,
37 }45 }
38 46
39 struct Row {47 struct Row {
40 job: Job,48 job: Job,
41 phase: Phase,49 phase: Phase,
42 line: String,50 line: String,
51+ started: Option<Instant>,
52+ ended: Option<Instant>,
53+}
54+
55+#[derive(Clone, Copy, PartialEq, Eq)]
56+enum Status {
57+ Running,
58+ Done,
59+ Failed,
60+ Cancelled,
61+}
62+
63+impl Row {
64+ fn share(&self) -> f32 {
65+ match self.phase {
66+ Phase::Waiting => 0.,
67+ Phase::Running { done, total } if total > 0 => done as f32 / total as f32,
68+ Phase::Running { .. } => 0.,
69+ Phase::Done | Phase::Skipped(_) | Phase::Failed(_) => 1.,
70+ }
71+ }
72+
73+ fn finished(&self) -> bool {
74+ matches!(self.phase, Phase::Done | Phase::Skipped(_))
75+ }
76+}
77+
78+fn span(from: Option<Instant>, to: Option<Instant>, seconds: bool) -> Option<String> {
79+ let total = to
80+ .unwrap_or_else(Instant::now)
81+ .duration_since(from?)
82+ .as_secs();
83+ let (hours, minutes, rest) = (total / 3600, total / 60 % 60, total % 60);
84+ Some(match (seconds, hours) {
85+ (true, 0) => format!("{minutes}:{rest:02}"),
86+ (true, _) => format!("{hours}:{minutes:02}:{rest:02}"),
87+ (false, 0) => format!("{minutes}m"),
88+ (false, _) => format!("{hours}h {minutes:02}m"),
89+ })
43 }90 }
44 91
45 enum Phase {92 enum Phase {
@@ -88,6 +135,25 @@ impl Desk {
88 fn row(&mut self, job: Job) -> Option<&mut Row> {135 fn row(&mut self, job: Job) -> Option<&mut Row> {
89 self.jobs.iter_mut().find(|row| row.job == job)136 self.jobs.iter_mut().find(|row| row.job == job)
90 }137 }
138+
139+ fn status(&self) -> Option<Status> {
140+ if self.jobs.is_empty() || self.dismissed {
141+ return None;
142+ }
143+ Some(if self.build.is_some() {
144+ Status::Running
145+ } else if self.failed {
146+ Status::Failed
147+ } else if self.cancelled {
148+ Status::Cancelled
149+ } else {
150+ Status::Done
151+ })
152+ }
153+
154+ fn share(&self) -> f32 {
155+ self.jobs.iter().map(Row::share).sum::<f32>() / self.jobs.len().max(1) as f32
156+ }
91 }157 }
92 158
93 fn job_label(job: Job) -> &'static str {159 fn job_label(job: Job) -> &'static str {
@@ -126,7 +192,7 @@ pub(super) fn meter(share: f32, label: String, palette: Palette) -> Div {
126 .child(caption_text(label, palette.muted))192 .child(caption_text(label, palette.muted))
127 }193 }
128 194
129-fn job_row(row: &Row, palette: Palette) -> Div {195+fn job_row(row: &Row, seconds: bool, palette: Palette) -> Div {
130 let (status, detail): (Div, Option<Div>) = match &row.phase {196 let (status, detail): (Div, Option<Div>) = match &row.phase {
131 Phase::Waiting => (197 Phase::Waiting => (
132 caption_text(w().builder_release.waiting, palette.muted),198 caption_text(w().builder_release.waiting, palette.muted),
@@ -171,6 +237,9 @@ fn job_row(row: &Row, palette: Palette) -> Div {
171 .children(detail.map(|detail| detail.truncate())),237 .children(detail.map(|detail| detail.truncate())),
172 )238 )
173 .child(status)239 .child(status)
240+ .children(
241+ span(row.started, row.ended, seconds).map(|time| caption_text(time, palette.muted)),
242+ )
174 }243 }
175 244
176 fn draft_row(draft: &Draft, duplicate: bool, entity: &Entity<Yumush>, palette: Palette) -> Div {245 fn draft_row(draft: &Draft, duplicate: bool, entity: &Entity<Yumush>, palette: Palette) -> Div {
@@ -251,8 +320,9 @@ fn release_row(
251 )320 )
252 .into_any_element()321 .into_any_element()
253 } else {322 } else {
254- parts::toggle(323+ parts::labeled_toggle(
255 format!("release_required_{seq}"),324 format!("release_required_{seq}"),
325+ w().builder_release.required,
256 required,326 required,
257 palette.tokens,327 palette.tokens,
258 entity_action(entity, move |yumush, window, cx| {328 entity_action(entity, move |yumush, window, cx| {
@@ -354,28 +424,7 @@ impl Yumush {
354 cx.notify();424 cx.notify();
355 }),425 }),
356 );426 );
357- let lanes: Vec<Div> = LANES427+ let lanes = self.lanes(|row| row, palette);
358- .iter()
359- .filter(|(_, jobs)| self.desk.jobs.iter().any(|row| jobs.contains(&row.job)))
360- .map(|(lane, jobs)| {
361- div()
362- .flex()
363- .flex_col()
364- .child(
365- list_row()
366- .text_size(text(text::LABEL))
367- .text_color(palette.muted)
368- .child(lane_label(*lane)),
369- )
370- .children(
371- self.desk
372- .jobs
373- .iter()
374- .filter(|row| jobs.contains(&row.job))
375- .map(|row| job_row(row, palette).pl(px(space::XL))),
376- )
377- })
378- .collect();
379 428
380 card(palette)429 card(palette)
381 .child(430 .child(
@@ -405,6 +454,162 @@ impl Yumush {
405 )454 )
406 }455 }
407 456
457+ fn lanes(&self, fit: impl Fn(Div) -> Div, palette: Palette) -> Vec<Div> {
458+ let seconds = self.settings.clock_seconds;
459+ LANES
460+ .iter()
461+ .filter(|(_, jobs)| self.desk.jobs.iter().any(|row| jobs.contains(&row.job)))
462+ .map(|(lane, jobs)| {
463+ div()
464+ .flex()
465+ .flex_col()
466+ .child(fit(list_row()
467+ .text_size(text(text::LABEL))
468+ .text_color(palette.muted)
469+ .child(lane_label(*lane))))
470+ .children(
471+ self.desk
472+ .jobs
473+ .iter()
474+ .filter(|row| jobs.contains(&row.job))
475+ .map(|row| fit(job_row(row, seconds, palette).pl(px(space::XL)))),
476+ )
477+ })
478+ .collect()
479+ }
480+
481+ pub(in crate::gui) fn build_control(
482+ &self,
483+ entity: &Entity<Self>,
484+ palette: Palette,
485+ ) -> Option<AnyElement> {
486+ let status = self.desk.status()?;
487+ let w = &w().builder_release;
488+ let t = palette.tokens;
489+ let seconds = self.settings.clock_seconds;
490+ let label = match status {
491+ Status::Running => w.building,
492+ Status::Done => w.done,
493+ Status::Failed => w.build_failed,
494+ Status::Cancelled => w.cancelled,
495+ };
496+ let aside = match status {
497+ Status::Running => format!(
498+ "{} / {}",
499+ self.desk.jobs.iter().filter(|row| row.finished()).count(),
500+ self.desk.jobs.len()
501+ ),
502+ _ => span(self.desk.began, self.desk.ended, seconds).unwrap_or_default(),
503+ };
504+ let failed = status == Status::Failed;
505+ let trigger = hoverable(
506+ "build_trigger",
507+ div()
508+ .flex()
509+ .flex_col()
510+ .gap(px(space::XS))
511+ .py(px(space::XS))
512+ .px(px(space::SM))
513+ .rounded(px(radius::MD))
514+ .child(
515+ div()
516+ .flex()
517+ .justify_between()
518+ .text_size(text(text::LABEL))
519+ .child(
520+ div()
521+ .text_color(if failed { palette.danger } else { palette.text })
522+ .child(label),
523+ )
524+ .child(div().text_color(palette.muted).child(aside)),
525+ )
526+ .child(parts::track(Fill::Part(self.desk.share()), failed, t)),
527+ palette,
528+ );
529+ let entity = entity.clone();
530+ Some(
531+ Popover::new("build_status")
532+ .anchor(Anchor::BottomLeft)
533+ .appearance(false)
534+ .trigger(Trigger::new(trigger))
535+ .content(move |_, _, cx| {
536+ let popover = cx.entity();
537+ let palette = crate::gui::palette(cx);
538+ entity.read(cx).build_sheet(&entity, &popover, palette)
539+ })
540+ .into_any_element(),
541+ )
542+ }
543+
544+ fn build_sheet(
545+ &self,
546+ entity: &Entity<Self>,
547+ popover: &Entity<gpui_kit::component::popover::PopoverState>,
548+ palette: Palette,
549+ ) -> Div {
550+ let w = &w().builder_release;
551+ let running = self.desk.build.is_some();
552+ let total = span(
553+ self.desk.began,
554+ self.desk.ended,
555+ self.settings.clock_seconds,
556+ );
557+ let open = parts::button(
558+ "build_open_releases",
559+ w.open_releases,
560+ Press::Plain,
561+ palette.tokens,
562+ yumush_action(entity, popover, |yumush, window, cx| {
563+ yumush.show_view(View::Builder, window, cx);
564+ yumush.select_builder_tab(BuilderTab::Releases, window, cx);
565+ }),
566+ );
567+ let close = if running {
568+ parts::button(
569+ "build_sheet_cancel",
570+ w.cancel,
571+ Press::Danger,
572+ palette.tokens,
573+ yumush_action(entity, popover, |yumush, _, cx| yumush.cancel_build(cx)),
574+ )
575+ } else {
576+ parts::button(
577+ "build_sheet_dismiss",
578+ w.dismiss,
579+ Press::Plain,
580+ palette.tokens,
581+ yumush_action(entity, popover, |yumush, _, cx| {
582+ yumush.desk.dismissed = true;
583+ cx.notify();
584+ }),
585+ )
586+ };
587+ parts::popover(palette.tokens)
588+ .w(px(size::SHEET))
589+ .p(px(space::MD))
590+ .child(
591+ div()
592+ .flex()
593+ .justify_between()
594+ .pb(px(space::XS))
595+ .text_size(text(text::LABEL))
596+ .child(div().text_color(palette.text).child(w.build))
597+ .children(total.map(|time| div().text_color(palette.muted).child(time))),
598+ )
599+ .children(self.lanes(
600+ |row| row.min_h(px(size::CONTROL)).py(px(space::XXS)),
601+ palette,
602+ ))
603+ .child(
604+ div()
605+ .pt(px(space::SM))
606+ .flex()
607+ .justify_between()
608+ .child(open)
609+ .child(close),
610+ )
611+ }
612+
408 fn draft_card(&self, entity: &Entity<Self>, palette: Palette) -> Div {613 fn draft_card(&self, entity: &Entity<Self>, palette: Palette) -> Div {
409 let drafts = &self.desk.drafts;614 let drafts = &self.desk.drafts;
410 let rows: Vec<Div> = drafts615 let rows: Vec<Div> = drafts
@@ -514,8 +719,13 @@ impl Yumush {
514 job,719 job,
515 phase: Phase::Waiting,720 phase: Phase::Waiting,
516 line: String::new(),721 line: String::new(),
722+ started: None,
723+ ended: None,
517 })724 })
518 .collect();725 .collect();
726+ self.desk.began = Some(Instant::now());
727+ self.desk.ended = None;
728+ self.desk.dismissed = false;
519 self.desk.failed = false;729 self.desk.failed = false;
520 self.desk.cancelled = false;730 self.desk.cancelled = false;
521 self.desk.auto_publish = false;731 self.desk.auto_publish = false;
@@ -533,6 +743,20 @@ impl Yumush {
533 }743 }
534 })744 })
535 .detach();745 .detach();
746+ cx.spawn_in(window, async move |this, cx| {
747+ loop {
748+ cx.background_executor().timer(TICK).await;
749+ let running = this.update_in(cx, |yumush, window, cx| {
750+ cx.notify();
751+ window.refresh();
752+ yumush.desk.build.is_some()
753+ });
754+ if !matches!(running, Ok(true)) {
755+ break;
756+ }
757+ }
758+ })
759+ .detach();
536 cx.notify();760 cx.notify();
537 }761 }
538 762
@@ -565,18 +789,27 @@ impl Yumush {
565 }789 }
566 Event::Done => {790 Event::Done => {
567 self.desk.build = None;791 self.desk.build = None;
792+ self.desk.ended = Some(Instant::now());
568 self.desk.auto_publish =793 self.desk.auto_publish =
569 !self.desk.failed && !self.desk.cancelled && !self.desk.drafts.is_empty();794 !self.desk.failed && !self.desk.cancelled && !self.desk.drafts.is_empty();
570 self.try_auto_publish(window, cx);795 self.try_auto_publish(window, cx);
571 }796 }
572 }797 }
798+ window.refresh();
573 cx.notify();799 cx.notify();
574 }800 }
575 801
576 fn set_phase(&mut self, job: Job, phase: Phase) {802 fn set_phase(&mut self, job: Job, phase: Phase) {
577- if let Some(row) = self.desk.row(job) {803+ let Some(row) = self.desk.row(job) else {
578- row.phase = phase;804+ return;
805+ };
806+ let now = Some(Instant::now());
807+ match phase {
808+ Phase::Running { .. } => row.started = row.started.or(now),
809+ Phase::Waiting => {}
810+ Phase::Done | Phase::Skipped(_) | Phase::Failed(_) => row.ended = now,
579 }811 }
812+ row.phase = phase;
580 }813 }
581 814
582 fn try_auto_publish(&mut self, window: &mut Window, cx: &mut Context<Self>) {815 fn try_auto_publish(&mut self, window: &mut Window, cx: &mut Context<Self>) {
crates/client/src/gui/sidebar.rsmodified+1 -0
@@ -217,6 +217,7 @@ impl Yumush {
217 |list, f| fade(list, f).flex_1().min_h_0(),217 |list, f| fade(list, f).flex_1().min_h_0(),
218 ),218 ),
219 )219 )
220+ .children(self.build_control(entity, palette))
220 .children(self.account_row(entity, palette))221 .children(self.account_row(entity, palette))
221 .into_any_element()222 .into_any_element()
222 }223 }