From a4f6c5473cfb083708561f5488be802a62e5ea66 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 6 Nov 2026 22:21:31 +0000 Subject: [PATCH] Dispose pane focus animation resources and record measured switching improvements --- .../chat/workspace/chat_mobile_panes.dart | 27 ++++++++++-------- app/notes/chat-pane-performance.md | 28 +++++++++++++++++++ 2 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 app/notes/chat-pane-performance.md diff --git a/app/lib/features/chat/workspace/chat_mobile_panes.dart b/app/lib/features/chat/workspace/chat_mobile_panes.dart index a5032221..18eee553 100644 --- a/app/lib/features/chat/workspace/chat_mobile_panes.dart +++ b/app/lib/features/chat/workspace/chat_mobile_panes.dart @@ -43,8 +43,8 @@ class ChatMobilePanes { String? peekId; } -/// Both mobile threads retain the same full content layout. Only the cheap -/// viewport clip and position change during a switch; transcript layout, scroll +/// Both mobile threads retain the same full content layout. Selection changes +/// positions once; only a tiny focus cue animates, so transcript layout, scroll /// anchoring and backdrop painting do not repeat on every animation tick. class ChatMobilePaneViewport extends StatefulWidget { const ChatMobilePaneViewport({ @@ -72,15 +72,19 @@ class ChatMobilePaneViewport extends StatefulWidget { class _ChatMobilePaneViewportState extends State with SingleTickerProviderStateMixin { - late final AnimationController _reveal = AnimationController( - vsync: this, - duration: const Duration(milliseconds: 120), - value: 1, - ); - late final Animation _accent = CurvedAnimation( - parent: _reveal, - curve: Curves.easeOutCubic, - ); + late final AnimationController _reveal; + late final CurvedAnimation _accent; + @override + void initState() { + super.initState(); + _reveal = AnimationController( + vsync: this, + duration: const Duration(milliseconds: 120), + value: 1, + ); + _accent = CurvedAnimation(parent: _reveal, curve: Curves.easeOutCubic); + } + @override void didUpdateWidget(covariant ChatMobilePaneViewport oldWidget) { super.didUpdateWidget(oldWidget); @@ -93,6 +97,7 @@ class _ChatMobilePaneViewportState extends State @override void dispose() { + _accent.dispose(); _reveal.dispose(); super.dispose(); } diff --git a/app/notes/chat-pane-performance.md b/app/notes/chat-pane-performance.md new file mode 100644 index 00000000..c54210fc --- /dev/null +++ b/app/notes/chat-pane-performance.md @@ -0,0 +1,28 @@ +# Mobile chat switching: active pane on top + +Selecting a chat now places it immediately in the top80% slot, with the previous chat in the bottom20% preview. Saved desktop tree order, axes and ratios remain unchanged. Every retained thread keeps its state and draft. + +Both mobile threads keep one stable80%-height content layout. Switching moves their viewport positions once, rather than relaying out the header, transcript and composer on every animation frame. Repaint boundaries retain the rich thread bodies. A120ms focus cue repaints only a2px strip in the native theme primary color; the conversation body stays fully opaque and stationary. Reduced motion skips the cue; rapid selections take effect immediately without queued movement. + +A measured full-pane opacity/slide candidate was rejected: although it reduced total work, its full-pane alpha layer increased p95 raster and total-frame time. The final implementation removes that alpha layer entirely. + +## Repeatable profile evidence + +The manager profiled the same headless CanvasKit fixture at560px, with30 chats and120 rich messages, three repetitions per scenario. Warm-up frames were drained and every one of10 switches was checked in each run. Final normal-run medians: + +| Metric | Previous renderer | Final renderer | +| --- | ---: | ---: | +| Framework build time, summed |736.61ms |381.9ms | +| Raster time, summed |2472.51ms |1333.2ms | +| p95 raster time |39.5ms |32.4ms | +| p95 total frame time |62.7ms |56ms | +| Long-task time |1765ms |718ms | +| Long-task count |30 |13 | + +The final rapid-switch scenario also verified10/10 selections in each of three runs: p95 total frame time56.4ms,12 long tasks totaling638ms. These are headless rich-fixture measurements, not physical-device frame-rate claims. Raw normal-run evidence is under `/private/tmp/pane-bench-final-baseline/` and `/private/tmp/pane-bench-final-optimized/`. + +## Checks + +The23-test workspace suite passes. It includes active-top geometry, stable content height and RenderProxyBox layout counters across animation ticks, no body fade/slide, a2px focus accent with intermediate progress, rapid interruption, reduced motion, drafts/state identity, retained extra panes and desktop geometry. Bounded analysis is clean. Animation/controller objects initialize during initState and dispose in dependency order, including inactive/desktop teardown paths. + +Actual browser captures and a six-frame film in `/private/tmp/chat-pane-performance-final-film/` passed four assertions: newly added chat at top, selected preview promoted to top, keyboard remains closed after pointer switching, and switching back again promotes the chat to top. All four final screenshots/contact sheet were inspected: bodies remain opaque, geometry changes immediately, and the typed draft remains present. No production data, device testing or deployment was involved in this lane.