Skip to content

Commit 5a2ac6d

Browse files
committed
fix(ui): only auto-trigger suggestions on navigation, not typing
1 parent da75572 commit 5a2ac6d

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,19 @@ export const JsonEditorView = ({
425425
const editor = editorRef.current;
426426
if (!editor || !mounted) return;
427427

428+
// Track content changes to distinguish typing (content+cursor change)
429+
// from navigation (cursor change only). Don't auto-trigger after typing.
430+
let contentJustChanged = false;
431+
const contentDisposable = editor.onDidChangeModelContent(() => {
432+
contentJustChanged = true;
433+
});
434+
428435
let timeout: number | null = null;
429-
const disposable = editor.onDidChangeCursorPosition((e) => {
430-
// Skip cursor changes from typing — quickSuggestions handles those.
431-
// Only auto-trigger on navigation (click, arrow keys, etc.).
432-
// CursorChangeReason: NotSet=0, ContentFlush=1, RecoverFromMarkers=2, Explicit=3, Paste=4, Undo=5, Redo=6
433-
if (e.reason !== 3 /* Explicit */) return;
436+
const disposable = editor.onDidChangeCursorPosition(() => {
437+
if (contentJustChanged) {
438+
contentJustChanged = false;
439+
return;
440+
}
434441

435442
if (timeout) window.clearTimeout(timeout);
436443
timeout = window.setTimeout(() => {
@@ -466,6 +473,7 @@ export const JsonEditorView = ({
466473
return () => {
467474
if (timeout) window.clearTimeout(timeout);
468475
disposable.dispose();
476+
contentDisposable.dispose();
469477
};
470478
}, [mounted, autocompleteContext]);
471479

0 commit comments

Comments
 (0)