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
perf(desktop): suspend inactive terminal cursor and hover work
deee0026e0e9daf
diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dartindex 1845d2798..7b76f65e6 100644--- a/desktop/lib/widgets/terminal_panel.dart+++ b/desktop/lib/widgets/terminal_panel.dart@@ -89,6 +89,7 @@ class TerminalPanel extends StatefulWidget {}class _TerminalPanelState extends State<TerminalPanel>+ with WidgetsBindingObserverimplements TerminalViewport {static const _dialScale = 2.5;static const _dialStopVelocity = 40.0;@@ -102,6 +103,7 @@ class _TerminalPanelState extends State<TerminalPanel>late GlobalKey<TerminalViewState> _terminalViewKey;Timer? _dialInertiaTimer;Timer? _cursorBlinkTimer;+ ValueListenable<TickerModeData>? _tickerMode;double _dialVelocity = 0;bool _cursorBlinkVisible = true;double _alternateScrollRemainder = 0;@@ -112,6 +114,7 @@ class _TerminalPanelState extends State<TerminalPanel>String? _pressedLink;bool _openingLink = false;bool _linkRefreshPending = false;+ bool _observingLinkModifiers = false;late final RemoteMediaDownloader _mediaDownloader;MediaDownloadCancellation? _previewCancellation;RemoteMediaProgress? _previewProgress;@@ -127,19 +130,46 @@ class _TerminalPanelState extends State<TerminalPanel>_terminalViewKey = GlobalKey<TerminalViewState>();_linkOpener = widget.linkOpener ?? TerminalLinkOpener();_mediaDownloader = widget.mediaDownloader ?? RemoteMediaDownloader();- HardwareKeyboard.instance.addHandler(_onLinkModifierChanged);_focusNode.addListener(_handleFocusChange);_composerFocus.addListener(_handleComposerFocusChange);- _cursorBlinkTimer = Timer.periodic(- const Duration(milliseconds: 500),- (_) => _advanceCursorBlink(),- );+ WidgetsBinding.instance.addObserver(this);widget.session.attachViewport(this);widget.session.addListener(_onSessionChanged);terminalFontStore.addListener(_onFontChanged);_afterTerminalMounted();}+ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ _updateTickerMode();+ }++ @override+ void activate() {+ super.activate();+ _updateTickerMode();+ }++ @override+ void deactivate() {+ _stopCursorBlink();+ super.deactivate();+ }++ void _updateTickerMode() {+ final mode = TickerMode.getValuesNotifier(context);+ if (!identical(mode, _tickerMode)) {+ _tickerMode?.removeListener(_syncCursorBlink);+ _tickerMode = mode..addListener(_syncCursorBlink);+ }+ _syncCursorBlink();+ }++ @override+ void didChangeAppLifecycleState(AppLifecycleState state) =>+ _syncCursorBlink();+@overridevoid didUpdateWidget(TerminalPanel oldWidget) {super.didUpdateWidget(oldWidget);@@ -159,6 +189,7 @@ class _TerminalPanelState extends State<TerminalPanel>_viewTerminal.addListener(_scheduleLinkRefresh);_pressedLink = null;_hoveredLink = null;+ _observeLinkModifiers(false);_terminalViewKey = GlobalKey<TerminalViewState>();_cursorBlinkVisible = true;widget.session.setCursorBlinkPhase(true);@@ -168,6 +199,10 @@ class _TerminalPanelState extends State<TerminalPanel>_focusNode.unfocus();_composerFocus.unfocus();_cancelDialInertia();+ _linkPointerPosition = null;+ _hoveredLink = null;+ _pressedLink = null;+ _observeLinkModifiers(false);}if (!oldWidget.focused && widget.focused) {_claimFocusAfterFrame();@@ -177,14 +212,17 @@ class _TerminalPanelState extends State<TerminalPanel>if (oldWidget.composerVisible != widget.composerVisible) {_afterTerminalMounted();}+ _syncCursorBlink();}@overridevoid dispose() {+ WidgetsBinding.instance.removeObserver(this);+ _tickerMode?.removeListener(_syncCursorBlink);_previewCancellation?.cancel();_viewTerminal.removeListener(_scheduleLinkRefresh);_scrollController.removeListener(_scheduleLinkRefresh);- HardwareKeyboard.instance.removeHandler(_onLinkModifierChanged);+ _observeLinkModifiers(false);widget.session.setCursorBlinkPhase(true);widget.session.removeListener(_onSessionChanged);widget.session.detachViewport(this);@@ -224,7 +262,9 @@ class _TerminalPanelState extends State<TerminalPanel>bool _composerFocusPending = false;void _onSessionChanged() {- if (!mounted || !_composerFocusPending) return;+ if (!mounted) return;+ _syncCursorBlink();+ if (!_composerFocusPending) return;if (!widget.focused || !_showsComposer) {_composerFocusPending = false;return;@@ -259,6 +299,7 @@ class _TerminalPanelState extends State<TerminalPanel>_viewTerminal.addListener(_scheduleLinkRefresh);_pressedLink = null;_hoveredLink = null;+ _observeLinkModifiers(false);_terminalViewKey = GlobalKey<TerminalViewState>();_cancelDialInertia();_alternateScrollRemainder = 0;@@ -273,13 +314,10 @@ class _TerminalPanelState extends State<TerminalPanel>}void _handleFocusChange() {+ _syncCursorBlink();if (_focusNode.hasFocus) {widget.onRendererFocus?.call();- return;}- _cursorBlinkVisible = true;- widget.session.setCursorBlinkPhase(true);- _repaintTerminalCursor();}/// Re-establishes the native text-input connection after a rail selection.@@ -313,14 +351,39 @@ class _TerminalPanelState extends State<TerminalPanel>});}- void _advanceCursorBlink() {- if (!mounted) return;- final shouldBlink =- widget.visible && _focusNode.hasFocus && widget.session.acceptsInput;- final next = shouldBlink ? !_cursorBlinkVisible : true;- if (next == _cursorBlinkVisible) return;- _cursorBlinkVisible = next;- widget.session.setCursorBlinkPhase(next);+ /// Retaining a renderer must not retain a polling loop. Only the focused,+ /// interactive terminal in the active window needs a cursor clock. Observe+ /// ticker mode without rebuilding the subtree when a route covers it.+ void _syncCursorBlink() {+ final lifecycle = WidgetsBinding.instance.lifecycleState;+ final enabled =+ mounted &&+ widget.visible &&+ !widget.readOnly &&+ _focusNode.hasFocus &&+ widget.session.acceptsInput &&+ (_tickerMode?.value.enabled ?? false) &&+ (lifecycle == null || lifecycle == AppLifecycleState.resumed);+ if (!enabled) {+ _stopCursorBlink();+ return;+ }+ _cursorBlinkTimer ??= Timer.periodic(+ const Duration(milliseconds: 500),+ (_) => _setCursorBlinkVisible(!_cursorBlinkVisible),+ );+ }++ void _stopCursorBlink() {+ _cursorBlinkTimer?.cancel();+ _cursorBlinkTimer = null;+ _setCursorBlinkVisible(true);+ }++ void _setCursorBlinkVisible(bool visible) {+ if (visible == _cursorBlinkVisible) return;+ _cursorBlinkVisible = visible;+ widget.session.setCursorBlinkPhase(visible);_repaintTerminalCursor();}@@ -376,6 +439,7 @@ class _TerminalPanelState extends State<TerminalPanel>// Never over the composer: a rebuild that re-focuses this tile while someone is typing into// the box would pull the caret out from under them mid-sentence._claimFocus(view);+ if (_linkPointerPosition != null) _hoverLink(_linkPointerPosition);});}@@ -555,12 +619,29 @@ class _TerminalPanelState extends State<TerminalPanel>return false; // Modifier observation never consumes a terminal key.}+ /// Modifier keys only change the pointer over a link. Do not fan every key+ /// out to the retained terminal pool when no pointer feedback can change.+ void _observeLinkModifiers(bool enabled) {+ if (_observingLinkModifiers == enabled) return;+ _observingLinkModifiers = enabled;+ final keyboard = HardwareKeyboard.instance;+ if (enabled) {+ keyboard.addHandler(_onLinkModifierChanged);+ } else {+ keyboard.removeHandler(_onLinkModifierChanged);+ }+ }+void _scheduleLinkRefresh() {- if (_linkPointerPosition == null || _linkRefreshPending) return;+ if (!widget.visible ||+ _linkPointerPosition == null ||+ _linkRefreshPending) {+ return;+ }_linkRefreshPending = true;WidgetsBinding.instance.addPostFrameCallback((_) {_linkRefreshPending = false;- if (mounted) _hoverLink(_linkPointerPosition);+ if (mounted && widget.visible) _hoverLink(_linkPointerPosition);});}@@ -574,10 +655,11 @@ class _TerminalPanelState extends State<TerminalPanel>}void _hoverLink(Offset? globalPosition) {- _linkPointerPosition = globalPosition;- final target = globalPosition == null+ _linkPointerPosition = widget.visible ? globalPosition : null;+ final target = _linkPointerPosition == null? null- : _linkAtPointer(globalPosition);+ : _linkAtPointer(_linkPointerPosition!);+ _observeLinkModifiers(target != null);if (target != _hoveredLink) setState(() => _hoveredLink = target);}diff --git a/desktop/test/benchmarks/terminal_idle_benchmark.dart b/desktop/test/benchmarks/terminal_idle_benchmark.dartnew file mode 100644index 000000000..fd8486035--- /dev/null+++ b/desktop/test/benchmarks/terminal_idle_benchmark.dart@@ -0,0 +1,73 @@+import 'dart:convert';++import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/widgets/terminal_panel.dart';++import '../support/periodic_timer_probe.dart';+import '../swarm_screen_test.dart' show mount, terminal;+import '../swarm_state_test.dart' show createApp;++/// Structural idle-work measurement, separate from wall-clock CPU benchmarks.+/// Isolated sessions have no network heartbeat or real terminal connection.+/// The empty Swarm count includes the focused welcome search field's caret.+void main() {+ for (final count in [16, 48]) {+ testWidgets('idle cursor work with $count retained terminals', (+ tester,+ ) async {+ final probe = PeriodicTimerProbe();+ await probe.run(() async {+ final app = createApp();+ app.machineStates['m']!.nodeOnline = true;+ for (var i = 0; i < count; i++) {+ if (i > 0 && i % 4 == 0) app.newSwarm();+ app.adoptSessionForTest(terminal('a$i', []));+ }+ await mount(tester, app);+ for (var i = 0; i < count ~/ 4; i++) {+ app.stepSwarm(1);+ await tester.pump();+ }+ expect(find.byType(TerminalPanel), findsNWidgets(4));+ expect(+ find.byType(TerminalPanel, skipOffstage: false),+ findsNWidgets(count),+ );+ final active = probe.active;+ var before = probe.callbacks;+ await tester.pump(const Duration(seconds: 5));+ final foreground = probe.callbacks - before;+ tester.binding.handleAppLifecycleStateChanged(+ AppLifecycleState.inactive,+ );+ final inactive = probe.active;+ before = probe.callbacks;+ await tester.pump(const Duration(seconds: 5));+ final background = probe.callbacks - before;+ tester.binding.handleAppLifecycleStateChanged(+ AppLifecycleState.resumed,+ );+ app.newSwarm();+ await tester.pump();+ final empty = probe.active;+ before = probe.callbacks;+ await tester.pump(const Duration(seconds: 5));+ final emptyCallbacks = probe.callbacks - before;+ debugPrint(+ 'TERMINAL_IDLE_BENCH ${jsonEncode({+ 'kind': 'headless_fake_clock_timer_activity',+ 'retainedTerminals': count,+ 'observationSeconds': 5,+ 'foreground': {'timers': active, 'callbacks': foreground},+ 'inactiveWindow': {'timers': inactive, 'callbacks': background},+ 'emptySwarm': {'timers': empty, 'callbacks': emptyCallbacks},+ })}',+ );+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ expect(probe.active, 0);+ });+ });+ }+}diff --git a/desktop/test/support/periodic_timer_probe.dart b/desktop/test/support/periodic_timer_probe.dartnew file mode 100644index 000000000..2de5a9bfc--- /dev/null+++ b/desktop/test/support/periodic_timer_probe.dart@@ -0,0 +1,24 @@+import 'dart:async';++/// Counts actual timer activity without adding instrumentation to the app.+/// Delegation preserves the widget test runner's fake clock and cancellation.+class PeriodicTimerProbe {+ final _timers = <Timer>[];+ int callbacks = 0;++ int get active => _timers.where((timer) => timer.isActive).length;++ Future<void> run(Future<void> Function() body) => runZoned(+ body,+ zoneSpecification: ZoneSpecification(+ createPeriodicTimer: (self, parent, zone, period, callback) {+ final timer = parent.createPeriodicTimer(zone, period, (timer) {+ callbacks++;+ callback(timer);+ });+ _timers.add(timer);+ return timer;+ },+ ),+ );+}diff --git a/desktop/test/terminal_panel_activity_test.dart b/desktop/test/terminal_panel_activity_test.dartnew file mode 100644index 000000000..c9302ef46--- /dev/null+++ b/desktop/test/terminal_panel_activity_test.dart@@ -0,0 +1,179 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/terminal/terminal_session.dart';+import 'package:harness/widgets/pane_grid.dart';+import 'package:harness/widgets/terminal_panel.dart';++import 'support/periodic_timer_probe.dart';+import 'swarm_screen_test.dart' show terminal;+import 'swarm_state_test.dart' show createApp;++void main() {+ testWidgets('retained Swarms run only the focused terminal cursor clock', (+ tester,+ ) async {+ final probe = PeriodicTimerProbe();+ await probe.run(() async {+ final app = createApp();+ app.machineStates['m']!.nodeOnline = true;+ final first = app.activeSwarmId;+ for (var i = 0; i < 8; i++) {+ if (i == 4) app.newSwarm();+ app.adoptSessionForTest(terminal('a$i', []));+ }+ await tester.pumpWidget(+ MaterialApp(+ home: PaneGrid(+ notifier: app,+ swarmMode: true,+ empty: const SizedBox(),+ ),+ ),+ );+ await tester.pump();+ app.selectSwarm(first);+ await tester.pump();+ expect(find.byType(TerminalPanel, skipOffstage: false), findsNWidgets(8));+ expect(probe.active, 1);+ final oldFocus = app.panes.firstWhere((p) => app.isPaneFocused(p.id));+ await tester.pump(const Duration(milliseconds: 500));+ expect(oldFocus.session!.terminal.cursorVisibleMode, isFalse);++ app.focusPaneBy(1);+ await tester.pump();+ expect(probe.active, 1);+ expect(oldFocus.session!.terminal.cursorVisibleMode, isTrue);+ final focused = app.panes.firstWhere((p) => app.isPaneFocused(p.id));+ await tester.pump(const Duration(milliseconds: 500));+ expect(focused.session!.terminal.cursorVisibleMode, isFalse);+ app.toggleZoomPane();+ await tester.pump();+ expect(probe.active, 1);++ app.stepSwarm(1);+ await tester.pump();+ expect(probe.active, 1);+ expect(focused.session!.terminal.cursorVisibleMode, isTrue);+ app.newSwarm();+ await tester.pump();+ expect(probe.active, 0);+ final before = probe.callbacks;+ await tester.pump(const Duration(seconds: 5));+ expect(probe.callbacks, before);+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ });+ });++ testWidgets(+ 'window and route inactivity suspend blinking without rebuilding',+ (tester) async {+ final probe = PeriodicTimerProbe();+ await probe.run(() async {+ final app = createApp();+ final session = terminal('a0', []);+ final enabled = ValueNotifier(true);+ final panel = TerminalPanel(+ notifier: app,+ session: session,+ focused: true,+ );+ await tester.pumpWidget(+ MaterialApp(+ home: ValueListenableBuilder<bool>(+ valueListenable: enabled,+ child: panel,+ builder: (_, value, child) =>+ TickerMode(enabled: value, child: child!),+ ),+ ),+ );+ await tester.pump();+ expect(probe.active, 1);+ await tester.pump(const Duration(milliseconds: 500));+ expect(session.terminal.cursorVisibleMode, isFalse);+ tester.binding.handleAppLifecycleStateChanged(+ AppLifecycleState.inactive,+ );+ expect(probe.active, 0);+ expect(session.terminal.cursorVisibleMode, isTrue);+ final before = probe.callbacks;+ await tester.pump(const Duration(seconds: 5));+ expect(probe.callbacks, before);+ tester.binding.handleAppLifecycleStateChanged(+ AppLifecycleState.resumed,+ );+ expect(probe.active, 1);+ enabled.value = false;+ await tester.pump();+ expect(probe.active, 0);+ enabled.value = true;+ await tester.pump();+ expect(probe.active, 1);+ await tester.pump(const Duration(milliseconds: 500));+ expect(session.terminal.cursorVisibleMode, isFalse);+ await tester.pumpWidget(const SizedBox());+ expect(probe.active, 0);+ enabled.dispose();+ session.dispose();+ app.dispose();+ });+ },+ );++ testWidgets('cursor clocks follow session replacement and input ownership', (+ tester,+ ) async {+ final probe = PeriodicTimerProbe();+ await probe.run(() async {+ final app = createApp();+ final first = terminal('a0', []);+ final second = terminal('a1', []);+ final active = ValueNotifier((session: first, readOnly: false));+ await tester.pumpWidget(+ MaterialApp(+ home:+ ValueListenableBuilder<+ ({TerminalSession session, bool readOnly})+ >(+ valueListenable: active,+ builder: (_, value, _) => TerminalPanel(+ notifier: app,+ session: value.session,+ readOnly: value.readOnly,+ focused: true,+ ),+ ),+ ),+ );+ await tester.pump();+ expect(probe.active, 1);+ await tester.pump(const Duration(milliseconds: 500));+ first.transportLost('Test disconnect');+ expect(probe.active, 0);+ expect(first.terminal.cursorVisibleMode, isTrue);+ active.value = (session: second, readOnly: false);+ await tester.pump();+ expect(probe.active, 1);+ await tester.pump(const Duration(milliseconds: 500));+ expect(second.terminal.cursorVisibleMode, isFalse);+ active.value = (session: second, readOnly: true);+ await tester.pump();+ expect(probe.active, 0);+ expect(second.terminal.cursorVisibleMode, isTrue);+ active.value = (session: second, readOnly: false);+ await tester.pump();+ expect(probe.active, 1);+ await second.handleFrame('terminal_closed', {+ 'streamId': 'stream-a1',+ 'code': 'TERMINAL_TAKEN_OVER',+ });+ expect(probe.active, 0);+ await tester.pumpWidget(const SizedBox());+ active.dispose();+ first.dispose();+ second.dispose();+ app.dispose();+ });+ });+}diff --git a/desktop/test/terminal_panel_links_test.dart b/desktop/test/terminal_panel_links_test.dartindex 78fa7fd34..a9e628f5b 100644--- a/desktop/test/terminal_panel_links_test.dart+++ b/desktop/test/terminal_panel_links_test.dart@@ -354,6 +354,62 @@ void main() {final view = tester.widget<TerminalView>(find.byType(TerminalView));expect(view.controller!.selection, isNotNull);});+ testOnPlatform(+ 'a stationary link pointer follows session replacement and modifier release',+ (tester) async {+ await mount(tester);+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);+ await mouse.addPointer(location: Offset.zero);+ await mouse.moveTo(point(tester));+ await tester.sendKeyDownEvent(+ LogicalKeyboardKey.metaLeft,+ platform: 'macos',+ );+ await tester.pump();+ final previous = tester.widget<TerminalPanel>(find.byType(TerminalPanel));+ final replacement =+ TerminalSession(+ machineId: 'm1',+ agentId: 'a2',+ agentName: 'a2',+ engineId: 'codex',+ send: (_, _) async => true,+ sendBinary: (_) async => true,+ )+ ..status = TerminalSessionStatus.controlling+ ..streamId = 'stream-a2';+ replacement.terminal.write('/tmp/replacement.png');+ addTearDown(replacement.dispose);+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: TerminalPanel(+ notifier: notifier,+ session: replacement,+ focused: true,+ linkOpener: previous.linkOpener,+ ),+ ),+ ),+ );+ await tester.pump();+ expect(+ tester.widget<TerminalView>(find.byType(TerminalView)).mouseCursor,+ SystemMouseCursors.click,+ );+ await tester.sendKeyUpEvent(+ LogicalKeyboardKey.metaLeft,+ platform: 'macos',+ );+ await tester.pump();+ expect(+ tester.widget<TerminalView>(find.byType(TerminalView)).mouseCursor,+ SystemMouseCursors.text,+ );+ await mouse.removePointer();+ await tester.pump(const Duration(milliseconds: 350));+ },+ );testOnPlatform('hover shows the shortcut and refreshes after streamed output changes',(tester) async {diff --git a/docs/harness-v2-performance.md b/docs/harness-v2-performance.mdindex e3e762659..d660f9826 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 a retained-canvas continuation 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 and idle-work 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/`:@@ -58,6 +58,31 @@ Incoming binary data now skips unrelated sessions before awaiting the matching rSettings route and section fades are removed: the former opening/closing durations were 170/120 ms for the route and 200/90 ms for the section switcher. Both now present their destination immediately. Existing Settings, modal and route checks pass; this change removes configured animation time, not all possible input or rendering cost.+## Idle cursor and keyboard work++Every mounted terminal previously started a 500 ms periodic cursor timer, including retained hidden views. Its callback checked focus and visibility after waking, and the focused terminal continued blinking when the native window was inactive.++The cursor clock now exists only while the terminal is visible, focused, accepting input, writable, in an enabled ticker subtree, and in the active application. Focus, session status, route visibility and application lifecycle events start/stop it directly. Stopping restores the local bright cursor phase while preserving the remote program's cursor visibility. The ticker-mode listener updates the clock without rebuilding the retained subtree.++The paired isolated measurement counts actual periodic timer creation and callbacks through a delegated Dart zone. Each observation advances the widget runner's fake clock by five seconds:++| Retained terminals | View/window | Active timers before → after | Callbacks in 5 s before → after |+| ---: | --- | ---: | ---: |+| 16 | Four visible panes, one focused | 16 → 1 | 160 → 10 |+| 48 | Four visible panes, one focused | 48 → 1 | 480 → 10 |+| 16 | Inactive window | 16 → 0 | 160 → 0 |+| 48 | Inactive window | 48 → 0 | 480 → 0 |+| 16 | Empty New swarm | 17 → 1 | 170 → 10 |+| 48 | Empty New swarm | 49 → 1 | 490 → 10 |++The empty Swarm's remaining timer belongs to its focused search field caret. These synthetic sessions start in controlling state without network heartbeats, so the table measures UI timer activity rather than total process wakeups, CPU usage, battery life or display latency. Real session heartbeats and output delivery continue independently. Baseline and final-source logs: `/private/tmp/harness-v2-idle-before.log` and `/private/tmp/harness-v2-idle-measured.log`.++```bash+flutter test test/benchmarks/terminal_idle_benchmark.dart --no-pub --reporter expanded+```++Global link-modifier handlers are now registered only while a visible link is under the pointer, removing the per-retained-terminal listener from ordinary keyboard input. Hidden views clear hover state and skip link refresh callbacks. Tests cover focus/tab/zoom changes, covered routes, window inactivity and resumption, session replacement, read-only/connection ownership, and a stationary link pointer across session replacement and modifier release. The complete Flutter suite passes with 1,010 tests and one skip.+## Terminal output allocationsOrdinary output packets now decode directly from their existing byte view. Previously every packet was copied into a joined list and copied again to select the decodable prefix. A joined buffer is still used when a UTF-8 character crosses packet boundaries, and the decoder reads a bounded range without copying that prefix. Malformed-byte replacement and terminal recovery behavior are unchanged.diff --git a/docs/harness-v2-progress.md b/docs/harness-v2-progress.mdindex 4dbc316e2..39e401408 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 retained-canvas performance continuation. This is a working preview, not a release.+Updated 2026-09-13 after the idle-work performance continuation. This is a working preview, not a release.## Resume here@@ -15,7 +15,8 @@ Updated 2026-09-13 after the retained-canvas performance continuation. This is a- 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.- 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.-- The final Release preview was rebuilt and normally relaunched; PID **39721** 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. 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 or stable canvas 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.+- 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 full suite now passes 1,010 tests with one skip.+- The final Release preview was rebuilt and normally relaunched; PID **50640** 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 surface inventory lists 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 or cursor lifecycle 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.- Continue implementation here. Do not create another repository or fork for V2.```bash@@ -72,6 +73,8 @@ Approved reference: `/Users/ab/code/harness-new-ui`, React prototype commit `f83- Hidden panes retain their widget configuration; healthy visible cells retain it until their presentation changes. Connection/setup views continue reading their full state. A replaced session updates its hidden view; returning to a tab applies current machine and agent metadata. Headers separately retain unchanged title/controls, with callbacks resolving the current widget. The paired 16-terminal benchmark reduced rebuilds from 1,491 to 917 per switch and 980 to 602 per focus change; see `docs/harness-v2-performance.md` for all measurements and limits.- Swarm rectangles use the same unit geometry as the layout picker and keyboard navigation. Per-Swarm scroll offsets restore before the first frame, including transitions between large, small and empty Swarms. Font metric changes invalidate the minimum-tile cache and update grid geometry even when the point size is unchanged. Legacy non-Swarm layouts retain their existing renderer.- `TerminalPane.lastViewSize` retains geometry. Hidden `TerminalPanel` views stop auto-resizing/reporting viewport and release input focus.+- The cursor timer exists only while the visible terminal has actual keyboard focus, accepts input, is writable, has enabled ticker mode and the application is active. Focus, session, ticker-mode and lifecycle listeners update it directly; retained inactive panes have no cursor polling loop. Stopping restores only the local bright phase, preserving the remote program's cursor visibility.+- Link-modifier keyboard handlers are registered only while a visible link is under the pointer. Hidden panes clear hover state and skip hover refresh work; mounting a replacement terminal refreshes a stationary pointer against the current buffer.- Compact headers remove routine transport/status/pin clutter, retaining exceptional states and offline/unavailable placeholders.- Existing terminal sessions/transports/renderer and patched `third_party/xterm` are retained. One regression verifies renderer identity, hidden geometry during window resize, and input going only to the active view.- Binary dispatch reads current session stream IDs and skips unrelated sessions before awaiting them, avoiding a scheduling turn per unrelated view. No duplicate stream registry is maintained. Socket FIFO remains in `WsConn`; regressions additionally exercise direct concurrent dispatch during tab reorder, hidden shared views, machine isolation, unknown streams and corrupt-frame recovery.@@ -156,7 +159,8 @@ 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,005 passed, 1 skipped** on the final retained-canvas production code, including terminal, modal, persistence and shortcut regressions. One additional auto-layout comparison was then added to the tests only; the complete 39-case layout file passed afterward. |+| Full Flutter suite | **1,010 passed, 1 skipped** on the final idle-work production code, including terminal, modal, persistence, layout and shortcut regressions. |+| 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. || 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`. |@@ -167,6 +171,7 @@ The reopen binding follows the documented Mac tab-recovery shortcut in [Safari](| CLI targeted tests | 135 passed across project/frame, registry/restore, and terminal recovery files. Project/frame tests rerun after port normalization: 9 passed. || Flutter analyzer | **0 errors, 0 warnings, 12 existing vendored xterm infos**; passes with `--no-fatal-infos`. || 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. || 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. || Remote terminals / production release | No remote takeover, release, installer, or production CLI update/restart. Cross-platform and end-to-end latency measurements remain. |@@ -176,9 +181,13 @@ Tests now exercise the actual V2 welcome/settings/linking flow. Usage pricing agEvidence on this Mac under `/private/tmp`:+- `harness-v2-idle-full-tests.log`: full 1,010-test pass on the final production changes.+- `harness-v2-idle-tests.log`: 74 cursor/session/focus/canvas checks before the hover-listener change.+- `harness-v2-idle-analyze.log`: latest diagnostics, 0 errors/warnings and 12 existing vendored infos.+- `harness-v2-idle-before.log`, `harness-v2-idle-measured.log`: paired periodic timer counts/callbacks with 16/48 retained terminals, active/inactive windows and empty Swarms.- `harness-v2-canvas-full-tests.log`: full 1,005-test pass on the final production changes.- `harness-v2-canvas-geometry.log`: 39 layout checks after adding the final test-only auto-layout comparison.-- `harness-v2-canvas-analyze.log`: latest diagnostics, 0 errors/warnings and 12 existing vendored infos.+- `harness-v2-canvas-analyze.log`: earlier retained-canvas diagnostics, 0 errors/warnings and 12 existing vendored infos.- `harness-v2-stable-canvas-before.log`, `harness-v2-stable-canvas-measured.log`: paired tab/focus CPU and rebuild counts before and after the stable canvas and presentation caches.- `harness-v2-jump-full-tests.log`: full 1,000-test pass.- `harness-v2-jump-tests.log`: 60 focused navigation/shortcut/interaction checks.