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(desktop): navigate waiting agents from the keyboard
dee6be933b0dc9c
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex 7b39ec0d5..fef32d685 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -11,18 +11,18 @@ import '../core/test_run.dart';import '../settings/settings_screen.dart';import '../settings/settings_section.dart';import '../shared/theme/app_theme.dart' as grid;-import '../shared/widgets/app_dialog.dart';import '../shortcuts/app_shortcuts.dart';import '../state/app_state.dart';import '../state/swarm_catalog.dart';+import '../state/swarm_attention.dart';import '../state/swarm_navigation.dart';-import '../widgets/engine_identity.dart';import '../widgets/layout_palette.dart';import '../widgets/link_machine_screen.dart';import '../widgets/new_agent_dialog.dart';import '../widgets/pane_grid.dart';import '../widgets/shortcuts_sheet.dart';import '../widgets/swarm_dialogs.dart';+import '../widgets/swarm_attention.dart';import '../widgets/swarm_switcher.dart';import '../widgets/swarm_wallpaper.dart';import '../widgets/swarm_welcome.dart';@@ -307,99 +307,16 @@ class _SwarmScreenState extends State<SwarmScreen> {}}- Future<void> _goToAgent(String machineId, String agentId) async {- if (app.revealAgentView(machineId, agentId)) return;- await app.addAgentToSwarm(machineId, agentId);+ Future<void> _notifications() async {+ final target = app.activeSwarmId;+ SwarmAttentionEntry? selected;+ await _dialog(() async {+ selected = await showSwarmAttention(context, app, _navigation);+ });+ if (!mounted || selected == null) return;+ await activateSwarmAttention(app, selected!, destinationSwarmId: target);}- Future<void> _notifications() => _dialog(() async {- final selected = await showAppDialog<({String machineId, String agentId})>(- context: context,- builder: (context) => Dialog(- child: SizedBox(- width: 520,- height: 400,- child: Padding(- padding: const EdgeInsets.all(22),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Row(- children: [- const Text('Notifications', style: TextStyle(fontSize: 20)),- const Spacer(),- IconButton(- tooltip: 'Close notifications',- onPressed: () => Navigator.pop(context),- icon: const Icon(Icons.close, size: 18),- ),- ],- ),- const SizedBox(height: 14),- Expanded(- child: ListenableBuilder(- listenable: app,- builder: (context, _) {- final questions =- app.machineStates.values- .expand((m) => m.blockedAgents.values)- .toList()- ..sort((a, b) => a.since.compareTo(b.since));- if (questions.isEmpty) {- return const Center(- child: Text(- 'No agents need your input',- style: TextStyle(color: Colors.white60),- ),- );- }- return ListView(- children: [- for (final q in questions)- ListTile(- leading: EngineMark(- engine: app- .stateOf(q.machineId)- ?.agents- .where((a) => a.id == q.agentId)- .firstOrNull- ?.engine,- size: 22,- ),- title: Text(- q.prompt,- maxLines: 3,- overflow: TextOverflow.ellipsis,- style: const TextStyle(fontSize: 13),- ),- subtitle: Text(- '${app.stateOf(q.machineId)?.agents.where((a) => a.id == q.agentId).firstOrNull?.name ?? q.agentId} · ${app.stateOf(q.machineId)?.machine.displayName ?? q.machineId}',- style: const TextStyle(- fontSize: 11,- color: Colors.white54,- ),- ),- onTap: () => Navigator.pop(context, (- machineId: q.machineId,- agentId: q.agentId,- )),- ),- ],- );- },- ),- ),- ],- ),- ),- ),- ),- );- if (selected != null) {- await _goToAgent(selected.machineId, selected.agentId);- }- });-Future<void> _openSpokenTask(SpokenTaskRequest request) async {final spoken = SpokenTask(voiceId: request.voiceId,@@ -493,6 +410,7 @@ class _SwarmScreenState extends State<SwarmScreen> {ShortcutAction.lastPane: app.focusLastPane,ShortcutAction.zoomPane: app.toggleZoomPane,ShortcutAction.switchAgent: _jump,+ ShortcutAction.showAttention: _notifications,ShortcutAction.addAgent: _addAgent,ShortcutAction.closePane: () {if (app.focusedPaneId != null) {@@ -720,9 +638,10 @@ class _SwarmScreenState extends State<SwarmScreen> {),const Spacer(),IconButton(- tooltip: _attention == 0- ? 'Notifications'- : '$_attention agents need input',+ tooltip: withShortcutHint(+ _attention == 0 ? 'Needs input' : '$_attention agents need input',+ ShortcutAction.showAttention,+ ),onPressed: _notifications,icon: Badge(isLabelVisible: _attention > 0,diff --git a/desktop/lib/shortcuts/app_shortcuts.dart b/desktop/lib/shortcuts/app_shortcuts.dartindex 8b1c503c9..685a435a4 100644--- a/desktop/lib/shortcuts/app_shortcuts.dart+++ b/desktop/lib/shortcuts/app_shortcuts.dart@@ -73,6 +73,9 @@ enum ShortcutAction {/// Jump to any agent by name, on any machine.switchAgent,+ /// Find a live question and jump to the agent waiting for input.+ showAttention,+/// Add a view to the current Swarm, independently of navigation.addAgent,@@ -521,6 +524,16 @@ const kSwarmShortcuts = [label: 'Jump to an agent or swarm',group: ShortcutGroup.navigate,),+ AppShortcut(+ action: ShortcutAction.showAttention,+ activator: SingleActivator(+ LogicalKeyboardKey.keyI,+ meta: true,+ shift: true,+ ),+ label: 'Show agents needing input',+ group: ShortcutGroup.navigate,+ ),AppShortcut(action: ShortcutAction.addAgent,activator: SingleActivator(diff --git a/desktop/lib/state/pending_question.dart b/desktop/lib/state/pending_question.dartindex 2cb82243d..9daa627d0 100644--- a/desktop/lib/state/pending_question.dart+++ b/desktop/lib/state/pending_question.dart@@ -13,7 +13,7 @@/// dial cabled to this computer, and every one of those arrives back here down/// the same path — so the ring cannot outlive a dialog somebody else closed.///-/// The tile's amber ring is the only thing that reads this.+/// The tile's amber ring and Needs input picker read this same live state.class PendingQuestion {PendingQuestion({required this.machineId,@@ -42,8 +42,8 @@ class PendingQuestion {final String prompt;final List<String> options;- /// Whether the dialog takes more than one option. Parsed because the frame- /// carries it; nothing acts on it while the ring is the only surface.+ /// Whether the terminal dialog takes more than one option. Navigation does+ /// not answer it; the original terminal still owns that interaction.final bool multi;/// When this window first heard about it. Not when the agent actuallydiff --git a/desktop/lib/state/swarm_attention.dart b/desktop/lib/state/swarm_attention.dartnew file mode 100644index 000000000..cf8406d2c--- /dev/null+++ b/desktop/lib/state/swarm_attention.dart@@ -0,0 +1,121 @@+import 'app_state.dart';+import 'pending_question.dart';+import 'swarm_navigation.dart';++/// A real pending question and the view it would open at selection time.+/// Missing roster entries remain visible, but cannot create an unknown view.+class SwarmAttentionEntry {+ const SwarmAttentionEntry({+ required this.question,+ required this.destination,+ required this.available,+ });++ final PendingQuestion question;+ final SwarmDestination destination;+ final bool available;+ String get id => destination.id;+}++List<SwarmAttentionEntry> swarmAttentionEntries(+ AppNotifier app, {+ List<String> recent = const [],+}) {+ final questions = app.machineStates.values+ .expand((machine) => machine.blockedAgents.values)+ .toList();+ if (questions.isEmpty) return const [];+ final destinations = {+ for (final row in swarmDestinations(app, recent: recent)) row.id: row,+ };+ questions.sort((a, b) {+ final age = a.since.compareTo(b.since);+ return age != 0+ ? age+ : agentDestinationId(+ a.machineId,+ a.agentId,+ ).compareTo(agentDestinationId(b.machineId, b.agentId));+ });+ return [+ for (final question in questions) _entry(app, question, destinations),+ ];+}++SwarmAttentionEntry _entry(+ AppNotifier app,+ PendingQuestion question,+ Map<String, SwarmDestination> destinations,+) {+ final id = agentDestinationId(question.machineId, question.agentId);+ final view = destinations[id];+ final machine = app.stateOf(question.machineId);+ final agent = view == null+ ? machine?.agents.where((a) => a.id == question.agentId).firstOrNull+ : null;+ final project = agent == null ? null : machine?.projectOf(agent);+ return SwarmAttentionEntry(+ question: question,+ available: view != null,+ destination: SwarmDestination(+ id: id,+ title: view?.title ?? agent?.name ?? question.agentId,+ detail:+ view?.detail ??+ [+ machine?.machine.displayName ?? question.machineId,+ project?.name,+ project?.branch,+ ].whereType<String>().where((s) => s.isNotEmpty).join(' · '),+ swarmId: view?.swarmId,+ current: view?.current ?? false,+ machineId: question.machineId,+ agentId: question.agentId,+ engine: view?.engine ?? agent?.engine,+ searchFields: [+ ...?view?.fields.skip(1),+ if (view == null) machine?.machine.displayName ?? question.machineId,+ project?.name,+ project?.branch,+ project?.cwd,+ question.prompt,+ ],+ ),+ );+}++List<SwarmAttentionEntry> filterSwarmAttention(+ List<SwarmAttentionEntry> entries,+ String query,+) {+ // An empty search retains the time we first heard each question. No timers,+ // polling, or changing "age" labels are needed while someone chooses.+ if (query.trim().isEmpty) return entries;+ final byId = {for (final entry in entries) entry.id: entry};+ return [+ for (final destination in rankSwarmDestinations(+ entries.map((entry) => entry.destination).toList(),+ query,+ ))+ byId[destination.id]!,+ ];+}++Future<bool> activateSwarmAttention(+ AppNotifier app,+ SwarmAttentionEntry entry, {+ required String destinationSwarmId,+}) async {+ final question = entry.question;+ final current = app.questionFor(question.machineId, question.agentId);+ // A question answered elsewhere, or replaced during dismissal, must not+ // redirect focus or create a now-unneeded membership.+ if (!entry.available || current == null || !question.sameAs(current)) {+ return false;+ }+ return activateSwarmDestination(+ app,+ entry.destination,+ destinationSwarmId: destinationSwarmId,+ );+}diff --git a/desktop/lib/widgets/swarm_attention.dart b/desktop/lib/widgets/swarm_attention.dartnew file mode 100644index 000000000..f1291938b--- /dev/null+++ b/desktop/lib/widgets/swarm_attention.dart@@ -0,0 +1,273 @@+import 'package:flutter/material.dart';++import '../shared/widgets/app_dialog.dart';+import '../state/app_state.dart';+import '../state/swarm_attention.dart';+import '../state/swarm_navigation.dart';+import 'engine_identity.dart';+import 'swarm_welcome.dart';++Future<SwarmAttentionEntry?> showSwarmAttention(+ BuildContext context,+ AppNotifier app,+ SwarmNavigationHistory history,+) => showAppDialog<SwarmAttentionEntry>(+ context: context,+ transitionDuration: Duration.zero,+ veilBlur: 0,+ veilTint: const Color(0x66000000),+ builder: (_) => _SwarmAttention(app: app, recent: history.recent),+);++class _SwarmAttention extends StatefulWidget {+ const _SwarmAttention({required this.app, required this.recent});+ final AppNotifier app;+ final List<String> recent;++ @override+ State<_SwarmAttention> createState() => _SwarmAttentionState();+}++class _SwarmAttentionState extends State<_SwarmAttention> {+ final _scroll = ScrollController();+ late List<SwarmAttentionEntry> _catalog;+ List<SwarmAttentionEntry> _rows = [];+ String _query = '';+ String? _selectedId;+ int _cursor = 0;+ double _rowHeight = 104;+ bool _revealScheduled = false;+ late final _targetName = widget.app.activeSwarm.name;++ @override+ void initState() {+ super.initState();+ _refreshCatalog();+ widget.app.addListener(_onAppChanged);+ }++ void _onAppChanged() => setState(_refreshCatalog);++ void _refreshCatalog() {+ _catalog = swarmAttentionEntries(widget.app, recent: widget.recent);+ _filter();+ }++ void _filter() {+ _rows = filterSwarmAttention(_catalog, _query);+ final index = _rows.indexWhere((row) => row.id == _selectedId);+ _cursor = _rows.isEmpty+ ? 0+ : index >= 0+ ? index+ : _cursor.clamp(0, _rows.length - 1);+ _selectedId = _rows.isEmpty ? null : _rows[_cursor].id;+ _revealSelection();+ }++ void _move(int delta) {+ if (_rows.isEmpty) return;+ setState(() {+ _cursor = (_cursor + delta) % _rows.length;+ _selectedId = _rows[_cursor].id;+ });+ // The list dimensions are already known during a key event. Move before+ // paint so the new highlight and its row arrive in the same frame.+ _scrollToSelection();+ }++ void _revealSelection() {+ if (_revealScheduled) return;+ _revealScheduled = true;+ WidgetsBinding.instance.addPostFrameCallback((_) {+ _revealScheduled = false;+ if (mounted) _scrollToSelection();+ });+ }++ void _scrollToSelection() {+ if (!_scroll.hasClients || _rows.isEmpty) return;+ final top = _cursor * _rowHeight;+ final bottom = top + _rowHeight;+ final position = _scroll.position;+ final offset = top < position.pixels+ ? top+ : bottom > position.pixels + position.viewportDimension+ ? bottom - position.viewportDimension+ : position.pixels;+ final target = offset.clamp(0.0, position.maxScrollExtent);+ if (target != position.pixels) _scroll.jumpTo(target);+ }++ void _submit() {+ if (_rows.isNotEmpty && _rows[_cursor].available) {+ Navigator.pop(context, _rows[_cursor]);+ }+ }++ @override+ void dispose() {+ widget.app.removeListener(_onAppChanged);+ _scroll.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final scale = MediaQuery.textScalerOf(context);+ _rowHeight = (scale.scale(13) * 1.35 * 3 + scale.scale(11) * 1.3 + 36)+ .clamp(104, double.infinity);+ final selected = _rows.isEmpty ? null : _rows[_cursor];+ return Dialog(+ alignment: const Alignment(0, -0.5),+ insetPadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 48),+ child: SizedBox(+ width: 660,+ height: 560,+ child: Padding(+ padding: const EdgeInsets.all(16),+ child: Column(+ children: [+ Row(+ children: [+ const Text('Needs input', style: TextStyle(fontSize: 16)),+ const SizedBox(width: 8),+ Text(+ '${_catalog.length}',+ style: const TextStyle(fontSize: 13, color: Colors.white54),+ ),+ const Spacer(),+ IconButton(+ tooltip: 'Close notifications',+ onPressed: () => Navigator.pop(context),+ icon: const Icon(Icons.close, size: 18),+ ),+ ],+ ),+ const SizedBox(height: 8),+ SwarmSearchField(+ autofocus: true,+ hintText: 'Find a question, agent, or project…',+ onChanged: (value) => setState(() {+ _query = value;+ _cursor = 0;+ _selectedId = null;+ _filter();+ }),+ onMove: _move,+ onSubmitted: _submit,+ ),+ const SizedBox(height: 12),+ Expanded(+ child: _rows.isEmpty+ ? Center(+ child: Text(+ _catalog.isEmpty+ ? 'No agents need your input'+ : 'No matching questions',+ style: const TextStyle(+ fontSize: 13,+ color: Colors.white60,+ ),+ ),+ )+ : ListView.builder(+ controller: _scroll,+ itemCount: _rows.length,+ itemExtent: _rowHeight,+ itemBuilder: (context, index) {+ final row = _rows[index];+ final destination = row.destination;+ return ListTile(+ key: ValueKey(row.id),+ enabled: row.available,+ selected: index == _cursor,+ selectedColor: Colors.white,+ selectedTileColor: Colors.white10,+ shape: RoundedRectangleBorder(+ borderRadius: BorderRadius.circular(8),+ ),+ contentPadding: const EdgeInsets.symmetric(+ horizontal: 12,+ ),+ leading: EngineMark(+ engine: destination.engine,+ size: 20,+ ),+ title: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ destination.title,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: const TextStyle(+ fontSize: 13,+ height: 1.35,+ fontWeight: FontWeight.w500,+ ),+ ),+ const SizedBox(height: 2),+ Text(+ row.question.prompt,+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: const TextStyle(+ fontSize: 13,+ height: 1.35,+ color: Colors.white70,+ ),+ ),+ const SizedBox(height: 4),+ Text(+ destination.detail,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: const TextStyle(+ fontSize: 11,+ height: 1.3,+ color: Colors.white54,+ ),+ ),+ ],+ ),+ trailing: Text(+ !row.available+ ? 'Unavailable'+ : destination.hasView+ ? 'Jump'+ : 'Open view',+ style: const TextStyle(+ fontSize: 11,+ color: Colors.white54,+ ),+ ),+ onTap: row.available+ ? () => Navigator.pop(context, row)+ : null,+ );+ },+ ),+ ),+ const SizedBox(height: 12),+ Align(+ alignment: Alignment.centerLeft,+ child: Text(+ selected != null && !selected.available+ ? 'This agent’s terminal is unavailable · Esc to close'+ : selected != null && !selected.destination.hasView+ ? '↵ Open view in $_targetName · Esc to close'+ : '↑↓ or ⌃N ⌃P to choose · Return to jump · Esc to close',+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: const TextStyle(fontSize: 11, color: Colors.white54),+ ),+ ),+ ],+ ),+ ),+ ),+ );+ }+}diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dartindex a606dcdec..3efb02e61 100644--- a/desktop/lib/widgets/swarm_switcher.dart+++ b/desktop/lib/widgets/swarm_switcher.dart@@ -34,6 +34,7 @@ class _SwarmSwitcherState extends State<_SwarmSwitcher> {String? _selectedId;int _cursor = 0;double _rowHeight = 56;+ bool _revealScheduled = false;late final _targetName = widget.app.activeSwarm.name;@override@@ -68,25 +69,34 @@ class _SwarmSwitcherState extends State<_SwarmSwitcher> {_cursor = (_cursor + delta) % _rows.length;_selectedId = _rows[_cursor].id;});- _revealSelection();+ // The list dimensions are already known during a key event. Move before+ // paint so the new highlight and its row arrive in the same frame.+ _scrollToSelection();}void _revealSelection() {+ if (_revealScheduled) return;+ _revealScheduled = true;WidgetsBinding.instance.addPostFrameCallback((_) {- if (!mounted || !_scroll.hasClients || _rows.isEmpty) return;- final top = _cursor * _rowHeight;- final bottom = top + _rowHeight;- final position = _scroll.position;- final offset = top < position.pixels- ? top- : bottom > position.pixels + position.viewportDimension- ? bottom - position.viewportDimension- : position.pixels;- final target = offset.clamp(0.0, position.maxScrollExtent);- if (target != position.pixels) _scroll.jumpTo(target);+ _revealScheduled = false;+ if (mounted) _scrollToSelection();});}+ void _scrollToSelection() {+ if (!_scroll.hasClients || _rows.isEmpty) return;+ final top = _cursor * _rowHeight;+ final bottom = top + _rowHeight;+ final position = _scroll.position;+ final offset = top < position.pixels+ ? top+ : bottom > position.pixels + position.viewportDimension+ ? bottom - position.viewportDimension+ : position.pixels;+ final target = offset.clamp(0.0, position.maxScrollExtent);+ if (target != position.pixels) _scroll.jumpTo(target);+ }+void _submit() {if (_rows.isNotEmpty) Navigator.pop(context, _rows[_cursor]);}diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swiftindex 11779d577..e72eb3aba 100644--- a/desktop/macos/Runner/SwarmTitlebar.swift+++ b/desktop/macos/Runner/SwarmTitlebar.swift@@ -108,6 +108,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation {menu.addItem(.separator())add("Add Agent…", "f", "addAgent", [.command, .shift])add("Close Agent View", "w", "closePane", [.command, .shift])+ add("Agents Needing Input…", "i", "notifications", [.command, .shift])if !settingsInAppMenu { add("Settings…", ",", "settings") }let item = NSMenuItem(title: "Swarm", action: nil, keyEquivalent: "")item.submenu = menu@@ -160,7 +161,7 @@ private final class SwarmTabStrip: NSView {addSubview(button)}button(newButton, "plus", "New swarm (⌘T)", #selector(newSwarm))- button(notifications, "bell", "Notifications", #selector(showNotifications))+ button(notifications, "bell", "Needs input", #selector(showNotifications))button(settings, "gearshape", "Settings (⌘,)", #selector(showSettings))registerForDraggedTypes([swarmPasteboardType])}@@ -195,10 +196,11 @@ private final class SwarmTabStrip: NSView {notifications.isEnabled = actionsEnabledsettings.isEnabled = actionsEnabledlet count = state["attention"] as? Int ?? 0+ let attentionLabel = count > 0 ? "\(count) agents need input" : "Needs input"notifications.image = NSImage(systemSymbolName: count > 0 ? "bell.badge" : "bell",- accessibilityDescription: count > 0 ? "\(count) agents need input" : "Notifications")- notifications.toolTip = count > 0 ? "\(count) agents need input" : "Notifications"- notifications.setAccessibilityLabel(notifications.toolTip)+ accessibilityDescription: attentionLabel)+ notifications.toolTip = "\(attentionLabel) (⇧⌘I)"+ notifications.setAccessibilityLabel(attentionLabel)needsLayout = truelayoutSubtreeIfNeeded()if ids != previousOrder {diff --git a/desktop/test/shortcuts_test.dart b/desktop/test/shortcuts_test.dartindex 43a434406..08c323123 100644--- a/desktop/test/shortcuts_test.dart+++ b/desktop/test/shortcuts_test.dart@@ -294,6 +294,7 @@ void main() {expect(chordsFor(ShortcutAction.switchAgent), contains('⌘P'));expect(chordsFor(ShortcutAction.switchAgent), isNot(contains('⇧⌘F')));expect(chordsFor(ShortcutAction.addAgent), ['⇧⌘F']);+ expect(chordsFor(ShortcutAction.showAttention), ['⇧⌘I']);});test(diff --git a/desktop/test/swarm_attention_picker_test.dart b/desktop/test/swarm_attention_picker_test.dartnew file mode 100644index 000000000..52209b340--- /dev/null+++ b/desktop/test/swarm_attention_picker_test.dart@@ -0,0 +1,240 @@+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/state/swarm_navigation.dart';+import 'package:harness/widgets/swarm_attention.dart';+import 'package:harness/terminal/terminal_binary.dart';++import 'swarm_attention_test.dart' show waitingQuestion, announceQuestion;+import 'swarm_interactions_test.dart' show chord;+import 'swarm_screen_test.dart' show mount, terminal;+import 'swarm_state_test.dart' show createApp;+import 'swarm_switcher_test.dart' show selectedRow;++Finder get attentionField => find.byWidgetPredicate(+ (w) =>+ w is TextField &&+ w.decoration?.hintText == 'Find a question, agent, or project…',+);++void main() {+ testWidgets(+ 'large text keeps the question and keyboard selection inside a compact window',+ (tester) async {+ final app = createApp();+ for (var i = 0; i < 8; i++) {+ app.machineStates['m']!.blockedAgents['a$i'] = waitingQuestion(+ 'a$i',+ prompt: 'Should I use the existing project folder or create a separate working folder for this change?',+ ageOrder: i,+ );+ }+ tester.view.devicePixelRatio = 1;+ tester.view.physicalSize = const Size(880, 600);+ addTearDown(tester.view.resetPhysicalSize);+ addTearDown(tester.view.resetDevicePixelRatio);+ await tester.pumpWidget(+ MaterialApp(+ builder: (context, child) => MediaQuery(+ data: MediaQuery.of(context)+ .copyWith(textScaler: TextScaler.linear(2)),+ child: child!,+ ),+ home: Builder(+ builder: (context) => Scaffold(+ body: TextButton(+ onPressed: () =>+ showSwarmAttention(context, app, SwarmNavigationHistory()),+ child: const Text('Open'),+ ),+ ),+ ),+ ),+ );+ await tester.tap(find.text('Open'));+ await tester.pump();+ for (var i = 0; i < 5; i++) {+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);+ await tester.pump();+ final row = tester.getRect(selectedRow);+ final list = tester.getRect(find.byType(ListView));+ expect(row.top, greaterThanOrEqualTo(list.top));+ expect(row.bottom, lessThanOrEqualTo(list.bottom));+ expect(tester.takeException(), isNull);+ }+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ },+ );++ testWidgets(+ 'attention opens in one frame, owns typing, and returns to prior work through Cmd+P',+ (tester) async {+ final app = createApp();+ app.machineStates['m']!.nodeOnline = true;+ final firstInput = <TerminalBinaryFrame>[];+ final secondInput = <TerminalBinaryFrame>[];+ final firstPane = app.adoptSessionForTest(terminal('a0', firstInput));+ final first = app.activeSwarm;+ await mount(tester, app);+ app.newSwarm();+ final secondPane = app.adoptSessionForTest(terminal('a1', secondInput));+ final second = app.activeSwarm;+ await announceQuestion(app, 'a0', prompt: 'Choose the deployment region');+ await tester.pump();+ await tester.sendKeyDownEvent(LogicalKeyboardKey.meta);+ await tester.sendKeyDownEvent(LogicalKeyboardKey.shift);+ await tester.sendKeyEvent(LogicalKeyboardKey.keyI);+ await tester.sendKeyUpEvent(LogicalKeyboardKey.shift);+ await tester.sendKeyUpEvent(LogicalKeyboardKey.meta);+ await tester.pump();+ expect(attentionField, findsOneWidget);+ expect(+ tester.widget<TextField>(attentionField).focusNode!.hasFocus,+ isTrue,+ );+ expect(+ (ModalRoute.of(+ tester.element(attentionField),+ ) as TransitionRoute).transitionDuration,+ Duration.zero,+ );+ expect(find.byType(BackdropFilter), findsNothing);+ await chord(tester, LogicalKeyboardKey.keyI, shift: true);+ expect(find.byType(Dialog), findsOneWidget);+ await tester.enterText(attentionField, 'region host');+ await tester.pump();+ expect(find.text('Choose the deployment region'), findsOneWidget);+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);+ await tester.pump();+ expect(app.activeSwarmId, first.id);+ expect(app.focusedPaneId, firstPane.id);+ expect(firstInput, isEmpty);+ expect(secondInput, isEmpty);+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);+ await tester.pump(const Duration(milliseconds: 10));+ expect(firstInput.single.bytes, [27, 91, 68]);+ expect(secondInput, isEmpty);+ await chord(tester, LogicalKeyboardKey.keyP);+ expect(+ find.descendant(of: selectedRow, matching: find.text('Agent 1')),+ findsOneWidget,+ );+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);+ await tester.pump();+ expect(app.activeSwarmId, second.id);+ expect(app.focusedPaneId, secondPane.id);+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);+ await tester.pump(const Duration(milliseconds: 10));+ expect(secondInput.single.bytes, [27, 91, 67]);+ expect(firstInput, hasLength(1));+ expect(first.panes, [firstPane]);+ expect(second.panes, [secondPane]);+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ },+ );++ testWidgets(+ 'keyboard scroll retains selection through live questions and Escape preserves zoom',+ (tester) async {+ final app = createApp();+ app.adoptSessionForTest(terminal('a0', []));+ app.toggleZoomPane();+ final zoom = app.zoomedPaneId;+ final panes = [...app.panes];+ final machine = app.machineStates['m']!;+ for (var i = 0; i < 25; i++) {+ machine.blockedAgents['a$i'] = waitingQuestion(+ 'a$i',+ prompt: 'Question $i?',+ ageOrder: i,+ );+ }+ await mount(tester, app);+ await chord(tester, LogicalKeyboardKey.keyI, shift: true);+ expect(find.byType(ListTile).evaluate().length, lessThan(25));+ for (var i = 0; i < 12; i++) {+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);+ await tester.pump();+ expect(selectedRow, findsOneWidget);+ final row = tester.getRect(selectedRow);+ final list = tester.getRect(find.byType(ListView));+ expect(row.top, greaterThanOrEqualTo(list.top));+ expect(row.bottom, lessThanOrEqualTo(list.bottom));+ }+ await tester.pump();+ final selection = tester.widget<ListTile>(selectedRow).key;+ expect(selection, ValueKey(agentDestinationId('m', 'a12')));+ final list = tester.getRect(find.byType(ListView));+ final row = tester.getRect(selectedRow);+ expect(row.top, greaterThanOrEqualTo(list.top));+ expect(row.bottom, lessThanOrEqualTo(list.bottom));+ machine.blockedAgents['a30'] = waitingQuestion('a30', ageOrder: -1);+ app.dismissError();+ await tester.pump();+ await tester.pump();+ expect(tester.widget<ListTile>(selectedRow).key, selection);+ await tester.sendKeyDownEvent(LogicalKeyboardKey.control);+ await tester.sendKeyEvent(LogicalKeyboardKey.keyN);+ await tester.sendKeyUpEvent(LogicalKeyboardKey.control);+ await tester.pump();+ expect(+ tester.widget<ListTile>(selectedRow).key,+ ValueKey(agentDestinationId('m', 'a13')),+ );+ await tester.sendKeyDownEvent(LogicalKeyboardKey.control);+ await tester.sendKeyEvent(LogicalKeyboardKey.keyP);+ await tester.sendKeyUpEvent(LogicalKeyboardKey.control);+ await tester.pump();+ expect(tester.widget<ListTile>(selectedRow).key, selection);+ machine.blockedAgents.remove('a12');+ app.dismissError();+ await tester.pump();+ expect(find.text('Question 12?'), findsNothing);+ expect(+ tester.widget<ListTile>(selectedRow).key,+ ValueKey(agentDestinationId('m', 'a13')),+ );+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pump();+ expect(attentionField, findsNothing);+ expect(app.panes, panes);+ expect(app.zoomedPaneId, zoom);+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ },+ );++ testWidgets(+ 'unavailable, filtered empty, and live empty states never submit a hidden destination',+ (tester) async {+ final app = createApp();+ final machine = app.machineStates['m']!;+ machine.blockedAgents['missing'] = waitingQuestion('missing');+ await mount(tester, app);+ await chord(tester, LogicalKeyboardKey.keyI, shift: true);+ expect(find.text('Unavailable'), findsOneWidget);+ expect(tester.widget<ListTile>(selectedRow).enabled, isFalse);+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);+ await tester.pump();+ expect(attentionField, findsOneWidget);+ expect(app.panes, isEmpty);+ await tester.enterText(attentionField, 'not found');+ await tester.pump();+ expect(find.text('No matching questions'), findsOneWidget);+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);+ await tester.pump();+ expect(attentionField, findsOneWidget);+ machine.blockedAgents.clear();+ app.dismissError();+ await tester.pump();+ expect(find.text('No agents need your input'), findsOneWidget);+ await tester.tap(find.byTooltip('Close notifications'));+ await tester.pump();+ expect(app.panes, isEmpty);+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ },+ );+}diff --git a/desktop/test/swarm_attention_test.dart b/desktop/test/swarm_attention_test.dartnew file mode 100644index 000000000..d883ebbf5--- /dev/null+++ b/desktop/test/swarm_attention_test.dart@@ -0,0 +1,246 @@+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/core/models.dart';+import 'package:harness/state/app_state.dart';+import 'package:harness/state/pending_question.dart';+import 'package:harness/state/swarm_attention.dart';+import 'package:harness/terminal/terminal_session.dart';++import 'swarm_screen_test.dart' show terminal;+import 'swarm_state_test.dart' show createApp;++PendingQuestion waitingQuestion(+ String agentId, {+ String machineId = 'm',+ String requestId = 'question',+ String prompt = 'Which folder?',+ int ageOrder = 0,+}) => PendingQuestion(+ machineId: machineId,+ agentId: agentId,+ requestId: requestId,+ answerKey: prompt,+ prompt: prompt,+ options: const ['A', 'B'],+ multi: false,+ since: DateTime.utc(2026, 9, 13).add(Duration(seconds: ageOrder)),+);++Future<void> announceQuestion(+ AppNotifier app,+ String agentId, {+ String requestId = 'question',+ String prompt = 'Which folder?',+}) => app.handleEventForTest('m', {+ 'type': 'commander_question',+ 'payload': {+ 'agentId': agentId,+ 'requestId': requestId,+ 'questions': [+ {+ 'q': prompt,+ 'options': ['A', 'B'],+ },+ ],+ },+});++void main() {+ test('questions stay oldest first and search prompt plus machine/project context', () {+ final app = createApp();+ addTearDown(app.dispose);+ final machine = app.machineStates['m']!;+ machine.agents = [+ const Agent(+ id: 'auth',+ name: 'Login',+ engine: 'codex',+ terminalAvailable: true,+ project: AgentProject(+ name: 'Payments',+ cwd: '/work/billing',+ branch: 'fix-login',+ ),+ ),+ const Agent(id: 'docs', name: 'Docs', terminalAvailable: true),+ ];+ machine.blockedAgents['auth'] = waitingQuestion(+ 'auth',+ prompt: 'Choose the staging region',+ ageOrder: 1,+ );+ machine.blockedAgents['docs'] = waitingQuestion(+ 'docs',+ prompt: 'Publish documentation?',+ );+ final entries = swarmAttentionEntries(app);+ expect(filterSwarmAttention(entries, ' ').map((e) => e.question.agentId), [+ 'docs',+ 'auth',+ ]);+ for (final query in [+ 'staging payments',+ 'host region',+ 'billing login',+ 'stg rgn',+ ]) {+ expect(+ filterSwarmAttention(entries, query).single.question.agentId,+ 'auth',+ reason: query,+ );+ }+ expect(filterSwarmAttention(entries, 'absent'), isEmpty);+ });++ test(+ 'missing and unavailable terminals remain visible and cannot add a view',+ () async {+ final app = createApp();+ addTearDown(app.dispose);+ final machine = app.machineStates['m']!;+ machine.agents = [+ const Agent(+ id: 'closed',+ name: 'Closed agent',+ terminalAvailable: false,+ ),+ ];+ machine.blockedAgents['missing'] = waitingQuestion('missing');+ machine.blockedAgents['closed'] = waitingQuestion('closed');+ final entries = swarmAttentionEntries(app);+ expect(entries, hasLength(2));+ expect(entries.map((e) => e.destination.title), [+ 'Closed agent',+ 'missing',+ ]);+ for (final entry in entries) {+ expect(entry.available, isFalse);+ expect(+ await activateSwarmAttention(+ app,+ entry,+ destinationSwarmId: app.activeSwarmId,+ ),+ isFalse,+ );+ }+ expect(app.panes, isEmpty);+ // A retained view is still useful even when discovery no longer lists it.+ final retained = app.adoptSessionForTest(terminal('missing', []));+ final row = swarmAttentionEntries(app)+ .firstWhere((e) => e.question.agentId == 'missing');+ expect(row.available, isTrue);+ expect(row.destination.hasView, isTrue);+ expect(row.destination.title, retained.session!.agentName);+ },+ );++ test('resolved and replaced question snapshots cannot change focus or membership', () async {+ final app = createApp();+ addTearDown(app.dispose);+ await announceQuestion(app, 'a0');+ final row = swarmAttentionEntries(app).single;+ await app.handleEventForTest('m', {+ 'type': 'commander_question_close',+ 'payload': {'agentId': 'a0', 'requestId': 'question'},+ });+ expect(+ await activateSwarmAttention(+ app,+ row,+ destinationSwarmId: app.activeSwarmId,+ ),+ isFalse,+ );+ await announceQuestion(+ app,+ 'a0',+ requestId: 'replacement',+ prompt: 'Choose a region instead',+ );+ expect(+ await activateSwarmAttention(+ app,+ row,+ destinationSwarmId: app.activeSwarmId,+ ),+ isFalse,+ );+ expect(app.panes, isEmpty);+ expect(app.focusedPaneId, isNull);+ });++ test('shared retained view uses current owner without retrying a taken-over terminal', () async {+ final app = createApp();+ addTearDown(app.dispose);+ final sent = <String>[];+ final session = TerminalSession(+ machineId: 'm',+ agentId: 'a0',+ agentName: 'Retained',+ engineId: 'codex',+ send: (type, _) async {+ sent.add(type);+ return true;+ },+ sendBinary: (_) async => true,+ )..status = TerminalSessionStatus.controlling;+ final pane = app.adoptSessionForTest(session);+ final first = app.activeSwarm;+ app.newSwarm();+ await app.addAgentToSwarm('m', 'a0');+ final second = app.activeSwarm;+ final other = app.adoptSessionForTest(terminal('a1', []));+ app.togglePinPane(pane.id);+ app.toggleZoomPane();+ session.status = TerminalSessionStatus.takenOver;+ final pins = Map.of(second.pinnedSlots);+ await announceQuestion(app, 'a0');+ final row = swarmAttentionEntries(app).single;+ expect(row.destination.swarmId, second.id);+ sent.clear();+ expect(+ await activateSwarmAttention(app, row, destinationSwarmId: second.id),+ isTrue,+ );+ expect(app.activeSwarmId, second.id);+ expect(app.focusedPaneId, pane.id);+ expect(second.zoomedPaneId, pane.id);+ expect(second.panes, [pane, other]);+ expect(first.panes, [pane]);+ expect(second.pinnedSlots, pins);+ expect(pane.session, same(session));+ expect(session.status, TerminalSessionStatus.takenOver);+ expect(sent, isEmpty);+ });++ test('opening a question captures its target and a vanished existing view never becomes Add', () async {+ final app = createApp();+ addTearDown(app.dispose);+ final first = app.activeSwarm;+ await announceQuestion(app, 'a0');+ final unopened = swarmAttentionEntries(app).single;+ expect(unopened.destination.hasView, isFalse);+ app.newSwarm();+ final second = app.activeSwarm;+ expect(+ await activateSwarmAttention(app, unopened, destinationSwarmId: first.id),+ isTrue,+ );+ expect(first.panes.single.agentId, 'a0');+ expect(second.panes, isEmpty);+ expect(app.activeSwarmId, second.id);+ final existing = swarmAttentionEntries(app).single;+ await app.closeSwarm(first.id);+ await announceQuestion(app, 'a0');+ expect(+ await activateSwarmAttention(+ app,+ existing,+ destinationSwarmId: second.id,+ ),+ isFalse,+ );+ expect(second.panes, isEmpty);+ });+}diff --git a/desktop/test/swarm_interactions_test.dart b/desktop/test/swarm_interactions_test.dartindex ced816e54..47e615321 100644--- a/desktop/test/swarm_interactions_test.dart+++ b/desktop/test/swarm_interactions_test.dart@@ -221,6 +221,8 @@ void main() {expect(updates.last['enabled'], isFalse);await native('new');await native('closeActive');+ await native('notifications');+ expect(find.text('Needs input'), findsNothing);expect(app.swarms.single.id, 'swarm-1');Navigator.of(tester.element(find.byType(SettingsScreen))).pop();await tester.pump(const Duration(milliseconds: 300));@@ -249,6 +251,18 @@ void main() {await tester.pump();expect(app.swarms.single.name, 'Recover me');expect(updates.last['canReopen'], isFalse);+ final attention = native('notifications');+ await tester.pump();+ expect(find.text('Needs input'), findsOneWidget);+ expect(updates.last['enabled'], isFalse);+ await native('new');+ await native('notifications');+ expect(app.swarms.single.name, 'Recover me');+ expect(find.byType(Dialog), findsOneWidget);+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pump();+ await attention;+ expect(updates.last['enabled'], isTrue);await tester.pumpWidget(const SizedBox());projects.dispose();app.dispose();diff --git a/desktop/test/swarm_switcher_test.dart b/desktop/test/swarm_switcher_test.dartindex eaaf693a8..bd27a30f5 100644--- a/desktop/test/swarm_switcher_test.dart+++ b/desktop/test/swarm_switcher_test.dart@@ -119,6 +119,11 @@ void main() {for (var i = 0; i < 12; i++) {await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);await tester.pump();+ expect(selectedRow, findsOneWidget);+ final row = tester.getRect(selectedRow);+ final list = tester.getRect(find.byType(ListView));+ expect(row.top, greaterThanOrEqualTo(list.top));+ expect(row.bottom, lessThanOrEqualTo(list.bottom));}await tester.pump();final selectedId =diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swiftindex 4a3e2af7b..5d6cd80c8 100644--- a/desktop/tool/swarm_titlebar_checks.swift+++ b/desktop/tool/swarm_titlebar_checks.swift@@ -92,6 +92,7 @@ private extension SwarmTabStrip {try original.checkAccessibility(expectedName: "Renamed tab", active: true)try checkTitlebar(newButton.isEnabled, "New tab returns below capacity")try checkTitlebar(notifications.accessibilityLabel() == "2 agents need input", "Attention has a readable accessible label")+ try checkTitlebar(notifications.toolTip == "2 agents need input (⇧⌘I)", "Attention tooltip advertises its keyboard shortcut")try original.checkEnabled(true)original.clickBothActions()try checkTitlebar(events == ["select", "close"], "Native selection and close dispatch once each")@@ -119,7 +120,21 @@ private final class TitlebarCheckMessenger: NSObject, FlutterBinaryMessenger {private extension SwarmTitlebar {func checkNativeContainer() throws {guard let window else { throw TitlebarCheckFailure(message: "Native test window exists") }+ let main = NSMenu()+ main.addItem(NSMenuItem(title: "Harness V2", action: nil, keyEquivalent: ""))+ NSApp.mainMenu = mainconfigure()+ guard let menu = main.items.first(where: { $0.title == "Swarm" })?.submenu,+ let attention = menu.items.first(where: { $0.representedObject as? String == "notifications" }) else {+ throw TitlebarCheckFailure(message: "Swarm menu exposes agents needing input")+ }+ try checkTitlebar(attention.title == "Agents Needing Input…", "Native command names its destination")+ try checkTitlebar(attention.keyEquivalent == "i" && attention.keyEquivalentModifierMask == [.command, .shift], "Native attention shortcut matches Flutter")+ try checkTitlebar(attention.target === self && attention.action == #selector(menuAction(_:)), "Native attention command uses the guarded channel handler")+ actionsEnabled = false+ try checkTitlebar(!validateMenuItem(attention), "Native attention shortcut is disabled behind a modal")+ actionsEnabled = true+ try checkTitlebar(validateMenuItem(attention), "Native attention shortcut returns when the modal closes")strip.update(["enabled": true, "activeId": "swarm-11","tabs": (0..<12).map { ["id": "swarm-\($0)", "name": "Swarm \($0)"] },diff --git a/docs/harness-v2-developer-tools-research.md b/docs/harness-v2-developer-tools-research.mdindex 3c8f04240..3ee8c40be 100644--- a/docs/harness-v2-developer-tools-research.md+++ b/docs/harness-v2-developer-tools-research.md@@ -49,7 +49,7 @@ The opportunity for Harness is to make movement among real agents across real ma| **Keep and finish** | Native Swarm tabs, terminal panes, directional focus, zoom, last-pane and close/reopen | These already support a small working set. Finish native alignment, overflow, accessibility and measured interaction latency. || **Keep and harden** | Shared terminal controllers, saved membership, reconnect and local/remote discovery | This is the foundation. Preserve input ownership, scrollback and chosen arrangements through interruption. Validate remote failures on real linked machines; do not infer that a disconnected agent stopped. || **Implemented; verify in daily use** | `Cmd+P` jumps to agents and Swarms; `Cmd+Shift+F` opens **Add agent** | Fuzzy search covers name/project/branch/folder/machine context, with recent destinations and shared-view reuse. Existing-view navigation preserves focus/layout and terminal ownership without retrying a stream. No dialog fade or backdrop blur. Unopened agents explicitly offer **Open view** in the captured Swarm. |-| **Improve first** | Notifications dialog shows actual blocked agents | Add direct keyboard access to waiting work and a route back to the previous focus. Use authoritative states and quiet presentation. Offer optional interruption behavior only when warranted. |+| **Implemented; verify in daily use** | **Needs input** replaces the notifications list; `Cmd+Shift+I` opens it | Search live questions and agent/project/machine context; jump without changing ownership or chosen membership. `Cmd+P`, Return goes back to prior work. Resolved/replaced questions cannot trigger stale navigation. Unavailable terminals remain explicit. Opens on request with no fade, blur or polling. || **Preserve compatibility** | Real agent terminals and user shell environments | Verify selection, multiline/image paste, scrollback, nested tmux/Vim and escape/control keys. Before promising a full terminal replacement, verify a straightforward ordinary-shell workflow too; the current New agent UI centers on detected agent engines. || **Remove from active work — implemented** | Wallpaper behind populated Swarms | Use `#463746`, matching the selected native tab. Wallpaper fills only an empty New swarm canvas and its decoded cache entry is evicted when that view is disposed. || **Reduce prominence** | “Next wallpaper” button, repeated metadata, permanent Settings gear | Keep appearance choices in a secondary location. Keep machine identity legible where needed to distinguish remote work. Settings already has `Cmd+,` and the app menu; consider reclaiming the extra toolbar control. These are proposals, not removed features. |diff --git a/docs/harness-v2-performance.md b/docs/harness-v2-performance.mdindex d6d7309fa..03b8e7e11 100644--- a/docs/harness-v2-performance.md+++ b/docs/harness-v2-performance.md@@ -1,6 +1,6 @@# Harness V2 performance checks-Measured on 2026-09-12, with retained-canvas, idle-work and background-output continuations on 2026-09-13, using Apple M2 Max, macOS 26.6.2, Flutter 3.47.2 and Dart 3.13.2.+Measured on 2026-09-12, with retained-canvas, idle-work, background-output and keyboard attention continuations on 2026-09-13, using Apple M2 Max, macOS 26.6.2, Flutter 3.47.2 and Dart 3.13.2.The explicit benchmark runs in the headless Flutter test runner with isolated synthetic sessions. It never opens a sample-data app or connects to a real agent. Run it from `desktop/`:@@ -135,11 +135,19 @@ The continuation's headless debug run produced the following measurements in `/pAll five benchmark cases passed; retained rebuild counts remained 1,491 / 1,625. This repetition was not a controlled paired comparison with the prior run. The new search measurements establish CPU cost for that query and catalog, excluding widget layout, AppKit input and physical display. Correctness checks verify the first terminal key after a jump goes only to its destination, but they do not measure native keystroke latency.+## Waiting work and keyboard scrolling++Cmd+Shift+I opens the existing bell's **Needs input** surface without the prior 140 ms dialog transition or backdrop blur. Its live catalog uses the same fuzzy ranking as Cmd+P, including question text. No discovery, network call, polling or aging timer runs on each keystroke. Only visible and cached list rows are built.++Keyboard selection in both pickers now adjusts the scroll offset during the key event, before painting. The earlier post-frame scroll could leave the new selection offscreen for a frame. Tests require the selected row to be visible after a single pump on each arrow movement, including past the bottom edge. Live catalog changes still reveal selection after the new list dimensions exist, with at most one scheduled reveal callback.++Nine new state/widget checks pass, alongside the extended native command guards. They cover immediate search focus, Ctrl-N/P, 2× text at 880×600, stale question/view guards and the cross-Swarm round trip: select a waiting agent, deliver input only there, then Cmd+P / Return and deliver input only to the prior agent. The final full suite passes 1,023 tests with one skip. These are frame-order and correctness checks, not measurements of physical input-to-display latency.+## Native follow-upThe optimized real-data app builds and runs locally. The native tab/canvas polish was visually reviewed before the navigation and retained-canvas continuations; CUA currently returns `cgWindowNotFound` for the rebuilt Release preview, so those newer interactions still need live native review. The tab strip uses AppKit's compact unified title bar: the old right accessory was clipped to 32 points; the container now supplies 40 points and aligns controls with the system traffic lights.-The native check covers overflow, resizing, accessibility order and disabled actions. `bash tool/check_swarm_titlebar.sh /path/to/flutter --window-layout` adds actual container checks in a hidden window at three widths, for 170 assertions total. No Flutter engine, account or terminal is accessed.+The native check covers overflow, resizing, accessibility order and disabled actions. `bash tool/check_swarm_titlebar.sh /path/to/flutter --window-layout` adds actual container checks in a hidden window at three widths, for 176 assertions total, including the native attention shortcut and its modal guard. No Flutter engine, account or terminal is accessed.Wallpaper is built only for the empty New swarm. Populated Swarms paint a flat color matching the selected native tab, and the disposed wallpaper evicts its own decoded cache entry. This removes wallpaper painting/cache retention from the active terminal canvas; no process-memory reduction has been measured yet.diff --git a/docs/harness-v2-progress.md b/docs/harness-v2-progress.mdindex eda7d4004..ba20e53d9 100644--- a/docs/harness-v2-progress.md+++ b/docs/harness-v2-progress.md@@ -1,6 +1,6 @@# Harness App V2 — development handoff-Updated 2026-09-13 after the background-output performance continuation. This is a working preview, not a release.+Updated 2026-09-13 after the keyboard attention continuation. This is a working preview, not a release.## Resume here@@ -14,10 +14,11 @@ Updated 2026-09-13 after the background-output performance continuation. This is- Latest design direction: wallpaper fills an empty New swarm only. Populated Swarms use a flat `#463746` canvas matching the selected native tab. Tab hover, spacing and alignment are being compared with the user's Chrome references.- The user requested research into expert developers' tools and a smaller feature set. [Developer-tool research and the keep/improve/remove/defer audit](harness-v2-developer-tools-research.md) documents firsthand sources and a proposed three-part focus: durable sessions, instant navigation, and steering agents without losing concentration.- Cmd+P now jumps to existing agents and Swarms with fuzzy project/machine context and bounded recent-work history. Cmd+Shift+F remains Add agent. The jump dialog has no transition or backdrop blur; selecting an existing view is focus-only, including terminals controlled elsewhere. The 2,000-agent headless search check measured 1.06 ms median / 1.15 ms p95 CPU time; this is not native display latency.+- Cmd+Shift+I now opens **Needs input** from the existing bell or native Swarm menu. It searches live questions and agent/project/machine context, keeps the oldest first when search is blank, and shares focus-only navigation with Cmd+P. Cmd+P, Return takes you back to the prior agent. Both pickers scroll and highlight keyboard selections in the same frame. Nine new state/widget checks pass, including large text and the full terminal-input round trip.- Swarm terminals now keep the same widget ancestry across tabs, zoom and presets, retaining unchanged cells and headers. The paired headless check reduced median tab-switch CPU time from 20.924 to 12.226 ms with 16 terminals and from 14.151 to 8.925 ms with 48; focus changes also improved. Settings route and section fades are removed. These are debug CPU measurements, not native input-to-display timings.- Cursor timers now follow the active, focused terminal, stopping for hidden/covered views and inactive windows. With 48 retained terminals, the isolated five-second observation fell from 480 periodic callbacks to 10 in the foreground and zero when inactive. New swarm retains only its search caret timer. Link-modifier keyboard listeners exist only while hovering a visible link. The idle-work continuation's full suite passed 1,010 tests with one skip.-- Ordinary hidden output now updates the buffer without scheduling a renderer frame. The paired 16/48-terminal debug benchmark reduced hidden-output median CPU cost by 88%/84%; mixed visible/hidden output improved by 32%/51%. Restoring a view reconciles its current buffer, scroll and dimensions once; native caret coordinates coalesce after the frame. The final full suite passes 1,014 tests with one skip.-- The final Release preview was rebuilt and normally relaunched; PID **69137** was the sole V2 instance at the last check. Revalidate the process before any later restart. CUA still reports `cgWindowNotFound` when selecting that full bundle path after this rebuild, as it did after an earlier CUA reset and normal relaunches. CUA's earlier surface inventory listed the preview as running. An earlier relaunched process did have a 1280×840 onscreen CoreGraphics window. Bundle-ID selection was also ambiguous with the retained backup under `/Users/ab/code/harness-app-v2`; no backup was altered. Do not claim the new jump interaction, stable canvas, cursor lifecycle or renderer restoration was reviewed in the live native window. The actual native titlebar/canvas had been reviewed before these continuations; the new picker was visually inspected in an isolated Flutter render with native font files and engine icons loaded. First-frame renderer pixels and native caret messages are now covered by isolated Flutter checks.+- Ordinary hidden output now updates the buffer without scheduling a renderer frame. The paired 16/48-terminal debug benchmark reduced hidden-output median CPU cost by 88%/84%; mixed visible/hidden output improved by 32%/51%. Restoring a view reconciles its current buffer, scroll and dimensions once; native caret coordinates coalesce after the frame. That continuation passed 1,014 tests with one skip; the current full suite passes 1,023 with one skip.+- The final Release preview was rebuilt and normally relaunched; PID **84666** was the sole V2 instance at the last check. Revalidate the process before any later restart. CUA still reports `cgWindowNotFound` when selecting that full bundle path after this rebuild, as it did after an earlier CUA reset and normal relaunches. CUA's earlier surface inventory listed the preview as running. An earlier relaunched process did have a 1280×840 onscreen CoreGraphics window. Bundle-ID selection was also ambiguous with the retained backup under `/Users/ab/code/harness-app-v2`; no backup was altered. Do not claim the new jump/Needs input interaction, stable canvas, cursor lifecycle or renderer restoration was reviewed in the live native window. The actual native titlebar/canvas had been reviewed before these continuations; both pickers were visually inspected in isolated Flutter renders with native font files and engine icons loaded. First-frame renderer pixels and native caret messages are now covered by isolated Flutter checks.- Continue implementation here. Do not create another repository or fork for V2.```bash@@ -96,7 +97,7 @@ Approved reference: `/Users/ab/code/harness-new-ui`, React prototype commit `f83- `state/swarm_catalog.dart`: search, project grouping, saved folders (`swarm_projects_v1`). Group by canonical remote if supplied, otherwise owning machine and full folder path; matching basenames never establish identity.- Project-store load/add operations are serialized, and failures are visible without claiming a project was saved.- Search supports arrows, Ctrl-N/P, and Return, reveals the selected row, and retains the highlighted agent across live list changes. Both the welcome and picker immediately focus search; blank Return on welcome does not open an invisible first result.-- Notifications come from real blocked agents; selecting an existing membership uses the same focus-only navigation without implicitly retrying the terminal.+- `widgets/swarm_attention.dart` and `state/swarm_attention.dart` replace the mouse-only notifications list with **Needs input** (Cmd+Shift+I). It opens with no transition or blur, searches live prompts plus agent/project/machine context using the existing fuzzy ranker, and builds rows on demand. Blank search keeps the time each question was first heard; live updates preserve the selected agent and remove resolved questions. Unavailable terminals remain visible and cannot create an unknown view. Activation revalidates the same pending request before using focus-only navigation or explicitly opening a view in the captured Swarm. It never answers a question or retries/takes over an existing terminal. Cmd+P, Return restores prior work, including across Swarms. Keyboard movement in both pickers now scrolls before paint, avoiding a second frame for an offscreen selection.- Spoken-task subscription/reporting/window reveal and existing linking dialogs are retained. Settings is in the title bar, with Account/sign-out restored inside Settings.- Settings opens/closes immediately and switches sections without cross-fades. The former 170/120 ms route and 200/90 ms section transitions are removed.- Non-macOS/tests use a Flutter reorderable tab-strip fallback. Linux/Windows have not been built or visually reviewed.@@ -141,6 +142,7 @@ Approved reference: `/Users/ab/code/harness-new-ui`, React prototype commit `f83| Rename swarm | Cmd+Shift+R || Previous / next swarm | Cmd+Shift+[ / ], Ctrl+Shift+Tab / Ctrl+Tab || Jump to agent or swarm | Cmd+P |+| Agents needing input | Cmd+Shift+I || Add agent picker / New agent | Cmd+Shift+F / Cmd+N || Focus neighboring pane | Cmd+H/J/K/L or Cmd+arrow || Move pane | Cmd+Shift+H/J/K/L or Cmd+Shift+arrow |@@ -162,11 +164,12 @@ The reopen binding follows the documented Mac tab-recovery shortcut in [Safari](| --- | --- || macOS debug build | Passed and launched from the monorepo with real saved Swarms and terminals. || macOS optimized local build | Passed and running with the real entry point and saved V2 state. Local ad hoc signing requires the command-line `ENABLE_HARDENED_RUNTIME=NO` override for Flutter's framework; distribution signing settings remain unchanged. The distribution Developer ID certificate is unavailable; nothing was uploaded. Normal asynchronous quit and relaunch were verified. Unlocked native review confirmed the taller tab container, edge-to-edge empty wallpaper, and the flat populated canvas joining the selected tab. The native hover rendering was also inspected in a local image. |-| Full Flutter suite | **1,014 passed, 1 skipped** on the final background-output production code, including terminal, modal, persistence, layout and shortcut regressions. |+| Full Flutter suite | **1,023 passed, 1 skipped** on the final keyboard attention production code, including terminal, modal, persistence, layout and shortcut regressions. || Hidden rendering and native caret | Four new checks cover binary output arriving without hidden layout/frame requests; retained selection, manual scroll and follow-tail; first-visible-frame raster pixels; changed emulator dimensions and preserved TUI scroll regions; covered routes; and coalesced/fresh caret coordinates. The focused restoration/IME/key-ownership run passed 22 checks. || Cursor and link activity | Four new checks cover one cursor clock across retained Swarms/focus/zoom, immediate suspension for inactive windows and disabled ticker mode, session replacement and read-only/connection ownership, and stationary link hover across session replacement/modifier release. The earlier focused cursor/session run passed 74 checks. || Retained canvas and header | Five new checks cover stable element ancestry and terminal State across tabs/zoom/presets, first-frame per-Swarm scrolling, tall splits and hidden geometry, font metrics at unchanged point size, and fresh header metadata/callbacks. Layout checks compare legacy and Swarm geometry for all fixed presets and auto layouts at two sizes. || Jump navigation | 13 new state/widget checks cover fuzzy context, shared/offline views, focus-only navigation, preserved layout and terminal state, bounded recents, stale results, captured destinations, immediate focus, keyboard scrolling, live discovery and Add separation. The three widget checks also pass after adding assertions that the first terminal key reaches only the destination session. |+| Needs input | Nine new state/widget checks cover oldest-first search, live prompt/context matching, missing terminals, resolved/replaced request guards, shared ownership, captured targets, stale views, first-frame open and scrolling, Ctrl-N/P, large text, cancellation, and the Cmd+P return path with the first terminal key reaching only its destination. Existing native modal tests now exercise the notifications channel too. The isolated render was inspected with SF font files and engine icons; live native review remains pending. || Jump visual review | Isolated render inspected with SF font files and engine icons; selected-result text now stays white on a quiet highlight. Four checks (the three widget cases plus the temporary visual fixture) passed after this contrast adjustment. Final Release build passed. Live CUA review remains unavailable with `cgWindowNotFound`. || Focused interaction checks | 8 passed: picker navigation/scroll/refresh, welcome keys, shared-view close, composer, native modal guard, profile and folder races. || Closed-Swarm recovery | 7 passed: arrangement and shared-view restoration, untouched welcome replacement, rapid close/reopen with delayed cleanup, capacity, bounded history, sign-out isolation and the keyboard command. Native command availability and modal behavior also pass in the interaction suite. |@@ -177,7 +180,7 @@ The reopen binding follows the documented Mac tab-recovery shortcut in [Safari](| Headless performance | The prior five-case catalog/terminal/output benchmark passed. The paired retained-canvas continuation reran both 16/48-terminal cases with new focus measurements: tab medians 12.226 / 8.925 ms and focus medians 5.284 / 4.586 ms. Reproducible commands and limits in `docs/harness-v2-performance.md`. || Idle-work measurement | Both isolated timer scenarios passed: 16/48 retained terminals now share one focused cursor clock, with 10 callbacks in five seconds, and zero terminal cursor callbacks when the window is inactive or an empty Swarm is shown. Empty New swarm keeps its search field's caret timer. These are fake-clock structural counts, not native process CPU/battery measurements. || Background output measurement | Both 16/48-terminal cases passed with hidden-only and mixed output. Hidden dirty renderers fell from 12/44 to zero; hidden-only bursts schedule no frame in this workload. Final CPU medians are 0.110/0.206 ms for hidden output and 0.757/0.766 ms for all-terminal output. See performance notes for scope and paired results. |-| AppKit components and container | **170 assertions passed**: the original 151 component checks plus native-container checks at 880, 1280 and 1920 points. These verify height, traffic-light clearance/alignment, direct contact with the content edge and active-tab visibility. The optional container check creates a hidden native window; no window is displayed and no engine, account or terminal is accessed. |+| AppKit components and container | **176 assertions passed**: component, attention shortcut/menu/modal checks plus native-container checks at 880, 1280 and 1920 points. These verify height, traffic-light clearance/alignment, direct contact with the content edge and active-tab visibility. The optional container check creates a hidden native window; no window is displayed and no engine, account or terminal is accessed. || Remote terminals / production release | No remote takeover, release, installer, or production CLI update/restart. Cross-platform and end-to-end latency measurements remain. |Tests now exercise the actual V2 welcome/settings/linking flow. Usage pricing again explains a partial estimate as a lower bound. Small offline panes avoid overflowing the full connection guide. No remaining full-suite failures are being dismissed as baseline.