Skip to content

Commit 89d1f2b

Browse files
committed
Native: Enable Stick-to-bottom for logs table
* Add stick to end for logs table with stream sources and file source once it get into tailing state after finishing the initial file reading. * Reference egui_table to special patch until the next crate release with the accepted changes.
1 parent e6d1873 commit 89d1f2b

File tree

6 files changed

+50
-3
lines changed

6 files changed

+50
-3
lines changed

application/apps/indexer/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ egui = "0.33"
8383
eframe = { version = "0.33", default-features = false }
8484
rfd = "0.17"
8585
egui_extras = { version = "0.33", default-features = false }
86-
egui_table = "0.6"
86+
egui_table = "0.7"
8787
egui_plot = "0.34"
8888
# We don't have direct dependency to winit but we need to specify it here to activate
8989
# its default features which won't be activated otherwise without activating egui default
@@ -99,6 +99,10 @@ criterion = { version = "0.5", features = ["html_reports"] }
9999
insta = { version = "1.41", features = ["yaml"] }
100100
proptest = "1.6"
101101

102+
[patch.crates-io]
103+
# This is needed until the next release "0.8" is available.
104+
egui_table = { git = "https://github.com/rerun-io/egui_table.git", rev = "cb95a2481f0e62f8f128d62ba2045ae0e6fb6253" }
105+
102106
[workspace.lints.clippy]
103107
undocumented_unsafe_blocks = "deny"
104108

application/apps/indexer/gui/application/src/session/message.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,10 @@ pub enum SessionMessage {
4343

4444
/// Source has been added to session.
4545
SourceAdded { observe_op: Box<ObserveOperation> },
46+
47+
/// Triggered when a file is opened within the session.
48+
/// Although `chipmunk` continues to monitor the file for changes,
49+
/// this event is triggered upon the completion of file reading.
50+
/// This event is not triggered for streams within a session.
51+
FileReadCompleted,
4652
}

application/apps/indexer/gui/application/src/session/service/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ impl SessionService {
424424
})
425425
.await;
426426
}
427+
CallbackEvent::FileRead => {
428+
self.senders
429+
.send_session_msg(SessionMessage::FileReadCompleted)
430+
.await;
431+
}
427432
event => {
428433
println!("************** DEBUG: Received unhandled callback: {event:?}");
429434
log::warn!("Unhandled callback: {event}");

application/apps/indexer/gui/application/src/session/ui/logs_table/mod.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use egui::{Color32, Sense, TextBuffer, Ui};
44
use egui_table::{CellInfo, Column, HeaderCellInfo, PrefetchInfo, TableDelegate};
55
use processor::grabber::LineRange;
66
use std::sync::mpsc::Receiver as StdReceiver;
7-
use stypes::GrabbedElement;
7+
use stypes::{GrabbedElement, ObserveOrigin};
88
use tokio::sync::mpsc::Sender;
99

1010
use crate::{
@@ -53,11 +53,27 @@ impl LogsTable {
5353
actions: &mut UiActions,
5454
ui: &mut Ui,
5555
) {
56+
let stick_to_bottom =
57+
shared
58+
.observe
59+
.operations()
60+
.first()
61+
.is_some_and(|op| match &op.origin {
62+
ObserveOrigin::File(..) => {
63+
// Enable stick to bottom for files only when they reach tailing phase
64+
// after reading the already existed data in that file.
65+
op.phase().is_running() && shared.observe.is_file_read_completed()
66+
}
67+
ObserveOrigin::Concat(..) => false,
68+
ObserveOrigin::Stream(..) => true,
69+
});
70+
5671
let mut table = egui_table::Table::new()
5772
.id_salt("logs_table")
5873
.num_rows(shared.logs.logs_count)
5974
.columns(self.columns.as_ref())
60-
.num_sticky_cols(1);
75+
.num_sticky_cols(1)
76+
.stick_to_bottom(stick_to_bottom);
6177

6278
if !self.schema.has_headers() {
6379
table = table.headers(Vec::new());

application/apps/indexer/gui/application/src/session/ui/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ impl Session {
225225
}
226226
// Potential components which keep track for operations can go here.
227227
}
228+
SessionMessage::FileReadCompleted => self.shared.observe.set_file_read_completed(),
228229
}
229230
}
230231
}

application/apps/indexer/gui/application/src/session/ui/shared/observe.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ use crate::{
1414
pub struct ObserveState {
1515
sources_count: usize,
1616
operations: Vec<ObserveOperation>,
17+
/// Indicates if the initial file reading process has completed.
18+
/// This is only relevant for file sources.
19+
file_read_completed: bool,
1720
}
1821

1922
impl ObserveState {
2023
pub fn new(observe_op: ObserveOperation) -> Self {
2124
let mut state = Self {
2225
sources_count: 0,
2326
operations: Vec::with_capacity(1),
27+
file_read_completed: false,
2428
};
2529
state.add_operation(observe_op);
2630

@@ -35,6 +39,7 @@ impl ObserveState {
3539
let Self {
3640
sources_count,
3741
operations,
42+
file_read_completed: _,
3843
} = self;
3944

4045
operations.push(observe_op);
@@ -73,4 +78,14 @@ impl ObserveState {
7378
pub fn is_initial_loading(&self) -> bool {
7479
self.operations.iter().all(ObserveOperation::initializing)
7580
}
81+
82+
/// Mark the initial file reading as completed.
83+
pub fn set_file_read_completed(&mut self) {
84+
self.file_read_completed = true
85+
}
86+
87+
/// Check if the initial file reading has completed.
88+
pub fn is_file_read_completed(&self) -> bool {
89+
self.file_read_completed
90+
}
7691
}

0 commit comments

Comments
 (0)