Shut down Orin: confirmed poweroff, sent once with the hello's boot_id
/ crosscheck (push) Successful in 1s
CI / Analyze & Test (push) Successful in 10s
CI / Debug APK (push) Successful in 16s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDwfd6Ki8UfG4hK6W5YpJz
This commit is contained in:
2026-10-13 18:35:49 +09:00
parent db5253587b
commit 88c572f447
2 changed files with 78 additions and 0 deletions
+57
View File
@@ -260,6 +260,12 @@ class LinkBar extends StatelessWidget {
icon: const Icon(Icons.checklist),
label: const Text('Captures'),
),
if (b.state == LinkState.up && b.hello?['boot_id'] is String)
TextButton.icon(
onPressed: () => shutDownOrin(context, b),
icon: const Icon(Icons.power_settings_new),
label: const Text('Shut down Orin'),
),
],
),
),
@@ -268,6 +274,57 @@ class LinkBar extends StatelessWidget {
}
}
/// Confirm, then send `poweroff` once (contracts BOUNDARY.md): it carries this
/// connection's boot id, so it can never take effect on a later boot.
Future<void> shutDownOrin(BuildContext context, Boundary b) async {
final host = b.hello?['host'] ?? 'the Orin';
final yes = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: Text('Shut down $host?'),
content: const Text(
'Recording stops and the session is closed cleanly. '
'The Orin stays off until its power button is pressed.',
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text('Cancel'),
),
FilledButton(
style: FilledButton.styleFrom(backgroundColor: Colors.red.shade700),
onPressed: () => Navigator.of(context).pop(true),
child: const Text('Shut down'),
),
],
),
);
if (yes != true || !context.mounted) return;
final messenger = ScaffoldMessenger.of(context);
final id = b.commandOnce('poweroff', {
'confirm': 'poweroff',
'boot_id': b.hello?['boot_id'],
});
if (id == null) {
messenger.showSnackBar(
const SnackBar(content: Text('Not sent: no link to the Orin')),
);
return;
}
final ack = await b.ackFor(id);
messenger.showSnackBar(
SnackBar(
content: Text(
ack == null
? 'No reply: the Orin may or may not be shutting down'
: ack.ok
? 'Orin: ${ack.detail}'
: 'Refused: ${ack.detail}',
),
),
);
}
class SignalList extends StatelessWidget {
const SignalList({super.key, required this.boundary});
final Boundary boundary;