A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: add back LSP snippets, upgrade codemirror-languageserver (#8052)
Myles Scolnick6120cd0e99f8
diff --git a/frontend/package.json b/frontend/package.jsonindex bf39852bdb..ba224bcc09 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -55,7 +55,7 @@"@lezer/markdown": "^1.6.2","@lezer/python": "^1.1.18","@marimo-team/codemirror-ai": "^0.3.5",- "@marimo-team/codemirror-languageserver": "^1.16.10",+ "@marimo-team/codemirror-languageserver": "^1.16.11","@marimo-team/codemirror-mcp": "^0.1.5","@marimo-team/codemirror-sql": "^0.2.4","@marimo-team/llm-info": "workspace:*",diff --git a/frontend/src/core/codemirror/language/languages/python.ts b/frontend/src/core/codemirror/language/languages/python.tsindex f800b4849c..ea57ec53be 100644--- a/frontend/src/core/codemirror/language/languages/python.ts+++ b/frontend/src/core/codemirror/language/languages/python.ts@@ -293,7 +293,7 @@ export class PythonLanguageAdapter implements LanguageAdapter<{}> {client: client as unknown as LanguageServerClient,languageId: "python",allowHTMLContent: true,- useSnippetOnCompletion: false,+ useSnippetOnCompletion: true,hoverConfig: hoverOptions,completionConfig: autocompleteOptions,// Default to falsediff --git a/frontend/src/core/codemirror/lsp/notebook-lsp.ts b/frontend/src/core/codemirror/lsp/notebook-lsp.tsindex 0ede423403..2401c17c80 100644--- a/frontend/src/core/codemirror/lsp/notebook-lsp.ts+++ b/frontend/src/core/codemirror/lsp/notebook-lsp.ts@@ -47,13 +47,6 @@ class Snapshotter {this.getNotebookCode = getNotebookCode;}- /**- * Map from the global document version to the cell id and version.- */- private versionToCellNumberAndVersion = new LRUCache<number, NotebookLens>(- 20,- );-private lastSnapshot: NotebookLens | null = null;public snapshot() {@@ -78,14 +71,6 @@ class Snapshotter {};}- public getSnapshot(version: number) {- const snapshot = this.versionToCellNumberAndVersion.get(version);- if (!snapshot) {- throw new Error(`No snapshot for version ${version}`);- }- return snapshot;- }-public getLatestSnapshot() {if (!this.lastSnapshot) {throw new Error("No snapshots");@@ -657,14 +642,49 @@ export class NotebookLanguageServerClient implements ILanguageServerClient {public async textDocumentCompletion(params: LSP.CompletionParams) {const { lens } = this.snapshotter.getLatestSnapshot();++ // Check if URI is valid+ if (!CellDocumentUri.is(params.textDocument.uri)) {+ Logger.error(+ "[lsp] Invalid cell document URI in completion request",+ params.textDocument.uri,+ );+ return null;+ }+const cellId = CellDocumentUri.parse(params.textDocument.uri);+ // Check if cellId is valid (not undefined string)+ if (!cellId || cellId === "undefined") {+ Logger.error("[lsp] Invalid cellId 'undefined' in completion request", {+ cellId,+ uri: params.textDocument.uri,+ availableCellIds: lens.cellIds,+ });+ // Return null to fail gracefully instead of sending wrong position+ return null;+ }++ // Warn if cellId not found in lens (might be okay if cell was just added)+ if (!lens.cellIds.includes(cellId)) {+ Logger.warn(+ "[lsp] CellId in completion request not found in current lens",+ {+ cellId,+ uri: params.textDocument.uri,+ availableCellIds: lens.cellIds,+ },+ );+ }++ const transformedPosition = lens.transformPosition(params.position, cellId);+return this.client.textDocumentCompletion({...params,textDocument: {uri: this.documentUri,},- position: lens.transformPosition(params.position, cellId),+ position: transformedPosition,});}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex d91de4e50d..2cc7dda5e7 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -143,8 +143,8 @@ importers:specifier: ^0.3.5version: 0.3.5(@codemirror/[email protected])(@codemirror/[email protected])'@marimo-team/codemirror-languageserver':- specifier: ^1.16.10- version: 1.16.10(@codemirror/[email protected])(@codemirror/[email protected])+ specifier: ^1.16.11+ version: 1.16.11(@codemirror/[email protected])(@codemirror/[email protected])'@marimo-team/codemirror-mcp':specifier: ^0.1.5version: 0.1.5(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@modelcontextprotocol/[email protected])@@ -1898,8 +1898,8 @@ packages:'@codemirror/state': ^6'@codemirror/view': ^6- '@marimo-team/[email protected]':- resolution: {integrity: sha512-Rh3ls/zjV0VJ1/V25KFWnXF56iON8L1vhY4YY0rfVSBn26VFJcz6CIreHV/7ZW4AnDy97w6RheJ8Y86V080z/w==}+ '@marimo-team/[email protected]':+ resolution: {integrity: sha512-ZDYg8td8BK7DIYlTJCDeDN21/0HlFWh+63opMXVZ9jHleg7C/yvY8B8pfPmX/UCizkf39OSGJkJPqyMPjL7swg==}peerDependencies:'@codemirror/state': ^6'@codemirror/view': ^6@@ -11769,7 +11769,7 @@ snapshots:'@codemirror/view': 6.39.9diff: 8.0.2dependencies:'@codemirror/autocomplete': 6.20.0'@codemirror/lint': 6.9.2