Skip to content

Commit bbcc1b2

Browse files
committed
fix(serve): address post-approval suggestions — editMode stuck, type cast, approvalMode deny-set
- Clear editMode when setting disappears from rows during SSE reload - Use isRecord guard instead of unsafe type cast in normalizeSettingsChanged - Add SECURITY_SENSITIVE_SETTINGS deny-set to block tools.approvalMode from generic write path (must go through trust-gated session route) - Remove tools.approvalMode from SUB_DIALOG_KEYS (no longer in list)
1 parent 13792d6 commit bbcc1b2

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

packages/cli/src/serve/routes/workspaceSettings.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ interface SettingsResponse {
6262
settings: SettingDescriptor[];
6363
}
6464

65+
const SECURITY_SENSITIVE_SETTINGS = new Set(['tools.approvalMode']);
66+
6567
function getAllowedKeys(): Set<string> {
6668
return new Set(
67-
getDialogSettingKeys().filter((k) => !TUI_ONLY_SETTINGS.has(k)),
69+
getDialogSettingKeys().filter(
70+
(k) => !TUI_ONLY_SETTINGS.has(k) && !SECURITY_SENSITIVE_SETTINGS.has(k),
71+
),
6872
);
6973
}
7074

packages/sdk-typescript/src/daemon/ui/normalizer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ function normalizeSettingsChanged(
989989
type: 'workspace.settings.changed',
990990
key,
991991
scope: scope ?? 'workspace',
992-
value: (event.data as Record<string, unknown>)?.['value'],
992+
value: isRecord(event.data) ? event.data['value'] : undefined,
993993
},
994994
];
995995
}

packages/web-shell/client/components/dialogs/SettingsDialog.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ interface SettingsDialogProps {
1212
onSubDialog: (settingKey: string) => void;
1313
}
1414

15-
const SUB_DIALOG_KEYS = new Set([
16-
'ui.theme',
17-
'fastModel',
18-
'tools.approvalMode',
19-
]);
15+
const SUB_DIALOG_KEYS = new Set(['ui.theme', 'fastModel']);
2016

2117
type Scope = 'user' | 'workspace';
2218

@@ -253,7 +249,10 @@ export function SettingsDialog({ onClose, onSubDialog }: SettingsDialogProps) {
253249
(r) => r.type === 'setting' && r.setting?.key === editMode.key,
254250
);
255251
const setting = row?.setting;
256-
if (!setting) return;
252+
if (!setting) {
253+
setEditMode(null);
254+
return;
255+
}
257256
let parsed: unknown = editMode.draft;
258257
if (setting.type === 'number') {
259258
const trimmed = editMode.draft.trim();

0 commit comments

Comments
 (0)