Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat(mobile): answer agent questions by tapping their lines

tony56046e92f9bd
diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dart
index 6d6c3e181..d332c4a1b 100644
--- a/mobile/lib/phone/terminal_page.dart
+++ b/mobile/lib/phone/terminal_page.dart
@@ -545,8 +545,8 @@ class _TerminalPageState extends State<TerminalPage>
final view = _questionWatcher?.view;
final open = view != null && view.answerable;
_tellDaemon(open ? view : null);
- // VoiceOver hears it too, once per question: the keys appearing beside the mic and the
- // terminal repainting say nothing to someone who cannot see them.
+ // VoiceOver hears it too, once per question: the answers lighting up in the terminal say
+ // nothing to someone who cannot see them.
if (open && view.question != _questionAnnounced) {
_questionAnnounced = view.question;
unawaited(
@@ -623,10 +623,10 @@ class _TerminalPageState extends State<TerminalPage>
if (watcher == null || _keyboardSettling) return;
if (!(_readFacts().session?.acceptsInput ?? false)) return;
final view = watcher.view;
- // ⚠️ **A dialog the bar can answer raises nothing.** Its answers are keys on the status line
- // and words said to the mic (prompt mode); a keyboard would cover both, and push the bar that
- // holds them off the screen. Only a dialog the bar cannot answer — multi-select — still asks
- // for the keyboard's keys.
+ // ⚠️ **A dialog the page can answer raises nothing.** Its answers are a tap on their own lines
+ // and words said to the mic (prompt mode); a keyboard would cover both, and a tap on the pane
+ // under it is xterm's. Only a dialog the page cannot answer — multi-select — still asks for
+ // the keyboard's keys.
if (view != null && view.answerable && !view.multi) return;
if (view != null && view.answerable) {
final key = view.fingerprint;
@@ -916,16 +916,10 @@ class _TerminalPageState extends State<TerminalPage>
});
}
- /// The two answers beside the mic while a question is open — its first (`1 yes`) and its last
- /// (`3 no`). The ones between are a tap on their own line in the terminal, where what they
- /// mean is written in full ([_onLineTap]). Null when there is nothing to press: a question
- /// that takes several answers, or one only partly on screen.
- (QuestionKey, QuestionKey?)? _answerKeys(QuestionPaneView view) {
- if (!view.answerable || view.multi) return null;
- final keys = questionKeys(view);
- if (keys.isEmpty) return null;
- return (keys.first, keys.length > 1 ? keys.last : null);
- }
+ /// Whether [view]'s answers are each one tap: not a question that takes several answers, nor one
+ /// only partly on screen.
+ static bool _answersTappable(QuestionPaneView view) =>
+ view.answerable && !view.multi;
/// The mic's centre, up from the terminal's foot: where Siri's orb stands, just over the home
/// strip — where the thumb already is. Fixed in points, not rows: the terminal's size must not
@@ -943,13 +937,14 @@ class _TerminalPageState extends State<TerminalPage>
/// home strip, and no further. The terminal fills the screen; the mic floats over it, the way
/// Siri's orb floats over the home screen (the owner: "we need to fill the screen 100%").
///
- /// ⚠️ **Except while the agent asks.** Its answers are the lines at its foot, and the keys
- /// beside the mic would sit on them: the question lifts clear of the keys until it is answered.
+ /// ⚠️ **Except while the agent asks.** Its answers are the lines at its foot — and the lines to
+ /// tap — and the line above the mic asks for the answer: the question lifts clear of it until it
+ /// is answered.
double get _clearAboveMic =>
_questionWatcher?.view != null ? _statusBottom + 22 : _windowBottomInset;
/// The line above the mic, highest first: a two-second message (`✓ 1 yes`, or an error in red),
- /// what a take is doing, a question with no keys to offer, the sample's next step. Null when
+ /// what a take is doing, how to answer the question open, the sample's next step. Null when
/// there is nothing to say.
///
/// ⚠️ **The two-second message outranks the take.** The take's line was first, and a take the
@@ -968,9 +963,13 @@ class _TerminalPageState extends State<TerminalPage>
return _StatusLine(text: said.text, color: said.color);
}
final view = _questionWatcher?.view;
- if (view != null && _answerKeys(view) == null) {
+ if (view != null && !_answersTappable(view)) {
return _StatusLine(text: 'answer on screen', color: tty.yellow);
}
+ // In the sample its guide says this in its own words, and counts the step — see [_sampleGuide].
+ if (_answersOnScreen && SampleMode.maybeOf(context) == null) {
+ return _StatusLine(text: 'tap an answer · or say it', color: tty.yellow);
+ }
// Not while reading back through the history: the line sat on the rows being read, halving
// one ("FAIL src/auth/…"). It is back the moment the reader is at the end again.
if (_scrollback.value != null) return null;
@@ -980,12 +979,47 @@ class _TerminalPageState extends State<TerminalPage>
return null;
}
- /// [_answerKeys] while they can be pressed here: not over the keyboard, nor while recording.
- (QuestionKey, QuestionKey?)? get _answersBesideMic {
+ /// Whether the open question's answers are bands to tap in the terminal right now — not under
+ /// the keyboard, where a tap on the pane is xterm's.
+ ///
+ /// ⚠️ **No keys beside the mic, by the owner's call (2026-09-29).** The first and last answers
+ /// were keys either side of it: on a 360pt Android the first ran off the screen's edge, both
+ /// labels were cut to a word ("làm app/tr…"), and the answers between had no key at all. Each
+ /// answer is now its own lines, in full, where it is read — see [_answerBands].
+ bool get _answersOnScreen {
final view = _questionWatcher?.view;
- if (view == null || _ownsInput || _keyBarUp) return null;
- if (VoiceLine.shows(widget.voice)) return null;
- return _answerKeys(view);
+ if (view == null || _ownsInput || _keyBarUp) return false;
+ return _answersTappable(view);
+ }
+
+ /// The open question's answers where the terminal draws them — each its row and the description
+ /// under it — as the bands [TerminalPanel] lays over them. See [questionAnswerLines].
+ List<TerminalLineBand> _answerBands(Terminal terminal) {
+ final view = _questionWatcher?.view;
+ if (view == null || !_answersTappable(view)) return const [];
+ final labels = {for (final row in view.rows) row.number: row.label};
+ return [
+ for (final answer in questionAnswerLines(terminal, view))
+ (
+ key: answer.number,
+ first: answer.first,
+ last: answer.last,
+ label: 'Answer ${answer.number} ${labels[answer.number] ?? ''}',
+ ),
+ ];
+ }
+
+ /// A tap on an answer's band: it presses that answer, as a tap on its row does ([_onLineTap]).
+ void _onAnswerBand(TerminalLineBand band) {
+ final view = _questionWatcher?.view;
+ if (view == null || !_answersTappable(view)) return;
+ for (final key in questionKeys(view)) {
+ if (key.number == band.key) {
+ HapticFeedback.selectionClick();
+ _answer(view, key);
+ return;
+ }
+ }
}
/// A tap on a row of the terminal while a question is open: on an answer's own line —
@@ -1998,6 +2032,12 @@ class _TerminalPageState extends State<TerminalPage>
),
),
onLineTap: _onLineTap,
+ // The open question's answers, each a band
+ // across its lines — see [_answersOnScreen].
+ lineBands: _answersOnScreen
+ ? _answerBands
+ : null,
+ onBandTap: _onAnswerBand,
// Where the reader is in the history —
// what holds the view still under them.
scrollback: _scrollback,
@@ -2226,35 +2266,8 @@ class _TerminalPageState extends State<TerminalPage>
),
),
),
- // An agent's question: its first and last answers, `1 yes` and `3 no`, as keys
- // either side of the mic — which never moves. The rest are a tap on their line.
- if (_answersBesideMic case (final first, final last)?) ...[
- Positioned(
- right:
- MediaQuery.sizeOf(context).width / 2 +
- VoiceMicButton.extent / 2 +
- 20 -
- _Keycap.slop,
- bottom: _micCenter - _Keycap.touch / 2,
- child: _AnswerKeycap(
- answer: first,
- onTap: () => _answer(_questionWatcher!.view!, first),
- ),
- ),
- if (last != null)
- Positioned(
- left:
- MediaQuery.sizeOf(context).width / 2 +
- VoiceMicButton.extent / 2 +
- 20 -
- _Keycap.slop,
- bottom: _micCenter - _Keycap.touch / 2,
- child: _AnswerKeycap(
- answer: last,
- onTap: () => _answer(_questionWatcher!.view!, last),
- ),
- ),
- ],
+ // An agent's question has no keys out here: each answer is a band on its own
+ // lines in the terminal — see [_answersOnScreen].
// The sample, done: what it was, and the way to the real thing. Once.
if (_showEndCard)
Positioned.fill(
@@ -3283,118 +3296,6 @@ class _SlideAway extends StatelessWidget {
);
}
-/// One of a question's answers beside the mic: `1 yes`, its digit in the asking yellow.
-class _AnswerKeycap extends StatelessWidget {
- const _AnswerKeycap({required this.answer, required this.onTap});
-
- final QuestionKey answer;
- final VoidCallback onTap;
-
- @override
- Widget build(BuildContext context) {
- final tty = Tty.of(context);
- return _Keycap(
- semanticsLabel: 'Answer ${answer.number} ${answer.label}',
- minWidth: 88,
- haptic: HapticFeedback.selectionClick,
- onTap: onTap,
- child: ConstrainedBox(
- // Room for `2 always`; a longer answer ends in an ellipsis — its line says it in full.
- constraints: const BoxConstraints(maxWidth: 120),
- child: Text.rich(
- TextSpan(
- children: [
- TextSpan(
- text: '${answer.number} ',
- style: tty.style(
- size: TtySize.row,
- color: tty.yellow,
- weight: FontWeight.w600,
- ),
- ),
- TextSpan(
- text: answer.label,
- style: tty.style(size: TtySize.row),
- ),
- ],
- ),
- maxLines: 1,
- softWrap: false,
- overflow: TextOverflow.ellipsis,
- ),
- ),
- );
- }
-}
-
-/// A key on the raised plane: 6pt corners, no outline, darker under the finger on the way down.
-/// Drawn [height] tall inside a 44pt touch that reaches [slop] past it on every side.
-class _Keycap extends StatefulWidget {
- const _Keycap({
- required this.semanticsLabel,
- required this.onTap,
- required this.child,
- required this.haptic,
- this.minWidth = 48,
- });
-
- final String semanticsLabel;
- final VoidCallback onTap;
- final Widget child;
- final Future<void> Function() haptic;
- final double minWidth;
-
- static const double height = 36;
- static const double touch = 52;
- static const double slop = (touch - height) / 2;
-
- @override
- State<_Keycap> createState() => _KeycapState();
-}
-
-class _KeycapState extends State<_Keycap> {
- bool _down = false;
-
- void _set(bool down) {
- if (_down != down) setState(() => _down = down);
- }
-
- @override
- Widget build(BuildContext context) {
- final tty = Tty.of(context);
- final raised = ttyRaised(tty);
- return Semantics(
- button: true,
- label: widget.semanticsLabel,
- excludeSemantics: true,
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTapDown: (_) => _set(true),
- onTapCancel: () => _set(false),
- onTapUp: (_) => _set(false),
- onTap: () {
- unawaited(widget.haptic());
- widget.onTap();
- },
- child: Padding(
- padding: const EdgeInsets.all(_Keycap.slop),
- child: Container(
- height: _Keycap.height,
- constraints: BoxConstraints(minWidth: widget.minWidth),
- padding: const EdgeInsets.symmetric(horizontal: 12),
- alignment: Alignment.center,
- decoration: BoxDecoration(
- color: _down ? Color.lerp(raised, tty.ground, 0.5) : raised,
- borderRadius: BorderRadius.circular(6),
- ),
- child: widget.child,
- ),
- ),
- ),
- );
- }
-}
-
/// Holds the agent's last line at the foot of the screen while the output is followed at its end,
/// by moving the terminal rather than resizing it.
///
diff --git a/mobile/lib/terminal/question_pane.dart b/mobile/lib/terminal/question_pane.dart
index 165b6f76c..c7edaf7ee 100644
--- a/mobile/lib/terminal/question_pane.dart
+++ b/mobile/lib/terminal/question_pane.dart
@@ -539,6 +539,68 @@ bool _isLastThingOnScreen(List<String> lines, int footer) {
return true;
}
+/// How many lines one answer may run to, its own row included — a label the
+/// pane wrapped and a description of three or four lines on a narrow phone.
+const int _maxAnswerLines = 8;
+
+/// Where each answer of [view] is drawn on [terminal]'s buffer: its own row and
+/// the lines under it that belong to it, as absolute buffer line indices, top
+/// answer first. What the phone draws a band across and takes a tap on.
+///
+/// ⚠️ **The lowest dialog only**, as [readQuestionPane] reads it. The walk goes
+/// up from the bottom, takes the first row of each answer it meets, and stops
+/// at row 1 — an answered copy of the same question in the scrollback above is
+/// never the one found.
+///
+/// A line belongs to the answer above it while it is indented at least as far
+/// as that answer's label: Claude draws the description there, and a wrapped
+/// label carries on there. A blank line, any other row (`5. Type something.`),
+/// a rule or the footer ends it.
+List<({String number, int first, int last})> questionAnswerLines(
+ Terminal terminal,
+ QuestionPaneView view,
+) {
+ final lines = terminal.buffer.lines;
+ final total = lines.length;
+ if (total == 0 || view.rows.isEmpty) return const [];
+ String text(int i) =>
+ lines[i].toString().replaceAll('\u00a0', ' ').trimRight();
+ final wanted = {for (final row in view.rows) row.number: row.label};
+ final found = <({String number, int first, int last})>[];
+ final from = total - _bufferScan < 0 ? 0 : total - _bufferScan;
+ for (var i = total - 1; i >= from && wanted.isNotEmpty; i--) {
+ final line = text(i);
+ final match = _row.firstMatch(line);
+ if (match == null) continue;
+ final number = match.group(1)!;
+ final label = wanted[number];
+ if (label == null || !line.contains(label)) continue;
+ wanted.remove(number);
+ // The label's column: past `❯ 1. `, wherever the caret and the digits put it.
+ final indent = line.indexOf(
+ match.group(2)!,
+ line.indexOf('$number.') + number.length + 1,
+ );
+ var last = i;
+ for (var j = i + 1; j < total && j - i < _maxAnswerLines; j++) {
+ final next = text(j);
+ if (next.trim().isEmpty ||
+ _row.hasMatch(next) ||
+ _ruleTop.hasMatch(next.trim()) ||
+ _footer.hasMatch(next)) {
+ break;
+ }
+ if (next.length - next.trimLeft().length < indent) break;
+ last = j;
+ }
+ found.add((number: number, first: i, last: last));
+ // Row 1 is the dialog's top: every other answer is below it.
+ if (number == '1') break;
+ }
+ found.sort((a, b) => a.first.compareTo(b.first));
+ return found;
+}
+
QuestionPaneRow? _parseRow(String line, QuestionEngine engine) {
final m = _row.firstMatch(line);
if (m == null) return null;
diff --git a/mobile/lib/widgets/terminal_panel.dart b/mobile/lib/widgets/terminal_panel.dart
index 352facc22..d4bfcf5ff 100644
--- a/mobile/lib/widgets/terminal_panel.dart
+++ b/mobile/lib/widgets/terminal_panel.dart
@@ -2,8 +2,10 @@ import 'dart:async';
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
+import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
+import 'package:flutter/semantics.dart';
import 'package:flutter/services.dart';
import 'package:xterm/xterm.dart';
@@ -25,6 +27,11 @@ import '../terminal/terminal_viewport.dart';
import '../shared/theme/app_theme.dart' as grid;
import 'terminal_pane_badges.dart';
+/// A run of output rows drawn and pressed as one — [TerminalPanel.lineBands]. [first] and [last]
+/// are absolute buffer lines, inclusive; [key] is the host's own name for it, and [label] is what a
+/// screen reader says.
+typedef TerminalLineBand = ({String key, int first, int last, String label});
+
/// One agent's terminal: xterm, its input, its scrollback and its links.
///
/// ⚠️ **No tile chrome.** The desktop's copy of this widget also draws a pane's header strip —
@@ -89,6 +96,15 @@ class TerminalPanel extends StatefulWidget {
/// when the host took it: on the phone, an answer's own line while a question is open.
final bool Function(String line)? onLineTap;
+ /// Runs of output rows drawn on a faint band, each one tap target — on the phone, an open
+ /// question's answers. Asked again on every paint and every tap rather than held, so a band
+ /// stays on its lines as the pane scrolls and repaints. Null draws none.
+ final List<TerminalLineBand> Function(Terminal terminal)? lineBands;
+
+ /// A tap anywhere on a [lineBands] band, its description lines included. Taken before
+ /// [onLineTap], and whether or not [onInputTap] is set: a band is drawn to be pressed.
+ final void Function(TerminalLineBand band)? onBandTap;
+
/// Test seam for OS actions; normal panes use the platform launcher.
final TerminalLinkOpener? linkOpener;
final RemoteMediaDownloader? mediaDownloader;
@@ -105,6 +121,8 @@ class TerminalPanel extends StatefulWidget {
this.jumpToEndRequest = 0,
this.onInputTap,
this.onLineTap,
+ this.lineBands,
+ this.onBandTap,
this.linkOpener,
this.mediaDownloader,
});
@@ -156,6 +174,17 @@ class _TerminalPanelState extends State<TerminalPanel>
);
String? _pressedLink;
+ /// The [TerminalLineBand.key] under a finger that is down on it: drawn brighter until the finger
+ /// lifts or the pane scrolls. A notifier for the reason [_hoveredLink] is one — a press repaints
+ /// the bands, not the pane.
+ final ValueNotifier<String?> _pressedBand = ValueNotifier(null);
+
+ /// The bands' own box, which a band's rect is measured into — see [_bandRect].
+ final GlobalKey _bandsKey = GlobalKey();
+
+ /// Whether [_releaseBandOnUp] is on the pointer router, waiting for the pressing finger to lift.
+ bool _bandReleaseRouted = false;
+
/// Whether the tap in progress was claimed for [TerminalPanel.onInputTap].
bool _inputTapClaimed = false;
bool _openingLink = false;
@@ -304,6 +333,8 @@ class _TerminalPanelState extends State<TerminalPanel>
_hoveredLink.dispose();
_linkModifierDown.dispose();
_previewProgress.dispose();
+ _unrouteBandRelease();
+ _pressedBand.dispose();
super.dispose();
}
@@ -952,6 +983,8 @@ class _TerminalPanelState extends State<TerminalPanel>
void _onScrollChanged() {
_rememberFollowTail();
_scheduleLinkRefresh();
+ // A press that turned into a scroll is no longer a press.
+ _pressedBand.value = null;
}
String? _linkAtPointer(Offset globalPosition) {
@@ -975,18 +1008,43 @@ class _TerminalPanelState extends State<TerminalPanel>
bool _onTerminalTapDown(TapDownDetails details, CellOffset cell) {
_inputTapClaimed = false;
if (_onLinkTapDown(details, cell)) return true;
- if (widget.onInputTap == null || _controller.selection != null) {
- return false;
+ if (_controller.selection != null) return false;
+ final band = _bandAt(cell.y);
+ if (band == null && widget.onInputTap == null) return false;
+ _pressedBand.value = band?.key;
+ if (band != null && !_bandReleaseRouted) {
+ _bandReleaseRouted = true;
+ GestureBinding.instance.pointerRouter.addGlobalRoute(_releaseBandOnUp);
}
return _inputTapClaimed = true;
}
+ /// Up or gone, the finger is off the band — whatever xterm makes of it. Its tap has no cancel,
+ /// and a press that became a long press, or a drag with nothing to scroll, would stay lit.
+ void _releaseBandOnUp(PointerEvent event) {
+ if (event is! PointerUpEvent && event is! PointerCancelEvent) return;
+ _unrouteBandRelease();
+ _pressedBand.value = null;
+ }
+
+ void _unrouteBandRelease() {
+ if (!_bandReleaseRouted) return;
+ _bandReleaseRouted = false;
+ GestureBinding.instance.pointerRouter.removeGlobalRoute(_releaseBandOnUp);
+ }
+
void _onTerminalTapUp(TapUpDetails details, CellOffset cell) {
if (!_inputTapClaimed) {
_onLinkTapUp(details, cell);
return;
}
_inputTapClaimed = false;
+ _pressedBand.value = null;
+ // Read again, not remembered from the press: what is under the finger now is what it meant.
+ if (_bandAt(cell.y) case final band?) {
+ widget.onBandTap?.call(band);
+ return;
+ }
final buffer = _viewTerminal.buffer;
if (cell.y >= 0 &&
cell.y < buffer.lines.length &&
@@ -997,6 +1055,42 @@ class _TerminalPanelState extends State<TerminalPanel>
widget.onInputTap?.call();
}
+ /// The bands the host asks for now, or none when there is nothing to press them with.
+ List<TerminalLineBand> _bands() {
+ if (widget.onBandTap == null) return const [];
+ return widget.lineBands?.call(_viewTerminal) ?? const [];
+ }
+
+ /// The band drawn across buffer line [line], if any.
+ TerminalLineBand? _bandAt(int line) {
+ for (final band in _bands()) {
+ if (line >= band.first && line <= band.last) return band;
+ }
+ return null;
+ }
+
+ /// Where [band] is drawn, in the bands' own box: the full width, its rows' height less a point
+ /// top and bottom, so two answers on adjacent rows read as two. Null before layout.
+ ///
+ /// Measured through the terminal's render box rather than worked out from the line height, so
+ /// the scroll offset and xterm's own padding are counted exactly as its text is.
+ Rect? _bandRect(TerminalLineBand band) {
+ final render = _laidOutTerminalView()?.renderTerminal;
+ final box = _bandsKey.currentContext?.findRenderObject();
+ if (render == null || box is! RenderBox || !render.attached) return null;
+ if (!box.attached || !box.hasSize) return null;
+ final origin = box.globalToLocal(render.localToGlobal(Offset.zero));
+ final top = render.getOffset(CellOffset(0, band.first)).dy;
+ final bottom =
+ render.getOffset(CellOffset(0, band.last)).dy + render.lineHeight;
+ return Rect.fromLTRB(
+ 0,
+ origin.dy + top + 1,
+ box.size.width,
+ origin.dy + bottom - 1,
+ );
+ }
+
/// Whether a tap on a link opens it. On a phone, always: there is no ⌘ or ctrl to hold, and a
/// URL or `file:line` you cannot open by touching it is a dead word. Elsewhere, with the modifier.
bool get _linkTapOpens =>
@@ -1082,6 +1176,10 @@ class _TerminalPanelState extends State<TerminalPanel>
grid.AppTheme.watch(context);
final session = widget.session;
_syncTerminal(session.terminal);
+ final foreground = terminalThemeFor(
+ grid.AppTheme.palette.value,
+ terminalThemeStore.value,
+ ).foreground;
return ColoredBox(
color: grid.AppPalette.windowBg,
child: Column(
@@ -1181,6 +1279,29 @@ class _TerminalPanelState extends State<TerminalPanel>
),
),
),
+ // The bands the host asks for — on the phone, an open question's answers. They
+ // take no hit themselves: a tap goes through to xterm, which hands it to [_bandAt].
+ if (widget.lineBands != null && widget.onBandTap != null)
+ Positioned.fill(
+ child: CustomPaint(
+ key: _bandsKey,
+ painter: _LineBandPainter(
+ bands: _bands,
+ rectOf: _bandRect,
+ pressed: _pressedBand,
+ color: foreground.withValues(alpha: 0.06),
+ pressedColor: foreground.withValues(alpha: 0.16),
+ onTap: (band) => widget.onBandTap?.call(band),
+ // Output, a scroll and a press are what move or light a band; a new
+ // question rebuilds the page, and with it this painter.
+ repaint: Listenable.merge([
+ session.outputTicks,
+ _scrollController,
+ _pressedBand,
+ ]),
+ ),
+ ),
+ ),
// Both bars tick once per transferred chunk. Listening here
// keeps that traffic off the pane's own element, so a paste
// or a preview download cannot stutter the live terminal.
@@ -1219,6 +1340,72 @@ class _TerminalPanelState extends State<TerminalPanel>
}
}
+/// [TerminalPanel.lineBands], drawn: a faint wash across each band's rows, brighter while pressed.
+///
+/// ⚠️ **Over the text, not under it.** xterm owns its render box's whole background (see
+/// `RenderTerminal._paint`), so there is no under; the wash is light enough to leave the text as it
+/// is, the way xterm's own selection sits over the glyphs it marks.
+///
+/// Each band is also a button to a screen reader, named by [TerminalLineBand.label]: the rows are
+/// only paint to VoiceOver, and the answers must still be there to press.
+class _LineBandPainter extends CustomPainter {
+ _LineBandPainter({
+ required this.bands,
+ required this.rectOf,
+ required this.pressed,
+ required this.color,
+ required this.pressedColor,
+ required this.onTap,
+ required Listenable repaint,
+ }) : super(repaint: repaint);
+
+ final List<TerminalLineBand> Function() bands;
+ final Rect? Function(TerminalLineBand band) rectOf;
+ final ValueListenable<String?> pressed;
+ final Color color;
+ final Color pressedColor;
+ final void Function(TerminalLineBand band) onTap;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final paint = Paint();
+ for (final band in bands()) {
+ final rect = rectOf(band);
+ if (rect == null || !rect.overlaps(Offset.zero & size)) continue;
+ paint.color = band.key == pressed.value ? pressedColor : color;
+ canvas.drawRect(rect, paint);
+ }
+ }
+
+ /// Never hit: the tap belongs to xterm underneath, which finds the band itself.
+ @override
+ bool? hitTest(Offset position) => false;
+
+ @override
+ SemanticsBuilderCallback get semanticsBuilder =>
+ (size) => [
+ for (final band in bands())
+ if (rectOf(band) case final rect?
+ when rect.overlaps(Offset.zero & size))
+ CustomPainterSemantics(
+ key: ValueKey<String>('line-band-${band.key}'),
+ rect: rect.intersect(Offset.zero & size),
+ properties: SemanticsProperties(
+ button: true,
+ label: band.label,
+ textDirection: TextDirection.ltr,
+ onTap: () => onTap(band),
+ ),
+ ),
+ ];
+
+ @override
+ bool shouldRepaint(_LineBandPainter old) => true;
+
+ @override
+ bool shouldRebuildSemantics(_LineBandPainter old) => true;
+}
+
/// The "⌘-click to open" hint, and the click cursor that goes with it.
///
/// Both answer the same two facts — which link is under the pointer, and