Skip to content

Commit d188e3b

Browse files
committed
fix(ui): suppress null suggestion + prevent mid-edit corruption
- Don't show value suggestions (like "null") at property key positions - Only apply comma fix + reformat when result is valid JSON - Prevents corruption when user is mid-edit inside a string value
1 parent 153d3b6 commit d188e3b

2 files changed

Lines changed: 21 additions & 18 deletions

File tree

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,20 +1193,25 @@ function buildCompletionSuggestions(
11931193
);
11941194
}
11951195

1196-
const valueSchemaCursor = resolveSchemaAtJsonPath(
1197-
context,
1198-
activeEvaluator,
1199-
location.path
1200-
);
1196+
// Only show value suggestions when NOT at a property key position.
1197+
// At key positions, property suggestions are sufficient — value suggestions
1198+
// like "null" are confusing noise.
1199+
if (!propertyKeyContext) {
1200+
const valueSchemaCursor = resolveSchemaAtJsonPath(
1201+
context,
1202+
activeEvaluator,
1203+
location.path
1204+
);
12011205

1202-
suggestions.push(
1203-
...buildSchemaValueSuggestions(
1204-
monaco,
1205-
valueRange,
1206-
valueSchemaCursor,
1207-
isStringValueContext
1208-
)
1209-
);
1206+
suggestions.push(
1207+
...buildSchemaValueSuggestions(
1208+
monaco,
1209+
valueRange,
1210+
valueSchemaCursor,
1211+
isStringValueContext
1212+
)
1213+
);
1214+
}
12101215

12111216
return dedupeSuggestions(suggestions);
12121217
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ export const JsonEditorView = ({
323323
const current = editor.getValue();
324324
const commaFixed = fixJsonCommas(current);
325325

326+
// Only apply changes if the result is valid JSON.
327+
// Don't touch broken JSON mid-edit — comma insertion can corrupt it.
326328
try {
327329
const formatted = JSON.stringify(JSON.parse(commaFixed), null, 2);
328330
if (formatted !== current) {
@@ -331,11 +333,7 @@ export const JsonEditorView = ({
331333
handleJsonChange(formatted);
332334
}
333335
} catch {
334-
if (commaFixed !== current) {
335-
isProgrammaticEdit = true;
336-
replaceAllContent(editor, commaFixed, 'auto-comma-fix');
337-
handleJsonChange(commaFixed);
338-
}
336+
// JSON is invalid — leave it alone, user is still editing
339337
}
340338
}, COMMA_FIX_DEBOUNCE_MS);
341339

0 commit comments

Comments
 (0)