From bd59e74ad20b6fc5e44cfd46f595d65e819d85e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Sat, 16 May 2026 01:52:19 -0400 Subject: [PATCH] perf(shell): trim render snapshot work --- crates/ely_app/src/shell/render.rs | 24 ++++++++++++------------ crates/ely_browser_core/src/state.rs | 19 ++++++++----------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/crates/ely_app/src/shell/render.rs b/crates/ely_app/src/shell/render.rs index 0d16639..ecc9231 100644 --- a/crates/ely_app/src/shell/render.rs +++ b/crates/ely_app/src/shell/render.rs @@ -32,7 +32,7 @@ impl Render for ElyShell { appearance, )); match active_tab_from_snapshot(&snapshot) { - Some(active_tab) => self.render_browser(snapshot, active_tab, window, cx), + Some(active_tab) => self.render_browser(&snapshot, active_tab, window, cx), None => render_error("active tab missing from snapshot".to_string()), } } @@ -70,19 +70,19 @@ fn resolve_color_mode( } } -fn active_tab_from_snapshot(snapshot: &BrowserSnapshot) -> Option { - snapshot.tabs.iter().find(|tab| tab.id() == &snapshot.active_tab_id).cloned() +fn active_tab_from_snapshot(snapshot: &BrowserSnapshot) -> Option<&BrowserTab> { + snapshot.tabs.iter().find(|tab| tab.id() == &snapshot.active_tab_id) } impl ElyShell { fn render_browser( &mut self, - snapshot: BrowserSnapshot, - active_tab: BrowserTab, + snapshot: &BrowserSnapshot, + active_tab: &BrowserTab, window: &mut Window, cx: &mut Context, ) -> AnyElement { - let sidebar_width = match active_sidebar_width(&snapshot) { + let sidebar_width = match active_sidebar_width(snapshot) { Ok(sidebar_width) => sidebar_width, Err(message) => return render_error(message), }; @@ -129,21 +129,21 @@ impl ElyShell { .gap(px(spacing::SIDEBAR_MAIN_GAP)) .flex() .child(self.render_sidebar( - &snapshot, + snapshot, sidebar_width, sidebar_collapsed, sidebar_hidden, cx, )) .child(self.render_main_pane( - &snapshot, - &active_tab, + snapshot, + active_tab, sidebar_collapsed, window, cx, )), ) - .when(hover_expanded, |el| el.child(self.render_hidden_sidebar_overlay(&snapshot, cx))) + .when(hover_expanded, |el| el.child(self.render_hidden_sidebar_overlay(snapshot, cx))) // Workspace popover only makes sense when the picker pill is // visible — i.e. the sidebar is expanded. Compact/hidden // modes don't render the trigger, so showing the disclosure @@ -151,9 +151,9 @@ impl ElyShell { .when(self.workspace_picker_open && !sidebar_collapsed && !sidebar_hidden, |el| { let anchor = WorkspaceDisclosureAnchor::solve(sidebar_width); el.child(render_workspace_disclosure_backdrop(cx)) - .child(render_workspace_disclosure(&snapshot, anchor, cx)) + .child(render_workspace_disclosure(snapshot, anchor, cx)) }) - .children(render_command_overlay(self, &snapshot, cx)) + .children(render_command_overlay(self, snapshot, cx)) .into_any_element() } diff --git a/crates/ely_browser_core/src/state.rs b/crates/ely_browser_core/src/state.rs index 770346a..e8db9b5 100644 --- a/crates/ely_browser_core/src/state.rs +++ b/crates/ely_browser_core/src/state.rs @@ -408,10 +408,16 @@ impl BrowserCore { pub fn snapshot(&self) -> Result { let active_space = self.active_space()?; let active_profile = self.active_profile()?; + let tabs = self.visible_tabs(); + let pinned_tabs = tabs + .iter() + .filter(|tab| tab.flags().pinned && !tab.flags().favorite) + .cloned() + .collect(); Ok(BrowserSnapshot { favorites: self.favorites(), - pinned_tabs: self.pinned_tabs(), + pinned_tabs, archived_tabs: self.archived_tabs.clone(), bookmarks: self.visible_bookmarks(), notes: self.visible_notes(), @@ -431,7 +437,7 @@ impl BrowserCore { trashed_spaces: self.trashed_spaces.clone(), profiles: self.profiles.clone(), sync_status: self.sync_status(), - tabs: self.visible_tabs(), + tabs, active_tab_id: self.active_tab_id.clone(), active_space_id: self.active_space_id.clone(), active_profile_id: self.active_profile_id.clone(), @@ -477,15 +483,6 @@ impl BrowserCore { self.tabs.iter().filter(|tab| tab.flags().favorite).cloned().collect() } - fn pinned_tabs(&self) -> Vec { - tab_order::sorted_tabs( - self.tabs - .iter() - .filter(|tab| tab.space_id() == &self.active_space_id) - .filter(|tab| tab.flags().pinned && !tab.flags().favorite), - ) - } - fn visible_tabs(&self) -> Vec { tab_order::sorted_tabs( self.tabs.iter().filter(|tab| tab.space_id() == &self.active_space_id),