feat(chat): per-chat permission modes for Claude, Codex and OpenCode

This commit is contained in:
2026-10-24 18:16:10 +01:00
parent ef575898f2
commit 6d430948a6
29 changed files with 1512 additions and 3 deletions
@@ -49,6 +49,40 @@ class ChatRepository {
});
}
/// The permission modes the session's harness offers, in the server's
/// order, and the session's stored mode (empty for the harness default).
Future<({List<JsonMap> modes, String current})> modes(
String sessionId,
) async {
final session = sessionId.trim();
if (session.isEmpty) {
throw ArgumentError('Select a chat session first.');
}
final reply = await gateway.call('chat_modes', {
'chat_query': {'session_id': session},
});
final value = reply['chat_modes'];
final current = reply['chat_mode'];
return (
modes: value is List ? _maps(value) : const <JsonMap>[],
current: current is Map ? '${current['mode'] ?? ''}'.trim() : '',
);
}
/// Switches the session's mode; the reply echoes the stored mode.
Future<String> selectMode(String sessionId, String mode) async {
final session = sessionId.trim();
if (session.isEmpty) {
throw ArgumentError('Select a chat session first.');
}
if (mode.trim().isEmpty) throw ArgumentError('Choose a mode first.');
final reply = await gateway.call('chat_mode', {
'chat_mode': {'session_id': session, 'mode': mode.trim()},
});
final echoed = reply['chat_mode'];
return echoed is Map ? '${echoed['mode'] ?? ''}'.trim() : mode.trim();
}
Future<List<JsonMap>> shells(String sessionId) async => _maps(
(await gateway.call('chat_shells', {
'chat_query': {'session_id': sessionId},