add per-agent permission-mode badge to the cockpit roster

Each roster row shows a D/A/P mode badge reflecting the session's live
permission mode. Click cycles the safe trio default -> acceptEdits ->
plan and sends a set_permission_mode control_request to that session
(mirrors interrupt(); fire-and-forget). bypassPermissions is a footgun,
so it is reachable only on Shift-click and behind an inline confirm. A
clide.agent.set-permission-mode command gives the CLI parity.

T-181.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-05-30 23:25:07 +02:00
co-authored by Claude
parent 4220d97a49
commit 2888efbe5f
8 changed files with 451 additions and 20 deletions
@@ -592,6 +592,22 @@ class StreamJsonSession {
}));
}
/// Set the session's permission mode (T-181, D-77). Sends a
/// `set_permission_mode` control_request; fire-and-forget, mirroring
/// [interrupt]. [mode] must be one of the claude-recognised strings:
/// `default`, `acceptEdits`, `plan`, `bypassPermissions`.
///
/// The safe trio (default → acceptEdits → plan → default) is cycled by the
/// cockpit badge's plain click; bypassPermissions is reachable only via a
/// confirmed shift-click (T-181).
void setPermissionMode(String mode) {
_proc.writeLine(jsonEncode({
'type': 'control_request',
'request_id': 'set-perm-${_localSeq++}',
'request': {'subtype': 'set_permission_mode', 'mode': mode},
}));
}
Future<void> dispose() async {
await _sub?.cancel();
await _proc.kill();