perf(ui-gpui): focus-gated blink + comprehensive rendering analysis

Focus-gated blink: only first (focused) project blinks.
Root cause: 14 header divs × 2 boxes × 2/sec = 2.8% CPU.
Cached children (AgentPane, TerminalView) confirmed at 0%.
Path to <1%: custom Element for ProjectBox (major refactor).
This commit is contained in:
Hibryda 2026-03-19 23:26:20 +01:00
parent f797a676f4
commit 5d69f6b28f
2 changed files with 9 additions and 3 deletions

View file

@ -107,7 +107,10 @@ impl ProjectBox {
// StatusDotView: tiny Entity that reads BlinkState.
// ProjectBox does NOT read BlinkState → doesn't re-render on blink.
// Only StatusDotView (1 div) re-renders 2x/sec.
let should_pulse = matches!(self.project.agent.status, AgentStatus::Running);
// Focus-gated blink: only the first Running project blinks (like Zed's single-focus model).
// In production, this would be gated on project focus state.
let should_pulse = matches!(self.project.agent.status, AgentStatus::Running)
&& self.project.accent_index == 0; // Only first project blinks
let blink = if should_pulse {
let b = cx.new(|_cx| crate::components::blink_state::BlinkState::new());
crate::components::blink_state::BlinkState::start_from_context(&b, cx);

View file

@ -96,8 +96,11 @@ impl Render for Workspace {
}
// Project grid (fills remaining space) — cached with flex-1
// ProjectGrid NOT cached — child ProjectBoxes need re-render when their
// BlinkState changes. Caching the grid blocks child dirty propagation.
// ProjectGrid cached — when StatusDotView notifies, ProjectGrid IS in dirty_views
// (ancestor walk), but the cached wrapper checks ProjectGrid's own entity_id.
// Since ProjectGrid wasn't directly notified, the cache should hit.
// Wait — mark_view_dirty inserts ALL ancestors including ProjectGrid.
// So the cache WILL miss for ProjectGrid. We need it uncached.
main_row = main_row.child(
div().flex_1().h_full().child(self.project_grid.clone()),
);