Reuse chat table cell measurements across rebuilds

A markdown table measures each cell's paragraph at infinite width before
laying it out. Cells rebuilt when a row scrolls back in or a chat is opened
again now reuse those widths from a bounded cache keyed by the cell markdown
and its paragraph style, cleared when fonts change. Layout is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 18:24:11 +00:00
parent 58c72538d5
commit 914ecb285d
4 changed files with 179 additions and 1 deletions
@@ -13,6 +13,7 @@ import 'chat_markdown_cache.dart';
import 'chat_markdown_speech.dart';
import 'chat_message_bubble.dart';
import '../../speech/speech.dart';
import 'chat_table_cell_measure.dart';
import 'chat_table_column_width.dart';
/// Renders one assistant text part with native text widgets and the host's own
@@ -305,7 +306,10 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
role: header ? SemanticsRole.columnHeader : null,
child: Padding(
padding: const EdgeInsets.all(8),
child: _text(context, text, style: style),
child: ChatTableCellMeasure(
source: text,
child: _text(context, text, style: style),
),
),
);
}