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): rebuild the terminal chrome around a search bar

tony7e0a8c8d9b2e
diff --git a/mobile/lib/phone/phone_search_page.dart b/mobile/lib/phone/phone_search_page.dart
index c61f263f7..86cbeddfa 100644
--- a/mobile/lib/phone/phone_search_page.dart
+++ b/mobile/lib/phone/phone_search_page.dart
@@ -87,7 +87,7 @@ class _PhoneSearchPageState extends State<PhoneSearchPage> {
onBack: () => Navigator.of(context).maybePop(),
),
Expanded(
- child: _Results(
+ child: PhoneSearchResults(
notifier: widget.notifier,
rows: rows,
terms: terms,
@@ -103,13 +103,22 @@ class _PhoneSearchPageState extends State<PhoneSearchPage> {
);
}
-class _Results extends StatelessWidget {
- const _Results({
+/// The ranked results, drawn — agents under their folders, then machines.
+///
+/// ⚠️ Public because two screens draw it: this page, and the terminal's own
+/// in-place search (see `terminal_search.dart`), which expands out of the header
+/// bar rather than pushing a route. The two must return the same rows in the
+/// same order from the same query, or opening a result would walk a different
+/// pager depending on where the search was started.
+class PhoneSearchResults extends StatelessWidget {
+ const PhoneSearchResults({
+ super.key,
required this.notifier,
required this.rows,
required this.terms,
required this.query,
required this.total,
+ this.onOpen,
});
final AppNotifier notifier;
@@ -118,6 +127,14 @@ class _Results extends StatelessWidget {
final String query;
final int total;
+ /// Called the moment a row is tapped, before anything opens.
+ ///
+ /// ⚠️ For the in-place search, which is not a route and so is not popped by
+ /// opening something. Its field still holds the keyboard, and the terminal it
+ /// is covering is about to be replaced underneath it — this is what puts the
+ /// search away first. Null on [PhoneSearchPage], where the pop does it.
+ final VoidCallback? onOpen;
+
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
@@ -158,7 +175,10 @@ class _Results extends StatelessWidget {
row: row,
terms: terms,
now: now,
- onTap: () => _openAgent(context, agents, row),
+ onTap: () {
+ onOpen?.call();
+ _openAgent(context, agents, row);
+ },
),
],
],
diff --git a/mobile/lib/phone/status_pill.dart b/mobile/lib/phone/status_pill.dart
index 4aae1f155..39a63fc93 100644
--- a/mobile/lib/phone/status_pill.dart
+++ b/mobile/lib/phone/status_pill.dart
@@ -15,11 +15,25 @@ Color phoneToneColor(PhoneTone tone) => switch (tone) {
/// A status line: a dot — a small spinner while something is under way — and its label.
class StatusPill extends StatelessWidget {
- const StatusPill({super.key, required this.summary, this.fontSize = 13});
+ const StatusPill({
+ super.key,
+ required this.summary,
+ this.fontSize = 13,
+ this.dotSize = StatusDot.defaultSize,
+ this.gap = 7,
+ });
final PhoneSummary summary;
final double fontSize;
+ /// The dot's box. Defaulted rather than derived from [fontSize]: every screen
+ /// but one wants the full-size dot, and tying the two would have shrunk them
+ /// all the day the terminal's foot row asked for a smaller one.
+ final double dotSize;
+
+ /// Between the dot and its label, which narrows with the dot.
+ final double gap;
+
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
@@ -28,8 +42,8 @@ class StatusPill extends StatelessWidget {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
- StatusDot(summary: summary),
- const SizedBox(width: 7),
+ StatusDot(summary: summary, size: dotSize),
+ SizedBox(width: gap),
Flexible(
child: Text(
summary.label,
@@ -53,10 +67,23 @@ class StatusPill extends StatelessWidget {
/// The label is still there for a screen reader, and as a long-press tooltip, so a colour is never
/// the only way to learn what it means.
class StatusDot extends StatelessWidget {
- const StatusDot({super.key, required this.summary, this.ring});
+ const StatusDot({
+ super.key,
+ required this.summary,
+ this.ring,
+ this.size = defaultSize,
+ });
+
+ /// The box every screen but the terminal's foot row draws it at.
+ static const double defaultSize = 10;
final PhoneSummary summary;
+ /// The dot's box. The filled circle inside it keeps the same proportion, and
+ /// the spinner's stroke thins with it — a 1.6pt stroke on an 8pt box reads as
+ /// a solid ring rather than as something turning.
+ final double size;
+
/// A cut-out ring in this colour around the dot, for a dot laid OVER something — a badge on a
/// mark, the way presence sits on an avatar. It should be the colour behind the mark, so the dot
/// reads as notched into it rather than stuck on top.
@@ -68,13 +95,16 @@ class StatusDot extends StatelessWidget {
final color = phoneToneColor(summary.tone);
final ring = this.ring;
Widget dot = SizedBox.square(
- dimension: 10,
+ dimension: size,
child: summary.tone == PhoneTone.busy
- ? CircularProgressIndicator(strokeWidth: 1.6, color: color)
+ ? CircularProgressIndicator(
+ strokeWidth: 1.6 * size / defaultSize,
+ color: color,
+ )
: Center(
child: DecoratedBox(
decoration: BoxDecoration(color: color, shape: BoxShape.circle),
- child: const SizedBox.square(dimension: 8),
+ child: SizedBox.square(dimension: size * 0.8),
),
),
);
diff --git a/mobile/lib/phone/terminal_foot_bar.dart b/mobile/lib/phone/terminal_foot_bar.dart
index 2c31f0372..75b171aa9 100644
--- a/mobile/lib/phone/terminal_foot_bar.dart
+++ b/mobile/lib/phone/terminal_foot_bar.dart
@@ -1,171 +1,117 @@
-import 'dart:async';
-
import 'package:flutter/material.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart';
-import 'package:harness_mobile/terminal/terminal_session.dart';
+import 'package:harness_mobile/core/models.dart';
+import 'package:harness_mobile/widgets/engine_identity.dart';
import 'phone_status.dart';
import 'status_pill.dart';
import 'voice_input_controller.dart';
-import 'voice_language_store.dart';
import 'voice_mic_action.dart';
-import 'voice_mic_button.dart';
import 'voice_mic_mode.dart';
-/// The foot of a terminal page, one row: which computer the agent runs on,
-/// whether it is still answering, and the mic.
+/// The foot of a terminal page, one short row: which agent this is, on which
+/// computer, and what the mic is doing while it is doing it.
///
-/// Voice is this one button and nothing else — no panel. Tap to talk, tap again
-/// to send; the row's left half says what the mic is doing while it is doing it,
-/// and goes back to the machine when it is done. A tap on the terminal instead
-/// raises the keyboard with what was said typed into the prompt, which is how a
-/// sentence is corrected before it goes.
+/// ⚠️ **The mic is no longer in here.** It floats over the terminal's bottom
+/// right corner instead — see `voice_mic_fab.dart` — which is what let this row
+/// shrink to a line of text. What stayed is the line the mic needs somebody to
+/// read: "Listening… release to send", "Didn't catch that". A floating button
+/// has nowhere to put words.
///
/// ⚠️ **One fixed height, whatever it says.** This row's top edge is the
-/// terminal's bottom edge: a row that grew for a two-line notice, or that lost
-/// its mic while a pane attached, would resize the remote shell under it.
-class TerminalFootBar extends StatefulWidget {
+/// terminal's bottom edge: a row that grew for a two-line notice would resize
+/// the remote shell under it.
+class TerminalFootBar extends StatelessWidget {
const TerminalFootBar({
super.key,
required this.name,
required this.status,
required this.voice,
- required this.session,
+ required this.agent,
+ this.slippedOff = false,
});
+ /// The machine's name. Empty leaves it out.
final String name;
- /// Null while the header's reclaim button is saying the state instead — see
- /// the call site. The row then carries the machine alone, at the same height.
+ /// Null while the header's reclaim button is saying the state instead — the
+ /// row then carries the identity alone, at the same height.
final PhoneSummary? status;
final VoiceInputController voice;
- /// Null while the pane is still attaching: there is nothing to talk to yet,
- /// and the mic is not drawn.
- final TerminalSession? session;
-
- static const double height = VoiceMicButton.extent + 4;
-
- @override
- State<TerminalFootBar> createState() => _TerminalFootBarState();
-}
+ /// The agent this terminal belongs to — its engine mark and its name are the
+ /// identity this row leads with. Null while it is still loading.
+ final Agent? agent;
-class _TerminalFootBarState extends State<TerminalFootBar> {
/// Whether a hold in progress has been dragged off the mic, so letting go
- /// would cancel. Held here rather than read from the controller because it is
- /// a fact about the FINGER, which no amount of voice state can answer.
- ///
- /// [VoiceMicMode.tapToToggle] leaves it false forever — that mode has no hold
- /// to slide out of.
- bool _slippedOff = false;
+ /// would cancel. A fact about the FINGER, which only the button knows; it is
+ /// passed down so this row can say what the release will now do.
+ final bool slippedOff;
- String get name => widget.name;
- PhoneSummary? get status => widget.status;
- VoiceInputController get voice => widget.voice;
+ /// ⚠️ Short on purpose, and the whole reason the mic left. Every point here
+ /// is a point taken off the terminal above, which is then resized.
+ ///
+ /// ⚠️ **20 is what one line of 10.5pt text fits in, and nothing more.** The
+ /// type, the engine mark and the status dot were all cut to match when this
+ /// came down from 26 — a child that kept its old size would overflow rather
+ /// than shrink the row, because the height is fixed above everything in it.
+ static const double height = 20;
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
- final session = widget.session;
- // Nothing to say — the machine has not loaded, the header is carrying the
- // state, and there is no pane to talk to. Draw no row rather than an empty
- // one holding its height open under the terminal.
- if (name.isEmpty && status == null && session == null) {
- return const SizedBox.shrink();
- }
return SizedBox(
- height: TerminalFootBar.height,
+ height: height,
child: Padding(
- padding: const EdgeInsets.only(left: 20, right: 8),
+ // The mic floats over the terminal ABOVE this row rather than over the
+ // row itself, so the right inset is only the screen's own margin — but
+ // it stays generous, because the mic's hit area reaches down to within
+ // a few points of this line and text running right up to it would look
+ // like part of the button.
+ padding: const EdgeInsets.only(left: 16, right: 16),
child: ListenableBuilder(
- listenable: Listenable.merge([voice, session]),
+ listenable: voice,
builder: (context, _) => Row(
children: [
Expanded(
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 180),
layoutBuilder: _alignStart,
- child: _voiceLine(voice, _slippedOff) ?? _machineLine(),
+ child:
+ _voiceLine(voice, slippedOff) ??
+ _IdentityLine(
+ key: const ValueKey('identity'),
+ name: name,
+ status: status,
+ agent: agent,
+ ),
),
),
- if (session != null) ...[
- if (_showsDismiss) ...[
- _DismissButton(onTap: voice.clear),
- // ⚠️ **Clearance, not styling.** The mic's hit area overflows
- // its slot by [VoiceMicButton.touchOverhang] on each side, and
- // it is painted after this button — so without a gap at least
- // that wide its overhang lies on top of the `×`, and a press
- // aimed at Cancel starts a recording instead.
- const SizedBox(width: VoiceMicButton.touchOverhang),
- ],
- _mic(context, session),
- ],
+ // ⚠️ **At the END OF THE LINE it dismisses, not over the mic.**
+ // Stacked above the floating button it sat in the middle of the
+ // terminal with nothing beside it — a lone glyph over streaming
+ // output, which reads as a rendering fault rather than as a
+ // control. Here it is plainly the way to get rid of the words to
+ // its left.
+ //
+ // The mic cannot be shifted by it either, which is what put it
+ // over there in the first place: the mic floats and this is in
+ // the layout, so they no longer share a row.
+ if (_showsDismiss(voice)) _DismissButton(onTap: voice.clear),
],
),
),
),
);
}
-
- /// Whether the `×` beside the mic is drawn.
- ///
- /// ⚠️ **Never while a take is being recorded in hold-to-talk, and that is a
- /// layout bug rather than a preference.** This `×` appears to the LEFT of the
- /// mic, so drawing it shifts the mic sideways — and in hold mode the thumb is
- /// pressed on the mic at exactly that moment. The button would slide out from
- /// under the finger mid-sentence, the finger would land outside its new
- /// bounds, and the take would read as "slid off to cancel" and be thrown away
- /// on release.
- ///
- /// It is not needed there either: releasing off the button is the cancel, and
- /// the recording cannot outlast the thumb. What remains is what the gesture
- /// cannot reach — words held from a failed send, and notices — which is also
- /// the only state hold mode leaves standing after the finger is up.
- bool get _showsDismiss {
- if (voice.notice != null) return true;
- if (voice.isSending) return false;
- if (micHoldsToTalk) {
- return switch (voice.status) {
- VoiceInputStatus.starting ||
- VoiceInputStatus.listening ||
- VoiceInputStatus.transcribing => false,
- VoiceInputStatus.idle ||
- VoiceInputStatus.unavailable => voice.transcript.isNotEmpty,
- };
- }
- return !voice.isIdle;
- }
-
- Widget _machineLine() =>
- _MachineLine(key: const ValueKey('machine'), name: name, status: status);
-
- VoiceMicButton _mic(BuildContext context, TerminalSession session) {
- final action = voiceMicAction(voice, session);
- return VoiceMicButton(
- face: action.face,
- onPressed: action.onPressed,
- // ⚠️ No language shortcut in hold-to-talk: press-and-hold is what records
- // there, and a picker opening out of a held mic would fire in the middle
- // of every sentence. Settings ▸ Voice language is the way to it.
- onLongPress: micHoldsToTalk
- ? null
- : () => unawaited(showVoiceLanguagePicker(context)),
- onHoldStart: action.onHoldStart,
- onHoldFinish: action.onHoldFinish,
- onSlipChanged: (off) {
- if (!mounted || off == _slippedOff) return;
- setState(() => _slippedOff = off);
- },
- );
- }
}
-/// What the row's left half says instead of the machine while voice is in use —
-/// a notice first, since it is the one thing here that asks to be read. Null
-/// with the mic at rest.
+/// What the row says instead of the agent while voice is in use — a notice
+/// first, since it is the one thing here that asks to be read. Null with the mic
+/// at rest.
Widget? _voiceLine(VoiceInputController voice, bool slippedOff) {
final notice = voice.notice;
// ⚠️ The slip outranks the notice and the activity alike. A thumb held off
@@ -178,11 +124,11 @@ Widget? _voiceLine(VoiceInputController voice, bool slippedOff) {
return Text(
label,
key: ValueKey(label),
- maxLines: 2,
+ maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
- fontSize: 12,
- height: 1.3,
+ fontSize: 10.5,
+ height: 1.2,
fontWeight: FontWeight.w500,
// The warning colour for both things that are about to go wrong or go
// away, matching the mic's own fill while it is under a slipped thumb.
@@ -196,83 +142,167 @@ Widget? _voiceLine(VoiceInputController voice, bool slippedOff) {
Widget _alignStart(Widget? current, List<Widget> previous) =>
Stack(alignment: Alignment.centerLeft, children: [...previous, ?current]);
-/// The machine and its state, as one sentence — *on that machine, live*.
+/// Whether the `×` at the end of the row is drawn.
///
-/// ⚠️ The name is what yields when the row is narrow. A truncated state word
-/// is the bug this layout was moved out of the header to avoid — "Taken over"
-/// ellipsed to "Ta…" there — so [StatusPill] keeps its intrinsic width and the
-/// [Flexible] is on the name alone. A machine called "Macbook Pro của Phát"
-/// loses its tail; "Disconnected" never does.
-class _MachineLine extends StatelessWidget {
- const _MachineLine({super.key, required this.name, required this.status});
+/// ⚠️ **Never while a take is being recorded in hold-to-talk.** It is not needed
+/// there — releasing off the button is the cancel, and the recording cannot
+/// outlast the thumb. What remains is what the gesture cannot reach: words held
+/// from a failed send, and notices, which are also the only state hold mode
+/// leaves standing after the finger is up.
+bool _showsDismiss(VoiceInputController voice) {
+ if (voice.notice != null) return true;
+ if (voice.isSending) return false;
+ if (micHoldsToTalk) {
+ return switch (voice.status) {
+ VoiceInputStatus.starting ||
+ VoiceInputStatus.listening ||
+ VoiceInputStatus.transcribing => false,
+ VoiceInputStatus.idle ||
+ VoiceInputStatus.unavailable => voice.transcript.isNotEmpty,
+ };
+ }
+ return !voice.isIdle;
+}
+
+/// `×` at the end of the row while there is something to drop: words held from
+/// a failed send, or a notice. Gone again at rest.
+///
+/// ⚠️ **The glyph is tiny and the target is not.** The row is 20pt tall and this
+/// has to read as punctuation at the end of a sentence rather than as a button
+/// competing with the mic — but 20pt of glass is not something a thumb can hit.
+/// An [OverflowBox] gives it a 40pt target while the row keeps its height.
+///
+/// ⚠️ **The target grows DOWNWARD, never up, and that is the one thing here
+/// that must not change.** The mic floats above this row at the same right-hand
+/// end, its own hit area spills below its box, and it is painted after this — so
+/// a target reaching up meets the mic's coming down, the mic wins, and a tap
+/// meant to dismiss a notice starts a recording. Everything below this row is
+/// the home indicator's margin, which has nothing to collide with.
+class _DismissButton extends StatelessWidget {
+ const _DismissButton({required this.onTap});
+
+ final VoidCallback onTap;
+
+ /// What the finger may land on, against the 20pt the row gives it.
+ static const double _touch = 40;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return Semantics(
+ button: true,
+ label: 'Cancel',
+ child: SizedBox(
+ width: TerminalFootBar.height,
+ height: TerminalFootBar.height,
+ child: OverflowBox(
+ maxWidth: _touch,
+ maxHeight: _touch,
+ // Pinned to the row's TOP edge, so the box that overflows hangs off
+ // the bottom rather than straddling both sides. See the note above.
+ alignment: Alignment.topCenter,
+ child: GestureDetector(
+ key: const ValueKey('voice-cancel'),
+ behavior: HitTestBehavior.opaque,
+ onTap: onTap,
+ child: SizedBox.square(
+ dimension: _touch,
+ child: Center(
+ child: Icon(
+ LucideIcons.x300,
+ size: 13,
+ color: AppPalette.textSecondary,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+/// Who this terminal belongs to, as one line — *engine mark, agent, machine,
+/// state*.
+///
+/// ⚠️ **The agent's name is what yields when the row is narrow, and the state
+/// word never does.** A truncated "Ta…" for "Taken over" is the bug this layout
+/// exists to avoid, so [StatusPill] keeps its intrinsic width and the
+/// [Flexible]s are on the two names. The agent's name gets the larger share: it
+/// is the thing that says WHICH terminal this is.
+class _IdentityLine extends StatelessWidget {
+ const _IdentityLine({
+ super.key,
+ required this.name,
+ required this.status,
+ required this.agent,
+ });
final String name;
final PhoneSummary? status;
+ final Agent? agent;
@override
Widget build(BuildContext context) {
final status = this.status;
+ final agent = this.agent;
return Row(
children: [
+ if (agent != null) ...[
+ // Small enough to read as a mark beside the name rather than as an
+ // avatar — this row is 20pt tall and the mark may not crowd it.
+ EngineMark(
+ engine: agent.engine,
+ displayName: agent.engineDisplayName,
+ size: 12,
+ ),
+ const SizedBox(width: 5),
+ Flexible(
+ flex: 3,
+ child: Text(
+ agent.name,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(
+ color: AppPalette.textPrimary,
+ fontSize: 10.5,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ ],
+ if (agent != null && name.isNotEmpty) _dot(),
if (name.isNotEmpty)
Flexible(
+ flex: 2,
child: Text(
name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: AppPalette.textSecondary,
- fontSize: 12,
+ fontSize: 10.5,
fontWeight: FontWeight.w500,
),
),
),
- if (name.isNotEmpty && status != null)
- // A separator the eye passes over rather than reads: the two halves
- // are one sentence, and a heavier mark between them made the row
- // look like two controls.
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 7),
- child: Text(
- '·',
- style: TextStyle(color: AppPalette.textFaint, fontSize: 12),
- ),
- ),
- if (status != null) StatusPill(fontSize: 12, summary: status),
+ if ((agent != null || name.isNotEmpty) && status != null) _dot(),
+ if (status != null)
+ // The dot and its gap come down with the type: at the row's default
+ // 10pt the dot was wider than the cap height beside it and read as a
+ // bullet rather than as a state.
+ StatusPill(fontSize: 10.5, dotSize: 8, gap: 5, summary: status),
],
);
}
-}
-/// `×` beside the mic while there is something to drop: a take being recorded,
-/// words held from a failed send, or a notice. Gone again at rest.
-class _DismissButton extends StatelessWidget {
- const _DismissButton({required this.onTap});
-
- final VoidCallback onTap;
-
- @override
- Widget build(BuildContext context) => Semantics(
- button: true,
- label: 'Cancel',
- child: GestureDetector(
- key: const ValueKey('voice-cancel'),
- behavior: HitTestBehavior.opaque,
- onTap: onTap,
- // ⚠️ **44, not [VoiceMicButton.extent], and the two parted company when
- // the mic grew.** The mic's hit area now spills well past its own slot to
- // give a held thumb room; this sits immediately to its left, so a target
- // that grew alongside it would put the two in the same place and a press
- // meant for the mic would land on Cancel. 44 is iOS's minimum and as much
- // as this button needs — it is tapped deliberately, never held.
- child: SizedBox.square(
- dimension: 44,
- child: Icon(
- LucideIcons.x300,
- size: 17,
- color: AppPalette.textSecondary,
- ),
- ),
+ /// A separator the eye passes over rather than reads: the halves are one
+ /// sentence, and a heavier mark between them made the row look like controls.
+ Widget _dot() => Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 4),
+ child: Text(
+ '·',
+ style: TextStyle(color: AppPalette.textFaint, fontSize: 12),
),
);
}
diff --git a/mobile/lib/phone/terminal_header.dart b/mobile/lib/phone/terminal_header.dart
new file mode 100644
index 000000000..f91ef21da
--- /dev/null
+++ b/mobile/lib/phone/terminal_header.dart
@@ -0,0 +1,131 @@
+import 'package:flutter/material.dart';
+import 'package:lucide_icons_flutter/lucide_icons.dart';
+
+import 'package:harness_mobile/shared/theme/app_theme.dart';
+
+/// The terminal page's own header: a search bar across the row, with the page's
+/// controls at its right end.
+///
+/// ⚠️ **Not [PhoneHeader], and the agent's name is not here.** The phone opens
+/// straight into a terminal now, so this row is the only place search can live —
+/// and a title beside a field leaves the field too narrow to read a hint in. The
+/// name moved to the foot of the page, beside the engine mark, where it is
+/// identity rather than chrome. See `terminal_foot_bar.dart`.
+///
+/// The bar is a button wearing a field's clothes: tapping it does not push
+/// anything, it grows in place into the search screen — see
+/// `terminal_search.dart`, which draws the same bar at the same geometry so the
+/// two frames line up. That is what the measurements below are public for: the
+/// expanded bar has to land on the pixels the collapsed one left.
+class TerminalHeader extends StatelessWidget {
+ const TerminalHeader({
+ super.key,
+ required this.onSearch,
+ this.trailing = const [],
+ });
+
+ final VoidCallback onSearch;
+
+ /// The page's controls, right of the bar: `+`, `⋯`, and the reclaim button
+ /// when the stream is read-only.
+ final List<Widget> trailing;
+
+ /// The bar's height, and with it the header's.
+ static const double barHeight = 38;
+
+ /// The row's padding, shared with the expanded bar. See the class note.
+ static const double sideInset = 14;
+ static const double topInset = 6;
+ static const double bottomInset = 8;
+
+ /// Inside the bar: the inset before the magnifier, and the magnifier itself.
+ static const double barPadding = 10;
+ static const double glyphSize = 16;
+
+ /// What the bar says it will search.
+ ///
+ /// ⚠️ Names both kinds on purpose. The query spans agents AND machines, and
+ /// the two tabs this screen replaced each answered half the question — a bare
+ /// "Search" left somebody who remembers "that review thing" unsure whether
+ /// this is where to look for it.
+ static const String searchHint = 'Search agents and machines';
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return Padding(
+ padding: const EdgeInsets.fromLTRB(
+ sideInset,
+ topInset,
+ sideInset,
+ bottomInset,
+ ),
+ child: Row(
+ children: [
+ Expanded(child: _SearchBar(onTap: onSearch)),
+ const SizedBox(width: 6),
+ ...trailing,
+ ],
+ ),
+ );
+ }
+}
+
+/// The field-shaped target. Opaque hit test so the whole bar answers, not just
+/// the glyph and the words in it.
+class _SearchBar extends StatelessWidget {
+ const _SearchBar({required this.onTap});
+
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return Semantics(
+ button: true,
+ label: TerminalHeader.searchHint,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onTap,
+ child: Container(
+ height: TerminalHeader.barHeight,
+ padding: const EdgeInsets.symmetric(
+ horizontal: TerminalHeader.barPadding,
+ ),
+ decoration: BoxDecoration(
+ color: AppGlass.rowFill,
+ borderRadius: BorderRadius.circular(AppCard.radius),
+ border: Border.all(color: AppGlass.hair),
+ ),
+ child: Row(
+ children: [
+ Icon(
+ LucideIcons.search300,
+ size: TerminalHeader.glyphSize,
+ color: AppPalette.textFaint,
+ ),
+ const SizedBox(width: 8),
+ Expanded(
+ child: Text(
+ TerminalHeader.searchHint,
+ maxLines: 1,
+ // ⚠️ Fades rather than ellipses. The hint names two things and
+ // the second one is what somebody is scanning for — a cut at
+ // "Search agents and mac…" reads as a bug, while a soft edge
+ // reads as a line that ran out of room.
+ overflow: TextOverflow.fade,
+ softWrap: false,
+ style: TextStyle(
+ color: AppPalette.textFaint,
+ fontSize: 14,
+ fontWeight: FontWeight.w500,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dart
index 92034740b..077e3f1f2 100644
--- a/mobile/lib/phone/terminal_page.dart
+++ b/mobile/lib/phone/terminal_page.dart
@@ -12,23 +12,24 @@ import 'package:harness_mobile/shared/widgets/app_icon_button.dart';
import 'package:harness_mobile/state/app_state.dart';
import 'package:harness_mobile/terminal/image_transcode.dart';
import 'package:harness_mobile/terminal/terminal_session.dart';
-import 'package:harness_mobile/widgets/engine_identity.dart';
import 'package:harness_mobile/widgets/rename_agent_dialog.dart';
import 'package:harness_mobile/widgets/terminal_panel.dart';
import 'agents_page.dart' show openNewAgent;
import 'delete_agent.dart';
import 'machine_actions.dart';
-import 'phone_header.dart';
import 'phone_navigation.dart' show phoneRoute;
-import 'phone_search_page.dart' show openPhoneSearch;
import 'phone_sheet.dart';
import 'phone_status.dart';
import 'settings_page.dart';
import 'status_pill.dart';
import 'terminal_foot_bar.dart';
+import 'terminal_header.dart';
import 'terminal_input_dock.dart';
+import 'terminal_search.dart';
import 'voice_input_controller.dart';
+import 'voice_mic_fab.dart';
+import 'voice_mic_mode.dart';
/// One agent's terminal, filling the phone. The header says whose it is and whether it is live;
/// everything below it is the same [TerminalPanel] a desktop tile draws, minus that tile's own
@@ -127,7 +128,7 @@ void dismissKeyboardForSwipe() {
}
class _TerminalPageState extends State<TerminalPage>
- with WidgetsBindingObserver {
+ with WidgetsBindingObserver, SingleTickerProviderStateMixin {
/// Whether this page's pane ever existed.
///
/// ⚠️ Load-bearing, and the reason this page is stateful at all. The page is pushed BEFORE the
@@ -164,6 +165,48 @@ class _TerminalPageState extends State<TerminalPage>
/// the renderer and the auto-resize until this clears.
bool _keyboardSettling = false;
+ /// Whether a hold in progress on the mic has been dragged off it, so letting
+ /// go would throw the take away.
+ ///
+ /// Kept here rather than in either widget because it crosses between them: the
+ /// floating button is what feels the finger leave, and the foot row at the
+ /// other end of the page is what can say so in words — the thumb is covering
+ /// the button itself.
+ ///
+ /// [VoiceMicMode.tapToToggle] leaves it false forever; that mode has no hold
+ /// to slide out of.
+ bool _micSlippedOff = false;
+
+ /// Drives search opening out of the header bar and collapsing back into it.
+ ///
+ /// ⚠️ **One controller for both halves of the move, read by both.** The search
+ /// overlay grows on it while the terminal and its chrome fade out on the same
+ /// value — two controllers, or an implicit animation on either side, would let
+ /// the two drift apart on a dropped frame and show the terminal through the
+ /// gap.
+ late final AnimationController _searchOpen = AnimationController(
+ vsync: this,
+ duration: const Duration(milliseconds: 260),
+ reverseDuration: const Duration(milliseconds: 220),
+ );
+
+ /// The curve everything on the open/close reads. Eased out on the way in so
+ /// the bar arrives rather than snaps, and symmetric on the way back.
+ late final Animation<double> _searchCurve = CurvedAnimation(
+ parent: _searchOpen,
+ curve: Curves.easeOutCubic,
+ reverseCurve: Curves.easeInCubic,
+ );
+
+ /// Whether the search overlay is BUILT — true from the first frame of the
+ /// opening animation to the last frame of the closing one.
+ ///
+ /// ⚠️ Not the same question as "is the animation at 1". The overlay holds a
+ /// focused [TextField], so it must come down the moment the collapse finishes
+ /// and not a frame later — a field left mounted behind the terminal keeps the
+ /// keyboard and swallows what the terminal is owed.
+ bool _searching = false;
+
/// The last bottom inset seen, in physical pixels, and the timer that decides
/// the animation has stopped.
///
@@ -210,10 +253,47 @@ class _TerminalPageState extends State<TerminalPage>
@override
void dispose() {
_cancelSettle();
+ _searchOpen.dispose();
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
+ /// Grows the header's bar into the search screen.
+ ///
+ /// ⚠️ The overlay is mounted on THIS frame and the animation started on it,
+ /// so the field is there to take the keyboard as the bar opens. Starting the
+ /// animation first and mounting at the end would land the caret after the
+ /// move, which is a beat too late for a bar that was tapped to type in.
+ void _openSearch() {
+ if (_searching) return;
+ setState(() {
+ _searching = true;
+ // ⚠️ Handed over, not left standing. The bar can be tapped with the
+ // terminal's own keyboard already up, and a claim still outstanding would
+ // race the search field for it the moment the inset ticks — the panel
+ // would win and the query would be typed into the shell.
+ _keyboardRequested = false;
+ });
+ _searchOpen.forward();
+ }
+
+ /// Collapses it back into the bar, and takes the overlay down once it is home.
+ ///
+ /// ⚠️ **Guarded on the controller's own status, not on [_searching].** Cancel
+ /// and the system back gesture can both arrive while the reverse is already
+ /// running — a second `reverse()` restarts it from wherever it had got to, and
+ /// the bar visibly bounces.
+ void _closeSearch() {
+ if (!_searching || _searchOpen.status == AnimationStatus.reverse) return;
+ _searchOpen.reverse().whenCompleteOrCancel(() {
+ // A completed reverse is the only thing that unmounts the overlay; a
+ // CANCELLED one means the search was opened again mid-collapse, and taking
+ // the field down then would drop the keyboard it has just been given.
+ if (!mounted || _searchOpen.status != AnimationStatus.dismissed) return;
+ setState(() => _searching = false);
+ });
+ }
+
/// Watches the keyboard through [View], because MediaQuery lies to this page.
///
/// ⚠️ `MediaQuery.viewInsetsOf(context).bottom` is ALWAYS ZERO here, keyboard
@@ -288,8 +368,14 @@ class _TerminalPageState extends State<TerminalPage>
///
/// ⚠️ Holding reads [_keyboardIsUp], the one screen-wide fact, rather than
/// anything this page remembers — see that flag for why swiping needs it.
+ ///
+ /// ⚠️ **Never while search is open, and that is not cosmetic.** The search
+ /// field raises the keyboard itself, [_keyboardIsUp] goes true from its inset,
+ /// and the panel underneath would read that as its own — `requestKeyboard()`
+ /// takes the input connection back and every letter typed into the search box
+ /// would be sent to the shell instead.
bool get _shouldFocus =>
- widget.isActive && (_keyboardIsUp || _keyboardRequested);
+ widget.isActive && !_searching && (_keyboardIsUp || _keyboardRequested);
/// A tap on the terminal while no keyboard is up or coming: the keyboard.
/// Voice is the mic at the foot of the page, never this tap — see
@@ -445,244 +531,261 @@ class _TerminalPageState extends State<TerminalPage>
// that value is pinned at ZERO inside this page (see
// [didChangeMetrics]). The toggle therefore never toggled.
body: SafeArea(
- child: Column(
+ child: Stack(
children: [
- PhoneHeader(
- title: _clipTitle(agent?.name ?? 'Agent'),
- // The connection state rides the engine mark as a badge in
- // its bottom-right corner, the way a messenger shows presence
- // on an avatar: green while live, a spinner while attaching or
- // resyncing, the warning or error colour when the stream is
- // taken over or drops. No words — the long-press tooltip and
- // screen readers still get them.
- leading: Stack(
- clipBehavior: Clip.none,
- children: [
- EngineMark(
- engine: agent?.engine,
- displayName: agent?.engineDisplayName,
- size: 22,
- ),
- Positioned(
- right: -4,
- bottom: -4,
- child: StatusDot(
- summary: phoneSessionSummary(session),
- ring: AppPalette.windowBg,
- ),
- ),
- ],
- ),
- // ⚠️ No subtitle. The machine and its state moved to
- // [TerminalFootBar] at the foot of the page — see there for
- // why.
- // A header carrying both a name and a status line spent two
- // rows on identity and left the filename, the one thing that
- // says WHICH agent this is, sharing its row with four
- // controls and ellipsing halfway through.
- trailing: [
- // Read-only is a state to get OUT of, so its way out is a
- // labelled button in the header rather than a line in the
- // actions sheet: the sheet is where you go having decided
- // to do something, and this is the thing telling you that
- // typing will go nowhere until you do.
- if (reclaim != null)
- _ReclaimButton(
- action: reclaim,
- onPressed: () => widget.notifier.selectAgent(
- widget.machineId,
- widget.agentId,
- ),
- ),
- // New agent, search and the actions menu: the three the
- // page offers, in the order they are reached for — create,
- // find, then everything else.
- //
- // ⚠️ They are spaced by [_HeaderAction], not drawn bare.
- // [AppIconButton] is a fixed 24px box whatever glyph size
- // it is given, so a 22px search glyph fills its box edge to
- // edge while a 20px ellipsis sits inside one — three
- // buttons butted together then read as unevenly spaced
- // when the gaps are in fact identical. One glyph size and
- // one padding across the three is what evens the rhythm.
- //
- // ⚠️ `+` here rather than floating over the terminal. A fab
- // covers the last line of output — the line being read —
- // and this page has no list to scroll it clear of.
- //
- // Gated on the machine ANSWERING, the same gate the Agents
- // tab puts on its fab: creating needs the machine to list
- // its folders and name its engines, so one that is offline
- // or still wants its password cannot host a new agent.
- if (machine != null &&
- phoneMachineStatusOf(machine) ==
- PhoneMachineStatus.ready)
- _HeaderAction(
- icon: LucideIcons.plus300,
- size: 21,
- tooltip: 'New agent',
- // Awaited for the same reason search is: the form may
- // be backed out of rather than completed, and this page
- // gets no rebuild when it lands back on top.
- onPressed: () async {
- await openNewAgent(
- context,
- widget.notifier,
- widget.machineId,
- );
- if (mounted) setState(() {});
- },
- ),
- // Search is here because this page is where the phone now
- // opens, so what the list screens offered has to be
- // reachable without going back to them first:
- // [openPhoneSearch] is the same search that spans agents
- // and machines.
- //
- // ⚠️ Shown while the keyboard is up, and so is `+`. Both
- // were once hidden while typing, to spare a one-row
- // header while typing — but the row is not what was short.
- // The title ellipses at the same width either way, so
- // hiding them bought the title nothing and only left a gap,
- // while the header's controls jumped position on every
- // keyboard raise. A header that holds still is worth more
- // than two columns of unused space.
- //
- // ⚠️ Not [PhoneSearchButton], which pushes and forgets. A
- // page that pops back onto the top gets no rebuild of its
- // own, so anything read from the route's state would keep
- // answering with what was true while the search was
- // covering it. Awaiting the push
- // is what turns "the search closed" into a frame.
- _HeaderAction(
- icon: LucideIcons.search300,
- size: 21,
- tooltip: 'Search',
- onPressed: () async {
- await openPhoneSearch(context, widget.notifier);
- if (mounted) setState(() {});
- },
+ // ⚠️ The terminal is FADED, never unbuilt, while search is
+ // open. Taking it down would detach the pane and drop the
+ // scrollback; cancelling has to hand back the same screen that
+ // was there, mid-stream.
+ //
+ // ⚠️ **The header is NOT inside the fade, on purpose.** The
+ // overlay's bar sits exactly on top of this one and has to read
+ // as the same object growing — fading this one out underneath
+ // it made the row flicker on every open, which is the opposite
+ // of what the expansion is for.
+ Column(
+ children: [
+ TerminalHeader(
+ // ⚠️ Grows in place — no route is pushed. [openPhoneSearch]
+ // is still what the LIST screens use, and this page used it
+ // too until the bar arrived: pushing slid a fresh screen in
+ // from the right, so the bar the finger had just touched left
+ // the frame while an identical one came in from off-screen.
+ // See `terminal_search.dart`.
+ onSearch: _openSearch,
+ // ⚠️ No title and no engine mark up here any more: the search
+ // bar takes the row, and the agent's name moved to
+ // [TerminalFootBar] at the foot of the page, where it reads
+ // as identity rather than as chrome.
+ trailing: [
+ // Read-only is a state to get OUT of, so its way out is a
+ // labelled button in the header rather than a line in the
+ // actions sheet: the sheet is where you go having decided
+ // to do something, and this is the thing telling you that
+ // typing will go nowhere until you do.
+ if (reclaim != null)
+ _ReclaimButton(
+ action: reclaim,
+ onPressed: () => widget.notifier.selectAgent(
+ widget.machineId,
+ widget.agentId,
+ ),
+ ),
+ // New agent, search and the actions menu: the three the
+ // page offers, in the order they are reached for — create,
+ // find, then everything else.
+ //
+ // ⚠️ They are spaced by [_HeaderAction], not drawn bare.
+ // [AppIconButton] is a fixed 24px box whatever glyph size
+ // it is given, so a 22px search glyph fills its box edge to
+ // edge while a 20px ellipsis sits inside one — three
+ // buttons butted together then read as unevenly spaced
+ // when the gaps are in fact identical. One glyph size and
+ // one padding across the three is what evens the rhythm.
+ //
+ // ⚠️ `+` here rather than floating over the terminal. A fab
+ // covers the last line of output — the line being read —
+ // and this page has no list to scroll it clear of.
+ //
+ // Gated on the machine ANSWERING, the same gate the Agents
+ // tab puts on its fab: creating needs the machine to list
+ // its folders and name its engines, so one that is offline
+ // or still wants its password cannot host a new agent.
+ if (machine != null &&
+ phoneMachineStatusOf(machine) ==
+ PhoneMachineStatus.ready)
+ _HeaderAction(
+ icon: LucideIcons.plus300,
+ size: 21,
+ tooltip: 'New agent',
+ // Awaited for the same reason search is: the form may
+ // be backed out of rather than completed, and this page
+ // gets no rebuild when it lands back on top.
+ onPressed: () async {
+ await openNewAgent(
+ context,
+ widget.notifier,
+ widget.machineId,
+ );
+ if (mounted) setState(() {});
+ },
+ ),
+ // ⚠️ Both stay put while the keyboard is up. They were once
+ // hidden while typing to spare the row — but the row was
+ // never what was short, and the controls jumping position
+ // on every keyboard raise cost more than the two columns
+ // bought back. A header that holds still is worth more.
+ //
+ // Null while the agent is not loaded: there is nothing to act on yet, and a
+ // menu of actions that all fail is worse than no menu.
+ if (agent != null)
+ _HeaderAction(
+ icon: LucideIcons.ellipsis300,
+ size: 21,
+ tooltip: 'Agent actions',
+ // Last in the row, so its padding stops at the header's
+ // own right inset rather than adding to it.
+ last: true,
+ onPressed: () => _showActions(
+ machineName: machine?.machine.displayName ?? '',
+ agentName: agent.name,
+ ),
+ ),
+ ],
),
- // Null while the agent is not loaded: there is nothing to act on yet, and a
- // menu of actions that all fail is worse than no menu.
- if (agent != null)
- _HeaderAction(
- icon: LucideIcons.ellipsis300,
- size: 21,
- tooltip: 'Agent actions',
- // Last in the row, so its padding stops at the header's
- // own right inset rather than adding to it.
- last: true,
- onPressed: () => _showActions(
- machineName: machine?.machine.displayName ?? '',
- agentName: agent.name,
- ),
+ Expanded(
+ child: Column(
+ children: [
+ Divider(height: 1, color: AppGlass.hair),
+ Expanded(
+ // ⚠️ The mic floats INSIDE this box, over the terminal
+ // — not over the whole page. Stacked any higher it
+ // would hang over the key bar while the keyboard is
+ // up, which is the one row the thumb is working.
+ child: Stack(
+ children: [
+ Positioned.fill(
+ child: pane == null || session == null
+ ? const _Attaching()
+ : TerminalPanel(
+ key: ValueKey(pane.id),
+ notifier: widget.notifier,
+ session: session,
+ // Only the page on screen takes the keyboard — see
+ // [TerminalPage.isActive]. `visible` is the same answer for the
+ // panel's other half: a page parked beside this one releases
+ // focus, stops rendering and stops resizing its remote shell.
+ //
+ // Whether it also HOLDS one that is already
+ // up is a separate question, and the pager asks
+ // it on every swipe — see [_shouldFocus].
+ focused: _shouldFocus,
+ visible: widget.isActive,
+ // Hold the renderer still while the keyboard
+ // slides. Separate from `visible` because this
+ // must NOT release focus — the animation being
+ // waited on is the one that focus started.
+ settling: _keyboardSettling,
+ // ⚠️ The tap is taken in the panel, not by a
+ // `Listener` over it. xterm's own `_onTapDown`
+ // calls `requestKeyboard()`, so anything that
+ // merely ALSO reacted to the tap would raise
+ // the keyboard before the words said were typed
+ // into the prompt — and a re-armed claim on top
+ // of it was measured asking Android twice per
+ // tap, which answers a show mid-animation by
+ // cancelling and restarting it. Null while the
+ // keyboard is up or coming, so the tap is
+ // xterm's and the keyboard stays.
+ onInputTap: _shouldFocus
+ ? null
+ : () => unawaited(
+ _raiseKeyboard(session),
+ ),
+ showHeader: false,
+ // No composer, and so no grip above it: the
+ // page hands the pane its full height and the
+ // software keyboard drives the terminal
+ // directly. The mic's send is what kept the
+ // composer's batched turn.
+ ),
+ ),
+ // The mic — the one voice control the page has,
+ // floating over the terminal's bottom right corner
+ // rather than sitting in a row of its own.
+ //
+ // ⚠️ Hidden while this page owns the keyboard, the
+ // same gate the foot row takes. Typing is the other
+ // way of saying the same thing, the key bar is
+ // already under the thumb, and a button floating
+ // over it would be in the way of both.
+ if (session != null && !_ownsInput)
+ Positioned(
+ right: VoiceMicFab.inset,
+ bottom: VoiceMicFab.inset,
+ child: VoiceMicFab(
+ voice: widget.voice,
+ session: session,
+ onSlipChanged: (off) {
+ if (!mounted || off == _micSlippedOff) {
+ return;
+ }
+ setState(() => _micSlippedOff = off);
+ },
+ ),
+ ),
+ ],
+ ),
+ ),
+ // The bottom of this page IS just above the keyboard:
+ // `PhoneShell`'s Scaffold has already resized for it —
+ // the same resize that empties this page's MediaQuery
+ // insets (see [didChangeMetrics]).
+ if (session != null)
+ TerminalInputDock(
+ session: session,
+ keyboardUp: _keyboardUp || _keyboardRequested,
+ onDismiss: _dismissInput,
+ // 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
+ // buttons undrawn rather than drawn dead.
+ onPickImage:
+ machine?.terminalImagePasteAvailable == true
+ ? () => unawaited(
+ _sendImage(session, ImageSource.gallery),
+ )
+ : null,
+ onTakePhoto:
+ machine?.terminalImagePasteAvailable == true
+ ? () => unawaited(
+ _sendImage(session, ImageSource.camera),
+ )
+ : null,
+ ),
+ // Who this terminal belongs to, and what the mic is doing
+ // while it is doing it — the words the floating button
+ // has nowhere to put.
+ //
+ // ⚠️ Below the key bar, not above it. The bar is what the
+ // thumb works, and a line that moves every time it
+ // appears would shift the keys under it. Here it is the
+ // last row on the page and nothing it does moves
+ // anything above it.
+ //
+ // ⚠️ Hidden while this page owns the keyboard. The key
+ // bar is already tall, and a line wedged under it is a
+ // row of chrome the terminal loses for nothing — who the
+ // agent is is not what is being read mid-typing.
+ if (!_ownsInput)
+ TerminalFootBar(
+ name: machine?.machine.displayName ?? '',
+ voice: widget.voice,
+ agent: agent,
+ status: phoneSessionSummary(session),
+ slippedOff: _micSlippedOff,
+ ),
+ ],
),
+ ),
],
),
- Expanded(
- child: Column(
- children: [
- Divider(height: 1, color: AppGlass.hair),
- Expanded(
- child: pane == null || session == null
- ? const _Attaching()
- : TerminalPanel(
- key: ValueKey(pane.id),
- notifier: widget.notifier,
- session: session,
- // Only the page on screen takes the keyboard — see
- // [TerminalPage.isActive]. `visible` is the same answer for the
- // panel's other half: a page parked beside this one releases
- // focus, stops rendering and stops resizing its remote shell.
- //
- // Whether it also HOLDS one that is already
- // up is a separate question, and the pager asks
- // it on every swipe — see [_shouldFocus].
- focused: _shouldFocus,
- visible: widget.isActive,
- // Hold the renderer still while the keyboard
- // slides. Separate from `visible` because this
- // must NOT release focus — the animation being
- // waited on is the one that focus started.
- settling: _keyboardSettling,
- // ⚠️ The tap is taken in the panel, not by a
- // `Listener` over it. xterm's own `_onTapDown`
- // calls `requestKeyboard()`, so anything that
- // merely ALSO reacted to the tap would raise
- // the keyboard before the words said were typed
- // into the prompt — and a re-armed claim on top
- // of it was measured asking Android twice per
- // tap, which answers a show mid-animation by
- // cancelling and restarting it. Null while the
- // keyboard is up or coming, so the tap is
- // xterm's and the keyboard stays.
- onInputTap: _shouldFocus
- ? null
- : () => unawaited(_raiseKeyboard(session)),
- showHeader: false,
- // No composer, and so no grip above it: the
- // page hands the pane its full height and the
- // software keyboard drives the terminal
- // directly. The mic's send is what kept the
- // composer's batched turn.
- ),
- ),
- // The bottom of this page IS just above the keyboard:
- // `PhoneShell`'s Scaffold has already resized for it —
- // the same resize that empties this page's MediaQuery
- // insets (see [didChangeMetrics]).
- if (session != null)
- TerminalInputDock(
- session: session,
- keyboardUp: _keyboardUp || _keyboardRequested,
- onDismiss: _dismissInput,
- // 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
- // buttons undrawn rather than drawn dead.
- onPickImage:
- machine?.terminalImagePasteAvailable == true
- ? () => unawaited(
- _sendImage(session, ImageSource.gallery),
- )
- : null,
- onTakePhoto:
- machine?.terminalImagePasteAvailable == true
- ? () => unawaited(
- _sendImage(session, ImageSource.camera),
- )
- : null,
- ),
- // The mic — the one voice control the page has.
- //
- // ⚠️ No machine name and no status in it any more: the
- // state is the dot on the engine mark in the header, and
- // the machine is on the `⋯` sheet's title line. The row
- // stays for the mic, and for what the mic is doing while
- // it is doing it.
- //
- // ⚠️ Below the key bar, not above it. The bar is what the
- // thumb works, and a line that moves every time it
- // appears would shift the keys under it. Here it is the
- // last row on the page and nothing it does moves
- // anything above it.
- //
- // ⚠️ Hidden while this page owns the keyboard, the same
- // gate the header controls take. The key bar is already
- // tall, and a status line wedged under it is a row of
- // chrome the terminal loses for nothing — state is not
- // what is being read mid-typing.
- if (!_ownsInput)
- TerminalFootBar(
- name: '',
- voice: widget.voice,
- session: session,
- status: null,
- ),
- ],
+ // Search, grown out of the header bar. Only built while it is
+ // on its way in, up, or on its way out — see [_searching].
+ //
+ // ⚠️ **No fade and no scale on the whole overlay.** It carries
+ // its own move — the bar widening, the list rising into it —
+ // and dipping the opacity of the lot on top of that only made
+ // the terminal show through the gaps. It is opaque from its
+ // first frame.
+ if (_searching)
+ Positioned.fill(
+ child: TerminalSearchOverlay(
+ notifier: widget.notifier,
+ animation: _searchCurve,
+ onClose: _closeSearch,
+ ),
),
- ),
],
),
),
@@ -892,9 +995,15 @@ const int _titleMaxChars = 20;
/// emoji or a decomposed Vietnamese vowel costs two and a name cuts early —
/// short of the 20 the design asks for, and at a different point per name.
///
-/// ⚠️ The width ellipsis in [PhoneHeader] stays as well. This one bounds the
+/// ⚠️ The header's own width ellipsis stays as well. This one bounds the
/// string; that one still catches a 20-character name on a narrow screen, and
/// neither makes the other redundant.
+///
+/// ⚠️ **Nothing calls it since the title left the header** — the name is drawn
+/// in [TerminalFootBar] now, where it has a whole row and ellipses on width
+/// alone. Kept because a title may come back to the chrome, and this is the
+/// rune-correct cut it would want.
+// ignore: unused_element
String _clipTitle(String name) {
final runes = name.runes.toList();
if (runes.length <= _titleMaxChars) return name;
diff --git a/mobile/lib/phone/terminal_search.dart b/mobile/lib/phone/terminal_search.dart
new file mode 100644
index 000000000..50ed59b9b
--- /dev/null
+++ b/mobile/lib/phone/terminal_search.dart
@@ -0,0 +1,443 @@
+import 'package:flutter/material.dart';
+import 'package:lucide_icons_flutter/lucide_icons.dart';
+
+import 'package:harness_mobile/shared/theme/app_theme.dart';
+import 'package:harness_mobile/state/app_state.dart';
+
+import 'phone_search_index.dart';
+import 'phone_search_page.dart' show PhoneSearchResults;
+import 'terminal_header.dart';
+
+/// Search, opened in place over a terminal rather than pushed as a page.
+///
+/// ⚠️ **Not a route, and that is the point of the whole file.** The bar sits in
+/// the terminal's header, and pushing [PhoneSearchPage] slid a fresh screen in
+/// from the right — the bar the finger had just touched went out of the frame
+/// while an identical one arrived from off-screen. Growing out of the bar keeps
+/// the thing that was tapped on screen and expands it, which is what the gesture
+/// says will happen.
+///
+/// The way out is Cancel beside the bar, which collapses it the way it came. The
+/// system back gesture reaches it too — see [TerminalSearchOverlay]'s
+/// [PopScope].
+///
+/// ⚠️ **It must stay mounted only while searching.** The [TextField] inside
+/// autofocuses, so a copy left built behind the terminal would keep the keyboard
+/// and eat every keystroke the terminal is owed.
+class TerminalSearchOverlay extends StatefulWidget {
+ const TerminalSearchOverlay({
+ super.key,
+ required this.notifier,
+ required this.animation,
+ required this.onClose,
+ });
+
+ final AppNotifier notifier;
+
+ /// The open/close animation the terminal page drives — 0 collapsed into the
+ /// header bar, 1 filling the screen.
+ ///
+ /// Run by the page rather than here, because the page is what decides when
+ /// this widget stops existing: the collapse has to finish before the overlay
+ /// comes down, and a controller owned by a widget being unmounted cannot
+ /// outlive itself to say so.
+ final Animation<double> animation;
+
+ final VoidCallback onClose;
+
+ @override
+ State<TerminalSearchOverlay> createState() => _TerminalSearchOverlayState();
+}
+
+class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {
+ final _controller = TextEditingController();
+ final _focus = FocusNode(debugLabel: 'Terminal search');
+ String _query = '';
+
+ @override
+ void dispose() {
+ _controller.dispose();
+ _focus.dispose();
+ super.dispose();
+ }
+
+ /// ⚠️ Drops the keyboard BEFORE handing back, so the terminal underneath does
+ /// not inherit an inset that belongs to this field. The page's own keyboard
+ /// tracking reads the inset, not the focus, and would otherwise come back
+ /// believing the terminal had raised it.
+ void _close() {
+ _focus.unfocus();
+ widget.onClose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return PopScope(
+ // Back closes the search instead of leaving the agent — the terminal is
+ // still underneath, and this is what is covering it.
+ canPop: false,
+ onPopInvokedWithResult: (didPop, _) {
+ if (!didPop) _close();
+ },
+ child: ListenableBuilder(
+ listenable: widget.notifier,
+ builder: (context, _) {
+ final all = phoneSearchIndex(widget.notifier);
+ final rows = rankPhoneSearch(all, _query);
+ final terms = phoneSearchTerms(_query);
+ return Column(
+ children: [
+ // ⚠️ **The bar is NOT faded in over the header's own.** The two
+ // are the same shape in the same place, so cross-fading them
+ // looked like nothing happening at all — which is exactly what
+ // this screen was reported as doing. It is opaque from frame one
+ // and animates its WIDTH instead: Cancel opens out of the right
+ // edge while `+` and `⋯` collapse behind it, and the field takes
+ // the space. That is the move the tap promises.
+ _Bar(
+ controller: _controller,
+ focus: _focus,
+ animation: widget.animation,
+ onChanged: (value) => setState(() => _query = value),
+ onCancel: _close,
+ ),
+ // ⚠️ Fades AND rises, on the second half of the animation alone.
+ // Rows arriving while the bar is still opening read as two things
+ // at once; waiting until the bar is nearly home makes it one move
+ // — the bar opens, the list comes up into it.
+ Expanded(
+ child: _Rise(
+ animation: widget.animation,
+ child: ColoredBox(
+ color: AppPalette.windowBg,
+ child: PhoneSearchResults(
+ notifier: widget.notifier,
+ rows: rows,
+ terms: terms,
+ query: _query,
+ total: all.length,
+ // ⚠️ Nothing pops this search — opening an agent swaps
+ // the terminal underneath it instead — so tapping a row
+ // has to close it by hand. Without this the keyboard
+ // would still be up over an agent nobody asked to type
+ // into.
+ onOpen: _close,
+ ),
+ ),
+ ),
+ ),
+ ],
+ );
+ },
+ ),
+ );
+ }
+}
+
+/// The field and the way out, on the row the collapsed bar came from.
+///
+/// ⚠️ **Exactly [TerminalHeader]'s geometry, and that is what sells the
+/// expansion.** The two rows are drawn by different widgets but must land on the
+/// same pixels: same height, same corner radius, same outer padding. Anything
+/// off by a point makes the bar jump on the frame the overlay takes over.
+class _Bar extends StatelessWidget {
+ const _Bar({
+ required this.controller,
+ required this.focus,
+ required this.animation,
+ required this.onChanged,
+ required this.onCancel,
+ });
+
+ final TextEditingController controller;
+ final FocusNode focus;
+
+ /// 0 collapsed into the header's bar, 1 open. Drives Cancel's width, which is
+ /// what makes the field grow: the two share the row.
+ final Animation<double> animation;
+
+ final ValueChanged<String> onChanged;
+ final VoidCallback onCancel;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return ColoredBox(
+ color: AppPalette.windowBg,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(
+ TerminalHeader.sideInset,
+ TerminalHeader.topInset,
+ TerminalHeader.sideInset,
+ TerminalHeader.bottomInset,
+ ),
+ child: Row(
+ children: [
+ Expanded(
+ child: ListenableBuilder(
+ listenable: focus,
+ builder: (context, child) => AnimatedContainer(
+ duration: AppMotion.hover,
+ curve: AppMotion.curve,
+ height: TerminalHeader.barHeight,
+ padding: const EdgeInsets.symmetric(
+ horizontal: TerminalHeader.barPadding,
+ ),
+ decoration: BoxDecoration(
+ color: AppGlass.rowFill,
+ borderRadius: BorderRadius.circular(AppCard.radius),
+ // Focus is said once, by the rim of the box the field fills.
+ border: Border.all(
+ color: focus.hasFocus
+ ? AppPalette.accentOnSurface
+ : AppGlass.hair,
+ ),
+ ),
+ child: child,
+ ),
+ child: Row(
+ children: [
+ Icon(
+ LucideIcons.search300,
+ size: TerminalHeader.glyphSize,
+ color: AppPalette.textFaint,
+ ),
+ const SizedBox(width: 8),
+ Expanded(
+ child: _Input(
+ controller: controller,
+ focus: focus,
+ onChanged: onChanged,
+ ),
+ ),
+ _ClearButton(
+ controller: controller,
+ onTap: () {
+ controller.clear();
+ onChanged('');
+ // Clearing is a step back into browsing, not out of the
+ // search — the caret stays where the next query will go.
+ focus.requestFocus();
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
+ // ⚠️ **Opens from zero width, and that IS the animation.** `+` and
+ // `⋯` are gone while searching — they act on the agent underneath,
+ // which is not what is on screen — so Cancel takes their column, and
+ // the field widens into whatever Cancel has not claimed yet. Fading
+ // one bar over another identical one showed nothing; a row whose
+ // proportions move shows the tap landing.
+ //
+ // ⚠️ Rebuilt on every tick by this builder. The button reads
+ // `animation.value` directly, and a stateless widget given an
+ // Animation does not listen to it — the row would have snapped to its
+ // open width on the first frame and shown nothing moving.
+ AnimatedBuilder(
+ animation: animation,
+ builder: (context, _) =>
+ _CancelButton(animation: animation, onTap: onCancel),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
+
+/// The results, rising into place as the bar finishes opening.
+///
+/// A translation rather than a slide transition: [SlideTransition] moves by a
+/// fraction of the child's own size, and this child is most of the screen — a
+/// tenth of it is half a phone. A fixed number of points is what reads as the
+/// list settling.
+class _Rise extends StatelessWidget {
+ const _Rise({required this.animation, required this.child});
+
+ final Animation<double> animation;
+ final Widget child;
+
+ /// How far below its place the list starts. Far enough to be a move, near
+ /// enough that nothing is ever seen sliding past the bar.
+ static const double _drop = 18;
+
+ @override
+ Widget build(BuildContext context) {
+ final curve = CurvedAnimation(
+ parent: animation,
+ curve: const Interval(0.35, 1, curve: Curves.easeOutCubic),
+ );
+ return AnimatedBuilder(
+ animation: curve,
+ builder: (context, child) => Opacity(
+ opacity: curve.value,
+ child: Transform.translate(
+ offset: Offset(0, _drop * (1 - curve.value)),
+ child: child,
+ ),
+ ),
+ child: child,
+ );
+ }
+}
+
+class _Input extends StatelessWidget {
+ const _Input({
+ required this.controller,
+ required this.focus,
+ required this.onChanged,
+ });
+
+ final TextEditingController controller;
+ final FocusNode focus;
+ final ValueChanged<String> onChanged;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return TextField(
+ controller: controller,
+ focusNode: focus,
+ // The whole point of expanding rather than pushing: the keyboard comes up
+ // on the bar that was tapped, without a screen sliding across first.
+ autofocus: true,
+ onChanged: onChanged,
+ // The list is already filtered by the time a key is released; there is
+ // nothing left for the return key to submit, so it stays a plain "done"
+ // that drops the keyboard and leaves the results up.
+ textInputAction: TextInputAction.search,
+ onSubmitted: (_) => focus.unfocus(),
+ autocorrect: false,
+ enableSuggestions: false,
+ // Agent names are ids as often as sentences — `Dijkstra-visualization.html`
+ // — and a capital forced onto the first letter of one is a wrong query.
+ textCapitalization: TextCapitalization.none,
+ textAlignVertical: TextAlignVertical.center,
+ style: TextStyle(color: AppPalette.textPrimary, fontSize: 14),
+ cursorColor: AppPalette.accentOnSurface,
+ decoration: InputDecoration(
+ isDense: true,
+ // ⚠️ **Every** border state, not just `border`. The app's
+ // `inputDecorationTheme` fills the named states in, and its
+ // `focusedBorder` is an accent outline at a tighter radius than this box
+ // — which drew a second rectangle INSIDE the rim. Naming each state is
+ // what keeps the theme from reaching past `border`.
+ border: InputBorder.none,
+ enabledBorder: InputBorder.none,
+ focusedBorder: InputBorder.none,
+ errorBorder: InputBorder.none,
+ focusedErrorBorder: InputBorder.none,
+ disabledBorder: InputBorder.none,
+ // The theme also fills these, and both would draw over the box: a fill
+ // over the rim's own, and Material's phone-sized padding over the height
+ // set above.
+ filled: false,
+ contentPadding: EdgeInsets.zero,
+ constraints: const BoxConstraints(),
+ hintText: TerminalHeader.searchHint,
+ hintStyle: TextStyle(color: AppPalette.textFaint, fontSize: 14),
+ ),
+ );
+ }
+}
+
+/// Only once there is something to clear: a button that does nothing on an
+/// empty field is a button people learn to skip.
+class _ClearButton extends StatelessWidget {
+ const _ClearButton({required this.controller, required this.onTap});
+
+ final TextEditingController controller;
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return ValueListenableBuilder(
+ valueListenable: controller,
+ builder: (context, value, _) => value.text.isEmpty
+ ? const SizedBox.shrink()
+ : Semantics(
+ button: true,
+ label: 'Clear',
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onTap,
+ child: Padding(
+ // Padding, not size: the glyph stays small while the target
+ // reaches a thumb.
+ padding: const EdgeInsets.only(left: 8),
+ child: Icon(
+ LucideIcons.circleX300,
+ size: 16,
+ color: AppPalette.textFaint,
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+/// The word, not a glyph. This is the one control on the row that leaves, and a
+/// second `×` beside the field's own would be two ways out sitting together.
+///
+/// ⚠️ **It opens by WIDTH, from nothing, and the field's growth is the other
+/// side of that.** The two share the row, so every point Cancel takes is a point
+/// the field gives up — which is what makes the bar look like it is expanding
+/// out of the header rather than being replaced by a copy of itself.
+class _CancelButton extends StatelessWidget {
+ const _CancelButton({required this.animation, required this.onTap});
+
+ final Animation<double> animation;
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return Semantics(
+ button: true,
+ label: 'Cancel search',
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onTap,
+ child: SizedBox(
+ height: TerminalHeader.barHeight,
+ // ⚠️ Align + a widthFactor, not an animated `width`. The label must
+ // not reflow while the box narrows — a "Cancel" wrapping to "Canc /
+ // el" for four frames is what a `SizedBox(width: …)` around text
+ // does. This clips it instead, from the left, so the word slides out
+ // from behind the field's right edge.
+ child: ClipRect(
+ child: Align(
+ alignment: Alignment.centerRight,
+ widthFactor: animation.value,
+ child: Padding(
+ padding: const EdgeInsets.only(left: 12, right: 2),
+ child: Center(
+ child: Opacity(
+ // The word itself catches up late, so it is legible the
+ // moment there is room for it rather than smearing in.
+ opacity: Curves.easeIn.transform(animation.value),
+ child: Text(
+ 'Cancel',
+ maxLines: 1,
+ softWrap: false,
+ style: TextStyle(
+ color: AppPalette.accentOnSurface,
+ fontSize: 14,
+ fontWeight: FontWeight.w500,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/mobile/lib/phone/voice_mic_button.dart b/mobile/lib/phone/voice_mic_button.dart
index f1bd58e1e..72dd548fc 100644
--- a/mobile/lib/phone/voice_mic_button.dart
+++ b/mobile/lib/phone/voice_mic_button.dart
@@ -37,8 +37,8 @@ enum VoiceMicFace {
cancelling,
}
-/// The one voice control on a terminal page — a small round button at the foot
-/// of the page, beside the machine it is talking to.
+/// The one voice control on a terminal page — a small round button floating
+/// over the terminal's bottom right corner. [VoiceMicFab] is what places it.
///
/// Two ways to work it, chosen by [voiceMicMode] and nothing else:
///
@@ -51,9 +51,8 @@ enum VoiceMicFace {
/// that gesture is what records.
///
/// ⚠️ **The swell is painted, never laid out.** The breathing ring scales past
-/// the button's box with [Clip.none] rather than growing it: this button's row
-/// sits under the terminal, and a row whose height moved with the animation
-/// would resize the remote shell every frame.
+/// the button's box with [Clip.none] rather than growing it, so nothing around
+/// the button moves while it breathes.
class VoiceMicButton extends StatefulWidget {
const VoiceMicButton({
super.key,
@@ -94,36 +93,33 @@ class VoiceMicButton extends StatefulWidget {
/// can actually read at that moment.
final ValueChanged<bool>? onSlipChanged;
- /// The space this button takes in the row, and with it the row's height.
+ /// The space this button asks of its parent's layout.
///
- /// ⚠️ **Raising this makes the terminal shorter, so it is not the knob to
- /// reach for when the target feels small.** `TerminalFootBar.height` is
- /// derived from it, and that row's top edge is the terminal's bottom edge —
- /// every point added here is a point taken off the remote shell, which is then
- /// resized. [touchExtent] is the one that grew instead: it widens what the
- /// finger can hit without costing the terminal anything.
- static const double extent = 52;
+ /// ⚠️ **It no longer sets any row's height.** The mic floats over the terminal
+ /// now (see `voice_mic_fab.dart`), so this is simply the box the `Positioned`
+ /// sizes to — raising it costs the terminal nothing, and the hit area below
+ /// already reaches well past it either way.
+ static const double extent = 60;
/// What the finger may actually land on.
///
- /// ⚠️ **Deliberately LARGER than [extent], and drawn outside the row's
- /// bounds.** Hold-to-talk asks for a press held through a whole sentence, so
- /// the target has to forgive a thumb that shifts while somebody talks — but
- /// the row cannot grow to hold a bigger one without shortening the terminal.
- /// An [OverflowBox] resolves the two: the hit area reaches up over the
- /// terminal's last line and down towards the home indicator, neither of which
- /// has anything tappable to collide with, while the row keeps its height.
- static const double touchExtent = 76;
+ /// ⚠️ **Deliberately LARGER than [extent], and drawn outside the layout
+ /// box.** Hold-to-talk asks for a press held through a whole sentence, so the
+ /// target has to forgive a thumb that shifts while somebody talks. An
+ /// [OverflowBox] is what allows a child bigger than its parent: the hit area
+ /// reaches out over the terminal on every side, which has nothing tappable to
+ /// collide with.
+ static const double touchExtent = 84;
/// How far the hit area spills past its slot on each side.
///
- /// What anything placed beside this button has to clear: the overhang is
- /// painted over its neighbour and would swallow the neighbour's presses. See
- /// the gap before the mic in `terminal_foot_bar.dart`.
+ /// What anything placed beside or above this button has to clear: the
+ /// overhang is painted over its neighbour and would swallow the neighbour's
+ /// presses. See the gap above the mic in `voice_mic_fab.dart`.
static const double touchOverhang = (touchExtent - extent) / 2;
/// The visible circle.
- static const double _core = 40;
+ static const double _core = 48;
/// How far past [touchExtent] the thumb may stray and still count as "on" the
/// button.
@@ -389,9 +385,9 @@ class _Glyph extends StatelessWidget {
Widget build(BuildContext context) {
if (face == VoiceMicFace.busy) {
return SizedBox.square(
- dimension: 18,
+ dimension: 21,
child: CircularProgressIndicator(
- strokeWidth: 2.2,
+ strokeWidth: 2.4,
color: AppPalette.accent,
),
);
@@ -411,7 +407,7 @@ class _Glyph extends StatelessWidget {
VoiceMicFace.starting ||
VoiceMicFace.busy => LucideIcons.mic300,
},
- size: 21,
+ size: 25,
color: lit
? Colors.white
: face == VoiceMicFace.off
diff --git a/mobile/lib/phone/voice_mic_fab.dart b/mobile/lib/phone/voice_mic_fab.dart
new file mode 100644
index 000000000..2f650efcf
--- /dev/null
+++ b/mobile/lib/phone/voice_mic_fab.dart
@@ -0,0 +1,88 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+
+import 'package:harness_mobile/shared/theme/app_theme.dart';
+import 'package:harness_mobile/terminal/terminal_session.dart';
+
+import 'voice_language_store.dart';
+import 'voice_input_controller.dart';
+import 'voice_mic_action.dart';
+import 'voice_mic_button.dart';
+import 'voice_mic_mode.dart';
+
+/// The mic, floating over the terminal's bottom right corner.
+///
+/// ⚠️ **Floating rather than in a row, and that is what the row below it pays
+/// for.** The foot bar used to hold this button, which set its height at 56 —
+/// and that row's top edge is the terminal's bottom edge, so every point of it
+/// was a point taken off the remote shell. Lifting the mic out of the layout let
+/// the row shrink to one line of text; the button now costs the terminal nothing
+/// but the corner it covers.
+///
+/// ⚠️ **The corner, deliberately — not centred, and not over the middle.** A
+/// terminal's newest output is the line being read, and it runs left to right:
+/// the right end of the last few lines is the least of it.
+///
+/// ⚠️ **The `×` is NOT here.** It lives at the end of the foot row's line, next
+/// to the words it dismisses — see `terminal_foot_bar.dart`. Stacked over this
+/// button it floated in the middle of the terminal with nothing beside it, a
+/// glyph on its own over streaming output that read as a rendering fault.
+class VoiceMicFab extends StatefulWidget {
+ const VoiceMicFab({
+ super.key,
+ required this.voice,
+ required this.session,
+ required this.onSlipChanged,
+ });
+
+ final VoiceInputController voice;
+ final TerminalSession session;
+
+ /// The thumb crossed in or out of the button mid-hold. The foot bar is what
+ /// says "Release to cancel" — this button is under a thumb and cannot.
+ final ValueChanged<bool> onSlipChanged;
+
+ /// What the whole floating cluster asks of the corner it sits in.
+ ///
+ /// Bigger than [VoiceMicButton.extent] because the mic's hit area spills past
+ /// its slot: this is what the page keeps clear of anything else tappable.
+ static const double extent = VoiceMicButton.touchExtent;
+
+ /// How far the cluster sits from the screen's right edge and from the foot row
+ /// under it.
+ static const double inset = 8;
+
+ @override
+ State<VoiceMicFab> createState() => _VoiceMicFabState();
+}
+
+class _VoiceMicFabState extends State<VoiceMicFab> {
+ VoiceInputController get voice => widget.voice;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return ListenableBuilder(
+ listenable: Listenable.merge([voice, widget.session]),
+ builder: (context, _) => _mic(context),
+ );
+ }
+
+ Widget _mic(BuildContext context) {
+ final action = voiceMicAction(voice, widget.session);
+ return VoiceMicButton(
+ face: action.face,
+ onPressed: action.onPressed,
+ // ⚠️ No language shortcut in hold-to-talk: press-and-hold is what records
+ // there, and a picker opening out of a held mic would fire in the middle
+ // of every sentence. Settings ▸ Voice language is the way to it.
+ onLongPress: micHoldsToTalk
+ ? null
+ : () => unawaited(showVoiceLanguagePicker(context)),
+ onHoldStart: action.onHoldStart,
+ onHoldFinish: action.onHoldFinish,
+ onSlipChanged: widget.onSlipChanged,
+ );
+ }
+}