Merge branch 'worktree-agent-a717651aa412e3b7c'

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 01:00:02 +00:00
60 changed files with 4265 additions and 222 deletions
@@ -5,6 +5,7 @@ import 'package:flutter/rendering.dart';
import 'chat_transcript_selection.dart';
import 'chat_code_hover.dart';
import 'chat_find_highlight.dart';
import '../../../../ui/text/monospace.dart';
import 'chat_link_launcher.dart';
import 'chat_link_spans.dart';
@@ -110,7 +111,7 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
// The text is built once and never restyled while speaking; the
// spoken word is painted behind it, so nothing shifts or rewraps.
final rendered = _rendered ??= _buildRendered(context);
return CustomPaint(
final spoken = CustomPaint(
key: _paintKey,
painter: SpokenWordPainter(
anchor: _paintKey,
@@ -121,6 +122,13 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
),
child: rendered,
);
// Find's matches are painted the same way, behind the text.
return ChatFindHighlight(
text: widget.text,
rects: (start, end, box) =>
spokenWordRects(_segments, (start: start, end: end), box),
child: spoken,
);
},
);
}
@@ -252,6 +260,7 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
],
);
case MarkdownCode(language: final language, code: final code):
final codeKey = _codeSegment(code);
_skipCodeBlock(code);
final labelStyle = _roleStyle(
context,
@@ -265,6 +274,7 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
child: ChatTranscriptHorizontalScrollView(
label: 'code block',
child: Text.rich(
key: codeKey,
TextSpan(
children: _linked(
context,
@@ -280,6 +290,27 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
}
}
/// Records where a code block's text renders, character for character
/// from its place in the source, so find can highlight matches in it.
GlobalKey _codeSegment(String code) {
if (_textCount == _textKeys.length) _textKeys.add(GlobalKey());
final key = _textKeys[_textCount++];
final start = code.isEmpty ? -1 : widget.text.indexOf(code, _sourceCursor);
if (start >= 0) {
_segments.add(
MarkdownSpokenSegment(
key,
start,
start + code.length,
0,
code.length,
List<int>.generate(code.length, (index) => start + index),
),
);
}
return key;
}
void _skipCodeBlock(String code) {
_sourceCursor = fencedCodeSpan(
widget.text,