Skip to content

Commit d697850

Browse files
committed
♻️ Defer file log loading until event loop starts in explore mode
File log loading during initialization would execute before the event loop was ready to process results. This moves the initial file log load to a deferred pattern: store the path during init and trigger loading via the event system once the main loop begins. Adds pending_file_log field to ExploreState and processes it at the start of each event loop iteration.
1 parent 9becc01 commit d697850

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/studio/app/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ impl StudioApp {
493493
let tree_state = super::components::FileTreeState::from_paths(&all_files, &statuses);
494494
self.state.modes.explore.file_tree = tree_state;
495495

496-
// Load file log for initially selected file
496+
// Initialize selected file (content only - file log loads via event system)
497497
if let Some(entry) = self.state.modes.explore.file_tree.selected_entry()
498498
&& !entry.is_dir
499499
{
@@ -503,9 +503,8 @@ impl StudioApp {
503503
if let Err(e) = self.state.modes.explore.code_view.load_file(&path) {
504504
tracing::warn!("Failed to load initial file: {}", e);
505505
}
506-
// Trigger file log loading
507-
self.state.modes.explore.file_log_loading = true;
508-
self.load_file_log(&path);
506+
// Store path for deferred file log loading (will be triggered after event loop starts)
507+
self.state.modes.explore.pending_file_log = Some(path);
509508
}
510509
}
511510
}
@@ -788,6 +787,11 @@ impl StudioApp {
788787
}
789788

790789
loop {
790+
// Process any pending file log load (deferred from initialization)
791+
if let Some(path) = self.state.modes.explore.pending_file_log.take() {
792+
self.push_event(StudioEvent::FileLogLoading(path));
793+
}
794+
791795
// Check for completed Iris tasks
792796
self.check_iris_results();
793797

src/studio/state/modes.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ pub struct ExploreState {
7272
pub show_global_log: bool,
7373
/// Whether global log is loading
7474
pub global_log_loading: bool,
75+
/// Pending file log path (for deferred loading after event loop starts)
76+
pub pending_file_log: Option<PathBuf>,
7577
}
7678

7779
impl std::fmt::Debug for ExploreState {

0 commit comments

Comments
 (0)