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
feat(mobile): a tab is renamed by double-tapping its name
bubu-dudu4affca3d1926
diff --git a/mobile/lib/phone/desk_tab_rename_dialog.dart b/mobile/lib/phone/desk_tab_rename_dialog.dartnew file mode 100644index 000000000..509027fc1--- /dev/null+++ b/mobile/lib/phone/desk_tab_rename_dialog.dart@@ -0,0 +1,89 @@+import 'package:flutter/material.dart';++import 'package:harness_mobile/shared/theme/app_theme.dart';+import 'package:harness_mobile/shared/widgets/app_dialog.dart';+import 'package:harness_mobile/state/app_state.dart';++/// Rename a tab, from a double tap on its name in the tabs panel.+///+/// ⚠️ **It writes and closes; it does not wait to be told it worked.** A tab+/// name is not the CLI's to refuse the way an agent's is (see+/// [showAgentRenameDialog], which shows the machine's answer under the field):+/// the desk takes the op, every computer on the account picks it up, and this+/// phone has already drawn the new name over its own copy — see+/// [PhoneDesk.renameTab]. A dialog held open for a round trip would sit there+/// on a phone in a lift for no reason.+Future<void> showDeskTabRenameDialog(+ BuildContext context,+ AppNotifier notifier, {+ required String tabId,+ required String currentName,+}) => showAppDialog<void>(+ context: context,+ builder: (_) => _RenameTabDialog(+ notifier: notifier,+ tabId: tabId,+ currentName: currentName,+ ),+);++/// ⚠️ A widget that OWNS its controller — see the note in+/// `widgets/rename_agent_dialog.dart` for the red screen the other shape+/// caused.+class _RenameTabDialog extends StatefulWidget {+ const _RenameTabDialog({+ required this.notifier,+ required this.tabId,+ required this.currentName,+ });++ final AppNotifier notifier;+ final String tabId;+ final String currentName;++ @override+ State<_RenameTabDialog> createState() => _RenameTabDialogState();+}++class _RenameTabDialogState extends State<_RenameTabDialog> {+ late final _controller = TextEditingController(text: widget.currentName)+ // The name is there to be replaced, not to be typed around: selected, the+ // first key wipes it, and a thumb that meant to edit still has the caret.+ ..selection = TextSelection(+ baseOffset: 0,+ extentOffset: widget.currentName.length,+ );++ @override+ void dispose() {+ _controller.dispose();+ super.dispose();+ }++ void _submit() {+ widget.notifier.renameDeskTab(widget.tabId, _controller.text);+ Navigator.of(context).pop();+ }++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return AlertDialog(+ title: const Text('Rename tab'),+ content: TextField(+ controller: _controller,+ autofocus: true,+ style: kFieldTextStyle,+ textInputAction: TextInputAction.done,+ onSubmitted: (_) => _submit(),+ ),+ actions: [+ TextButton(+ onPressed: () => Navigator.of(context).pop(),+ child: const Text('Cancel'),+ ),+ FilledButton(onPressed: _submit, child: const Text('Save')),+ ],+ );+ }+}diff --git a/mobile/lib/phone/desk_tab_strip.dart b/mobile/lib/phone/desk_tab_strip.dartindex a1c311ce8..0aca358d0 100644--- a/mobile/lib/phone/desk_tab_strip.dart+++ b/mobile/lib/phone/desk_tab_strip.dart@@ -37,6 +37,7 @@ class DeskTabStrip extends StatefulWidget {required this.selectedId,required this.onPick,this.onAddTab,+ this.onRename,});/// Every tab, in the desk's own order, with the leftover group last — see@@ -54,6 +55,11 @@ class DeskTabStrip extends StatefulWidget {/// [AppNotifier.deskWritable].final VoidCallback? onAddTab;+ /// A name double-tapped. Called only for the groups that are real tabs on a+ /// desk this phone may write to — the leftover group has no name of its own+ /// to change.+ final void Function(DeskGroup group)? onRename;+/// The row's height, which the popup counts into its own.////// One 15pt line, the bar under it, and the air that keeps the names off the@@ -121,6 +127,7 @@ class _DeskTabStripState extends State<DeskTabStrip> {final selectedId = widget.selectedId;final onPick = widget.onPick;final onAddTab = widget.onAddTab;+ final onRename = widget.onRename;const sideInset = DeskTabStrip.sideInset;const height = DeskTabStrip.height;const gap = DeskTabStrip._gap;@@ -153,6 +160,20 @@ class _DeskTabStripState extends State<DeskTabStrip> {selected: selected,reachable: !group.isEmpty,onTap: () => onPick(group),+ // ⚠️ **Only the tab being SHOWN can be double-tapped, and+ // that is a decision about the other tabs rather than about+ // this one.** A name that has to wait and see whether a+ // second tap is coming answers the first one 300ms late —+ // and on every other name that first tap is the switch+ // itself, which is the one thing on this row that has to+ // feel immediate. On the tab already open the tap does+ // nothing anyway, so the wait costs nothing.+ //+ // Null too for the leftover group and on a desk with no+ // writes — see [DeskTabStrip.onRename].+ onRename: onRename == null || group.id == null || !selected+ ? null+ : () => onRename(group),);},),@@ -227,6 +248,7 @@ class _DeskTabName extends StatelessWidget {required this.selected,required this.reachable,required this.onTap,+ required this.onRename,});final String name;@@ -238,6 +260,13 @@ class _DeskTabName extends StatelessWidget {final VoidCallback onTap;+ /// A double tap on the name. Null on the groups that cannot be renamed, and+ /// that is worth more than a dead callback would be: a name with no+ /// double-tap recognizer answers a SINGLE tap at once, while one that has to+ /// wait and see whether a second is coming answers it 300ms later. So the+ /// tabs that cannot be renamed keep the snappier tap.+ final VoidCallback? onRename;+static const double _barHeight = 2;static const double _barGap = 5;@@ -254,6 +283,7 @@ class _DeskTabName extends StatelessWidget {// the tap — a 15pt word is a small thing to hit with a thumb.behavior: HitTestBehavior.opaque,onTap: _tapped,+ onDoubleTap: onRename == null ? null : _renamed,child: Center(child: Stack(children: [@@ -300,4 +330,9 @@ class _DeskTabName extends StatelessWidget {HapticFeedback.selectionClick();onTap();}++ void _renamed() {+ HapticFeedback.selectionClick();+ onRename?.call();+ }}diff --git a/mobile/lib/phone/desk_tabs_popup.dart b/mobile/lib/phone/desk_tabs_popup.dartindex 69e266794..a87aa9bc6 100644--- a/mobile/lib/phone/desk_tabs_popup.dart+++ b/mobile/lib/phone/desk_tabs_popup.dart@@ -13,6 +13,7 @@ import 'agent_tile.dart';import 'agents_page.dart' show openNewAgent;import 'desk_add_agent_sheet.dart';import 'desk_groups.dart';+import 'desk_tab_rename_dialog.dart';import 'desk_tab_strip.dart';import 'phone_card.dart';import 'phone_navigation.dart';@@ -167,6 +168,26 @@ class _DeskTabsPanelState extends State<_DeskTabsPanel> {.isNotEmpty ??false;+ /// A double tap on a tab's name.+ ///+ /// ⚠️ **The tab is picked as well as renamed, and not as an afterthought.**+ /// The first tap of the two has already picked it, so the panel below is+ /// showing what is being named — and after a rename the row under the names+ /// would otherwise belong to a different tab than the one just typed.+ void _rename(DeskGroup group) {+ final id = group.id;+ if (id == null) return;+ setState(() => _selectedId = id);+ unawaited(+ showDeskTabRenameDialog(+ context,+ widget.notifier,+ tabId: id,+ currentName: group.name,+ ),+ );+ }+/// The `+` on the tab row: a tab of its own for an agent picked or made now.////// ⚠️ **The tab is written only once there is something to put in it.** A@@ -269,6 +290,7 @@ class _DeskTabsPanelState extends State<_DeskTabsPanel> {// Undrawn on a desk that cannot be written to — see// [AppNotifier.deskWritable].onAddTab: widget.notifier.deskWritable ? _addTab : null,+ onRename: widget.notifier.deskWritable ? _rename : null,),const SizedBox(height: 6),// ⚠️ **One height, whatever the tab holds.** Sized to its contents,diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dartindex a60a8e5c1..4ead88b74 100644--- a/mobile/lib/state/app_state.dart+++ b/mobile/lib/state/app_state.dart@@ -557,6 +557,11 @@ class AppNotifier extends ChangeNotifier {void addAgentToDeskTab(String tabId, AgentRef agent) =>_desk.addToTab(tabId, agent);+ /// A tab renamed by hand, from a double tap on its name in the tabs panel.+ /// See [PhoneDesk.renameTab].+ void renameDeskTab(String tabId, String name) =>+ _desk.renameTab(tabId, name);+/// An agent that already exists opens a tab of its own — the `+` on the tab/// row. See [PhoneDesk.createTabFor].String? createDeskTabFor(AgentRef agent, {String? name}) =>diff --git a/mobile/lib/state/phone_desk.dart b/mobile/lib/state/phone_desk.dartindex 7f0bdc009..9326619e7 100644--- a/mobile/lib/state/phone_desk.dart+++ b/mobile/lib/state/phone_desk.dart@@ -270,6 +270,33 @@ class PhoneDesk {return id;}+ /// A tab renamed by hand on this phone.+ ///+ /// ⚠️ **`nameIsCustom: true`, and that is not the same field twice.** A tab+ /// carries the name of whatever is in it until somebody says otherwise: a+ /// window re-derives it as panes come and go, and [createTabFor] leaves that+ /// free. A name typed by a person is the exception every computer has to+ /// honour, and this flag is how they know — without it the next pane added on+ /// a desktop would quietly take the name back.+ ///+ /// A blank name is not a rename; it is a tap on Save with nothing typed, and+ /// the tab keeps what it had.+ void renameTab(String tabId, String name) {+ if (!_state.enabled) return;+ final trimmed = name.trim();+ if (trimmed.isEmpty) return;+ final tab = _state.synced.where((t) => t.id == tabId).firstOrNull;+ if (tab == null || (tab.name == trimmed && tab.nameIsCustom)) return;+ _queue([+ {+ 'op': 'tab.rename',+ 'id': tabId,+ 'name': trimmed,+ 'nameIsCustom': true,+ },+ ]);+ }+/// An agent that already exists joins a tab the person picked — which need/// not be the tab the phone is in. Silent where the tab has it already: the/// panel offers agents a tab lacks, but the desk can have moved underneath.diff --git a/mobile/test/desk_tab_add_test.dart b/mobile/test/desk_tab_add_test.dartindex d9024299e..8a54a0078 100644--- a/mobile/test/desk_tab_add_test.dart+++ b/mobile/test/desk_tab_add_test.dart@@ -64,6 +64,17 @@ void main() {await tester.pump();}+ /// The rename gesture. The pause between the two taps is inside Flutter's+ /// 300ms double-tap window, and the wait after it is the dialog's own+ /// transition.+ Future<void> doubleTap(WidgetTester tester, String tab) async {+ await tester.tap(find.text(tab));+ await tester.pump(const Duration(milliseconds: 50));+ await tester.tap(find.text(tab));+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));+ }+Future<void> settleSheet(WidgetTester tester) async {await tester.pump();await tester.pump(const Duration(milliseconds: 400));@@ -195,6 +206,76 @@ void main() {expect(find.bySemanticsLabel('Add agent to Empty'), findsOneWidget);});+ testWidgets('a name double-tapped is the tab renamed, and kept custom', (+ tester,+ ) async {+ final app = await pumpHome(+ tester,+ tabs: [+ deskTab('t1', 'Desktop', ['a']),+ deskTab('t2', 'Docker', ['b']),+ ],+ );++ await openPanel(tester);+ // ⚠️ Switched to first, THEN double-tapped: only the tab being shown takes+ // the gesture — see [DeskTabStrip.onRename].+ await showTab(tester, 'Docker');+ await doubleTap(tester, 'Docker');++ await tester.enterText(find.byType(TextField), 'Servers');+ await tester.tap(find.text('Save'));+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));++ expect(deskApiOf(app).written, [+ {'op': 'tab.rename', 'id': 't2', 'name': 'Servers', 'nameIsCustom': true},+ ]);+ expect(+ app.deskTabs.firstWhere((tab) => tab.id == 't2').nameIsCustom,+ isTrue,+ reason: 'a name a person typed is not one a window may take back',+ );+ expect(find.text('Servers'), findsOneWidget);+ });++ testWidgets('a blank name leaves the tab as it was', (tester) async {+ final app = await pumpHome(+ tester,+ tabs: [+ deskTab('t1', 'Desktop', ['a']),+ ],+ );++ await openPanel(tester);+ await doubleTap(tester, 'Desktop');++ await tester.enterText(find.byType(TextField), ' ');+ await tester.tap(find.text('Save'));+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));++ expect(deskApiOf(app).written, isEmpty);+ expect(find.text('Desktop'), findsOneWidget);+ });++ testWidgets('the agents no tab holds cannot be renamed', (tester) async {+ final app = await pumpHome(+ tester,+ tabs: [+ deskTab('t1', 'Desktop', ['a']),+ ],+ );++ await openPanel(tester);+ await showTab(tester, 'Other');+ await doubleTap(tester, 'Other');++ // "Other" is not a tab on the desk — there is no name to write.+ expect(find.byType(TextField), findsNothing);+ expect(deskApiOf(app).written, isEmpty);+ });+testWidgets('the agents no tab holds are offered no + of their own', (tester,) async {