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.

Preserve shared session views when closing panes and tabs (#942)

Dee37240dd875c8
diff --git a/desktop/design/desktop-design-system.md b/desktop/design/desktop-design-system.md
index b92df84ac..535d11aa9 100644
--- a/desktop/design/desktop-design-system.md
+++ b/desktop/design/desktop-design-system.md
@@ -352,6 +352,10 @@ inner edge beneath their 1-point rim. Only their frame changes: terminal content
input, selection and status typography remain the terminal's own. AppKit mirrors
these shared geometry values; Flutter uses AppDesktop directly.
+Closing a tab leaves the remaining tab in its normal selected appearance.
+Show a focus outline when a tab control is deliberately reached by keyboard
+navigation; the temporary input hold after Close does not add one.
+
**Pane header** — terminal panes show agent, model and close at every width.
Splitting is revealed at the pane edges; zoom remains available through menus,
command search and shortcuts. Keep split, add and zoom icons out of the header.
diff --git a/desktop/design/icon-design-system.md b/desktop/design/icon-design-system.md
index 48c1b8513..18bb82aa5 100644
--- a/desktop/design/icon-design-system.md
+++ b/desktop/design/icon-design-system.md
@@ -86,7 +86,7 @@ These are content or identities, not a second action-icon library:
number. Layout thumbnails use the real pane geometry. Connection dots,
progress indicators and activity marks encode state.
- Harness activity has one vocabulary in `harness_activity.dart`: `?`, `✗`,
- `✓`, the ten-frame Braille spinner, `◌`, `||`, `⊘`, and unmarked idle. Native
+ `✓`, the ten-frame Braille spinner, `◌`, `■`, `⊘`, and unmarked idle. Native
tabs and menu notifications share `HarnessNativeActivity`; Dart pane headers
share `ActivityMark`. Bridge payloads use `nativeActivityPayload` and the
same `activityColor`, including the monochrome preference. Do not substitute
diff --git a/desktop/design/terminal-workspace.md b/desktop/design/terminal-workspace.md
index 1950f11cb..aaf1c075b 100644
--- a/desktop/design/terminal-workspace.md
+++ b/desktop/design/terminal-workspace.md
@@ -18,6 +18,11 @@ monospace elsewhere when it helps readability.
Do not recreate, resize, or send input to a terminal merely because app chrome
opens or closes. Preserve terminal ownership, pending streams, viewer-owner
relationships, and pane state. Closing a pane removes its view immediately.
+When a session is shown in another pane or tab, Close removes only the chosen
+view and keeps the shared terminal alive. Closing the last view saves and stops
+the session, using the existing confirmation when it is working. A tab close
+applies this rule separately to each session. Recheck remaining views after
+any wait for inspection or confirmation, before requesting a stop.
## Keep the workspace structure
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 44b5962d8..e26d7f1fd 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -263,8 +263,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
final _shellFocus = FocusNode(debugLabel: 'Tab shell');
/// Where the keyboard waits after the active tab closes
- /// ([AppNotifier.tabStripFocused]): the strip drawn here, or the native one
- /// in the title bar, which draws its selected tab as focused.
+ /// ([AppNotifier.tabStripFocused]). This passive hold has no focus outline;
+ /// tab controls show one when explicitly reached by keyboard navigation.
final _tabStripFocus = FocusNode(
debugLabel: 'Tab strip',
skipTraversal: true,
@@ -1848,7 +1848,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
'searchTooltip': _commandTooltip('Open Harness', 'harnesses.list'),
'storeTooltip': _commandTooltip('Explore Harness Store', 'app.store'),
'devicesVisible': app.devicesEnabled,
- // The selected tab is drawn with keyboard focus: ⏎ goes into it.
+ // Native accessibility explains that ⏎ enters the selected tab.
'tabsFocused': app.tabStripFocused && _tabStripFocus.hasPrimaryFocus,
// Only once the slot is shown: until then (and whenever daemons are
// off) native lays out the bar it had before daemons existed.
@@ -2599,11 +2599,22 @@ class _SwarmScreenState extends State<SwarmScreen> {
Future<bool> _reviewSessionClose(
List<(String, Agent)> targets, {
String? tabName,
+ bool Function(String machineId, String agentId)? canStop,
}) async {
final requests = [
for (final (machine, agent) in targets)
app.prepareSessionClose(machine, agent),
];
+ // This gate belongs to closing views. The session stop protocol and its
+ // activity checks remain unchanged, including terminal and DSH handling.
+ Future<Map<String, dynamic>> request(int index, String mode) {
+ final target = targets[index];
+ if (canStop?.call(target.$1, target.$2.id) == false) {
+ return Future.value({'keptRunning': true, 'activity': 'idle'});
+ }
+ return requests[index](mode);
+ }
+
final activities = List.filled(targets.length, 'unknown');
final showMachines = targets.map((target) => target.$1).toSet().length > 1;
Future<String?> choose({String? error}) async {
@@ -2613,14 +2624,15 @@ class _SwarmScreenState extends State<SwarmScreen> {
context,
[
for (var i = 0; i < targets.length; i++)
- SessionCloseItem(
- name: targets[i].$2.displayName,
- activity: activities[i],
- machineName: showMachines
- ? app.stateOf(targets[i].$1)?.machine.displayName ??
- targets[i].$1
- : null,
- ),
+ if (activities[i] != 'kept_running')
+ SessionCloseItem(
+ name: targets[i].$2.displayName,
+ activity: activities[i],
+ machineName: showMachines
+ ? app.stateOf(targets[i].$1)?.machine.displayName ??
+ targets[i].$1
+ : null,
+ ),
],
tabName: tabName,
keymap: _keymap,
@@ -2648,13 +2660,17 @@ class _SwarmScreenState extends State<SwarmScreen> {
Future<String?> inspectFrom(int start) async {
for (var i = start; i < requests.length; i++) {
if (!mounted) return null;
- final state = await requests[i]('inspect');
+ final state = await request(i, 'inspect');
if (!mounted) return null;
if (state['error'] != null) {
return state['detail'] as String? ??
'Could not check ${targets[i].$2.displayName}. Nothing else will be stopped.';
}
- activities[i] = state['activity'] as String? ?? 'unknown';
+ activities[i] =
+ state['keptRunning'] == true ||
+ canStop?.call(targets[i].$1, targets[i].$2.id) == false
+ ? 'kept_running'
+ : state['activity'] as String? ?? 'unknown';
}
return null;
}
@@ -2665,12 +2681,18 @@ class _SwarmScreenState extends State<SwarmScreen> {
final inspectionError = await inspectFrom(0);
if (!mounted) return false;
if (inspectionError != null) return closeAfterError(inspectionError);
- var stopNow = activities.any((activity) => activity != 'idle');
+ var stopNow = activities.any(
+ (activity) => activity != 'idle' && activity != 'kept_running',
+ );
if (stopNow && await choose() != 'now') return false;
for (var i = 0; i < requests.length; i++) {
if (!mounted) return false;
- var result = await requests[i](stopNow ? 'now' : 'idle');
+ var result = await request(i, stopNow ? 'now' : 'idle');
if (!mounted) return false;
+ if (result['keptRunning'] == true) {
+ activities[i] = 'kept_running';
+ continue;
+ }
// An idle-only close may race with new work. Review every remaining
// session together, and disclose any sessions that already stopped.
if (result['error'] == 'SESSION_NOT_IDLE') {
@@ -2680,9 +2702,13 @@ class _SwarmScreenState extends State<SwarmScreen> {
if (inspectionError != null) return closeAfterError(inspectionError);
if (await choose() != 'now') return false;
stopNow = true;
- result = await requests[i]('now');
+ result = await request(i, 'now');
}
if (!mounted) return false;
+ if (result['keptRunning'] == true) {
+ activities[i] = 'kept_running';
+ continue;
+ }
if (result['closed'] != true && result['deferred'] != true) {
activities[i] = 'unconfirmed';
return closeAfterError(
@@ -7767,10 +7793,6 @@ class _SwarmScreenState extends State<SwarmScreen> {
),
tooltip: tabHint.isEmpty ? null : tabHint,
activityLabel: activity?.label,
- highlighted:
- selected &&
- app.tabStripFocused &&
- _tabStripFocus.hasPrimaryFocus,
onSelect: _shortcutsEnabled
? () => app.selectSwarm(swarm.id)
: null,
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dart
index abd6bfed4..bbcce3be8 100644
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@ -621,7 +621,11 @@ class AppNotifier extends ChangeNotifier {
final _agentPauses = <(String, String), Future<String?>>{};
/// The workspace supplies presentation; the model owns target identity and completion.
- Future<bool> Function(List<(String, Agent)>, {String? tabName})?
+ Future<bool> Function(
+ List<(String, Agent)>, {
+ String? tabName,
+ bool Function(String machineId, String agentId)? canStop,
+ })?
reviewSessionClose;
final _viewCloseRequests = <String, Future<void>>{};
final _closingViewAgents = <(String, String), int>{};
@@ -2100,19 +2104,26 @@ class AppNotifier extends ChangeNotifier {
}
}
- /// Explicit user Close. The reusable Harness Monitor dismisses its views;
- /// ordinary sessions are saved and stopped before their views close.
+ /// Close removes these views. A session stops only when this removes its
+ /// last view across all tabs; shared views keep their live terminal.
Future<void> requestCloseSwarm(String id) {
final tab = swarms.where((s) => s.id == id).firstOrNull;
if (tab == null) return Future.value();
final captured = tab.panes.toList();
- return _requestViewClose('tab:$id', tab, captured, () async {
- if (tab.panes.length != captured.length ||
- !captured.every(tab.panes.contains)) {
- return;
- }
- await closeSwarm(id);
- }, tabName: tab.name);
+ return _requestViewClose(
+ 'tab:$id',
+ tab,
+ captured,
+ () async {
+ if (tab.panes.length != captured.length ||
+ !captured.every(tab.panes.contains)) {
+ return;
+ }
+ await closeSwarm(id);
+ },
+ tabName: tab.name,
+ wholeTab: true,
+ );
}
Future<void> requestClosePane(int paneId) {
@@ -2141,14 +2152,44 @@ class AppNotifier extends ChangeNotifier {
List<TerminalPane> closing,
Future<void> Function() finish, {
String? tabName,
+ bool wholeTab = false,
}) {
if (_disposed) return Future.value();
if (_viewCloseRequests[key] case final pending?) return pending;
+ bool canStop(String machineId, String agentId) {
+ if (!swarms.contains(tab) ||
+ (wholeTab &&
+ (tab.panes.length != closing.length ||
+ !closing.every(tab.panes.contains)))) {
+ return false;
+ }
+ bool showsAgent(TerminalPane pane) =>
+ pane.machineId == machineId &&
+ (pane.agentId ?? pane.ownerAgentId) == agentId;
+ if (!closing.any(
+ (pane) => showsAgent(pane) && tab.panes.contains(pane),
+ )) {
+ return false;
+ }
+ return !swarms.any(
+ (other) => other.panes.any(
+ (pane) =>
+ showsAgent(pane) &&
+ !(identical(other, tab) && closing.contains(pane)),
+ ),
+ );
+ }
+
final targets = <(String, Agent)>[];
final seen = <(String, String)>{};
for (final pane in closing) {
final id = pane.agentId;
- if (pane.isWeb || id == null || !seen.add((pane.machineId, id))) continue;
+ if (pane.isWeb ||
+ id == null ||
+ !seen.add((pane.machineId, id)) ||
+ !canStop(pane.machineId, id)) {
+ continue;
+ }
final machine = stateOf(pane.machineId);
final agent = machine?.agents.where((a) => a.id == id).firstOrNull;
if (machine?.machine.isShared == true ||
@@ -2164,8 +2205,14 @@ class AppNotifier extends ChangeNotifier {
targets.add((pane.machineId, agent));
}
final revision = _authRevision;
- for (final (machine, agent) in targets) {
- final target = (machine, agent.id);
+ // The whole captured view belongs to Close, including sessions already
+ // stopped or served by an older CLI. Peer pruning must not trim its undo.
+ final held = {
+ for (final pane in closing)
+ if (pane.agentId ?? pane.ownerAgentId case final String id)
+ (pane.machineId, id),
+ };
+ for (final target in held) {
_closingViewAgents[target] = (_closingViewAgents[target] ?? 0) + 1;
}
final completion = Completer<void>();
@@ -2176,31 +2223,15 @@ class AppNotifier extends ChangeNotifier {
try {
if (targets.isNotEmpty &&
(reviewSessionClose == null ||
- !await reviewSessionClose!(targets, tabName: tabName))) {
+ !await reviewSessionClose!(
+ targets,
+ tabName: tabName,
+ canStop: canStop,
+ ))) {
return;
}
if (!_authWorkCurrent(revision) || !swarms.contains(tab)) return;
await finish();
- // Close is global: the acknowledged session also leaves any other
- // tab holding it. Preserve each layout through the normal close path.
- for (final (machineId, agent) in targets) {
- final current = stateOf(machineId)?.agents
- .where((candidate) => candidate.id == agent.id)
- .firstOrNull;
- if (current?.isStopped != true ||
- current?.createdAt != agent.createdAt ||
- current?.sessionId != agent.sessionId) {
- continue;
- }
- for (final other in swarms.toList()) {
- for (final pane in other.panes.toList()) {
- if (!_authWorkCurrent(revision)) return;
- if (pane.machineId == machineId && pane.agentId == agent.id) {
- await closePane(pane.id, swarmId: other.id);
- }
- }
- }
- }
} catch (_) {
if (_authWorkCurrent(revision)) {
_lastError = 'Could not close this session safely. Check its state and try again.';
@@ -2208,8 +2239,7 @@ class AppNotifier extends ChangeNotifier {
notifyListeners();
}
} finally {
- for (final (machine, agent) in targets) {
- final target = (machine, agent.id);
+ for (final target in held) {
final remaining = (_closingViewAgents[target] ?? 1) - 1;
if (remaining == 0) {
_closingViewAgents.remove(target);
@@ -2220,6 +2250,11 @@ class AppNotifier extends ChangeNotifier {
if (identical(_viewCloseRequests[key], request)) {
_viewCloseRequests.remove(key);
}
+ // A cancelled or partial close keeps its remaining local views. Once
+ // the operation releases them, share that intent with the desk too.
+ if (_authWorkCurrent(revision) && swarms.contains(tab)) {
+ _persistLayout();
+ }
completion.complete();
}
})(),
@@ -2373,6 +2408,7 @@ class AppNotifier extends ChangeNotifier {
target.focusedPaneId ??= target.panes.firstOrNull?.id;
_paneFocusRequest++;
selectSwarm(target.id);
+ _openSavedPanes(target.panes);
return;
}
final restored =
@@ -2412,6 +2448,7 @@ class AppNotifier extends ChangeNotifier {
restored.zoomedPaneId = paneAt(saved.zoom);
swarms.insert(saved.index.clamp(0, swarms.length), restored);
selectSwarm(restored.id);
+ _openSavedPanes(restored.panes);
}
/// Reopen the chosen closure, or the newest closure for Cmd-Shift-T.
@@ -2506,9 +2543,48 @@ class AppNotifier extends ChangeNotifier {
_settlePins();
_paneFocusRequest++;
selectSwarm(target.id);
+ _openSavedPanes([pane]);
return true;
}
+ void _openSavedPanes(Iterable<TerminalPane> restored) {
+ for (final pane in restored) {
+ final agent = stateOf(pane.machineId)?.agents
+ .where((agent) => agent.id == pane.agentId)
+ .firstOrNull;
+ if (agent?.isStopped == true) unawaited(openSavedPane(pane.id));
+ }
+ }
+
+ /// Explicit reopening resumes the saved conversation in its existing slot.
+ /// A delayed response cannot follow focus into another tab or reopen a pane
+ /// the person has since closed. Resume receipts deduplicate repeated clicks.
+ Future<void> openSavedPane(int paneId) async {
+ final pane = allPanes.where((pane) => pane.id == paneId).firstOrNull;
+ final agentId = pane?.agentId;
+ if (_disposed || pane == null || agentId == null) return;
+ final revision = _authRevision;
+ final request = resumeAgent(pane.machineId, agentId);
+ notifyListeners();
+ final result = await request;
+ if (!_authWorkCurrent(revision) ||
+ !allPanes.contains(pane) ||
+ pane.agentId != agentId) {
+ return;
+ }
+ if (result.error case final error?) {
+ _lastError = error;
+ _lastErrorRetryable = result.retryable;
+ notifyListeners();
+ return;
+ }
+ pane.claimOnFirstAttach = true;
+ if (panes.contains(pane) && _paneNeedsAttach(pane) && _canAttachPane(pane)) {
+ pane.claimOnFirstAttach = false;
+ await _reattachPane(pane, intent: AttachIntent.person);
+ }
+ }
+
/// Capture the destination before any network wait or tab change.
Future<void> addAgentToSwarm(
String machineId,
@@ -11479,6 +11555,9 @@ class AppNotifier extends ChangeNotifier {
return true;
}
+ AgentRestartAttempt? pendingAgentRestart(String machineId, String agentId) =>
+ _agentRestarts[(machineId, agentId)];
+
/// Attach to a running harness or resume its saved conversation immediately.
Future<RestartAgentResult> resumeAgent(String machineId, String agentId) {
if (pendingAgentPause(machineId, agentId) != null) {
@@ -11876,10 +11955,12 @@ class AppNotifier extends ChangeNotifier {
final _agentChanges = <(String, String), _AgentChange>{};
- bool _keepsSwitchPane(TerminalPane pane) =>
- _agentChanges[(pane.machineId, pane.agentId ?? pane.ownerAgentId)]
- ?.preservingViews ==
- true;
+ bool _keepsPendingAgent(String machineId, String? agentId) =>
+ _closingViewAgents.containsKey((machineId, agentId)) ||
+ _agentChanges[(machineId, agentId)]?.preservingViews == true;
+
+ bool _keepsPendingPane(TerminalPane pane) =>
+ _keepsPendingAgent(pane.machineId, pane.agentId ?? pane.ownerAgentId);
Future<Map<String, dynamic>> Function(String sourceId, String engine)?
changeCompanionAgent;
@@ -14163,9 +14244,9 @@ class AppNotifier extends ChangeNotifier {
/// Called from [_persistLayout]: whatever just changed, said to the desk as ops.
void _deskQueueDiff() {
if (!_desk.enabled) return;
- // A peer can prune the stopped source while its replacement starts.
- // Keep that pane locally, but never advertise the stopped reference
- // again. The successful switch publishes the replacement in its slot.
+ // A peer can prune stopped sessions while Close or a replacement is still
+ // pending. Keep their local slots for history, without publishing them back
+ // to the desk. The operation owns the final layout change.
final projection = <DeskTab>[];
for (final tab in _deskProjection()) {
final synced = _desk.synced.where((t) => t.id == tab.id).firstOrNull;
@@ -14174,8 +14255,7 @@ class AppNotifier extends ChangeNotifier {
.where(
(p) =>
known.contains(p.key) ||
- _agentChanges[(p.machineId, p.agentId)]?.preservingViews !=
- true,
+ !_keepsPendingAgent(p.machineId, p.agentId),
)
.toList();
if (panes.length == tab.panes.length) {
@@ -14318,14 +14398,15 @@ class AppNotifier extends ChangeNotifier {
final kept = <Swarm>[];
for (final swarm in swarms) {
if (_deskTracks(swarm) && !targetById.containsKey(swarm.id)) {
- if (!swarm.panes.any(_keepsSwitchPane)) {
+ if (!swarm.panes.any(_keepsPendingPane)) {
released.addAll(swarm.panes);
continue;
}
- // Only the in-flight replacement owns a temporary local slot.
+ // Close keeps its complete layout until its acknowledgement can save
+ // history. A replacement similarly owns its temporary local slot.
// Other panes still follow closures from another window.
for (final pane in swarm.panes.toList()) {
- if (_keepsSwitchPane(pane)) continue;
+ if (_keepsPendingPane(pane)) continue;
swarm.remove(pane);
released.add(pane);
}
@@ -14355,7 +14436,7 @@ class AppNotifier extends ChangeNotifier {
for (final pane in swarm.panes.toList()) {
if (pane.agentId == null) continue;
if (wanted.contains('${pane.machineId}\u0000${pane.agentId}')) continue;
- if (_keepsSwitchPane(pane)) continue;
+ if (_keepsPendingPane(pane)) continue;
swarm.remove(pane);
released.add(pane);
for (final viewer in swarm.panes.toList()) {
@@ -14448,7 +14529,7 @@ class AppNotifier extends ChangeNotifier {
final holdingSlot = swarm.panes.any(
(pane) =>
pane.agentId != null &&
- _keepsSwitchPane(pane) &&
+ _keepsPendingPane(pane) &&
!wanted.contains('${pane.machineId}\u0000${pane.agentId}'),
);
if (layoutMoved &&
diff --git a/desktop/lib/state/harness_activity.dart b/desktop/lib/state/harness_activity.dart
index bcd30831e..36108b6de 100644
--- a/desktop/lib/state/harness_activity.dart
+++ b/desktop/lib/state/harness_activity.dart
@@ -14,7 +14,7 @@ enum HarnessActivity {
starting('◌', 'Starting'),
unknown('◌', 'Status unavailable'),
idle('', 'Idle'),
- paused('×', 'Stopped'),
+ paused('■', 'Stopped'),
offline('⊘', 'Offline');
const HarnessActivity(this.mark, this.label);
diff --git a/desktop/lib/widgets/harness_activity_mark.dart b/desktop/lib/widgets/harness_activity_mark.dart
index 9e0a6dc8d..93f2fc0e8 100644
--- a/desktop/lib/widgets/harness_activity_mark.dart
+++ b/desktop/lib/widgets/harness_activity_mark.dart
@@ -172,7 +172,7 @@ class _ActivityMarkState extends State<ActivityMark> {
? activitySpinnerFrames[clock.frame]
: widget.activity.mark;
final cell = workspaceBarCellSizeOf(context);
- var style =
+ final style =
workspaceBarTextStyle(
color: widget.color,
emphasized: widget.emphasized,
@@ -185,14 +185,6 @@ class _ActivityMarkState extends State<ActivityMark> {
'DejaVu Sans',
],
);
- if (widget.activity == HarnessActivity.paused) {
- // Two short ASCII pipes, tightened into the same cell as every other
- // mark. Keep these metrics in sync with SwarmTabButton's native drawing.
- style = style.copyWith(
- fontSize: workspaceBarFontSize * .65,
- letterSpacing: -cell.width * .25,
- );
- }
final child = Semantics(
label: widget.activity.label,
child: ExcludeSemantics(
diff --git a/desktop/lib/widgets/pane_grid.dart b/desktop/lib/widgets/pane_grid.dart
index 143b8b710..a42c1d869 100644
--- a/desktop/lib/widgets/pane_grid.dart
+++ b/desktop/lib/widgets/pane_grid.dart
@@ -1609,6 +1609,19 @@ class _PaneContent extends StatelessWidget {
detail:
'${machine.machine.displayName} is offline. Retained output is read only.',
);
+ } else if (agent?.isStopped == true) {
+ final opening = notifier.pendingAgentRestart(
+ pane.machineId,
+ wantedAgentId!,
+ );
+ notice = terminalNotice(
+ label: opening?.busy == true ? 'Opening' : 'Stopped',
+ icon: AppIcons.terminal,
+ detail: opening?.result?.error ?? 'Open to continue your saved conversation. Retained output is read only.',
+ actionLabel: opening?.busy == true ? null : 'Open',
+ onAction: () => notifier.openSavedPane(pane.id).ignore(),
+ banner: true,
+ );
} else if (agent == null || !agent.terminalAvailable) {
notice = terminalNotice(
label: 'Unavailable',
@@ -1813,6 +1826,24 @@ class _PaneContent extends StatelessWidget {
onClose: close,
);
}
+ if (agent?.isStopped == true) {
+ final opening = notifier.pendingAgentRestart(
+ pane.machineId,
+ wantedAgentId,
+ );
+ return _PaneStatus(
+ activity: activityMark,
+ title: agentName,
+ icon: AppIcons.terminal,
+ message: opening?.busy == true
+ ? 'Opening saved conversation…'
+ : opening?.result?.error ?? 'This harness is stopped. Open it to continue your saved conversation.',
+ onClose: close,
+ busy: opening?.busy == true,
+ actionLabel: opening?.busy == true ? null : 'Open',
+ onAction: () => notifier.openSavedPane(pane.id).ignore(),
+ );
+ }
if (agent != null && !agent.terminalAvailable) {
return _PaneStatus(
activity: activityMark,
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index 8c7dff2a9..8568d6219 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -2229,9 +2229,8 @@ private final class SwarmTabStrip: NSView {
updateDaemon(state["daemon"] as? [String: Any] ?? [:])
let rows = state["tabs"] as? [[String: Any]] ?? []
let nextActiveId = state["activeId"] as? String ?? ""
- // A closed tab left the keyboard on the strip (Dart's `tabStripFocused`):
- // the selected tab is drawn focused, and Return goes into it. The keys stay
- // with Flutter, so every shortcut keeps working while the strip holds them.
+ // A closed tab left the keyboard with Flutter (Dart's `tabStripFocused`).
+ // Expose the Return hint without drawing a focus ring for this passive hold.
let tabsFocused = state["tabsFocused"] as? Bool == true
revealActiveAfterLayout = revealActiveAfterLayout || nextActiveId != activeId
activeId = nextActiveId
@@ -2679,7 +2678,7 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
return NSRect(x: indicatorRect.midX - Self.activityWidth / 2,
y: 0, width: Self.activityWidth, height: bounds.height)
}
- /// The strip holds the keyboard on this tab; Flutter still owns the keys.
+ /// Flutter holds the keyboard after Close; accessibility explains Return.
var keyboardFocus = false { didSet { if keyboardFocus != oldValue { needsDisplay = true; updateAccessibility() } } }
var showsDivider = false { didSet { if showsDivider != oldValue { needsDisplay = true } } }
var contentCenterY: CGFloat = 20
@@ -2872,7 +2871,7 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
foreground.withAlphaComponent(0.16).setFill()
NSRect(x: bounds.maxX - 0.5, y: 10, width: 1, height: max(0, bounds.height - 20)).fill()
}
- if actionsEnabled && (keyboardFocus || selectButton.hasKeyboardFocus) {
+ if actionsEnabled && selectButton.hasKeyboardFocus {
NSColor.controlAccentColor.setStroke()
let focus = NSBezierPath(roundedRect: NSRect(x: Self.shoulder + 2, y: 3,
width: max(0, bounds.width - 2 * (Self.shoulder + 2)), height: max(0, bounds.height - Self.topInset - 6)),
@@ -2991,6 +2990,11 @@ private class SwarmTabActionButton: SwarmIconButton {
}
private final class SwarmSelectButton: SwarmTabActionButton {
+ // The parent draws the complete tab, including hover, press and focus.
+ // NSButton can retain an on-state after activation and paint a second
+ // rounded background even though this selection target is borderless.
+ override func draw(_ dirtyRect: NSRect) {}
+
override func mouseDown(with event: NSEvent) {
guard isEnabled else { return }
highlight(true)
diff --git a/desktop/test/desk_sync_test.dart b/desktop/test/desk_sync_test.dart
index cf1ab9ed6..b72f65021 100644
--- a/desktop/test/desk_sync_test.dart
+++ b/desktop/test/desk_sync_test.dart
@@ -11,6 +11,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:harness/api/api_client.dart';
import 'package:harness/auth/auth_session.dart';
import 'package:harness/core/config.dart';
+import 'package:harness/core/models.dart';
import 'package:harness/state/desk_sync.dart';
import 'package:harness/state/pane_arrangement.dart';
import 'package:harness/state/pane_layout_store.dart';
@@ -78,6 +79,89 @@ void main() {
setUpAll(() async {
if (captureDir != null) await loadPreviewFonts();
});
+ for (final confirm in [true, false]) {
+ test(
+ 'desk pruning during close preserves the full tab (confirm: $confirm)',
+ () async {
+ final api = _DeskApi();
+ final app = createApp()..api = api;
+ addTearDown(app.dispose);
+ app.stateOf('m')!.agents = [
+ for (var i = 0; i < 4; i++)
+ Agent(
+ id: 'a$i',
+ name: 'Work $i',
+ engine: 'codex',
+ sessionId: 'conversation-$i',
+ closeSupported: true,
+ terminalAvailable: i != 3,
+ status: i == 3 ? 'stopped' : 'active',
+ createdAt: DateTime.utc(2026, 10, 6),
+ ),
+ ];
+ await app.deskStartForTest();
+ for (var i = 0; i < 4; i++) {
+ app.adoptSessionForTest(terminal('a$i', []));
+ }
+ final work = app.activeSwarm;
+ app.renameSwarm(work.id, 'Hardware');
+ final shape = PaneArrangement(PanePreset.quad.tilesFor(4));
+ work.savePaneSizes('4:manual', shape);
+ await app.deskFlushForTest();
+ final original = work.panes.toList();
+ final paneIds = original.map((p) => p.agentId).toList();
+ var reviewed = 0;
+ app.reviewSessionClose = (targets, {tabName, canStop}) async {
+ reviewed++;
+ expect(targets, hasLength(3));
+ for (var i = 0; i < targets.length; i++) {
+ final (machineId, agent) = targets[i];
+ await app.handleEventForTest(machineId, {
+ 'type': 'agent_deleted',
+ 'payload': {'agentId': agent.id},
+ });
+ // Another window receives that stop and prunes its shared desk.
+ api.doc = DeskDoc(
+ revision: api.doc!.revision + 1,
+ tabs: [
+ if (i < targets.length - 1)
+ tab(
+ work.id,
+ name: 'Hardware',
+ custom: true,
+ agents: paneIds.skip(i + 1).cast<String>().toList(),
+ ),
+ ],
+ );
+ await app.deskFetchForTest();
+ expect(work.panes, original);
+ expect(work.paneSizes['4:manual']!.tiles, shape.tiles);
+ expect(app.swarms, contains(work));
+ expect(app.deskSyncForTest.pending, isEmpty);
+ expect(api.doc!.tabs.expand((t) => t.panes).length, i < targets.length - 1 ? 3 - i : 0);
+ }
+ return confirm;
+ };
+ await app.requestCloseSwarm(work.id);
+ expect(reviewed, 1);
+ expect(app.lastError, isNull);
+ if (confirm) {
+ expect(app.swarms, isNot(contains(work)));
+ final saved = app.closedSwarms.single;
+ expect(saved.panes.map((p) => p.agentId), paneIds);
+ expect(saved.paneSizes['4:manual']!.tiles, shape.tiles);
+ app.reopenClosed();
+ expect(app.activeSwarm.name, 'Hardware');
+ expect(app.panes.map((p) => p.agentId), paneIds);
+ } else {
+ expect(work.panes, original);
+ await app.deskFlushForTest();
+ expect(api.doc!.tabs.single.panes.map((p) => p.agentId), paneIds);
+ }
+ },
+ );
+ }
+
test(
'closing syncs the default layout and reopening restores split order',
() async {
diff --git a/desktop/test/harness_activity_test.dart b/desktop/test/harness_activity_test.dart
index 99a0460e9..58c2264b7 100644
--- a/desktop/test/harness_activity_test.dart
+++ b/desktop/test/harness_activity_test.dart
@@ -54,6 +54,8 @@ void main() {
Agent(id: 'a0', name: 'Paused', engine: 'codex', status: 'stopped'),
];
expect(harnessActivity(app, 'm', 'a0'), HarnessActivity.paused);
+ expect(HarnessActivity.paused.mark, '■');
+ expect(nativeActivityPayload(HarnessActivity.paused)['mark'], '■');
machine.agents = const [
Agent(
id: 'a0',
diff --git a/desktop/test/pane_tab_cleanup_test.dart b/desktop/test/pane_tab_cleanup_test.dart
index 92d87dba5..aef8aa761 100644
--- a/desktop/test/pane_tab_cleanup_test.dart
+++ b/desktop/test/pane_tab_cleanup_test.dart
@@ -417,7 +417,11 @@ void main() {
if (native) {
expect(lastUpdate(calls)['tabsFocused'], isTrue);
} else {
- expect(stripTab(tester, keptTab.id).highlighted, isTrue);
+ expect(
+ stripTab(tester, keptTab.id).highlighted,
+ isFalse,
+ reason: 'Closing keeps the normal selected appearance',
+ );
}
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
diff --git a/desktop/test/session_close_test.dart b/desktop/test/session_close_test.dart
index ff6fc2073..659e2e2e2 100644
--- a/desktop/test/session_close_test.dart
+++ b/desktop/test/session_close_test.dart
@@ -7,6 +7,7 @@ import 'package:harness/core/models.dart';
import 'package:harness/state/app_state.dart';
import 'package:harness/state/harness_monitor_controller.dart';
import 'package:harness/ws/ws_conn.dart';
+import 'package:harness/widgets/desktop_prompt_surface.dart';
import 'swarm_screen_test.dart' show mount, terminal;
import 'swarm_state_test.dart' show createApp;
@@ -267,8 +268,8 @@ void main() {
final original = app.activeSwarm;
app.newSwarm();
final other = app.activeSwarm;
- other.panes.add(pane);
- other.focusedPaneId = pane.id;
+ app.stateOf('m')!.agents.add(agent('a2'));
+ final otherPane = app.adoptSessionForTest(terminal('a2', []));
app.selectSwarm(original.id);
await mount(tester, app);
unawaited(
@@ -300,8 +301,8 @@ void main() {
app.stateOf('m')!.agents.every((agent) => !agent.isStopped),
isTrue,
);
- expect(other.panes, [pane]);
- expect(pane.session, isNotNull);
+ expect(other.panes, [otherPane]);
+ expect(otherPane.session, isNotNull);
if (closeTab) {
expect(app.swarms, isNot(contains(original)));
} else {
@@ -436,10 +437,11 @@ void main() {
},
);
- testWidgets('Close also removes the session from another hidden tab', (
+ testWidgets('Close preserves another view and only the last view stops', (
tester,
) async {
final pane = app.adoptSessionForTest(terminal('a0', []));
+ final attached = pane.session;
final original = app.activeSwarm;
app.newSwarm();
app.activeSwarm.panes.add(pane);
@@ -447,9 +449,28 @@ void main() {
await mount(tester, app);
await app.requestClosePane(pane.id);
await tester.pumpAndSettle();
+ expect(modes(), isEmpty);
+ expect(app.swarms, [original]);
+ expect(original.panes, [pane]);
+ expect(pane.session, same(attached));
+ expect(app.closedHistory, hasLength(1));
+ expect(
+ app.stateOf('m')!.agents.firstWhere((a) => a.id == 'a0').isStopped,
+ isFalse,
+ );
+ expect(app.reopenClosed(), isTrue);
+ await tester.pumpAndSettle();
+ expect(app.activeSwarm.panes.single, same(pane));
+ expect(pane.session, same(attached));
+ expect(modes(), isEmpty);
+ await app.requestClosePane(pane.id);
+ await tester.pumpAndSettle();
+ expect(modes(), isEmpty);
+ expect(pane.session, same(attached));
+ await app.requestClosePane(pane.id);
+ await tester.pumpAndSettle();
expect(modes(), ['inspect', 'idle']);
expect(app.allPanes, isEmpty);
- expect(app.swarms, isNot(contains(original)));
expect(
app.stateOf('m')!.agents.firstWhere((a) => a.id == 'a0').isStopped,
isTrue,
@@ -457,6 +478,113 @@ void main() {
await tester.pumpWidget(const SizedBox());
});
+ testWidgets('tab Close stops only sessions without another view', (
+ tester,
+ ) async {
+ final shared = app.adoptSessionForTest(terminal('a0', []));
+ final attached = shared.session;
+ final retained = app.activeSwarm;
+ app.newSwarm(name: 'Closing');
+ final closing = app.activeSwarm;
+ closing.panes.add(shared);
+ app.adoptSessionForTest(terminal('a1', []));
+ await mount(tester, app);
+ await app.requestCloseSwarm(closing.id);
+ await tester.pumpAndSettle();
+ expect(app.swarms, [retained]);
+ expect(retained.panes, [shared]);
+ expect(shared.session, same(attached));
+ expect(connection.closes.map((r) => (r['agentId'], r['mode'])), [
+ ('a1', 'inspect'),
+ ('a1', 'idle'),
+ ]);
+ expect(
+ app.stateOf('m')!.agents.firstWhere((a) => a.id == 'a0').isStopped,
+ isFalse,
+ );
+ expect(
+ app.stateOf('m')!.agents.firstWhere((a) => a.id == 'a1').isStopped,
+ isTrue,
+ );
+ expect(app.closedSwarms.single.panes.map((p) => p.agentId), ['a0', 'a1']);
+ await tester.pumpWidget(const SizedBox());
+ });
+
+ for (final (engine, dsh) in [
+ ('terminal', null),
+ ('codex', 'fixture/dashboard'),
+ ]) {
+ testWidgets(
+ '$engine/$dsh closes shared views before the usual last-view stop',
+ (tester) async {
+ app.stateOf('m')!.agents = [
+ Agent(
+ id: 'a0',
+ name: 'Shared work',
+ engine: engine,
+ dsh: dsh,
+ sessionId: engine == 'terminal' ? null : 'conversation-a0',
+ createdAt: DateTime.utc(2026, 9, 30),
+ closeSupported: true,
+ terminalAvailable: true,
+ ),
+ ];
+ final pane = app.adoptSessionForTest(terminal('a0', []));
+ final retained = app.activeSwarm;
+ app.newSwarm();
+ app.activeSwarm.panes.add(pane);
+ app.activeSwarm.focusedPaneId = pane.id;
+ await mount(tester, app);
+ await app.requestClosePane(pane.id);
+ await tester.pumpAndSettle();
+ expect(modes(), isEmpty);
+ expect(retained.panes, [pane]);
+ expect(pane.session, isNotNull);
+ await app.requestClosePane(pane.id);
+ await tester.pumpAndSettle();
+ expect(modes(), ['inspect', 'idle']);
+ expect(app.allPanes, isEmpty);
+ await tester.pumpWidget(const SizedBox());
+ },
+ );
+ }
+
+ for (final phase in ['inspection', 'confirmation']) {
+ testWidgets('a view opened during close $phase prevents stopping', (
+ tester,
+ ) async {
+ final pane = app.adoptSessionForTest(terminal('a0', []));
+ final attached = pane.session;
+ final closing = app.activeSwarm;
+ connection.activities['a0'] = 'working';
+ if (phase == 'inspection') connection.inspecting = Completer();
+ await mount(tester, app);
+ final close = app.requestClosePane(pane.id);
+ await tester.pumpAndSettle();
+ app.newSwarm(name: 'Keep working');
+ final retained = app.activeSwarm;
+ retained.panes.add(pane);
+ retained.focusedPaneId = pane.id;
+ if (phase == 'inspection') {
+ connection.inspecting!.complete({'activity': 'working'});
+ } else {
+ await tester.tap(find.widgetWithText(FilledButton, 'Stop'));
+ }
+ await tester.pumpAndSettle();
+ await close;
+ expect(modes(), ['inspect']);
+ expect(app.swarms, isNot(contains(closing)));
+ expect(retained.panes, [pane]);
+ expect(pane.session, same(attached));
+ expect(
+ app.stateOf('m')!.agents.firstWhere((a) => a.id == 'a0').isStopped,
+ isFalse,
+ );
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ });
+ }
+
for (final stop in [false, true]) {
testWidgets(
'one mixed-tab review ${stop ? 'stops' : 'keeps'} all sessions',
@@ -581,7 +709,13 @@ void main() {
await tester.tap(find.text('Stop'));
await tester.pumpAndSettle();
expect(find.text('Not enough free disk space.'), findsOneWidget);
- expect(find.text('Stopped'), findsOneWidget);
+ expect(
+ find.descendant(
+ of: find.byType(DesktopPromptSurface),
+ matching: find.text('Stopped'),
+ ),
+ findsOneWidget,
+ );
expect(find.text('Stop not confirmed'), findsOneWidget);
expect(
find.text('You can close this tab. Some sessions may still be running.'),
@@ -621,7 +755,13 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.text('Stop'));
await tester.pumpAndSettle();
- expect(find.text('Stopped'), findsOneWidget);
+ expect(
+ find.descendant(
+ of: find.byType(DesktopPromptSurface),
+ matching: find.text('Stopped'),
+ ),
+ findsOneWidget,
+ );
expect(find.text('Stop not confirmed'), findsOneWidget);
final sent = List.of(connection.closes);
await tester.tap(find.text('Close Tab'));
diff --git a/desktop/test/stopped_harness_test.dart b/desktop/test/stopped_harness_test.dart
index 9ec4f43c9..39968fcb9 100644
--- a/desktop/test/stopped_harness_test.dart
+++ b/desktop/test/stopped_harness_test.dart
@@ -191,6 +191,110 @@ void main() {
expect(swarmDestinations(app).any((row) => row.agentId == 'a0'), isTrue);
});
+ test(
+ 'Reopen restores and resumes saved panes without following a tab switch',
+ () async {
+ await app.addAgentToSwarm('m', 'saved');
+ final closedId = app.activeSwarmId;
+ await app.closeSwarm(closedId);
+ expect(connection.requests, isEmpty);
+ expect(app.reopenClosed(), isTrue);
+ expect(app.activeSwarmId, closedId);
+ final pane = app.panes.single;
+ expect(connection.types, ['agent_resume']);
+ final repeat = app.openSavedPane(pane.id);
+ expect(connection.requests, hasLength(1));
+ app.newSwarm();
+ final otherId = app.activeSwarmId;
+ connection.restartReplies.single.complete(
+ restartReceipt(
+ connection.requests.single['creationId'] as String,
+ agentId: 'saved',
+ sessionId: 'original-conversation',
+ ),
+ );
+ await repeat;
+ expect(app.activeSwarmId, otherId);
+ expect(app.swarms.firstWhere((s) => s.id == closedId).panes, [pane]);
+ expect(app.panes, isEmpty);
+ expect(
+ app
+ .stateOf('m')!
+ .agents
+ .firstWhere((a) => a.id == 'saved')
+ .terminalAvailable,
+ isTrue,
+ );
+ },
+ );
+
+ testWidgets(
+ 'a restored stopped pane offers Open and retains a failed resume',
+ (tester) async {
+ await app.addAgentToSwarm('m', 'saved');
+ await mount(tester, app);
+ expect(
+ find.text(
+ 'This harness is stopped. Open it to continue your saved conversation.',
+ ),
+ findsOneWidget,
+ );
+ expect(
+ find.text('terminal unavailable (no verified terminal pane)'),
+ findsNothing,
+ );
+ await tester.tap(find.widgetWithText(TextButton, 'Open'));
+ await tester.pump();
+ expect(connection.types, ['agent_resume']);
+ expect(find.text('Opening saved conversation…'), findsOneWidget);
+ connection.restartReplies.single.complete({
+ 'creationId': connection.requests.single['creationId'],
+ 'state': 'failed',
+ 'failure': {
+ 'code': 'RESUME_UNAVAILABLE',
+ 'detail': 'Conversation missing',
+ },
+ });
+ await tester.pumpAndSettle();
+ expect(app.panes.single.agentId, 'saved');
+ expect(find.widgetWithText(TextButton, 'Open'), findsOneWidget);
+ expect(find.text('Conversation missing'), findsWidgets);
+ await tester.pumpWidget(const SizedBox());
+ },
+ );
+
+ test('closing a pane while resume is pending cannot recreate it', () async {
+ await app.addAgentToSwarm('m', 'saved');
+ final pane = app.panes.single;
+ final opening = app.openSavedPane(pane.id);
+ await app.closePane(pane.id);
+ connection.restartReplies.single.complete(
+ restartReceipt(
+ connection.requests.single['creationId'] as String,
+ agentId: 'saved',
+ sessionId: 'original-conversation',
+ ),
+ );
+ await opening;
+ expect(app.allPanes, isEmpty);
+ expect(connection.requests, hasLength(1));
+ });
+
+ testWidgets('a stopped pane with retained output also offers Open', (
+ tester,
+ ) async {
+ app.adoptSessionForTest(terminal('saved', []));
+ await mount(tester, app);
+ expect(
+ find.text(
+ 'Open to continue your saved conversation. Retained output is read only.',
+ ),
+ findsOneWidget,
+ );
+ expect(find.text('Open'), findsOneWidget);
+ await tester.pumpWidget(const SizedBox());
+ });
+
for (final placement in HarnessPlacement.values) {
test('Enter resumes directly before opening ${placement.name}', () async {
final target = app.activeSwarmId;
diff --git a/desktop/test/swarm_close_race_test.dart b/desktop/test/swarm_close_race_test.dart
index af25ca7c3..3d932eeb9 100644
--- a/desktop/test/swarm_close_race_test.dart
+++ b/desktop/test/swarm_close_race_test.dart
@@ -159,7 +159,7 @@ void main() {
try {
await mount(tester, app, nativeTabs: true);
var reviewed = false;
- app.reviewSessionClose = (targets, {tabName}) {
+ app.reviewSessionClose = (targets, {tabName, canStop}) {
reviewed = true;
return review.future;
};
diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swift
index b01662d5a..9dd2b048b 100644
--- a/desktop/tool/swarm_titlebar_checks.swift
+++ b/desktop/tool/swarm_titlebar_checks.swift
@@ -98,7 +98,7 @@ private extension SwarmTabStrip {
}
let states: [(String, String)] = [("⠋", "Working"), ("?", "Needs your input"),
("✗", "Failed"), ("✓", "Finished · unread"), ("", "Idle"),
- ("◌", "Starting"), ("||", "Paused"), ("⊘", "Offline")]
+ ("◌", "Starting"), ("■", "Stopped"), ("⊘", "Offline")]
update(["enabled": true, "activeId": "activity", "tabs": [
["id": "activity", "name": "desktop", "label": "1:desktop", "activity": payload("⠋", "Working", working: true)]
]])
@@ -546,13 +546,42 @@ private extension SwarmTabButton {
func drawWithHoverControl() {
draw(bounds)
- guard !closeButton.isHidden else { return }
- NSGraphicsContext.saveGraphicsState()
- let transform = NSAffineTransform()
- transform.translateX(by: closeButton.frame.minX, yBy: closeButton.frame.minY)
- transform.concat()
- closeButton.draw(closeButton.bounds)
- NSGraphicsContext.restoreGraphicsState()
+ for control in [selectButton, closeButton] where !control.isHidden {
+ NSGraphicsContext.saveGraphicsState()
+ let transform = NSAffineTransform()
+ transform.translateX(by: control.frame.minX, yBy: control.frame.minY)
+ transform.concat()
+ control.draw(control.bounds)
+ NSGraphicsContext.restoreGraphicsState()
+ }
+ }
+
+ func checkSelectionSurface() throws {
+ frame = NSRect(x: 0, y: 0, width: 256, height: 40)
+ layoutSubtreeIfNeeded()
+ let hover = NSEvent.mouseEvent(with: .mouseMoved, location: .zero, modifierFlags: [],
+ timestamp: 0, windowNumber: 0, context: nil, eventNumber: 0, clickCount: 0, pressure: 0)!
+ for appearance in [NSAppearance.Name.darkAqua, .aqua] {
+ self.appearance = NSAppearance(named: appearance)
+ for active in [false, true] {
+ selected = active
+ for pressed in [false, true] {
+ selectButton.performClick(nil)
+ selectButton.mouseEntered(with: hover)
+ selectButton.highlight(pressed)
+ let bitmap = selectButton.renderedBitmap()
+ let paintsOverTab = (0..<bitmap.pixelsWide).contains { x in
+ (0..<bitmap.pixelsHigh).contains { y in
+ (bitmap.colorAt(x: x, y: y)?.alphaComponent ?? 0) > 0
+ }
+ }
+ try checkTitlebar(!paintsOverTab,
+ "The selection target adds no second surface over the tab in \(appearance.rawValue), selected=\(active), pressed=\(pressed)")
+ selectButton.highlight(false)
+ selectButton.mouseExited(with: hover)
+ }
+ }
+ }
}
func checkClickOwnership() throws {
@@ -1775,7 +1804,12 @@ private extension SwarmTabStrip {
let buttons = tab.accessibilityChildren()!.compactMap { $0 as? NSButton }
try checkTitlebar(buttons.count == 2, "Hover exposes selection and close to native accessibility")
for button in buttons {
+ let beforeFocus = tab.renderedPixels()
try checkTitlebar(window.makeFirstResponder(button), "An enabled tab action accepts keyboard focus")
+ if button === buttons[0] {
+ try checkTitlebar(tab.renderedPixels() != beforeFocus,
+ "Explicit keyboard focus still outlines the native tab control")
+ }
try tab.checkCenteredLabel()
try checkTitlebar(scroll.documentVisibleRect.contains(tab.frame),
"Keyboard focus reveals the entire overflowed tab")
@@ -1858,8 +1892,7 @@ private extension SwarmTabStrip {
}
private extension SwarmTabStrip {
- /// Dart's `tabsFocused`: closing the active tab left the keyboard on the
- /// strip, so the selected tab is drawn focused until the person goes in.
+ /// Dart's `tabsFocused`: Close parks keys without adding a visual outline.
func checkKeyboardOnTabs() throws {
let rows = (0..<3).map { ["id": "strip-\($0)", "name": "Strip \($0)", "label": "\($0 + 1):work"] }
update(["enabled": true, "activeId": "strip-1", "tabs": rows])
@@ -1868,9 +1901,9 @@ private extension SwarmTabStrip {
update(["enabled": true, "activeId": "strip-1", "tabs": rows, "tabsFocused": true])
try checkTitlebar(tabs.map(\.keyboardFocus) == [false, true, false],
"Only the selected tab shows the strip's keyboard focus")
- try checkTitlebar(tabs[1].renderedPixels() != resting[1] &&
+ try checkTitlebar(tabs[1].renderedPixels() == resting[1] &&
tabs[0].renderedPixels() == resting[0] && tabs[2].renderedPixels() == resting[2],
- "The selected tab is drawn focused and its neighbours are unchanged")
+ "Closing a tab keeps the normal selected appearance without an automatic focus ring")
let select = tabs[1].accessibilityChildren()!.compactMap { $0 as? NSButton }.first!
try checkTitlebar(select.accessibilityHelp()?.contains("Return") == true,
"VoiceOver hears that Return types in the selected tab")
@@ -2606,6 +2639,7 @@ do {
try strip.checkActivityMarks()
try SwarmTabButton(id: "label-measurements").checkLabelMeasurementChanges()
try SwarmTabButton(id: "close-shortcuts").checkHoverCloseAndShortcutHints()
+ try SwarmTabButton(id: "selection-surface").checkSelectionSurface()
try strip.checkTabPresentationAndCapture()
try SwarmTabButton(id: "hover-fixture").checkHoverStyleAndTooltips()
try strip.checkDaemon()