Skip to content

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.

fix(desktop): focus jump destinations and retain offline terminals

dee1be6dd9e254d
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index d1d6bf5cf..d3b393b77 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -124,20 +124,9 @@ class _SwarmScreenState extends State<SwarmScreen> {
}
}
- bool get _canFindTerminal {
- final pane = app.focusedPane;
- if (pane?.session == null) return false;
- final machine = app.stateOf(pane!.machineId);
- final agent = machine?.agents
- .where((a) => a.id == pane.agentId)
- .firstOrNull;
- // Connection/setup placeholders do not currently mount a TerminalPanel.
- return machine != null &&
- agent?.terminalAvailable == true &&
- machine.nodeOnline != false &&
- !(machine.isRemote && !machine.isLocalMachine && machine.needsLink) &&
- (!machine.isLocalMachine || machine.usesLocalTransport);
- }
+ // Any retained session has a mounted terminal, including read-only/offline
+ // output. Never-attached setup guides have no buffer to search.
+ bool get _canFindTerminal => app.focusedPane?.session != null;
void _syncNative() {
final payload = {
@@ -267,9 +256,17 @@ class _SwarmScreenState extends State<SwarmScreen> {
selected = await showSwarmSwitcher(context, app, _navigation);
});
if (!mounted || selected == null) return;
+ _preparePaneFocus();
await activateSwarmDestination(app, selected!, destinationSwarmId: target);
}
+ void _preparePaneFocus() {
+ // The closing picker otherwise restores its previous terminal, whose focus
+ // callback can overwrite the chosen destination during this same frame.
+ _shellFocus.requestFocus();
+ FocusManager.instance.applyFocusChangesIfNeeded();
+ }
+
Future<void> _addAgent() async {
final target = app.activeSwarmId;
bool create = false;
@@ -337,6 +334,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
selected = await showSwarmAttention(context, app, _navigation);
});
if (!mounted || selected == null) return;
+ _preparePaneFocus();
await activateSwarmAttention(app, selected!, destinationSwarmId: target);
}
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dart
index cdb526add..b727e4b6c 100644
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@ -378,7 +378,7 @@ class AppNotifier extends ChangeNotifier {
_announceFocusToDial();
if (attachPending) {
for (final machine in machineStates.values) {
- _attachPendingPanes(machine);
+ _attachPendingPanes(machine, retryExisting: false);
}
}
notifyListeners();
@@ -407,7 +407,7 @@ class AppNotifier extends ChangeNotifier {
(p) => p.machineId == machineId && p.agentId == agentId,
);
if (owner == activeSwarm) {
- focusPane(pane.id);
+ focusPane(pane.id, reveal: true);
return true;
}
if (owner.focusedPaneId != pane.id) {
@@ -418,6 +418,7 @@ class AppNotifier extends ChangeNotifier {
_activeSwarmId = owner.id;
railFocused = false;
selectedMachineId = machineId;
+ _paneFocusRequest++;
_persistLayout();
_announceFocusToDial();
notifyListeners();
@@ -569,6 +570,11 @@ class AppNotifier extends ChangeNotifier {
int? get focusedPaneId => activeSwarm.focusedPaneId;
set focusedPaneId(int? value) => activeSwarm.focusedPaneId = value;
+ int _paneFocusRequest = 0;
+
+ /// Explicit navigation must reveal and refocus even an already-selected pane.
+ int get paneFocusRequest => _paneFocusRequest;
+
/// The chosen shape for a grid of this size, or the shipped one.
Map<int, PanePreset> get panePresets => activeSwarm.presets;
@@ -860,7 +866,7 @@ class AppNotifier extends ChangeNotifier {
}
}
- void focusPane(int paneId) {
+ void focusPane(int paneId, {bool reveal = false}) {
if (!panes.any((pane) => pane.id == paneId)) return;
final moved = focusedPaneId != paneId || railFocused;
railFocused = false;
@@ -871,6 +877,7 @@ class AppNotifier extends ChangeNotifier {
if (moved) _previousPaneId = focusedPaneId;
focusedPaneId = paneId;
selectedMachineId = focusedPane?.machineId;
+ if (reveal) _paneFocusRequest++;
if (zoomedPaneId != null) zoomedPaneId = paneId;
// Announced even when this tile was ALREADY focused.
//
@@ -889,11 +896,8 @@ class AppNotifier extends ChangeNotifier {
// real position (`agentId === this.dialFocus` in cableSession), which is the
// only side that can judge, because only it knows where the dial is.
_announceFocusToDial();
- // Only a real move is worth a rebuild.
- if (moved) {
- _persistLayout();
- notifyListeners();
- }
+ if (moved) _persistLayout();
+ if (moved || reveal) notifyListeners();
}
/// Tell the local daemon which agent this window is looking at, so the dial follows it.
@@ -3494,6 +3498,7 @@ class AppNotifier extends ChangeNotifier {
} else if (terminal.status != TerminalSessionStatus.opening &&
terminal.status != TerminalSessionStatus.controlling &&
terminal.status != TerminalSessionStatus.resyncing) {
+ if (!_canAttachPane(existing)) return;
// A healthy pane is focus-only: opening the same daemon controller a
// second time would take over its own first stream. A frozen/closed
// pane is different — the explicit retry action needs a fresh session.
@@ -4216,11 +4221,14 @@ class AppNotifier extends ChangeNotifier {
/// and the machine's terminal protocol has been negotiated — become true at
/// different moments, and a machine that goes away and returns has to be able
/// to re-arrive at them.
- void _attachPendingPanes(MachineState machine) {
+ void _attachPendingPanes(MachineState machine, {bool retryExisting = true}) {
final machineId = machine.machine.machineId;
for (final pane in allPanes.toList()) {
if (!panes.contains(pane) && pane.session == null) continue;
if (pane.machineId != machineId) continue;
+ // Navigation may mount a new view; it must never retry a retained stream
+ // or discard its output while the machine is unavailable.
+ if (!retryExisting && pane.session != null) continue;
if (!_paneNeedsAttach(pane)) continue;
// Covers a tile that never attached AND one holding a stream the machine
// lost. Only the first used to be covered, and the second is why a
@@ -4254,10 +4262,22 @@ class AppNotifier extends ChangeNotifier {
/// already lost or closed, so a close addressed to it would at best be
/// ignored and at worst land on whatever took its place.
Future<void> _reattachPane(TerminalPane pane) async {
+ if (!_canAttachPane(pane)) return;
await _detachSession(pane, sendClose: false);
await _attachSession(pane);
}
+ bool _canAttachPane(TerminalPane pane) {
+ if (_disposed || !allPanes.contains(pane)) return false;
+ final machine = machineStates[pane.machineId];
+ return machine != null &&
+ machine.nodeOnline != false &&
+ machine.terminalCapabilityAvailable &&
+ !(machine.isRemote && !machine.isLocalMachine && machine.needsLink) &&
+ (!machine.isLocalMachine || machine.usesLocalTransport) &&
+ machine.agents.any((a) => a.id == pane.agentId && a.terminalAvailable);
+ }
+
/// Resolve a dial agent to the machine that owns it.
///
/// New CLIs state the machine explicitly. Older CLIs only sent an agent id;
diff --git a/desktop/lib/state/swarm_navigation.dart b/desktop/lib/state/swarm_navigation.dart
index c16d633e4..fbc1ef7c3 100644
--- a/desktop/lib/state/swarm_navigation.dart
+++ b/desktop/lib/state/swarm_navigation.dart
@@ -243,6 +243,8 @@ Future<bool> activateSwarmDestination(
if (destination.isSwarm) {
if (!app.swarms.any((s) => s.id == destination.swarmId)) return false;
app.selectSwarm(destination.swarmId!, attachPending: false);
+ final pane = app.focusedPane;
+ if (pane != null) app.focusPane(pane.id, reveal: true);
return true;
}
if (app.revealAgentView(
@@ -266,6 +268,13 @@ Future<bool> activateSwarmDestination(
destination.agentId!,
swarmId: destinationSwarmId,
);
+ if (app.activeSwarmId == destinationSwarmId) {
+ final pane = app.focusedPane;
+ if (pane?.machineId == destination.machineId &&
+ pane?.agentId == destination.agentId) {
+ app.focusPane(pane!.id, reveal: true);
+ }
+ }
return app.swarms.any(
(s) =>
s.id == destinationSwarmId &&
diff --git a/desktop/lib/widgets/pane_grid.dart b/desktop/lib/widgets/pane_grid.dart
index 6160fe85b..1d2bc8a1e 100644
--- a/desktop/lib/widgets/pane_grid.dart
+++ b/desktop/lib/widgets/pane_grid.dart
@@ -219,6 +219,9 @@ class _SwarmCanvasState extends State<_SwarmCanvas> {
final _scroll = ScrollController(keepScrollOffset: false);
final _offsets = <String, double>{};
late String _activeId = widget.notifier.activeSwarmId;
+ late int _focusRequest = widget.notifier.paneFocusRequest;
+ Size? _viewportSize;
+ bool _focusRevealPending = false;
@override
void initState() {
@@ -235,6 +238,7 @@ class _SwarmCanvasState extends State<_SwarmCanvas> {
widget.notifier.addListener(_onAppChanged);
_offsets.clear();
_activeId = widget.notifier.activeSwarmId;
+ _focusRequest = widget.notifier.paneFocusRequest;
if (_scroll.hasClients) _scroll.jumpTo(0);
}
}
@@ -250,9 +254,51 @@ class _SwarmCanvasState extends State<_SwarmCanvas> {
final open = app.swarms.map((s) => s.id).toSet();
_offsets.removeWhere((id, _) => !open.contains(id));
}
+ if (_focusRequest != app.paneFocusRequest) {
+ _focusRequest = app.paneFocusRequest;
+ _focusRevealPending = true;
+ _revealFocusedPane();
+ }
setState(() {});
}
+ void _revealFocusedPane({bool correctingLayout = false}) {
+ final viewport = _viewportSize;
+ if (viewport == null || !_scroll.hasClients) return;
+ final app = widget.notifier;
+ final panes = app.panes
+ .where((p) => app.zoomedPaneId == null || p.id == app.zoomedPaneId)
+ .toList();
+ final index = panes.indexWhere((p) => p.id == app.focusedPaneId);
+ if (index < 0) return;
+ final geometry = _SwarmGeometry(
+ count: panes.length,
+ viewport: viewport,
+ preset: app.presetFor(panes.length),
+ minimum: _MinTile.of(),
+ );
+ final rect = geometry.rectangles[index];
+ final current = _scroll.offset;
+ final offset = rect.top < current || rect.height > viewport.height
+ ? rect.top
+ : rect.bottom > current + viewport.height
+ ? rect.bottom - viewport.height
+ : current;
+ final target = offset.clamp(
+ 0.0,
+ (geometry.height - viewport.height).clamp(0.0, double.infinity),
+ );
+ if (target != current) {
+ if (correctingLayout) {
+ // The incoming viewport size will lay out the scroll view immediately
+ // after this LayoutBuilder. Correct without notifying during layout.
+ _scroll.position.correctPixels(target);
+ } else {
+ _scroll.jumpTo(target);
+ }
+ }
+ }
+
void _onFontChanged() => setState(() {});
@override
@@ -263,8 +309,8 @@ class _SwarmCanvasState extends State<_SwarmCanvas> {
super.dispose();
}
- /// Cache the healthy terminal path when focus/discovery changes no visible
- /// presentation. Connection/setup views still read their complete state.
+ /// Cache retained terminal presentation, including read-only output.
+ /// Never-attached connection/setup views still read their complete state.
/// Theme/font dependencies continue updating retained descendants directly.
Object? _presentation(TerminalPane pane, bool visible) {
if (!visible) return null;
@@ -274,32 +320,31 @@ class _SwarmCanvasState extends State<_SwarmCanvas> {
.where((a) => a.id == pane.agentId)
.firstOrNull;
final session = pane.session;
- if (machine == null ||
- agent == null ||
- session == null ||
- machine.nodeOnline == false ||
- machine.needsLink ||
- (machine.isLocalMachine && !machine.usesLocalTransport) ||
- !agent.terminalAvailable ||
- session.status != TerminalSessionStatus.controlling) {
- return Object();
- }
+ if (session == null) return Object();
return (
notifier: app,
- machine: machine.machine,
- local: machine.isLocalMachine,
+ machine: machine?.machine,
+ local: machine?.isLocalMachine,
+ online: machine?.nodeOnline,
+ needsLink: machine?.needsLink,
+ localTransport: machine?.usesLocalTransport,
agent: agent,
- project: machine.projectOf(agent),
+ project: agent == null ? null : machine?.projectOf(agent),
session: session,
terminal: session.terminal,
name: session.agentName,
+ status: session.status,
+ error: session.errorMessage ?? session.errorCode,
link: session.linkMode,
upload: session.uploadProgress,
focused: app.isPaneFocused(pane.id),
+ focusRequest: app.isPaneFocused(pane.id) ? app.paneFocusRequest : 0,
single: app.panes.length == 1,
pinned: app.isPanePinned(pane),
composer: pane.composerVisible,
- blocked: app.questionFor(pane.machineId, agent.id) != null,
+ blocked:
+ app.questionFor(pane.machineId, pane.agentId ?? session.agentId) !=
+ null,
dragging: widget.dragging,
);
}
@@ -308,6 +353,12 @@ class _SwarmCanvasState extends State<_SwarmCanvas> {
Widget build(BuildContext context) => LayoutBuilder(
builder: (context, constraints) {
final app = widget.notifier;
+ final viewportChanged = _viewportSize != constraints.biggest;
+ _viewportSize = constraints.biggest;
+ if (_focusRevealPending && viewportChanged) {
+ _revealFocusedPane(correctingLayout: true);
+ }
+ _focusRevealPending = false;
final visible = [
for (final pane in app.panes)
if (app.zoomedPaneId == null || pane.id == app.zoomedPaneId) pane,
@@ -892,13 +943,96 @@ class _PaneContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
final machine = notifier.stateOf(pane.machineId);
- void close() => notifier.closePane(pane.id);
-
+ final session = pane.session;
final wantedAgentId = pane.agentId;
+ final agent = machine?.agents
+ .where((agent) => agent.id == wantedAgentId)
+ .firstOrNull;
+ final agentName = agent?.name;
+ void close() => notifier.closePane(pane.id);
+ final needsLink =
+ machine != null &&
+ machine.isRemote &&
+ !machine.isLocalMachine &&
+ machine.needsLink;
+ final offline =
+ machine != null &&
+ (machine.nodeOnline == false ||
+ (machine.isLocalMachine && !machine.usesLocalTransport));
+
+ // Availability changes the header and input permission, never the renderer's
+ // ancestry. Retained output, selection, scroll and Find stay in this view.
+ if (session != null) {
+ final TerminalNotice? notice;
+ if (machine == null) {
+ notice = (
+ label: 'Unavailable',
+ icon: Icons.cloud_off,
+ detail: 'Waiting for this machine. Retained output is read only.',
+ );
+ } else if (needsLink) {
+ notice = (
+ label: 'Link required',
+ icon: Icons.link_off,
+ detail:
+ '${machine.machine.displayName} needs linking. Retained output is read only.',
+ );
+ } else if (offline) {
+ notice = (
+ label: 'Offline',
+ icon: Icons.cloud_off,
+ detail:
+ '${machine.machine.displayName} is offline. Retained output is read only.',
+ );
+ } else if (agent == null || !agent.terminalAvailable) {
+ notice = (
+ label: 'Unavailable',
+ icon: Icons.terminal,
+ detail:
+ agent?.terminalUnavailableReason ??
+ 'This agent is unavailable on ${machine.machine.displayName}. Retained output is read only.',
+ );
+ } else if (agent.launchState == 'failed') {
+ notice = (
+ label: 'Start failed',
+ icon: Icons.error_outline,
+ detail:
+ agent.launchDetail ??
+ 'The engine failed to start. Terminal output is preserved.',
+ );
+ } else {
+ notice = null;
+ }
+ return LayoutBuilder(
+ builder: (context, constraints) => TerminalPanel(
+ notifier: notifier,
+ session: session,
+ focused: visible && notifier.isPaneFocused(pane.id),
+ focusRequest: notifier.isPaneFocused(pane.id)
+ ? notifier.paneFocusRequest
+ : 0,
+ visible: visible,
+ compactHeader: swarmMode,
+ composerVisible: pane.composerVisible,
+ readOnly: notice != null,
+ notice: notice,
+ onToggleComposer: () => notifier.toggleComposer(pane.id),
+ onClose: single && !swarmMode ? null : close,
+ pinned: notifier.isPanePinned(pane),
+ onTogglePin: single ? null : () => notifier.togglePinPane(pane.id),
+ onRendererFocus: () => notifier.focusPane(pane.id),
+ paneDrag: single
+ ? null
+ : PaneDragHandle(
+ ref: PaneDragRef(paneId: pane.id),
+ size: constraints.biggest,
+ ),
+ ),
+ );
+ }
+ // A never-attached view has no output to preserve: keep its setup guidance.
if (machine == null) {
- // The ordinary state of a restored tile for the first moments of a launch,
- // and of a tile whose machine is briefly out of the list.
return _PaneStatus(
title: wantedAgentId ?? pane.machineId,
icon: Icons.hourglass_empty,
@@ -907,19 +1041,6 @@ class _PaneContent extends StatelessWidget {
busy: true,
);
}
-
- final agent = wantedAgentId == null
- ? null
- : machine.agents
- .where((agent) => agent.id == wantedAgentId)
- .firstOrNull;
- final agentName = agent?.name;
-
- // Deliberately NOT gated on isLinkPromptDismissed: dismissing only suppresses the popup (see
- // showLinkMachineScreenDialog / HomeScreen._maybeShowLinkDialog) — the tile's own status stays
- // honest about the machine actually being unlinked regardless.
- final needsLink =
- machine.isRemote && !machine.isLocalMachine && machine.needsLink;
if (needsLink) {
return _PaneStatus(
title: agentName ?? machine.machine.displayName,
@@ -929,10 +1050,6 @@ class _PaneContent extends StatelessWidget {
onClose: single && !swarmMode ? null : close,
);
}
-
- final offline =
- machine.nodeOnline == false ||
- (machine.isLocalMachine && !machine.usesLocalTransport);
if (offline) {
return _Guide(
single: single && !swarmMode,
@@ -949,10 +1066,6 @@ class _PaneContent extends StatelessWidget {
),
);
}
-
- // A machine tile that has nothing left to report. It arrived to carry a
- // link prompt or a setup form; once those are answered it has said all it
- // has to say, and the person can drag an agent into it.
if (wantedAgentId == null) {
return _PaneStatus(
title: machine.machine.displayName,
@@ -961,7 +1074,6 @@ class _PaneContent extends StatelessWidget {
onClose: close,
);
}
-
if (agentName == null) {
return _PaneStatus(
title: wantedAgentId,
@@ -970,7 +1082,6 @@ class _PaneContent extends StatelessWidget {
onClose: close,
);
}
-
if (agent != null && !agent.terminalAvailable) {
return _PaneStatus(
title: agentName,
@@ -981,93 +1092,16 @@ class _PaneContent extends StatelessWidget {
onClose: close,
);
}
-
- final session = pane.session;
- if (session == null) {
- return _PaneStatus(
- title: agentName,
- icon: Icons.hourglass_empty,
- message: 'Attaching…',
- onClose: single && !swarmMode ? null : close,
- busy: true,
- );
- }
-
- // LayoutBuilder ONLY to learn this tile's size, for the drag ghost to be
- // cut to. Asking the render object instead — `key.currentContext.size` —
- // is what Flutter refuses outright during build: "the size getter should
- // only be called from paint callbacks or interaction event handlers", and
- // it does not warn, it throws, so every pane became a red error box.
- return LayoutBuilder(
- builder: (context, constraints) {
- final launchFailed = agent?.launchState == 'failed';
- final terminal = TerminalPanel(
- notifier: notifier,
- session: session,
- focused: visible && notifier.isPaneFocused(pane.id),
- visible: visible,
- compactHeader: swarmMode,
- composerVisible: !launchFailed && pane.composerVisible,
- readOnly: launchFailed,
- onToggleComposer: launchFailed
- ? null
- : () => notifier.toggleComposer(pane.id),
- onClose: single && !swarmMode ? null : close,
- pinned: notifier.isPanePinned(pane),
- onTogglePin: single ? null : () => notifier.togglePinPane(pane.id),
- onRendererFocus: () => notifier.focusPane(pane.id),
- paneDrag: single
- ? null
- : PaneDragHandle(
- ref: PaneDragRef(paneId: pane.id),
- size: constraints.biggest,
- ),
- );
- if (agent?.launchState != 'failed') return terminal;
- return Column(
- children: [
- _LaunchFailureBanner(
- message: agent?.launchDetail ?? 'The engine failed to start. Terminal output is preserved below.',
- ),
- Expanded(child: terminal),
- ],
- );
- },
+ return _PaneStatus(
+ title: agentName,
+ icon: Icons.hourglass_empty,
+ message: 'Attaching…',
+ onClose: single && !swarmMode ? null : close,
+ busy: true,
);
}
}
-class _LaunchFailureBanner extends StatelessWidget {
- const _LaunchFailureBanner({required this.message});
-
- final String message;
-
- @override
- Widget build(BuildContext context) => Container(
- width: double.infinity,
- color: Theme.of(context).colorScheme.errorContainer,
- padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
- child: Row(
- children: [
- Icon(
- Icons.error_outline,
- size: 16,
- color: Theme.of(context).colorScheme.onErrorContainer,
- ),
- const SizedBox(width: 8),
- Expanded(
- child: Text(
- message,
- style: Theme.of(context).textTheme.bodySmall?.copyWith(
- color: Theme.of(context).colorScheme.onErrorContainer,
- ),
- ),
- ),
- ],
- ),
- );
-}
-
/// Where an OS file (from Finder/Nautilus, not an in-app drag) may be dropped onto this pane.
///
/// Outermost of the three drop layers on a tile ([_SwapZone]/[_DropZone] handle in-app Flutter
diff --git a/desktop/lib/widgets/terminal_composer.dart b/desktop/lib/widgets/terminal_composer.dart
index 70d1eedeb..68cc8322d 100644
--- a/desktop/lib/widgets/terminal_composer.dart
+++ b/desktop/lib/widgets/terminal_composer.dart
@@ -22,10 +22,12 @@ class TerminalComposer extends StatefulWidget {
super.key,
required this.session,
required this.focusNode,
+ this.inputEnabled = true,
});
final TerminalSession session;
final FocusNode focusNode;
+ final bool inputEnabled;
@override
State<TerminalComposer> createState() => _TerminalComposerState();
@@ -90,7 +92,9 @@ class _TerminalComposerState extends State<TerminalComposer> {
bool _sending = false;
Future<void> _submit() async {
- if (_sending) return;
+ if (_sending || !widget.inputEnabled || !widget.session.acceptsInput) {
+ return;
+ }
final text = _controller.text;
if (text.isEmpty) return;
_sending = true;
@@ -121,7 +125,7 @@ class _TerminalComposerState extends State<TerminalComposer> {
@override
Widget build(BuildContext context) {
grid.AppTheme.watch(context);
- final enabled = widget.session.acceptsInput;
+ final enabled = widget.inputEnabled && widget.session.acceptsInput;
final focused = widget.focusNode.hasFocus;
final terminalStyle = terminalFontStore.value;
// No top border of its own: [ComposerGrip] is the line between this and the terminal.
diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dart
index c5745d603..257a1d4b3 100644
--- a/desktop/lib/widgets/terminal_panel.dart
+++ b/desktop/lib/widgets/terminal_panel.dart
@@ -31,6 +31,8 @@ import 'engine_identity.dart';
/// The pane header's own horizontal inset.
const double _stripPadding = 14;
+typedef TerminalNotice = ({String label, String detail, IconData icon});
+
class TerminalPanel extends StatefulWidget {
final AppNotifier notifier;
final TerminalSession session;
@@ -51,10 +53,12 @@ class TerminalPanel extends StatefulWidget {
final bool focused;
final bool visible;
final bool compactHeader;
+ final int focusRequest;
/// Whether this tile's composer textbox is showing. Only consulted for a remote machine.
final bool composerVisible;
final bool readOnly;
+ final TerminalNotice? notice;
/// Flips [composerVisible]. Null where there is no composer to toggle.
final VoidCallback? onToggleComposer;
@@ -74,8 +78,10 @@ class TerminalPanel extends StatefulWidget {
required this.focused,
this.visible = true,
this.compactHeader = false,
+ this.focusRequest = 0,
this.composerVisible = false,
this.readOnly = false,
+ this.notice,
this.onToggleComposer,
this.onClose,
this.pinned = false,
@@ -223,7 +229,8 @@ class _TerminalPanelState extends State<TerminalPanel>
_pressedLink = null;
_observeLinkModifiers(false);
}
- if (!oldWidget.focused && widget.focused) {
+ if (widget.focused &&
+ (!oldWidget.focused || oldWidget.focusRequest != widget.focusRequest)) {
_claimFocusAfterFrame();
}
// Showing or hiding the box changes how many rows the terminal has. Re-measure so the remote
@@ -271,10 +278,7 @@ class _TerminalPanelState extends State<TerminalPanel>
/// one, which is what puts it on the loopback transport.
bool get _showsComposer {
final machineState = widget.notifier.stateOf(widget.session.machineId);
- return machineState != null &&
- !machineState.isLocalMachine &&
- !widget.readOnly &&
- widget.composerVisible;
+ return machineState?.isLocalMachine != true && widget.composerVisible;
}
/// The composer refuses focus while it is disabled, which it is until the stream goes live. When
@@ -290,7 +294,7 @@ class _TerminalPanelState extends State<TerminalPanel>
_composerFocusPending = false;
return;
}
- if (!widget.session.acceptsInput) return;
+ if (widget.readOnly || !widget.session.acceptsInput) return;
_composerFocusPending = false;
// Deferred a frame on purpose. This panel registers its session listener before the composer
// registers its own (a parent's initState runs first), so at this instant the field is still
@@ -298,7 +302,7 @@ class _TerminalPanelState extends State<TerminalPanel>
// composer rebuilds in is what makes the claim actually land.
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted || !widget.focused || !_showsComposer) return;
- if (!widget.session.acceptsInput) return;
+ if (widget.readOnly || !widget.session.acceptsInput) return;
_composerFocus.requestFocus();
});
}
@@ -368,7 +372,7 @@ class _TerminalPanelState extends State<TerminalPanel>
if (_composerFocus.hasFocus) return;
// On a remote pane the box gets the caret, not the terminal. Landing in the terminal would
// hand the user the per-keystroke path by default — the exact cost the box exists to avoid.
- if (_showsComposer) {
+ if (_showsComposer && !widget.readOnly) {
if (widget.session.acceptsInput) {
_composerFocus.requestFocus();
} else {
@@ -1062,32 +1066,6 @@ class _TerminalPanelState extends State<TerminalPanel>
),
),
),
- if (session.status == TerminalSessionStatus.opening ||
- session.status == TerminalSessionStatus.resyncing)
- Positioned(
- top: 12,
- right: 14,
- child: _OverlayBadge(
- label: session.status == TerminalSessionStatus.opening
- ? 'ATTACHING'
- : 'RESYNCING',
- spinning: true,
- ),
- ),
- if (_find == null &&
- (session.status == TerminalSessionStatus.error ||
- session.status == TerminalSessionStatus.takenOver))
- Positioned.fill(
- child: _FrozenOverlay(
- session: session,
- onRetry: () => widget.notifier.selectAgent(
- session.machineId,
- session.agentId,
- ),
- ),
- ),
- // Bottom, not top-right alongside ATTACHING/RESYNCING: the two are not mutually
- // exclusive (a reconnect can happen mid-upload) and must not overlap each other.
if (session.uploadProgress != null || _previewProgress != null)
Positioned(
left: 14,
@@ -1128,7 +1106,11 @@ class _TerminalPanelState extends State<TerminalPanel>
onPressed: widget.onToggleComposer!,
),
if (showComposer)
- TerminalComposer(session: session, focusNode: _composerFocus),
+ TerminalComposer(
+ session: session,
+ focusNode: _composerFocus,
+ inputEnabled: !widget.readOnly,
+ ),
],
),
);
@@ -1153,6 +1135,9 @@ class _TerminalPanelState extends State<TerminalPanel>
session: session,
name: session.agentName,
status: session.status,
+ notice: widget.notice,
+ readOnly: widget.readOnly,
+ error: session.errorMessage ?? session.errorCode,
link: session.linkMode,
machine: machine?.machine,
agent: agent,
@@ -1171,6 +1156,8 @@ class _TerminalPanelState extends State<TerminalPanel>
_header = _TerminalHeader(
notifier: widget.notifier,
session: session,
+ notice: widget.notice,
+ readOnly: widget.readOnly,
compact: widget.compactHeader,
onClose: widget.onClose == null ? null : () => widget.onClose?.call(),
pinned: widget.pinned,
@@ -1191,6 +1178,8 @@ class _TerminalPanelState extends State<TerminalPanel>
class _TerminalHeader extends StatelessWidget {
final AppNotifier notifier;
final TerminalSession session;
+ final TerminalNotice? notice;
+ final bool readOnly;
final VoidCallback? onClose;
final bool pinned;
final bool compact;
@@ -1211,6 +1200,8 @@ class _TerminalHeader extends StatelessWidget {
const _TerminalHeader({
required this.notifier,
required this.session,
+ this.notice,
+ this.readOnly = false,
this.onClose,
this.pinned = false,
this.compact = false,
@@ -1236,30 +1227,41 @@ class _TerminalHeader extends StatelessWidget {
.where((agent) => agent.id == session.agentId)
.firstOrNull
?.codexHome;
- final statusLabel = switch (session.status) {
- TerminalSessionStatus.controlling => 'controlling',
- TerminalSessionStatus.opening => 'attaching',
- TerminalSessionStatus.resyncing => 'resyncing',
- TerminalSessionStatus.takenOver => 'taken over',
- TerminalSessionStatus.error => 'error',
- TerminalSessionStatus.closed => 'closed',
- };
- final statusMark = switch (session.status) {
- TerminalSessionStatus.opening ||
- TerminalSessionStatus.resyncing => SizedBox(
- width: 13,
- height: 13,
- child: CircularProgressIndicator(strokeWidth: 1.7, color: color),
- ),
- TerminalSessionStatus.controlling ||
- TerminalSessionStatus.takenOver ||
- TerminalSessionStatus.error ||
- TerminalSessionStatus.closed => Container(
- width: 8,
- height: 8,
- decoration: BoxDecoration(color: color, shape: BoxShape.circle),
- ),
- };
+ final status =
+ notice ??
+ switch (session.status) {
+ TerminalSessionStatus.controlling => null,
+ TerminalSessionStatus.opening => (
+ label: 'Connecting',
+ icon: Icons.sync,
+ detail:
+ 'Connecting to this terminal. Retained output is read only.',
+ ),
+ TerminalSessionStatus.resyncing => (
+ label: 'Restoring',
+ icon: Icons.sync,
+ detail: 'Restoring this terminal. Retained output is read only.',
+ ),
+ TerminalSessionStatus.takenOver => (
+ label: 'Take control',
+ icon: Icons.lock_outline,
+ detail: 'Read only: another app controls this terminal. Take control moves input ownership to this app.',
+ ),
+ TerminalSessionStatus.error || TerminalSessionStatus.closed => (
+ label: 'Reconnect',
+ icon: Icons.refresh,
+ detail:
+ session.errorMessage ??
+ session.errorCode ??
+ 'This stream is closed. Retained output is read only.',
+ ),
+ };
+ final canReconnect =
+ notice == null &&
+ !readOnly &&
+ (session.status == TerminalSessionStatus.error ||
+ session.status == TerminalSessionStatus.closed ||
+ session.status == TerminalSessionStatus.takenOver);
final machine = notifier.stateOf(session.machineId);
final agent = machine?.agents
.where((a) => a.id == session.agentId)
@@ -1317,7 +1319,7 @@ class _TerminalHeader extends StatelessWidget {
),
),
),
- if (compact && project != null) ...[
+ if (compact && status == null && project != null) ...[
const SizedBox(width: 12),
Flexible(
child: Tooltip(
@@ -1332,7 +1334,7 @@ class _TerminalHeader extends StatelessWidget {
),
),
],
- if (compact) ...[
+ if (compact && status == null) ...[
const SizedBox(width: 12),
Flexible(
child: Tooltip(
@@ -1350,15 +1352,53 @@ class _TerminalHeader extends StatelessWidget {
),
],
const SizedBox(width: 6),
- if (!compact && session.status == TerminalSessionStatus.controlling)
- Padding(padding: const EdgeInsets.all(4), child: statusMark)
- else if (session.status != TerminalSessionStatus.controlling)
- Tooltip(
- message: statusLabel,
- child: Padding(
- padding: const EdgeInsets.all(4),
- child: statusMark,
+ if (status != null)
+ Flexible(
+ fit: FlexFit.tight,
+ child: Align(
+ alignment: Alignment.centerRight,
+ child: Tooltip(
+ message: status.detail,
+ child: TextButton(
+ onPressed: canReconnect
+ ? () => notifier.selectAgent(
+ session.machineId,
+ session.agentId,
+ )
+ : null,
+ style: TextButton.styleFrom(
+ foregroundColor: color,
+ disabledForegroundColor: AppColors.textSoft,
+ minimumSize: Size.zero,
+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,
+ padding: const EdgeInsets.symmetric(
+ horizontal: 6,
+ vertical: 4,
+ ),
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Icon(status.icon, size: 14),
+ const SizedBox(width: 6),
+ Flexible(
+ child: Text(
+ status.label,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: const TextStyle(fontSize: 11),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
),
+ )
+ else if (!compact)
+ Padding(
+ padding: const EdgeInsets.all(4),
+ child: Icon(Icons.circle, size: 8, color: color),
),
// Which of the three paths carries this pane's bytes. Absent for a local machine's own
// terminal, which has no such distinction and so gets no badge.
@@ -1458,54 +1498,7 @@ class _LinkModeMark extends StatelessWidget {
}
}
-class _OverlayBadge extends StatelessWidget {
- final String label;
- final bool spinning;
- const _OverlayBadge({required this.label, required this.spinning});
-
- @override
- Widget build(BuildContext context) {
- grid.AppTheme.watch(context);
- return Container(
- padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 6),
- decoration: BoxDecoration(
- color: grid.AppPalette.panelBg.withValues(alpha: 0.93),
- border: Border.all(color: AppColors.borderStrong),
- // Left at 4 on purpose. This badge is drawn INSIDE a terminal pane, and
- // the pane is off-limits to the app-wide design pass — it is reviewed
- // with the terminal, not with the app's chrome.
- borderRadius: BorderRadius.circular(4),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- if (spinning) ...[
- const SizedBox(
- width: 11,
- height: 11,
- child: CircularProgressIndicator(strokeWidth: 1.5),
- ),
- const SizedBox(width: 7),
- ],
- Text(
- label,
- style: TextStyle(
- color: AppColors.textSoft,
- fontFamily: AppFonts.sans,
- fontSize: 10,
- fontWeight: FontWeight.w700,
- ),
- ),
- ],
- ),
- );
- }
-}
-
-/// Shown while an image/file drag-drop upload is in flight — see [TerminalSession.uploadProgress].
-/// Same container language as [_OverlayBadge] ([email protected], borderStrong border, radius 4,
-/// textSoft label) with a thin [LinearProgressIndicator] in place of a spinner, plus a Cancel
-/// affordance.
+/// Image/file transfer progress with a cancel action, kept in the pane's corner.
class _TransferProgressBadge extends StatelessWidget {
final String label;
final double? fraction;
@@ -1578,67 +1571,6 @@ class _TransferProgressBadge extends StatelessWidget {
}
}
-class _FrozenOverlay extends StatelessWidget {
- final TerminalSession session;
- final VoidCallback onRetry;
- const _FrozenOverlay({required this.session, required this.onRetry});
-
- @override
- Widget build(BuildContext context) {
- grid.AppTheme.watch(context);
- final takenOver = session.status == TerminalSessionStatus.takenOver;
- final accent = takenOver ? AppColors.warning : AppColors.danger;
- return ColoredBox(
- color: grid.AppPalette.windowBg.withValues(alpha: 0.67),
- child: Center(
- child: Container(
- constraints: const BoxConstraints(maxWidth: 440),
- padding: const EdgeInsets.all(18),
- decoration: BoxDecoration(
- color: grid.AppPalette.panelBg,
- border: Border.all(color: const Color(0xff7f1d1d)),
- borderRadius: BorderRadius.circular(6),
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- 'TERMINAL FROZEN',
- style: TextStyle(
- color: accent,
- fontFamily: AppFonts.sans,
- fontSize: 12,
- fontWeight: FontWeight.w700,
- ),
- ),
- const SizedBox(height: 8),
- Text(
- takenOver
- ? 'Another app is controlling this terminal.'
- : session.errorMessage ??
- session.errorCode ??
- 'Stream closed',
- textAlign: TextAlign.center,
- style: TextStyle(
- color: AppColors.textSoft,
- fontFamily: AppFonts.sans,
- fontSize: 11,
- ),
- ),
- const SizedBox(height: 14),
- OutlinedButton.icon(
- onPressed: onRetry,
- icon: Icon(takenOver ? Icons.link : Icons.refresh, size: 16),
- label: Text(takenOver ? 'CONNECT' : 'ATTACH NEW STREAM'),
- ),
- ],
- ),
- ),
- ),
- );
- }
-}
-
/// The whole tile, carried under the cursor.
///
/// ⚠️ THIS IS DRAWN, NOT PHOTOGRAPHED, AND THE PHOTOGRAPH IS WHY. The obvious
diff --git a/desktop/test/swarm_interactions_test.dart b/desktop/test/swarm_interactions_test.dart
index 0b671753d..739bc8aab 100644
--- a/desktop/test/swarm_interactions_test.dart
+++ b/desktop/test/swarm_interactions_test.dart
@@ -272,6 +272,14 @@ void main() {
app.dismissError();
await tester.pump();
expect(updates.last['canFind'], isTrue);
+ app.machineStates['m']!.nodeOnline = false;
+ app.dismissError();
+ await tester.pump();
+ expect(
+ updates.last['canFind'],
+ isTrue,
+ reason: 'Retained offline output stays searchable',
+ );
await native('findTerminal');
await tester.pump();
expect(find.byType(TerminalFindBar), findsOneWidget);
diff --git a/desktop/test/swarm_switcher_test.dart b/desktop/test/swarm_switcher_test.dart
index bd27a30f5..a5387c9b4 100644
--- a/desktop/test/swarm_switcher_test.dart
+++ b/desktop/test/swarm_switcher_test.dart
@@ -4,6 +4,9 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:harness/core/models.dart';
import 'package:harness/state/swarm_navigation.dart';
import 'package:harness/terminal/terminal_binary.dart';
+import 'package:harness/state/pane_preset.dart';
+import 'package:harness/widgets/terminal_panel.dart';
+import 'package:xterm/xterm.dart';
import 'swarm_interactions_test.dart' show chord;
import 'swarm_screen_test.dart' show mount, terminal;
@@ -17,6 +20,115 @@ Finder get selectedRow =>
find.byWidgetPredicate((w) => w is ListTile && w.selected);
void main() {
+ testWidgets('jump reveals an offscreen pane and delivers the first key there', (
+ tester,
+ ) async {
+ final app = createApp();
+ app.machineStates['m']!.nodeOnline = true;
+ final inputs = List.generate(12, (_) => <TerminalBinaryFrame>[]);
+ final sessions = List.generate(12, (i) => terminal('a$i', inputs[i]));
+ for (final session in sessions) {
+ app.adoptSessionForTest(session);
+ }
+ app.setPreset(12, PanePreset.cols2);
+ app.focusPane(app.panes.first.id);
+ await mount(tester, app);
+ await chord(tester, LogicalKeyboardKey.keyP);
+ await tester.enterText(jumpField, 'Agent 11');
+ await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ final pane = find.byWidgetPredicate(
+ (w) => w is TerminalPanel && identical(w.session, sessions.last),
+ );
+ final rect = tester.getRect(pane);
+ expect(rect.top, greaterThanOrEqualTo(40));
+ expect(rect.bottom, lessThanOrEqualTo(800));
+ final view = tester.widget<TerminalView>(
+ find.descendant(of: pane, matching: find.byType(TerminalView)),
+ );
+ expect(
+ view.focusNode!.hasFocus,
+ isTrue,
+ reason:
+ 'model ${app.focusedPaneId} / primary ${FocusManager.instance.primaryFocus}',
+ );
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
+ await tester.pump(const Duration(milliseconds: 10));
+ expect(inputs.last.single.bytes, [27, 91, 68]);
+ expect(inputs.take(11).every((input) => input.isEmpty), isTrue);
+ final gridScroll = tester
+ .widget<SingleChildScrollView>(find.byType(SingleChildScrollView).first)
+ .controller!;
+ for (final crossSwarm in [false, true]) {
+ if (crossSwarm) {
+ app.newSwarm();
+ } else {
+ gridScroll.jumpTo(0);
+ }
+ await tester.pump();
+ await chord(tester, LogicalKeyboardKey.keyP);
+ await tester.enterText(jumpField, 'Agent 11');
+ await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ expect(tester.getRect(pane).bottom, lessThanOrEqualTo(800));
+ expect(tester.getRect(pane).top, greaterThanOrEqualTo(40));
+ expect(
+ tester
+ .widget<TerminalView>(
+ find.descendant(of: pane, matching: find.byType(TerminalView)),
+ )
+ .focusNode!
+ .hasFocus,
+ isTrue,
+ );
+ }
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+
+ testWidgets('jump focuses a same-Swarm pane, repeats focus and follows zoom', (
+ tester,
+ ) async {
+ final app = createApp();
+ app.machineStates['m']!.nodeOnline = true;
+ final inputs = List.generate(3, (_) => <TerminalBinaryFrame>[]);
+ final sessions = List.generate(3, (i) => terminal('a$i', inputs[i]));
+ for (final session in sessions) {
+ app.adoptSessionForTest(session);
+ }
+ await mount(tester, app);
+ for (final i in [0, 0, 1]) {
+ if (i == 1) app.toggleZoomPane();
+ await chord(tester, LogicalKeyboardKey.keyP);
+ await tester.enterText(jumpField, 'Agent $i');
+ await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ final view = tester.widget<TerminalView>(
+ find.byWidgetPredicate(
+ (w) =>
+ w is TerminalView && identical(w.terminal, sessions[i].terminal),
+ ),
+ );
+ expect(
+ view.focusNode!.hasFocus,
+ isTrue,
+ reason:
+ 'model ${app.focusedPaneId} / primary ${FocusManager.instance.primaryFocus}',
+ );
+ if (i == 1) expect(app.zoomedPaneId, app.panes[i].id);
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
+ await tester.pump(const Duration(milliseconds: 10));
+ }
+ expect(inputs[0], hasLength(2));
+ expect(inputs[1].single.bytes, [27, 91, 68]);
+ expect(inputs[2], isEmpty);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+
testWidgets(
'jump opens in one frame, owns typing, cancels, and leaves Add separate',
(tester) async {
diff --git a/desktop/test/terminal_find_test.dart b/desktop/test/terminal_find_test.dart
index 389dcc58b..936079cf3 100644
--- a/desktop/test/terminal_find_test.dart
+++ b/desktop/test/terminal_find_test.dart
@@ -326,7 +326,8 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
expect(session.status, TerminalSessionStatus.takenOver);
- expect(find.text('TERMINAL FROZEN'), findsOneWidget);
+ expect(find.text('TERMINAL FROZEN'), findsNothing);
+ expect(find.text('Take control'), findsOneWidget);
expect(input, isEmpty);
await tester.pumpWidget(const SizedBox());
app.dispose();
diff --git a/desktop/test/terminal_offline_view_test.dart b/desktop/test/terminal_offline_view_test.dart
new file mode 100644
index 000000000..398993c1b
--- /dev/null
+++ b/desktop/test/terminal_offline_view_test.dart
@@ -0,0 +1,140 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/terminal/terminal_binary.dart';
+import 'package:harness/terminal/terminal_session.dart';
+import 'package:harness/widgets/terminal_composer.dart';
+import 'package:harness/widgets/terminal_find_bar.dart';
+import 'package:xterm/xterm.dart';
+
+import 'swarm_interactions_test.dart' show chord;
+import 'swarm_screen_test.dart' show mount, terminal;
+import 'swarm_state_test.dart' show createApp;
+import 'terminal_find_test.dart' show findField, finishFind, terminalView;
+
+void main() {
+ testWidgets(
+ 'offline output keeps its renderer, scroll, selection and Find across tabs',
+ (tester) async {
+ final app = createApp();
+ final machine = app.machineStates['m']!..nodeOnline = true;
+ final input = <TerminalBinaryFrame>[];
+ final session = terminal('a0', input);
+ session.terminal.write(
+ List.generate(180, (i) => 'Retained marker $i\r\n').join(),
+ );
+ final pane = app.adoptSessionForTest(session);
+ final first = app.activeSwarmId;
+ await mount(tester, app);
+ final view = terminalView(tester, session);
+ final scroll = view.widget.scrollController!;
+ scroll.jumpTo(80);
+ final selection = session.terminal.buffer.createAnchor(0, 1);
+ final end = session.terminal.buffer.createAnchor(8, 1);
+ view.widget.controller!.setSelection(selection, end);
+ await tester.pump();
+ final size = tester.getSize(find.byType(TerminalView));
+ session.transportLost('Connection interrupted');
+ machine.nodeOnline = false;
+ app.dismissError();
+ await tester.pump();
+ expect(terminalView(tester, session), same(view));
+ expect(scroll.offset, 80);
+ expect(tester.getSize(find.byType(TerminalView)), size);
+ expect(view.widget.controller!.selection, isNotNull);
+ expect(find.text('Offline'), findsOneWidget);
+ expect(find.text('TERMINAL FROZEN'), findsNothing);
+ await chord(tester, LogicalKeyboardKey.keyF);
+ await tester.enterText(findField, 'marker');
+ await finishFind(tester);
+ expect(
+ tester
+ .widget<TerminalFindBar>(find.byType(TerminalFindBar))
+ .search
+ .count,
+ 180,
+ );
+ app.newSwarm();
+ await tester.pump();
+ app.selectSwarm(first);
+ await tester.pump();
+ await finishFind(tester);
+ expect(pane.session, same(session));
+ expect(terminalView(tester, session), same(view));
+ expect(session.status, TerminalSessionStatus.error);
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ expect(scroll.offset, 80);
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
+ await tester.pump(const Duration(milliseconds: 10));
+ expect(input, isEmpty);
+ await app.selectAgent('m', 'a0');
+ expect(
+ pane.session,
+ same(session),
+ reason: 'An unavailable retry must not discard retained output',
+ );
+ machine.nodeOnline = true;
+ app.dismissError();
+ await tester.pump();
+ expect(terminalView(tester, session), same(view));
+ expect(find.text('Reconnect'), findsOneWidget);
+ expect(session.status, TerminalSessionStatus.error);
+ await tester.pumpWidget(const SizedBox());
+ selection.dispose();
+ end.dispose();
+ app.dispose();
+ },
+ );
+
+ testWidgets(
+ 'availability changes preserve an unsent composer draft and disable input',
+ (tester) async {
+ final app = createApp();
+ final machine = app.machineStates['m']!..nodeOnline = true;
+ final input = <TerminalBinaryFrame>[];
+ final session = terminal('a0', input);
+ final pane = app.adoptSessionForTest(session)..composerVisible = true;
+ await mount(tester, app);
+ final field = find.descendant(
+ of: find.byType(TerminalComposer),
+ matching: find.byType(TextField),
+ );
+ await tester.enterText(field, 'Unsent instructions');
+ final text = tester.widget<TextField>(field).controller!;
+ final renderer = terminalView(tester, session);
+ final size = tester.getSize(find.byType(TerminalView));
+ machine.nodeOnline = false;
+ app.dismissError();
+ await tester.pump();
+ expect(tester.widget<TextField>(field).controller, same(text));
+ expect(text.text, 'Unsent instructions');
+ expect(tester.widget<TextField>(field).enabled, isFalse);
+ expect(terminalView(tester, session), same(renderer));
+ expect(tester.getSize(find.byType(TerminalView)), size);
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump(const Duration(milliseconds: 10));
+ expect(input, isEmpty);
+ app.machineStates.remove('m');
+ app.dismissError();
+ await tester.pump();
+ expect(tester.widget<TextField>(field).controller, same(text));
+ expect(find.text('Unavailable'), findsOneWidget);
+ app.machineStates['m'] = machine..nodeOnline = true;
+ machine.needsLink = true;
+ app.dismissError();
+ await tester.pump();
+ expect(find.text('Link required'), findsOneWidget);
+ expect(pane.session, same(session));
+ expect(tester.widget<TextField>(field).enabled, isFalse);
+ machine.needsLink = false;
+ app.dismissError();
+ await tester.pump();
+ expect(tester.widget<TextField>(field).enabled, isTrue);
+ expect(text.text, 'Unsent instructions');
+ expect(input, isEmpty);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
+}
diff --git a/desktop/test/terminal_pane_test.dart b/desktop/test/terminal_pane_test.dart
index 903727ac6..cfca5baa6 100644
--- a/desktop/test/terminal_pane_test.dart
+++ b/desktop/test/terminal_pane_test.dart
@@ -9,6 +9,7 @@ import 'package:harness/state/app_state.dart';
import 'package:harness/state/pane_layout_store.dart';
import 'package:harness/state/terminal_pane.dart';
import 'package:harness/terminal/terminal_session.dart';
+import 'package:harness/ws/ws_conn.dart';
/// In-memory stand-in so a layout test never reaches the developer's own
/// ~/.harness state file.
@@ -25,13 +26,39 @@ class _MemoryStore implements LocalKeyValueStore {
Future<void> delete(String key) async => values.remove(key);
}
-AppNotifier _notifier({PaneLayoutStore? layout}) => AppNotifier(
+AppNotifier _notifier({
+ PaneLayoutStore? layout,
+ WsConn Function(String)? connectionForTest,
+}) => AppNotifier(
config: AppConfig.dev,
authSession: AuthSession(),
configStore: null,
paneLayoutStore: layout,
+ connectionForTest: connectionForTest,
);
+class _TerminalConnection extends WsConn {
+ _TerminalConnection()
+ : super(
+ wsBaseUrl: 'ws://fixture.invalid',
+ autonomousEnv: 'test',
+ machineId: 'm1',
+ accessTokenProvider: (_, _) async => '',
+ onAuthFailure: (_) {},
+ onEvent: (_) {},
+ onStatus: (_) {},
+ );
+ final sent = <String>[];
+ @override
+ Future<bool> sendTerminalFrame(
+ String type,
+ Map<String, dynamic> payload,
+ ) async {
+ sent.add(type);
+ return true;
+ }
+}
+
Agent _agent(String id) => Agent.fromJson({
'id': id,
'name': id,
@@ -372,25 +399,37 @@ void main() {
},
);
- test('selecting an agent whose stream died rebuilds it, not just the ring', () async {
- final app = _notifier();
- _machine(app, 'm1', ['a']);
- final pane = app.adoptSessionForTest(_session('m1', 'a'));
- final dead = pane.session!;
- dead.transportLost('Harness reconnected; restoring terminal…');
-
- // What the tile's own retry button does. An early return on "already on
- // screen" made that button move a focus ring and nothing else, leaving the
- // frozen overlay exactly where it was.
- await app.selectAgent('m1', 'a');
-
- expect(
- identical(app.panes.single.session, dead),
- isFalse,
- reason: 'the dead session must be replaced, not re-focused',
- );
- app.dispose();
- });
+ test(
+ 'retry preserves offline output and opens a new stream only when ready',
+ () async {
+ final connection = _TerminalConnection();
+ final app = _notifier(connectionForTest: (_) => connection);
+ final machine = _machine(app, 'm1', ['a']);
+ final pane = app.adoptSessionForTest(_session('m1', 'a'));
+ final dead = pane.session!;
+ dead.transportLost('Harness reconnected; restoring terminal…');
+
+ dead.terminal.write('Last useful result');
+ await app.selectAgent('m1', 'a');
+ expect(pane.session, same(dead));
+ expect(dead.terminal.buffer.getText(), contains('Last useful result'));
+ expect(connection.sent, isEmpty);
+ machine.nodeOnline = true;
+ machine.terminalCapabilityAvailable = true;
+ final retry = app.selectAgent('m1', 'a');
+ await Future<void>.delayed(Duration.zero);
+ expect(pane.session, isNot(same(dead)));
+ pane.session!.reportViewport(120, 40);
+ await retry;
+ expect(
+ connection.sent.where((type) => type == 'terminal_open'),
+ hasLength(1),
+ );
+ expect(pane.session!.status, TerminalSessionStatus.opening);
+ app.dispose();
+ await connection.close();
+ },
+ );
test('the composer toggle is remembered across a restart', () async {
final storage = _MemoryStore();
diff --git a/desktop/test/terminal_panel_presentation_test.dart b/desktop/test/terminal_panel_presentation_test.dart
index fdb8b1e8f..323a2bd05 100644
--- a/desktop/test/terminal_panel_presentation_test.dart
+++ b/desktop/test/terminal_panel_presentation_test.dart
@@ -58,7 +58,13 @@ void main() {
session.status = TerminalSessionStatus.takenOver;
revision.value = 3;
await tester.pump();
- expect(find.byTooltip('taken over'), findsOneWidget);
+ expect(find.text('Take control'), findsOneWidget);
+ expect(
+ find.byTooltip(
+ 'Read only: another app controls this terminal. Take control moves input ownership to this app.',
+ ),
+ findsOneWidget,
+ );
await tester.pumpWidget(const SizedBox());
revision.dispose();
session.dispose();
diff --git a/docs/harness-v2-developer-tools-research.md b/docs/harness-v2-developer-tools-research.md
index cacc2952a..3657a7a5f 100644
--- a/docs/harness-v2-developer-tools-research.md
+++ b/docs/harness-v2-developer-tools-research.md
@@ -50,7 +50,8 @@ The opportunity for Harness is to make movement among real agents across real ma
| **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. |
| **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. |
-| **Implemented; verify in daily use** | Terminal Find with `Cmd+F`, `Cmd+G` and `Cmd+Shift+G` | Search retained output and move between literal matches without sending input. Escape restores the previous scroll position and prompt focus. The compact field uses the existing header, then disappears. These familiar bindings are documented by [Apple Terminal](https://support.apple.com/en-euro/guide/terminal/trmlshtcts/mac) and [Chrome](https://support.google.com/chrome/answer/157179?co=GENIE.Platform%3DDesktop&hl=en). Offline panes that show a connection guide still need retained-output support. |
+| **Implemented; verify in daily use** | Terminal Find with `Cmd+F`, `Cmd+G` and `Cmd+Shift+G` | Search retained output and move between literal matches without sending input. Escape restores the previous scroll position and prompt focus. The compact field uses the existing header, then disappears. These familiar bindings are documented by [Apple Terminal](https://support.apple.com/en-euro/guide/terminal/trmlshtcts/mac) and [Chrome](https://support.google.com/chrome/answer/157179?co=GENIE.Platform%3DDesktop&hl=en). Retained offline panes now remain searchable; never-attached panes retain setup guidance. |
+| **Removed blocking chrome** | Full-pane frozen and reconnect overlays | Read-only status and explicit Reconnect/Take control actions live in the header. Retained output, selection, search and unsent composer text survive unavailable-machine presentation. Ordinary tab navigation never retries a dead stream. |
| **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.md
index fe4b67172..0845b9e5e 100644
--- a/docs/harness-v2-performance.md
+++ b/docs/harness-v2-performance.md
@@ -169,13 +169,21 @@ Background-output comparison before/after line versioning and Find:
All hidden-output samples still reported zero hidden renderers needing layout and no scheduled frame. Several median timings increased by about 4–5%; these shared-workstation observations do not isolate that difference or establish zero overhead. Logs: `/private/tmp/harness-v2-find-benchmark.log` and `/private/tmp/harness-v2-find-output-before.log`. The earlier overlapping benchmark run was replaced by this sequential result.
-The final full suite passes 1,035 tests with one skip; the analyzer reports zero errors/warnings and 12 existing vendored infos. Find checks cover literal/wide-character mapping, reflow and buffer changes, 50,000 repeated matches, cancellation/eviction, immediate navigation during output, first-frame opening, no resize or agent input, hidden suspension, keyframe focus preservation, read-only ownership, and a narrow field at 2× text. Offline panes still show a connection guide in place of their retained renderer, so offline search is not yet available.
+The final full suite passes 1,035 tests with one skip; the analyzer reports zero errors/warnings and 12 existing vendored infos. Find checks cover literal/wide-character mapping, reflow and buffer changes, 50,000 repeated matches, cancellation/eviction, immediate navigation during output, first-frame opening, no resize or agent input, hidden suspension, keyframe focus preservation, read-only ownership, and a narrow field at 2× text. The following continuation keeps retained offline renderers available to Find; never-attached views still need setup guidance.
Native tab hover now hides both adjacent separators, uses a 28-point shape with 12-point corners, and aligns 13-point text with a 10-point close symbol. The title and paragraph layout are cached until the name or selection changes. Before/after native component renders were inspected, alongside an isolated Flutter Find render; neither substitutes for live native interaction or physical-display timing.
+## Focus handoff and retained offline views
+
+The reported Cmd+P bug reproduced in isolated tests. Closing the picker could restore the old terminal's FocusNode, whose callback changed the model back to that pane. Both jump and Needs input now clear that restoration before applying the destination. An explicit focus request also reaches an already-selected pane. The canvas reveals the target during the same frame, with a layout correction when a New swarm's full-size content becomes the inset terminal canvas. Ordinary tab switches continue restoring their own saved canvas offsets.
+
+Retained terminals stay mounted while offline, unlinked or temporarily missing from discovery. Their header carries read-only status, so no overlay blocks output or changes terminal dimensions. Cached presentation includes availability and error details; unchanged offline panels can reuse their widget tree too. The optional composer stays mounted and disabled, preserving its unsent draft. Native Find remains enabled for retained buffers. Neither navigation nor unavailable retry attempts discard the session or start a replacement stream.
+
+The full desktop suite passes 1,039 tests with one skip; the final combined suite and isolated render passes 1,040 with one skip. Focus regressions cover repeated and same-Swarm jumps, zoom, offscreen/cross-Swarm targets, the first input frame and unavailable destinations. Offline checks preserve renderer identity, dimensions, selection, scroll, Find and composer text while refusing input. The ready retry fixture verifies that an explicit retry still opens a fresh stream when prerequisites return. Actual reattachment still replaces the session before its first keyframe; retaining context through that handoff remains follow-up work. These are behavior and frame-order checks, not physical-display latency measurements.
+
## Native follow-up
-The 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 optimized real-data app builds and runs locally. The native tab/canvas polish was visually reviewed before the navigation and retained-canvas continuations; CUA access returned after the pane-focus Release rebuild. The empty wallpaper and tab strip were captured; newer navigation 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 195 assertions total, including hover separators and native Find/attention shortcuts and modal guards. No Flutter engine, account or terminal is accessed.
diff --git a/docs/harness-v2-progress.md b/docs/harness-v2-progress.md
index 0cae484ac..e1b1f3fac 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 terminal Find and native hover continuation. This is a working preview, not a release.
+Updated 2026-09-13 after the pane-focus and disconnected-terminal continuation. This is a working preview, not a release.
## Resume here
@@ -17,10 +17,12 @@ Updated 2026-09-13 after the terminal Find and native hover continuation. This i
- 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. That continuation passed 1,014 tests with one skip; the current full suite passes 1,035 with one skip.
-- The final Release preview was rebuilt and normally relaunched; PID **20082** 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 inventory after this rebuild still listed the preview as running, alongside an unlaunched backup with the same bundle ID. 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 Find/jump/Needs input interaction, latest hover refinement, 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.
-- Cmd+F now searches retained output in the focused terminal; Cmd+G / Cmd+Shift+G and Enter / Shift+Enter move through matches. Escape restores the previous scroll position and input focus. The field occupies the existing header without resizing the terminal. Find pauses and releases its index when hidden or covered. A keyframe keeps the field, caret and query; read-only rendered panes remain searchable without taking control. Offline panes currently replace retained output with a connection guide, so offline search remains a separate follow-up.
+- 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,039 with one skip.
+- The pane-focus Release preview was rebuilt and normally relaunched; PID **41137** was the sole V2 instance at the last check. Revalidate before any later restart. CUA access returned after this rebuild: the real New swarm, native tab strip and edge-to-edge wallpaper were captured. The user is actively changing window size and Swarms; refresh UI state before actions. Live picker focus verification is still in progress. Earlier `cgWindowNotFound` failures no longer establish a current block. First-frame renderer pixels and native caret messages remain covered by isolated Flutter checks.
+- Cmd+F now searches retained output in the focused terminal; Cmd+G / Cmd+Shift+G and Enter / Shift+Enter move through matches. Escape restores the previous scroll position and input focus. The field occupies the existing header without resizing the terminal. Find pauses and releases its index when hidden or covered. A keyframe keeps the field, caret and query; read-only rendered panes remain searchable without taking control. Retained offline output is now searchable; only never-attached panes keep the setup guide.
- The latest hover pass uses 13-point native titles, 14-point leading space inside the 28-point hover shape, a 12-point corner radius and a 10-point close symbol. Both neighboring separators disappear on hover. The title layout is cached across hover redraws. Native selected shoulders still meet the flat canvas. Isolated native before/after images were inspected; CUA still could not capture the live window after the normal Release relaunch.
+- The user reported that Cmd+P did not focus the selected agent. New tests reproduced two failures: the closing picker could restore the old terminal and overwrite the selected pane, and an offscreen result stayed outside the viewport. Both pickers now clear that stale focus restoration before activating their result. Explicit jumps refocus even the currently selected pane and reveal it before paint, accounting for changed canvas padding when leaving New swarm. Checks cover same-Swarm, repeated, zoomed, offscreen and cross-Swarm jumps, including the first key arriving only at the destination.
+- Retained sessions now keep the same terminal renderer through offline, missing-machine, link-required and unavailable-agent presentation. The large frozen overlay and redundant connection overlays are removed; status and explicit Reconnect/Take control actions occupy the header. Offline output stays selectable/searchable, and disabled composer text remains intact. Tab switches no longer retry existing dead streams; unavailable retries keep the old session. A never-attached pane still shows setup guidance.
- Continue implementation here. Do not create another repository or fork for V2.
```bash
@@ -167,7 +169,7 @@ 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,035 passed, 1 skipped** on the final terminal Find and native hover code, including terminal, modal, persistence, layout and shortcut regressions. |
+| Full Flutter suite | **1,039 passed, 1 skipped** on the pane-focus and disconnected-terminal 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. |
@@ -192,10 +194,18 @@ Tests now exercise the actual V2 welcome/settings/linking flow. Usage pricing ag
Evidence on this Mac under `/private/tmp`:
+- `harness-v2-jump-focus-before.log`: reproduces stale terminal focus and an offscreen selected pane; the extended viewport case also caught the padding change when leaving New swarm.
+- `harness-v2-focus-offline-tests.log`: 41 focused terminal, picker, Find, composer and retained-view checks.
+- `harness-v2-focus-offline-full-tests.log`: 1,039 passed, one existing skip.
+- `harness-v2-focus-offline-final.log`: final full suite plus isolated offline render, **1,040 passed, one skip** after the header alignment refinement; `harness-offline-review.png` inspected.
+- `harness-v2-release-build.log`: successful local Release build and normal relaunch of this continuation.
+- `harness-v2-focus-offline-analyze.log`: zero errors/warnings and 12 existing vendored infos.
+- `harness-v2-offline-render.log` / `harness-offline-review.png`: an isolated read-only terminal/Find render; no real agent data or native-window capture.
+
- `harness-v2-find-full-tests.log`: 1,035 passed, one existing skip.
- `harness-v2-find-focused.log`: 99 focused checks, including one isolated visual fixture; `harness-v2-find-visual-tests.log`: final six-case render/find pass.
- `harness-v2-find-native.log`: 195 AppKit checks, including hidden native window geometry and hover separators.
-- `harness-v2-find-analyze.log`: current diagnostics, zero errors/warnings and 12 existing vendored infos.
+- `harness-v2-find-analyze.log`: earlier Find diagnostics, zero errors/warnings and 12 existing vendored infos.
- `harness-v2-find-benchmark.log`: sequential three-case terminal Find/background-output run; `harness-v2-find-output-before.log`: pre-index versioning background baseline. Timings and limits are in the performance notes.
- `harness-titlebar-before.png`, `harness-titlebar-after.png`, `harness-find-review.png`: inspected isolated native/Flutter renders, not live app captures.
@@ -236,12 +246,12 @@ Earlier logs contain superseded failures. Temporary logs and toolchains are loca
## Remaining work
-1. Restore CUA access to the current Release preview and review the new jump workflow, stable canvas, restored terminal output/caret, actual project starters and keyboard navigation. The tool currently reports `cgWindowNotFound`; the process is running. The user can change window size and Swarms; re-read UI state before actions and preserve their arrangement.
+1. Continue live CUA review of the jump workflow, stable canvas, restored terminal output/caret, project starters and keyboard navigation. Access returned after the pane-focus rebuild. The user is actively changing window size and Swarms; re-read UI state before actions and preserve their arrangement.
2. Audit native drag/reorder, overflow, close-last-tab, renaming and accessibility without changing the user's saved agent memberships. Keep any integration runner separate and out of the foreground review app.
3. Measure native terminal input and tab-switch responsiveness before making end-to-end latency claims. Headless CPU benchmarks are now recorded. Preserve the existing immediate first-input flush and shared retained renderers.
4. Visually confirm app-menu modal behavior and overflow accessibility in AppKit; route/shortcut behavior is covered by passing Flutter tests.
5. Build/review Linux and Windows when their toolchains are available. Remote full project/branch metadata requires daemons running the new wire format; do not upgrade them automatically.
-6. Preserve retained terminal output when an offline pane shows a connection guide, then enable offline Find without reconnecting or taking control. Current Find searches only the buffer rendered by TerminalPanel, not remote files or unretained history.
+6. Preserve the retained buffer, Find context and composer draft through an actual stream reattachment until its replacement keyframe arrives. This pass preserves them while unavailable and during navigation; a ready retry still creates a new TerminalSession. Exercise actual reconnect ordering with a disposable local protocol fixture, never a real agent.
7. Continue the agreed goal and apply the latest steering. The research proposes a focused roadmap and specific subtraction candidates; do not mistake proposals for already-implemented removals.
## Toolchain and workflow