The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(mobile): New's dock scrolls instead of overflowing on a small phone
dee2dd28353e367
diff --git a/mobile/lib/phone/new_agent_page.dart b/mobile/lib/phone/new_agent_page.dartindex 909a343b5..b8675ac26 100644--- a/mobile/lib/phone/new_agent_page.dart+++ b/mobile/lib/phone/new_agent_page.dart@@ -763,206 +763,238 @@ class _NewAgentPageState extends State<NewAgentPage> {label: 'harness',value: summary.isEmpty ? 'Choose an agent' : summary,onTap: () => FocusManager.instance.primaryFocus?.unfocus(),- )- else- Expanded(- child: ListView(- keyboardDismissBehavior:- ScrollViewKeyboardDismissBehavior.onDrag,- padding: EdgeInsets.zero,- children: [- TtyFormRow(- label: 'agent',- value: _engine == null- ? 'Choose an agent'- : _engineName(_engine!),- valueColor: _engine == null ? tty.green : null,- detail: _engine == null- ? null- : _engineNote(_engine!),- onTap: _creating- ? null- : () => unawaited(_chooseAgent()),- ),- TtyFormRow(- label: 'project',- value: _folder == null && _project == null- ? 'Choose a project'- : _projectValue,- valueColor: _folder == null && _project == null- ? tty.green- : null,- detail: null,- onTap: _creating- ? null- : () => unawaited(_chooseProject()),- ),- // Options, folded as the desktop folds them: branch, approvals and profile- // sit on their defaults until asked for.- TtyFormRow(- label: 'options',- // Left as it is nearly every time: folded to `[+]`.- value: _optionsOpen ? '[−]' : '[+]',- chevron: false,- onTap: () =>- setState(() => _optionsOpen = !_optionsOpen),- ),- if (_optionsOpen &&- (info != null || _gitLoading || _gitFailed))- TtyFormRow(- label: 'branch',- valueColor: info == null && !_gitLoading- ? tty.faint- : null,- value: _gitLoading- ? 'Reading…'- : info == null- ? 'No answer from the computer'- : _worktree- ? 'New worktree'- : _branchTitle,- detail: info == null- ? null- : _worktree- ? 'from $_branchTitle, in its own folder'- : _branchNote,- onTap: info == null || _creating- ? null- : () => unawaited(_chooseBranch(info)),- ),- if (_optionsOpen && _permissionModes.isNotEmpty)- TtyFormRow(- label: 'approvals',- value: mode?.label ?? 'Auto-approve',- detail: mode?.detail,- valueColor: (mode?.risky ?? false) ? tty.red : null,- onTap: _creating- ? null- : () => unawaited(_chooseApprovals()),- ),- if (_optionsOpen && _showsCodexProfile)- TtyFormRow(- label: 'profile',- value: _codexProfile?.label ?? 'Default',- onTap: _creating- ? null- : () => unawaited(_chooseProfile()),- ),- ],- ),),- if (typing) const Spacer(),- // The dock: the task, then Start. It rides the keyboard.- Padding(- padding: const EdgeInsets.fromLTRB(- Tty.origin,- 20,- Tty.origin,- 12,- ),- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- // A first harness has nothing to go on: three first tasks to tap, the kind- // that shows what an agent does in a minute.- if (_task.text.trim().isEmpty && !_creating)- Padding(- padding: const EdgeInsets.only(bottom: 8),- child: Wrap(- spacing: 8,- runSpacing: 8,- children: [- for (final idea in const [- 'Explain this project to me',- 'Find a bug and fix it',- 'Run the tests',- ])- _Suggestion(- text: idea,- onTap: () => setState(() {- _task.value = TextEditingValue(- text: idea,- selection: TextSelection.collapsed(- offset: idea.length,- ),- );- }),- ),- ],- ),- ),- Row(- children: [+ // ⚠️ **The dock scrolls once nothing else can give way.** The rows above it go first,+ // as they always have; with none left, a dock taller than what is left used to+ // overflow — an SE typing its task at the largest text size lost the foot of the+ // field and Start with it. Held to the height below the header, it scrolls instead,+ // pinned to its foot, so the field being typed into and Start stay on the keys.+ Expanded(+ child: LayoutBuilder(+ builder: (context, box) => Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ if (typing)+ const Spacer()+ elseExpanded(- child: TtyText(- 'task (optional)',- color: tty.faint,- size: TtySize.meta,- ),- ),- if (count > 1800)- TtyText(- '$count/$kFirstTaskMaxLength',- color: count > kFirstTaskMaxLength- ? tty.red- : tty.faint,- size: TtySize.meta,- ),- ],- ),- const SizedBox(height: 6),- TtyField(- controller: _task,- hint: 'What should it do?',- lines: 6,- maxLength: kFirstTaskMaxLength,- action: TextInputAction.newline,- onChanged: (_) => setState(() {}),- trailing: [- Align(- alignment: Alignment.bottomRight,- child: ListenableBuilder(- listenable: _voiceIfAny ?? const _Silent(),- builder: (context, _) {- final status = _voiceIfAny?.status;- return TtyFieldMic(- live:- status == VoiceInputStatus.listening ||- status == VoiceInputStatus.starting,- onTap: _creating ? null : _talk,- );- },+ child: ListView(+ keyboardDismissBehavior:+ ScrollViewKeyboardDismissBehavior.onDrag,+ padding: EdgeInsets.zero,+ children: [+ TtyFormRow(+ label: 'agent',+ value: _engine == null+ ? 'Choose an agent'+ : _engineName(_engine!),+ valueColor: _engine == null+ ? tty.green+ : null,+ detail: _engine == null+ ? null+ : _engineNote(_engine!),+ onTap: _creating+ ? null+ : () => unawaited(_chooseAgent()),+ ),+ TtyFormRow(+ label: 'project',+ value: _folder == null && _project == null+ ? 'Choose a project'+ : _projectValue,+ valueColor:+ _folder == null && _project == null+ ? tty.green+ : null,+ detail: null,+ onTap: _creating+ ? null+ : () => unawaited(_chooseProject()),+ ),+ // Options, folded as the desktop folds them: branch, approvals and profile+ // sit on their defaults until asked for.+ TtyFormRow(+ label: 'options',+ // Left as it is nearly every time: folded to `[+]`.+ value: _optionsOpen ? '[−]' : '[+]',+ chevron: false,+ onTap: () => setState(+ () => _optionsOpen = !_optionsOpen,+ ),+ ),+ if (_optionsOpen &&+ (info != null || _gitLoading || _gitFailed))+ TtyFormRow(+ label: 'branch',+ valueColor: info == null && !_gitLoading+ ? tty.faint+ : null,+ value: _gitLoading+ ? 'Reading…'+ : info == null+ ? 'No answer from the computer'+ : _worktree+ ? 'New worktree'+ : _branchTitle,+ detail: info == null+ ? null+ : _worktree+ ? 'from $_branchTitle, in its own folder'+ : _branchNote,+ onTap: info == null || _creating+ ? null+ : () => unawaited(_chooseBranch(info)),+ ),+ if (_optionsOpen && _permissionModes.isNotEmpty)+ TtyFormRow(+ label: 'approvals',+ value: mode?.label ?? 'Auto-approve',+ detail: mode?.detail,+ valueColor: (mode?.risky ?? false)+ ? tty.red+ : null,+ onTap: _creating+ ? null+ : () => unawaited(_chooseApprovals()),+ ),+ if (_optionsOpen && _showsCodexProfile)+ TtyFormRow(+ label: 'profile',+ value: _codexProfile?.label ?? 'Default',+ onTap: _creating+ ? null+ : () => unawaited(_chooseProfile()),+ ),+ ],),),- ],- ),- if (_error != null)- Padding(- padding: const EdgeInsets.only(top: 8),- child: Text(- '✗ ${_error!}',- style: tty.style(- color: tty.red,- size: TtySize.meta,+ // The dock: the task, then Start. It rides the keyboard.+ ConstrainedBox(+ constraints: BoxConstraints(maxHeight: box.maxHeight),+ child: SingleChildScrollView(+ reverse: true,+ child: Padding(+ padding: const EdgeInsets.fromLTRB(+ Tty.origin,+ 20,+ Tty.origin,+ 12,+ ),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ // A first harness has nothing to go on: three first tasks to tap, the kind+ // that shows what an agent does in a minute.+ if (_task.text.trim().isEmpty && !_creating)+ Padding(+ padding: const EdgeInsets.only(bottom: 8),+ child: Wrap(+ spacing: 8,+ runSpacing: 8,+ children: [+ for (final idea in const [+ 'Explain this project to me',+ 'Find a bug and fix it',+ 'Run the tests',+ ])+ _Suggestion(+ text: idea,+ onTap: () => setState(() {+ _task.value = TextEditingValue(+ text: idea,+ selection:+ TextSelection.collapsed(+ offset: idea.length,+ ),+ );+ }),+ ),+ ],+ ),+ ),+ Row(+ children: [+ Expanded(+ child: TtyText(+ 'task (optional)',+ color: tty.faint,+ size: TtySize.meta,+ ),+ ),+ if (count > 1800)+ TtyText(+ '$count/$kFirstTaskMaxLength',+ color: count > kFirstTaskMaxLength+ ? tty.red+ : tty.faint,+ size: TtySize.meta,+ ),+ ],+ ),+ const SizedBox(height: 6),+ TtyField(+ controller: _task,+ hint: 'What should it do?',+ lines: 6,+ maxLength: kFirstTaskMaxLength,+ action: TextInputAction.newline,+ onChanged: (_) => setState(() {}),+ trailing: [+ Align(+ alignment: Alignment.bottomRight,+ child: ListenableBuilder(+ listenable:+ _voiceIfAny ?? const _Silent(),+ builder: (context, _) {+ final status = _voiceIfAny?.status;+ return TtyFieldMic(+ live:+ status ==+ VoiceInputStatus+ .listening ||+ status ==+ VoiceInputStatus.starting,+ onTap: _creating ? null : _talk,+ );+ },+ ),+ ),+ ],+ ),+ if (_error != null)+ Padding(+ padding: const EdgeInsets.only(top: 8),+ child: Text(+ '✗ ${_error!}',+ style: tty.style(+ color: tty.red,+ size: TtySize.meta,+ ),+ ),+ ),+ const SizedBox(height: 10),+ TtyPrimaryButton(+ // Says what it will do: start, or choose what is still missing first.+ label: _failed+ ? 'Try Again'+ : ready+ ? 'Start'+ : _engine == null+ ? 'Choose an agent'+ : 'Choose a project',+ busy: _creating,+ busyLabel: 'Starting…',+ // Never a dead button: with a choice missing, Start opens its chooser.+ onPressed: () => unawaited(_start()),+ ),+ ],+ ),),),),- const SizedBox(height: 10),- TtyPrimaryButton(- // Says what it will do: start, or choose what is still missing first.- label: _failed- ? 'Try Again'- : ready- ? 'Start'- : _engine == null- ? 'Choose an agent'- : 'Choose a project',- busy: _creating,- busyLabel: 'Starting…',- // Never a dead button: with a choice missing, Start opens its chooser.- onPressed: () => unawaited(_start()),- ),- ],+ ],+ ),),),],diff --git a/mobile/test/phone_edge/edge_fixture.dart b/mobile/test/phone_edge/edge_fixture.dartindex 22ca65cf0..b47f4a804 100644--- a/mobile/test/phone_edge/edge_fixture.dart+++ b/mobile/test/phone_edge/edge_fixture.dart@@ -1,6 +1,8 @@import 'dart:async';+import 'dart:io';import 'package:flutter/material.dart';+import 'package:flutter/services.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/auth/auth_session.dart';import 'package:harness_mobile/core/config.dart';@@ -21,14 +23,38 @@ import '../voice_fakes.dart';/// Everything here is a fake — no daemon, no network, no disk outside memory. See the rules in/// `mobile/README.md` and the incident they came from.-/// iPhone SE (2nd/3rd gen), in logical pixels.-const smallPhone = Size(375, 667);+/// A phone as a layout meets it, in logical pixels: the screen, the status bar over its top, the+/// home indicator under its foot, and how tall its keyboard stands (with the suggestion strip).+typedef Phone = ({Size size, double top, double bottom, double keyboard});-/// iPhone 15 Pro Max, in logical pixels.-const largePhone = Size(430, 932);+/// iPhone SE (2nd/3rd gen): a 20pt status bar, a home button rather than an indicator.+const Phone smallPhone = (+ size: Size(375, 667),+ top: 20,+ bottom: 0,+ keyboard: 260,+);++/// iPhone 15 Pro Max.+const Phone largePhone = (+ size: Size(430, 932),+ top: 59,+ bottom: 34,+ keyboard: 346,+);const phones = {'SE': smallPhone, 'Pro Max': largePhone};+/// The phone [setPhone] last set — what [raiseKeyboard] raises.+Phone _current = largePhone;++/// The software keyboard up, at the current phone's height.+void raiseKeyboard(WidgetTester tester) =>+ tester.view.viewInsets = FakeViewPadding(bottom: _current.keyboard * 3);++void lowerKeyboard(WidgetTester tester) =>+ tester.view.viewInsets = FakeViewPadding.zero;+/// The scales the brief asks for, and the largest the app itself can reach: `HarnessApp` pins the/// text scale to Settings ▸ Text size, 11–19pt over a 14pt default.const textScales = [1.0, 19 / 14, 1.5, 2.0];@@ -75,7 +101,7 @@ class FakeSample implements SampleSession {/// A machine the fake conn answers every request for, and accepts every frame.class EdgeConn extends WsConn {- EdgeConn()+ EdgeConn([this.answers = const {}]): super(wsBaseUrl: 'ws://fixture.invalid',autonomousEnv: 'test',@@ -86,6 +112,9 @@ class EdgeConn extends WsConn {onStatus: (_) {},);+ /// What the machine answers, by request type; anything else is answered with nothing.+ final Map<String, Map<String, dynamic>> answers;+final List<(String, Map<String, dynamic>)> frames = [];final List<String> requests = [];@@ -105,7 +134,7 @@ class EdgeConn extends WsConn {Duration timeout = const Duration(seconds: 20),}) async {requests.add(type);- return {};+ return answers[type] ?? {};}}@@ -210,13 +239,16 @@ edgeVoice() {return (voice: voice, recorder: recorder, stt: stt);}-/// Sizes the test's window as [size] logical pixels on a 3x phone, with an iPhone's status bar and-/// home indicator — reset when the test ends.-void setPhone(WidgetTester tester, Size size) {- tester.view.physicalSize = size * 3;+/// Sizes the test's window as [phone] on a 3x screen, with its status bar and home indicator and+/// no keyboard — reset when the test ends.+void setPhone(WidgetTester tester, Phone phone) {+ _current = phone;+ final insets = FakeViewPadding(top: phone.top * 3, bottom: phone.bottom * 3);+ tester.view.physicalSize = phone.size * 3;tester.view.devicePixelRatio = 3;- tester.view.padding = const FakeViewPadding(top: 47 * 3, bottom: 34 * 3);- tester.view.viewPadding = const FakeViewPadding(top: 47 * 3, bottom: 34 * 3);+ tester.view.padding = insets;+ tester.view.viewPadding = insets;+ tester.view.viewInsets = FakeViewPadding.zero;addTearDown(tester.view.reset);}@@ -270,22 +302,22 @@ Future<List<String>> collectErrors(Future<void> Function() body) async {Future<void> expectNoLayoutErrors(WidgetTester tester,Future<void> Function(double scale, Brightness brightness) pump, {- Map<String, Size> sizes = phones,+ Map<String, Phone> sizes = phones,List<double> scales = textScales,List<Brightness> brightnesses = const [Brightness.dark, Brightness.light],}) async {final failures = <String>[];- for (final MapEntry(key: phone, value: size) in sizes.entries) {+ for (final MapEntry(key: name, value: phone) in sizes.entries) {for (final scale in scales) {for (final brightness in brightnesses) {- setPhone(tester, size);+ setPhone(tester, phone);final before = grid.AppTheme.brightness.value;grid.AppTheme.brightness.value = brightness;try {final errors = await collectErrors(() => pump(scale, brightness));for (final error in errors.toSet()) {failures.add(- '$phone ×${scale.toStringAsFixed(2)} ${brightness.name}: $error',+ '$name ×${scale.toStringAsFixed(2)} ${brightness.name}: $error',);}} finally {@@ -299,6 +331,37 @@ Future<void> expectNoLayoutErrors(expect(failures, isEmpty, reason: failures.join('\n'));}+/// Lays the screens out in the phone's own faces rather than the test font, when+/// `PHONE_EDGE_REAL_FONTS=1` asks for it — macOS only, from the SF Mono and SF Pro files the render+/// test reads (`test/render/phone_screens_render_test.dart`).+///+/// ⚠️ **Off by default, and the tests are written to pass either way.** The test font draws every+/// glyph a full em wide — about two thirds wider than SF Mono — so text wraps sooner than on a+/// phone and a layout that holds here holds there. The real faces are for telling a layout that+/// is truly short of room from one only the test font crowds.+Future<void> loadRealFontsIfAsked() async {+ if (Platform.environment['PHONE_EDGE_REAL_FONTS'] != '1' ||+ !Platform.isMacOS) {+ return;+ }+ Future<void> load(String family, List<String> files) async {+ final loader = FontLoader(family);+ for (final file in files) {+ final bytes = await File('/Library/Fonts/$file').readAsBytes();+ loader.addFont(Future.value(ByteData.view(bytes.buffer)));+ }+ await loader.load();+ }++ const weights = ['Regular', 'Medium', 'Semibold', 'Bold'];+ for (final family in ['.AppleSystemUIFontMonospaced', 'SF Mono']) {+ await load(family, [for (final w in weights) 'SF-Mono-$w.otf']);+ }+ for (final family in ['.AppleSystemUIFont', 'SF Pro Text', 'Roboto']) {+ await load(family, [for (final w in weights) 'SF-Pro-Text-$w.otf']);+ }+}+/// Takes the screen down and runs its clocks out, so no timer outlives the test.Future<void> unmount(WidgetTester tester) async {await tester.pumpWidget(const SizedBox());diff --git a/mobile/test/phone_edge/focus_layout_test.dart b/mobile/test/phone_edge/focus_layout_test.dartindex b1d1f5956..1871a5bcf 100644--- a/mobile/test/phone_edge/focus_layout_test.dart+++ b/mobile/test/phone_edge/focus_layout_test.dart@@ -12,6 +12,8 @@ import 'edge_fixture.dart';/// Focus — one agent's terminal, full screen — laid out at every phone, scale and brightness the/// phone meets, with the names that break layouts. None may report an overflow.void main() {+ setUpAll(loadRealFontsIfAsked);+Future<void> pumpFocus(WidgetTester tester,AppNotifier app,@@ -110,10 +112,10 @@ void main() {await pumpFocus(tester, app, scale, brightness);await tester.tap(find.byType(TerminalView));await tester.pump();- tester.view.viewInsets = const FakeViewPadding(bottom: 336 * 3);+ raiseKeyboard(tester);await frames(tester);expect(find.byKey(const ValueKey('terminal-key-esc')), findsOneWidget);- tester.view.viewInsets = FakeViewPadding.zero;+ lowerKeyboard(tester);await frames(tester);});});diff --git a/mobile/test/phone_edge/new_layout_test.dart b/mobile/test/phone_edge/new_layout_test.dartnew file mode 100644index 000000000..7f940e259--- /dev/null+++ b/mobile/test/phone_edge/new_layout_test.dart@@ -0,0 +1,142 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/phone/new_agent_draft.dart';+import 'package:harness_mobile/phone/new_agent_page.dart';+import 'package:harness_mobile/state/app_state.dart';++import 'edge_fixture.dart';++/// New — start an agent — laid out at every phone, scale and brightness, empty, full, typing and+/// failed. None may report an overflow.+void main() {+ setUpAll(loadRealFontsIfAsked);+ tearDown(() => newAgentDraft = null);++ /// A repository with a long branch, so the options have something to say.+ const gitAnswer = {+ 'git_project_info': {+ 'isGit': true,+ 'branch': longBranch,+ 'root': '/code/$longProject',+ 'defaultRef': 'refs/heads/main',+ 'branches': [+ {'ref': 'refs/heads/main', 'name': 'main'},+ {'ref': 'refs/heads/$longBranch', 'name': longBranch},+ ],+ },+ };++ Future<void> pumpNew(+ WidgetTester tester,+ AppNotifier app,+ double scale,+ Brightness brightness,+ ) async {+ await tester.pumpWidget(+ phoneApp(+ NewAgentPage(notifier: app, machineId: 'm', voice: edgeVoice().voice),+ textScale: scale,+ brightness: brightness,+ ),+ );+ await frames(tester);+ }++ testWidgets('a machine with nothing running and no project yet', (+ tester,+ ) async {+ await expectNoLayoutErrors(tester, (scale, brightness) async {+ final app = edgeApp(agents: []);+ addTearDown(app.dispose);+ await pumpNew(tester, app, scale, brightness);+ expect(find.text('Choose a project', findRichText: true), findsWidgets);+ });+ });++ testWidgets('long names everywhere, 200 agents, options open', (+ tester,+ ) async {+ await expectNoLayoutErrors(tester, (scale, brightness) async {+ final app = edgeApp(+ machineName: longMachine,+ conn: EdgeConn(gitAnswer),+ agents: [+ edgeAgent('a', name: longName, project: longProject),+ ...manyAgents(199),+ ],+ );+ addTearDown(app.dispose);+ await pumpNew(tester, app, scale, brightness);+ await tester.tap(find.text('options'));+ await frames(tester);+ });+ });++ testWidgets('typing a long task with the keyboard up', (tester) async {+ await expectNoLayoutErrors(tester, (scale, brightness) async {+ final app = edgeApp(+ machineName: longMachine,+ agents: [edgeAgent('a', project: longProject)],+ );+ addTearDown(app.dispose);+ await pumpNew(tester, app, scale, brightness);+ await tester.enterText(+ find.byType(TextField),+ List.filled(40, 'fix the login test $emojiName $rtlName').join(' '),+ );+ raiseKeyboard(tester);+ await frames(tester);+ lowerKeyboard(tester);+ await frames(tester);+ });+ });++ testWidgets(+ 'on an SE at the largest text size, typing keeps Start on screen above the keys',+ (tester) async {+ setPhone(tester, smallPhone);+ final app = edgeApp(agents: [edgeAgent('a')]);+ addTearDown(app.dispose);+ await pumpNew(tester, app, 19 / 14, Brightness.dark);+ await tester.enterText(+ find.byType(TextField),+ List.filled(12, 'fix the login test and run the suite').join(' '),+ );+ raiseKeyboard(tester);+ await frames(tester);++ // Before: the dock overflowed by 10px here and Start fell under the keyboard.+ expect(tester.takeException(), isNull);+ final start = tester.getRect(find.text('Start'));+ expect(+ start.bottom,+ lessThanOrEqualTo(smallPhone.size.height - smallPhone.keyboard),+ );+ await tester.tap(find.text('Start'), warnIfMissed: true);+ lowerKeyboard(tester);+ await unmount(tester);+ },+ );++ testWidgets('a creation the machine refused', (tester) async {+ await expectNoLayoutErrors(tester, (scale, brightness) async {+ final app = edgeApp(+ conn: EdgeConn(const {+ 'agent_create': {+ 'error': {+ 'code': 'INVALID_CWD',+ 'message':+ 'The project folder is unavailable on this machine. Choose another '+ 'folder and try again, or check that the disk is mounted.',+ },+ },+ }),+ agents: [edgeAgent('a', project: longProject)],+ );+ addTearDown(app.dispose);+ await pumpNew(tester, app, scale, brightness);+ await tester.tap(find.text('Start'));+ await frames(tester);+ });+ });+}