Chat perf: path-free running border, keystroke- and delta-quiet composer, spinners that do not relayout their list

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 01:21:19 +00:00
parent 2889d59119
commit 7b045e5aab
13 changed files with 534 additions and 60 deletions
@@ -45,12 +45,48 @@ class _ChatSendUsageRingState extends State<ChatSendUsageRing> {
/// Keeps the reset times and a passed reset current while a ring shows.
Timer? _tick;
/// What the last build showed: the tooltip and the ring's arc and tone.
/// The source (the thread controller) notifies on every streamed delta;
/// only a change here rebuilds the button.
Object? _shown;
@override
void initState() {
super.initState();
widget.source?.addListener(_onSource);
}
@override
void didUpdateWidget(ChatSendUsageRing oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.source != widget.source) {
oldWidget.source?.removeListener(_onSource);
widget.source?.addListener(_onSource);
}
}
@override
void dispose() {
widget.source?.removeListener(_onSource);
_tick?.cancel();
super.dispose();
}
void _onSource() {
if (!mounted) return;
final now = widget.now();
final usage = widget.usage();
if (_shownOf(usage, chatUsageRing(usage, now), now) == _shown) return;
setState(() {});
}
Object _shownOf(ChatAccountUsage? usage, ChatUsageRing? ring, DateTime now) =>
(
chatSendTooltip(widget.label, usage, ring, now),
ring?.fraction,
ring?.tone,
);
void _ticking(bool on) {
if (on == (_tick != null)) return;
_tick?.cancel();
@@ -63,19 +99,11 @@ class _ChatSendUsageRingState extends State<ChatSendUsageRing> {
@override
Widget build(BuildContext context) {
final source = widget.source;
if (source == null) return _ring(context);
return ListenableBuilder(
listenable: source,
builder: (context, _) => _ring(context),
);
}
Widget _ring(BuildContext context) {
final now = widget.now();
final usage = widget.usage();
final ring = chatUsageRing(usage, now);
_ticking(ring != null);
_shown = _shownOf(usage, ring, now);
// The button stays the same child with or without a ring, so a report
// arriving never remounts it (its hover, focus and ink stay).
return CustomPaint(