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
Gate the workspace Share button behind an Experimental setting (#419)
Dee838805c7ee40
diff --git a/desktop/design/images/share-experimental.png b/desktop/design/images/share-experimental.pngnew file mode 100644index 000000000..7aac2fcbfBinary files /dev/null and b/desktop/design/images/share-experimental.png differdiff --git a/desktop/design/terminal-workspace.md b/desktop/design/terminal-workspace.mdindex 0e7a8dc0f..f4386cbe9 100644--- a/desktop/design/terminal-workspace.md+++ b/desktop/design/terminal-workspace.md@@ -47,8 +47,9 @@ Keep mouse access useful without adding duplicate floating controls. Clickabletext shows a hand cursor and bold text on hover, press, and keyboard focus.Preserve the underlying colors, including filled status segments. Reserve bothtext weights during layout so emphasis never shifts neighboring controls.-Resting controls stay unboxed, except the persistent Share action: its flat+Resting controls stay unboxed, except the optional Share action: its flatprimary accent fill makes collaboration visible at the top-right corner.+Settings → Experimental → Share button enables it; it is off by default.Tooltips describe theaction, not merely the text. Omit a tooltip that repeats the visible name;show the full name when truncated, or a different underlying name. A modeldiff --git a/desktop/design/workspace-status-bar.md b/desktop/design/workspace-status-bar.mdindex 0fc658c67..7b90befdc 100644--- a/desktop/design/workspace-status-bar.md+++ b/desktop/design/workspace-status-bar.md@@ -95,9 +95,12 @@ Pane edges have no floating split buttons. Split Right and Split Down remainkeyboard commands (Cmd-R and Cmd-D by default), with File menu and command-searchaccess. Keep the resize gaps available for resizing.-Share is a persistent primary action at the far right of the top bar, with a-flat accent fill, white text, and the same fixed font and control height as the-other bar actions. Reserve its width before allocating tabs and context. Web+Settings → Experimental → Share button is off by default on desktop and web.+The choice persists locally and updates the bar immediately; when off, no button+or space is reserved. [Settings reference](images/share-experimental.png).+When enabled, Share is a primary action at the far right+of the top bar, with a flat accent fill, white text, and the same fixed font and+control height as the other bar actions. Reserve its width before allocating tabs and context. Webkeeps Download app as a secondary text action immediately before Share.Clicking Share or pressing Cmd-Shift-S (Alt-Shift-S on web) opens the existingpublic/private link dialog for the focused agent. The tooltip and accessibility@@ -248,7 +251,8 @@ References: [Zsh prompt parameters](https://zsh.sourceforge.io/Doc/Release/Param[Powerlevel10k](https://github.com/romkatv/powerlevel10k).Pane headers keep task identity and the hover-only close action. The top bar-contains tabs, New Tab, focused model/machine/project/branch/PR context, and Share.+contains tabs, New Tab, focused model/machine/project/branch/PR context, and the+optional Share button.Do not add a standalone Search label or category icons at the right edge.Context links open the corresponding scope in the unified picker. Globalsearch remains available through Cmd-P and the app menu.diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex aa55a4496..4c8c814c9 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -242,6 +242,9 @@ class _SwarmScreenState extends State<SwarmScreen> {late final _experimentalFeatures =widget.experimentalFeatures ?? experimentalFeaturesStore;+ bool get _showShareButton =>+ _experimentalFeatures.enabled(ExperimentalFeature.shareButton);+/// An explicit local choice overrides the separate account rollout. This/// stays null for installations that have never tried the test collection.late bool? _daemonPreviewOverride = _creaturePreviewChoice;@@ -1612,21 +1615,22 @@ class _SwarmScreenState extends State<SwarmScreen> {'canReopen': app.canReopenLastClosed,'canFind': _canFindTerminal,'canClosePane': app.focusedPane != null,- 'shareAction': {- 'text': WorkspaceShareButton.text,- 'label': _shareLabel(focused),- 'tooltip': _shareTooltip(focused),- 'enabled': _canExecuteCommand('agent.share'),- 'paneId': focused?.pane.id,- 'machineId': focused?.pane.machineId,- 'agentId': focused?.agentId,- 'background': WorkspaceShareButton.backgroundFor(- _canExecuteCommand('agent.share'),- ).toARGB32(),- 'foreground': WorkspaceShareButton.foregroundFor(- _canExecuteCommand('agent.share'),- ).toARGB32(),- },+ if (_showShareButton)+ 'shareAction': {+ 'text': WorkspaceShareButton.text,+ 'label': _shareLabel(focused),+ 'tooltip': _shareTooltip(focused),+ 'enabled': _canExecuteCommand('agent.share'),+ 'paneId': focused?.pane.id,+ 'machineId': focused?.pane.machineId,+ 'agentId': focused?.agentId,+ 'background': WorkspaceShareButton.backgroundFor(+ _canExecuteCommand('agent.share'),+ ).toARGB32(),+ 'foreground': WorkspaceShareButton.foregroundFor(+ _canExecuteCommand('agent.share'),+ ).toARGB32(),+ },'paneActions': {'restartAgent': _canExecuteCommand('agent.restart'),'shareAgent': _canExecuteCommand('agent.share'),@@ -1841,6 +1845,7 @@ class _SwarmScreenState extends State<SwarmScreen> {}final args = call.arguments is Map ? call.arguments as Map : const {};if (call.method == 'shareAgent' && args.containsKey('paneId')) {+ if (!_showShareButton) return;final focused = WorkspacePaneContext.focused(app);if (focused == null ||focused.pane.id != args['paneId'] ||@@ -3205,6 +3210,8 @@ class _SwarmScreenState extends State<SwarmScreen> {app.sendDaemonFrame(type, payload);void _experimentalFeaturesChanged() {+ setState(() {});+ if (_native) _syncNative();final choice = _creaturePreviewChoice;if (_daemonPreviewOverride == choice) return;final hadOverlay = _daemonOverlay != null || _hatchOverlay != null;@@ -6248,7 +6255,9 @@ class _SwarmScreenState extends State<SwarmScreen> {final downloadWidth = kIsWeb? WebDownloadButton.widthOf(context) + cell.width: 0.0;- final shareWidth = WorkspaceShareButton.widthOf(context) + cell.width;+ final shareWidth = _showShareButton+ ? WorkspaceShareButton.widthOf(context) + cell.width+ : 0.0;final contentWidth = math.max(0.0,constraints.maxWidth -@@ -6496,15 +6505,17 @@ class _SwarmScreenState extends State<SwarmScreen> {selected: _daemonOverlay != null,onPressed: _activateDaemon,),- SizedBox(width: cell.width),- WorkspaceShareButton(- key: const ValueKey('workspace-share-button'),- label: _shareLabel(focused),- tooltip: _shareTooltip(focused),- onPressed: _canExecuteCommand('agent.share')- ? () => _runShortcut('agent.share')- : null,- ),+ if (_showShareButton) ...[+ SizedBox(width: cell.width),+ WorkspaceShareButton(+ key: const ValueKey('workspace-share-button'),+ label: _shareLabel(focused),+ tooltip: _shareTooltip(focused),+ onPressed: _canExecuteCommand('agent.share')+ ? () => _runShortcut('agent.share')+ : null,+ ),+ ],SizedBox(width: cell.width),],),diff --git a/desktop/lib/settings/experimental_features.dart b/desktop/lib/settings/experimental_features.dartindex f0ba9d0a0..eee7bc639 100644--- a/desktop/lib/settings/experimental_features.dart+++ b/desktop/lib/settings/experimental_features.dart@@ -12,6 +12,11 @@ enum ExperimentalFeature {'Focus-bar creature','Try a small companion in the focus bar, with an egg ready to hatch. ''Its test collection resets when you close the window.',+ ),+ shareButton(+ 'share_button',+ 'Share button',+ 'Show Share in the top-right corner of the workspace.',);const ExperimentalFeature(this.id, this.label, this.description);@@ -19,12 +24,14 @@ enum ExperimentalFeature {String get storageKey => 'experimental.$id';- // The first experiment belongs to the desktop workspace. A viewer has no- // workspace or creature of its own.- bool get available => !kIsWeb && !kViewerMode;+ bool get available => switch (this) {+ // The creature preview belongs to the native desktop workspace.+ focusBarCreature => !kIsWeb && !kViewerMode,+ shareButton => true,+ };}-/// Per-computer preferences, loaded before the first frame. Experiments are+/// Per-installation preferences, loaded before the first frame. Experiments are/// off until chosen; neither an account nor a server can opt a user into one.class ExperimentalFeaturesStore extends ChangeNotifier {ExperimentalFeaturesStore({LocalKeyValueStore? storage})diff --git a/desktop/test/daemon_off_test.dart b/desktop/test/daemon_off_test.dartindex 72f6956ad..d419fb3d9 100644--- a/desktop/test/daemon_off_test.dart+++ b/desktop/test/daemon_off_test.dart@@ -360,6 +360,9 @@ void main() {testWidgets('a 404 is off: no slot and the bar from before daemons, at ''every width', (tester) async {seedStatusBarWorkspace(app);+ // This historical layout includes Share; keep its independent experiment+ // enabled while checking that daemons reserve no space.+ await experiments.set(ExperimentalFeature.shareButton, true);await mount(tester);await tester.pump();expect(remote.fetches, 1);@@ -377,6 +380,7 @@ void main() {testWidgets('while the first read has no answer nothing is kept for the ''slot', (tester) async {seedStatusBarWorkspace(app);+ await experiments.set(ExperimentalFeature.shareButton, true);final gate = Completer<void>();await mount(tester, on: true, gate: gate);expect(zoo.daemons, DaemonsSwitch.unknown);diff --git a/desktop/test/experimental_features_test.dart b/desktop/test/experimental_features_test.dartindex 48e7248b1..1014d25a2 100644--- a/desktop/test/experimental_features_test.dart+++ b/desktop/test/experimental_features_test.dart@@ -29,28 +29,33 @@ class _DelayedWrite extends MemoryStore {void main() {const creature = ExperimentalFeature.focusBarCreature;- test('experiments default off and restore both saved choices', () async {- final storage = MemoryStore();- Future<ExperimentalFeaturesStore> reopen() async {- final store = ExperimentalFeaturesStore(storage: storage);- addTearDown(store.dispose);- await store.load();- return store;- }+ for (final feature in ExperimentalFeature.values) {+ test(+ '${feature.label} defaults off and restores both saved choices',+ () async {+ final storage = MemoryStore();+ Future<ExperimentalFeaturesStore> reopen() async {+ final store = ExperimentalFeaturesStore(storage: storage);+ addTearDown(store.dispose);+ await store.load();+ return store;+ }- final first = await reopen();- expect(first.enabled(creature), isFalse);- expect(first.choice(creature), isNull);- expect(storage.values, isEmpty);- await first.set(creature, true);- final second = await reopen();- expect(second.enabled(creature), isTrue);- await second.set(creature, false);- final third = await reopen();- expect(third.choice(creature), isFalse);- storage.values[creature.storageKey] = 'true';- expect((await reopen()).enabled(creature), isFalse);- });+ final first = await reopen();+ expect(first.enabled(feature), isFalse);+ expect(first.choice(feature), isNull);+ expect(storage.values, isEmpty);+ await first.set(feature, true);+ final second = await reopen();+ expect(second.enabled(feature), isTrue);+ await second.set(feature, false);+ final third = await reopen();+ expect(third.choice(feature), isFalse);+ storage.values[feature.storageKey] = 'true';+ expect((await reopen()).enabled(feature), isFalse);+ },+ );+ }test('a late preference read cannot undo a choice made in Settings',diff --git a/desktop/test/settings_section_test.dart b/desktop/test/settings_section_test.dartindex 524572b0f..3d4c3b488 100644--- a/desktop/test/settings_section_test.dart+++ b/desktop/test/settings_section_test.dart@@ -3,6 +3,7 @@// shape worth guarding is the one no test build has. `settingsGroupsFor` takes the gate as an// argument for exactly this.import 'package:flutter_test/flutter_test.dart';+import 'package:flutter/foundation.dart' show kIsWeb;import 'package:harness/logging/debug_surface.dart';import 'package:harness/settings/settings_section.dart';@@ -35,7 +36,7 @@ void main() {SettingsSection.customize,SettingsSection.notifications,SettingsSection.experimental,- SettingsSection.devices,+ if (!kIsWeb) SettingsSection.devices,SettingsSection.account,SettingsSection.shortcuts,SettingsSection.about,diff --git a/desktop/test/share_toolbar_test.dart b/desktop/test/share_toolbar_test.dartindex c6c341a51..2c423beaf 100644--- a/desktop/test/share_toolbar_test.dart+++ b/desktop/test/share_toolbar_test.dart@@ -7,6 +7,8 @@ import 'package:flutter_test/flutter_test.dart';import 'package:lucide_icons_flutter/lucide_icons.dart';import 'package:harness/core/models.dart';import 'package:harness/screens/swarm_screen.dart';+import 'package:harness/settings/experimental_features.dart';+import 'package:harness/settings/settings_screen.dart';import 'package:harness/shared/theme/app_theme.dart' as grid;import 'package:harness/sharing/share_harness_dialog.dart';import 'package:harness/shortcuts/app_keymap.dart';@@ -22,7 +24,7 @@ import 'package:harness/ws/ws_conn.dart';import 'keymap_host_test.dart' show MemoryKeymap, key;import 'swarm_screen_test.dart' show terminal;-import 'swarm_state_test.dart' show createApp;+import 'swarm_state_test.dart' show createApp, MemoryStore;class _SharingConnection extends WsConn {_SharingConnection()@@ -52,6 +54,8 @@ void main() {final button = find.byKey(const ValueKey('workspace-share-button'));late AppNotifier app;late MemoryKeymap keymap;+ late MemoryStore preferences;+ late ExperimentalFeaturesStore experiments;late _SharingConnection connection;final input = <TerminalBinaryFrame>[];@@ -63,18 +67,25 @@ void main() {app = createApp(connectionForTest: (_) => connection);app.stateOf('m')!.nodeOnline = true;keymap = MemoryKeymap();+ preferences = MemoryStore();+ experiments = ExperimentalFeaturesStore(storage: preferences);input.clear();});tearDown(() {app.dispose();keymap.dispose();+ experiments.dispose();});Future<void> mount(WidgetTester tester, {bool native = false,+ bool enableShareButton = true,Size size = const Size(1280, 800),}) async {+ if (enableShareButton) {+ await experiments.set(ExperimentalFeature.shareButton, true);+ }tester.view.devicePixelRatio = 1;tester.view.physicalSize = size;addTearDown(tester.view.reset);@@ -83,7 +94,11 @@ void main() {theme: grid.buildAppTheme(brightness: Brightness.dark),home: KeymapProvider(keymap: keymap,- child: SwarmScreen(notifier: app, nativeTabs: native),+ child: SwarmScreen(+ notifier: app,+ nativeTabs: native,+ experimentalFeatures: experiments,+ ),),),);@@ -98,6 +113,84 @@ void main() {shift: true,);+ for (final native in [false, true]) {+ testWidgets(+ 'Share defaults hidden and its saved Settings toggle updates the toolbar (native=$native)',+ (tester) async {+ const feature = ExperimentalFeature.shareButton;+ const channel = MethodChannel('harness/swarm_tabs');+ final updates = <Map>[];+ final messenger = tester.binding.defaultBinaryMessenger;+ messenger.setMockMethodCallHandler(channel, (call) async {+ if (call.method == 'update') updates.add(call.arguments as Map);+ return true;+ });+ addTearDown(() => messenger.setMockMethodCallHandler(channel, null));+ final session = terminal('a0', input);+ final pane = app.adoptSessionForTest(session);+ await mount(tester, native: native, enableShareButton: false);+ expect(experiments.choice(feature), isNull);+ expect(button, findsNothing);+ if (native) expect(updates.last['shareAction'], isNull);++ Future<void> openExperimental() async {+ await key(+ tester,+ LogicalKeyboardKey.comma,+ cmd: !kIsWeb,+ alt: kIsWeb,+ );+ await tester.pumpAndSettle();+ await tester.tap(find.text('Experimental'));+ await tester.pumpAndSettle();+ }++ await openExperimental();+ final toggle = find.byKey(const ValueKey('experimental-share_button'));+ expect(tester.widget<Switch>(toggle).value, isFalse);+ await tester.tap(toggle);+ await tester.pumpAndSettle();+ expect(tester.widget<Switch>(toggle).value, isTrue);+ expect(preferences.values[feature.storageKey], 'on');+ await tester.tap(find.byKey(const Key('settings-back-button')));+ await tester.pumpAndSettle();+ expect(find.byType(SettingsScreen), findsNothing);+ final shownTarget = native ? updates.last['shareAction'] as Map : null;+ if (native) {+ expect(shownTarget!['enabled'], isTrue);+ } else {+ expect(button, findsOneWidget);+ }++ await openExperimental();+ expect(tester.widget<Switch>(toggle).value, isTrue);+ await tester.tap(toggle);+ await tester.pumpAndSettle();+ expect(preferences.values[feature.storageKey], 'off');+ await tester.tap(find.byKey(const Key('settings-back-button')));+ await tester.pumpAndSettle();+ expect(button, findsNothing);+ if (native) {+ expect(updates.last['shareAction'], isNull);+ final done = Completer<void>();+ messenger.handlePlatformMessage(+ channel.name,+ const StandardMethodCodec().encodeMethodCall(+ MethodCall('shareAgent', shownTarget),+ ),+ (_) => done.complete(),+ );+ await tester.pumpAndSettle();+ expect(done.isCompleted, isTrue);+ }+ expect(connection.shares, isEmpty);+ expect(input, isEmpty);+ expect(pane.session, same(session));+ await tester.pumpWidget(const SizedBox());+ },+ );+ }+testWidgets('button and shortcut share only the focused agent and return terminal focus',(tester) async {diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swiftindex e10abdc86..3a2e463b7 100644--- a/desktop/tool/swarm_titlebar_checks.swift+++ b/desktop/tool/swarm_titlebar_checks.swift@@ -575,6 +575,12 @@ private extension SwarmTabStrip {emit = { method, args in calls.append((method, args as? [String: Any] ?? [:])) }for width in [CGFloat(360), CGFloat(520), CGFloat(1280)] {setFrameSize(NSSize(width: width, height: 40))+ var hidden = state+ hidden.removeValue(forKey: "shareAction")+ update(hidden)+ let withoutShare = barFrames()+ try checkTitlebar(shareButton.isHidden && !shareButton.isEnabled && shareButton.frame.width == 0,+ "The Share experiment reserves no space while off at width \(width)")update(state)try checkTitlebar(!shareButton.isHidden && shareButton.isEnabled &&shareButton.frame.width == shareButton.preferredWidth &&@@ -582,6 +588,10 @@ private extension SwarmTabStrip {contextButton.frame.maxX < shareButton.frame.minX &&newButton.frame.maxX < shareButton.frame.minX,"Share stays prominent at the right edge without overlapping tabs or context at width \(width)")+ update(hidden)+ try checkTitlebar(barFrames() == withoutShare,+ "Turning Share off restores the original toolbar layout at width \(width)")+ update(state)}try checkTitlebar(shareButton.accessibilityLabel() == "Share Website launch" &&shareButton.toolTip == "Share Website launch · ⇧⌘S",