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(desktop): Cmd-P — one scrollbar, and a list that holds still while open (#378)
Dee73651d72eadb
diff --git a/desktop/lib/state/swarm_navigation.dart b/desktop/lib/state/swarm_navigation.dartindex 4145875c3..4ff08b519 100644--- a/desktop/lib/state/swarm_navigation.dart+++ b/desktop/lib/state/swarm_navigation.dart@@ -715,7 +715,9 @@ List<SwarmDestination> rankSwarmDestinationsByActivity(List<String> recent = const [],SessionPreviewStore? previews,Map<String, SessionContentHit>? contentHits,+ DateTime? Function(SwarmDestination row)? activityOf,}) {+ final activity = activityOf ?? (SwarmDestination row) => row.lastActivityAt;final matches = _matchSwarmDestinations(all,query,@@ -733,14 +735,14 @@ List<SwarmDestination> rankSwarmDestinationsByActivity(final said = b.said.compareTo(a.said);if (said != 0) return said;}- final aTime = a.entry.lastActivityAt;- final bTime = b.entry.lastActivityAt;- final activity = aTime == null+ final aTime = activity(a.entry);+ final bTime = activity(b.entry);+ final byTime = aTime == null? (bTime == null ? 0 : 1): bTime == null? -1: bTime.compareTo(aTime);- if (activity != 0) return activity;+ if (byTime != 0) return byTime;final visit = (visits[a.entry.id] ?? recent.length).compareTo(visits[b.entry.id] ?? recent.length,);diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dartindex 56c7275c1..08f80d63f 100644--- a/desktop/lib/state/swarm_search.dart+++ b/desktop/lib/state/swarm_search.dart@@ -201,6 +201,17 @@ class SwarmSearchController extends ChangeNotifier {/// Open Harness filters by latest activity; commands and splits keep relevance order.final bool activityFirst;+ /// When this opening began: the list's ages are measured from it.+ final DateTime openedAt = DateTime.now();+ final _activity = <String, DateTime?>{};++ /// A row's last activity as it was when this opening first listed it. The+ /// list keeps the order and ages it opened with while agents work on:+ /// rows moving under the cursor as someone arrowed through them was the+ /// confusing part. The next opening reads activity afresh.+ DateTime? activityOf(SwarmDestination row) =>+ _activity.putIfAbsent(row.id, () => row.lastActivityAt);+/// Cmd-P starts without a choice; typing or navigating activates a result.final bool selectOnEmptyQuery;// Prefixes change the catalog, never the Cmd-P dialog's layout.@@ -967,7 +978,7 @@ class SwarmSearchController extends ChangeNotifier {at != null && !at.isBefore(when.from) && !at.isAfter(when.to);return [for (final row in rows)- if (hits.containsKey(row.id) || then(row.lastActivityAt)) row,+ if (hits.containsKey(row.id) || then(activityOf(row))) row,];}@@ -1183,6 +1194,7 @@ class SwarmSearchController extends ChangeNotifier {wordsQuery,recent: recent,previews: app.sessionPreviews,+ activityOf: activityOf,contentHits: _contentQuery.isEmpty? null: _content?.hitsFor(_contentQuery),diff --git a/desktop/lib/widgets/swarm_search_preview.dart b/desktop/lib/widgets/swarm_search_preview.dartindex e55aec116..f96c98361 100644--- a/desktop/lib/widgets/swarm_search_preview.dart+++ b/desktop/lib/widgets/swarm_search_preview.dart@@ -338,40 +338,53 @@ class _SwarmSearchPreviewState extends State<SwarmSearchPreview> {);}final agents = _agents(app, row);- return Semantics(- container: true,- label: 'Agent preview',- child: Scrollbar(- controller: _scroll,- child: row.isGroup || agents.length != 1- ? ListView.builder(- key: ValueKey('preview-content:${row.id}'),- controller: _scroll,- padding: padding,- scrollCacheExtent: const ScrollCacheExtent.pixels(120),- itemCount: agents.length + 1,- itemBuilder: (context, index) => index == 0- ? Padding(- padding: EdgeInsets.only(- bottom: widget.terminal ? cell.height : 24,+ if (row.isGroup || agents.length != 1) _scroll.reversed = false;+ final content = row.isGroup || agents.length != 1+ ? ListView.builder(+ key: ValueKey('preview-content:${row.id}'),+ controller: _scroll,+ padding: padding,+ scrollCacheExtent: const ScrollCacheExtent.pixels(120),+ itemCount: agents.length + 1,+ itemBuilder: (context, index) => index == 0+ ? Padding(+ padding: EdgeInsets.only(+ bottom: widget.terminal ? cell.height : 24,+ ),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ row.title,+ // The list leads the eye; this confirms it.+ style: widget.terminal+ ? terminalContentStyle(+ color: theme.foreground,+ )+ : AppType.monoLabel(+ fontWeight: FontWeight.w600,+ ),),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- row.title,- // The list leads the eye; this confirms it.- style: widget.terminal- ? terminalContentStyle(- color: theme.foreground,- )- : AppType.monoLabel(- fontWeight: FontWeight.w600,- ),+ if (!widget.terminal) const SizedBox(height: 6),+ Text(+ row.detail,+ style: widget.terminal+ ? terminalContentStyle(+ color: theme.foreground.withValues(+ alpha: .54,+ ),+ )+ : _muted,+ ),+ // Nothing exists yet behind the create row, so+ // there is no session to be missing text from.+ if (agents.isEmpty && !row.isCreate)+ Padding(+ padding: EdgeInsets.only(+ top: widget.terminal ? cell.height : 24,),- if (!widget.terminal) const SizedBox(height: 6),- Text(- row.detail,+ child: Text(+ 'No recent session text available.',style: widget.terminal? terminalContentStyle(color: theme.foreground.withValues(@@ -380,53 +393,45 @@ class _SwarmSearchPreviewState extends State<SwarmSearchPreview> {): _muted,),- // Nothing exists yet behind the create row, so- // there is no session to be missing text from.- if (agents.isEmpty && !row.isCreate)- Padding(- padding: EdgeInsets.only(- top: widget.terminal ? cell.height : 24,- ),- child: Text(- 'No recent session text available.',- style: widget.terminal- ? terminalContentStyle(- color: theme.foreground- .withValues(alpha: .54),- )- : _muted,- ),- ),- ],- ),- )- : Padding(- padding: EdgeInsets.only(- top: index > 1- ? widget.terminal- ? cell.height- : 20- : 0,- ),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- _AgentPreview(- app: app,- item: agents[index - 1],- compact: true,- terminal: widget.terminal,- ),- if (index < agents.length)- SizedBox(- height: widget.terminal ? cell.height : 20,- ),- ],+ ),+ ],+ ),+ )+ : Padding(+ padding: EdgeInsets.only(+ top: index > 1+ ? widget.terminal+ ? cell.height+ : 20+ : 0,+ ),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ _AgentPreview(+ app: app,+ item: agents[index - 1],+ compact: true,+ terminal: widget.terminal,),- ),- )- : _single(row, agents.single, padding, cell, theme),- ),+ if (index < agents.length)+ SizedBox(+ height: widget.terminal ? cell.height : 20,+ ),+ ],+ ),+ ),+ )+ : _single(row, agents.single, padding, cell, theme);+ return Semantics(+ container: true,+ label: 'Agent preview',+ // A session's latest turns carry their list's own scrollbar, on the+ // turns alone: one around the whole preview, header included, drew+ // a second thumb beside it.+ child: _scroll.reversed+ ? content+ : Scrollbar(controller: _scroll, child: content),);},);diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dartindex 2b13a785c..1c1489b40 100644--- a/desktop/lib/widgets/swarm_switcher.dart+++ b/desktop/lib/widgets/swarm_switcher.dart@@ -740,9 +740,14 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {final canSubmit = search.canSubmit(row);final unavailableReason = search.sessionUnavailable(row);final alreadyHere = search.alreadyHere(row);- final activityAge = widget.bios && row.lastActivityAt != null- ? harnessActivityAge(row.lastActivityAt, DateTime.now())- : null;+ // As of this opening, like the order: the list does not move while+ // it is open. Under a minute is "now", not "0m".+ final activity = widget.bios ? search.activityOf(row) : null;+ final activityAge = activity == null+ ? null+ : search.openedAt.difference(activity).inMinutes < 1+ ? 'now'+ : harnessActivityAge(activity, search.openedAt);final presentation = (row,selected,diff --git a/desktop/test/bios_navigation_test.dart b/desktop/test/bios_navigation_test.dartindex 4904de489..7102c0903 100644--- a/desktop/test/bios_navigation_test.dart+++ b/desktop/test/bios_navigation_test.dart@@ -7,108 +7,136 @@ import 'package:harness/state/harness_placement.dart';import 'swarm_state_test.dart' show createApp;void main() {- testWidgets('Open Harness sorts by activity while filtering and refreshing', (- tester,- ) async {- final app = createApp();- addTearDown(app.dispose);- app.machineStates['m']!.agents = [- for (final (id, hour) in [- ('a1', 10),- ('a10', 12),- ('a11', 11),- ('a12', null),- ])- Agent(- id: id,- sessionId: 'session-$id',- name: 'Agent ${id.substring(1)}',- engine: 'codex',- terminalAvailable: true,- lastActivityAt: hour == null ? null : DateTime.utc(2026, 9, 23, hour),- ),- ];- final recent = [- agentDestinationId('m', 'a1'),- agentDestinationId('m', 'a12'),- agentDestinationId('m', 'a10'),- ];- final search = SwarmSearchController(- app,- recent,- adding: true,- offersCreate: true,- activityFirst: true,- placement: HarnessPlacement.newTab,- );- addTearDown(search.dispose);- expect(search.setupLayout, isTrue);- expect(search.rows.first.isCreate, isTrue);- expect(search.rows.skip(1).map((row) => row.agentId), [- 'a10',- 'a11',- 'a1',- 'a12',- ]);- search.setQuery('Agent 1');- // The harness named exactly that leads; the rest keep activity order.- expect(- search.rows.where((row) => !row.isCreate).map((row) => row.agentId),- ['a1', 'a10', 'a11', 'a12'],- );+ testWidgets(+ 'Open Harness sorts by activity as it opened, and keeps that order while open',+ (tester) async {+ final app = createApp();+ addTearDown(app.dispose);+ app.machineStates['m']!.agents = [+ for (final (id, hour) in [+ ('a1', 10),+ ('a10', 12),+ ('a11', 11),+ ('a12', null),+ ])+ Agent(+ id: id,+ sessionId: 'session-$id',+ name: 'Agent ${id.substring(1)}',+ engine: 'codex',+ terminalAvailable: true,+ lastActivityAt: hour == null+ ? null+ : DateTime.utc(2026, 9, 23, hour),+ ),+ ];+ final recent = [+ agentDestinationId('m', 'a1'),+ agentDestinationId('m', 'a12'),+ agentDestinationId('m', 'a10'),+ ];+ final search = SwarmSearchController(+ app,+ recent,+ adding: true,+ offersCreate: true,+ activityFirst: true,+ placement: HarnessPlacement.newTab,+ );+ addTearDown(search.dispose);+ expect(search.setupLayout, isTrue);+ expect(search.rows.first.isCreate, isTrue);+ expect(search.rows.skip(1).map((row) => row.agentId), [+ 'a10',+ 'a11',+ 'a1',+ 'a12',+ ]);+ search.setQuery('Agent 1');+ // The harness named exactly that leads; the rest keep activity order.+ expect(+ search.rows.where((row) => !row.isCreate).map((row) => row.agentId),+ ['a1', 'a10', 'a11', 'a12'],+ );- final ordinary = SwarmSearchController(app, recent, adding: true);- addTearDown(ordinary.dispose);- ordinary.setQuery('Agent 1');- expect(ordinary.setupLayout, isFalse);- expect(ordinary.rows.first.agentId, 'a1');+ final ordinary = SwarmSearchController(app, recent, adding: true);+ addTearDown(ordinary.dispose);+ ordinary.setQuery('Agent 1');+ expect(ordinary.setupLayout, isFalse);+ expect(ordinary.rows.first.agentId, 'a1');- final selected = search.selected!.id;- await app.handleEventForTest('m', {- 'type': 'agent_synced',- 'payload': {- 'agent': {- 'id': 'a1',- 'sessionId': 'session-a1',- 'name': 'Agent 1',- 'engine': 'codex',- 'terminal': {'available': true},- 'updatedAt': '2026-09-23T12:00:30Z',- },- },- });- expect(search.rows.first.isCreate, isTrue);- expect(search.rows.skip(1).map((row) => row.agentId), [- 'a1',- 'a10',- 'a11',- 'a12',- ]);- expect(search.selected!.id, selected);-- search.setQuery('retry-safe');- expect(search.rows.every((row) => row.isCreate), isTrue);- Future<void> response(String id) async {+ final selected = search.selected!.id;await app.handleEventForTest('m', {- 'type': 'text_delta',+ 'type': 'agent_synced','payload': {- 'agentId': id,- 'sessionId': 'session-$id',- 'content': 'The operation is now retry-safe.',+ 'agent': {+ 'id': 'a1',+ 'sessionId': 'session-a1',+ 'name': 'Agent 1',+ 'engine': 'codex',+ 'terminal': {'available': true},+ 'updatedAt': '2026-09-23T12:00:30Z',+ },},});- await tester.pump(const Duration(milliseconds: 80));- }+ // Agent 1 just worked, but the open list does not move under the cursor.+ expect(search.rows.first.isCreate, isTrue);+ expect(search.rows.skip(1).map((row) => row.agentId), [+ 'a1',+ 'a10',+ 'a11',+ 'a12',+ ]);+ expect(search.selected!.id, selected);+ search.setQuery('');+ expect(search.rows.skip(1).map((row) => row.agentId), [+ 'a10',+ 'a11',+ 'a1',+ 'a12',+ ]);+ // The next opening reads activity afresh.+ final reopened = SwarmSearchController(+ app,+ recent,+ adding: true,+ offersCreate: true,+ activityFirst: true,+ placement: HarnessPlacement.newTab,+ );+ addTearDown(reopened.dispose);+ expect(reopened.rows.skip(1).map((row) => row.agentId), [+ 'a1',+ 'a10',+ 'a11',+ 'a12',+ ]);++ search.setQuery('retry-safe');+ expect(search.rows.every((row) => row.isCreate), isTrue);+ Future<void> response(String id) async {+ await app.handleEventForTest('m', {+ 'type': 'text_delta',+ 'payload': {+ 'agentId': id,+ 'sessionId': 'session-$id',+ 'content': 'The operation is now retry-safe.',+ },+ });+ await tester.pump(const Duration(milliseconds: 80));+ }- await response('a11');- search.move(1);- expect(search.selected!.agentId, 'a11');- await response('a1');- expect(search.rows.skip(1).map((row) => row.agentId), ['a1', 'a11']);- expect(search.selected!.agentId, 'a11');- search.setQuery('>');- expect(search.setupLayout, isTrue);- });+ await response('a11');+ search.move(1);+ expect(search.selected!.agentId, 'a11');+ await response('a1');+ // Found now too, in the order this opening listed them.+ expect(search.rows.skip(1).map((row) => row.agentId), ['a11', 'a1']);+ expect(search.selected!.agentId, 'a11');+ search.setQuery('>');+ expect(search.setupLayout, isTrue);+ },+ );test('activity ordering spans tabs with deterministic ties and missing times',diff --git a/desktop/test/session_search_rendering_test.dart b/desktop/test/session_search_rendering_test.dartindex 453b4b255..e0cdac1cb 100644--- a/desktop/test/session_search_rendering_test.dart+++ b/desktop/test/session_search_rendering_test.dart@@ -98,6 +98,7 @@ void main() {testWidgets('a session previews its latest turns from the bottom up, and pages up for older ones',+ variant: TargetPlatformVariant.only(TargetPlatform.macOS),(tester) async {final tails = <int?>[];Map<String, dynamic> row(int turn) => {@@ -158,6 +159,9 @@ void main() {name: 'Agent 7',engine: 'codex',terminalAvailable: true,+ lastActivityAt: DateTime.now().subtract(+ const Duration(seconds: 20),+ ),): agent,];@@ -199,6 +203,9 @@ void main() {await tester.pump(const Duration(seconds: 10));expect(tails, [null], reason: 'nothing refreshes while Cmd-P is open');expect(find.text('Working'), findsOneWidget);+ // Under a minute old reads "now", not "0m".+ expect(find.text('now'), findsOneWidget);+ expect(find.text('0m'), findsNothing);final list = find.byKey(const ValueKey('session-tail:m:s7'));expect(list, findsOneWidget);@@ -241,6 +248,20 @@ void main() {});expect(bold, ['retention']);+ // One scrollbar, on the turns alone: macOS gives every list its own,+ // and none may wrap the whole preview besides.+ expect(+ find.descendant(+ of: find.ancestor(of: list, matching: find.byType(Semantics)).first,+ matching: find.byType(Scrollbar),+ ),+ findsOneWidget,+ );+ expect(+ find.ancestor(of: list, matching: find.byType(Scrollbar)),+ findsNothing,+ );+// The latest ask is in view, so nothing is pinned above the turns.expect(find.byKey(const ValueKey('preview-last-ask')), findsNothing);