Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: disable lsp for readonly editors (#15983)

boojackb455648fd93a
diff --git a/frontend/src/components/MonacoEditor/MonacoTextModelEditor.vue b/frontend/src/components/MonacoEditor/MonacoTextModelEditor.vue
index 125e313f37..bb90f6882e 100644
--- a/frontend/src/components/MonacoEditor/MonacoTextModelEditor.vue
+++ b/frontend/src/components/MonacoEditor/MonacoTextModelEditor.vue
@@ -204,7 +204,12 @@ onMounted(async () => {
useAdvices(monaco, editor, toRef(props, "advices"));
useLineHighlights(monaco, editor, toRef(props, "lineHighlights"));
useAutoHeight(monaco, editor, containerRef, toRef(props, "autoHeight"));
- useAutoComplete(monaco, editor, toRef(props, "autoCompleteContext"));
+ useAutoComplete(
+ monaco,
+ editor,
+ toRef(props, "autoCompleteContext"),
+ toRef(props, "readonly")
+ );
useOverrideSuggestIcons(monaco, editor);
ready.value = true;
diff --git a/frontend/src/components/MonacoEditor/composables/useAutoComplete.ts b/frontend/src/components/MonacoEditor/composables/useAutoComplete.ts
index 5b28cff2c0..2856ba733a 100644
--- a/frontend/src/components/MonacoEditor/composables/useAutoComplete.ts
+++ b/frontend/src/components/MonacoEditor/composables/useAutoComplete.ts
@@ -27,11 +27,9 @@ type SetMetadataParams = {
export const useAutoComplete = async (
monaco: MonacoModule,
editor: monaco.editor.IStandaloneCodeEditor,
- context: Ref<AutoCompleteContext | undefined>
+ context: Ref<AutoCompleteContext | undefined>,
+ readonly: Ref<boolean | undefined>
) => {
- const { executeCommand, useLSPClient } = await import("../lsp-client");
-
- const client = useLSPClient();
const params = computed(() => {
const p: SetMetadataParams = {
instanceId: "",
@@ -54,17 +52,31 @@ export const useAutoComplete = async (
}
return p;
});
+
watch(
- () => JSON.stringify(params.value),
+ [() => JSON.stringify(params.value), () => readonly.value],
async () => {
- const result = await executeCommand(client, "setMetadata", [
- params.value,
- ]);
- console.debug(
- `setMetadata(${JSON.stringify(params.value)}): ${JSON.stringify(
- result
- )}`
- );
+ if (readonly.value) {
+ return;
+ }
+
+ // Initialize LSP client if not already initialized.
+ try {
+ const { executeCommand, initializeLSPClient } = await import(
+ "../lsp-client"
+ );
+ const client = await initializeLSPClient();
+ const result = await executeCommand(client, "setMetadata", [
+ params.value,
+ ]);
+ console.debug(
+ `[MonacoEditor] setMetadata(${JSON.stringify(params.value)}): ${JSON.stringify(
+ result
+ )}`
+ );
+ } catch (err) {
+ console.error("[MonacoEditor] Failed to initialize LSP client", err);
+ }
},
{ immediate: true }
);
diff --git a/frontend/src/components/MonacoEditor/editor.ts b/frontend/src/components/MonacoEditor/editor.ts
index 153e07e0a9..16adcd6f2b 100644
--- a/frontend/src/components/MonacoEditor/editor.ts
+++ b/frontend/src/components/MonacoEditor/editor.ts
@@ -27,14 +27,6 @@ export const createMonacoEditor = async (config: {
}): Promise<monaco.editor.IStandaloneCodeEditor> => {
await initialize();
- // Initialize LSP client.
- try {
- const { initializeLSPClient } = await import("./lsp-client");
- await initializeLSPClient();
- } catch (err) {
- console.error("[MonacoEditor] Failed to initialize LSP client", err);
- }
-
// Create monaco editor.
const editor = monaco.editor.create(config.container, {
...({