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 {
614614 pending_backup_delete: Option<String>,
615615 update: crate::update::Phase,
616616 desk: builder::releases::Desk,
617+ log_search: Entity<InputState>,
618+ log_scroll: gpui_kit::UniformListScrollHandle,
617619 share_apps: Vec<crate::share::audio::AudioApp>,
618620 share_apps_seen: std::cell::Cell<Instant>,
619621 share_apps_task: Option<gpui_kit::Task<()>>,
@@ -690,6 +692,7 @@ impl Yumush {
690692
691693 let server = network.server();
692694 let account_filter = new_input(w().auth.find_account, window, cx);
695+ let log_search = new_input(w().chat.find, window, cx);
693696 cx.subscribe(&account_filter, |_, _, event: &InputEvent, cx| {
694697 if matches!(event, InputEvent::Change) {
695698 cx.notify();
@@ -716,6 +719,8 @@ impl Yumush {
716719 pending_backup_delete: None,
717720 update: crate::update::Phase::Idle,
718721 desk: builder::releases::Desk::default(),
722+ log_search,
723+ log_scroll: gpui_kit::UniformListScrollHandle::new(),
719724 share_apps: Vec::new(),
720725 share_apps_seen: std::cell::Cell::new(Instant::now()),
721726 share_apps_task: None,
crates/client/src/gui/builder/releases.rsmodified+118 -22
@@ -3,10 +3,12 @@ use common::{
33 model::{ReleaseInfo, Staged},
44 };
55 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,
78 Styled, Window, component::popover::Popover, div, px, uniform_list,
89 };
910 use std::path::PathBuf;
11+use std::rc::Rc;
1012 use std::time::{Duration, Instant};
1113
1214 use super::ui::{card, card_header, confirmed, delete_icon_button, list_row, rows_body};
@@ -24,6 +26,8 @@ use crate::lang::w;
2426 use crate::release::{Build, Event, Job, LANES, Lane, Level, is_source};
2527
2628 const METER: f32 = 140.;
29+const LOG_LINE: f32 = 18.;
30+const LOG_MAX: usize = 50_000;
2731 const TICK: Duration = Duration::from_secs(1);
2832
2933 #[derive(Default)]
@@ -40,12 +44,14 @@ pub(crate) struct Desk {
4044 began: Option<Instant>,
4145 ended: Option<Instant>,
4246 dismissed: bool,
47+ log_open: Option<Job>,
4348 }
4449
4550 struct Row {
4651 job: Job,
4752 phase: Phase,
4853 line: String,
54+ log: Vec<String>,
4955 started: Option<Instant>,
5056 ended: Option<Instant>,
5157 }
@@ -211,7 +217,13 @@ pub(super) fn meter(share: f32, label: String, palette: Palette) -> Div {
211217 .child(caption_text(label, palette.muted))
212218 }
213219
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 {
215227 let (status, detail): (Div, Option<Div>) = match &row.phase {
216228 Phase::Waiting => (
217229 caption_text(w().builder_release.waiting, palette.muted),
@@ -240,20 +252,30 @@ fn job_row(row: &Row, seconds: bool, retry: Option<AnyElement>, palette: Palette
240252 ),
241253 };
242254
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()
244261 .child(
245262 div()
246- .flex_1()
247- .min_w_0()
248- .flex()
249- .flex_col()
250- .child(
251- div()
252- .text_size(text(text::LABEL))
253- .text_color(palette.text)
254- .child(job_label(row.job)),
255- )
256- .children(detail.map(|detail| detail.truncate())),
263+ .text_size(text(text::LABEL))
264+ .text_color(palette.text)
265+ .child(job_label(row.job)),
266+ )
267+ .children(detail.map(|detail| detail.truncate()));
268+ let job = row.job;
269+ let entity = entity.clone();
270+ list_row()
271+ .child(
272+ div().flex_1().min_w_0().child(
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+ ),
257279 )
258280 .children(retry)
259281 .child(status)
@@ -262,6 +284,75 @@ fn job_row(row: &Row, seconds: bool, retry: Option<AnyElement>, palette: Palette
262284 )
263285 }
264286
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+
265356 fn draft_row(draft: &Draft, duplicate: bool, entity: &Entity<Yumush>, palette: Palette) -> Div {
266357 let id = draft.id;
267358 let status = match &draft.stage {
@@ -545,12 +636,7 @@ impl Yumush {
545636 .child(div().text_color(palette.muted).child(aside))
546637 }
547638
548- fn lanes(
549- &self,
550- entity: &Entity<Self>,
551- fit: impl Fn(Div) -> Div,
552- palette: Palette,
553- ) -> Vec<Div> {
639+ fn lanes(&self, entity: &Entity<Self>, fit: impl Fn(Div) -> Div, palette: Palette) -> Vec<Div> {
554640 let seconds = self.settings.clock_seconds;
555641 LANES
556642 .iter()
@@ -570,7 +656,7 @@ impl Yumush {
570656 .filter(|row| jobs.contains(&row.job))
571657 .map(|row| {
572658 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)))
574660 }),
575661 )
576662 })
@@ -860,6 +946,7 @@ impl Yumush {
860946 job,
861947 phase: Phase::Waiting,
862948 line: String::new(),
949+ log: Vec::new(),
863950 started: None,
864951 ended: None,
865952 })
@@ -915,13 +1002,22 @@ impl Yumush {
9151002 }
9161003 Event::Line(job, line) => {
9171004 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());
9181009 row.line = line;
9191010 }
9201011 }
9211012 Event::Built(_, path) => self.stage_release_file(path, window, cx),
9221013 Event::Finished(job) => self.set_phase(job, Phase::Done),
9231014 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+ }
9251021 Event::Done => {
9261022 self.desk.build = None;
9271023 self.desk.ended = Some(Instant::now());