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.

refactor(mobile): one New agent button, in one place on both screens

bubu-dudu757ac3fa5fb6
diff --git a/mobile/lib/phone/agents_page.dart b/mobile/lib/phone/agents_page.dart
index a3b64d1da..10a998398 100644
--- a/mobile/lib/phone/agents_page.dart
+++ b/mobile/lib/phone/agents_page.dart
@@ -13,6 +13,7 @@ import 'agent_tile.dart';
import 'delete_agent.dart';
import 'link_page.dart';
import 'phone_card.dart';
+import 'phone_fab.dart';
import 'new_agent_page.dart';
import 'phone_header.dart';
import 'phone_navigation.dart';
@@ -46,8 +47,26 @@ class AgentsPage extends StatelessWidget {
builder: (context, _) {
AppTheme.watch(context);
final machine = notifier.stateOf(machineId);
+ // Only once the machine is answering: creating needs it to list its folders and say which
+ // engines it has, and a button that opens a page with neither is a dead end.
+ final canCreate =
+ machine != null &&
+ phoneMachineStatusOf(machine) == PhoneMachineStatus.ready;
return Scaffold(
backgroundColor: AppPalette.windowBg,
+ // Down here rather than in the header beside `⋯`, matching the Agents tab: the same act
+ // reached from two screens should be in the same place on both, and a list's primary
+ // action belongs under the thumb rather than at the far top corner.
+ //
+ // ⚠️ This page's Scaffold is the last one, unlike the tab's — nothing sits below it, so the
+ // button clears the home indicator on `SafeArea`'s account rather than a tab bar's.
+ floatingActionButton: !canCreate
+ ? null
+ : PhoneFab(
+ icon: LucideIcons.plus300,
+ tooltip: 'New agent',
+ onPressed: () => openNewAgent(context, notifier, machineId),
+ ),
body: SafeArea(
bottom: false,
child: Column(
@@ -58,19 +77,6 @@ class AgentsPage extends StatelessWidget {
? null
: StatusPill(summary: phoneMachineSummary(machine)),
trailing: [
- // Only once the machine is answering: creating needs it to
- // list its folders and say which engines it has, and a button
- // that opens a page with neither is a dead end.
- if (machine != null &&
- phoneMachineStatusOf(machine) == PhoneMachineStatus.ready)
- AppIconButton(
- icon: LucideIcons.plus300,
- size: 20,
- tooltip: 'New agent',
- color: AppPalette.textSecondary,
- onPressed: () =>
- openNewAgent(context, notifier, machineId),
- ),
if (machine != null)
AppIconButton(
icon: LucideIcons.ellipsis300,
diff --git a/mobile/lib/phone/agents_tab.dart b/mobile/lib/phone/agents_tab.dart
index 6c14dd033..1bdc3d833 100644
--- a/mobile/lib/phone/agents_tab.dart
+++ b/mobile/lib/phone/agents_tab.dart
@@ -4,12 +4,14 @@ import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart';
import 'package:harness_mobile/shared/widgets/empty_state.dart';
import 'package:harness_mobile/state/app_state.dart';
+
import 'agent_index.dart';
import 'agent_row.dart';
import 'agents_page.dart';
import 'account_button.dart';
import 'machine_filter_bar.dart';
import 'phone_card.dart';
+import 'phone_fab.dart';
import 'phone_header.dart';
import 'phone_sheet.dart';
import 'phone_navigation.dart';
@@ -57,7 +59,8 @@ class _AgentsTabState extends State<AgentsTab> {
// agent — the same gate the machine's own page puts on its `+`.
final ready = [
for (final machine in machines)
- if (phoneMachineStatusOf(machine) == PhoneMachineStatus.ready) machine,
+ if (phoneMachineStatusOf(machine) == PhoneMachineStatus.ready)
+ machine,
];
return Scaffold(
backgroundColor: AppPalette.windowBg,
@@ -69,15 +72,10 @@ class _AgentsTabState extends State<AgentsTab> {
// shell's (`phone_shell.dart`), whose own `bottomNavigationBar` sits below it.
floatingActionButton: ready.isEmpty
? null
- : FloatingActionButton(
- onPressed: () => _pickMachine(context, ready),
- backgroundColor: AppPalette.accent,
- foregroundColor: Colors.white,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(AppCard.radius),
- ),
+ : PhoneFab(
+ icon: LucideIcons.plus300,
tooltip: 'New agent',
- child: const Icon(LucideIcons.plus300, size: 26),
+ onPressed: () => _pickMachine(context, ready),
),
body: SafeArea(
bottom: false,
@@ -234,21 +232,24 @@ class _Body extends StatelessWidget {
);
}
- Widget _row(BuildContext context, List<AgentEntry> ordered, AgentEntry entry) =>
- Padding(
- padding: const EdgeInsets.only(bottom: kPhoneCardGap),
- child: AgentRow(
- entry: entry,
- // The whole visible list goes with the tap, so the page opens as a pager over exactly the
- // agents on screen — the filter chip included. Swiping there walks this order.
- onTap: () => openAgentPager(context, notifier, ordered, entry),
- // The same sheet a machine's own page opens, from [AgentsPage] rather than written again
- // here: one agent reached two ways must not offer two different sets of actions, and the
- // delete wording in particular is the one that has to match.
- onLongPress: () =>
- showAgentActions(context, notifier, entry.machineId, entry.agent),
- ),
- );
+ Widget _row(
+ BuildContext context,
+ List<AgentEntry> ordered,
+ AgentEntry entry,
+ ) => Padding(
+ padding: const EdgeInsets.only(bottom: kPhoneCardGap),
+ child: AgentRow(
+ entry: entry,
+ // The whole visible list goes with the tap, so the page opens as a pager over exactly the
+ // agents on screen — the filter chip included. Swiping there walks this order.
+ onTap: () => openAgentPager(context, notifier, ordered, entry),
+ // The same sheet a machine's own page opens, from [AgentsPage] rather than written again
+ // here: one agent reached two ways must not offer two different sets of actions, and the
+ // delete wording in particular is the one that has to match.
+ onLongPress: () =>
+ showAgentActions(context, notifier, entry.machineId, entry.agent),
+ ),
+ );
}
class _SectionLabel extends StatelessWidget {
diff --git a/mobile/lib/phone/phone_fab.dart b/mobile/lib/phone/phone_fab.dart
new file mode 100644
index 000000000..4ffdf81ed
--- /dev/null
+++ b/mobile/lib/phone/phone_fab.dart
@@ -0,0 +1,46 @@
+import 'package:flutter/material.dart';
+
+import 'package:harness_mobile/shared/theme/app_theme.dart';
+
+/// The phone's one floating action button: a screen's primary act, put where a
+/// thumb already rests rather than in the header a thumb has to reach for.
+///
+/// Its own widget because two screens draw it — the Agents tab and a machine's
+/// own page — and a button that looks like the app on one screen and like bare
+/// Material on the other is the bug. What it DOES differs (one asks which
+/// machine first, the other already knows); only the shape is shared.
+///
+/// ⚠️ Callers pass null rather than disabling it. Both uses gate on a machine
+/// being able to host an agent at all, and a button whose only outcome is an
+/// explanation of why it does nothing is worse than no button.
+class PhoneFab extends StatelessWidget {
+ const PhoneFab({
+ super.key,
+ required this.icon,
+ required this.tooltip,
+ required this.onPressed,
+ });
+
+ final IconData icon;
+ final String tooltip;
+ final VoidCallback onPressed;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return FloatingActionButton(
+ onPressed: onPressed,
+ // The accent is specified as a solid fill with white on it, so the
+ // foreground is white in both themes rather than a token that flips.
+ backgroundColor: AppPalette.accent,
+ foregroundColor: Colors.white,
+ // The radius every card in these lists uses, so it reads as one family
+ // rather than a circle dropped on top of them.
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(AppCard.radius),
+ ),
+ tooltip: tooltip,
+ child: Icon(icon, size: 26),
+ );
+ }
+}