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(phone): add TerminalHeaderAction widget and corresponding tests

Dev jacob4003313ce445
diff --git a/mobile/lib/phone/terminal_header_action.dart b/mobile/lib/phone/terminal_header_action.dart
new file mode 100644
index 000000000..9a6993023
--- /dev/null
+++ b/mobile/lib/phone/terminal_header_action.dart
@@ -0,0 +1,61 @@
+import 'package:flutter/material.dart';
+
+import 'package:harness_mobile/shared/theme/app_theme.dart';
+import 'package:harness_mobile/shared/widgets/app_icon_button.dart';
+import 'package:harness_mobile/shared/widgets/touch_target.dart';
+
+/// One mark in the terminal header's trailing row — the tabs grid, `⋮`,
+/// and the Take control button's neighbours.
+///
+/// Its own file because [gap] is an invariant with arithmetic behind it and
+/// a test that checks it (`terminal_header_action_test.dart`); a private class
+/// inside a 2,500-line page could not be reached to check.
+class TerminalHeaderAction extends StatelessWidget {
+ const TerminalHeaderAction({
+ required this.icon,
+ required this.tooltip,
+ required this.onPressed,
+ this.size = 21,
+ this.last = false,
+ });
+
+ final IconData icon;
+ final String tooltip;
+ final VoidCallback onPressed;
+ final double size;
+
+ /// The rightmost action, whose trailing padding is dropped: [PhoneHeader]
+ /// already insets the row's right edge, and keeping it here would push the
+ /// last mark further from the edge than the others are from each other.
+ final bool last;
+
+ /// Half the gap between two marks — each neighbour contributes one, so the
+ /// boxes end up 20 apart.
+ ///
+ /// ⚠️ **10, not 7, and the reason is the hit area rather than the look.**
+ /// An action draws a 24pt box and [TouchTarget] reaches 44pt around it — 10
+ /// past each edge. Two actions therefore need their centres 44 apart, and a
+ /// centre-to-centre distance is `2 * gap + 24`. At the old 7 that came to 38,
+ /// so the two reaches OVERLAPPED by 6pt — and a [Row] hit-tests in reverse
+ /// paint order, so `⋯` was tested first and took that strip off the right
+ /// edge of the tabs mark beside it. The tabs mark simply did not answer
+ /// there. 10 makes it exactly 44: the targets meet and neither steals.
+ ///
+ /// This replaces an earlier rule that set the gap to half [PhoneHeader]'s own
+ /// 14pt right inset so the marks and the screen edge read as evenly spaced.
+ /// That is a nicer rhythm and it cost one of two buttons its right-hand
+ /// sixth; a mark that does not respond is the worse of the two problems.
+ static const double gap = 10;
+
+ @override
+ Widget build(BuildContext context) => Padding(
+ padding: EdgeInsets.fromLTRB(gap, 0, last ? 0 : gap, 0),
+ child: AppIconButton(
+ icon: icon,
+ size: size,
+ tooltip: tooltip,
+ color: AppPalette.textSecondary,
+ onPressed: onPressed,
+ ),
+ );
+}
diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dart
index 992fe87ec..2b495ebc6 100644
--- a/mobile/lib/phone/terminal_page.dart
+++ b/mobile/lib/phone/terminal_page.dart
@@ -12,7 +12,6 @@ import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:harness_mobile/core/models.dart' show Agent, AgentProject;
import 'package:harness_mobile/shared/theme/app_theme.dart';
-import 'package:harness_mobile/shared/widgets/app_icon_button.dart';
import 'package:harness_mobile/shared/widgets/skeleton.dart';
import 'package:harness_mobile/state/app_state.dart';
import 'package:harness_mobile/terminal/image_transcode.dart';
@@ -41,6 +40,7 @@ import 'status_pill.dart';
import 'terminal_action_column.dart';
import 'terminal_chrome_scroll.dart';
import 'terminal_header.dart';
+import 'terminal_header_action.dart';
import 'terminal_input_dock.dart';
import 'terminal_search.dart';
import 'voice_input_controller.dart';
@@ -1313,7 +1313,7 @@ class _TerminalPageState extends State<TerminalPage>
// panel would hold one tab over every agent on the
// account, which is what a swipe already walks.
if (widget.notifier.deskTabs.isNotEmpty)
- _HeaderAction(
+ TerminalHeaderAction(
icon: LucideIcons.layoutGrid300,
tooltip: 'Tabs',
onPressed: () => unawaited(
@@ -1331,8 +1331,12 @@ class _TerminalPageState extends State<TerminalPage>
// 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,
+ TerminalHeaderAction(
+ // Stood up, not laid flat: three dots in a
+ // column is the narrower mark AND the one a
+ // phone means by "more actions", so it reads
+ // as a menu rather than as a truncation.
+ icon: LucideIcons.ellipsisVertical300,
size: 21,
tooltip: 'Agent actions',
// Last in the row, so its padding stops at
@@ -2459,43 +2463,3 @@ String _clipTitle(String name) {
/// dead space either side and the three stay 24px each — under the 44 iOS asks
/// for. Fixing that belongs in the shared button, where every screen's header
/// would get it, not in a wrapper one page defines.
-class _HeaderAction extends StatelessWidget {
- const _HeaderAction({
- required this.icon,
- required this.tooltip,
- required this.onPressed,
- this.size = 21,
- this.last = false,
- });
-
- final IconData icon;
- final String tooltip;
- final VoidCallback onPressed;
- final double size;
-
- /// The rightmost action, whose trailing padding is dropped: [PhoneHeader]
- /// already insets the row's right edge, and keeping it here would push the
- /// last mark further from the edge than the others are from each other.
- final bool last;
-
- /// Half the gap between two marks — each neighbour contributes one, so the
- /// boxes end up 14 apart.
- ///
- /// 14 because that is [PhoneHeader]'s own right inset: the gap between two
- /// actions and the gap from the last one to the screen edge are then the
- /// same measure, and the three read as evenly placed rather than as a group
- /// shoved against the corner.
- static const double gap = 7;
-
- @override
- Widget build(BuildContext context) => Padding(
- padding: EdgeInsets.fromLTRB(gap, 0, last ? 0 : gap, 0),
- child: AppIconButton(
- icon: icon,
- size: size,
- tooltip: tooltip,
- color: AppPalette.textSecondary,
- onPressed: onPressed,
- ),
- );
-}
diff --git a/mobile/test/terminal_header_action_test.dart b/mobile/test/terminal_header_action_test.dart
new file mode 100644
index 000000000..555db2e2a
--- /dev/null
+++ b/mobile/test/terminal_header_action_test.dart
@@ -0,0 +1,79 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness_mobile/phone/terminal_header_action.dart';
+import 'package:harness_mobile/shared/widgets/touch_target.dart';
+import 'package:lucide_icons_flutter/lucide_icons.dart';
+
+/// The terminal header's marks sit close enough that their 44pt reaches used to
+/// overlap, and a [Row] hit-tests in reverse paint order — so the LAST mark was
+/// tested first and answered for a strip of its neighbour.
+///
+/// It was the tabs grid that lost, every time, because `⋮` is drawn after it.
+void main() {
+ Future<void> pumpRow(
+ WidgetTester tester,
+ List<String> pressed,
+ ) => tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: Align(
+ alignment: Alignment.topLeft,
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ TerminalHeaderAction(
+ icon: LucideIcons.layoutGrid300,
+ tooltip: 'Tabs',
+ onPressed: () => pressed.add('tabs'),
+ ),
+ TerminalHeaderAction(
+ icon: LucideIcons.ellipsisVertical300,
+ tooltip: 'Agent actions',
+ last: true,
+ onPressed: () => pressed.add('actions'),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+
+ test('two marks are far enough apart for two whole touch targets', () {
+ // A mark draws a 24pt box and reaches [minTouchTarget] around it, so two
+ // of them need their centres that far apart. The distance between two
+ // neighbours is one gap from each plus the box between them.
+ const boxWidth = 24.0;
+ expect(
+ 2 * TerminalHeaderAction.gap + boxWidth,
+ greaterThanOrEqualTo(minTouchTarget),
+ );
+ });
+
+ testWidgets('the right edge of the tabs mark still presses the tabs mark', (
+ tester,
+ ) async {
+ final pressed = <String>[];
+ await pumpRow(tester, pressed);
+
+ final tabs = find.byTooltip('Tabs');
+ final box = tester.getRect(tabs);
+ // Just inside the far edge of its reach — the strip `⋮` used to take.
+ await tester.tapAt(
+ Offset(box.center.dx + minTouchTarget / 2 - 1, box.center.dy),
+ );
+ await tester.pump();
+
+ expect(pressed, ['tabs']);
+ });
+
+ testWidgets('and the actions mark still presses its own', (tester) async {
+ final pressed = <String>[];
+ await pumpRow(tester, pressed);
+
+ await tester.tap(find.byTooltip('Agent actions'));
+ await tester.pump();
+
+ expect(pressed, ['actions']);
+ });
+}