reflect permission-mode changes in the status line

setPermissionMode only wrote the control_request; the mode was never
folded back into the session status, so the badge and Ctrl/Cmd+M looked
dead. Optimistically merge + emit the new mode immediately; the next
system/init still reconciles.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-06-06 09:49:08 +02:00
co-authored by Claude
parent 0e85f7f5e7
commit 13187d3994
5 changed files with 41 additions and 0 deletions
@@ -583,6 +583,18 @@ void main() {
expect(id1, isNot(equals(id2)));
});
test('setPermissionMode emits the new mode on statusStream (T-250)', () async {
// The control_request itself emits no status event; without an optimistic
// update the badge stayed stale. Each call must surface the new mode.
session.setPermissionMode('plan');
await Future<void>.delayed(Duration.zero);
expect(statuses.last.permissionMode, 'plan');
session.setPermissionMode('acceptEdits');
await Future<void>.delayed(Duration.zero);
expect(statuses.last.permissionMode, 'acceptEdits');
});
test('busy goes true on send and false on a result event', () async {
final busy = <bool>[];
session.busyStream.listen(busy.add);