The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Desktop: ⌘⇧T opens a terminal tile; a tile follows its engine
0xken159d5a6da6560e
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex 0a8f9567e..54c6bd0b1 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -30,6 +30,7 @@ import '../state/swarm_attention.dart';import '../state/swarm_navigation.dart';import '../state/swarm_search.dart';import '../state/swarm.dart';+import '../state/terminal_pane.dart';import '../widgets/transient_menus.dart';import '../widgets/layout_palette.dart';import '../widgets/engine_identity.dart';@@ -507,7 +508,9 @@ class _SwarmScreenState extends State<SwarmScreen> {DateTime? _localModelsAt;Future<void> _refreshLocalModels() async {- final machines = app.machines.where((machine) => !machine.isShared).toList();+ final machines = app.machines+ .where((machine) => !machine.isShared)+ .toList();if (machines.isEmpty) return;// The daemon memoises its answer, so a repeat is nearly free — but this is called on every app// change, and an RPC per keystroke-sized notification is not free. One read per window is@@ -564,6 +567,7 @@ class _SwarmScreenState extends State<SwarmScreen> {args['command'] is String ? args['command'] as String : null,'commands' => 'navigation.commands','newAgent' => 'agent.new',+ 'newTerminal' => 'terminal.new',_ => null,};if (nativeCommand != null) {@@ -662,6 +666,8 @@ class _SwarmScreenState extends State<SwarmScreen> {await _addAgent();case 'newAgent':unawaited(_newAgent(swarmId: app.activeSwarmId));+ case 'newTerminal':+ unawaited(_newTerminal());case 'runLocalModel':// The native Models menu's one command. Wrapped like Link Machine…// because the notifier may open its dialog here, and the pane it then@@ -773,6 +779,7 @@ class _SwarmScreenState extends State<SwarmScreen> {'notifications','addAgent','newAgent',+ 'newTerminal','manageMachines','deleteMachine','splitRight',@@ -872,6 +879,50 @@ class _SwarmScreenState extends State<SwarmScreen> {await _ensureEmptyEntry();}+ /// ⌘⇧T: a shell in a new tile, no dialog — the way a terminal app opens a+ /// tab. It lands on the machine the focused tile is on (this computer when+ /// nothing is focused), in the folder that tile's harness works in, else+ /// the first project any tile in this tab has, else the machine's home —+ /// which is what the daemon opens when no folder is named.+ Future<void> _newTerminal() async {+ if (app.activeSwarm.isStore) app.newSwarm();+ final target = app.activeSwarmId;+ final focused = app.focusedPane;+ final machine = focused == null+ ? app.machineStates.values+ .where((machine) => machine.isLocalMachine)+ .firstOrNull ??+ app.machineStates.values.firstOrNull+ : app.stateOf(focused.machineId);+ if (machine == null) {+ await _dialog(() => showSwarmLinkDialog(context, app));+ return;+ }+ final machineId = machine.machine.machineId;+ String? folderOf(TerminalPane pane) {+ if (pane.machineId != machineId) return null;+ final agent = machine.agents+ .where((agent) => agent.id == pane.agentId)+ .firstOrNull;+ return agent == null ? null : machine.projectOf(agent)?.cwd;+ }++ final folder =+ (focused == null ? null : folderOf(focused)) ??+ app.panes.map(folderOf).whereType<String>().firstOrNull;+ final error = await app.createAgent(+ machineId,+ engine: kTerminalEngine,+ folder: folder,+ bypassPermission: false,+ swarmId: target,+ );+ if (error != null && mounted) {+ ScaffoldMessenger.maybeOf(context)+ ?.showSnackBar(SnackBar(content: Text(error)));+ }+ }+Future<void> _splitAgent(PaneResizeAxis axis, {int? paneId,@@ -1294,6 +1345,7 @@ class _SwarmScreenState extends State<SwarmScreen> {}},ShortcutAction.newAgent: _newAgent,+ ShortcutAction.newTerminal: _newTerminal,ShortcutAction.routeTask: () =>_dialog(() => showTaskPalette(context, app)),ShortcutAction.orchestrate: () =>@@ -1357,6 +1409,9 @@ class _SwarmScreenState extends State<SwarmScreen> {}if (id == 'navigation.back') return _navigation.canGoBack(app);if (id == 'navigation.forward') return _navigation.canGoForward(app);+ // Opening a terminal needs no terminal to already be there; the other+ // `terminal.*` commands are find, which does.+ if (id == 'terminal.new') return true;if (id.startsWith('terminal.')) return _canFindTerminal;if (id == 'pane.resize') {return app.panes.length > 1 && app.zoomedPaneId == null;diff --git a/desktop/lib/shortcuts/app_shortcuts.dart b/desktop/lib/shortcuts/app_shortcuts.dartindex 4b6d7f020..9df668049 100644--- a/desktop/lib/shortcuts/app_shortcuts.dart+++ b/desktop/lib/shortcuts/app_shortcuts.dart@@ -53,6 +53,10 @@ enum ShortcutAction {closePane,newAgent,++ /// A plain shell in a pane, like a native terminal's new tab — the daemon+ /// treats whatever engine is later typed into it as the pane's agent.+ newTerminal,routeTask,orchestrate,reload,@@ -364,15 +368,18 @@ const kSwarmShortcuts = [label: 'New Tab',group: ShortcutGroup.navigate,),+ // ⌘⇧T is New Terminal, as it is in a terminal app. "Reopen last closed+ // harness" used to sit on it; it lives on in the History menu, the ⌘⇧P+ // command palette and `keybindings.jsonc`, without a default chord.AppShortcut(- action: ShortcutAction.reopenClosedSwarm,+ action: ShortcutAction.newTerminal,activator: SingleActivator(LogicalKeyboardKey.keyT,meta: true,shift: true,),- label: 'Reopen last closed harness',- group: ShortcutGroup.navigate,+ label: 'New Terminal',+ group: ShortcutGroup.actions,),AppShortcut(action: ShortcutAction.closeSwarm,diff --git a/desktop/lib/shortcuts/keymap_commands.dart b/desktop/lib/shortcuts/keymap_commands.dartindex a30fe6c93..c6360eb1d 100644--- a/desktop/lib/shortcuts/keymap_commands.dart+++ b/desktop/lib/shortcuts/keymap_commands.dart@@ -68,6 +68,9 @@ final harnessCommands = <HarnessCommand>[action: ShortcutAction.closeSwarm,nativeAction: 'closeActive',),+ // The live table binds no chord to it any more (⌘⇧T is New Terminal), so+ // `keys` comes back empty: a palette and menu command a person may give a+ // key of their own in keybindings.jsonc.const HarnessCommand('swarm.reopen','Reopen last closed harness',@@ -284,6 +287,13 @@ final harnessCommands = <HarnessCommand>[action: ShortcutAction.newAgent,nativeAction: 'newAgent',),+ const HarnessCommand(+ 'terminal.new',+ 'New Terminal',+ ShortcutGroup.actions,+ action: ShortcutAction.newTerminal,+ nativeAction: 'newTerminal',+ ),const HarnessCommand('machines.manage','Open Machines Manager',diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex b5527b0ac..c94082c17 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -42,7 +42,8 @@ import '../terminal/terminal_theme_store.dart';import '../logging/app_log.dart';import '../shared/theme/app_theme.dart' as grid;import '../terminal/remote_media_download.dart';-import '../widgets/engine_identity.dart' show allEngines, engineIdentity;+import '../widgets/engine_identity.dart'+ show allEngines, engineIdentity, isTerminalEngine;import '../widgets/run_local_model_dialog.dart' show showRunLocalModelDialog;import 'dial_status.dart';import 'pane_layout_store.dart';@@ -1662,7 +1663,23 @@ class AppNotifier extends ChangeNotifier {void _announceOpenPanesToDial() {final pool = _pool;if (pool == null) return;- final agentIds = <String>[for (final pane in panes) ?pane.agentId];+ // A terminal tile is not the dial's: the dial drives agents, and the daemon+ // never lists a shell to it. Naming one here would make the daemon "hold"+ // an id it has nothing for. The same tile IS named once an engine has been+ // typed into it — `_upsertAgent` re-announces on the engine change.+ bool onDial(TerminalPane pane) {+ final agentId = pane.agentId;+ if (agentId == null) return false;+ final agent = machineStates[pane.machineId]?.agents+ .where((agent) => agent.id == agentId)+ .firstOrNull;+ return !isTerminalEngine(agent?.engine);+ }++ final agentIds = <String>[+ for (final pane in panes)+ if (onDial(pane)) pane.agentId!,+ ];// The swarms travel with the tiles: the dial names the one on screen above the agent and offers// the others, and a pick there comes back as `dial_swarm`. Names and member ids only — the layout// inside a swarm is this window's business.@@ -1671,7 +1688,10 @@ class AppNotifier extends ChangeNotifier {{'id': swarm.id,'name': swarm.name,- 'agentIds': [for (final pane in swarm.panes) ?pane.agentId],+ 'agentIds': [+ for (final pane in swarm.panes)+ if (onDial(pane)) pane.agentId!,+ ],},];for (final machineId in machineStates.keys) {@@ -4355,6 +4375,15 @@ class AppNotifier extends ChangeNotifier {machine.agentLoadStatus = AgentLoadStatus.loaded;machine.agentsLoadError = null;_syncViewerPane(machine, agent);+ // A terminal that adopted an engine, or let one go: the tiles already+ // attached to it keep their stream and change their face. The dial's+ // tile list changes with it — a terminal is not on it, its engine is.+ if (previous != null && previous.engine != agent.engine) {+ for (final pane in panesFor(machine.machine.machineId)) {+ if (pane.agentId == agent.id) pane.session?.setEngineId(agent.engine);+ }+ _announceOpenPanesToDial();+ }if (agent.launchState == 'failed' && previous?.launchState != 'failed') {_lastError = agent.launchDetail ?? 'Failed to start ${agent.name}';// The launch already ran and failed (e.g. the engine's automatic@@ -4896,7 +4925,11 @@ class AppNotifier extends ChangeNotifier {Future<String?> createAgent(String machineId, {required String engine,- required String folder,++ /// Where the agent works. Null only for a terminal (`kTerminalEngine`),+ /// which the daemon then opens at the machine's home, as a terminal app+ /// would — every other engine is refused without one (`INVALID_CWD`).+ required String? folder,ProjectFolderRequest? projectFolder,bool bypassPermission = true,String? permissionMode,@@ -4912,7 +4945,7 @@ class AppNotifier extends ChangeNotifier {final creation = attempt ?? AgentCreationAttempt();final choices = <String, dynamic>{'engine': engine,- if (projectFolder == null) 'cwd': folder,+ if (projectFolder == null && folder != null) 'cwd': folder,...?projectFolder?.payload,'bypassPermission': bypassPermission,// The mode picked in New Harness (`permission_modes.dart`). A daemon that@@ -5014,6 +5047,10 @@ class AppNotifier extends ChangeNotifier {'This first task is too long for $machine. Shorten it and try again.','AGENT_UNSUPPORTED' =>'This engine cannot be opened as a named agent on $machine.',+ // A daemon that predates the terminal engine refuses it by name; the+ // fix is the same one the other UNSUPPORTED codes ask for.+ 'INVALID_ENGINE' =>+ 'Update the harness CLI on $machine to open this kind of pane.',_ => 'Create harness failed: ${detail ?? code}',};@@ -5039,6 +5076,12 @@ class AppNotifier extends ChangeNotifier {}}}+ // Nothing to dial with before sign-in finishes (`_finishBootstrapSignedIn`+ // makes the pool) — a shortcut that fires in that window, such as ⌘⇧T, is+ // answered rather than crashed on.+ if (_pool == null && connectionForTest == null) {+ return 'Not connected to $machineName yet.';+ }final connection = _conn(machineId);var launchChoices = choices;if (!creation.awaitingConfirmation &&diff --git a/desktop/lib/terminal/terminal_session.dart b/desktop/lib/terminal/terminal_session.dartindex 98ef8c91e..9d136c9a5 100644--- a/desktop/lib/terminal/terminal_session.dart+++ b/desktop/lib/terminal/terminal_session.dart@@ -75,7 +75,13 @@ class TerminalSession extends ChangeNotifier {final String machineId;final String agentId;String agentName;- final String? engineId;++ /// The engine the pane runs — what `terminal_ready` said, until the daemon+ /// says otherwise. Not final: a terminal tile becomes a Claude tile the+ /// moment `claude` is typed into it (and a terminal again when it exits),+ /// and the stream underneath is the same tmux pane throughout, so the+ /// session is told rather than reopened — see [setEngineId].+ String? engineId;final TerminalFrameSender send;final TerminalBinarySender sendBinary;final Duration resyncTimeout;@@ -195,6 +201,15 @@ class TerminalSession extends ChangeNotifier {notifyListeners();}+ /// The daemon re-labelled this pane's engine (`agent_synced` with a new+ /// `engine`): the header mark, the model picker and the scroll strategy+ /// follow, over the stream already open.+ void setEngineId(String? engine) {+ if (engine == engineId) return;+ engineId = engine;+ notifyListeners();+ }+Future<void> open({int initialCols = 80,int initialRows = 24,diff --git a/desktop/lib/widgets/delete_agent_dialog.dart b/desktop/lib/widgets/delete_agent_dialog.dartindex 5425549d4..1f40c9037 100644--- a/desktop/lib/widgets/delete_agent_dialog.dart+++ b/desktop/lib/widgets/delete_agent_dialog.dart@@ -3,25 +3,36 @@ import 'package:flutter/material.dart';import '../shared/theme/app_theme.dart' as grid;import '../shared/widgets/app_dialog.dart';import '../state/app_state.dart';+import 'engine_identity.dart';/// Shared Stop Agent confirmation. The legacy agent_delete request stops the/// engine and removes its active entry, preserving files and saved history.+///+/// [engine] tells the dialog what it is ending: a terminal (`kTerminalEngine`)+/// is a shell, and closing one ends whatever was running in it — said in+/// those words, since "agent" and "conversation history" mean nothing to it.Future<void> confirmDeleteAgent(BuildContext context,AppNotifier notifier,String machineId,String agentId,- String name,-) async {+ String name, {+ String? engine,+}) async {+ final terminal = isTerminalEngine(engine);+ final verb = terminal ? 'Stop Terminal' : 'Stop Harness';final confirmed = await showAppDialog<bool>(context: context,builder: (dialogContext) => AlertDialog(- title: const Text('Stop Harness'),+ title: Text(verb),content: SizedBox(width: 360,child: Text(- 'Stop “$name”? This ends the running agent and removes it from your '- 'active agents. Project files and saved conversation history are kept.',+ terminal+ ? 'Stop “$name”? This closes the shell and ends anything still '+ 'running in it. Files are kept.'+ : 'Stop “$name”? This ends the running agent and removes it from your '+ 'active agents. Project files and saved conversation history are kept.',style: TextStyle(fontFamily: grid.AppFont.sans, fontSize: 13.5),),),@@ -35,7 +46,7 @@ Future<void> confirmDeleteAgent(backgroundColor: grid.AppPalette.dangerFill,),onPressed: () => Navigator.of(dialogContext).pop(true),- child: const Text('Stop Harness'),+ child: Text(verb),),],),diff --git a/desktop/lib/widgets/engine_identity.dart b/desktop/lib/widgets/engine_identity.dartindex 07292346d..19c0fce05 100644--- a/desktop/lib/widgets/engine_identity.dart+++ b/desktop/lib/widgets/engine_identity.dart@@ -1,6 +1,7 @@import 'dart:math' as math;import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';import '../core/models.dart';import '../theme/app_theme.dart';@@ -440,6 +441,27 @@ const knownHarnessBase = <String, String>{'autonomous/bonsai-mcp': 'codex',};+/// The daemon's engine id for a plain shell in a pane (⌘⇧T, New Terminal).+///+/// Deliberately NOT in [_engines]: [allEngines] is what New Harness offers and+/// what `engines_probe` asks a machine about, and a terminal is neither+/// installable nor something to pick from that list — it is its own action.+/// It still has a face, because a tile shows one, and the daemon swaps the+/// tile's engine for whatever gets typed into it, so the face must come and+/// go through the same [engineIdentity] every other mark reads.+const String kTerminalEngine = 'terminal';++const EngineIdentity _terminal = EngineIdentity(+ id: kTerminalEngine,+ label: 'Terminal',+ category: 'Shell',+ tagline: 'Your shell, in a tile',+ color: Color(0xffa8b0b8),+);++/// Whether [engine] is the shell rather than an agent.+bool isTerminalEngine(String? engine) => engine == kTerminalEngine;+/// All known engines, in declaration order — for the New Agent engine picker.List<EngineIdentity> get allEngines => _engines.values.toList(growable: false);@@ -453,7 +475,10 @@ bool isHarnessId(String? id) => id != null && id.contains('/');EngineIdentity engineIdentity(String? engine, {String? displayName}) {final id = engine?.trim().toLowerCase() ?? '';- final known = _engines[id] ?? _harnesses[id];+ final known =+ _engines[id] ??+ _harnesses[id] ??+ (id == kTerminalEngine ? _terminal : null);if (known != null) return known;final raw = displayName?.trim().isNotEmpty == true? displayName!.trim()@@ -527,6 +552,13 @@ class EngineMark extends StatelessWidget {size: Size.square(size),painter: _ClaudeMarkPainter(identity.color),)+ : identity.id == kTerminalEngine+ ? Icon(+ LucideIcons.terminal,+ key: const ValueKey('engine-icon-terminal'),+ size: size,+ color: identity.color,+ ): _InitialMark(key: ValueKey('engine-fallback-${identity.id}'),identity: identity,diff --git a/desktop/lib/widgets/machine_rail.dart b/desktop/lib/widgets/machine_rail.dartindex 12be9cfea..f811cb6f6 100644--- a/desktop/lib/widgets/machine_rail.dart+++ b/desktop/lib/widgets/machine_rail.dart@@ -1031,6 +1031,7 @@ class _AgentRowState extends State<_AgentRow> {state.machine.machineId,agent.id,agent.name,+ engine: agent.engine,);Future<void> _restartAgent() =>diff --git a/desktop/lib/widgets/pane_grid.dart b/desktop/lib/widgets/pane_grid.dartindex 0359ae39f..d56dd1bc6 100644--- a/desktop/lib/widgets/pane_grid.dart+++ b/desktop/lib/widgets/pane_grid.dart@@ -1408,6 +1408,7 @@ class _PaneContent extends StatelessWidget {pane.machineId,agent.id,agent.name,+ engine: agent.engine,),zoomed: notifier.zoomedPaneId == pane.id,onToggleZoom:diff --git a/desktop/lib/widgets/pane_header_actions.dart b/desktop/lib/widgets/pane_header_actions.dartindex 93253249c..59697370d 100644--- a/desktop/lib/widgets/pane_header_actions.dart+++ b/desktop/lib/widgets/pane_header_actions.dart@@ -21,9 +21,14 @@ class PaneHeaderActions extends StatelessWidget {this.viewerColor,this.details,this.modelPicker,+ this.terminal = false,});final bool zoomed, composerVisible;++ /// The pane is a shell, not a harness: Restart and Stop say so, because+ /// "Stop Harness" over a terminal reads as a button for something else.+ final bool terminal;final VoidCallback? onShare;final VoidCallback? onZoom, onRestart, onDelete, onClose, onToggleComposer;@@ -125,9 +130,17 @@ class PaneHeaderActions extends StatelessWidget {onZoom,),const SizedBox(width: 2),- action('Restart Harness', LucideIcons.refreshCw, onRestart),+ action(+ terminal ? 'Restart Terminal' : 'Restart Harness',+ LucideIcons.refreshCw,+ onRestart,+ ),const SizedBox(width: 2),- action('Stop Harness', Icons.stop_rounded, onDelete),+ action(+ terminal ? 'Stop Terminal' : 'Stop Harness',+ Icons.stop_rounded,+ onDelete,+ ),const SizedBox(width: 2),action('Close Pane', LucideIcons.x, onClose),],diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dartindex 8ef25f098..78eb8d7fc 100644--- a/desktop/lib/widgets/terminal_panel.dart+++ b/desktop/lib/widgets/terminal_panel.dart@@ -1533,7 +1533,12 @@ class _TerminalHeader extends StatelessWidget {if (profile != null) 'Codex profile: $profile','Double-click to rename',].join('\n');- final remoteComposer = machine != null && !machine.isLocalMachine+ // A terminal has no prompt to compose a message for — a shell reads keys,+ // and the composer's Enter-to-send would be a line nobody asked for.+ final remoteComposer =+ machine != null &&+ !machine.isLocalMachine &&+ !isTerminalEngine(session.engineId)? onToggleComposer: null;// The icon cluster, plus the model picker that now sits at its left — without the extra the@@ -1744,6 +1749,7 @@ class _TerminalHeader extends StatelessWidget {onRestart: onRestart,onDelete: onDelete,onClose: onClose,+ terminal: isTerminalEngine(session.engineId),onToggleComposer: remoteComposer,composerVisible: composerVisible,// A harness agent's viewer, shown or hidden from thediff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swiftindex a85de8206..377a6a316 100644--- a/desktop/macos/Runner/SwarmTitlebar.swift+++ b/desktop/macos/Runner/SwarmTitlebar.swift@@ -99,7 +99,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {}private func sendTabAction(_ method: String, arguments: Any?) {- guard ["select", "close", "new", "rename", "commands", "notifications", "addAgent", "newAgent", "splitRight", "splitDown", "zoomPane", "pinPane", "machineDestination", "machineAgent", "manageMachines"].contains(method) else {+ guard ["select", "close", "new", "rename", "commands", "notifications", "addAgent", "newAgent", "newTerminal", "splitRight", "splitDown", "zoomPane", "pinPane", "machineDestination", "machineAgent", "manageMachines"].contains(method) else {channel.invokeMethod(method, arguments: arguments)return}@@ -221,7 +221,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {item.representedObject = actionitem.identifier = NSUserInterfaceItemIdentifier(HarnessKeymapMenu.actionPrefix + action)let symbols = [- "new": "plus.square", "newAgent": "plus", "addAgent": "arrow.up.right",+ "new": "plus.square", "newAgent": "plus", "addAgent": "arrow.up.right", "newTerminal": "terminal","renameActive": "pencil", "closeActive": "xmark","splitRight": "rectangle.split.2x1", "splitDown": "rectangle.split.1x2","zoomPane": "viewfinder", "closePane": "xmark",@@ -241,6 +241,10 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {let file = NSMenu(title: "File")add(file, "New Tab", "t", "new")add(file, "New Harness…", "n", "newAgent")+ // ⌘⇧T, as in a terminal app. It used to be Reopen Last Closed (History menu), which keeps its+ // row and loses its default chord — the Dart keymap (`swarm.reopen`) is where both are decided,+ // and applyMenuKeys rewrites every equivalent here from it.+ add(file, "New Terminal", "t", "newTerminal", [.command, .shift])add(file, "Open Harness…", "o", "addAgent")add(file, "Rename Tab…", "r", "renameActive", [.command, .shift])add(file, "Close Tab", "w", "closeActive")@@ -557,11 +561,11 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {}command("Back", "[", "historyBack")command("Forward", "]", "historyForward")- let reopen = NSMenuItem(title: "Reopen Last Closed", action: #selector(menuAction(_:)), keyEquivalent: "t")+ // No default chord: ⌘⇧T is New Terminal now. A person can give this one in keybindings.jsonc.+ let reopen = NSMenuItem(title: "Reopen Last Closed", action: #selector(menuAction(_:)), keyEquivalent: "")reopen.target = selfreopen.representedObject = "reopen"reopen.identifier = NSUserInterfaceItemIdentifier(HarnessKeymapMenu.actionPrefix + "reopen")- reopen.keyEquivalentModifierMask = [.command, .shift]historyMenu.addItem(reopen)historyMenu.addItem(.separator())appendHistorySection("Recently Closed", entries: closed, closed: true, trailingEdge: trailingEdge)diff --git a/desktop/test/agent_events_test.dart b/desktop/test/agent_events_test.dartindex 57470436c..61c12e368 100644--- a/desktop/test/agent_events_test.dart+++ b/desktop/test/agent_events_test.dart@@ -59,7 +59,7 @@ class FakeCreateAgentNotifier extends AppNotifier {Future<String?> createAgent(String machineId, {required String engine,- required String folder,+ required String? folder,ProjectFolderRequest? projectFolder,bool bypassPermission = false,String? permissionMode,diff --git a/desktop/test/first_workspace_test.dart b/desktop/test/first_workspace_test.dartindex 3b37e3303..17c3cae4d 100644--- a/desktop/test/first_workspace_test.dart+++ b/desktop/test/first_workspace_test.dart@@ -76,7 +76,7 @@ class _FirstUseApp extends AppNotifier {Future<String?> createAgent(String machineId, {required String engine,- required String folder,+ required String? folder,ProjectFolderRequest? projectFolder,bool bypassPermission = false,String? permissionMode,@@ -92,7 +92,7 @@ class _FirstUseApp extends AppNotifier {launches.add((machine: machineId,engine: engine,- folder: folder,+ folder: folder!,bypass: bypassPermission,));if (creation != null) {diff --git a/desktop/test/new_agent_choices_layout_test.dart b/desktop/test/new_agent_choices_layout_test.dartindex e752062e3..117846959 100644--- a/desktop/test/new_agent_choices_layout_test.dart+++ b/desktop/test/new_agent_choices_layout_test.dart@@ -60,7 +60,7 @@ class _ChoicesApp extends AppNotifier {Future<String?> createAgent(String machineId, {required String engine,- required String folder,+ required String? folder,ProjectFolderRequest? projectFolder,bool bypassPermission = false,String? permissionMode,diff --git a/desktop/test/new_agent_codex_profile_test.dart b/desktop/test/new_agent_codex_profile_test.dartindex b7504f6b4..6672b47f8 100644--- a/desktop/test/new_agent_codex_profile_test.dart+++ b/desktop/test/new_agent_codex_profile_test.dart@@ -126,7 +126,7 @@ class _Notifier extends AppNotifier {Future<String?> createAgent(String machineId, {required String engine,- required String folder,+ required String? folder,ProjectFolderRequest? projectFolder,bool bypassPermission = false,String? permissionMode,diff --git a/desktop/test/new_agent_dsh_test.dart b/desktop/test/new_agent_dsh_test.dartindex 5e1cc0280..c14e29770 100644--- a/desktop/test/new_agent_dsh_test.dart+++ b/desktop/test/new_agent_dsh_test.dart@@ -99,7 +99,7 @@ class _Notifier extends AppNotifier {Future<String?> createAgent(String machineId, {required String engine,- required String folder,+ required String? folder,bool bypassPermission = false,String? permissionMode,String? codexHome,diff --git a/desktop/test/new_agent_engine_check_test.dart b/desktop/test/new_agent_engine_check_test.dartindex d1df233b9..cf9329b27 100644--- a/desktop/test/new_agent_engine_check_test.dart+++ b/desktop/test/new_agent_engine_check_test.dart@@ -299,7 +299,7 @@ class _RetryNotifier extends AppNotifier {Future<String?> createAgent(String machineId, {required String engine,- required String folder,+ required String? folder,ProjectFolderRequest? projectFolder,bool bypassPermission = false,String? permissionMode,@@ -315,7 +315,7 @@ class _RetryNotifier extends AppNotifier {launches.add({'machine': machineId,'engine': engine,- 'folder': folder,+ 'folder': folder!,'bypass': bypassPermission,});return 'Test launch refused.';diff --git a/desktop/test/new_agent_permission_mode_test.dart b/desktop/test/new_agent_permission_mode_test.dartindex 6327b6d45..219bc9f49 100644--- a/desktop/test/new_agent_permission_mode_test.dart+++ b/desktop/test/new_agent_permission_mode_test.dart@@ -49,7 +49,7 @@ class _Notifier extends AppNotifier {Future<String?> createAgent(String machineId, {required String engine,- required String folder,+ required String? folder,bool bypassPermission = false,String? permissionMode,String? codexHome,diff --git a/desktop/test/new_agent_project_picker_test.dart b/desktop/test/new_agent_project_picker_test.dartindex 2b5d02232..0772cadd2 100644--- a/desktop/test/new_agent_project_picker_test.dart+++ b/desktop/test/new_agent_project_picker_test.dart@@ -62,7 +62,7 @@ class _App extends AppNotifier {Future<String?> createAgent(String machineId, {required String engine,- required String folder,+ required String? folder,ProjectFolderRequest? projectFolder,bool bypassPermission = false,String? permissionMode,diff --git a/desktop/test/new_agent_rows_and_task_test.dart b/desktop/test/new_agent_rows_and_task_test.dartindex aeaf24908..5c38ba319 100644--- a/desktop/test/new_agent_rows_and_task_test.dart+++ b/desktop/test/new_agent_rows_and_task_test.dart@@ -115,7 +115,7 @@ class _App extends AppNotifier {Future<String?> createAgent(String machineId, {required String engine,- required String folder,+ required String? folder,bool bypassPermission = false,String? permissionMode,String? codexHome,diff --git a/desktop/test/remote_folder_picker_test.dart b/desktop/test/remote_folder_picker_test.dartindex d9ff41082..507505471 100644--- a/desktop/test/remote_folder_picker_test.dart+++ b/desktop/test/remote_folder_picker_test.dart@@ -45,7 +45,7 @@ class _Folders extends AppNotifier {Future<String?> createAgent(String machineId, {required String engine,- required String folder,+ required String? folder,ProjectFolderRequest? projectFolder,bool bypassPermission = false,String? permissionMode,@@ -58,7 +58,7 @@ class _Folders extends AppNotifier {PaneSplitRequest? split,AgentCreationAttempt? attempt,}) async {- launches.add((machine: machineId, engine: engine, folder: folder));+ launches.add((machine: machineId, engine: engine, folder: folder!));return null;}diff --git a/desktop/test/store_showcase_test.dart b/desktop/test/store_showcase_test.dartindex b59b32e35..cd5ce5352 100644--- a/desktop/test/store_showcase_test.dart+++ b/desktop/test/store_showcase_test.dart@@ -75,7 +75,7 @@ class _Notifier extends AppNotifier {Future<String?> createAgent(String machineId, {required String engine,- required String folder,+ required String? folder,bool bypassPermission = false,String? permissionMode,String? codexHome,diff --git a/desktop/test/swarm_closed_agents_test.dart b/desktop/test/swarm_closed_agents_test.dartindex 2fa441bd4..fdab07c0f 100644--- a/desktop/test/swarm_closed_agents_test.dart+++ b/desktop/test/swarm_closed_agents_test.dart@@ -108,10 +108,7 @@ void main() {expect(app.reopenClosed(), isTrue);expect(app.activeSwarm, same(restored));expect(app.panes.map((pane) => pane.agentId), ['a0', 'a1']);- expect(- app.swarms.where((swarm) => swarm.name == 'Solid'),- hasLength(1),- );+ expect(app.swarms.where((swarm) => swarm.name == 'Solid'), hasLength(1));expect(app.swarms.map((s) => s.id).toSet().length, app.swarms.length);},);@@ -252,28 +249,25 @@ void main() {},);- test(- 'with many tabs open, agent and tab recovery both still fit',- () async {- final app = createApp();- addTearDown(app.dispose);- await app.addAgentToSwarm('m', 'a0');- final origin = app.activeSwarmId;- await app.closePane(app.focusedPaneId!);- final agentId = app.closedHistory.single.historyId;- app.newSwarm(name: 'Closed group');- await app.closeSwarm(app.activeSwarmId);- while (app.swarms.length < 30) {- app.newSwarm(name: 'Occupied ${app.swarms.length}');- }- expect(app.canReopenLastClosed, isTrue);- expect(app.canReopenClosed(agentId), isTrue);- expect(app.reopenClosed(historyId: agentId), isTrue);- expect(app.activeSwarmId, origin);- expect(app.panes.single.agentId, 'a0');- expect(app.swarms, hasLength(30));- },- );+ test('with many tabs open, agent and tab recovery both still fit', () async {+ final app = createApp();+ addTearDown(app.dispose);+ await app.addAgentToSwarm('m', 'a0');+ final origin = app.activeSwarmId;+ await app.closePane(app.focusedPaneId!);+ final agentId = app.closedHistory.single.historyId;+ app.newSwarm(name: 'Closed group');+ await app.closeSwarm(app.activeSwarmId);+ while (app.swarms.length < 30) {+ app.newSwarm(name: 'Occupied ${app.swarms.length}');+ }+ expect(app.canReopenLastClosed, isTrue);+ expect(app.canReopenClosed(agentId), isTrue);+ expect(app.reopenClosed(historyId: agentId), isTrue);+ expect(app.activeSwarmId, origin);+ expect(app.panes.single.agentId, 'a0');+ expect(app.swarms, hasLength(30));+ });test('a full destination retains its closed agent until there is room',@@ -362,14 +356,21 @@ void main() {},);- testWidgets('Cmd-Shift-T restores the last removed agent', (tester) async {+ testWidgets('reopen restores the last removed agent; ⌘⇧T no longer does', (+ tester,+ ) async {final app = createApp();app.adoptSessionForTest(terminal('a0', []));final origin = app.activeSwarm;await mount(tester, app);await app.closePane(app.focusedPaneId!);await tester.pump();+ // ⌘⇧T is New Terminal now: nothing comes back, nothing is forgotten.await chord(tester, LogicalKeyboardKey.keyT, shift: true);+ expect(app.panes, isEmpty);+ expect(app.closedHistory, hasLength(1));+ expect(app.reopenClosed(), isTrue);+ await tester.pump();expect(app.activeSwarm, same(origin));expect(app.panes.single.agentId, 'a0');expect(app.closedHistory, isEmpty);@@ -397,7 +398,7 @@ void main() {final restored = app.activeSwarm;await mount(tester, app);- await chord(tester, LogicalKeyboardKey.keyT, shift: true);+ expect(app.reopenClosed(), isTrue);await tester.pump();expect(app.activeSwarm, same(restored));expect(restored.panes, [first, second]);diff --git a/desktop/test/swarm_reopen_test.dart b/desktop/test/swarm_reopen_test.dartindex e1b72236f..21eaba7c4 100644--- a/desktop/test/swarm_reopen_test.dart+++ b/desktop/test/swarm_reopen_test.dart@@ -7,6 +7,7 @@ import 'package:harness/auth/auth_session.dart';import 'package:harness/auth/cli_login.dart';import 'package:harness/core/config.dart';import 'package:harness/state/app_state.dart';+import 'package:harness/shortcuts/keymap_commands.dart';import 'package:harness/state/pane_preset.dart';import 'package:harness/terminal/terminal_session.dart';@@ -182,20 +183,26 @@ void main() {},);- testWidgets('Cmd-Shift-T restores the last closed swarm from the welcome', (- tester,- ) async {- final app = createApp();- await app.addAgentToSwarm('m', 'a0');- app.renameSwarm(app.activeSwarmId, 'My work');- await mount(tester, app);- await chord(tester, LogicalKeyboardKey.keyW);- expect(app.panes, isEmpty);- await chord(tester, LogicalKeyboardKey.keyT, shift: true);- expect(app.activeSwarm.name, 'My work');- expect(app.panes.single.agentId, 'a0');- expect(app.canReopenClosedSwarm, isFalse);- await tester.pumpWidget(const SizedBox());- app.dispose();- });+ testWidgets(+ 'Cmd-Shift-T is New Terminal now, not reopen; reopen stays a command with no default chord',+ (tester) async {+ final app = createApp();+ await app.addAgentToSwarm('m', 'a0');+ app.renameSwarm(app.activeSwarmId, 'My work');+ await mount(tester, app);+ await chord(tester, LogicalKeyboardKey.keyW);+ expect(app.panes, isEmpty);+ await chord(tester, LogicalKeyboardKey.keyT, shift: true);+ expect(app.panes, isEmpty);+ expect(app.canReopenClosedSwarm, isTrue);+ expect(harnessCommandById['swarm.reopen']!.keys, isEmpty);+ expect(harnessCommandById['terminal.new']!.keys, ['cmd+shift+t']);+ app.reopenClosedSwarm();+ expect(app.activeSwarm.name, 'My work');+ expect(app.panes.single.agentId, 'a0');+ expect(app.canReopenClosedSwarm, isFalse);+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ },+ );}diff --git a/desktop/test/terminal_engine_test.dart b/desktop/test/terminal_engine_test.dartnew file mode 100644index 000000000..58568da24--- /dev/null+++ b/desktop/test/terminal_engine_test.dart@@ -0,0 +1,124 @@+// A terminal is an engine the daemon calls `terminal`: a shell in a tile that+// becomes whatever gets typed into it and a shell again when that exits. What+// the app must get right about one is pinned here — its face, its chord, and+// that a tile already attached follows the engine change without reopening.+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/auth/auth_session.dart';+import 'package:harness/core/config.dart';+import 'package:harness/core/models.dart';+import 'package:harness/shortcuts/app_shortcuts.dart';+import 'package:harness/shortcuts/keymap_commands.dart';+import 'package:harness/state/app_state.dart';+import 'package:harness/terminal/terminal_session.dart';+import 'package:harness/widgets/engine_identity.dart';++void main() {+ group('the terminal engine has a face but is not an engine to pick', () {+ test('engineIdentity knows it, allEngines does not', () {+ final identity = engineIdentity(kTerminalEngine);+ expect(identity.id, 'terminal');+ expect(identity.label, 'Terminal');+ expect(isTerminalEngine('terminal'), isTrue);+ expect(isTerminalEngine('claude'), isFalse);+ expect(isTerminalEngine(null), isFalse);+ // New Harness and `engines_probe` never see it.+ expect(allEngines.map((e) => e.id), isNot(contains('terminal')));+ });+ });++ group('⌘⇧T', () {+ test('is New Terminal in the live table, and reopen keeps no chord', () {+ final shiftT = kSwarmShortcuts.where(+ (s) =>+ s.activator.trigger == LogicalKeyboardKey.keyT &&+ s.activator.meta &&+ s.activator.shift,+ );+ expect(shiftT.single.action, ShortcutAction.newTerminal);+ expect(+ appShortcuts().where(+ (s) => s.action == ShortcutAction.reopenClosedSwarm,+ ),+ isEmpty,+ );+ expect(harnessCommandById['terminal.new']!.keys, ['cmd+shift+t']);+ expect(harnessCommandById['terminal.new']!.nativeAction, 'newTerminal');+ expect(harnessCommandById['swarm.reopen']!.keys, isEmpty);+ // Still a command: the palette and the History menu list it.+ expect(+ harnessCommandById['swarm.reopen']!.action,+ ShortcutAction.reopenClosedSwarm,+ );+ });+ });++ group('a tile follows its agent\'s engine', () {+ const machine = Machine(+ machineId: 'm',+ authMode: MachineAuthMode.remote,+ name: 'Mac mini',+ );++ Map<String, dynamic> synced(String engine) => {+ 'type': 'agent_synced',+ 'payload': {+ 'agent': {+ 'id': 'term-1',+ 'name': 'Terminal 1',+ 'engine': engine,+ 'status': 'active',+ 'launch': {'state': 'ready'},+ 'terminal': {+ 'available': true,+ 'runtimes': [+ {'backend': 'tmux', 'paneId': '%9'},+ ],+ },+ },+ },+ };++ test(+ 'agent_synced with a new engine re-labels the open session in place',+ () async {+ final notifier = AppNotifier(+ config: AppConfig.dev,+ authSession: AuthSession(),+ configStore: null,+ );+ addTearDown(notifier.dispose);+ notifier.machineStates['m'] = MachineState(machine);+ await notifier.handleEventForTest('m', synced('terminal'));+ final session = TerminalSession(+ machineId: 'm',+ agentId: 'term-1',+ agentName: 'Terminal 1',+ engineId: 'terminal',+ send: (_, _) async => true,+ sendBinary: (_) async => true,+ );+ final pane = notifier.adoptSessionForTest(session);+ var notified = 0;+ session.addListener(() => notified++);++ // Somebody typed `claude` into it.+ await notifier.handleEventForTest('m', synced('claude'));+ expect(session.engineId, 'claude');+ expect(notified, 1);+ expect(notifier.panes.single, same(pane));+ expect(notifier.machineStates['m']!.agents.single.engine, 'claude');++ // And it exited.+ await notifier.handleEventForTest('m', synced('terminal'));+ expect(session.engineId, 'terminal');+ expect(notified, 2);+ // The same engine again says nothing.+ await notifier.handleEventForTest('m', synced('terminal'));+ expect(notified, 2);+ // Never removed by either flip.+ expect(notifier.panes, hasLength(1));+ },+ );+ });+}