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
Add a per-computer tab profile on one Harness account
Jasmine Naderi94a9c63fc18b
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex 5b2495b34..e0514e69f 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -592,7 +592,7 @@ class _SwarmScreenState extends State<SwarmScreen> {},],'tabs': [- for (final swarm in app.swarms)+ for (final swarm in app.profileSwarms){'id': swarm.id,'name': swarm.name,@@ -2469,12 +2469,12 @@ class _SwarmScreenState extends State<SwarmScreen> {if (id == 'pane.layout' || id == 'task.route') return true;if (id.startsWith('swarm.select_')) {final number = int.tryParse(id.substring('swarm.select_'.length));- return number != null && number >= 1 && number <= app.swarms.length;+ return number != null && number >= 1 && number <= app.profileSwarms.length;}if (id == 'swarm.new') return true;if (id == 'swarm.reopen') return app.canReopenLastClosed;if (id == 'swarm.next' || id == 'swarm.previous') {- return app.swarms.length > 1;+ return app.profileSwarms.length > 1;}if (id == 'navigation.back') return _navigation.canGoBack(app);if (id == 'navigation.forward') return _navigation.canGoForward(app);@@ -3020,7 +3020,7 @@ class _SwarmScreenState extends State<SwarmScreen> {void _revealSelectedTab(double viewport) {final previous = _tabGeometry;- final order = app.swarms.map((tab) => tab.id).toList(growable: false);+ final order = app.profileSwarms.map((tab) => tab.id).toList(growable: false);if (previous != null &&previous.activeId == app.activeSwarmId &&previous.viewport == viewport &&@@ -3050,7 +3050,9 @@ class _SwarmScreenState extends State<SwarmScreen> {WidgetsBinding.instance.addPostFrameCallback((_) {_tabRevealScheduled = false;if (!mounted || !_tabScroll.hasClients) return;- final index = app.swarms.indexWhere((tab) => tab.id == app.activeSwarmId);+ final index = app.profileSwarms.indexWhere(+ (tab) => tab.id == app.activeSwarmId,+ );if (index < 0) return;final position = _tabScroll.position;final left = index * _tabExtent;@@ -3099,11 +3101,11 @@ class _SwarmScreenState extends State<SwarmScreen> {scrollDirection: Axis.horizontal,shrinkWrap: true,buildDefaultDragHandles: false,- itemCount: app.swarms.length,+ itemCount: app.profileSwarms.length,onReorderItem: (old, to) =>- app.reorderSwarm(app.swarms[old].id, to),+ app.reorderSwarm(app.profileSwarms[old].id, to),itemBuilder: (context, index) {- final swarm = app.swarms[index];+ final swarm = app.profileSwarms[index];return ReorderableDragStartListener(key: ValueKey(swarm.id),index: index,diff --git a/desktop/lib/settings/sections/profiles_section.dart b/desktop/lib/settings/sections/profiles_section.dartnew file mode 100644index 000000000..238e0d152--- /dev/null+++ b/desktop/lib/settings/sections/profiles_section.dart@@ -0,0 +1,60 @@+import 'package:flutter/material.dart';++import '../../shared/widgets/section_scaffold.dart';+import '../../shared/widgets/setting_row.dart';+import '../../state/app_state.dart';++/// One login, several computers. The account desk still holds every tab.+/// This window draws all of them, or only the computer named here.+class ProfilesSection extends StatelessWidget {+ const ProfilesSection({super.key, required this.notifier});++ final AppNotifier notifier;++ @override+ Widget build(BuildContext context) => ListenableBuilder(+ listenable: notifier,+ builder: (context, _) {+ final selected = notifier.machineProfileId;+ final localId = notifier.localMachineState?.machine.machineId;+ final machines = notifier.machines;+ return SectionScaffold(+ title: 'Profiles',+ subtitle:+ 'One sign-in. Choose a computer to show only that computer\'s tabs. All machines keeps the shared desk.',+ child: SingleChildScrollView(+ child: Column(+ children: [+ SettingRow(+ title: 'All machines',+ detail: 'Every tab on this account, whichever computer it runs on.',+ control: _choice(+ selected: selected == null,+ onPressed: () => notifier.setMachineProfile(null),+ ),+ ),+ for (final machine in machines)+ SettingRow(+ title: machine.displayName,+ detail: machine.machineId == localId+ ? 'This computer. Tabs whose agents are all here.'+ : 'That computer. Tabs whose agents are all there.',+ control: _choice(+ selected: selected == machine.machineId,+ onPressed: () => notifier.setMachineProfile(machine.machineId),+ ),+ ),+ ],+ ),+ ),+ );+ },+ );++ Widget _choice({required bool selected, required VoidCallback onPressed}) {+ return OutlinedButton(+ onPressed: selected ? null : onPressed,+ child: Text(selected ? 'Showing' : 'Show'),+ );+ }+}diff --git a/desktop/lib/settings/settings_screen.dart b/desktop/lib/settings/settings_screen.dartindex 2012dede2..edfe25d7e 100644--- a/desktop/lib/settings/settings_screen.dart+++ b/desktop/lib/settings/settings_screen.dart@@ -7,6 +7,7 @@ import '../state/app_state.dart';import '../widgets/harness_customize_pane.dart';import 'sections/about_section.dart';import 'sections/account_section.dart';+import 'sections/profiles_section.dart';import 'sections/debug_section.dart';import 'sections/devices_section.dart';import 'sections/shortcuts_section.dart';@@ -184,6 +185,7 @@ class _SettingsBody extends StatelessWidget {Widget build(BuildContext context) {final screen = switch (section) {SettingsSection.account => AccountSection(notifier: notifier),+ SettingsSection.profiles => ProfilesSection(notifier: notifier),SettingsSection.usage => const UsageSection(),SettingsSection.customize => throw StateError('Customization opens over the workspace.',diff --git a/desktop/lib/settings/settings_section.dart b/desktop/lib/settings/settings_section.dartindex a687a517a..f7812a458 100644--- a/desktop/lib/settings/settings_section.dart+++ b/desktop/lib/settings/settings_section.dart@@ -11,6 +11,7 @@ import '../logging/debug_surface.dart';/// be listed without a screen behind it or reachable without a row.enum SettingsSection {account(LucideIcons.user300, 'Account'),+ profiles(LucideIcons.monitor300, 'Profiles'),usage(LucideIcons.chartNoAxesColumn300, 'Usage'),customize(LucideIcons.palette300, 'Customize'),devices(LucideIcons.zap300, 'Autonomous robots'),@@ -87,6 +88,7 @@ const _kSettingsGroups = [SettingsSection.customize,SettingsSection.devices,SettingsSection.account,+ SettingsSection.profiles,]),// Debug and Tracking sit between the two things they are most often reached// from: the keys that open them, and the version a report has to name. Thediff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex 1e6a30ba0..029ebad51 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -50,6 +50,7 @@ import '../store/store_screen.dart' show openStoreAgent;import 'dial_status.dart';import 'harness_placement.dart';import 'desk_sync.dart';+import 'machine_profile.dart';import 'pane_layout_store.dart';import 'terminal_pane.dart';import 'swarm.dart';@@ -665,6 +666,14 @@ class AppNotifier extends ChangeNotifier {/// Swarms own arrangements; a shared pane owns one live terminal controller.final List<Swarm> swarms = [Swarm(id: 'swarm-1')];+ /// null shows every machine's tabs. A machine id shows only tabs whose+ /// agents all live on that computer. The account desk is not rewritten:+ /// the other computers' tabs stay, they are just not drawn here.+ String? _machineProfileId;+ String? get machineProfileId => _machineProfileId;+ List<Swarm> get profileSwarms =>+ swarmsForMachineProfile(swarms, _machineProfileId);+// ── the desk: the account's tabs, the same on every computer ─────────────//// `desk_sync.dart` has the shape and the rules; this is the window's half.@@ -1027,13 +1036,36 @@ class AppNotifier extends ChangeNotifier {/// Command-number follows the current visual tab order, retaining each tab's/// focused pane. A missing position is a no-op, never a pane selection.void selectSwarmByIndex(int index) {- if (index < 0 || index >= swarms.length) return;- selectSwarm(swarms[index].id);+ final view = profileSwarms;+ if (index < 0 || index >= view.length) return;+ selectSwarm(view[index].id);}void stepSwarm(int delta) {- final index = swarms.indexOf(activeSwarm);- selectSwarm(swarms[(index + delta) % swarms.length].id);+ final view = profileSwarms;+ if (view.isEmpty) return;+ final index = view.indexWhere((swarm) => swarm.id == activeSwarmId);+ final next = index < 0 ? 0 : (index + delta) % view.length;+ selectSwarm(view[next].id);+ }++ /// Show every machine, or only [machineId]. An empty value is every machine.+ /// The hidden tabs stay on the account desk.+ void setMachineProfile(String? machineId) {+ final next = machineId == null || machineId.isEmpty ? null : machineId;+ if (next == _machineProfileId) return;+ _machineProfileId = next;+ unawaited(_paneLayout?.saveMachineProfile(next));+ final view = profileSwarms;+ if (view.isEmpty) {+ newSwarm();+ return;+ }+ if (view.every((swarm) => swarm.id != _activeSwarmId)) {+ selectSwarm(view.first.id);+ return;+ }+ notifyListeners();}void renameSwarm(String id, String name) {@@ -1048,10 +1080,23 @@ class AppNotifier extends ChangeNotifier {}void reorderSwarm(String id, int destination) {- final index = swarms.indexWhere((s) => s.id == id);- if (index < 0) return;- final swarm = swarms.removeAt(index);- swarms.insert(destination.clamp(0, swarms.length), swarm);+ final view = List<Swarm>.of(profileSwarms);+ final from = view.indexWhere((swarm) => swarm.id == id);+ if (from < 0) return;+ final moved = view.removeAt(from);+ view.insert(destination.clamp(0, view.length), moved);+ if (view.length == swarms.length) {+ swarms+ ..clear()+ ..addAll(view);+ } else {+ var next = 0;+ for (var i = 0; i < swarms.length; i++) {+ if (swarmMatchesMachineProfile(swarms[i], _machineProfileId)) {+ swarms[i] = view[next++];+ }+ }+ }_persistLayout();notifyListeners();}@@ -9149,6 +9194,12 @@ class AppNotifier extends ChangeNotifier {// instead is nobody's arrival here — see [paneFocusByUser]._paneFocusByUser = false;}+ final visible = profileSwarms;+ if (visible.isNotEmpty && visible.every((s) => s.id != _activeSwarmId)) {+ _activeSwarmId = visible.first.id;+ selectedMachineId = focusedPane?.machineId;+ _paneFocusByUser = false;+ }// Streams nobody shows any more.for (final pane in released.toSet()) {@@ -9211,8 +9262,12 @@ class AppNotifier extends ChangeNotifier {final initialSwarm = activeSwarm;final revision = _layoutRevision;final authRevision = _authRevision;+ final savedProfile = await store.loadMachineProfile();final saved = await store.loadSwarms();if (!_authWorkCurrent(authRevision) || revision != _layoutRevision) return;+ _machineProfileId = savedProfile == null || savedProfile.isEmpty+ ? null+ : savedProfile;if (saved != null &&allPanes.isEmpty &&swarms.length == 1 &&diff --git a/desktop/lib/state/machine_profile.dart b/desktop/lib/state/machine_profile.dartnew file mode 100644index 000000000..d36d9277f--- /dev/null+++ b/desktop/lib/state/machine_profile.dart@@ -0,0 +1,31 @@+import 'swarm.dart';++/// Which computer a window is looking at.+///+/// The account still has one desk — the same tabs on every computer — and a+/// profile only decides which of those tabs this window draws. `null` is every+/// machine. A machine id is that computer alone: a tab is in it when every+/// agent it holds is on that computer. The Store and a tab with no agent yet+/// stay, so there is always a place to start one.+bool swarmMatchesMachineProfile(Swarm swarm, String? machineId) {+ if (machineId == null || machineId.isEmpty) return true;+ if (swarm.isStore) return true;+ final ids = <String>{+ for (final pane in swarm.panes)+ if (pane.machineId.isNotEmpty) pane.machineId,+ if (swarm.titleMachineId != null && swarm.titleMachineId!.isNotEmpty)+ swarm.titleMachineId!,+ if (swarm.orchestratorMachineId != null &&+ swarm.orchestratorMachineId!.isNotEmpty)+ swarm.orchestratorMachineId!,+ };+ if (ids.isEmpty) return true;+ return ids.every((id) => id == machineId);+}++/// Tabs this window shows for [machineId]. The underlying list is not copied+/// and is not filtered in place: the desk keeps every machine's tabs.+List<Swarm> swarmsForMachineProfile(List<Swarm> swarms, String? machineId) => [+ for (final swarm in swarms)+ if (swarmMatchesMachineProfile(swarm, machineId)) swarm,+];diff --git a/desktop/lib/state/pane_layout_store.dart b/desktop/lib/state/pane_layout_store.dartindex d4ae5bcc7..284b11b0a 100644--- a/desktop/lib/state/pane_layout_store.dart+++ b/desktop/lib/state/pane_layout_store.dart@@ -32,6 +32,11 @@ class PaneLayoutStore {/// bytes of dead JSON costs less than a file this build has to migrate.static const _presetsKey = 'terminal_pane_presets';+ /// Which computer this window is showing. Absent or empty is every machine.+ /// A separate key from the desk: the desk stays the account's full tab list,+ /// and this is only the window's choice of which of those tabs to draw.+ static const machineProfileKey = 'machine_profile_v1';+/// The ceiling on tiles, enforced on the way IN as well as out: a file written/// by a future build that allows more must not make this one try to open/// terminals it has nowhere to put.@@ -176,6 +181,24 @@ class PaneLayoutStore {completion.complete();}+ Future<String?> loadMachineProfile() async {+ try {+ final raw = await _storage.read(machineProfileKey);+ if (raw == null || raw.isEmpty) return null;+ return raw;+ } catch (_) {+ return null;+ }+ }++ Future<void> saveMachineProfile(String? machineId) async {+ try {+ await _storage.write(machineProfileKey, machineId ?? '');+ } catch (_) {+ // The choice still applies for this run.+ }+ }+Future<void> save(List<PaneLayoutEntry> entries) async {try {final capped = entries.take(maxPanes).map((e) => e.toJson()).toList();diff --git a/desktop/test/machine_profile_test.dart b/desktop/test/machine_profile_test.dartnew file mode 100644index 000000000..b216b21d7--- /dev/null+++ b/desktop/test/machine_profile_test.dart@@ -0,0 +1,42 @@+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/state/machine_profile.dart';+import 'package:harness/state/swarm.dart';+import 'package:harness/state/terminal_pane.dart';++Swarm tab(+ String id,+ List<String> machines, {+ String? titleMachine,+ String kind = 'harness',+}) {+ final swarm = Swarm(id: id, name: id, kind: kind)+ ..titleMachineId = titleMachine;+ for (var i = 0; i < machines.length; i++) {+ swarm.panes.add(TerminalPane(id: i, machineId: machines[i], agentId: 'a$i'));+ }+ return swarm;+}++void main() {+ test('no profile shows every tab', () {+ final tabs = [tab('local', ['m1']), tab('remote', ['m2'])];+ expect(swarmsForMachineProfile(tabs, null).map((s) => s.id), ['local', 'remote']);+ expect(swarmsForMachineProfile(tabs, '').map((s) => s.id), ['local', 'remote']);+ });++ test('a machine profile keeps that computer and drops the other', () {+ final store = Swarm(id: 'store', name: Swarm.storeName, kind: 'store');+ final blank = Swarm(id: 'blank');+ final local = tab('local', ['m1']);+ final remote = tab('remote', ['m2'], titleMachine: 'm2');+ final mixed = tab('mixed', ['m1', 'm2']);+ final shown = swarmsForMachineProfile([store, blank, local, remote, mixed], 'm1');+ expect(shown.map((s) => s.id), ['store', 'blank', 'local']);+ });++ test('a tab titled for another computer stays out even with no pane yet', () {+ final named = Swarm(id: 'remote-blank')..titleMachineId = 'm2';+ expect(swarmMatchesMachineProfile(named, 'm1'), isFalse);+ expect(swarmMatchesMachineProfile(named, 'm2'), isTrue);+ });+}diff --git a/desktop/test/settings_section_test.dart b/desktop/test/settings_section_test.dartindex 7eedc0af6..2a14617e0 100644--- a/desktop/test/settings_section_test.dart+++ b/desktop/test/settings_section_test.dart@@ -35,6 +35,7 @@ void main() {SettingsSection.customize,SettingsSection.devices,SettingsSection.account,+ SettingsSection.profiles,SettingsSection.shortcuts,SettingsSection.about,]);diff --git a/docs/app.md b/docs/app.mdindex 752ebf7e3..7a5c37541 100644--- a/docs/app.md+++ b/docs/app.md@@ -82,3 +82,10 @@ The app talks to the daemon on this computer over a loopback socket and never diOther machines are reached through that daemon: it links to them with a per-machine remote password,terminates the encryption locally, and hands the app plaintext. Machines ▸ Link Machine… runs thelink flow; the CLI equivalent is under [The daemon and CLI](#the-daemon-and-cli).++Settings ▸ Profiles keeps that one sign-in and chooses which computer's tabs+this window draws. **All machines** is the shared desk. A computer's row hides+tabs whose agents run anywhere else. Those tabs stay on the account, so another+window, or **All machines** here, still has them. A tab that mixes agents from+two computers stays under **All machines** only. The Store and an empty tab+remain in every profile.