forge
Explore
Log in

Don't you dare go Hollow

Click a build job to open its full log in a popover with live search (newest at the bottom, long lines scroll sideways)

Browse files at this commit

4e8177afbf7941fd0caed7b5fe222e272ab9db6fAhmet Kaan GümüşParent: 92726cc
  • feat
    • click a build job to open its full log in a popover with live search (newest at the bottom, long lines scroll sideways)
    • every job keeps up to 50k lines
Show full message
✨ feat: click a build job to open its full log in a popover with live search (newest at the bottom, long lines scroll sideways); every job keeps up to 50k lines
crates/client/src/gui.rsmodified+5 -0
@@ -614,6 +614,8 @@ pub struct Yumush {
614 pending_backup_delete: Option<String>,614 pending_backup_delete: Option<String>,
615 update: crate::update::Phase,615 update: crate::update::Phase,
616 desk: builder::releases::Desk,616 desk: builder::releases::Desk,
617+ log_search: Entity<InputState>,
618+ log_scroll: gpui_kit::UniformListScrollHandle,
617 share_apps: Vec<crate::share::audio::AudioApp>,619 share_apps: Vec<crate::share::audio::AudioApp>,
618 share_apps_seen: std::cell::Cell<Instant>,620 share_apps_seen: std::cell::Cell<Instant>,
619 share_apps_task: Option<gpui_kit::Task<()>>,621 share_apps_task: Option<gpui_kit::Task<()>>,
@@ -690,6 +692,7 @@ impl Yumush {
690 692
691 let server = network.server();693 let server = network.server();
692 let account_filter = new_input(w().auth.find_account, window, cx);694 let account_filter = new_input(w().auth.find_account, window, cx);
695+ let log_search = new_input(w().chat.find, window, cx);
693 cx.subscribe(&account_filter, |_, _, event: &InputEvent, cx| {696 cx.subscribe(&account_filter, |_, _, event: &InputEvent, cx| {
694 if matches!(event, InputEvent::Change) {697 if matches!(event, InputEvent::Change) {
695 cx.notify();698 cx.notify();
@@ -716,6 +719,8 @@ impl Yumush {
716 pending_backup_delete: None,719 pending_backup_delete: None,
717 update: crate::update::Phase::Idle,720 update: crate::update::Phase::Idle,
718 desk: builder::releases::Desk::default(),721 desk: builder::releases::Desk::default(),
722+ log_search,
723+ log_scroll: gpui_kit::UniformListScrollHandle::new(),
719 share_apps: Vec::new(),724 share_apps: Vec::new(),
720 share_apps_seen: std::cell::Cell::new(Instant::now()),725 share_apps_seen: std::cell::Cell::new(Instant::now()),
721 share_apps_task: None,726 share_apps_task: None,
crates/client/src/gui/builder/releases.rsmodified+118 -22
@@ -3,10 +3,12 @@ use common::{
3 model::{ReleaseInfo, Staged},3 model::{ReleaseInfo, Staged},
4 };4 };
5 use gpui_kit::{5 use gpui_kit::{
6- Anchor, AnyElement, Context, Div, Entity, Hsla, IntoElement, ParentElement, PathPromptOptions,6+ Anchor, AnyElement, App, Context, Div, Entity, Focusable, Hsla, InteractiveElement,
7+ IntoElement, ListHorizontalSizingBehavior, ParentElement, PathPromptOptions, ScrollStrategy,
7 Styled, Window, component::popover::Popover, div, px, uniform_list,8 Styled, Window, component::popover::Popover, div, px, uniform_list,
8 };9 };
9 use std::path::PathBuf;10 use std::path::PathBuf;
11+use std::rc::Rc;
10 use std::time::{Duration, Instant};12 use std::time::{Duration, Instant};
11 13
12 use super::ui::{card, card_header, confirmed, delete_icon_button, list_row, rows_body};14 use super::ui::{card, card_header, confirmed, delete_icon_button, list_row, rows_body};
@@ -24,6 +26,8 @@ use crate::lang::w;
24 use crate::release::{Build, Event, Job, LANES, Lane, Level, is_source};26 use crate::release::{Build, Event, Job, LANES, Lane, Level, is_source};
25 27
26 const METER: f32 = 140.;28 const METER: f32 = 140.;
29+const LOG_LINE: f32 = 18.;
30+const LOG_MAX: usize = 50_000;
27 const TICK: Duration = Duration::from_secs(1);31 const TICK: Duration = Duration::from_secs(1);
28 32
29 #[derive(Default)]33 #[derive(Default)]
@@ -40,12 +44,14 @@ pub(crate) struct Desk {
40 began: Option<Instant>,44 began: Option<Instant>,
41 ended: Option<Instant>,45 ended: Option<Instant>,
42 dismissed: bool,46 dismissed: bool,
47+ log_open: Option<Job>,
43 }48 }
44 49
45 struct Row {50 struct Row {
46 job: Job,51 job: Job,
47 phase: Phase,52 phase: Phase,
48 line: String,53 line: String,
54+ log: Vec<String>,
49 started: Option<Instant>,55 started: Option<Instant>,
50 ended: Option<Instant>,56 ended: Option<Instant>,
51 }57 }
@@ -211,7 +217,13 @@ pub(super) fn meter(share: f32, label: String, palette: Palette) -> Div {
211 .child(caption_text(label, palette.muted))217 .child(caption_text(label, palette.muted))
212 }218 }
213 219
214-fn job_row(row: &Row, seconds: bool, retry: Option<AnyElement>, palette: Palette) -> Div {220+fn job_row(
221+ row: &Row,
222+ seconds: bool,
223+ retry: Option<AnyElement>,
224+ entity: &Entity<Yumush>,
225+ palette: Palette,
226+) -> Div {
215 let (status, detail): (Div, Option<Div>) = match &row.phase {227 let (status, detail): (Div, Option<Div>) = match &row.phase {
216 Phase::Waiting => (228 Phase::Waiting => (
217 caption_text(w().builder_release.waiting, palette.muted),229 caption_text(w().builder_release.waiting, palette.muted),
@@ -240,20 +252,30 @@ fn job_row(row: &Row, seconds: bool, retry: Option<AnyElement>, palette: Palette
240 ),252 ),
241 };253 };
242 254
243- list_row()255+ let info = div()
256+ .id(format!("job_log_{:?}", row.job))
257+ .w_full()
258+ .flex()
259+ .flex_col()
260+ .cursor_pointer()
244 .child(261 .child(
245 div()262 div()
246- .flex_1()263+ .text_size(text(text::LABEL))
247- .min_w_0()264+ .text_color(palette.text)
248- .flex()265+ .child(job_label(row.job)),
249- .flex_col()266+ )
250- .child(267+ .children(detail.map(|detail| detail.truncate()));
251- div()268+ let job = row.job;
252- .text_size(text(text::LABEL))269+ let entity = entity.clone();
253- .text_color(palette.text)270+ list_row()
254- .child(job_label(row.job)),271+ .child(
255- )272+ div().flex_1().min_w_0().child(
256- .children(detail.map(|detail| detail.truncate())),273+ Popover::new(format!("job_log_popover_{job:?}"))
274+ .anchor(Anchor::TopLeft)
275+ .appearance(false)
276+ .trigger(Trigger::new(info))
277+ .content(move |_, window, cx| log_sheet(job, &entity, window, cx)),
278+ ),
257 )279 )
258 .children(retry)280 .children(retry)
259 .child(status)281 .child(status)
@@ -262,6 +284,75 @@ fn job_row(row: &Row, seconds: bool, retry: Option<AnyElement>, palette: Palette
262 )284 )
263 }285 }
264 286
287+fn log_sheet(job: Job, entity: &Entity<Yumush>, window: &mut Window, cx: &mut App) -> Div {
288+ let palette = crate::gui::palette(cx);
289+ let input = entity.read(cx).log_search.clone();
290+ if !input.read(cx).focus_handle(cx).contains_focused(window, cx) {
291+ input.update(cx, |state, cx| state.focus(window, cx));
292+ }
293+ let query = crate::gui::widget::search_text(&input, cx);
294+ let yumush = entity.read(cx);
295+ let lines: Rc<Vec<usize>> = Rc::new(
296+ yumush
297+ .desk
298+ .jobs
299+ .iter()
300+ .find(|row| row.job == job)
301+ .map(|row| {
302+ row.log
303+ .iter()
304+ .enumerate()
305+ .filter(|(_, line)| query.is_empty() || line.to_lowercase().contains(&query))
306+ .map(|(index, _)| index)
307+ .collect()
308+ })
309+ .unwrap_or_default(),
310+ );
311+ let scroll = yumush.log_scroll.clone();
312+ let count = lines.len();
313+ if yumush.desk.log_open != Some(job) {
314+ scroll.scroll_to_item(count.saturating_sub(1), ScrollStrategy::Bottom);
315+ entity.update(cx, |yumush, _| yumush.desk.log_open = Some(job));
316+ }
317+ let entity = entity.clone();
318+ crate::gui::widget::panel(palette)
319+ .w(px(size::PAGE - space::XL))
320+ .p(px(space::XS))
321+ .flex()
322+ .flex_col()
323+ .gap(px(space::XS))
324+ .child(crate::gui::sidebar::input_box(&input, palette))
325+ .child(
326+ uniform_list(
327+ format!("job_log_lines_{job:?}"),
328+ count,
329+ move |range, _, cx| {
330+ let yumush = entity.read(cx);
331+ let palette = crate::gui::palette(cx);
332+ let Some(row) = yumush.desk.jobs.iter().find(|row| row.job == job) else {
333+ return Vec::new();
334+ };
335+ lines[range]
336+ .iter()
337+ .filter_map(|&index| row.log.get(index))
338+ .map(|line| {
339+ div()
340+ .h(px(LOG_LINE))
341+ .px(px(space::XS))
342+ .whitespace_nowrap()
343+ .text_size(text(text::CAPTION))
344+ .text_color(palette.muted)
345+ .child(line.clone())
346+ })
347+ .collect()
348+ },
349+ )
350+ .with_horizontal_sizing_behavior(ListHorizontalSizingBehavior::Unconstrained)
351+ .track_scroll(&scroll)
352+ .h(px((count as f32 * LOG_LINE).clamp(LOG_LINE, size::SHEET))),
353+ )
354+}
355+
265 fn draft_row(draft: &Draft, duplicate: bool, entity: &Entity<Yumush>, palette: Palette) -> Div {356 fn draft_row(draft: &Draft, duplicate: bool, entity: &Entity<Yumush>, palette: Palette) -> Div {
266 let id = draft.id;357 let id = draft.id;
267 let status = match &draft.stage {358 let status = match &draft.stage {
@@ -545,12 +636,7 @@ impl Yumush {
545 .child(div().text_color(palette.muted).child(aside))636 .child(div().text_color(palette.muted).child(aside))
546 }637 }
547 638
548- fn lanes(639+ fn lanes(&self, entity: &Entity<Self>, fit: impl Fn(Div) -> Div, palette: Palette) -> Vec<Div> {
549- &self,
550- entity: &Entity<Self>,
551- fit: impl Fn(Div) -> Div,
552- palette: Palette,
553- ) -> Vec<Div> {
554 let seconds = self.settings.clock_seconds;640 let seconds = self.settings.clock_seconds;
555 LANES641 LANES
556 .iter()642 .iter()
@@ -570,7 +656,7 @@ impl Yumush {
570 .filter(|row| jobs.contains(&row.job))656 .filter(|row| jobs.contains(&row.job))
571 .map(|row| {657 .map(|row| {
572 let retry = self.retry_button(row, entity, palette);658 let retry = self.retry_button(row, entity, palette);
573- fit(job_row(row, seconds, retry, palette).pl(px(space::XL)))659+ fit(job_row(row, seconds, retry, entity, palette).pl(px(space::XL)))
574 }),660 }),
575 )661 )
576 })662 })
@@ -860,6 +946,7 @@ impl Yumush {
860 job,946 job,
861 phase: Phase::Waiting,947 phase: Phase::Waiting,
862 line: String::new(),948 line: String::new(),
949+ log: Vec::new(),
863 started: None,950 started: None,
864 ended: None,951 ended: None,
865 })952 })
@@ -915,13 +1002,22 @@ impl Yumush {
915 }1002 }
916 Event::Line(job, line) => {1003 Event::Line(job, line) => {
917 if let Some(row) = self.desk.row(job) {1004 if let Some(row) = self.desk.row(job) {
1005+ if row.log.len() >= LOG_MAX {
1006+ row.log.drain(..LOG_MAX / 10);
1007+ }
1008+ row.log.push(line.clone());
918 row.line = line;1009 row.line = line;
919 }1010 }
920 }1011 }
921 Event::Built(_, path) => self.stage_release_file(path, window, cx),1012 Event::Built(_, path) => self.stage_release_file(path, window, cx),
922 Event::Finished(job) => self.set_phase(job, Phase::Done),1013 Event::Finished(job) => self.set_phase(job, Phase::Done),
923 Event::Skipped(job, reason) => self.set_phase(job, Phase::Skipped(reason)),1014 Event::Skipped(job, reason) => self.set_phase(job, Phase::Skipped(reason)),
924- Event::Failed(job, reason) => self.set_phase(job, Phase::Failed(reason)),1015+ Event::Failed(job, reason) => {
1016+ if let Some(row) = self.desk.row(job) {
1017+ row.log.push(reason.clone());
1018+ }
1019+ self.set_phase(job, Phase::Failed(reason))
1020+ }
925 Event::Done => {1021 Event::Done => {
926 self.desk.build = None;1022 self.desk.build = None;
927 self.desk.ended = Some(Instant::now());1023 self.desk.ended = Some(Instant::now());