Skip to content

Commit 53315ea

Browse files
committed
fix(ui): prevent double comma from auto-fix + programmatic edit conflict
1 parent c27d4e8 commit 53315ea

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎ui/src/core/page-components/agent-detail/modals/edit-control/json-editor-language.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,20 @@ function buildSchemaValueSnippet(
599599
return '{\n "name": "",\n "config": {}\n}';
600600
}
601601

602+
if (
603+
schemaTitle === 'ControlAction' ||
604+
isSchemaWithProperties(normalized, ['decision', 'steering_context'])
605+
) {
606+
return '{\n "decision": "deny"\n}';
607+
}
608+
609+
if (
610+
schemaTitle === 'ControlScope' ||
611+
isSchemaWithProperties(normalized, ['step_types', 'stages'])
612+
) {
613+
return '{\n "step_types": ["llm"],\n "stages": ["post"]\n}';
614+
}
615+
602616
if (
603617
schemaTitle === 'ConditionNode' ||
604618
isSchemaWithProperties(normalized, [

‎ui/src/core/page-components/agent-detail/modals/edit-control/json-editor-view.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export const JsonEditorView = ({
8181
const monacoRef = useRef<MonacoModule | null>(null);
8282
const editorRootRef = useRef<JsonEditorTestElement | null>(null);
8383
const cleanupLanguageRef = useRef<(() => void) | null>(null);
84+
const suppressCommaFixRef = useRef(false);
8485

8586
const modelUri = useMemo(
8687
() => `inmemory://agent-control/${testId}.json`,
@@ -310,7 +311,11 @@ export const JsonEditorView = ({
310311
const disposable = editor.onDidChangeModelContent(() => {
311312
if (timeout) window.clearTimeout(timeout);
312313
timeout = window.setTimeout(() => {
313-
// Don't auto-fix while the suggest widget is open — setValue kills it
314+
// Skip if suggest widget is open or a programmatic edit just ran
315+
if (suppressCommaFixRef.current) {
316+
suppressCommaFixRef.current = false;
317+
return;
318+
}
314319
const suggestWidget = editor
315320
.getDomNode()
316321
?.querySelector('.suggest-widget');
@@ -357,6 +362,7 @@ export const JsonEditorView = ({
357362
const startPos = model.getPositionAt(edit.offset);
358363
const endPos = model.getPositionAt(edit.offset + edit.length);
359364
queueMicrotask(() => {
365+
suppressCommaFixRef.current = true;
360366
editor.executeEdits(source, [
361367
{
362368
range: {

0 commit comments

Comments
 (0)