Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix(desktop): drag a pane by anywhere on its title bar to swap it

0xdiego25f515cc458223
diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dart
index e82ed7cd6..cac26cfeb 100644
--- a/desktop/lib/widgets/terminal_panel.dart
+++ b/desktop/lib/widgets/terminal_panel.dart
@@ -3144,7 +3144,14 @@ class _TerminalHeader extends StatelessWidget {
// The header itself does NOT change — the whole tile fades instead, in
// _PaneCell, so what dims is the thing that is moving rather than one
// strip of it.
- child: strip,
+ //
+ // OPAQUE TO THE POINTER across its whole width. The strip is a SizedBox
+ // of a Row, so only its words and icons hit-test; a press on the empty
+ // space between them — most of the strip, and where a hand reaches to
+ // carry a pane — never reached this Draggable, and dragging a pane by its
+ // title did nothing (owner, 2026-10-01). The buttons on it still take
+ // their own clicks first.
+ child: ColoredBox(color: Colors.transparent, child: strip),
);
}
}
diff --git a/desktop/test/pane_drag_swap_test.dart b/desktop/test/pane_drag_swap_test.dart
new file mode 100644
index 000000000..6ccf6027c
--- /dev/null
+++ b/desktop/test/pane_drag_swap_test.dart
@@ -0,0 +1,99 @@
+// Dragging a pane by its header and dropping it on another pane trades their places.
+import 'package:flutter/gestures.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/screens/swarm_screen.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/shortcuts/app_keymap.dart';
+import 'package:harness/state/app_state.dart';
+import 'package:harness/state/swarm_catalog.dart';
+import 'package:harness/widgets/agent_drag.dart';
+
+import 'keymap_host_test.dart' show MemoryKeymap;
+import 'swarm_screen_test.dart' show terminal;
+import 'swarm_state_test.dart' show createApp;
+
+void main() {
+ late AppNotifier app;
+ late MemoryKeymap map;
+ late SwarmProjectStore projects;
+ setUp(() {
+ app = createApp();
+ app.stateOf('m')!.nodeOnline = true;
+ map = MemoryKeymap();
+ projects = SwarmProjectStore();
+ });
+ tearDown(() {
+ app.dispose();
+ map.dispose();
+ projects.dispose();
+ });
+
+ Agent agent(String id, String name) => Agent.fromJson({
+ 'id': id,
+ 'name': name,
+ 'engine': 'claude',
+ 'terminal': {'available': true},
+ });
+
+ testWidgets('dragging a pane by its header onto another swaps them', (
+ tester,
+ ) async {
+ app.stateOf('m')!.agents = [agent('a0', 'First'), agent('a1', 'Second')];
+ app.adoptSessionForTest(terminal('a0', []));
+ app.adoptSessionForTest(terminal('a1', []));
+ tester.view.devicePixelRatio = 1;
+ tester.view.physicalSize = const Size(1400, 800);
+ addTearDown(tester.view.reset);
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: KeymapProvider(
+ keymap: map,
+ child: SwarmScreen(
+ notifier: app,
+ projectStore: projects,
+ nativeTabs: false,
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+
+ final before = app.panes.map((p) => p.agentId).toList();
+ expect(before, ['a0', 'a1']);
+ final draggables = find.byWidgetPredicate(
+ (w) => w is Draggable<PaneDragRef>,
+ );
+ expect(
+ draggables,
+ findsNWidgets(2),
+ reason: 'each pane header is draggable',
+ );
+
+ final first = app.panes.first.id, second = app.panes.last.id;
+ final from = tester.getCenter(
+ find.descendant(
+ of: find.byKey(ValueKey('pane-frame:$first')),
+ matching: draggables,
+ ),
+ );
+ final to = tester.getCenter(find.byKey(ValueKey('pane-frame:$second')));
+ final gesture = await tester.startGesture(
+ from,
+ kind: PointerDeviceKind.mouse,
+ );
+ await tester.pump(const Duration(milliseconds: 50));
+ for (var i = 1; i <= 10; i++) {
+ await gesture.moveTo(Offset.lerp(from, to, i / 10)!);
+ await tester.pump(const Duration(milliseconds: 16));
+ }
+ // The drop target lights up while the pane is carried over it.
+ expect(find.text('Swap with this pane'), findsOneWidget);
+ await gesture.up();
+ await tester.pumpAndSettle();
+
+ expect(app.panes.map((p) => p.agentId).toList(), ['a1', 'a0']);
+ });
+}