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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(mobile): answer MCP server Accept/Decline dialogs (#1272)
tony08f962b071c0
diff --git a/mobile/lib/phone/question_keys.dart b/mobile/lib/phone/question_keys.dartindex ea0b2f401..45a497942 100644--- a/mobile/lib/phone/question_keys.dart+++ b/mobile/lib/phone/question_keys.dart@@ -120,6 +120,7 @@ String _short(String label) {'dont','cancel','deny',+ 'reject','hold','never','negative',@@ -131,8 +132,12 @@ String _short(String label) {final always = numberWhere((key) => key.label == 'always');if (always != null) return (number: always, rest: after(1));}+ // An MCP server's question answers Accept or Decline, not yes or no — the same two answers by+ // other names.if (yesPhrases.contains(two) || yesWords.contains(words.first)) {- final yes = numberWhere((key) => key.label.startsWith('yes'));+ final yes = numberWhere(+ (key) => key.label.startsWith('yes') || key.label == 'accept',+ );if (yes != null) {final used = yesPhrases.contains(two) ? 2 : 1;// "go for it" — the phrase's third word goes with it.@@ -143,7 +148,9 @@ String _short(String label) {}}if (noWords.contains(words.first)) {- final no = numberWhere((key) => key.label.startsWith('no'));+ final no = numberWhere(+ (key) => key.label.startsWith('no') || key.label == 'decline',+ );if (no != null) return (number: no, rest: after(1));}// An answer said in its own words: "yes and don't ask again" / "no and tell claude".diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dartindex 70a2b7aab..8a3f3cfdb 100644--- a/mobile/lib/phone/terminal_page.dart+++ b/mobile/lib/phone/terminal_page.dart@@ -29,6 +29,7 @@ import 'package:harness_mobile/terminal/image_transcode.dart';import 'package:harness_mobile/terminal/terminal_font_store.dart';import 'package:harness_mobile/terminal/terminal_theme.dart';import 'package:harness_mobile/terminal/terminal_theme_store.dart';+import 'package:harness_mobile/terminal/elicitation_press.dart';import 'package:harness_mobile/terminal/key_hints.dart';import 'package:harness_mobile/terminal/question_pane.dart';import 'package:harness_mobile/terminal/question_pane_watcher.dart';@@ -636,9 +637,9 @@ class _TerminalPageState extends State<TerminalPage>final view = watcher.view;// ⚠️ **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;+ // under it is xterm's. Only a dialog the page cannot answer — multi-select, or an MCP form+ // whose field has the caret — still asks for the keyboard's keys.+ if (view != null && view.tappable) return;if (view != null && view.answerable) {final key = view.fingerprint;if (_questionRaisedFor == key) return;@@ -848,6 +849,7 @@ class _TerminalPageState extends State<TerminalPage>);_questionWatcher?.removeListener(_onQuestionPane);_questionWatcher?.dispose();+ _elicitationPress.cancel();_cancelSettle();_searchHoldTimer?.cancel();_chrome.dispose();@@ -968,9 +970,8 @@ class _TerminalPageState extends State<TerminalPage>}/// 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;+ /// only partly on screen, nor an MCP form being filled in — see [QuestionPaneView.tappable].+ static bool _answersTappable(QuestionPaneView view) => view.tappable;/// 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@@ -1126,6 +1127,7 @@ class _TerminalPageState extends State<TerminalPage>first: answer.first,last: answer.last,label: 'Answer ${answer.number} ${labels[answer.number] ?? ''}',+ columns: answer.columns,),];}@@ -1147,7 +1149,7 @@ class _TerminalPageState extends State<TerminalPage>/// `❯ 1. Yes`, ` 2. Yes, and don't ask again` — it presses that answer.bool _onLineTap(String line) {final view = _questionWatcher?.view;- if (view == null || !view.answerable || view.multi) return false;+ if (view == null || !view.tappable) return false;final number = _optionLine.firstMatch(line)?.group(1);if (number == null) return false;for (final key in questionKeys(view)) {@@ -1163,16 +1165,39 @@ class _TerminalPageState extends State<TerminalPage>static final _optionLine = RegExp(r'^\s*(?:[❯›>]\s*)?(\d{1,2})[.)]\s');/// Presses an answer: its digit, and Return only where the dialog asks for one (Codex's- /// `request_user_input`) — a chosen Return, never a blind one.+ /// `request_user_input`) — a chosen Return, never a blind one. An MCP server's Accept or Decline+ /// has no digit: the caret is moved onto it and Enter pressed — see [ElicitationPress].void _answer(QuestionPaneView view, QuestionKey key) {final session = widget.notifier.paneOfAgent(widget.machineId, widget.agentId)?.session;if (session == null) return;+ if (view.kind == QuestionPaneKind.elicitation) {+ _elicitationPress.press(key.number);+ return;+ }session.terminal.textInput(key.number);if (view.enterSubmits) session.terminal.keyInput(TerminalKey.enter);}+ /// Accept or Decline pressed on an MCP server's question, read off and keyed into whichever+ /// terminal this page's pane holds at the moment — a keyframe replaces it, and a press waiting on+ /// the caret outlives one.+ late final _elicitationPress = ElicitationPress(+ read: () {+ final session = widget.notifier+ .paneOfAgent(widget.machineId, widget.agentId)+ ?.session;+ if (session == null) return null;+ return readQuestionPane(session.terminal, QuestionEngine.claude);+ },+ send: (key) => widget.notifier+ .paneOfAgent(widget.machineId, widget.agentId)+ ?.session+ ?.terminal+ .keyInput(key),+ );+/// Where a voice take goes: to the agent's prompt — or, while the agent's question is open, to/// that question, as its answer or not at all. Nothing is echoed when it lands: the words appear/// in the prompt, and a tap is felt. Only what went wrong is said (see [_flash]).@@ -1209,7 +1234,7 @@ class _TerminalPageState extends State<TerminalPage>Future<bool> _answerByVoice(TerminalSession session, String text) async {final view = _questionWatcher?.view;if (view == null) return session.sendComposerText(text);- if (!view.answerable || view.multi) {+ if (!view.tappable) {_flash('✗ answer on screen', error: true);return false;}diff --git a/mobile/lib/terminal/elicitation_press.dart b/mobile/lib/terminal/elicitation_press.dartnew file mode 100644index 000000000..781fef1ec--- /dev/null+++ b/mobile/lib/terminal/elicitation_press.dart@@ -0,0 +1,111 @@+import 'dart:async';++import 'package:xterm/xterm.dart';++import 'question_pane.dart';++/// Presses one of an MCP elicitation's two buttons the way a person at the+/// keyboard does: the caret moved onto it, then Enter — but Enter only once the+/// PANE shows the caret there.+///+/// ⚠️ **Not `→` and Enter in one go.** Claude Code ignores Enter on Accept for a+/// moment after the caret arrives on it — its guard against a key typed ahead+/// into a destructive confirmation. Measured on 2.1.299: Enter 50ms after the+/// caret moved was dropped, 120ms after was taken. And the two keys cross the+/// relay, which can hand them over as one burst however far apart they left+/// the phone. So Enter waits for the screen to show the caret, then [settle].+///+/// ⚠️ **Enter is never sent on a caret this has not SEEN on the button asked+/// for.** Decline pressed as Accept would apply exactly what the person+/// refused — a dropped table, in the dialog that brought this about+/// (openharness#1272). A press that cannot see its caret arrive within+/// [timeout] gives up having sent only the arrow; the dialog stays open and a+/// second tap finds the caret already there.+class ElicitationPress {+ ElicitationPress({+ required this.read,+ required this.send,+ this.poll = const Duration(milliseconds: 80),+ this.settle = const Duration(milliseconds: 250),+ this.timeout = const Duration(milliseconds: 2500),+ });++ /// The dialog as the pane shows it NOW — read fresh, never a held view, since+ /// a caret moving between the buttons is not a change the watcher reports.+ final QuestionPaneView? Function() read;++ /// Sends one key to the pane.+ final void Function(TerminalKey key) send;++ /// How often the pane is read while waiting for the caret.+ final Duration poll;++ /// How long Enter waits once the caret is seen on the button — past the+ /// engine's own guard, counted from the moment it could last have moved.+ final Duration settle;++ /// How long to wait for the caret before giving up.+ final Duration timeout;++ Timer? _timer;++ /// A press is under way: the arrow is sent and Enter is not yet.+ bool get busy => _timer != null;++ /// Presses the button numbered [target] — `1` Accept, `2` Decline, as+ /// [QuestionPaneView.rows] number them.+ ///+ /// False when nothing was sent: a press already under way (a second tap+ /// while the first is still moving the caret would move it straight back),+ /// no elicitation on the pane, or one of its fields holding the caret.+ bool press(String target) {+ if (busy) return false;+ final view = read();+ if (view == null ||+ view.kind != QuestionPaneKind.elicitation ||+ view.focused == null ||+ !view.rows.any((row) => row.number == target)) {+ return false;+ }+ if (view.focused == target) {+ send(TerminalKey.enter);+ return true;+ }+ // `←` and `→` both swap the caret between the two buttons.+ send(TerminalKey.arrowRight);+ final fingerprint = view.fingerprint;+ // Counted in polls rather than read off the wall clock, so a test's fake+ // time runs it out too.+ var waited = Duration.zero;+ _timer = Timer.periodic(poll, (_) {+ waited += poll;+ final now = read();+ if (!_still(now, fingerprint) || waited > timeout) {+ cancel();+ return;+ }+ if (now!.focused != target) return;+ _timer?.cancel();+ _timer = Timer(settle, () {+ _timer = null;+ final last = read();+ if (_still(last, fingerprint) && last!.focused == target) {+ send(TerminalKey.enter);+ }+ });+ });+ return true;+ }++ /// The same elicitation is still open.+ static bool _still(QuestionPaneView? view, String fingerprint) =>+ view != null &&+ view.kind == QuestionPaneKind.elicitation &&+ view.fingerprint == fingerprint;++ /// Drops a press under way, sending nothing more.+ void cancel() {+ _timer?.cancel();+ _timer = null;+ }+}diff --git a/mobile/lib/terminal/question_pane.dart b/mobile/lib/terminal/question_pane.dartindex 952290e67..f69c43b85 100644--- a/mobile/lib/terminal/question_pane.dart+++ b/mobile/lib/terminal/question_pane.dart@@ -59,6 +59,17 @@ class QuestionPaneRow {final bool checked;}+/// How a dialog's answers are pressed.+enum QuestionPaneKind {+ /// Numbered rows: an answer is its digit.+ choice,++ /// Claude Code's MCP elicitation — a server asking mid-tool-call:+ /// `❯ Accept Decline` on ONE line, no digits. An answer is the caret moved+ /// onto it (`←`/`→`) and Enter — see [_parseElicitation].+ elicitation,+}+/// A dialog found on the pane.class QuestionPaneView {const QuestionPaneView({@@ -67,8 +78,29 @@ class QuestionPaneView {required this.multi,required this.enterSubmits,required this.partial,+ this.kind = QuestionPaneKind.choice,+ this.focused,});+ final QuestionPaneKind kind;++ /// [QuestionPaneKind.elicitation] only: the [QuestionPaneRow.number] of the+ /// button the caret is on, or null while one of the form's fields has it.+ ///+ /// ⚠️ **As of the read that made this view.** The watcher keeps one view+ /// across redraws of the same dialog, and the caret moving between the two+ /// buttons is such a redraw — so whatever acts on the caret reads the pane+ /// again first ([readQuestionPane]).+ final String? focused;++ /// Each answer is one tap: open, not several answers at once, and — for an+ /// MCP form — not while one of its fields has the caret, which only the+ /// keyboard can fill in.+ bool get tappable =>+ answerable &&+ !multi &&+ (kind != QuestionPaneKind.elicitation || focused != null);+/// Empty when [partial] — the dialog is open but its question has scrolled/// out of the buffer.final String question;@@ -334,6 +366,13 @@ QuestionPaneView? parseQuestionLines(List<String> lines,QuestionEngine engine,) {+ // An MCP server's own question has no digits and no `Enter to …`, so nothing below would ever+ // see it — and with nothing seeing it, the phone had no way to answer it (openharness#1272).+ if (engine == QuestionEngine.claude) {+ final elicitation = _parseElicitation(lines);+ if (elicitation != null) return elicitation;+ }+// ⚠️ **The review screen paints no footer**, so it has to be found first or// not at all. After the last question the dialog becomes "Ready to submit// your answers?" over `1. Submit answers` / `2. Cancel` — still open, still@@ -518,6 +557,112 @@ QuestionPaneView? _parseReview(List<String> lines) {);}+/// The button row of an MCP elicitation, the caret on Accept (group 1), on+/// Decline (group 2), or on neither while a field of the form has it.+///+/// Claude Code 2.1.299 draws it as `[caret] Accept [caret] Decline`, an empty+/// caret slot being a space — ` ❯ Accept Decline` or ` Accept ❯ Decline`.+final RegExp _elicitationButtons = RegExp(+ r'^\s*([❯›>]\s)?\s*Accept\s+([❯›>]\s)?\s*Decline\s*$',+);++/// The elicitation's footer — `Esc to cancel · ↑/↓ to navigate`. The keys are+/// the person's to remap; what they do is not.+final RegExp _elicitationFooter = RegExp(+ r'\bto (cancel|navigate)\b',+ caseSensitive: false,+);++/// The elicitation's title — `MCP server “claude.ai Supabase” requests your+/// input` — which a narrow pane wraps after `requests`.+final RegExp _elicitationTitle = RegExp(+ r'^MCP server\b.*?\brequests\s+your\s+input',+ caseSensitive: false,+);++/// How many lines the elicitation's title may wrap onto.+const int _maxTitleLines = 3;++/// Claude Code's MCP elicitation — a server asking for confirmation, or a+/// small form, in the middle of a tool call:+///+/// ```+/// ───────────────────────────────────────────────+/// MCP server “claude.ai Supabase” requests your input+///+/// This SQL includes destructive operations…+///+/// ❯ Accept Decline+///+/// Esc to cancel · ↑/↓ to navigate+/// ```+///+/// Measured on a live 47-column pane. It is driven by keys, not digits:+/// `←`/`→` swap the caret between the two buttons, Enter presses the one it is+/// on, Esc cancels. With no fields the caret starts on Accept; with fields it+/// starts on the first field, and the buttons show no caret at all.+///+/// Anchored like every other dialog here: to the LOWEST button row, live only+/// while nothing but its footer is drawn under it, and with its title above it+/// inside the same frame.+QuestionPaneView? _parseElicitation(List<String> lines) {+ final at = lines.lastIndexWhere((l) => _elicitationButtons.hasMatch(l));+ if (at < 0) return null;+ var footer = false;+ for (var i = at + 1; i < lines.length; i++) {+ final line = lines[i].trim();+ if (line.isEmpty) continue;+ if (_elicitationFooter.hasMatch(line)) {+ footer = true;+ continue;+ }+ if (_trailingChrome.hasMatch(line) || _looksLikeFooterTail(line)) continue;+ // Anything else under the buttons is the engine having moved on.+ return null;+ }+ if (!footer) return null;+ final title = _elicitationTitleAbove(lines, at);+ if (title == null) return null;+ final caret = _elicitationButtons.firstMatch(lines[at])!;+ return QuestionPaneView(+ question: title,+ rows: const [+ QuestionPaneRow(number: '1', label: 'Accept', checked: false),+ QuestionPaneRow(number: '2', label: 'Decline', checked: false),+ ],+ multi: false,+ enterSubmits: false,+ partial: false,+ kind: QuestionPaneKind.elicitation,+ focused: caret.group(1) != null+ ? '1'+ : caret.group(2) != null+ ? '2'+ : null,+ );+}++/// The elicitation's title, its wrapped lines stitched, found walking up from+/// the button row at [buttons] — but never past the rule over the dialog, where+/// an answered one in the scrollback would be.+String? _elicitationTitleAbove(List<String> lines, int buttons) {+ for (var i = buttons - 1; i >= 0 && buttons - i <= _maxRowScan; i--) {+ final line = lines[i].trim();+ if (_ruleTop.hasMatch(line)) return null;+ if (!line.startsWith('MCP server')) continue;+ var title = line;+ for (var j = i + 1; j < buttons && j - i < _maxTitleLines; j++) {+ if (_elicitationTitle.hasMatch(title)) break;+ final next = lines[j].trim();+ if (next.isEmpty) break;+ title = '$title $next';+ }+ final match = _elicitationTitle.firstMatch(title);+ return match?.group(0);+ }+ return null;+}+/// Is the dialog ending at [footer] the last thing drawn on the pane?////// Everything below it must be blank or the dialog's own trailing chrome.@@ -558,17 +703,23 @@ const int _maxAnswerLines = 8;/// 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,-) {+///+/// An MCP elicitation's two answers share one line, so each carries the+/// [columns] it covers — see [_elicitationAnswerLines]. Null everywhere else:+/// the answer is its rows' full width.+List<({String number, int first, int last, ({int start, int end})? columns})>+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();+ if (view.kind == QuestionPaneKind.elicitation) {+ return _elicitationAnswerLines(terminal, text);+ }final wanted = {for (final row in view.rows) row.number: row.label};- final found = <({String number, int first, int last})>[];+ final found =+ <({String number, int first, int last, ({int start, int end})? columns})>[];final from = total - _bufferScan < 0 ? 0 : total - _bufferScan;for (var i = total - 1; i >= from && wanted.isNotEmpty; i--) {final line = text(i);@@ -595,7 +746,7 @@ List<({String number, int first, int last})> questionAnswerLines(if (next.length - next.trimLeft().length < indent) break;last = j;}- found.add((number: number, first: i, last: last));+ found.add((number: number, first: i, last: last, columns: null));// Row 1 is the dialog's top: every other answer is below it.if (number == '1') break;}@@ -603,6 +754,46 @@ List<({String number, int first, int last})> questionAnswerLines(return found;}+/// Where an MCP elicitation's Accept and Decline are drawn: the lowest button+/// row, split between the two words.+///+/// Each takes its caret's slot and a little either side, and the gap between+/// them is shared at its middle — a thumb lands near a word, not on it, and a+/// band no wider than `Accept` would be missed as often as hit. The row's+/// columns are its string's indices: the caret and the words are all one cell+/// wide.+List<({String number, int first, int last, ({int start, int end})? columns})>+_elicitationAnswerLines(Terminal terminal, String Function(int i) text) {+ final total = terminal.buffer.lines.length;+ final from = total - _bufferScan < 0 ? 0 : total - _bufferScan;+ for (var i = total - 1; i >= from; i--) {+ final line = text(i);+ if (!_elicitationButtons.hasMatch(line)) continue;+ final accept = line.indexOf('Accept');+ final decline = line.indexOf('Decline', accept);+ final middle = (accept + 'Accept'.length + decline) ~/ 2;+ final end = decline + 'Decline'.length + 2;+ return [+ (+ number: '1',+ first: i,+ last: i,+ columns: (start: accept - 2 < 0 ? 0 : accept - 2, end: middle),+ ),+ (+ number: '2',+ first: i,+ last: i,+ columns: (+ start: middle,+ end: end > terminal.viewWidth ? terminal.viewWidth : end,+ ),+ ),+ ];+ }+ return const [];+}+QuestionPaneRow? _parseRow(String line, QuestionEngine engine) {final m = _row.firstMatch(line);if (m == null) return null;diff --git a/mobile/lib/terminal/question_pane_watcher.dart b/mobile/lib/terminal/question_pane_watcher.dartindex 3ae21545b..f8f2eb3d5 100644--- a/mobile/lib/terminal/question_pane_watcher.dart+++ b/mobile/lib/terminal/question_pane_watcher.dart@@ -181,7 +181,13 @@ class QuestionPaneWatcher extends ChangeNotifier {// The same dialog redrawn — a caret moving between rows rewrites the whole// block. Keeping the one already held is what stops a publish on every// arrow key.- if (_view?.fingerprint == found.fingerprint) {+ //+ // ⚠️ **Unless what a tap can do changed with it.** An MCP form's caret+ // moving from a field onto its buttons is the same dialog — same+ // fingerprint, so nothing upstream takes it for a new question — but its+ // answers have just become tappable, and the page has to hear that.+ if (_view?.fingerprint == found.fingerprint &&+ _view?.tappable == found.tappable) {return (view: _view, again: false);}return (view: found, again: false);diff --git a/mobile/lib/terminal/terminal_prompt_zone.dart b/mobile/lib/terminal/terminal_prompt_zone.dartindex 1983dc1a4..f56f18c12 100644--- a/mobile/lib/terminal/terminal_prompt_zone.dart+++ b/mobile/lib/terminal/terminal_prompt_zone.dart@@ -36,9 +36,53 @@ final _rule = RegExp(r'^[─━═╭╮╰╯┌┐└┘\-]+$');/// [row] is an absolute buffer row, scrollback included: what/// `RenderTerminal.getCellOffset` reports. A tap on history scrolled far above/// the prompt is therefore never a prompt tap.-bool isPromptTap(Buffer buffer, int row) {+///+/// ⚠️ **A dialog drawn in the prompt's place counts whole** ([wholeDialog]).+/// Claude Code hides its prompt under a dialog and parks the cursor UNDER the+/// dialog's footer — measured on a live pane with an MCP server's+/// `Accept Decline` open (openharness#1272): the cursor sat on the blank row+/// below `Esc to cancel · ↑/↓ to navigate`, so the dialog's own rows were+/// "reading", the rows left to tap were under the mic, and the phone had no+/// way at all to press the keys the dialog asked for. See [_dialogTop].+///+/// False where the host answers the dialog's rows itself (a tap on an answer's+/// band): a tap beside them is somebody reading the question, and a keyboard+/// rising over the answers would hide the very thing they were about to tap.+bool isPromptTap(Buffer buffer, int row, {bool wholeDialog = true}) {final top = _promptTop(buffer, buffer.absoluteCursorY) - 1;- return row >= min(top, buffer.height - _footRows);+ final edge = min(top, buffer.height - _footRows);+ final dialog = wholeDialog ? _dialogTop(buffer) : null;+ return row >= (dialog == null ? edge : min(edge, dialog));+}++/// A dialog's footer: what a key does, as Claude Code words its hints —+/// `Esc to cancel`, `↑/↓ to navigate`, `Enter to select`.+final _dialogFooter = RegExp(+ r'\b(?:esc|enter|tab|space)\s+to\s+\w|[←↑→↓](?:\s*/\s*[←↑→↓])?\s+to\s+\w',+ caseSensitive: false,+);++/// The rule over a dialog the program drew where its prompt was, or null when+/// the foot of the screen is a prompt — or anything a footer does not mark as a+/// dialog.+///+/// Walked up from the foot of the screen: no row on the way may start a prompt+/// (`❯ `, `› `), a footer must be passed, and the first rule at or above the+/// cursor is the dialog's top. Claude Code draws every dialog that way — a+/// full-width rule, the dialog, its footer — and Codex draws no rule, so a+/// Codex pane keeps exactly the zone it had.+int? _dialogTop(Buffer buffer) {+ final lines = buffer.lines;+ final screenTop = max(0, buffer.height - buffer.viewHeight);+ final cursor = min(buffer.absoluteCursorY, buffer.height - 1);+ var footer = false;+ for (var row = buffer.height - 1; row >= screenTop; row--) {+ final line = lines[row];+ if (_promptGlyphColumn(line) != null) return null;+ if (_dialogFooter.hasMatch(line.getText())) footer = true;+ if (row <= cursor && _isRuleRow(line)) return footer ? row : null;+ }+ return null;}int _promptTop(Buffer buffer, int cursorRow) {diff --git a/mobile/lib/widgets/terminal_panel.dart b/mobile/lib/widgets/terminal_panel.dartindex d43a3e3ec..ae74a492b 100644--- a/mobile/lib/widgets/terminal_panel.dart+++ b/mobile/lib/widgets/terminal_panel.dart@@ -33,7 +33,17 @@ 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});+///+/// [columns] narrows the band to cells `start` (inclusive) to `end` (exclusive) of its rows, for+/// answers drawn side by side on one line — Claude Code's `❯ Accept Decline`. Null spans the+/// full width, as an answer on rows of its own does.+typedef TerminalLineBand = ({+ String key,+ int first,+ int last,+ String label,+ ({int start, int end})? columns,+});/// One agent's terminal: xterm, its input, its scrollback and its links.///@@ -1412,7 +1422,7 @@ class _TerminalPanelState extends State<TerminalPanel>_inputTapClaimed = false;if (_onLinkTapDown(details, cell)) return true;if (_controller.selection != null) return false;- final band = _bandAt(cell.y);+ final band = _bandAt(cell);if (band == null && widget.onInputTap == null) return false;_pressedBand.value = band?.key;if (band != null && !_bandReleaseRouted) {@@ -1444,7 +1454,7 @@ class _TerminalPanelState extends State<TerminalPanel>_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?) {+ if (_bandAt(cell) case final band?) {widget.onBandTap?.call(band);return;}@@ -1454,7 +1464,9 @@ class _TerminalPanelState extends State<TerminalPanel>(widget.onLineTap?.call(buffer.lines[cell.y].getText()) ?? false)) {return;}- if (!isPromptTap(buffer, cell.y)) return;+ // A dialog whose answers are bands keeps the taps beside them for reading; any other dialog+ // takes a tap anywhere on it as asking for the keys it needs — see [isPromptTap].+ if (!isPromptTap(buffer, cell.y, wholeDialog: _bands().isEmpty)) return;widget.onInputTap?.call();}@@ -1464,16 +1476,23 @@ class _TerminalPanelState extends State<TerminalPanel>return widget.lineBands?.call(_viewTerminal) ?? const [];}- /// The band drawn across buffer line [line], if any.- TerminalLineBand? _bandAt(int line) {+ /// The band drawn over [cell], if any.+ TerminalLineBand? _bandAt(CellOffset cell) {for (final band in _bands()) {- if (line >= band.first && line <= band.last) return band;+ if (cell.y < band.first || cell.y > band.last) continue;+ final columns = band.columns;+ if (columns != null && (cell.x < columns.start || cell.x >= columns.end)) {+ continue;+ }+ 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.+ /// Where [band] is drawn, in the bands' own box: the full width — or its [TerminalLineBand+ /// .columns], less a point each side so two answers on one line read as two — and 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.@@ -1486,10 +1505,19 @@ class _TerminalPanelState extends State<TerminalPanel>final top = render.getOffset(CellOffset(0, band.first)).dy;final bottom =render.getOffset(CellOffset(0, band.last)).dy + render.lineHeight;+ final columns = band.columns;return Rect.fromLTRB(- 0,+ columns == null+ ? 0+ : origin.dx ++ render.getOffset(CellOffset(columns.start, band.first)).dx ++ 1,origin.dy + top + 1,- box.size.width,+ columns == null+ ? box.size.width+ : origin.dx ++ render.getOffset(CellOffset(columns.end, band.first)).dx -+ 1,origin.dy + bottom - 1,);}diff --git a/mobile/test/elicitation_press_test.dart b/mobile/test/elicitation_press_test.dartnew file mode 100644index 000000000..8ec709011--- /dev/null+++ b/mobile/test/elicitation_press_test.dart@@ -0,0 +1,119 @@+import 'package:fake_async/fake_async.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/terminal/elicitation_press.dart';+import 'package:harness_mobile/terminal/question_pane.dart';+import 'package:xterm/xterm.dart';++/// An MCP server's Accept/Decline with the caret on [focused] — `1`, `2`, or+/// null for a field of the form.+QuestionPaneView _dialog(String? focused, {String question = 'q'}) =>+ QuestionPaneView(+ question: question,+ rows: const [+ QuestionPaneRow(number: '1', label: 'Accept', checked: false),+ QuestionPaneRow(number: '2', label: 'Decline', checked: false),+ ],+ multi: false,+ enterSubmits: false,+ partial: false,+ kind: QuestionPaneKind.elicitation,+ focused: focused,+ );++/// A pane whose dialog the test moves by hand, and the keys pressed into it.+class _Pane {+ QuestionPaneView? view;+ final keys = <TerminalKey>[];++ late final press = ElicitationPress(read: () => view, send: keys.add);+}++void main() {+ test('the caret already on it: Enter, and nothing else', () {+ final pane = _Pane()..view = _dialog('1');+ expect(pane.press.press('1'), isTrue);+ expect(pane.keys, [TerminalKey.enter]);+ expect(pane.press.busy, isFalse);+ });++ test('Decline: the caret moved over, Enter only once the pane shows it '+ 'there, and a moment after', () {+ fakeAsync((async) {+ final pane = _Pane()..view = _dialog('1');+ expect(pane.press.press('2'), isTrue);+ expect(pane.keys, [TerminalKey.arrowRight]);++ // The pane has not redrawn yet: the caret is still on Accept, so no Enter.+ async.elapse(const Duration(milliseconds: 500));+ expect(pane.keys, [TerminalKey.arrowRight]);+ expect(pane.press.busy, isTrue);++ pane.view = _dialog('2');+ async.elapse(const Duration(milliseconds: 100));+ // Seen — but Claude Code drops an Enter that comes right on the caret's heels.+ expect(pane.keys, [TerminalKey.arrowRight]);+ async.elapse(const Duration(milliseconds: 300));+ expect(pane.keys, [TerminalKey.arrowRight, TerminalKey.enter]);+ expect(pane.press.busy, isFalse);+ });+ });++ test('a caret that never arrives: no Enter, ever', () {+ fakeAsync((async) {+ final pane = _Pane()..view = _dialog('2');+ pane.press.press('1');+ async.elapse(const Duration(seconds: 10));+ expect(pane.keys, [TerminalKey.arrowRight]);+ expect(pane.press.busy, isFalse, reason: 'it gave up');+ });+ });++ test('the caret leaving again before Enter: no Enter', () {+ fakeAsync((async) {+ final pane = _Pane()..view = _dialog('1');+ pane.press.press('2');+ pane.view = _dialog('2');+ async.elapse(const Duration(milliseconds: 100));+ pane.view = _dialog('1');+ async.elapse(const Duration(seconds: 1));+ expect(pane.keys, [TerminalKey.arrowRight]);+ });+ });++ test('the dialog answered elsewhere, or replaced: no Enter', () {+ fakeAsync((async) {+ final pane = _Pane()..view = _dialog('1');+ pane.press.press('2');+ pane.view = null;+ async.elapse(const Duration(seconds: 1));+ expect(pane.keys, [TerminalKey.arrowRight]);+ expect(pane.press.busy, isFalse);++ pane.keys.clear();+ pane.view = _dialog('1');+ pane.press.press('2');+ pane.view = _dialog('2', question: 'another server asking');+ async.elapse(const Duration(seconds: 1));+ expect(pane.keys, [TerminalKey.arrowRight]);+ });+ });++ test('a second tap while the first is moving the caret sends nothing', () {+ fakeAsync((async) {+ final pane = _Pane()..view = _dialog('1');+ expect(pane.press.press('2'), isTrue);+ expect(pane.press.press('2'), isFalse);+ expect(pane.press.press('1'), isFalse);+ expect(pane.keys, [TerminalKey.arrowRight]);+ pane.press.cancel();+ });+ });++ test('a form whose field has the caret, or no dialog at all: nothing', () {+ final pane = _Pane()..view = _dialog(null);+ expect(pane.press.press('1'), isFalse);+ pane.view = null;+ expect(pane.press.press('1'), isFalse);+ expect(pane.keys, isEmpty);+ });+}diff --git a/mobile/test/phone_edge/focus_behavior_test.dart b/mobile/test/phone_edge/focus_behavior_test.dartindex 82fe983aa..96c3ce23b 100644--- a/mobile/test/phone_edge/focus_behavior_test.dart+++ b/mobile/test/phone_edge/focus_behavior_test.dart@@ -504,6 +504,102 @@ void main() {});});+ // openharness#1272: Claude Code's MCP elicitation has no digits and no `Enter to …`, and its+ // cursor parks under the footer — so the page neither read it nor raised the keyboard for it,+ // and nothing on the phone could answer it.+ group('an MCP server asking', () {+ String elicitation({String buttons = ' ❯ Accept Decline'}) =>+ '\r\n──────────────────────────────\r\n'+ ' MCP server “db” requests your input\r\n'+ '\r\n'+ ' This SQL drops a table…\r\n'+ '\r\n'+ '$buttons\r\n'+ '\r\n'+ ' Esc to cancel · ↑/↓ to navigate';++ Future<_Focus> asked(WidgetTester tester, {String? buttons}) async {+ final focus = await _Focus.open(tester);+ focus.session.terminal.write(+ buttons == null ? elicitation() : elicitation(buttons: buttons),+ );+ await frames(tester);+ return focus;+ }++ testWidgets('Accept and Decline are each a button, and Accept with the '+ 'caret on it is Enter', (tester) async {+ final semantics = tester.ensureSemantics();+ final focus = await asked(tester);+ expect(find.text('tap an answer · or say it'), findsOneWidget);+ expect(find.semantics.byLabel('Answer 2 Decline'), findsOne);+ tester.semantics.tap(find.semantics.byLabel('Answer 1 Accept'));+ await frames(tester);+ expect(focus.typed, ['\r']);+ await focus.close();+ semantics.dispose();+ });++ testWidgets('a tap on Decline moves the caret over, and presses Enter only '+ 'once the pane shows it there', (tester) async {+ final focus = await asked(tester);+ await focus.tapText('Decline');+ await frames(tester);+ expect(focus.typed, hasLength(1));+ expect(focus.typed.single, anyOf('\x1b[C', '\x1bOC'));++ // Claude Code redraws the row with the caret on Decline.+ focus.session.terminal.write(+ '\x1b[2J\x1b[H${elicitation(buttons: ' Accept ❯ Decline')}',+ );+ await tester.pump(const Duration(milliseconds: 200));+ await tester.pump(const Duration(milliseconds: 400));+ await frames(tester);+ expect(focus.typed.last, '\r');+ expect(focus.typed.where((key) => key == '\r'), hasLength(1));+ await focus.close();+ });++ testWidgets('"no" said to the mic declines it', (tester) async {+ final focus = await asked(tester);+ focus.stt.replies.add('No.');+ await tester.tap(find.byType(VoiceMicCore));+ await frames(tester);+ await tester.tap(find.byType(VoiceMicCore));+ await frames(tester);+ expect(focus.typed, hasLength(1));+ expect(focus.typed.single, anyOf('\x1b[C', '\x1bOC'));+ await focus.close();+ });++ testWidgets('a form: the keyboard comes up for its fields, Enter on its '+ 'strip', (tester) async {+ final focus = await asked(tester, buttons: ' Accept Decline');+ expect(find.bySemanticsLabel(RegExp('^Answer ')), findsNothing);+ expect(find.byKey(const ValueKey('terminal-key-Enter')), findsOneWidget);+ await focus.close();+ });+ });++ testWidgets('a dialog the page cannot read: a tap anywhere on it raises the '+ 'keyboard', (tester) async {+ final focus = await _Focus.open(tester);+ focus.session.terminal.write(+ '\r\n──────────────────────────────\r\n'+ ' Pick a colour\r\n'+ '\r\n'+ ' ❯ Red Blue\r\n'+ '\r\n'+ ' Esc to cancel · ←/→ to choose',+ );+ await frames(tester);+ expect(find.byKey(const ValueKey('terminal-key-esc')), findsNothing);+ await focus.tapRow('Red');+ await frames(tester);+ expect(find.byKey(const ValueKey('terminal-key-esc')), findsOneWidget);+ await focus.close();+ });+testWidgets('↵ breaks the prompt\'s line without sending the turn', (tester,) async {@@ -1198,6 +1294,30 @@ class _Focus {await _widgetTester.tapAt(Offset(view.left + 40, y));}+ /// A tap on the middle of [text] where the terminal draws it — the lowest place it appears.+ Future<void> tapText(String text) async {+ final view = _widgetTester.state<TerminalViewState>(+ find.byType(TerminalView),+ );+ final render = view.renderTerminal;+ final lines = view.widget.terminal.buffer.lines;+ var row = -1;+ var column = -1;+ for (var i = 0; i < lines.length; i++) {+ final at = lines[i].getText().indexOf(text);+ if (at < 0) continue;+ row = i;+ column = at;+ }+ expect(row, isNot(-1), reason: '"$text" is on the screen');+ final cell = render.getOffset(CellOffset(column + text.length ~/ 2, row));+ await _widgetTester.tapAt(+ render.localToGlobal(+ cell + Offset(render.cellSize.width / 2, render.lineHeight / 2),+ ),+ );+ }+/// [agentId] stops to ask something, as its machine announces it.Future<void> question(String agentId) => app.handleMachineEventForTest('m', {'type': 'commander_question',diff --git a/mobile/test/question_keys_test.dart b/mobile/test/question_keys_test.dartindex 8933a637d..736b83fef 100644--- a/mobile/test/question_keys_test.dart+++ b/mobile/test/question_keys_test.dart@@ -70,4 +70,32 @@ void main() {expect(matchSpokenAnswer('the fast one', choice), isNull);expect(matchSpokenAnswer('two', choice)?.number, '2');});++ test('an MCP server\'s Accept and Decline answer to yes and no', () {+ final elicitation = parseQuestionLines([+ '───────────────────────────────────────────────',+ ' MCP server “claude.ai Supabase” requests your input',+ '',+ ' This SQL includes destructive operations…',+ '',+ ' ❯ Accept Decline',+ '',+ ' Esc to cancel · ↑/↓ to navigate',+ ], QuestionEngine.claude)!;+ String? press(String said) =>+ matchSpokenAnswer(said, elicitation)?.number;+ expect(questionKeys(elicitation), [+ (label: 'accept', number: '1'),+ (label: 'decline', number: '2'),+ ]);+ expect(press('Accept.'), '1');+ expect(press('yes'), '1');+ expect(press('go ahead'), '1');+ expect(press('Decline'), '2');+ expect(press('no'), '2');+ expect(press('reject it'), '2');+ expect(press('cancel'), '2');+ // Nowhere to put other words: nothing is sent.+ expect(press('drop the other table too'), isNull);+ });}diff --git a/mobile/test/question_pane_elicitation_test.dart b/mobile/test/question_pane_elicitation_test.dartnew file mode 100644index 000000000..701f6cf29--- /dev/null+++ b/mobile/test/question_pane_elicitation_test.dart@@ -0,0 +1,238 @@+import 'package:fake_async/fake_async.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/terminal/question_pane.dart';+import 'package:harness_mobile/terminal/question_pane_watcher.dart';+import 'package:xterm/xterm.dart';++/// Claude Code 2.1.299's MCP elicitation, as captured from a live 47-column+/// pane (openharness#1272): the server's name cut to fit, the caret on Accept.+const _narrow = [+ ' ◉ xhigh · /effort',+ '───────────────────────────────────────────────',+ ' MCP server “elicit-…” requests your input',+ '',+ ' This SQL includes destructive operations…',+ '',+ ' ❯ Accept Decline',+ '',+ ' Esc to cancel · ↑/↓ to navigate',+];++/// The same dialog on a 95-column pane: the message straight under the title,+/// with no blank line between them.+const _wide = [+ ' Calling elicit-test… (ctrl+o to expand)',+ '',+ '───────────────────────────────────────────────────────────────────',+ ' MCP server “elicit-test” requests your input',+ ' This SQL includes destructive operations (DROP TABLE). It may p…',+ '',+ ' ❯ Accept Decline',+ '',+ ' Esc to cancel · ↑/↓ to navigate',+ '',+ '',+];++QuestionPaneView? _parse(List<String> lines) =>+ parseQuestionLines(lines, QuestionEngine.claude);++List<String> _withButtons(List<String> lines, String buttons) => [+ for (final line in lines) line.contains('Accept') ? buttons : line,+];++void main() {+ group('an MCP server asking', () {+ test('is read as a dialog with Accept and Decline, caret on Accept', () {+ final view = _parse(_narrow)!;+ expect(view.kind, QuestionPaneKind.elicitation);+ expect(view.question, 'MCP server “elicit-…” requests your input');+ expect(view.rows.map((r) => (r.number, r.label)), [+ ('1', 'Accept'),+ ('2', 'Decline'),+ ]);+ expect(view.focused, '1');+ expect(view.answerable, isTrue);+ expect(view.tappable, isTrue);+ });++ test('the message under the title is not taken into the question', () {+ expect(+ _parse(_wide)!.question,+ 'MCP server “elicit-test” requests your input',+ );+ });++ test('a title the pane wrapped is stitched back together', () {+ // As the issue's screenshot shows it: the server's whole name, and the+ // line broken after "requests".+ final view = _parse([+ '───────────────────────────────────────────',+ ' MCP server “claude.ai Supabase” requests',+ ' your input',+ '',+ ' This SQL includes destructive operatio…',+ ' It may permanently remove data, tables…',+ ' Apply the migration to project qeiixie…',+ '',+ ' ❯ Accept Decline',+ '',+ ' Esc to cancel · ↑/↓ to navigate',+ ])!;+ expect(+ view.question,+ 'MCP server “claude.ai Supabase” requests your input',+ );+ });++ test('the caret on Decline', () {+ final view = _parse(_withButtons(_narrow, ' Accept ❯ Decline'))!;+ expect(view.focused, '2');+ expect(view.tappable, isTrue);+ });++ test('a form with a field holding the caret is open but not tappable', () {+ final view = _parse(_withButtons(_narrow, ' Accept Decline'))!;+ expect(view.focused, isNull);+ expect(view.answerable, isTrue);+ expect(view.tappable, isFalse);+ });++ test('the same dialog, wherever its caret is, is the same question', () {+ final accept = _parse(_narrow)!;+ final decline = _parse(_withButtons(_narrow, ' Accept ❯ Decline'))!;+ final field = _parse(_withButtons(_narrow, ' Accept Decline'))!;+ expect(decline.fingerprint, accept.fingerprint);+ expect(field.fingerprint, accept.fingerprint);+ });++ test('answered: output under the buttons means it is gone', () {+ expect(+ _parse([+ ..._narrow,+ '',+ '⏺ elicit-test - apply_migration (MCP)',+ ' ⎿ User answered: accept',+ ]),+ isNull,+ );+ });++ test('buttons with no footer under them are not a live dialog', () {+ expect(_parse(_narrow.sublist(0, 7)), isNull);+ });++ test('an Accept/Decline row with no MCP title above is not one', () {+ expect(+ _parse([+ '───────────────────────────────────────────────',+ ' Something else entirely',+ '',+ ' ❯ Accept Decline',+ '',+ ' Esc to cancel · ↑/↓ to navigate',+ ]),+ isNull,+ );+ });++ test('a title above the rule belongs to an older dialog', () {+ expect(+ _parse([+ ' MCP server “old” requests your input',+ '───────────────────────────────────────────────',+ ' Not a title',+ '',+ ' ❯ Accept Decline',+ '',+ ' Esc to cancel · ↑/↓ to navigate',+ ]),+ isNull,+ );+ });++ test('Codex panes are not read for it', () {+ expect(parseQuestionLines(_narrow, QuestionEngine.codex), isNull);+ });+ });++ group('where Accept and Decline are drawn', () {+ test('two bands on the one button row, side by side', () {+ final terminal = Terminal(maxLines: 200)..resize(47, 12);+ terminal.write(_narrow.join('\r\n'));+ final view = readQuestionPane(terminal, QuestionEngine.claude)!;+ final answers = questionAnswerLines(terminal, view);+ expect(answers, hasLength(2));+ final row = answers.first.first;+ final line = terminal.buffer.lines[row].getText();+ expect(line, contains('Accept'));+ final accept = answers[0];+ final decline = answers[1];+ expect(accept.number, '1');+ expect(decline.number, '2');+ expect((accept.first, accept.last), (row, row));+ expect((decline.first, decline.last), (row, row));+ // Each covers its own word, and they meet without overlapping.+ final acceptAt = line.indexOf('Accept');+ final declineAt = line.indexOf('Decline');+ expect(accept.columns!.start, lessThanOrEqualTo(acceptAt));+ expect(accept.columns!.end, greaterThanOrEqualTo(acceptAt + 6));+ expect(decline.columns!.start, accept.columns!.end);+ expect(decline.columns!.start, lessThanOrEqualTo(declineAt - 2));+ expect(decline.columns!.end, greaterThanOrEqualTo(declineAt + 7));+ expect(decline.columns!.end, lessThanOrEqualTo(47));+ });++ test('numbered answers keep their full width', () {+ final terminal = Terminal(maxLines: 200)..resize(47, 12);+ terminal.write(+ [+ '───────────────────────────────────────────────',+ ' Do you want to proceed?',+ ' ❯ 1. Yes',+ ' 2. No',+ '',+ ' Esc to cancel · Enter to select',+ ].join('\r\n'),+ );+ final view = readQuestionPane(terminal, QuestionEngine.claude)!;+ final answers = questionAnswerLines(terminal, view);+ expect(answers.map((a) => a.columns), [null, null]);+ });+ });++ test('the watcher tells the page when a form\'s caret reaches its buttons', () {+ fakeAsync((async) {+ final terminal = Terminal(maxLines: 200)..resize(47, 12);+ final watcher = QuestionPaneWatcher(engine: QuestionEngine.claude);+ var notified = 0;+ watcher.addListener(() => notified++);+ watcher.attach(terminal);++ terminal.write(+ _withButtons(_narrow, ' Accept Decline').join('\r\n'),+ );+ async.elapse(const Duration(milliseconds: 300));+ final form = watcher.view!;+ expect(form.tappable, isFalse);+ final before = notified;++ // The caret moves from the field onto Accept: the same question, now one a tap answers.+ terminal.write('\x1b[2J\x1b[H${_narrow.join('\r\n')}');+ async.elapse(const Duration(milliseconds: 300));+ expect(notified, greaterThan(before));+ expect(watcher.view!.tappable, isTrue);+ expect(watcher.view!.fingerprint, form.fingerprint);++ // Between the two buttons nothing a tap can do changes, so nothing is said.+ final settled = notified;+ terminal.write(+ '\x1b[2J\x1b[H${_withButtons(_narrow, ' Accept ❯ Decline').join('\r\n')}',+ );+ async.elapse(const Duration(milliseconds: 300));+ expect(notified, settled);++ watcher.dispose();+ });+ });+}diff --git a/mobile/test/terminal_prompt_zone_test.dart b/mobile/test/terminal_prompt_zone_test.dartindex 25767a91c..9def6190b 100644--- a/mobile/test/terminal_prompt_zone_test.dart+++ b/mobile/test/terminal_prompt_zone_test.dart@@ -90,4 +90,69 @@ void main() {expect(isPromptTap(terminal.buffer, 8), isFalse);},);++ group('a dialog drawn where the prompt was', () {+ // Claude Code with an MCP server's Accept/Decline open, as captured from a live pane+ // (openharness#1272): the prompt hidden, the cursor parked on the blank row under the footer.+ const dialog = [+ ' output',+ '',+ '────────────────────────────────────────',+ ' MCP server “x” requests your input',+ '',+ ' This SQL includes destructive op…',+ '',+ ' ❯ Accept Decline',+ '',+ ' Esc to cancel · ↑/↓ to navigate',+ '',+ '',+ ];++ test('counts whole, from the rule over it down', () {+ final terminal = _screen(dialog, cursorLine: 10);+ expect(_promptRows(terminal).first, 2);+ // The buttons themselves, which the cursor alone left out.+ expect(isPromptTap(terminal.buffer, 7), isTrue);+ expect(isPromptTap(terminal.buffer, 1), isFalse);+ });++ test('keeps the cursor\'s zone where the host answers its rows itself', () {+ final terminal = _screen(dialog, cursorLine: 10);+ expect(isPromptTap(terminal.buffer, 7, wholeDialog: false), isFalse);+ expect(isPromptTap(terminal.buffer, 9, wholeDialog: false), isTrue);+ });++ test('a rule with no footer under it is output, not a dialog', () {+ final terminal = _screen([+ for (var i = 0; i < 4; i++) 'output $i',+ '----------------------------------------',+ 'build ok',+ 'tests ok',+ 'lint ok',+ 'deploy ok',+ 'done',+ '',+ '',+ ], cursorLine: 11);+ expect(isPromptTap(terminal.buffer, 6), isFalse);+ });++ test('the prompt box under its rule is the prompt, not a dialog', () {+ final terminal = _screen(+ [+ ' answer',+ '',+ '────────────────────────────────────────',+ '❯ ',+ '────────────────────────────────────────',+ ' ⏵⏵ auto mode on (shift+tab to cycle)',+ ],+ cursorLine: 3,+ alt: true,+ );+ expect(_promptRows(terminal).first, 2);+ expect(isPromptTap(terminal.buffer, 1), isFalse);+ });+ });}