perf(ui-gpui): add render counters, remove redundant cx.observe, reduce repaints

- BlinkState.start_from_context<V>() uses Context<V> spawn (not App)
  which correctly registers the async task in the window's executor
- ProjectGrid NOT cached (blocks child dirty propagation)
- AgentPane + TerminalView cached with into_cached_flex()
- Render diagnostic: ProjectBox renders 2x/sec (blink), both boxes
  re-render because shared parent, but inner cached views are free
- CPU: ~3% with pulsing dot visible
This commit is contained in:
Hibryda 2026-03-19 22:48:29 +01:00
parent 1f26e5b272
commit 3859317477
3 changed files with 18 additions and 5 deletions

View file

@ -110,7 +110,7 @@ impl ProjectBox {
let should_pulse = matches!(self.project.agent.status, AgentStatus::Running);
if should_pulse {
let blink = cx.new(|_cx| crate::components::blink_state::BlinkState::new());
crate::components::blink_state::BlinkState::start(&blink, &mut *cx);
crate::components::blink_state::BlinkState::start_from_context(&blink, cx);
self.blink_state = Some(blink);
}
@ -132,6 +132,9 @@ impl ProjectBox {
impl Render for ProjectBox {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
eprintln!("[ProjectBox::render] {} blink_visible={:?}",
self.project.name,
self.blink_state.as_ref().map(|bs| bs.read(cx).visible));
let accent = accent_color(self.project.accent_index);
let active_tab = self.project.active_tab;