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 commit4e8177afbf7941fd0caed7b5fe222e272ab9db6fParent: 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
2 changed files +123 -22
crates/client/src/gui.rsmodified+5 -0
| @@ -614,6 +614,8 @@ pub struct Yumush { | ||
| 614 | 614 | pending_backup_delete: Option<String>, |
| 615 | 615 | update: crate::update::Phase, |
| 616 | 616 | desk: builder::releases::Desk, |
| 617 | + log_search: Entity<InputState>, | |
| 618 | + log_scroll: gpui_kit::UniformListScrollHandle, | |
| 617 | 619 | share_apps: Vec<crate::share::audio::AudioApp>, |
| 618 | 620 | share_apps_seen: std::cell::Cell<Instant>, |
| 619 | 621 | share_apps_task: Option<gpui_kit::Task<()>>, |
| @@ -690,6 +692,7 @@ impl Yumush { | ||
| 690 | 692 | |
| 691 | 693 | let server = network.server(); |
| 692 | 694 | let account_filter = new_input(w().auth.find_account, window, cx); |
| 695 | + let log_search = new_input(w().chat.find, window, cx); | |
| 693 | 696 | cx.subscribe(&account_filter, |_, _, event: &InputEvent, cx| { |
| 694 | 697 | if matches!(event, InputEvent::Change) { |
| 695 | 698 | cx.notify(); |
| @@ -716,6 +719,8 @@ impl Yumush { | ||
| 716 | 719 | pending_backup_delete: None, |
| 717 | 720 | update: crate::update::Phase::Idle, |
| 718 | 721 | desk: builder::releases::Desk::default(), |
| 722 | + log_search, | |
| 723 | + log_scroll: gpui_kit::UniformListScrollHandle::new(), | |
| 719 | 724 | share_apps: Vec::new(), |
| 720 | 725 | share_apps_seen: std::cell::Cell::new(Instant::now()), |
| 721 | 726 | share_apps_task: None, |
crates/client/src/gui/builder/releases.rsmodified+118 -22
| @@ -3,10 +3,12 @@ use common::{ | ||
| 3 | 3 | model::{ReleaseInfo, Staged}, |
| 4 | 4 | }; |
| 5 | 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 | 8 | Styled, Window, component::popover::Popover, div, px, uniform_list, |
| 8 | 9 | }; |
| 9 | 10 | use std::path::PathBuf; |
| 11 | +use std::rc::Rc; | |
| 10 | 12 | use std::time::{Duration, Instant}; |
| 11 | 13 | |
| 12 | 14 | use super::ui::{card, card_header, confirmed, delete_icon_button, list_row, rows_body}; |
| @@ -24,6 +26,8 @@ use crate::lang::w; | ||
| 24 | 26 | use crate::release::{Build, Event, Job, LANES, Lane, Level, is_source}; |
| 25 | 27 | |
| 26 | 28 | const METER: f32 = 140.; |
| 29 | +const LOG_LINE: f32 = 18.; | |
| 30 | +const LOG_MAX: usize = 50_000; | |
| 27 | 31 | const TICK: Duration = Duration::from_secs(1); |
| 28 | 32 | |
| 29 | 33 | #[derive(Default)] |
| @@ -40,12 +44,14 @@ pub(crate) struct Desk { | ||
| 40 | 44 | began: Option<Instant>, |
| 41 | 45 | ended: Option<Instant>, |
| 42 | 46 | dismissed: bool, |
| 47 | + log_open: Option<Job>, | |
| 43 | 48 | } |
| 44 | 49 | |
| 45 | 50 | struct Row { |
| 46 | 51 | job: Job, |
| 47 | 52 | phase: Phase, |
| 48 | 53 | line: String, |
| 54 | + log: Vec<String>, | |
| 49 | 55 | started: Option<Instant>, |
| 50 | 56 | ended: Option<Instant>, |
| 51 | 57 | } |
| @@ -211,7 +217,13 @@ pub(super) fn meter(share: f32, label: String, palette: Palette) -> Div { | ||
| 211 | 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 | 227 | let (status, detail): (Div, Option<Div>) = match &row.phase { |
| 216 | 228 | Phase::Waiting => ( |
| 217 | 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 | 261 | .child( |
| 245 | 262 | 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 | + ), | |
| 257 | 279 | ) |
| 258 | 280 | .children(retry) |
| 259 | 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 | 356 | fn draft_row(draft: &Draft, duplicate: bool, entity: &Entity<Yumush>, palette: Palette) -> Div { |
| 266 | 357 | let id = draft.id; |
| 267 | 358 | let status = match &draft.stage { |
| @@ -545,12 +636,7 @@ impl Yumush { | ||
| 545 | 636 | .child(div().text_color(palette.muted).child(aside)) |
| 546 | 637 | } |
| 547 | 638 | |
| 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> { | |
| 554 | 640 | let seconds = self.settings.clock_seconds; |
| 555 | 641 | LANES |
| 556 | 642 | .iter() |
| @@ -570,7 +656,7 @@ impl Yumush { | ||
| 570 | 656 | .filter(|row| jobs.contains(&row.job)) |
| 571 | 657 | .map(|row| { |
| 572 | 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 | 946 | job, |
| 861 | 947 | phase: Phase::Waiting, |
| 862 | 948 | line: String::new(), |
| 949 | + log: Vec::new(), | |
| 863 | 950 | started: None, |
| 864 | 951 | ended: None, |
| 865 | 952 | }) |
| @@ -915,13 +1002,22 @@ impl Yumush { | ||
| 915 | 1002 | } |
| 916 | 1003 | Event::Line(job, line) => { |
| 917 | 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 | 1009 | row.line = line; |
| 919 | 1010 | } |
| 920 | 1011 | } |
| 921 | 1012 | Event::Built(_, path) => self.stage_release_file(path, window, cx), |
| 922 | 1013 | Event::Finished(job) => self.set_phase(job, Phase::Done), |
| 923 | 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 | 1021 | Event::Done => { |
| 926 | 1022 | self.desk.build = None; |
| 927 | 1023 | self.desk.ended = Some(Instant::now()); |