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(share-machine): say when sharing ends, trim the Share form, explain hn's sharing rows

bitcoinbuilderef064db6e41b
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dart
index 0ce23b7be..be564213e 100644
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@ -1353,6 +1353,24 @@ class AppNotifier extends ChangeNotifier {
/// Machines other accounts share with this one's domain, not added yet: Add machine lists them, and
/// [addSharedMachine] adds one.
List<Machine> machinesToAdd = const [];
+
+ /// Machines another account shared with this one and no longer does, by id: what a pane left on one
+ /// says once the machine itself has left the list. Forgotten when it is shared again.
+ final Map<String, ({String name, String owner})> _sharingEnded = {};
+
+ /// Who stopped sharing [machineId] with this account, and its name, if they did.
+ ({String name, String owner})? sharingEnded(String machineId) =>
+ _sharingEnded[machineId];
+
+ void _noteSharingEnded(Machine machine) {
+ final share = machine.machineShare;
+ if (share == null) return;
+ _sharingEnded[machine.machineId] = (
+ name: machine.displayName,
+ owner: share.owner,
+ );
+ }
+
final Map<String, MachineState> machineStates = {};
final Set<String> expandedMachines = {};
String? selectedMachineId;
@@ -7451,8 +7469,11 @@ class AppNotifier extends ChangeNotifier {
);
}
final visible = machines.map((machine) => machine.machineId).toSet();
+ _sharingEnded.removeWhere((id, _) => visible.contains(id));
for (final entry in machineStates.entries) {
if (!visible.contains(entry.key)) {
+ // A shared machine that left the list was taken back by its owner (a fresh list says so).
+ if (!machinesAreStale) _noteSharingEnded(entry.value.machine);
_clearMachineActivity(entry.value);
_stopOfflineRetry(entry.key);
_stopLinkRetry(entry.key);
@@ -18094,9 +18115,21 @@ class AppNotifier extends ChangeNotifier {
await _applyNodeStatus(machine, online, why: 'node_status');
break;
case 'machine_select_error':
- _lastError =
- 'Machine selection failed: ${payload['error'] ?? 'unknown error'}';
- _lastErrorRetryable = true;
+ final code = '${payload['error'] ?? ''}';
+ final name = machine.machine.displayName;
+ if (code == 'NOT_YOUR_MACHINE' &&
+ machine.machine.machineShare != null) {
+ // Its owner stopped sharing it: no retry brings it back, and the list drops it.
+ _noteSharingEnded(machine.machine);
+ _lastError =
+ '${machine.machine.machineShare!.owner} stopped sharing $name with you.';
+ _lastErrorRetryable = false;
+ unawaited(refreshMachines());
+ } else {
+ _lastError = machineSelectErrorText(code, name);
+ _lastErrorRetryable =
+ code != 'NOT_YOUR_MACHINE' && code != 'MACHINE_ENV_MISMATCH';
+ }
machine.connectionStatus = ConnectionStatus.disconnected;
break;
case 'agent_synced':
@@ -18579,3 +18612,14 @@ final appStateProvider = Provider<AppNotifier>((ref) {
app.bootstrap();
return app;
});
+
+/// What a refused `machine_select` means, in words a person can act on (backend lib/webWs.ts codes).
+String machineSelectErrorText(String code, String machine) => switch (code) {
+ 'NOT_YOUR_MACHINE' => '$machine is no longer on your account.',
+ 'MACHINE_ENV_MISMATCH' =>
+ '$machine belongs to another Autonomous environment. Sign in to that one to use it.',
+ 'MACHINE_PAYMENT_PENDING' => '$machine is waiting for its payment to finish.',
+ 'MACHINE_SUBSCRIPTION_REQUIRED' =>
+ 'The subscription for $machine has ended. Renew it to use it again.',
+ _ => 'Could not connect to $machine. Try again in a moment.',
+};
diff --git a/desktop/lib/widgets/machine_sharing_form.dart b/desktop/lib/widgets/machine_sharing_form.dart
index e372dcb7e..33f96afdb 100644
--- a/desktop/lib/widgets/machine_sharing_form.dart
+++ b/desktop/lib/widgets/machine_sharing_form.dart
@@ -64,15 +64,13 @@ class MachineSharingFormState extends State<MachineSharingForm> {
/// Why the sharing could not be read at all; the form offers Retry instead of its controls.
String? _unavailable;
- /// What is wrong with what was typed, said under the field it was typed in.
+ /// What is wrong with what was typed, said under the field it was typed in ([_fieldIsError]: in
+ /// error ink; otherwise a quiet note, "Already shared with …").
String? _fieldError;
+ bool _fieldIsError = true;
- /// What the last change came to: an error (in error ink) or a quiet confirmation.
+ /// Why the last change was refused. A change that went through says nothing: the list shows it.
String? _status;
- bool _statusIsError = false;
-
- /// The address the last removal took off, while its Undo is offered.
- String? _undo;
/// Something changed while the form was open: Done leaves a summary in the machine's details.
bool _changed = false;
@@ -192,27 +190,20 @@ class MachineSharingFormState extends State<MachineSharingForm> {
}
}
- void _say(String message, {bool error = false, String? undo}) {
+ void _fieldSays(String message, {bool error = true}) {
setState(() {
- _status = message;
- _statusIsError = error;
- _undo = undo;
+ _fieldError = message;
+ _fieldIsError = error;
});
}
/// Make the machine's sharing [emails] and [sameDomain], at once. While it is written nothing else
/// can change; a refusal leaves the sharing as it was and says why.
- Future<bool> _apply(
- List<String> emails,
- bool sameDomain, {
- required String done,
- String? undo,
- }) async {
+ Future<bool> _apply(List<String> emails, bool sameDomain) async {
if (_busy) return false;
setState(() {
_busy = true;
_status = null;
- _undo = null;
});
Map<String, dynamic> answer;
try {
@@ -231,17 +222,15 @@ class MachineSharingFormState extends State<MachineSharingForm> {
final error = answer['error'];
setState(() {
_busy = false;
- if (error == null) _show(answer);
+ if (error == null) {
+ _show(answer);
+ } else {
+ _status =
+ answer['message'] as String? ?? 'Could not share it ($error).';
+ }
});
- if (error != null) {
- _say(
- answer['message'] as String? ?? 'Could not share it ($error).',
- error: true,
- );
- return false;
- }
+ if (error != null) return false;
_changed = true;
- _say(done, undo: undo);
return true;
}
@@ -274,84 +263,55 @@ class MachineSharingFormState extends State<MachineSharingForm> {
.where((email) => !_emailPattern.hasMatch(email))
.firstOrNull;
if (bad != null) {
- setState(() => _fieldError = '“$bad” is not an email address.');
+ _fieldSays('“$bad” is not an email address.');
_input.requestFocus();
return;
}
final fresh = typed.where((email) => !_emails.contains(email)).toSet();
if (fresh.isEmpty) {
_value.clear();
- _say(
+ _fieldSays(
typed.length == 1
? 'Already shared with ${typed.single}.'
: 'Already shared with them.',
+ error: false,
);
return;
}
if (_emails.length + fresh.length > machineShareEmailsMax) {
- setState(
- () => _fieldError =
- 'A machine can be shared with up to $machineShareEmailsMax people.',
+ _fieldSays(
+ 'A machine can be shared with up to $machineShareEmailsMax people.',
);
return;
}
- final added = await _apply(
- [..._emails, ...fresh],
- _sameDomain,
- done: fresh.length == 1
- ? 'Shared with ${fresh.single}.'
- : 'Shared with ${fresh.length} people.',
- );
+ final added = await _apply([..._emails, ...fresh], _sameDomain);
if (added) _value.clear();
if (mounted) _input.requestFocus();
}
Future<void> _remove(String email) async {
- await _apply(
- [..._emails]..remove(email),
- _sameDomain,
- done: 'Stopped sharing with $email.',
- undo: email,
- );
+ await _apply([..._emails]..remove(email), _sameDomain);
if (mounted) focus();
}
- Future<void> _undoRemove() async {
- final email = _undo;
- if (email == null) return;
- await _apply(
- [..._emails, email],
- _sameDomain,
- done: 'Shared with $email again.',
- );
- }
-
Future<void> _toggleDomain() async {
- final domain = _domain;
- if (domain == null) return;
- final on = !_sameDomain;
- await _apply(
- _emails,
- on,
- done: on
- ? 'Everyone at $domain can add it now.'
- : 'No longer shared with everyone at $domain.',
- );
+ if (_domain == null) return;
+ await _apply(_emails, !_sameDomain);
}
// ── keys ──────────────────────────────────────────────────────────────────────────────────────
- /// The editor's stops after the field, in reading order: Share, each person's remove, Undo, then
- /// Done (or Retry and Done when the sharing could not be read). The domain switch reads before the
- /// field.
+ /// The editor's stops, in reading order: Back, the domain switch, (the field,) Share, each person's
+ /// remove (or Back and Retry when the sharing could not be read).
List<({String id, VoidCallback? run})> get _stops {
if (_loading || _unavailable != null) {
return [
+ (id: 'back', run: _done),
if (!_loading) (id: 'retry', run: () => unawaited(_load())),
- (id: 'done', run: _done),
];
}
return [
+ (id: 'back', run: _done),
if (_domain != null)
(id: 'domain', run: _busy ? null : () => unawaited(_toggleDomain())),
(
@@ -366,9 +326,6 @@ class MachineSharingFormState extends State<MachineSharingForm> {
id: 'remove:${person.email}',
run: _busy ? null : () => unawaited(_remove(person.email)),
),
- if (_undo != null)
- (id: 'undo', run: _busy ? null : () => unawaited(_undoRemove())),
- (id: 'done', run: _done),
];
}
@@ -378,12 +335,13 @@ class MachineSharingFormState extends State<MachineSharingForm> {
List<FocusNode> get _nodes {
final stops = _stops.where((stop) => stop.run != null).toList();
final field = !_loading && _unavailable == null && !_busy;
+ const beforeField = {'back', 'domain'};
return [
for (final stop in stops)
- if (stop.id == 'domain') _node(stop.id),
+ if (beforeField.contains(stop.id)) _node(stop.id),
if (field) _input,
for (final stop in stops)
- if (stop.id != 'domain') _node(stop.id),
+ if (!beforeField.contains(stop.id)) _node(stop.id),
];
}
@@ -537,11 +495,31 @@ class MachineSharingFormState extends State<MachineSharingForm> {
const small = SizedBox(height: DesktopChrome.controlGap);
final muted13 = DesktopChrome.text(size: 13, color: DesktopChrome.muted);
- final heading = Text(
- 'Share $_name',
- style: DesktopChrome.heading(),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
+ // Back to the machine's details: the way out, beside what it leaves (Esc does the same). The
+ // arrow's glyph sits on the column's edge, its 32-point target reaching past it.
+ final heading = Transform.translate(
+ offset: const Offset(-8, 0),
+ child: Row(
+ children: [
+ AppIconButton(
+ key: const ValueKey('machine-sharing:back'),
+ icon: AppIcons.arrowLeft,
+ tooltip: 'Back',
+ color: DesktopChrome.foreground,
+ focusNode: _node('back'),
+ onPressed: _done,
+ ),
+ const SizedBox(width: 2),
+ Expanded(
+ child: Text(
+ 'Share $_name',
+ style: DesktopChrome.heading(),
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ ],
+ ),
);
// What sharing gives, said once and plainly: these people get the owner's own rights.
@@ -642,13 +620,15 @@ class MachineSharingFormState extends State<MachineSharingForm> {
),
prefixIconConstraints: const BoxConstraints(minWidth: 36),
border: fieldBorder,
- enabledBorder: _fieldError == null
+ enabledBorder: _fieldError == null || !_fieldIsError
? fieldBorder
: fieldBorder.copyWith(borderSide: BorderSide(color: error)),
disabledBorder: fieldBorder,
focusedBorder: fieldBorder.copyWith(
borderSide: BorderSide(
- color: _fieldError == null ? DesktopChrome.focusRing : error,
+ color: _fieldError == null || !_fieldIsError
+ ? DesktopChrome.focusRing
+ : error,
width: grid.AppDesktop.focusWidth,
),
),
@@ -754,30 +734,7 @@ class MachineSharingFormState extends State<MachineSharingForm> {
),
);
- final empty = Container(
- key: const ValueKey('machine-sharing:empty'),
- decoration: inset,
- padding: const EdgeInsets.all(12),
- child: Row(
- children: [
- Icon(
- AppIcons.lock,
- size: AppIcons.inlineSize,
- color: DesktopChrome.muted,
- ),
- const SizedBox(width: 12),
- Expanded(
- child: Text(
- _sameDomain
- ? 'No one at $_domain has added it yet.'
- : 'Not shared. Only your own devices can use it.',
- style: muted13,
- ),
- ),
- ],
- ),
- );
-
+ // Only what needs saying: the change under way, or why it was refused.
final status = Semantics(
liveRegion: true,
child: Row(
@@ -786,11 +743,7 @@ class MachineSharingFormState extends State<MachineSharingForm> {
_spinner(),
const SizedBox(width: 8),
] else if (_status != null) ...[
- Icon(
- _statusIsError ? AppIcons.circleAlert : AppIcons.check,
- size: 14,
- color: _statusIsError ? error : DesktopChrome.muted,
- ),
+ Icon(AppIcons.circleAlert, size: 14, color: error),
const SizedBox(width: 8),
],
Flexible(
@@ -798,23 +751,31 @@ class MachineSharingFormState extends State<MachineSharingForm> {
_busy ? 'Saving…' : _status ?? '',
style: DesktopChrome.text(
size: 12,
- color: _statusIsError ? error : DesktopChrome.muted,
+ color: _busy ? DesktopChrome.muted : error,
),
),
),
- if (!_busy && _undo != null) ...[
- const SizedBox(width: 4),
- TextButton(
- key: const ValueKey('machine-sharing:undo'),
- focusNode: _node('undo'),
- onPressed: () => unawaited(_undoRemove()),
- child: const Text('Undo'),
- ),
- ],
],
),
);
+ // Said only when there is something to say: a change under way, a refusal, or Retry.
+ final retry = !_loading && _unavailable != null;
+ final actions = _busy || _status != null || retry
+ ? Row(
+ children: [
+ Expanded(child: status),
+ if (retry)
+ TextButton(
+ key: const ValueKey('machine-sharing:retry'),
+ focusNode: _node('retry'),
+ onPressed: () => unawaited(_load()),
+ child: const Text('Retry'),
+ ),
+ ],
+ )
+ : null;
+
final List<Widget> content;
if (_loading) {
content = [
@@ -866,77 +827,27 @@ class MachineSharingFormState extends State<MachineSharingForm> {
child: Text(
problem,
key: const ValueKey('machine-sharing:field-error'),
- style: DesktopChrome.text(size: 12, color: error),
+ style: DesktopChrome.text(
+ size: 12,
+ color: _fieldIsError ? error : DesktopChrome.muted,
+ ),
),
),
),
- small,
- if (people.isEmpty) empty else ...people.map(personRow),
+ if (people.isNotEmpty) ...[small, ...people.map(personRow)],
];
}
- final actions = Row(
- children: [
- Expanded(child: status),
- const SizedBox(width: DesktopChrome.controlGap),
- if (!_loading && _unavailable != null) ...[
- TextButton(
- key: const ValueKey('machine-sharing:retry'),
- focusNode: _node('retry'),
- onPressed: () => unawaited(_load()),
- child: const Text('Retry'),
- ),
- const SizedBox(width: DesktopChrome.controlGap),
+ // The pane's whole width: the form is the pane while it is open.
+ return SingleChildScrollView(
+ padding: const EdgeInsets.fromLTRB(18, 10, 18, 14),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ ...content,
+ if (actions != null) ...[gap, actions],
],
- // Quiet: every change has already applied, and Share is this surface's one strong action.
- TextButton(
- key: const ValueKey('machine-sharing:done'),
- focusNode: _node('done'),
- onPressed: _done,
- child: const Text('Done'),
- ),
- ],
- );
- String? hint(String command) => effectiveCommandHint(
- context,
- command,
- contextKind: KeymapContext.picker,
- )?.replaceAll('⇥', 'Tab').replaceAll('↵', 'Enter');
- return Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Expanded(
- child: SingleChildScrollView(
- padding: const EdgeInsets.fromLTRB(18, 14, 18, 8),
- child: Align(
- alignment: Alignment.topLeft,
- // A short form keeps a short reading line, whatever the pane's width.
- child: ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 520),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: content,
- ),
- ),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.fromLTRB(18, 8, 18, 0),
- child: actions,
- ),
- Padding(
- padding: const EdgeInsets.fromLTRB(18, 8, 18, 14),
- child: Text(
- [
- if (hint('picker.accept') case final enter?) '$enter share',
- if (hint('picker.complete') case final tab?) '$tab next',
- if (hint('picker.cancel') case final escape?) '$escape done',
- ].join(' · '),
- style: DesktopChrome.metadata(),
- ),
- ),
- ],
+ ),
);
}
@@ -969,7 +880,13 @@ class MachineSharingFormState extends State<MachineSharingForm> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- line('Share $_name'),
+ Row(
+ children: [
+ action('back', '←', _done),
+ SizedBox(width: cell.width),
+ line('Share $_name'),
+ ],
+ ),
gap,
if (_loading)
line('Reading who it is shared with…', color: theme.muted)
@@ -1028,11 +945,6 @@ class MachineSharingFormState extends State<MachineSharingForm> {
],
),
gap,
- if (people.isEmpty)
- line(
- 'Not shared. Only your own devices can use it.',
- color: theme.muted,
- ),
for (final person in people)
Row(
children: [
@@ -1055,16 +967,12 @@ class MachineSharingFormState extends State<MachineSharingForm> {
),
],
if (_fieldError case final problem?)
- line(problem, color: theme.yellow),
+ line(problem, color: _fieldIsError ? theme.yellow : theme.muted),
gap,
if (_busy)
line('Saving…', color: theme.muted)
else if (_status case final status?)
- line(status, color: _statusIsError ? theme.yellow : theme.muted),
- if (!_busy && _undo != null)
- action('undo', 'Undo', () => unawaited(_undoRemove())),
- gap,
- action('done', 'Done', _done),
+ line(status, color: theme.yellow),
],
),
);
diff --git a/desktop/lib/widgets/pane_grid.dart b/desktop/lib/widgets/pane_grid.dart
index 9bfc0e63a..79bb8a082 100644
--- a/desktop/lib/widgets/pane_grid.dart
+++ b/desktop/lib/widgets/pane_grid.dart
@@ -1662,7 +1662,25 @@ class _PaneContent extends StatelessWidget {
notifier.zoomedPaneId == null &&
terminalPaneCount >= 3;
final TerminalNotice? notice;
- if (machine == null) {
+ final sharingEnded = machine == null
+ ? notifier.sharingEnded(pane.machineId)
+ : null;
+ if (sharingEnded != null) {
+ // Its owner stopped sharing the machine: say who, and the one thing left to do here.
+ final tab = notifier.swarms
+ .where((swarm) => swarm.panes.contains(pane))
+ .firstOrNull;
+ notice = terminalNotice(
+ label: 'No longer shared',
+ icon: AppIcons.unlink,
+ detail:
+ '${sharingEnded.owner} stopped sharing ${sharingEnded.name} with you. The harness stays on their machine; what is shown here is read only.',
+ actionLabel: 'Close',
+ onAction: () =>
+ notifier.closePane(pane.id, swarmId: tab?.id).ignore(),
+ banner: true,
+ );
+ } else if (machine == null) {
notice = terminalNotice(
label: 'Unavailable',
icon: AppIcons.cloudOff,
diff --git a/desktop/test/machine_sharing_ended_test.dart b/desktop/test/machine_sharing_ended_test.dart
new file mode 100644
index 000000000..151860f3c
--- /dev/null
+++ b/desktop/test/machine_sharing_ended_test.dart
@@ -0,0 +1,97 @@
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/auth/auth_session.dart';
+import 'package:harness/core/config.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/state/app_state.dart';
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ late AppNotifier app;
+ AppNotifier withMachine(Machine machine) {
+ final app = AppNotifier(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ );
+ app.machines = [machine];
+ app.machineStates[machine.machineId] = MachineState(machine)
+ ..nodeOnline = true
+ ..connectionStatus = ConnectionStatus.connected;
+ return app;
+ }
+
+ tearDown(() => app.dispose());
+
+ // Seen 2026-10-16: the owner stopped sharing, and the person's pane said
+ // "Machine selection failed: NOT_YOUR_MACHINE" with a Retry that could never work.
+ test('a machine its owner stopped sharing says who, offers no retry, and is remembered for its panes', () async {
+ app = withMachine(
+ const Machine(
+ machineId: 'studio',
+ authMode: MachineAuthMode.remote,
+ name: 'MacBook Pro',
+ machineShare: MachineShare(
+ ownerName: 'Dee',
+ ownerEmail: '[email protected]',
+ via: 'email',
+ added: true,
+ ),
+ ),
+ );
+ await app.handleEventForTest('studio', {
+ 'type': 'machine_select_error',
+ 'payload': {'machineId': 'studio', 'error': 'NOT_YOUR_MACHINE'},
+ });
+ expect(app.lastError, 'Dee stopped sharing MacBook Pro with you.');
+ expect(app.lastErrorRetryable, isFalse);
+ expect(app.sharingEnded('studio'), (name: 'MacBook Pro', owner: 'Dee'));
+ expect(
+ app.stateOf('studio')!.connectionStatus,
+ ConnectionStatus.disconnected,
+ );
+ });
+
+ test('the account’s own machine refused is said in words, retryable only when retrying can help', () async {
+ app = withMachine(
+ const Machine(
+ machineId: 'own',
+ authMode: MachineAuthMode.remote,
+ name: 'Studio',
+ ),
+ );
+ await app.handleEventForTest('own', {
+ 'type': 'machine_select_error',
+ 'payload': {'machineId': 'own', 'error': 'NOT_YOUR_MACHINE'},
+ });
+ expect(app.lastError, 'Studio is no longer on your account.');
+ expect(app.lastErrorRetryable, isFalse);
+ expect(app.sharingEnded('own'), isNull);
+ await app.handleEventForTest('own', {
+ 'type': 'machine_select_error',
+ 'payload': {'machineId': 'own', 'error': 'MACHINE_START_FAILED'},
+ });
+ expect(
+ app.lastError,
+ 'Could not connect to Studio. Try again in a moment.',
+ );
+ expect(app.lastErrorRetryable, isTrue);
+ });
+
+ test('every refusal code reads as a sentence', () {
+ for (final code in [
+ 'NOT_YOUR_MACHINE',
+ 'MACHINE_ENV_MISMATCH',
+ 'MACHINE_PAYMENT_PENDING',
+ 'MACHINE_SUBSCRIPTION_REQUIRED',
+ 'SOMETHING_NEW',
+ ]) {
+ final text = machineSelectErrorText(code, 'Studio');
+ expect(text, contains('Studio'));
+ expect(text, isNot(contains('_')), reason: code);
+ }
+ app = withMachine(
+ const Machine(machineId: 'x', authMode: MachineAuthMode.remote),
+ );
+ });
+}
diff --git a/desktop/test/machine_sharing_form_test.dart b/desktop/test/machine_sharing_form_test.dart
index 3097dc208..98a5b8bff 100644
--- a/desktop/test/machine_sharing_form_test.dart
+++ b/desktop/test/machine_sharing_form_test.dart
@@ -136,13 +136,20 @@ void main() {
}
testWidgets(
- 'shares with people and the domain as each change is made, with Undo',
+ 'shares with people and the domain as each change is made, saying only what needs saying',
(tester) async {
final app = _SharingApp();
final (closed, boundary) = await open(tester, app);
expect(find.text('Share this machine'), findsOneWidget);
+ // Nobody yet: no empty box, no hints, no Done; Back (and Esc) leaves.
expect(
find.text('Not shared. Only your own devices can use it.'),
+ findsNothing,
+ );
+ expect(find.textContaining('Tab next'), findsNothing);
+ expect(find.text('Done'), findsNothing);
+ expect(
+ find.byKey(const ValueKey('machine-sharing:back')),
findsOneWidget,
);
expect(find.text('Everyone at autonomous.ai'), findsOneWidget);
@@ -183,7 +190,8 @@ void main() {
await tester.tap(find.byKey(const ValueKey('machine-sharing:add')));
await tester.pumpAndSettle();
expect(app.sets.last.emails, ['[email protected]', '[email protected]']);
- expect(find.text('Shared with 2 people.'), findsOneWidget);
+ // A share that went through says nothing: the list shows it.
+ expect(find.text('Shared with 2 people.'), findsNothing);
expect(find.text('Using it'), findsOneWidget);
expect(find.text('Invited · not using it yet'), findsOneWidget);
@@ -199,17 +207,27 @@ void main() {
);
await _snap(tester, boundary, 'share-people-dark');
- // Removing someone is undoable.
+ // Removing someone takes them off the list, and that is all that is said.
await tester.tap(
find.byKey(const ValueKey('machine-sharing:remove:[email protected]')),
);
await tester.pumpAndSettle();
expect(app.sets.last.emails, ['[email protected]']);
- expect(find.text('Stopped sharing with [email protected].'), findsOneWidget);
- await _snap(tester, boundary, 'share-undo-dark');
- await tester.tap(find.byKey(const ValueKey('machine-sharing:undo')));
+ expect(find.textContaining('Stopped sharing'), findsNothing);
+ expect(find.text('Undo'), findsNothing);
+ expect(find.text('[email protected]'), findsNothing);
+ await _snap(tester, boundary, 'share-removed-dark');
+
+ // Someone already on the list is a quiet note under the field, not an error.
+ await tester.enterText(
+ find.byKey(const ValueKey('machine-sharing-email')),
+ );
+ await tester.pump();
+ await tester.tap(find.byKey(const ValueKey('machine-sharing:add')));
await tester.pumpAndSettle();
- expect(app.sets.last.emails, ['[email protected]', '[email protected]']);
+ expect(find.text('Already shared with [email protected].'), findsOneWidget);
+ expect(app.sets.last.emails, ['[email protected]']);
// A refusal says why and changes nothing.
app.refusal = {
@@ -228,14 +246,14 @@ void main() {
isTrue,
);
- // Done leaves where the sharing stands.
- await tester.tap(find.byKey(const ValueKey('machine-sharing:done')));
+ // Back leaves where the sharing stands.
+ await tester.tap(find.byKey(const ValueKey('machine-sharing:back')));
await tester.pump();
- expect(closed(), 'Shared with 2 people and everyone at autonomous.ai.');
+ expect(closed(), 'Shared with 1 person and everyone at autonomous.ai.');
},
);
- testWidgets('Done with nothing changed closes quietly; light appearance', (
+ testWidgets('Back with nothing changed closes quietly; light appearance', (
tester,
) async {
final app = _SharingApp()
@@ -259,7 +277,7 @@ void main() {
findsNothing,
);
await _snap(tester, boundary, 'share-people-light');
- await tester.tap(find.byKey(const ValueKey('machine-sharing:done')));
+ await tester.tap(find.byKey(const ValueKey('machine-sharing:back')));
await tester.pump();
expect(closed(), '');
});
diff --git a/tui/src/app.rs b/tui/src/app.rs
index 89d3415fe..202b072bf 100644
--- a/tui/src/app.rs
+++ b/tui/src/app.rs
@@ -1344,7 +1344,15 @@ impl App {
// Whole machines other accounts share with this one: those named for it and those it added
// are its machines too; one shared with its domain waits to be added. A list that could not
// say (no `sharedMachines`) keeps the ones it had.
+ let before = app.fleet.shares.clone();
let rows = &app.fleet.take_shared(owned, reply.get("sharedMachines").and_then(Value::as_array));
+ // A machine its owner stopped sharing leaves the list, and its panes close with it: the
+ // status line says why (a fresh list says so; an outage's copy proves nothing).
+ if reply["stale"] != true && reply.get("sharedMachines").is_some() {
+ let ended: Vec<String> = before.iter().filter(|(id, _)| !app.fleet.shares.contains_key(*id))
+ .map(|(id, share)| format!("{} stopped sharing {} with you", share.owner, app.fleet.machine_name(id))).collect();
+ for said in ended { app.say(said, crate::theme::WARN) }
+ }
let local = app.fleet.local_id.clone();
// Only a fresh response is authoritative for removals. Outage caches may
// predate a connected computer, so their omissions must retain its views.
@@ -1492,6 +1500,29 @@ impl App {
agent.activity.unknown = unknown;
}
let needs_link = error.code == "NO_PEER_LINK";
+ // Its owner stopped sharing it: no reconnect brings it back. Say so on its panes and in
+ // the status line, and read the list again, which takes it (and them) away.
+ if error.code == "NOT_YOUR_MACHINE" {
+ if let Some(share) = self.fleet.shares.get(&machine_id).cloned() {
+ let name = self.fleet.machine_name(&machine_id);
+ let close = self.keymap.hint("confirm-before -p \"kill-pane #P? (y/n)\" kill-pane").unwrap_or_else(|| "C-b x".into());
+ for pane in self.panes.values_mut().filter(|p| p.machine_id == machine_id) {
+ pane.stream = None;
+ pane.opening = false;
+ pane.open_token += 1;
+ pane.phase = Phase::Card {
+ title: format!("{} stopped sharing {name} with you", share.owner),
+ detail: "The harness stays on their machine. What is shown here is read only.".into(),
+ keys: vec![(close.clone(), "close pane".into())],
+ };
+ pane.dirty = true;
+ }
+ if let Some(state) = self.links.get_mut(&machine_id) { if let Some(link) = state.link.take() { link.close(); } state.retry_at = None; }
+ self.say(format!("{} stopped sharing {name} with you", share.owner), crate::theme::WARN);
+ self.refresh_machines();
+ return;
+ }
+ }
if let Some(machine) = self.fleet.machine_mut(&machine_id) {
machine.reach = if needs_link { Reach::NeedsLink } else if machine.online() { Reach::Error(error.to_string()) } else { Reach::Offline };
}
@@ -7166,6 +7197,28 @@ mod recovery_tests {
app.links["test-peer"].link.as_ref().unwrap().close();
}
+ // Seen 2026-10-16: the owner stopped sharing and the person's panes waited to reconnect forever.
+ #[tokio::test]
+ async fn a_machine_its_owner_stops_sharing_says_who_and_stops_reconnecting() {
+ let mut app = fixture();
+ app.fleet.shares.insert("test-peer".into(), crate::fleet::MachineShare { owner: "Dee".into(), email: "[email protected]".into(), team: false });
+ app.on_machine("test-peer".into(), 1, MachineEvent::Failed(RpcError::new("NOT_YOUR_MACHINE", "")));
+ let on_it: Vec<u64> = app.panes.values().filter(|p| p.machine_id == "test-peer").map(|p| p.id).collect();
+ assert!(!on_it.is_empty());
+ for id in on_it {
+ match &app.panes[&id].phase {
+ Phase::Card { title, keys, .. } => {
+ assert!(title.starts_with("Dee stopped sharing"), "{title}");
+ assert_eq!(keys.iter().map(|(_, what)| what.as_str()).collect::<Vec<_>>(), ["close pane"]);
+ }
+ other => panic!("pane {id} shows {other:?}"),
+ }
+ assert!(app.panes[&id].stream.is_none());
+ }
+ assert!(app.links["test-peer"].link.is_none());
+ assert!(app.links["test-peer"].retry_at.is_none(), "no reconnect is scheduled");
+ }
+
#[tokio::test]
async fn expired_lease_recovers_hidden_shells_and_ignores_cancelled_events() {
let mut app = fixture();
diff --git a/tui/src/devices.rs b/tui/src/devices.rs
index 5e3d32dbd..bb8053f44 100644
--- a/tui/src/devices.rs
+++ b/tui/src/devices.rs
@@ -41,6 +41,8 @@ pub const DOWNLOAD_URL: &str = "https://www.autonomous.ai/harness";
pub const INSTALL: &str = "curl -fsSL https://cdn.autonomous.ai/harness/cli/install.sh | bash";
pub const LOGIN: &str = "harness login";
pub const START: &str = "harness start && harness remote-password set";
+/// What sharing this computer gives (machine_sharing_form.dart's intro).
+const SHARE_ACCESS: &str = "People you share it with get full access: they can run harnesses, open terminals and read files on it.";
/// Where the Add Phone QR points (add_phone_dialog.dart `phonePairLink`): the phone parses exactly
/// this, so the TUI's code is the app's, byte for byte.
@@ -174,6 +176,9 @@ pub struct Devices {
pub phone: Phone,
pub ask: Option<Ask>,
prompt_actions: std::cell::Cell<Option<PromptActions>>,
+ /// Where the title is drawn while a level is open (and the size it was drawn at): a click on
+ /// it goes back, as Esc does — the mouse's way out of a level.
+ back_at: std::cell::Cell<Option<((u16, u16), Rect)>>,
/// The chosen button of the prompt's row (0 Cancel, 1 the action), and whether the keys are on
/// the buttons: a confirmation's always are, a typed line's only after Tab.
prompt_row: std::cell::Cell<usize>,
@@ -192,7 +197,7 @@ pub struct Devices {
impl Default for Devices {
fn default() -> Devices {
Devices {
- password: None, sharing: None, links: None, account: HashMap::new(), link: None, phone: Phone::default(), ask: None, prompt_actions: Default::default(), prompt_row: Default::default(), prompt_focus: Default::default(), unfit: Default::default(), sub: None, footer: None, loading: Vec::new(), runner: default_runner(),
+ password: None, sharing: None, links: None, account: HashMap::new(), link: None, phone: Phone::default(), ask: None, prompt_actions: Default::default(), back_at: Default::default(), prompt_row: Default::default(), prompt_focus: Default::default(), unfit: Default::default(), sub: None, footer: None, loading: Vec::new(), runner: default_runner(),
}
}
}
@@ -925,7 +930,14 @@ pub fn paste(app: &mut App, text: &str) -> bool {
/// Only the actions drawn for this prompt can advance it; a click on its input gives the input
/// the keys; a click outside the panel cancels.
pub fn mouse(app: &mut App, mouse: MouseEvent) -> bool {
- if view_of(app).is_none() || app.devices.ask.is_none() { return false }
+ let Some(view) = view_of(app) else { return false };
+ if app.devices.ask.is_none() {
+ let back = app.devices.back_at.get().filter(|(size, _)| *size == app.size && app.devices.sub.is_some());
+ let click = mouse.kind == MouseEventKind::Down(MouseButton::Left) && mouse.modifiers.is_empty();
+ if !(click && back.is_some_and(|(_, r)| r.contains(Position::new(mouse.column, mouse.row)))) { return false }
+ step_back(app, view);
+ return true;
+ }
if mouse.kind != MouseEventKind::Down(MouseButton::Left) || !mouse.modifiers.is_empty() { return true }
let at = Position::new(mouse.column, mouse.row);
let action = app.devices.prompt_actions.get().filter(|a| a.size == app.size);
@@ -1436,7 +1448,7 @@ fn action_rows(app: &App, id: &str) -> Vec<Row> {
match app.fleet.shares.get(id) {
// Another account's: its owner renames, removes and shares it.
Some(share) => {
- rows.push(info("shared-by", format!("Shared with you by {}{}", share.owner, if share.email.is_empty() || share.email == share.owner { String::new() } else { format!(" ({})", share.email) }), &group));
+ rows.push(info("shared-by", format!("Shared with you by {}", owner_of(share)), &group));
if share.team { rows.push(act("unshare", "Remove from my machines…", "add it again from Shared with your team", "✗")) }
}
None => {
@@ -1450,7 +1462,7 @@ fn action_rows(app: &App, id: &str) -> Vec<Row> {
/// This computer's sharing: everyone at its domain, the addresses, and who uses it now.
fn share_rows(app: &App) -> Vec<Row> {
let here = format!("Share {}", app.fleet.local_machine_name());
- let mut rows = vec![info("share-what", "People you share it with use it as their own: its harnesses, terminals and files.", &here)];
+ let mut rows = vec![info("share-what", "People you share it with get full access.", &here)];
let Some((emails, same_domain, domain)) = sharing_now(app) else {
match &app.devices.sharing {
Some(Err(message)) => {
@@ -1469,12 +1481,22 @@ fn share_rows(app: &App) -> Vec<Row> {
for email in &emails {
rows.push(Row::new(format!("shr:rm:{email}"), email.clone()).group(here.clone()).extra("remove").lead(dot("·", theme::MUTED)).right("remove"));
}
- let using: Vec<&str> = app.devices.sharing.as_ref().and_then(|s| s.as_ref().ok()).and_then(|v| v.get("members")).and_then(Value::as_array)
- .into_iter().flatten().filter_map(|m| m.get("email").and_then(Value::as_str)).collect();
+ let using: Vec<String> = sharing_members(app).into_iter().map(|(email, _)| email).collect();
if !using.is_empty() { rows.push(info("share-using", format!("Using it now: {}", using.join(", ")), &here)) }
rows
}
+/// Who uses this computer through its sharing now, and how it reached them (`email` or `domain`).
+fn sharing_members(app: &App) -> Vec<(String, String)> {
+ app.devices.sharing.as_ref().and_then(|s| s.as_ref().ok()).and_then(|v| v.get("members")).and_then(Value::as_array).into_iter().flatten()
+ .filter_map(|m| Some((m.get("email")?.as_str()?.to_string(), m.get("via").and_then(Value::as_str).unwrap_or("email").to_string()))).collect()
+}
+
+/// A share's owner as people read it: the name, and the address when it says more.
+fn owner_of(share: &crate::fleet::MachineShare) -> String {
+ if share.email.is_empty() || share.email == share.owner { share.owner.clone() } else { format!("{} ({})", share.owner, share.email) }
+}
+
fn device_name(p: &Value) -> String {
let label = p.get("label").and_then(Value::as_str).unwrap_or("").trim();
if label.is_empty() || label == "harness link" || label == "browser" { "Linked device".into() } else { label.to_string() }
@@ -1521,7 +1543,15 @@ pub fn preview(app: &App, view: View, id: &str) -> Vec<Line<'static>> {
"here" => vec![Line::raw("Set up Harness on your other computer."), Line::raw(""),
dim("The setup guide covers sign-in, the remote password and servers.").into(),
Line::raw(""), dim("Enter opens Machines & devices.").into()],
- "account" => vec![Line::raw("Use Harness locally without signing in."), Line::raw(""), Line::raw("Sign in to connect your computers, sync your workspace, and use your phone."), Line::raw("Run models on one linked computer and use them from another.")],
+ "account" => match &app.account.status {
+ crate::account::Status::SignedIn { email, .. } => {
+ let mut out = vec![Line::raw(email.as_ref().map_or("Signed in.".into(), |e| format!("Signed in as {e}."))), Line::raw(""),
+ dim("Your computers, workspace and phone use this account.").into()];
+ out.extend(enter_does("opens Account"));
+ out
+ }
+ _ => vec![Line::raw("Use Harness locally without signing in."), Line::raw(""), Line::raw("Sign in to connect your computers, sync your workspace, and use your phone."), Line::raw("Run models on one linked computer and use them from another.")],
+ },
"m" => {
let mut out = machine_lines(app, rest);
if view == View::Connect {
@@ -1530,7 +1560,11 @@ pub fn preview(app: &App, view: View, id: &str) -> Vec<Line<'static>> {
out.extend(stage_lines(app, rest));
if app.devices.link.as_ref().is_none_or(|l| l.machine != rest) { out.extend(enter_does("type its remote password, then link")) }
} else {
- out.extend(enter_does("its actions — open, connect, rename, remove from account"));
+ out.extend(enter_does(match app.fleet.shares.get(rest) {
+ Some(share) if share.team => "its actions — open, remove from your machines",
+ Some(_) => "its actions — open",
+ None => "its actions — open, connect, rename, remove from account",
+ }));
}
out
}
@@ -1542,10 +1576,25 @@ pub fn preview(app: &App, view: View, id: &str) -> Vec<Line<'static>> {
"connect" => "asks for its remote password, then links it",
"rename" => "asks for its new name, then y/n",
"remove" => "asks y/n, then deletes it from your account",
+ "unshare" => "asks y/n, then removes it from your machines",
_ => "",
}));
out
}
+ "share" => {
+ let mut out = vec![bold(format!("Share {}", app.fleet.local_machine_name())).into(), Line::raw(""), Line::raw(SHARE_ACCESS), Line::raw("")];
+ out.extend(sharing_lines(app));
+ out.extend(enter_does("who it is shared with — add or remove people, or everyone at your domain"));
+ out
+ }
+ "shr" => share_preview(app, rest),
+ "addshared" => {
+ let Some((_, name, share)) = app.fleet.to_add.iter().find(|(id, ..)| id == rest) else { return vec![] };
+ let mut out = vec![bold(name.clone()).into(), Line::raw(""), kv("shared by", owner_of(share)), Line::raw(""),
+ Line::raw(format!("{} shared it with everyone at your company. Added, it is one of your machines: its harnesses, terminals and files.", share.owner))];
+ out.extend(enter_does("adds it to your machines"));
+ out
+ }
"pw" => {
let mut out = Vec::new();
match &app.devices.password {
@@ -1598,11 +1647,62 @@ pub fn preview(app: &App, view: View, id: &str) -> Vec<Line<'static>> {
}
}
+/// Who this computer is shared with now, under its Share row.
+fn sharing_lines(app: &App) -> Vec<Line<'static>> {
+ let Some((emails, same_domain, domain)) = sharing_now(app) else {
+ return vec![match &app.devices.sharing { Some(Err(e)) => Line::from(Span::styled(e.clone(), fg(theme::WARN))), _ => dim("Reading its sharing…").into() }];
+ };
+ let mut out = Vec::new();
+ if let Some(d) = domain { out.push(kv("domain", format!("everyone at @{d} · {}", if same_domain { "on" } else { "off" }))) }
+ if emails.is_empty() { out.push(kv("people", "nobody yet")) }
+ for (i, email) in emails.iter().enumerate() { out.push(kv(if i == 0 { "people" } else { "" }, email.clone())) }
+ let using: Vec<String> = sharing_members(app).into_iter().map(|(email, _)| email).collect();
+ if !using.is_empty() { out.push(kv("using it", using.join(", "))) }
+ out
+}
+
+/// The right side for one of this computer's sharing rows: what it is, and what Enter does.
+fn share_preview(app: &App, rest: &str) -> Vec<Line<'static>> {
+ if rest == "reload" {
+ let mut out = match &app.devices.sharing { Some(Err(e)) => vec![Line::from(Span::styled(e.clone(), fg(theme::WARN)))], _ => vec![] };
+ out.extend(enter_does("reads its sharing again"));
+ return out;
+ }
+ let Some((_, same_domain, domain)) = sharing_now(app) else { return vec![] };
+ let members = sharing_members(app);
+ match rest.split_once(':').unwrap_or((rest, "")) {
+ ("domain", _) => {
+ let Some(d) = domain else { return vec![] };
+ let mut out = vec![bold(format!("Everyone at @{d}")).into(), Line::raw(""),
+ Line::raw(format!("Anyone with an @{d} address can add it from Machines and use it as their own.")), Line::raw(""),
+ kv("now", if same_domain { "on" } else { "off" })];
+ let added: Vec<&str> = members.iter().filter(|(_, via)| via == "domain").map(|(email, _)| email.as_str()).collect();
+ if !added.is_empty() { out.push(kv("added it", added.join(", "))) }
+ out.extend(enter_does(if same_domain { format!("stops sharing with everyone at @{d}; people you added by email keep it") } else { "asks y/n, then shares it with them".into() }));
+ out
+ }
+ ("add", _) => {
+ let mut out = vec![bold("Add people").into(), Line::raw(""), Line::raw("They see it in their Machines and use it as their own: its harnesses, terminals and files."),
+ Line::raw(""), dim("Several at once: separate the addresses with commas or spaces.").into()];
+ out.extend(enter_does("asks for their email addresses, then y/n"));
+ out
+ }
+ ("rm", email) => {
+ let using = members.iter().any(|(e, _)| e == email);
+ let mut out = vec![bold(email.to_string()).into(), Line::raw(""), kv("status", if using { "using it" } else { "invited · not using it yet" })];
+ out.extend(enter_does("asks y/n, then stops sharing with them — they lose access at once"));
+ out
+ }
+ _ => vec![],
+ }
+}
+
fn machine_lines(app: &App, id: &str) -> Vec<Line<'static>> {
let Some(m) = app.fleet.machine(id) else { return vec![dim("(gone)").into()] };
let (glyph, color, word) = reach(app, m);
let mut out = vec![Line::from(vec![bold(m.name.clone()), dim(if m.local { " this computer" } else { "" })]), Line::raw("")];
out.push(Line::from(vec![dim(format!("{:<10}", "status")), Span::styled(format!("{glyph} {word}"), fg(color))]));
+ if let Some(share) = app.fleet.shares.get(id) { out.push(kv("shared by", owner_of(share))) }
if let Some(rtt) = app.rtt.get(id).filter(|_| m.usable()) { out.push(kv("rtt", format!("{}ms", rtt.as_millis()))) }
let row = app.devices.account.get(id);
let seen = row.and_then(|r| ["lastSeenAt", "lastSeen", "lastActiveAt", "updatedAt"].iter().find_map(|k| r.get(*k)));
@@ -1654,6 +1754,7 @@ fn head(buf: &mut Buffer, app: &App, title: &str, x: u16, y: u16, right: u16, c:
Some("share:") => Some(format!("Share {}", app.fleet.local_machine_name())),
sub => sub.and_then(|s| s.strip_prefix("m:")).map(|id| name_of(app, id)),
};
+ app.devices.back_at.set(level.as_ref().map(|_| (app.size, Rect::new(x, y, at - x, 1))));
if let Some(level) = level {
at += settings::put(buf, at, y, right.saturating_sub(at), " › ", c.muted);
settings::put(buf, at, y, right.saturating_sub(at), &level, c.accent);
@@ -2077,6 +2178,66 @@ mod tests {
assert_eq!(match &app.modal { Some(Modal::Picker { picker, .. }) => picker.current_id(), _ => None }.as_deref(), Some("share:"));
}
+ // Seen 2026-10-16: the list is about fifty columns, so the sharing rows were cut short, and
+ // the side beside them, where a row says the rest, was empty.
+ #[test]
+ fn every_sharing_row_says_in_full_beside_it_what_it_is_and_what_enter_does() {
+ const SHARED: &str = "abababababababababababababababab";
+ const TEAM: &str = "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd";
+ let mut app = app((150, 42));
+ let _log = sharing_world(&mut app);
+ app.account.status = crate::account::Status::SignedIn { offline: false, email: Some("[email protected]".into()) };
+ app.fleet.machines.push(crate::fleet::Machine { shared: false, id: SHARED.into(), name: "dee-studio".into(), local: false, status: "running".into(), reach: Reach::Ready });
+ let dee = crate::fleet::MachineShare { owner: "Dee".into(), email: "[email protected]".into(), team: true };
+ app.fleet.shares.insert(SHARED.into(), dee.clone());
+ app.fleet.to_add.push((TEAM.into(), "gpu-box-2".into(), dee));
+ open(&mut app, View::Machines);
+ app.devices.sharing = Some(Ok(json!({ "emails": ["[email protected]", "[email protected]"], "sameDomain": true, "domain": "acme.io",
+ "members": [{ "email": "[email protected]", "via": "email" }, { "email": "[email protected]", "via": "domain" }] })));
+ let text = |id: &str| preview(&app, View::Machines, id).iter().map(|l| l.spans.iter().map(|s| s.content.as_ref()).collect::<String>()).collect::<Vec<_>>().join("\n");
+
+ assert!(text("account").starts_with("Signed in as [email protected]."), "{}", text("account"));
+ let share = text("share:");
+ for said in ["get full access", "everyone at @acme.io · on", "[email protected]", "[email protected]", "[email protected], [email protected]"] { assert!(share.contains(said), "{said}: {share}") }
+ assert!(text("shr:domain").contains("Anyone with an @acme.io address") && text("shr:domain").contains("[email protected]"));
+ assert!(text("shr:domain").contains("people you added by email keep it"));
+ assert!(text("shr:rm:[email protected]").contains("using it") && text("shr:rm:[email protected]").contains("invited · not using it yet"));
+ assert!(text(&format!("m:{SHARED}")).contains("Dee ([email protected])") && text(&format!("m:{SHARED}")).contains("remove from your machines"));
+ assert!(text(&format!("addshared:{TEAM}")).contains("Dee ([email protected])"));
+ for id in ["share:", "shr:domain", "shr:add", "shr:rm:[email protected]", "shr:reload", &format!("addshared:{TEAM}"), &format!("act:unshare:{SHARED}")] {
+ let said = text(id);
+ assert!(said.lines().any(|l| l.starts_with("enter ") && l.len() > "enter ".len()), "{id}: {said}");
+ }
+ // And the line in the list itself fits it.
+ go_to(&mut app, "share:");
+ press(&mut app, KeyCode::Enter);
+ assert!(row_of(&app, "share-what").is_some_and(|r| r.label.chars().count() <= 44));
+ }
+
+ // Seen 2026-10-16 with a mouse: Share's level had no way out but Esc.
+ #[test]
+ fn a_click_on_the_title_leaves_a_level_as_esc_does() {
+ let mut app = app((150, 42));
+ app.mouse = true;
+ let _log = sharing_world(&mut app);
+ open(&mut app, View::Machines);
+ go_to(&mut app, "share:");
+ press(&mut app, KeyCode::Enter);
+ let (s, _) = screen(&mut app, 150, 42);
+ let (y, line) = s.lines().enumerate().find(|(_, l)| l.contains("Machines & devices › Share")).expect("the level's title");
+ let x = line[..line.find("Machines & devices").unwrap()].chars().count() as u16;
+ // The level's own name is not the way back.
+ click_at(&mut app, x + "Machines & devices › ".len() as u16 + 2, y as u16);
+ assert_eq!(app.devices.sub.as_deref(), Some("share:"));
+ click_at(&mut app, x + 3, y as u16);
+ assert_eq!(app.devices.sub, None);
+ assert_eq!(match &app.modal { Some(Modal::Picker { picker, .. }) => picker.current_id(), _ => None }.as_deref(), Some("share:"));
+ // At the top there is nothing to go back to: the title is only a title.
+ screen(&mut app, 150, 42);
+ click_at(&mut app, x + 3, y as u16);
+ assert!(matches!(app.modal, Some(Modal::Picker { kind: PickerKind::Devices(View::Machines), .. })));
+ }
+
#[test]
fn sharing_that_cannot_be_read_says_why_and_offers_a_retry() {
let mut app = app((150, 42));