Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
710fbeaaeThis file is pinned to the selected release. Download the original to open it in your design tool.
// The desk: the account's tabs, the same on every computer. The pure half
// (diff and replay) and the window's half (a document becomes `swarms`, an
// edit becomes ops, and what a window keeps for itself stays put).
import 'dart:ui' show Rect;
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/state/desk_sync.dart';
import 'package:harness/state/pane_arrangement.dart';
import 'package:harness/state/pane_layout_store.dart';
import 'package:harness/state/pane_preset.dart';
import 'package:harness/state/swarm.dart';
import 'package:harness/state/terminal_pane.dart';
import 'package:harness/terminal/terminal_session.dart';
import 'swarm_state_test.dart' show MemoryStore, createApp;
DeskTab tab(
String id, {
String name = 'Tab',
bool custom = false,
List<String> agents = const [],
}) => DeskTab(
id: id,
name: name,
nameIsCustom: custom,
panes: [for (final a in agents) DeskPaneRef(machineId: 'm', agentId: a)],
);
/// The daemon's desk proxy, scripted: a document to hand out, the ops it was
/// asked to apply (applied with the same rules the backend uses), or a failure.
class _DeskApi extends ApiClient {
_DeskApi() : super(config: AppConfig.dev, session: AuthSession());
DeskDoc? doc = const DeskDoc(revision: 0, tabs: []);
bool available = true;
Object? failWith;
final batches = <List<Map<String, dynamic>>>[];
Map<String, dynamic>? _json(DeskDoc d) => {
'revision': d.revision,
'tabs': [for (final t in d.tabs) t.toJson()],
};
@override
Future<Map<String, dynamic>?> desk() async {
if (failWith != null) throw failWith!;
if (!available || doc == null) return null;
return _json(doc!);
}
@override
Future<Map<String, dynamic>?> deskOps(List<Map<String, dynamic>> ops) async {
if (failWith != null) throw failWith!;
if (!available || doc == null) return null;
batches.add(ops);
final next = applyDeskOps(doc!.tabs, ops);
doc = DeskDoc(revision: doc!.revision + 1, tabs: next);
return _json(doc!);
}
}
void main() {
group('deskDiff', () {
test('creates a tab with its panes, closes, renames only what the person named, and reorders', () {
final before = [
tab('a', agents: ['x']),
tab('b', name: 'derived'),
];
final after = [
tab('b', name: 'Home', custom: true),
tab('c', name: 'New', agents: ['y', 'z']),
];
final ops = deskDiff(before, after);
expect(ops.map((o) => o['op']), [
'tab.close',
'tab.create',
'pane.add',
'pane.add',
'tab.rename',
]);
expect(ops[1], {
'op': 'tab.create',
'id': 'c',
'name': 'New',
'index': 1,
});
expect(ops[2], {
'op': 'pane.add',
'tabId': 'c',
'machineId': 'm',
'agentId': 'y',
'index': 0,
});
expect(ops[4], {
'op': 'tab.rename',
'id': 'b',
'name': 'Home',
'nameIsCustom': true,
});
// A derived name that differs is each window's own to derive — no op.
expect(
deskDiff([tab('b', name: 'one')], [tab('b', name: 'two')]),
isEmpty,
);
// Order of tabs both sides have.
expect(
deskDiff(
[tab('a'), tab('b')],
[tab('b'), tab('a')],
).map((o) => o['op']),
['tab.move', 'tab.move'],
);
});
test('adds, removes and moves panes within a tab', () {
final ops = deskDiff(
[
tab('a', agents: ['x', 'y']),
],
[
tab('a', agents: ['y', 'z']),
],
);
expect(ops, [
{'op': 'pane.remove', 'tabId': 'a', 'machineId': 'm', 'agentId': 'x'},
{
'op': 'pane.add',
'tabId': 'a',
'machineId': 'm',
'agentId': 'z',
'index': 1,
},
]);
final moved = deskDiff(
[
tab('a', agents: ['x', 'y']),
],
[
tab('a', agents: ['y', 'x']),
],
);
expect(moved.map((o) => o['op']), ['pane.move', 'pane.move']);
expect(
deskDiff(
[
tab('a', agents: ['x']),
],
[
tab('a', agents: ['x']),
],
),
isEmpty,
);
});
test(
'replays like the backend: idempotent, and nothing on a tab that is gone',
() {
final tabs = applyDeskOps(
[tab('a')],
[
{'op': 'pane.add', 'tabId': 'a', 'machineId': 'm', 'agentId': 'x'},
{'op': 'pane.add', 'tabId': 'a', 'machineId': 'm', 'agentId': 'x'},
{'op': 'tab.close', 'id': 'a'},
{'op': 'pane.add', 'tabId': 'a', 'machineId': 'm', 'agentId': 'y'},
{'op': 'tab.create', 'id': 'b', 'name': 'B', 'index': 0},
{'op': 'tab.create', 'id': 'b', 'name': 'B'},
],
);
expect(tabs.map((t) => t.id), ['b']);
// A diff, replayed, is the "after" it was taken from.
final before = [
tab('a', agents: ['x', 'y']),
tab('b'),
];
final after = [
tab('b', name: 'Home', custom: true),
tab('a', agents: ['y']),
tab('c', agents: ['z']),
];
final replayed = applyDeskOps(before, deskDiff(before, after));
expect(
[for (final t in replayed) t.toJson()],
[for (final t in after) t.toJson()],
);
},
);
test(
'desk ids are 32 hex characters; a window\'s own numbering is not one',
() {
expect(isDeskId(newDeskId()), isTrue);
expect(newDeskId(), isNot(newDeskId()));
expect(isDeskId('swarm-3'), isFalse);
},
);
});
group('the window and the desk', () {
for (final destinationFirst in [false, true]) {
for (final closeSource in [false, true]) {
test(
'a remote pane move preserves its terminal (destination first: $destinationFirst, source closed: $closeSource)',
() async {
final api = _DeskApi();
final app = createApp()..api = api;
addTearDown(app.dispose);
final sent = <String>[];
final session =
TerminalSession(
machineId: 'm',
agentId: 'a0',
agentName: 'Agent 0',
engineId: 'codex',
send: (type, _) async {
sent.add(type);
return true;
},
sendBinary: (_) async => true,
)
..status = TerminalSessionStatus.controlling
..streamId = 'existing-stream';
session.terminal.write('output before the move');
final moved = app.adoptSessionForTest(session);
final source = app.activeSwarm;
app.newSwarm(name: 'Destination');
final destination = app.activeSwarm;
app.selectSwarm(source.id);
await app.deskStartForTest();
final tabs = [
if (!closeSource) tab(source.id),
tab(
destination.id,
name: 'Destination',
custom: true,
agents: ['a0'],
),
];
api.doc = DeskDoc(
revision: api.doc!.revision + 1,
tabs: destinationFirst ? tabs.reversed.toList() : tabs,
);
await app.deskFetchForTest();
expect(destination.panes.single, same(moved));
expect(moved.session, same(session));
expect(session.streamId, 'existing-stream');
expect(
session.terminal.buffer.getText(),
contains('output before the move'),
);
expect(
sent.where(
(type) => type == 'terminal_close' || type == 'terminal_open',
),
isEmpty,
);
},
);
}
}
test(
'a remote move changing the focused pane does not claim terminal control',
() async {
final api = _DeskApi();
final app = createApp()..api = api;
addTearDown(app.dispose);
await app.addAgentToSwarm('m', 'a0');
await app.addAgentToSwarm('m', 'a1');
final source = app.activeSwarm;
app.newSwarm(name: 'Destination');
final destination = app.activeSwarm;
app.selectSwarm(source.id);
app.focusPane(source.panes.first.id);
await app.deskStartForTest();
expect(app.paneFocusByUser, isTrue);
api.doc = DeskDoc(
revision: api.doc!.revision + 1,
tabs: [
tab(source.id, agents: ['a1']),
tab(
destination.id,
name: 'Destination',
custom: true,
agents: ['a0'],
),
],
);
await app.deskFetchForTest();
expect(app.focusedPane?.agentId, 'a1');
expect(app.paneFocusByUser, isFalse);
},
);
test('joins the desk: its own tabs get desk ids and are seeded, the desk\'s tabs appear as intent', () async {
final api = _DeskApi()
..doc = DeskDoc(
revision: 4,
tabs: [
tab(
'd1',
name: 'From the other Mac',
custom: true,
agents: ['a5', 'a6'],
),
],
);
final app = createApp()..api = api;
addTearDown(app.dispose);
await app.addAgentToSwarm(
'm',
'a0',
); // this window's own tab, numbered swarm-N
final own = app.activeSwarm;
expect(isDeskId(own.id), isFalse);
await app.deskStartForTest();
expect(
isDeskId(own.id),
isTrue,
reason: 'the local tab was given a desk id',
);
expect(api.batches.single.single['op'], 'seed');
// The desk's own tabs first, this computer's after them — that is where the seed puts them.
expect(app.swarms.map((s) => s.id), ['d1', own.id]);
final remote = app.swarms.first;
expect(remote.name, 'From the other Mac');
expect(remote.panes.map((p) => p.agentId), ['a5', 'a6']);
expect(
remote.panes.every((p) => p.session == null),
isTrue,
reason: 'intent only until the machine answers',
);
expect(
app.activeSwarmId,
own.id,
reason: 'the active tab is this window\'s',
);
expect(app.deskSyncForTest.revision, 5);
expect(app.deskSyncForTest.pending, isEmpty);
});
test(
'says every edit as ops: new tab, a pane, a rename, an order, a close',
() async {
final api = _DeskApi();
final app = createApp()..api = api;
addTearDown(app.dispose);
await app.deskStartForTest();
api.batches.clear();
app.newSwarm(name: 'Work');
final work = app.activeSwarm;
expect(isDeskId(work.id), isTrue);
await app.addAgentToSwarm('m', 'a1');
app.renameSwarm(work.id, 'Real work');
app.newSwarm(name: 'Second');
final second = app.activeSwarm;
app.reorderSwarm(second.id, 0);
await app.closeSwarm(work.id);
await Future<void>.delayed(Duration.zero);
final sent = api.batches.expand((b) => b).map((o) => o['op']).toList();
expect(
sent,
containsAllInOrder([
'tab.create',
'pane.add',
'tab.rename',
'tab.create',
'tab.move',
'tab.close',
]),
);
// The starter tab this window opened with is on the desk too (empty, unnamed) — a tab is a tab.
final ids = api.doc!.tabs.map((t) => t.id).toList();
expect(ids, contains(second.id));
expect(ids, isNot(contains(work.id)));
expect(
ids,
app.swarms.map((s) => s.id).toList(),
reason: 'the desk and the window agree on order',
);
expect(app.deskSyncForTest.pending, isEmpty);
},
);
test('a desk_changed push closes a tab closed elsewhere and opens one opened elsewhere, keeping this window\'s focus', () async {
final api = _DeskApi()
..doc = DeskDoc(
revision: 1,
tabs: [
tab('d1', name: 'One', custom: true, agents: ['a1', 'a2']),
tab('d2', name: 'Two', custom: true, agents: ['a3']),
],
);
final app = createApp()..api = api;
addTearDown(app.dispose);
await app.deskStartForTest();
api.batches.clear();
app.selectSwarm('d1');
final d1 = app.activeSwarm;
final second = d1.panes[1];
app.focusPane(second.id);
expect(d1.focusedPaneId, second.id);
// The other Mac: closed Two, renamed One, added a pane to One, opened Three.
api.doc = DeskDoc(
revision: 9,
tabs: [
tab('d3', name: 'Three', custom: true, agents: ['a9']),
tab(
'd1',
name: 'One, really',
custom: true,
agents: ['a1', 'a2', 'a4'],
),
],
);
await app.handleEventForTest('m', {
'type': 'desk_changed',
'payload': {'revision': 9},
});
await Future<void>.delayed(Duration.zero);
// This window's starter tab went too: the other Mac's document did not have it.
expect(app.swarms.map((s) => s.id), ['d3', 'd1']);
expect(app.activeSwarmId, 'd1');
expect(d1.name, 'One, really');
expect(d1.panes.map((p) => p.agentId), ['a1', 'a2', 'a4']);
expect(d1.focusedPaneId, second.id, reason: 'focus is this window\'s');
expect(
api.batches,
isEmpty,
reason: 'applying the desk sends nothing back',
);
});
test('a document that did not move a tab\'s order leaves this window\'s tiles, sizes and pins alone', () async {
final api = _DeskApi()
..doc = DeskDoc(
revision: 1,
tabs: [
tab('d1', name: 'One', custom: true, agents: ['a1', 'a2']),
],
);
final app = createApp()..api = api;
addTearDown(app.dispose);
await app.deskStartForTest();
app.selectSwarm('d1');
final d1 = app.activeSwarm;
// This window's own furniture: a viewer between the two agents, a size the
// person dragged, a pin on the second agent.
final viewer = TerminalPane(
id: 900,
machineId: 'm',
kind: PaneKind.web,
ownerAgentId: 'a1',
url: 'http://127.0.0.1:1/',
);
d1.panes.insert(1, viewer);
final sizes = PaneArrangement([
Rect.fromLTWH(0, 0, 0.5, 1),
Rect.fromLTWH(0.5, 0, 0.5, 0.5),
Rect.fromLTWH(0.5, 0.5, 0.5, 0.5),
]);
d1.savePaneSizes('3:manual', sizes);
app.togglePinPane(d1.panes[2].id);
await Future<void>.delayed(Duration.zero);
api.batches.clear();
// The 15 s poll, and a push about another tab: the same order for this one
// (and, as the server would, the layout this window already sent up).
api.doc = DeskDoc(
revision: 5,
tabs: [
api.doc!.tabs.firstWhere((t) => t.id == 'd1'),
tab('d2', name: 'Two', custom: true, agents: ['a3']),
],
);
await app.deskFetchForTest();
await app.handleEventForTest('m', {
'type': 'desk_changed',
'payload': {'revision': 6},
});
await Future<void>.delayed(Duration.zero);
expect(d1.panes.map((p) => p.agentId ?? 'viewer'), [
'a1',
'viewer',
'a2',
]);
expect(identical(d1.paneSizes['3:manual'], sizes), isTrue);
expect(d1.pinnedSlots, {d1.panes[2].id: 2});
expect(api.batches, isEmpty, reason: 'nothing to say back');
});
test('a reorder made elsewhere moves the agent panes into their slots and nothing else', () async {
final api = _DeskApi()
..doc = DeskDoc(
revision: 1,
tabs: [
tab('d1', name: 'One', custom: true, agents: ['a1', 'a2', 'a3']),
],
);
final app = createApp()..api = api;
addTearDown(app.dispose);
await app.deskStartForTest();
app.selectSwarm('d1');
final d1 = app.activeSwarm;
final viewer = TerminalPane(
id: 900,
machineId: 'm',
kind: PaneKind.web,
ownerAgentId: 'a1',
url: 'http://127.0.0.1:1/',
);
d1.panes.insert(1, viewer);
final sizes = PaneArrangement([
Rect.fromLTWH(0, 0, 0.5, 1),
Rect.fromLTWH(0.5, 0, 0.5, 0.5),
Rect.fromLTWH(0.5, 0.5, 0.25, 0.5),
Rect.fromLTWH(0.75, 0.5, 0.25, 0.5),
]);
d1.savePaneSizes('4:manual', sizes);
final a3 = d1.panes[3];
app.togglePinPane(a3.id); // pinned in slot 3
await Future<void>.delayed(Duration.zero);
api.batches.clear();
// The other Mac dragged a3 to the front (the layout as the server holds it rides along).
api.doc = DeskDoc(
revision: 7,
tabs: [
api.doc!.tabs
.firstWhere((t) => t.id == 'd1')
.copyWith(
panes: [
for (final a in ['a3', 'a1', 'a2'])
DeskPaneRef(machineId: 'm', agentId: a),
],
),
],
);
await app.handleEventForTest('m', {
'type': 'desk_changed',
'payload': {'revision': 7},
});
await Future<void>.delayed(Duration.zero);
// Agent panes take the agent slots (0, 2, 3) in the desk's order; the
// viewer keeps slot 1; the size arrangement is untouched; the pin
// followed a3 to its new slot.
expect(d1.panes.map((p) => p.agentId ?? 'viewer'), [
'a3',
'viewer',
'a1',
'a2',
]);
expect(identical(d1.paneSizes['4:manual'], sizes), isTrue);
expect(d1.pinnedSlots, {a3.id: 0});
expect(app.deskSyncForTest.pending, isEmpty);
expect(
api.batches,
isEmpty,
reason: 'the order came from the desk; nothing to send back',
);
});
test(
'at the join the desk\'s order wins over the layout this window restored',
() async {
final id = newDeskId();
final api = _DeskApi()
..doc = DeskDoc(
revision: 3,
tabs: [
tab(id, name: 'One', custom: true, agents: ['a2', 'a1']),
],
);
final app = createApp()..api = api;
addTearDown(app.dispose);
// Restored from before: the same tab, the other way round.
app.newSwarm(name: 'One');
final local = app.activeSwarm..id = id;
await app.addAgentToSwarm('m', 'a1', swarmId: id);
await app.addAgentToSwarm('m', 'a2', swarmId: id);
expect(local.panes.map((p) => p.agentId), ['a1', 'a2']);
await app.deskStartForTest();
expect(app.swarms.where((s) => s.id == id).length, 1);
expect(local.panes.map((p) => p.agentId), ['a2', 'a1']);
expect(
api.batches.expand((b) => b).where((o) => o['op'] == 'pane.move'),
isEmpty,
reason: 'this window changed nothing',
);
},
);
test('a restart keeps the window\'s layout: preset, sizes, pins, focus and zoom survive the join', () async {
// The desk holds membership, order and names; everything else is this
// window's and lives in its saved layout. Restoring that layout and then
// joining a desk that already has the tab must change none of it.
final id = newDeskId();
final storage = MemoryStore();
final store = PaneLayoutStore(storage: storage);
final sizes = PaneArrangement([
Rect.fromLTWH(0, 0, 0.3, 1),
Rect.fromLTWH(0.3, 0, 0.7, 1),
]);
final saved = Swarm(id: id, name: 'Work', nameIsCustom: true)
..panes.addAll([
TerminalPane(id: 1, machineId: 'm', agentId: 'a1'),
TerminalPane(id: 2, machineId: 'm', agentId: 'a2'),
])
..presets[2] = PanePreset.rows
..savePaneSizes('2:manual', sizes)
..focusedPaneId = 2
..zoomedPaneId = 2;
saved.pinnedSlots[2] = 1;
await store.saveSwarms([saved], id);
final api = _DeskApi()
..doc = DeskDoc(
revision: 20,
tabs: [
tab(id, name: 'Work', custom: true, agents: ['a1', 'a2']),
],
);
final app = createApp(store: storage)..api = api;
addTearDown(app.dispose);
await app.restorePaneLayoutForTest();
final work = app.swarms.singleWhere((s) => s.id == id);
expect(work.presets[2], PanePreset.rows);
final focused = work.focusedPaneId, zoomed = work.zoomedPaneId;
expect(focused, isNotNull);
expect(zoomed, isNotNull);
await app.deskStartForTest();
await Future<void>.delayed(Duration.zero);
expect(app.swarms.map((s) => s.id), [id]);
expect(work.panes.map((p) => p.agentId), ['a1', 'a2']);
expect(
work.presets[2],
PanePreset.rows,
reason: 'the preset is the window\'s',
);
expect(work.paneSizes['2:manual']?.tiles, sizes.tiles);
expect(work.focusedPaneId, focused);
expect(work.zoomedPaneId, zoomed);
expect(work.pinnedSlots.values, [1]);
// The desk held no layout for the tab: it learns this window's, once.
final sent = api.batches.expand((b) => b).toList();
expect(sent.map((o) => o['op']), ['tab.layout']);
expect(api.doc!.tabs.single.layout?.presets, {'2': 'rows'});
});
test('a preset chosen or a split dragged here is the layout on the other Mac too', () async {
// The desk carries presets and arrangements since 2026-09-22 ("máy kia
// không có layout"). Focus, zoom and pins stay this window's.
final api = _DeskApi();
final app = createApp()..api = api;
addTearDown(app.dispose);
await app.deskStartForTest();
app.newSwarm(name: 'Work');
final work = app.activeSwarm;
await app.addAgentToSwarm('m', 'a1', swarmId: work.id);
await app.addAgentToSwarm('m', 'a2', swarmId: work.id);
await Future<void>.delayed(Duration.zero);
api.batches.clear();
app.setPreset(2, PanePreset.rows);
await Future<void>.delayed(Duration.zero);
final onDesk = () =>
api.doc!.tabs.singleWhere((t) => t.id == work.id).layout;
expect(onDesk()?.presets, {'2': 'rows'});
expect(
api.batches.expand((b) => b).where((o) => o['op'] == 'tab.layout'),
hasLength(1),
);
// A drag: the arrangement travels as fractions of the canvas.
final sizes = PaneArrangement([
Rect.fromLTWH(0, 0, 0.3, 1),
Rect.fromLTWH(0.3, 0, 0.7, 1),
]);
work.savePaneSizes('2:manual', sizes);
app.persistLayoutForTest();
await Future<void>.delayed(Duration.zero);
expect(onDesk()?.sizes['2:manual'], sizes.toJson());
// The other Mac, joining: the same tab with the same preset and split.
final other = createApp()..api = api;
addTearDown(other.dispose);
await other.deskStartForTest();
final theirs = other.swarms.singleWhere((s) => s.id == work.id);
expect(theirs.presets[2], PanePreset.rows);
expect(theirs.paneSizes['2:manual']?.tiles, sizes.tiles);
expect(
theirs.focusedPaneId,
isNot(work.focusedPaneId),
reason: 'focus is each window\'s own',
);
});
test('a document that did not move the layout leaves a drag in progress alone; one that did applies it', () async {
final id = newDeskId();
final api = _DeskApi()
..doc = DeskDoc(
revision: 1,
tabs: [
tab(id, name: 'Work', custom: true, agents: ['a1', 'a2']),
],
);
final app = createApp()..api = api;
addTearDown(app.dispose);
await app.deskStartForTest();
app.selectSwarm(id);
final work = app.activeSwarm;
// This window drags while the backend is unreachable: the op waits, the
// arrangement stands.
api.failWith = StateError('offline');
final mine = PaneArrangement([
Rect.fromLTWH(0, 0, 0.6, 1),
Rect.fromLTWH(0.6, 0, 0.4, 1),
]);
work.savePaneSizes('2:manual', mine);
app.persistLayoutForTest();
await Future<void>.delayed(Duration.zero);
api.failWith = null;
// A push about something else (a new tab) — the layout on the desk for this tab did not move.
api.doc = DeskDoc(
revision: 3,
tabs: [
tab(id, name: 'Work', custom: true, agents: ['a1', 'a2']),
tab('other', name: 'Other', custom: true),
],
);
await app.handleEventForTest('m', {
'type': 'desk_changed',
'payload': {'revision': 3},
});
await Future<void>.delayed(Duration.zero);
expect(work.paneSizes['2:manual']?.tiles, mine.tiles);
await app.deskFlushForTest();
expect(api.doc!.tabs.first.layout?.sizes['2:manual'], mine.toJson());
// The other Mac chose a preset for this tab: it applies here.
api.doc = DeskDoc(
revision: 9,
tabs: [
DeskTab(
id: id,
name: 'Work',
nameIsCustom: true,
panes: [
const DeskPaneRef(machineId: 'm', agentId: 'a1'),
const DeskPaneRef(machineId: 'm', agentId: 'a2'),
],
layout: const DeskLayout(presets: {'2': 'rows'}),
),
tab('other', name: 'Other', custom: true),
],
);
await app.handleEventForTest('m', {
'type': 'desk_changed',
'payload': {'revision': 9},
});
await Future<void>.delayed(Duration.zero);
expect(work.presets[2], PanePreset.rows);
expect(
work.paneSizes,
isEmpty,
reason: 'the preset replaced the split, as choosing it here would',
);
});
test('keeps its ops while the backend is unreachable and sends them once it is back', () async {
final api = _DeskApi();
final app = createApp()..api = api;
addTearDown(app.dispose);
await app.deskStartForTest();
api.failWith = StateError('offline');
app.newSwarm(name: 'Offline work');
final offline = app.activeSwarm;
await Future<void>.delayed(Duration.zero);
expect(app.deskSyncForTest.pending, isNotEmpty);
expect(api.doc!.tabs.map((t) => t.id), isNot(contains(offline.id)));
api.failWith = null;
await app.deskFlushForTest();
expect(api.doc!.tabs.map((t) => t.id), contains(offline.id));
expect(app.deskSyncForTest.pending, isEmpty);
});
test(
'a daemon without a desk leaves the window as it was: local ids, no ops',
() async {
final api = _DeskApi()..available = false;
final app = createApp()..api = api;
addTearDown(app.dispose);
await app.addAgentToSwarm('m', 'a0');
await app.deskStartForTest();
expect(app.deskSyncForTest.enabled, isFalse);
app.newSwarm(name: 'Local');
expect(isDeskId(app.activeSwarm.id), isFalse);
expect(api.batches, isEmpty);
},
);
});
}