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: enhance desk synchronization and update test descriptions for clarity
Dev jacobf389b0a4dd02
diff --git a/mobile/test/desk_fixture.dart b/mobile/test/desk_fixture.dartindex e07e16fd5..3805cb616 100644--- a/mobile/test/desk_fixture.dart+++ b/mobile/test/desk_fixture.dart@@ -3,6 +3,7 @@ import 'package:harness_mobile/auth/auth_session.dart';import 'package:harness_mobile/core/config.dart';import 'package:harness_mobile/state/app_state.dart';import 'package:harness_mobile/state/desk_sync.dart';+import 'package:harness_mobile/state/phone_desk.dart';import 'agent_pager_fixture.dart';@@ -65,13 +66,20 @@ Future<AppNotifier> deskApp(if (!opensTerminals) {app.stateOf('m')!.terminalCapabilityAvailable = false;}+ await syncDesk(app);+ return app;+}++/// Read the desk now, and leave no poll behind.+///+/// ⚠️ A test is not a phone somebody is holding. Reading the desk arms the+/// foreground poll (see [PhoneDesk.pollInterval]) and `testWidgets` fails a test+/// that leaves a timer running — so every read a test makes ends the way+/// backgrounding the app would. Tests about the poll itself drive [PhoneDesk]+/// directly, with an interval of their own.+Future<void> syncDesk(AppNotifier app) async {await app.deskSyncForTest();- // ⚠️ A test is not a phone somebody is holding. Joining the desk arms the- // foreground poll (see [PhoneDesk.pollInterval]), and `testWidgets` fails a- // test that leaves a timer running. Tests about the poll itself drive- // [PhoneDesk] directly, with an interval of their own.app.handleAppPaused();- return app;}/// The desk this app is talking to.diff --git a/mobile/test/phone_desk_tabs_test.dart b/mobile/test/phone_desk_tabs_test.dartindex a227daaa6..b87be4f8b 100644--- a/mobile/test/phone_desk_tabs_test.dart+++ b/mobile/test/phone_desk_tabs_test.dart@@ -3,7 +3,7 @@ import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/phone/agent_home.dart';import 'package:harness_mobile/phone/agent_swipe.dart';import 'package:harness_mobile/phone/desk_groups.dart';-import 'package:harness_mobile/phone/desk_tab_strip.dart';+import 'package:harness_mobile/phone/terminal_header.dart';import 'package:harness_mobile/phone/phone_shell_scope.dart';import 'package:harness_mobile/state/app_state.dart';import 'package:harness_mobile/state/desk_sync.dart';@@ -12,7 +12,7 @@ import 'agent_pager_fixture.dart';import 'desk_fixture.dart';/// The home screen inside its tab: a swipe walks the tab the phone is in, and-/// the strip is how it gets to another one.+/// the mark beside `⋯` is how it gets to another one.////// ⚠️ **The pager's `neighbours` is the assertion throughout, because it IS the/// swipe.** [AgentSwipeHost] pages through exactly that list and nothing else,@@ -20,8 +20,8 @@ import 'desk_fixture.dart';/// which is the whole change, and it can be read without flinging anything.void main() {/// The home screen as the shell mounts it: an agent picked anywhere else —- /// the strip included — arrives through [AgentHome.openAgent], and the shell- /// is what carries it there.+ /// the tabs sheet included — arrives through [AgentHome.openAgent], and the+ /// shell is what carries it there.Future<AppNotifier> pumpHome(WidgetTester tester, {required List<DeskTab> tabs,@@ -52,6 +52,23 @@ void main() {AgentSwipeHost pager(WidgetTester tester) =>tester.widget<AgentSwipeHost>(find.byType(AgentSwipeHost));+ /// Open the tabs sheet from the mark in the header, and pick [tab] in it.+ ///+ /// ⚠️ **Timed pumps, never `pumpAndSettle`.** These pages have no terminal+ /// behind them (see [deskApp]), so each one draws the "Attaching…" skeleton —+ /// which breathes for ever, and `pumpAndSettle` waits for a still frame that+ /// never comes. The waits below are the sheet's own open and dismiss+ /// animations; the row runs its action after the dismissal (see+ /// [showPhoneSheet]), so the second one is the switch as well.+ Future<void> switchTo(WidgetTester tester, String tab) async {+ await tester.tap(find.byTooltip('Tabs'));+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));+ await tester.tap(find.text(tab));+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));+ }+List<String> swipesOver(WidgetTester tester) => [for (final entry in pager(tester).neighbours!.entries) entry.agent.id,];@@ -82,9 +99,7 @@ void main() {],);- await tester.tap(find.text('Docker'));- await tester.pump();- await tester.pump();+ await switchTo(tester, 'Docker');expect(pager(tester).agentId, 'c');expect(swipesOver(tester), ['c', 'd']);@@ -99,9 +114,7 @@ void main() {],);- await tester.tap(find.text(kUntabbedGroupName));- await tester.pump();- await tester.pump();+ await switchTo(tester, kUntabbedGroupName);expect(pager(tester).agentId, 'c');expect(swipesOver(tester), ['c', 'd']);@@ -118,31 +131,47 @@ void main() {],);- // Swiped to `b` and then away to the other tab.- app.noteDeskTab('t1', showing: (machineId: 'm', agentId: 'b'));- await tester.tap(find.text('Docker'));- await tester.pump();- await tester.pump();+ await switchTo(tester, 'Docker');expect(pager(tester).agentId, 'c');+ // Desktop was left on `b` — what a swipe inside that tab records, and what+ // the home screen writes down on every build it draws (`noteDeskTab`).+ app.noteDeskTab('t1', showing: (machineId: 'm', agentId: 'b'));- await tester.tap(find.text('Desktop'));- await tester.pump();- await tester.pump();+ await switchTo(tester, 'Desktop');expect(pager(tester).agentId, 'b');});- testWidgets('one tab is no choice, so no strip is drawn', (tester) async {- // Every agent on the one tab: nothing to switch to, and the header is the- // row it has always been.+ testWidgets('an account with no tabs is offered none', (tester) async {+ // Nothing on the desk: the sheet would hold one row naming every agent on+ // the account, which is what a swipe already walks. So no mark at all, and+ // the header is the row it has always been.+ await pumpHome(tester, tabs: []);++ expect(find.byTooltip('Tabs'), findsNothing);+ expect(swipesOver(tester), ['a', 'b', 'c', 'd']);+ });++ testWidgets('the tabs mark sits in the header, not over the terminal', (+ tester,+ ) async {await pumpHome(tester,tabs: [- deskTab('t1', 'Desktop', ['a', 'b', 'c', 'd']),+ deskTab('t1', 'Desktop', ['a', 'b']),+ deskTab('t2', 'Docker', ['c']),],);- expect(find.byType(DeskTabStrip), findsNothing);+ // One mark, inside the header's own row — nothing is stacked under it, so+ // the terminal keeps every line it had before the desk existed.+ final mark = find.byTooltip('Tabs');+ expect(mark, findsOneWidget);+ expect(+ tester.getCenter(mark).dy,+ lessThan(TerminalHeader.height),+ reason: 'the mark rides the header row',+ );});testWidgets('a tab changed on another computer moves the swipe with it', (@@ -163,7 +192,7 @@ void main() {deskTab('t2', 'Docker', ['c']),];deskApiOf(app).revision++;- await app.deskSyncForTest();+ await syncDesk(app);await tester.pump();expect(pager(tester).agentId, 'a');