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
fix(desktop): Enter moves a conversation from a terminal without asking (#1116)
Deea18b55e3bf2e
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex 97822db9a..39c2f57bc 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -101,7 +101,6 @@ import '../state/toolbar_notices.dart';import '../widgets/machine_actions.dart';import '../widgets/rename_agent_dialog.dart';import '../widgets/delete_agent_dialog.dart';-import '../widgets/take_over_dialog.dart';import '../widgets/fork_agent_dialog.dart';import '../widgets/restart_agent_action.dart';import '../widgets/new_agent_dialog.dart';@@ -3774,7 +3773,6 @@ class _SwarmScreenState extends State<SwarmScreen> {String target, {PaneSplitRequest? split,HarnessPlacement? placement,- TakeOver? takeOver,}) async {final command = selected.destination.commandId;if (command != null) {@@ -3807,40 +3805,8 @@ class _SwarmScreenState extends State<SwarmScreen> {projects: _projects.projects,split: split,placement: placement,- takeOver: takeOver,);} on SwarmResumeFailure catch (failure) {- // Open in a terminal: ask whether to move it here — and, mid-turn,- // whether to wait for the turn or stop it. Asked again when a turn- // started between the question and the answer.- final ask =- failure.canTakeOver &&- (takeOver == null || (takeOver == TakeOver.idle && failure.busy));- if (ask && failure.destination.external != null) {- TakeOver? choice;- await _dialog(() async {- choice = await askTakeOver(- context,- title: failure.destination.title,- engine: failure.destination.external!.engine,- busy: failure.busy,- machine: failure.destination.machineLabel.isEmpty- ? null- : failure.destination.machineLabel,- keymap: _keymap,- );- });- if (choice case final choice? when mounted) {- await _activateSearch(- selected,- target,- split: split,- placement: placement,- takeOver: choice,- );- }- return;- }_showResumeFailure(failure, target: target, placement: placement);return;}diff --git a/desktop/lib/state/swarm_navigation.dart b/desktop/lib/state/swarm_navigation.dartindex c0db08ce4..001abf257 100644--- a/desktop/lib/state/swarm_navigation.dart+++ b/desktop/lib/state/swarm_navigation.dart@@ -272,7 +272,7 @@ class ExternalSessionRef {/// open, or the machine predates taking over.final String? openIn;- /// Open, and only in a terminal: opening it here moves it, once asked.+ /// Open, and only in a terminal: opening it here moves it.bool get inTerminal => open && openIn == 'terminal';/// Where it ran, as a person says it.@@ -892,8 +892,12 @@ Future<bool> activateSwarmSearchSelection(final machineId = destination.machineId;if (machineId == null || split != null) return false;// A new harness that resumes it, in its own folder: the machine refuses one- // that is open elsewhere, or already a harness, and says so — and one open- // in a terminal until asked how to take it over from there.+ // that is open elsewhere, or already a harness, and says so. One open in a+ // terminal is moved here without a question (the owner, 2026-10-09: "why do+ // we need to confirm? just move"): `wait` quits that terminal at once when+ // it is between turns, and holds the move until a running turn ends. Sent+ // with the first create, so a move the daemon must first verify (its search+ // service busy) keeps that consent rather than stalling as open elsewhere.final (:error, :refusal) = await app.resumeConversation(machineId,engine: external.engine,@@ -902,7 +906,7 @@ Future<bool> activateSwarmSearchSelection(name: external.title.isEmpty ? null : external.title,swarmId: destinationSwarmId,placement: placement ?? HarnessPlacement.currentTab,- takeOver: takeOver,+ takeOver: takeOver ?? TakeOver.wait,);if (error != null) {throw SwarmResumeFailure(destination, error, code: refusal);diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dartindex b56646dda..43f5ed525 100644--- a/desktop/lib/state/swarm_search.dart+++ b/desktop/lib/state/swarm_search.dart@@ -2283,7 +2283,7 @@ class SwarmSearchController extends ChangeNotifier {sessionId: external.sessionId,));if (external.open || previewed?.openElsewhere == true) {- // One in a terminal can be moved here: opening it asks how.+ // One in a terminal can be moved here: opening it moves it.final where = previewed?.openIn ?? external.openIn;if (where == 'terminal') return null;if (where == 'harness') return 'Already in Harness';diff --git a/desktop/lib/state/take_over.dart b/desktop/lib/state/take_over.dartindex 004cb7b59..f6aab54d5 100644--- a/desktop/lib/state/take_over.dart+++ b/desktop/lib/state/take_over.dart@@ -1,8 +1,3 @@-/// The engines that can resume with a first message, so Take Over Now can tell-/// them to continue (`FIRST_PROMPT_ARGS` in cli/src/lib/engineLaunch.ts). Any-/// other resumes where it was stopped and waits.-const engineResumesWithMessage = {'claude', 'codex', 'opencode'};-/// How to take a conversation over from the terminal that has it open: the/// `takeOver` of `agent_create`.enum TakeOver {diff --git a/desktop/lib/widgets/take_over_dialog.dart b/desktop/lib/widgets/take_over_dialog.dartdeleted file mode 100644index 6c246902d..000000000--- a/desktop/lib/widgets/take_over_dialog.dart+++ /dev/null@@ -1,153 +0,0 @@-import 'package:flutter/material.dart';--import '../shared/theme/app_theme.dart' as grid;-import '../shortcuts/app_keymap.dart';-import '../state/swarm_navigation.dart' show externalEngineName;-import '../state/take_over.dart';-import 'desktop_chrome.dart';-import 'desktop_prompt_surface.dart';-import 'terminal_prompt.dart';--export '../state/take_over.dart';--/// Asks whether to move a conversation open in a terminal into Harness. Idle,-/// the choice is to move it. Mid-turn, the choice is to wait for the turn to-/// end or stop it now. Null when dismissed: it stays where it is.-Future<TakeOver?> askTakeOver(- BuildContext context, {- required String title,- required String engine,- required bool busy,- String? machine,- AppKeymap? keymap,-}) => showTerminalPrompt<TakeOver>(- context,- keymap: keymap,- builder: (_) => _TakeOverPrompt(- title: title,- engine: engine,- busy: busy,- machine: machine,- ),-);--class _TakeOverPrompt extends StatefulWidget {- const _TakeOverPrompt({- required this.title,- required this.engine,- required this.busy,- this.machine,- });- final String title, engine;- final bool busy;- final String? machine;- @override- State<_TakeOverPrompt> createState() => _TakeOverPromptState();-}--class _TakeOverPromptState extends State<_TakeOverPrompt> {- final _first = FocusNode(debugLabel: 'Take over');-- @override- void initState() {- super.initState();- WidgetsBinding.instance.addPostFrameCallback((_) {- if (mounted) _first.requestFocus();- });- }-- @override- void dispose() {- _first.dispose();- super.dispose();- }-- void _pick(TakeOver? choice) => Navigator.pop(context, choice);-- String get _engineName => externalEngineName(widget.engine);-- @override- Widget build(BuildContext context) {- grid.AppTheme.watch(context);- final busy = widget.busy;- return TerminalPromptKeys(- cancel: () => _pick(null),- child: DesktopPromptSurface(- body: DesktopPromptScrollBody(- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- Text('Move to Harness', style: DesktopChrome.heading()),- const SizedBox(height: DesktopChrome.groupGap),- Text(- widget.title,- key: const ValueKey('take-over-title'),- maxLines: 2,- overflow: TextOverflow.ellipsis,- style: DesktopChrome.text(size: 14, medium: true),- ),- if (widget.machine case final machine?) ...[- const SizedBox(height: 4),- Text(- machine,- style: DesktopChrome.text(- size: 13,- color: DesktopChrome.muted,- ),- ),- ],- const SizedBox(height: 16),- Text(- busy- ? '$_engineName is working on it in a terminal.'- : 'It is open in $_engineName in a terminal. '- 'Moving it here quits it there.',- style: DesktopChrome.text(size: 13),- ),- const SizedBox(height: 8),- Text(- busy- ? engineResumesWithMessage.contains(widget.engine)- ? 'Wait moves it here when this turn ends. '- 'Take Over Now stops the turn and tells it to continue.'- : 'Wait moves it here when this turn ends. '- 'Take Over Now stops the turn; it picks up when you ask.'- : 'The conversation is kept.',- style: DesktopChrome.text(size: 13, color: DesktopChrome.muted),- ),- ],- ),- ),- actions: [- TextButton(- onPressed: () => _pick(null),- style: TextButton.styleFrom(- foregroundColor: DesktopChrome.foreground,- textStyle: DesktopChrome.text(size: 13),- ),- child: const Text('Cancel'),- ),- if (busy)- OutlinedButton(- key: const Key('take-over-now'),- onPressed: () => _pick(TakeOver.now),- style: OutlinedButton.styleFrom(- foregroundColor: Theme.of(context).colorScheme.error,- textStyle: DesktopChrome.text(size: 13),- ),- child: const Text('Take Over Now'),- ),- FilledButton(- key: Key(busy ? 'take-over-wait' : 'take-over-move'),- focusNode: _first,- onPressed: () => _pick(busy ? TakeOver.wait : TakeOver.idle),- style: FilledButton.styleFrom(- textStyle: DesktopChrome.text(size: 13),- ),- child: Text(busy ? 'Wait' : 'Move Here'),- ),- ],- ),- );- }-}diff --git a/desktop/test/take_over_dialog_test.dart b/desktop/test/take_over_dialog_test.dartdeleted file mode 100644index 1449da430..000000000--- a/desktop/test/take_over_dialog_test.dart+++ /dev/null@@ -1,133 +0,0 @@-import 'package:flutter/material.dart';-import 'package:flutter_test/flutter_test.dart';-import 'package:harness/shared/theme/app_theme.dart' as grid;-import 'package:harness/widgets/take_over_dialog.dart';--void main() {- Future<TakeOver?> ask(- WidgetTester tester, {- required String engine,- required bool busy,- String? pick,- Brightness brightness = Brightness.dark,- double scale = 1,- Size size = const Size(800, 600),- }) async {- TakeOver? chosen;- var answered = false;- tester.view.devicePixelRatio = 1;- tester.view.physicalSize = size;- addTearDown(tester.view.reset);- final oldBrightness = grid.AppTheme.brightness.value;- grid.AppTheme.brightness.value = brightness;- addTearDown(() => grid.AppTheme.brightness.value = oldBrightness);- await tester.pumpWidget(- MaterialApp(- theme: grid.buildAppTheme(brightness: brightness),- builder: (context, child) => MediaQuery(- data: MediaQuery.of(context)- .copyWith(textScaler: TextScaler.linear(scale)),- child: child!,- ),- home: Builder(- builder: (context) => TextButton(- onPressed: () async {- chosen = await askTakeOver(- context,- title: 'Retention cohorts',- engine: engine,- busy: busy,- machine: 'M2',- );- answered = true;- },- child: const Text('open'),- ),- ),- ),- );- await tester.tap(find.text('open'));- await tester.pumpAndSettle();- if (pick != null) {- await tester.tap(find.byKey(Key(pick)));- await tester.pumpAndSettle();- expect(answered, isTrue);- }- return chosen;- }-- testWidgets(- 'an idle session is moved; the engine is named as people call it',- (tester) async {- final chosen = await ask(- tester,- engine: 'claude',- busy: false,- pick: 'take-over-move',- );- expect(chosen, TakeOver.idle);- },- );-- testWidgets(- 'mid-turn, the prompt promises "continue" only to an engine that can take one',- (tester) async {- await ask(tester, engine: 'codex', busy: true);- expect(- find.text('Codex is working on it in a terminal.'),- findsOneWidget,- );- expect(find.textContaining('tells it to continue'), findsOneWidget);- await tester.tap(find.byKey(const Key('take-over-now')));- await tester.pumpAndSettle();-- await ask(tester, engine: 'grok', busy: true);- expect(find.text('Grok is working on it in a terminal.'), findsOneWidget);- expect(find.textContaining('tells it to continue'), findsNothing);- expect(find.textContaining('it picks up when you ask'), findsOneWidget);- expect(find.text('M2'), findsOneWidget);- },- );-- testWidgets('Wait waits, and Cancel leaves it where it is', (tester) async {- expect(- await ask(tester, engine: 'opencode', busy: true, pick: 'take-over-wait'),- TakeOver.wait,- );- await ask(tester, engine: 'pi', busy: false);- await tester.tap(find.text('Cancel'));- await tester.pumpAndSettle();- expect(find.text('Move to Harness'), findsNothing);- });-- for (final brightness in Brightness.values) {- testWidgets(- 'takeover keeps its safe default and visible choices in a short ${brightness.name} window',- (tester) async {- await ask(- tester,- engine: 'codex',- busy: true,- brightness: brightness,- scale: 1.7,- size: const Size(440, 360),- );- final wait = find.byKey(const Key('take-over-wait'));- expect(- tester.widget<FilledButton>(wait).focusNode!.hasPrimaryFocus,- isTrue,- );- expect(wait.hitTestable(), findsOneWidget);- expect(- find.byKey(const Key('take-over-now')).hitTestable(),- findsOneWidget,- );- expect(find.text('Cancel').hitTestable(), findsOneWidget);- expect(tester.takeException(), isNull);- await tester.tap(find.text('Cancel'));- await tester.pumpAndSettle();- expect(find.text('Move to Harness'), findsNothing);- },- );- }-}diff --git a/desktop/test/welcome_sessions_test.dart b/desktop/test/welcome_sessions_test.dartindex 9ccbdfb3b..d489e9cc6 100644--- a/desktop/test/welcome_sessions_test.dart+++ b/desktop/test/welcome_sessions_test.dart@@ -433,7 +433,7 @@ void main() {);testWidgets(- 'one open in a terminal is offered, and opening it asks how to move it here',+ 'one open in a terminal is offered, and opening it moves it here without asking',(tester) async {newHarnessOpensInBox = true;addTearDown(() => newHarnessOpensInBox = false);@@ -489,27 +489,70 @@ void main() {await tester.tap(find.text('Investigate Harness crash'));await tester.pump(const Duration(milliseconds: 100));await tester.pump(const Duration(milliseconds: 100));+ // One create: it says to move it, waiting for a running turn to end.+ expect(connection.creates, hasLength(1));expect(connection.creates.single,containsPair('resumeSessionId', 'e-busy'),);- expect(connection.creates.single.containsKey('takeOver'), isFalse);- expect(- find.text('Codex is working on it in a terminal.'),- findsOneWidget,- );- expect(find.byKey(const Key('take-over-wait')), findsOneWidget);+ expect(connection.creates.single, containsPair('takeOver', 'wait'));+ expect(find.text('Move to Harness'), findsNothing);+ expect(app.panes.map((pane) => pane.agentId), ['moved']);+ await tester.pumpWidget(const SizedBox());+ },+ );- await tester.tap(find.byKey(const Key('take-over-now')));+ testWidgets(+ 'one between turns in a terminal moves here at once: its terminal quits, nothing is asked',+ (tester) async {+ newHarnessOpensInBox = true;+ addTearDown(() => newHarnessOpensInBox = false);+ final connection = TailConnection(+ {+ '': [+ _external(+ 'e-idle',+ 'Fix the stuck pane',+ const Duration(minutes: 1),+ open: true,+ openIn: 'terminal',+ ),+ ],+ },+ tail: (_) => {'rows': [], 'hasMore': false, 'total': 0},+ create: (payload) => payload['takeOver'] == null+ ? {+ 'creationId': payload['creationId'],+ 'state': 'failed',+ 'failure': {+ 'code': 'SESSION_OPEN_IN_TERMINAL',+ 'detail': 'It is open in Claude Code in a terminal.',+ },+ }+ : {+ 'creationId': payload['creationId'],+ 'state': 'created',+ 'agent': {+ 'id': 'moved',+ 'name': 'Fix the stuck pane',+ 'engine': 'claude',+ },+ },+ );+ final app = createApp(+ connected: true,+ connectionForTest: (_) => connection,+ );+ addTearDown(app.dispose);+ await mount(tester, app);+ await tester.pump(const Duration(milliseconds: 50));+ await tester.tap(find.text('Fix the stuck pane'));await tester.pump(const Duration(milliseconds: 100));await tester.pump(const Duration(milliseconds: 100));- expect(connection.creates, hasLength(2));- expect(connection.creates.last, containsPair('takeOver', 'now'));- expect(- connection.creates.last,- containsPair('resumeSessionId', 'e-busy'),- );- expect(find.byKey(const Key('take-over-now')), findsNothing);+ // Between turns, `wait` moves it at once: one create, no question.+ expect(connection.creates, hasLength(1));+ expect(connection.creates.single, containsPair('takeOver', 'wait'));+ expect(find.text('Move to Harness'), findsNothing);expect(app.panes.map((pane) => pane.agentId), ['moved']);await tester.pumpWidget(const SizedBox());},