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): move key hints into the key bar

tony0c8763a6f320
diff --git a/mobile/lib/phone/terminal_input_dock.dart b/mobile/lib/phone/terminal_input_dock.dart
index 5aa832e2e..fcfc6462c 100644
--- a/mobile/lib/phone/terminal_input_dock.dart
+++ b/mobile/lib/phone/terminal_input_dock.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
+import 'package:harness_mobile/terminal/key_hints.dart';
import 'package:harness_mobile/terminal/terminal_session.dart';
import 'terminal_key_bar.dart';
@@ -34,6 +35,7 @@ class TerminalInputDock extends StatefulWidget {
this.onPickImage,
this.onTakePhoto,
this.questionOpen = false,
+ this.hints = const [],
});
final TerminalSession session;
@@ -42,6 +44,9 @@ class TerminalInputDock extends StatefulWidget {
/// [TerminalKeyBar.questionOpen].
final bool questionOpen;
+ /// The keys the pane's chrome offers — see [TerminalKeyBar.hints].
+ final List<KeyHint> hints;
+
/// The software keyboard is up, or has been asked for and is on its way.
final bool keyboardUp;
@@ -119,6 +124,7 @@ class _TerminalInputDockState extends State<TerminalInputDock>
onPickImage: widget.onPickImage,
onTakePhoto: widget.onTakePhoto,
questionOpen: widget.questionOpen,
+ hints: widget.hints,
),
),
builder: (context, child) {
diff --git a/mobile/lib/phone/terminal_key_bar.dart b/mobile/lib/phone/terminal_key_bar.dart
index ec2b695b3..6b6440964 100644
--- a/mobile/lib/phone/terminal_key_bar.dart
+++ b/mobile/lib/phone/terminal_key_bar.dart
@@ -1,9 +1,12 @@
+import 'package:flutter/foundation.dart' show listEquals;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:xterm/xterm.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart';
+import 'package:harness_mobile/terminal/key_hints.dart';
+import 'package:harness_mobile/terminal/terminal_font_store.dart';
import 'phone_sheet.dart';
@@ -37,6 +40,15 @@ import 'phone_sheet.dart';
/// on screen says so, and on a dialog that reads "enter to submit answer" a
/// strip of every other key it names reads as "Enter is missing". `/` is the
/// slot to give up: a dialog has no prompt to start a command in.
+///
+/// ⚠️ **The other exception: the pane's own keys — [hints] — join the row, and
+/// only then does it scroll.** They are what Codex offers on this screen and
+/// nowhere else (`ctrl+] skip`, `⌥+↓ main prompt`), so they follow the arrows
+/// on the SAME row, which scrolls sideways while they are there and brings
+/// them into view as they arrive. Never a line of their own: a second row
+/// cost the terminal a line of output, and a strip of buttons floating over
+/// the pane covered the very hints it was read off. The fixed keys keep their
+/// size either way — only how far along the row is scrolled changes.
class TerminalKeyBar extends StatefulWidget {
const TerminalKeyBar({
super.key,
@@ -47,6 +59,7 @@ class TerminalKeyBar extends StatefulWidget {
this.onPickImage,
this.onTakePhoto,
this.questionOpen = false,
+ this.hints = const [],
});
final Terminal terminal;
@@ -55,6 +68,12 @@ class TerminalKeyBar extends StatefulWidget {
/// see the class docblock.
final bool questionOpen;
+ /// The keys the pane's chrome offers and a phone cannot press — see
+ /// [parseKeyHints]. Each is drawn as the key and Codex's own word for what
+ /// it does, as the pane printed them, in the terminal's face — so it reads
+ /// as the hint it was read off. Empty leaves the row as it always was.
+ final List<KeyHint> hints;
+
/// Called after `tab` or `/` changed the prompt without the software
/// keyboard knowing — so its buffer can be emptied before it edits words the
/// prompt no longer holds.
@@ -152,6 +171,22 @@ class _TerminalKeyBarState extends State<TerminalKeyBar> {
if (_ctrl || _shift) setState(() => _ctrl = _shift = false);
}
+ /// Presses the chord a hint named, as the pane printed it — nothing else:
+ /// what the key does is the CLI's, and it redraws the screen to say so.
+ ///
+ /// ⚠️ **Armed modifiers are put down, never added.** A hint is already the
+ /// whole chord, and a `ctrl` left lit would turn `shift+←` into a key the CLI
+ /// never offered — so, like [_sendKey], nothing armed outlives the tap.
+ ///
+ /// The keyboard's buffer is emptied after it, as after `tab`: these keys move
+ /// between a question and the prompt, and the buffer still holds words typed
+ /// into the one just left.
+ void _sendHint(KeyHint hint) {
+ hint.chord.send(widget.terminal);
+ widget.onPromptEdited?.call();
+ if (_ctrl || _shift) setState(() => _ctrl = _shift = false);
+ }
+
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
@@ -240,22 +275,12 @@ class _TerminalKeyBarState extends State<TerminalKeyBar> {
child: MediaQuery.withNoTextScaling(
// Every key the same width, the two apart ones included — they are
// separated by the rule, not by being a different size.
- child: Row(
- children: [
- ..._row(keys),
- // The rule earns its place only when there are two kinds of
- // thing to separate. Against an older CLI the image key is
- // absent and `⌄` is all that is left, so a rule drawn for it
- // alone would be marking a distinction that is no longer made.
- if (_canSendImage) ...[
- const SizedBox(width: 8),
- Container(width: 1, height: 22, color: AppGlass.hair),
- const SizedBox(width: 8),
- ] else
- const SizedBox(width: 4),
- ..._row(apart),
- ],
- ),
+ child: widget.hints.isEmpty
+ ? Row(children: [..._row(keys), ..._rule(), ..._row(apart)])
+ : LayoutBuilder(
+ builder: (context, constraints) =>
+ _rowWithHints(keys, apart, constraints.maxWidth),
+ ),
),
),
),
@@ -272,6 +297,134 @@ class _TerminalKeyBarState extends State<TerminalKeyBar> {
],
];
+ /// The rule between the keys the pty receives and the two that act on the
+ /// phone.
+ ///
+ /// It earns its place only when there are two kinds of thing to separate.
+ /// Against an older CLI the image key is absent and `⌄` is all that is left,
+ /// so a rule drawn for it alone would be marking a distinction that is no
+ /// longer made.
+ List<Widget> _rule() => _canSendImage
+ ? [
+ const SizedBox(width: 8),
+ Container(width: 1, height: 22, color: AppGlass.hair),
+ const SizedBox(width: 8),
+ ]
+ : [const SizedBox(width: 4)];
+
+ /// How wide [_rule] is — `8 + 1 + 8`, or the single gap in its place.
+ double get _ruleWidth => _canSendImage ? 17 : 4;
+
+ /// The row while the pane offers its own keys: the fixed keys, then
+ /// [TerminalKeyBar.hints], scrolling sideways together; the two apart keys
+ /// stay pinned past the rule.
+ ///
+ /// ⚠️ **Every fixed key keeps exactly the width [_row] gives it.** The cell
+ /// is worked out the way the `Expanded` row divides [width] — the same keys,
+ /// gaps and rule — so the keys do not shrink or move when a hint arrives:
+ /// they fill the visible part of the row as they always do, and the hints
+ /// start where it ends. [_revealHints] then scrolls them into view.
+ Widget _rowWithHints(List<Widget> keys, List<Widget> apart, double width) {
+ const gap = 4.0;
+ final gaps =
+ gap * (keys.length - 1) + _ruleWidth + gap * (apart.length - 1);
+ final cell = (width - gaps) / (keys.length + apart.length);
+ if (!cell.isFinite || cell <= 0) {
+ return Row(children: [..._row(keys), ..._rule(), ..._row(apart)]);
+ }
+ final hints = widget.hints;
+ return Row(
+ children: [
+ Expanded(
+ child: SingleChildScrollView(
+ controller: _scroll,
+ scrollDirection: Axis.horizontal,
+ child: Row(
+ children: [
+ ..._cells(keys, cell),
+ // The pane's keys are not the strip's: a hairline says so,
+ // the way the rule sets the phone's own two apart.
+ const SizedBox(width: 6),
+ Container(width: 1, height: 22, color: AppGlass.hair),
+ const SizedBox(width: 6),
+ for (var i = 0; i < hints.length; i++) ...[
+ if (i > 0) const SizedBox(width: gap),
+ _hint(hints[i]),
+ ],
+ ],
+ ),
+ ),
+ ),
+ ..._rule(),
+ ..._cells(apart, cell),
+ ],
+ );
+ }
+
+ /// A run of keys at a fixed [width] each — [_row]'s layout, in a row that
+ /// scrolls and so cannot divide itself with `Expanded`.
+ List<Widget> _cells(List<Widget> keys, double width) => [
+ for (var index = 0; index < keys.length; index++) ...[
+ if (index > 0) const SizedBox(width: 4),
+ SizedBox(width: width, child: keys[index]),
+ ],
+ ];
+
+ /// Keeps the fixed keys and the hints on one row.
+ final ScrollController _scroll = ScrollController();
+
+ @override
+ void initState() {
+ super.initState();
+ // The strip opens with the keyboard, and a pane already offering its keys
+ // shows them as it does.
+ if (widget.hints.isNotEmpty) _revealHints();
+ }
+
+ @override
+ void didUpdateWidget(TerminalKeyBar oldWidget) {
+ super.didUpdateWidget(oldWidget);
+ if (widget.hints.isNotEmpty && !listEquals(widget.hints, oldWidget.hints)) {
+ _revealHints();
+ }
+ }
+
+ @override
+ void dispose() {
+ _scroll.dispose();
+ super.dispose();
+ }
+
+ /// Scrolls the row to its end, where the hints are, once they are laid out.
+ ///
+ /// ⚠️ **Brought into view, not left past the edge.** The fixed keys fill the
+ /// visible row by design, so hints that simply joined it would start just
+ /// out of sight and read as no hints at all. Only a new set of hints moves
+ /// the row; the same ones redrawn leave it wherever it was swiped to.
+ void _revealHints() {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (!mounted || !_scroll.hasClients) return;
+ final end = _scroll.position.maxScrollExtent;
+ if (_scroll.offset == end) return;
+ _scroll.animateTo(
+ end,
+ duration: const Duration(milliseconds: 250),
+ curve: Curves.easeOut,
+ );
+ });
+ }
+
+ Widget _hint(KeyHint hint) => Semantics(
+ button: true,
+ label: '${hint.action}, ${hint.keyText}',
+ child: _KeyCap(
+ hint: hint,
+ live: widget.enabled,
+ armed: false,
+ onTap: () => _send(() => _sendHint(hint)),
+ ),
+ );
+
Widget _key({
String? label,
IconData? icon,
@@ -311,15 +464,27 @@ class _TerminalKeyBarState extends State<TerminalKeyBar> {
/// feedback is worth nothing.
class _KeyCap extends StatefulWidget {
const _KeyCap({
- required this.label,
- required this.icon,
+ this.label,
+ this.icon,
+ this.hint,
required this.live,
required this.armed,
required this.onTap,
- });
+ }) : assert(
+ (label != null ? 1 : 0) +
+ (icon != null ? 1 : 0) +
+ (hint != null ? 1 : 0) ==
+ 1,
+ 'a key carries one of the three',
+ );
final String? label;
final IconData? icon;
+
+ /// One of the pane's own keys — see [TerminalKeyBar.hints]. As wide as its
+ /// words, rather than one of the row's equal cells.
+ final KeyHint? hint;
+
final bool live;
/// A modifier that is DOWN, waiting for the key it belongs to.
@@ -346,6 +511,7 @@ class _KeyCapState extends State<_KeyCap> {
Widget build(BuildContext context) {
AppTheme.watch(context);
final lit = (_down || widget.armed) && widget.live;
+ final hint = widget.hint;
final foreground = lit
? AppPalette.accentOnSurface
: widget.live
@@ -376,7 +542,9 @@ class _KeyCapState extends State<_KeyCap> {
color: lit ? AppPalette.accentOnSurface : AppGlass.lift,
),
),
- child: widget.icon != null
+ child: hint != null
+ ? _hintFace(hint, foreground: foreground, lit: lit)
+ : widget.icon != null
? Icon(widget.icon, size: 16, color: foreground)
// Shrinks rather than clips: ten keys share a phone's width, and
// `clear` is the widest word among them.
@@ -399,4 +567,48 @@ class _KeyCapState extends State<_KeyCap> {
),
);
}
+
+ /// A [_KeyCap.hint]'s face: the key as the pane printed it, then the CLI's
+ /// word for what it does, quieter — both in the terminal's own face,
+ /// followed live, since Settings ▸ Terminal can change it while the row is
+ /// up.
+ Widget _hintFace(
+ KeyHint hint, {
+ required Color foreground,
+ required bool lit,
+ }) => Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 10),
+ child: ValueListenableBuilder<TerminalStyle>(
+ valueListenable: terminalFontStore,
+ builder: (context, face, _) {
+ TextStyle style(Color color, FontWeight weight) => TextStyle(
+ fontFamily: face.fontFamily,
+ fontFamilyFallback: face.fontFamilyFallback,
+ fontSize: 12,
+ height: 1,
+ color: color,
+ fontWeight: weight,
+ );
+ return Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(hint.keyText, style: style(foreground, FontWeight.w600)),
+ const SizedBox(width: 6),
+ Text(
+ hint.action,
+ maxLines: 1,
+ style: style(
+ lit
+ ? foreground
+ : widget.live
+ ? AppPalette.textSecondary
+ : AppPalette.textFaint,
+ FontWeight.w400,
+ ),
+ ),
+ ],
+ );
+ },
+ ),
+ );
}
diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dart
index a32343056..4d391ea0a 100644
--- a/mobile/lib/phone/terminal_page.dart
+++ b/mobile/lib/phone/terminal_page.dart
@@ -9,8 +9,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
-// `TerminalStyle` — the key-hint chips wear the terminal's own face.
-import 'package:xterm/xterm.dart' show TerminalStyle;
import 'package:harness_mobile/core/models.dart' show Agent, AgentProject;
import 'package:harness_mobile/shared/theme/app_theme.dart';
@@ -423,6 +421,9 @@ class _TerminalPageState extends State<TerminalPage>
if (_settleTimer != null || _slideTimer != null) return;
if (!mounted || !_keyboardSettling) return;
setState(() => _keyboardSettling = false);
+ // The keyboard has stopped moving, so whether it is up is now a fact: a
+ // question read while it moved is decided here. See [_raiseForQuestion].
+ _raiseForQuestion();
}
/// What the last build read from the notifier — the baseline [_onNotifier]
@@ -502,6 +503,10 @@ class _TerminalPageState extends State<TerminalPage>
/// same questions wait stays away.
QueuedQuestions? _queueRaisedFor;
+ /// Whether this page's session took input as of the last [_onNotifier] —
+ /// so the moment it starts to can be told apart from every other tick.
+ bool _acceptedInput = false;
+
/// Point the question watcher at this page's current terminal.
///
/// Called from `build`, where both the engine and the session are known, and
@@ -540,29 +545,51 @@ class _TerminalPageState extends State<TerminalPage>
// again even if it words itself identically.
if (!open) _questionRaisedFor = null;
});
- // A queued question — Codex's async kind — raises the keyboard too, once
- // per change of the queue, by the same rule as a dialog below: the answer
- // is typed, and the band's key and the chip are pressed, with it up. The
- // header comes back with it, so the band is seen.
- //
- // ⚠️ **Marked only once the keyboard could actually be raised.** A queue
- // read before the session takes input — a page opened onto an agent that
- // already has one waiting — would otherwise be recorded as raised for, and
- // nothing would try again until the queue changed.
- final queued = _questionWatcher?.queued;
- if (queued == null) {
- _queueRaisedFor = null;
- } else if (!open &&
- queued != _queueRaisedFor &&
- (_readFacts().session?.acceptsInput ?? false)) {
- _queueRaisedFor = queued;
- _chrome.reveal();
+ if (_questionWatcher?.queued == null) _queueRaisedFor = null;
+ _raiseForQuestion();
+ }
+
+ /// Raise the keyboard for the question on the pane, if it has not had its
+ /// one raise yet — see [_questionRaisedFor] and [_queueRaisedFor].
+ ///
+ /// ⚠️ **A question is marked only once its raise could be DECIDED, and two
+ /// moments cannot decide it.** While the session takes no input a keyboard
+ /// would type nothing, so [_raiseKeyboardForQuestion] backs out — a page
+ /// opened onto an agent already asking. And while the keyboard is moving
+ /// ([_keyboardSettling]) the page cannot tell one on its way down from one
+ /// that is up: a dialog read mid-`⌄` found the keyboard still on screen,
+ /// counted it as the person's own, and marked the question — the keyboard
+ /// finished leaving and nothing raised it again.
+ ///
+ /// ⚠️ **On a simulator with "Connect Hardware Keyboard" on, none of this
+ /// shows a keyboard**, and that is iOS, not this: with a hardware keyboard
+ /// attached it answers a focus with the key strip alone and no software
+ /// keyboard, for a tap and for this alike. Measured: the claim landed, the
+ /// input connection opened, the key strip rose with `⏎`, and the inset
+ /// stayed at zero.
+ ///
+ /// Marking in either moment spent the one raise on nothing. So neither marks:
+ /// this is asked again when the session starts taking input ([_onNotifier])
+ /// and when the keyboard stops moving ([_endSettle]), and decides then.
+ void _raiseForQuestion() {
+ final watcher = _questionWatcher;
+ if (watcher == null || _keyboardSettling) return;
+ if (!(_readFacts().session?.acceptsInput ?? false)) return;
+ final view = watcher.view;
+ if (view != null && view.answerable) {
+ final key = view.fingerprint;
+ if (_questionRaisedFor == key) return;
+ _questionRaisedFor = key;
_raiseKeyboardForQuestion();
+ return;
}
- if (!open) return;
- final key = view.fingerprint;
- if (_questionRaisedFor == key) return;
- _questionRaisedFor = key;
+ // A queued question — Codex's async kind — raises the keyboard too, once
+ // per change of the queue, by the same rule as a dialog above: its
+ // `shift+← to answer` is a key on the key strip, and the strip is only on
+ // screen while the keyboard is.
+ final queued = watcher.queued;
+ if (queued == null || queued == _queueRaisedFor) return;
+ _queueRaisedFor = queued;
_raiseKeyboardForQuestion();
}
@@ -590,35 +617,21 @@ class _TerminalPageState extends State<TerminalPage>
if (_keyboardRequested || _ownsInput) return;
// The controls somebody reaches for next are in the header.
_chrome.reveal();
- setState(() => _keyboardRequested = true);
+ setState(() {
+ _keyboardRequested = true;
+ // ⚠️ **The claim is asked for outright, not left to `focused` turning
+ // true.** A tap raises the keyboard through the terminal's own gesture;
+ // this has no tap, only the flag — and a flag the panel already reads as
+ // true (the screen-wide [_keyboardIsUp] a moment behind a keyboard just
+ // put away) is no change for it to act on. See [_restoreKeyboard], which
+ // hit the same wall.
+ _focusRequest++;
+ });
// The keyboard is on its way and the key bar opens with it — see
// [_raiseKeyboard], which holds the resize the same way.
_armSettle();
}
- /// The band's Answer: press the key Codex named for opening its queued
- /// question, and bring the keyboard up for the answer.
- ///
- /// ⚠️ **The key the hint showed, not a Shift+Left of this page's own** — see
- /// `KeyChord`. Once Codex opens the question it is an ordinary dialog on the
- /// pane, and [_onQuestionPane] takes it from there.
- void _answerQueuedQuestion() {
- final queued = _questionWatcher?.queued;
- final session = _readFacts().session;
- if (queued == null || session == null || !session.acceptsInput) return;
- if (!queued.answerKey.send(session.terminal)) return;
- _raiseKeyboardForQuestion();
- }
-
- /// A key-hint chip: press the chord the pane's chrome named. Nothing else —
- /// what the key does is the CLI's, and it redraws the screen to say so.
- void _pressHint(KeyHint hint) {
- final session = _readFacts().session;
- if (session == null || !session.acceptsInput) return;
- HapticFeedback.selectionClick();
- hint.chord.send(session.terminal);
- }
-
_PageFacts _readFacts() {
final notifier = widget.notifier;
final pane = notifier.panes
@@ -672,6 +685,13 @@ class _TerminalPageState extends State<TerminalPage>
void _onNotifier() {
if (!mounted) return;
final facts = _readFacts();
+ // The session has just started taking input: a question read before it
+ // could has its raise decided now. See [_raiseForQuestion].
+ final accepts = facts.session?.acceptsInput ?? false;
+ if (accepts != _acceptedInput) {
+ _acceptedInput = accepts;
+ if (accepts) _raiseForQuestion();
+ }
// ⚠️ Checked BEFORE the equality bail below, not after. A take that ends where it began —
// `takenOver` again, because the other app answered first — moves no fact this page reads, so
// the bail would keep the band saying "Taking control…" over a page that had already been
@@ -1281,26 +1301,14 @@ class _TerminalPageState extends State<TerminalPage>
!agentGone &&
session != null &&
(session.watching || session.status == TerminalSessionStatus.takenOver);
- // Codex's queued async questions, for the band under the header. Only where
- // the key can be pressed — not on a pane that cannot type, whose own band
- // is up instead — and not once a question is open, when the dialog itself
- // is what is on screen.
- final queued = _questionWatcher?.queued;
- final queuedBanner =
- queued != null &&
- !blocked &&
- _reclaiming == null &&
- (session?.acceptsInput ?? false) &&
- _questionWatcher?.view == null
- ? queued
- : null;
// The keys the pane's chrome offers and a phone cannot press — see
- // [parseKeyHints]. Not on a pane that cannot type.
+ // [parseKeyHints], and [TerminalKeyBar.hints] for where they are drawn.
+ // Not on a pane that cannot type.
//
- // ⚠️ **The queued question's own key included, band or no band.** It was
- // left out while the band was up, as the same press twice — and the chip
- // is where the eye goes: beside `shift+← to answer` at the foot of the
- // pane, where the band's button, up under the header, was not looked for.
+ // ⚠️ **A queued Codex question is answered from here, and only here.** Its
+ // `shift+← to answer` is one of these keys; a band under the header that
+ // offered the same press was taken out — the one band up there is "Take
+ // control" ([_ControlBanner]), for a pane that cannot type at all.
final keyHints = agentGone || blocked || !(session?.acceptsInput ?? false)
? const <KeyHint>[]
: _questionWatcher?.hints ?? const <KeyHint>[];
@@ -1561,23 +1569,6 @@ class _TerminalPageState extends State<TerminalPage>
// says, the key bar is already under the thumb, and
// a column floating over the prompt being typed into
// would be in the way of both.
- // The chrome's own keys as buttons — see
- // [_KeyHintChips]. Laid OVER the pane, like the
- // column below, so they come and go without
- // resizing the terminal; and down at its foot,
- // under the column, where the hints they stand
- // for are drawn.
- if (keyHints.isNotEmpty &&
- session != null &&
- session.hasRenderedFrame)
- Positioned(
- right: 8,
- bottom: 6,
- child: _KeyHintChips(
- hints: keyHints,
- onPress: _pressHint,
- ),
- ),
// ⚠️ **Search stays while the keyboard is up; the
// mic goes.** Typing says what the mic says, so
// with a keyboard on screen the two are one
@@ -1625,6 +1616,7 @@ class _TerminalPageState extends State<TerminalPage>
// strip offers Enter for it. See
// [TerminalKeyBar.questionOpen].
questionOpen: _questionWatcher?.view != null,
+ hints: keyHints,
// Only where the far side can actually take one: an
// older CLI never advertises the binary kind, so the
// upload would go nowhere silently. Null leaves the
@@ -1761,15 +1753,6 @@ class _TerminalPageState extends State<TerminalPage>
holderName: holderName,
onTakeControl: _takeControl,
),
- // In the same place as that band, and for the same
- // reason: it rides the header's slide rather than
- // sitting on the output. Never both — see
- // `queuedBanner`.
- if (queuedBanner != null)
- _QueuedQuestionBanner(
- count: queuedBanner.count,
- onAnswer: _answerQueuedQuestion,
- ),
],
),
),
@@ -2164,212 +2147,6 @@ class _AgentGone extends StatelessWidget {
);
}
-/// Buttons for the keys the pane's chrome offers and a phone cannot press —
-/// `shift+tab cycle`, `ctrl+] skip`, `⌥+↓ main prompt` — each the key and the
-/// CLI's own word for what it does, both as the pane printed them and in the
-/// terminal's own face, so a chip reads as the hint it stands beside. See
-/// [parseKeyHints].
-///
-/// ⚠️ **Stacked in one column at the right edge, never side by side.** Laid in a
-/// row they ran across the pane's foot and covered the very lines they were
-/// read off — a wrapped footer's second line included. A column keeps to a
-/// strip at the edge, where a line of terminal text is usually shortest.
-///
-/// Nothing but the chips takes a touch: the column is as wide as its widest
-/// chip, and a Column hit-tests only its children, so the gaps between them
-/// let a tap through to the terminal.
-class _KeyHintChips extends StatelessWidget {
- const _KeyHintChips({required this.hints, required this.onPress});
-
- final List<KeyHint> hints;
- final ValueChanged<KeyHint> onPress;
-
- @override
- Widget build(BuildContext context) {
- AppTheme.watch(context);
- // ⚠️ Out of the focus chain, as the key strip is: a chip that took focus on
- // a tap would close the terminal's input connection, and the keyboard with
- // it.
- return ExcludeFocus(
- child: MediaQuery.withNoTextScaling(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- for (var i = 0; i < hints.length; i++) ...[
- if (i > 0) const SizedBox(height: 6),
- _KeyHintChip(hint: hints[i], onTap: () => onPress(hints[i])),
- ],
- ],
- ),
- ),
- );
- }
-}
-
-class _KeyHintChip extends StatelessWidget {
- const _KeyHintChip({required this.hint, required this.onTap});
-
- final KeyHint hint;
- final VoidCallback onTap;
-
- @override
- Widget build(BuildContext context) => Semantics(
- button: true,
- label: '${hint.action}, ${hint.keyText}',
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: onTap,
- child: Container(
- height: 28,
- constraints: const BoxConstraints(maxWidth: 200),
- padding: const EdgeInsets.symmetric(horizontal: 10),
- decoration: BoxDecoration(
- // Nearly opaque: it sits on terminal text, and a chip the output
- // showed through would be read as more of the output.
- color: AppPalette.panelBg.withValues(alpha: 0.94),
- borderRadius: BorderRadius.circular(14),
- border: Border.all(color: AppGlass.lift),
- ),
- // The terminal's face, followed live: Settings ▸ Terminal can change it
- // while the chips are up.
- child: ValueListenableBuilder<TerminalStyle>(
- valueListenable: terminalFontStore,
- builder: (context, face, _) => Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- hint.keyText,
- style: TextStyle(
- fontFamily: face.fontFamily,
- fontFamilyFallback: face.fontFamilyFallback,
- color: AppPalette.textPrimary,
- fontSize: 12,
- fontWeight: FontWeight.w600,
- height: 1,
- ),
- ),
- const SizedBox(width: 6),
- Flexible(
- child: Text(
- hint.action,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontFamily: face.fontFamily,
- fontFamilyFallback: face.fontFamilyFallback,
- color: AppPalette.textSecondary,
- fontSize: 12,
- height: 1,
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- );
-}
-
-/// Codex has asked something without stopping to wait — its async kind, queued
-/// under its composer as `? 1 question · shift+← to answer`.
-///
-/// ⚠️ **A band with a button, because the phone has no way to press the key
-/// the hint names.** The keyboard has no Shift or arrows, and the key strip has
-/// arrows without Shift, so the question sat there unanswerable until the agent
-/// gave up on it — Codex resolves an unanswered one on its own after a while.
-///
-/// Drawn like [_ControlBanner], in the same place, so the two read as one kind
-/// of thing: something about this terminal that needs a tap.
-class _QueuedQuestionBanner extends StatelessWidget {
- const _QueuedQuestionBanner({required this.count, required this.onAnswer});
-
- final int count;
- final VoidCallback onAnswer;
-
- @override
- Widget build(BuildContext context) {
- AppTheme.watch(context);
- final ink = phoneToneColor(PhoneTone.attention);
- return Semantics(
- key: const ValueKey('phone-queued-question-strip'),
- container: true,
- liveRegion: true,
- child: DecoratedBox(
- decoration: BoxDecoration(
- // Composited over the page's ground, as [_ControlBanner] is and for
- // its reason: the terminal theme behind may be any colour.
- color: Color.alphaBlend(
- ink.withValues(alpha: 0.12),
- AppPalette.windowBg,
- ),
- border: Border(
- bottom: BorderSide(color: ink.withValues(alpha: 0.55)),
- ),
- ),
- child: Padding(
- padding: const EdgeInsets.fromLTRB(14, 10, 10, 10),
- child: Row(
- children: [
- Icon(LucideIcons.messageCircleQuestion300, size: 15, color: ink),
- const SizedBox(width: 10),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- count == 1
- ? 'Codex is asking a question'
- : 'Codex is asking $count questions',
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- color: AppPalette.textPrimary,
- fontSize: 12,
- fontWeight: FontWeight.w700,
- ),
- ),
- const SizedBox(height: 2),
- Text(
- 'It keeps working while it waits for you.',
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- color: AppPalette.textSecondary,
- fontSize: 11,
- height: 1.3,
- ),
- ),
- ],
- ),
- ),
- const SizedBox(width: 10),
- TextButton(
- onPressed: onAnswer,
- style: TextButton.styleFrom(
- foregroundColor: ink,
- padding: const EdgeInsets.symmetric(
- horizontal: 12,
- vertical: 8,
- ),
- minimumSize: Size.zero,
- tapTargetSize: MaterialTapTargetSize.shrinkWrap,
- ),
- child: const Text(
- 'Answer',
- style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600),
- ),
- ),
- ],
- ),
- ),
- ),
- );
- }
-}
-
/// The band over the output saying this pane cannot be typed into, and offering the way in.
///
/// ⚠️ **Over the output, not in the header.** The header's status word is 11pt in a corner beside
diff --git a/mobile/lib/terminal/key_hints.dart b/mobile/lib/terminal/key_hints.dart
index c8052d504..bef802c20 100644
--- a/mobile/lib/terminal/key_hints.dart
+++ b/mobile/lib/terminal/key_hints.dart
@@ -2,17 +2,18 @@ import 'package:xterm/xterm.dart';
import 'key_chord.dart';
-/// A key a CLI's own chrome offers — `(shift+tab to cycle)`, `ctrl+] skip`,
-/// `⌥+↓ main prompt` — that a phone has no way to press.
+/// A key Codex's own chrome offers — `ctrl+] skip`, `⌥+↓ main prompt` — that a
+/// phone has no way to press.
///
/// ⚠️ **Why read them off the screen at all.** A phone keyboard has no Shift,
/// Ctrl, Alt or function keys to hold, and the key strip carries only the
-/// handful of keys every pane needs. What each CLI binds to those modifiers is
-/// its own, changes between versions, and is the person's to remap (Codex's
-/// `tui.keymap`) — so the key the CLI prints next to what it does is the one
-/// reliable source for both halves. Measured on Codex 0.156.1 and Claude Code
-/// 2.1.281, where the chords that stranded a phone were `shift+←` (a queued
-/// question) and `ctrl+]` and `⌥+↓` (leaving one).
+/// handful of keys every pane needs. What Codex binds to those modifiers
+/// changes between versions and is the person's to remap (`tui.keymap`) — so
+/// the key it prints next to what it does is the one reliable source for the
+/// key. WHICH hints become buttons is not read off the screen, though: see
+/// [_offered]. Measured on Codex 0.156.1, where the chords that stranded a
+/// phone were `shift+←` (a queued question) and `ctrl+]` and `⌥+↓` (leaving
+/// one).
class KeyHint {
const KeyHint({
required this.chord,
@@ -47,11 +48,12 @@ class KeyHint {
/// How many of the pane's last non-blank lines count as its live chrome.
///
-/// ⚠️ **Only the bottom, never the transcript.** Both CLIs draw their live
-/// chrome — the status line, a dialog's footer, the spinner's key hints —
+/// ⚠️ **Only the bottom, never the transcript.** Codex draws its live chrome —
+/// the status line, a dialog's footer, the queue's `shift+← to answer` —
/// under everything else; what is above is conversation, where a model
-/// explaining a shortcut would otherwise grow a button. Five covers Claude's
-/// footer wrapped over three lines on a phone-width pane plus the status line.
+/// explaining a shortcut would otherwise grow a button. Five reaches the
+/// queue's hint over the composer and a status line wrapped onto two lines on
+/// a phone-width pane.
const int _chromeLines = 5;
/// How far up from the bottom the walk may go looking for those lines.
@@ -95,18 +97,26 @@ bool _isProcessControl(KeyChord chord) =>
chord.key == null &&
const {'c', 'd', 'z', '\\'}.contains(chord.char);
-/// Shift+Tab: Claude's permission-mode cycle (`shift+tab to cycle`), and its
-/// plan-approval shortcut. Never offered — how far a harness may go without
-/// asking is chosen when it is made (New Harness ▸ Approvals), and a button in
-/// the corner of the pane would change it mid-session on a stray tap.
-bool _isShiftTab(KeyChord chord) =>
- chord.key == TerminalKey.tab && chord.shift && !chord.alt && !chord.ctrl;
-
-/// Words that make a hint an irreversible act. Offered as a button, each would
-/// be one tap from a glance at the screen — a confirm-by-pressing-again prompt
-/// (`ctrl+x again to delete`) exists precisely to take more than that.
-final RegExp _destructive = RegExp(
- r'\b(exit|quit|kill|delete|discard|remove|suspend|abort|stop|uninstall|reset)\b',
+/// The hints offered as buttons, by what Codex says each one does — every
+/// other hint on the pane is left as text.
+///
+/// ⚠️ **A list, not a rule.** Reading every `key + words` pair off the chrome
+/// turned tips and one-off shortcuts into buttons (`f3 search this
+/// conversation`, `shift+tab to cycle`) that crowded the key strip for keys
+/// nobody needed from a phone. These are the ones a phone is stranded
+/// without, from Codex 0.156.1 and 0.157.0:
+///
+/// - `shift+← to answer` — open a queued async question;
+/// - `ctrl+] skip`, `⌥+↓ main prompt` / `prev question`, `shift+← next
+/// question` — move through an open one, or leave it;
+/// - `shift+← edit last queued message` — take back a queued message;
+/// - `ctrl+o copy` — the warnings view;
+/// - `ctrl+t to view transcript`.
+///
+/// Matched on the WORDS, never the key: the key is the person's to remap, and
+/// the one printed beside the words is the one pressed.
+final RegExp _offered = RegExp(
+ r'^(answer|skip|main prompt|next question|prev(ious)? question|edit last queued|copy|view transcript)\b',
caseSensitive: false,
);
@@ -147,15 +157,14 @@ List<KeyHint> parseKeyHints(List<String> lines) {
if (chord == null ||
!chord.sendable ||
_phoneHas(chord) ||
- _isProcessControl(chord) ||
- _isShiftTab(chord)) {
+ _isProcessControl(chord)) {
continue;
}
final words = _action.firstMatch(line.substring(match.end));
// A key with nothing said about it is a name in a sentence, not a hint.
if (words == null) continue;
final action = words.group(1)!.toLowerCase();
- if (_destructive.hasMatch(action)) continue;
+ if (!_offered.hasMatch(action)) continue;
if (hints.any((hint) => hint.chord == chord)) continue;
hints.add(
KeyHint(
diff --git a/mobile/lib/terminal/question_pane_watcher.dart b/mobile/lib/terminal/question_pane_watcher.dart
index f46698b66..224d14652 100644
--- a/mobile/lib/terminal/question_pane_watcher.dart
+++ b/mobile/lib/terminal/question_pane_watcher.dart
@@ -55,7 +55,7 @@ class QuestionPaneWatcher extends ChangeNotifier {
QueuedQuestions? get queued => _queued;
/// The keys the pane's live chrome offers that a phone cannot press — see
- /// [parseKeyHints]. Empty when there are none.
+ /// [parseKeyHints]. Codex only; empty when there are none.
///
/// Debounced as [view] is: a repaint caught mid-way reads as a bare pane,
/// and a row of buttons that blinked out on every redraw would be one
@@ -118,7 +118,10 @@ class QuestionPaneWatcher extends ChangeNotifier {
? parseQueuedQuestions(lines)
: null,
);
- final keys = _readHints(parseKeyHints(lines));
+ // Codex only: every hint offered is one of its own (see `parseKeyHints`).
+ final keys = _readHints(
+ engine == QuestionEngine.codex ? parseKeyHints(lines) : const <KeyHint>[],
+ );
if (dialog.again || queue.again || keys.again) {
// ⚠️ **Ask for the next read rather than waiting for one.** Reads are
// driven by terminal output, and the engine may print NOTHING after the