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 device focus duplicating sessions across tabs (#438)
Deebba372768b2a
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex abc177948..4c8fb3669 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -10211,7 +10211,16 @@ class AppNotifier extends ChangeNotifier {/// the way a rail click does — that is an open, not a focus, and it claims/// only its own terminal.Future<void> focusAgentFromDevice(String machineId, String agentId) async {- final existing = paneOfAgent(machineId, agentId);+ // Device focus can name a pane on another tab. The current-tab lookup+ // alone turns that focus into an Add and copies the view into this tab.+ final existing =+ paneOfAgent(machineId, agentId) ??+ allPanes+ .where(+ (pane) =>+ pane.machineId == machineId && pane.agentId == agentId,+ )+ .firstOrNull;if (existing == null) {await _fromDevice(() =>diff --git a/desktop/test/dial_desk_test.dart b/desktop/test/dial_desk_test.dartindex ee729d697..bae86a5ff 100644--- a/desktop/test/dial_desk_test.dart+++ b/desktop/test/dial_desk_test.dart@@ -142,6 +142,44 @@ void main() {app.dispose();});+ test(+ 'dial focus reveals another tab without adding its agents here',+ () async {+ final app = await _withTiles(['a1', 'a2']);+ try {+ final desktop = app.activeSwarm;+ _machine(app, 'm2', ['a4']);+ app.newSwarm();+ final device = app.activeSwarm;+ await app.addAgentToSwarm('m1', 'a3');+ await app.addAgentToSwarm('m2', 'a4');+ final devicePanes = device.panes.toList();++ for (final (machineId, agentId) in [+ ('m1', 'a3'),+ ('m2', 'a4'),+ ('m1', 'a3'),+ ]) {+ app.selectSwarm(desktop.id);+ await app.handleEventForTest('m1', {+ 'type': 'dial_focus',+ 'payload': {'machineId': machineId, 'agentId': agentId},+ });++ expect(app.activeSwarmId, device.id);+ expect(app.focusedPane?.machineId, machineId);+ expect(app.focusedPane?.agentId, agentId);+ expect(app.paneFocusByUser, isFalse);+ expect(desktop.panes.map((p) => p.agentId), ['a1', 'a2']);+ expect(device.panes, devicePanes);+ expect(app.swarms, hasLength(2));+ }+ } finally {+ app.dispose();+ }+ },+ );+test('a dial-selected agent adds a view without replacing swarm membership',() async {@@ -449,6 +487,32 @@ void main() {);});+ test(+ 'dial focus finds a taken pane in another tab without reopening',+ () async {+ final first = app.activeSwarm;+ app.newSwarm();+ final second = app.activeSwarm;+ app.adoptSessionForTest(taken('a3'));+ app.selectSwarm(first.id);++ await dialFocus(app, 'a3');++ expect(app.activeSwarmId, second.id);+ expect(app.focusedPane?.agentId, 'a3');+ expect(app.paneFocusByUser, isFalse);+ expect(first.panes.map((p) => p.agentId), ['a1', 'a2']);+ expect(second.panes.map((p) => p.agentId), ['a3']);+ expect(+ app.focusedPane?.session?.status,+ TerminalSessionStatus.takenOver,+ );+ for (final id in ['a1', 'a2', 'a3']) {+ expect(opens(id), isEmpty);+ }+ },+ );+test('a question shown on the dial only brings the pane forward', () async {await app.handleEventForTest('m1', {'type': 'dial_open',