@marimo-team/islands 0.23.14-dev2 → 0.23.14-dev21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/{ConnectedDataExplorerComponent-Du3_nUzI.js → ConnectedDataExplorerComponent-DXBx_nQg.js} +4 -4
  2. package/dist/{chat-ui-CsPewo4h.js → chat-ui-CO8WuXGb.js} +3243 -3039
  3. package/dist/{code-visibility-CRYdBxcA.js → code-visibility-CPWEmIAX.js} +1115 -917
  4. package/dist/{formats-d6MhLuQ9.js → formats-WsOgyW_K.js} +1 -1
  5. package/dist/{glide-data-editor-DkzAInWG.js → glide-data-editor-qpmKyAPn.js} +2 -2
  6. package/dist/{html-to-image-DXwLcQ6l.js → html-to-image-DLSOS-bE.js} +2351 -2282
  7. package/dist/{input-CbEz_aj_.js → input-BSdZp5Ng.js} +1 -1
  8. package/dist/main.js +1139 -1071
  9. package/dist/{mermaid-CJW9vIyO.js → mermaid-D-HYBMEV.js} +2 -2
  10. package/dist/{process-output-C6_e1pT_.js → process-output-B9ysqk1y.js} +1 -1
  11. package/dist/{reveal-component-CbqUMhp8.js → reveal-component-BJwt0B2_.js} +16 -16
  12. package/dist/{spec-Bv-XlYiv.js → spec-CnTgI25l.js} +1 -1
  13. package/dist/{toDate-D-l5s8nn.js → toDate-D1Z7ZXWh.js} +1 -1
  14. package/dist/{useAsyncData-1Dhzjfwf.js → useAsyncData-BMc8itk2.js} +1 -1
  15. package/dist/{useDeepCompareMemoize-CDWT3BDz.js → useDeepCompareMemoize-ZwmDBRDY.js} +1 -1
  16. package/dist/{useLifecycle-AHlswLw-.js → useLifecycle-CxffarYV.js} +1 -1
  17. package/dist/{useTheme-BrYvK-_A.js → useTheme-yGsGEk82.js} +26 -24
  18. package/dist/{vega-component-Pk6lyc_a.js → vega-component-BFJTyykA.js} +5 -5
  19. package/package.json +2 -2
  20. package/src/components/chat/acp/agent-panel.tsx +35 -1
  21. package/src/components/chat/chat-panel.tsx +68 -29
  22. package/src/components/data-table/__tests__/column-explorer.test.tsx +25 -0
  23. package/src/components/data-table/__tests__/column-visibility-dropdown.test.tsx +60 -3
  24. package/src/components/data-table/column-explorer-panel/column-explorer.tsx +33 -12
  25. package/src/components/data-table/column-visibility-dropdown.tsx +15 -0
  26. package/src/components/editor/actions/useNotebookActions.tsx +2 -2
  27. package/src/components/editor/chrome/panels/snippets-panel.tsx +5 -2
  28. package/src/components/editor/chrome/wrapper/__tests__/useOpenAiAssistant.test.ts +36 -0
  29. package/src/components/editor/chrome/wrapper/footer-items/pyodide-status.tsx +6 -36
  30. package/src/components/editor/chrome/wrapper/useAiPanel.ts +3 -1
  31. package/src/components/editor/chrome/wrapper/useOpenAiAssistant.ts +88 -0
  32. package/src/components/editor/code/readonly-python-code.tsx +16 -2
  33. package/src/components/editor/errors/__tests__/auto-fix.test.ts +23 -0
  34. package/src/components/editor/errors/auto-fix.tsx +88 -34
  35. package/src/components/editor/errors/fix-mode.ts +1 -1
  36. package/src/components/editor/output/MarimoTracebackOutput.tsx +10 -1
  37. package/src/components/editor/output/__tests__/traceback.test.tsx +14 -6
  38. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +6 -2
  39. package/src/components/lifecycle/ProgressiveBoundary.tsx +42 -0
  40. package/src/components/lifecycle/RuntimeStatusBadge.tsx +59 -0
  41. package/src/components/lifecycle/__tests__/ProgressiveBoundary.test.tsx +147 -0
  42. package/src/components/lifecycle/__tests__/RuntimeStatusBadge.test.tsx +72 -0
  43. package/src/components/slides/slide-cell-view.tsx +7 -6
  44. package/src/core/ai/config.ts +2 -2
  45. package/src/core/ai/context/__tests__/registry.test.ts +133 -3
  46. package/src/core/ai/context/providers/__tests__/datasource.test.ts +3 -1
  47. package/src/core/ai/context/providers/__tests__/error.test.ts +200 -15
  48. package/src/core/ai/context/providers/datasource.ts +27 -2
  49. package/src/core/ai/context/providers/error.ts +226 -36
  50. package/src/core/ai/context/registry.ts +77 -43
  51. package/src/core/ai/state.ts +11 -0
  52. package/src/core/cells/__tests__/readonly-code-display.test.ts +46 -0
  53. package/src/core/cells/readonly-code-display.ts +35 -0
  54. package/src/core/codemirror/ai/resources.ts +15 -10
  55. package/src/core/codemirror/completion/__tests__/signature-hint.test.ts +94 -0
  56. package/src/core/codemirror/completion/completer.ts +12 -1
  57. package/src/core/codemirror/completion/signature-hint.ts +68 -0
  58. package/src/core/codemirror/language/languages/python.ts +10 -4
  59. package/src/core/codemirror/utils.ts +15 -0
  60. package/src/core/edit-app.tsx +8 -5
  61. package/src/core/errors/errors.ts +2 -1
  62. package/src/core/lifecycle/__tests__/render-policy.test.ts +247 -0
  63. package/src/core/lifecycle/render-policy.ts +125 -0
  64. package/src/core/mime.ts +11 -4
  65. package/src/core/run-app.tsx +27 -23
  66. package/src/core/runtime/__tests__/adapter.test.ts +160 -0
  67. package/src/core/runtime/adapter.ts +182 -0
  68. package/src/core/wasm/PyodideLoader.tsx +20 -62
  69. package/src/core/wasm/bridge.ts +9 -4
  70. package/src/core/wasm/state.ts +8 -19
  71. package/src/core/wasm/store.ts +1 -1
  72. package/src/hooks/__tests__/useDelayElapsed.test.tsx +55 -0
  73. package/src/hooks/useDelayElapsed.ts +27 -0
  74. package/src/core/ai/context/providers/__tests__/__snapshots__/error.test.ts.snap +0 -3
  75. package/src/core/wasm/__tests__/PyodideLoader.test.ts +0 -72
  76. package/src/core/wasm/__tests__/state.test.ts +0 -124
  77. /package/dist/{files → export_demos}/wasm-intro.py +0 -0
@@ -9,11 +9,19 @@ import { MultiMap } from "@/utils/multi-map";
9
9
  import type { TypedString } from "@/utils/typed";
10
10
 
11
11
  /**
12
- * Unique identifier for a context item in the format "type:id"
12
+ * Unique identifier for a context item in the format "type://id"
13
13
  * e.g., "variable://my_var", "data://users", "file://config.py"
14
14
  */
15
15
  export type ContextLocatorId = TypedString<"ContextLocatorId">;
16
16
 
17
+ function parseContextType(uri: ContextLocatorId): string | undefined {
18
+ const separator = uri.indexOf("://");
19
+ if (separator === -1) {
20
+ return undefined;
21
+ }
22
+ return uri.slice(0, separator);
23
+ }
24
+
17
25
  /**
18
26
  * Base interface for context items that can be mentioned in AI prompts
19
27
  */
@@ -142,40 +150,80 @@ export class AIContextRegistry<T extends AIContextItem> {
142
150
  );
143
151
  }
144
152
 
153
+ private findProviderForUri(
154
+ uri: ContextLocatorId,
155
+ ): AIContextProvider | undefined {
156
+ const type = parseContextType(uri);
157
+ if (!type) {
158
+ return undefined;
159
+ }
160
+ return [...this.providers].find(
161
+ (provider) =>
162
+ provider.contextType === type &&
163
+ provider.getItems().some((item) => item.uri === uri),
164
+ );
165
+ }
166
+
145
167
  /**
146
- * Get context information for mentioned items
168
+ * Resolve only the requested context items, querying each matching provider
147
169
  */
148
- getContextInfo(contextIds: ContextLocatorId[]): T[] {
149
- const contextInfo: T[] = [];
150
- const allItems = new Map<ContextLocatorId, T>(
151
- this.getAllItems().map((item) => [item.uri as ContextLocatorId, item]),
152
- );
170
+ resolveItems(contextIds: ContextLocatorId[]): T[] {
171
+ if (contextIds.length === 0) {
172
+ return [];
173
+ }
174
+
175
+ const idsByType = new MultiMap<string, ContextLocatorId>();
176
+ for (const contextId of contextIds) {
177
+ const type = parseContextType(contextId);
178
+ if (type) {
179
+ idsByType.add(type, contextId);
180
+ }
181
+ }
182
+
183
+ const itemsById = new Map<ContextLocatorId, T>();
184
+ for (const [type, ids] of idsByType.entries()) {
185
+ const providers = [...this.providers].filter(
186
+ (provider) => provider.contextType === type,
187
+ );
188
+ for (const provider of providers) {
189
+ const itemsByUri = new Map<ContextLocatorId, T>(
190
+ provider
191
+ .getItems()
192
+ .map((item) => [item.uri as ContextLocatorId, item as T]),
193
+ );
194
+ for (const id of ids) {
195
+ const item = itemsByUri.get(id);
196
+ if (item) {
197
+ itemsById.set(id, item);
198
+ }
199
+ }
200
+ }
201
+ }
153
202
 
203
+ // Preserve the order in which the ids were requested, so formatted context
204
+ // matches the order the user mentioned them in the prompt.
205
+ const results: T[] = [];
154
206
  for (const contextId of contextIds) {
155
- const item = allItems.get(contextId);
207
+ const item = itemsById.get(contextId);
156
208
  if (item) {
157
- contextInfo.push(item);
209
+ results.push(item);
158
210
  }
159
211
  }
212
+ return results;
213
+ }
160
214
 
161
- return contextInfo;
215
+ /**
216
+ * Get context information for mentioned items
217
+ */
218
+ getContextInfo(contextIds: ContextLocatorId[]): T[] {
219
+ return this.resolveItems(contextIds);
162
220
  }
163
221
 
164
222
  /**
165
223
  * Format context for AI prompt inclusion
166
224
  */
167
225
  formatContextForAI(contextIds: ContextLocatorId[]): string {
168
- const allItems = new Map<ContextLocatorId, T>(
169
- this.getAllItems().map((item) => [item.uri as ContextLocatorId, item]),
170
- );
171
-
172
- const contextInfo: T[] = [];
173
- for (const contextId of contextIds) {
174
- const item = allItems.get(contextId);
175
- if (item) {
176
- contextInfo.push(item);
177
- }
178
- }
226
+ const contextInfo = this.resolveItems(contextIds);
179
227
 
180
228
  if (contextInfo.length === 0) {
181
229
  return "";
@@ -183,7 +231,7 @@ export class AIContextRegistry<T extends AIContextItem> {
183
231
 
184
232
  return contextInfo
185
233
  .map((item) => {
186
- const provider = this.getProvider(item.type);
234
+ const provider = this.findProviderForUri(item.uri as ContextLocatorId);
187
235
  return provider?.formatContext(item) || "";
188
236
  })
189
237
  .join("\n\n");
@@ -195,36 +243,22 @@ export class AIContextRegistry<T extends AIContextItem> {
195
243
  async getAttachmentsForContext(
196
244
  contextIds: ContextLocatorId[],
197
245
  ): Promise<FileUIPart[]> {
198
- const allItems = new Map<ContextLocatorId, T>(
199
- this.getAllItems().map((item) => [item.uri as ContextLocatorId, item]),
200
- );
201
-
202
- const contextInfo: T[] = [];
203
- for (const contextId of contextIds) {
204
- const item = allItems.get(contextId);
205
- if (item) {
206
- contextInfo.push(item);
207
- }
208
- }
246
+ const contextInfo = this.resolveItems(contextIds);
209
247
 
210
248
  if (contextInfo.length === 0) {
211
249
  return [];
212
250
  }
213
251
 
214
- // Group items by provider type to batch attachment requests
215
- const itemsByProvider = new MultiMap<string, T>();
252
+ const itemsByProvider = new MultiMap<AIContextProvider, T>();
216
253
  for (const item of contextInfo) {
217
- const providerType = item.type;
218
- itemsByProvider.add(providerType, item);
254
+ const provider = this.findProviderForUri(item.uri as ContextLocatorId);
255
+ if (provider) {
256
+ itemsByProvider.add(provider, item);
257
+ }
219
258
  }
220
259
 
221
- // Collect attachments from all providers
222
260
  const attachmentPromises = [...itemsByProvider.entries()].map(
223
- async ([providerType, items]) => {
224
- const provider = this.getProvider(providerType);
225
- if (!provider) {
226
- return [];
227
- }
261
+ async ([provider, items]) => {
228
262
  try {
229
263
  return await provider.getAttachments(items);
230
264
  } catch (error) {
@@ -21,6 +21,17 @@ export interface AiCompletionCell {
21
21
 
22
22
  export const aiCompletionCellAtom = atom<AiCompletionCell | null>(null);
23
23
 
24
+ /**
25
+ * A prompt queued to be delivered to the AI assistant panel.
26
+ * The active panel consumes this on mount/when ready, then clears it.
27
+ */
28
+ export interface PendingAiPrompt {
29
+ prompt: string;
30
+ submit: boolean;
31
+ }
32
+
33
+ export const pendingAiPromptAtom = atom<PendingAiPrompt | null>(null);
34
+
24
35
  const INCLUDE_OTHER_CELLS_KEY = "marimo:ai:includeOtherCells";
25
36
  export const includeOtherCellsAtom = atomWithStorage<boolean>(
26
37
  INCLUDE_OTHER_CELLS_KEY,
@@ -0,0 +1,46 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import { describe, expect, it } from "vitest";
4
+ import { getReadonlyCodeDisplay } from "../readonly-code-display";
5
+
6
+ describe("getReadonlyCodeDisplay", () => {
7
+ it("unwraps SQL cells to their inner query and marks them as sql", () => {
8
+ const result = getReadonlyCodeDisplay(
9
+ 'my_table = mo.sql("""SELECT 1 AS id""")',
10
+ );
11
+ expect(result.language).toBe("sql");
12
+ expect(result.code).toBe("SELECT 1 AS id");
13
+ });
14
+
15
+ it("unwraps f-string SQL cells", () => {
16
+ const result = getReadonlyCodeDisplay(
17
+ 'my_table = mo.sql(f"""SELECT 1 AS id""")',
18
+ );
19
+ expect(result.language).toBe("sql");
20
+ expect(result.code).toBe("SELECT 1 AS id");
21
+ });
22
+
23
+ it("leaves plain Python cells untouched", () => {
24
+ const code = "x = 1 + 2\nprint(x)";
25
+ const result = getReadonlyCodeDisplay(code);
26
+ expect(result.language).toBe("python");
27
+ expect(result.code).toBe(code);
28
+ });
29
+
30
+ it("unwraps markdown cells to their inner content", () => {
31
+ const result = getReadonlyCodeDisplay('mo.md("""## Heading""")');
32
+ expect(result.language).toBe("markdown");
33
+ expect(result.code).toBe("## Heading");
34
+ });
35
+
36
+ it("treats empty or whitespace-only code as python", () => {
37
+ expect(getReadonlyCodeDisplay("")).toEqual({
38
+ code: "",
39
+ language: "python",
40
+ });
41
+ expect(getReadonlyCodeDisplay(" \n\t ")).toEqual({
42
+ code: " \n\t ",
43
+ language: "python",
44
+ });
45
+ });
46
+ });
@@ -0,0 +1,35 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import { MarkdownParser, SQLParser } from "@marimo-team/smart-cells";
4
+ import type { LanguageAdapterType } from "@/core/codemirror/language/types";
5
+
6
+ export interface ReadonlyCodeDisplay {
7
+ code: string;
8
+ language: LanguageAdapterType;
9
+ }
10
+
11
+ const markdownParser = new MarkdownParser();
12
+ const sqlParser = new SQLParser();
13
+
14
+ /**
15
+ * Unwrap SQL and markdown cells so read-only views show inner content with the
16
+ * correct syntax highlighting instead of the raw Python wrapper.
17
+ */
18
+ export function getReadonlyCodeDisplay(code: string): ReadonlyCodeDisplay {
19
+ const trimmed = code.trim();
20
+ if (!trimmed) {
21
+ return { code, language: "python" };
22
+ }
23
+
24
+ if (markdownParser.isSupported(trimmed)) {
25
+ return {
26
+ code: markdownParser.transformIn(trimmed).code,
27
+ language: "markdown",
28
+ };
29
+ }
30
+
31
+ if (sqlParser.isSupported(trimmed)) {
32
+ return { code: sqlParser.transformIn(trimmed).code, language: "sql" };
33
+ }
34
+ return { code, language: "python" };
35
+ }
@@ -11,6 +11,7 @@ import {
11
11
  resourceDecorations,
12
12
  resourceInputFilter,
13
13
  resourcesField,
14
+ resourceSync,
14
15
  resourceTheme,
15
16
  } from "@marimo-team/codemirror-mcp";
16
17
  import {
@@ -38,25 +39,28 @@ const NONE_RESOURCE_FORMAT_COMPLETION = {
38
39
  },
39
40
  };
40
41
 
42
+ function getRegistryResources(store: JotaiStore): Resource[] {
43
+ const registry = getAIContextRegistry(store);
44
+ const resources = registry.getAllItems();
45
+ if (resources.length === 0) {
46
+ return NONE_RESOURCE;
47
+ }
48
+ return resources;
49
+ }
50
+
41
51
  export function resourceExtension(opts: {
42
52
  language: Language;
43
53
  store: JotaiStore;
44
54
  onAddFiles?: (files: File[]) => void;
45
55
  }): Extension[] {
46
56
  const { language, store, onAddFiles } = opts;
57
+ const getResources = () => getRegistryResources(store);
47
58
 
48
59
  return [
49
60
  language.data.of({
50
61
  // Resource completion for static resources (variables, tables, etc.)
51
62
  autocomplete: resourceCompletion(
52
- async (): Promise<Resource[]> => {
53
- const registry = getAIContextRegistry(store);
54
- const resources = registry.getAllItems();
55
- if (resources.length === 0) {
56
- return NONE_RESOURCE;
57
- }
58
- return resources;
59
- },
63
+ async (): Promise<Resource[]> => getResources(),
60
64
  (resource) => {
61
65
  if (resource.type === NONE_RESOURCE_TYPE) {
62
66
  return NONE_RESOURCE_FORMAT_COMPLETION;
@@ -92,9 +96,10 @@ export function resourceExtension(opts: {
92
96
  : []),
93
97
  resourceDecorations,
94
98
  resourceInputFilter,
99
+ // Resolve @-mention chips for programmatic prefills.
100
+ resourceSync(getResources, { logger: Logger }),
95
101
  resourcesField.init(() => {
96
- const registry = getAIContextRegistry(store);
97
- const resources = registry.getAllItems();
102
+ const resources = getRegistryResources(store);
98
103
  return new Map(resources.map((resource) => [resource.uri, resource]));
99
104
  }),
100
105
  resourceTheme,
@@ -0,0 +1,94 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import { EditorState } from "@codemirror/state";
4
+ import { EditorView, type Tooltip } from "@codemirror/view";
5
+ import { describe, expect, it } from "vitest";
6
+ import {
7
+ asSignatureHint,
8
+ setSignatureHintEffect,
9
+ signatureHintField,
10
+ } from "../signature-hint";
11
+
12
+ function fakeTooltip(pos: number): Tooltip {
13
+ return {
14
+ pos,
15
+ above: true,
16
+ create: () => ({ dom: document.createElement("div") }),
17
+ };
18
+ }
19
+
20
+ function stateWithHint(doc: string, pos: number): EditorState {
21
+ const state = EditorState.create({
22
+ doc,
23
+ extensions: [signatureHintField],
24
+ });
25
+ return state.update({ effects: setSignatureHintEffect.of(fakeTooltip(pos)) })
26
+ .state;
27
+ }
28
+
29
+ describe("signatureHintField", () => {
30
+ it("starts empty", () => {
31
+ const state = EditorState.create({ extensions: [signatureHintField] });
32
+ expect(state.field(signatureHintField)).toBeNull();
33
+ });
34
+
35
+ it("shows a tooltip when the effect is dispatched", () => {
36
+ const state = stateWithHint("plt.plot(", 9);
37
+ expect(state.field(signatureHintField)?.pos).toBe(9);
38
+ });
39
+
40
+ it("clears the tooltip when the effect dispatches null", () => {
41
+ let state = stateWithHint("plt.plot(", 9);
42
+ state = state.update({
43
+ effects: setSignatureHintEffect.of(null),
44
+ }).state;
45
+ expect(state.field(signatureHintField)).toBeNull();
46
+ });
47
+
48
+ it("dismisses the tooltip on a selection-only change", () => {
49
+ let state = stateWithHint("plt.plot(x)", 9);
50
+ state = state.update({ selection: { anchor: 0 } }).state;
51
+ expect(state.field(signatureHintField)).toBeNull();
52
+ });
53
+
54
+ it("keeps and re-anchors the tooltip across edits", () => {
55
+ let state = stateWithHint("plt.plot(", 9);
56
+ // Insert before the tooltip position; it should shift to stay anchored.
57
+ state = state.update({ changes: { from: 0, insert: "xy" } }).state;
58
+ expect(state.field(signatureHintField)?.pos).toBe(11);
59
+ });
60
+ });
61
+
62
+ describe("asSignatureHint", () => {
63
+ it("nests the content so descendant styling applies", () => {
64
+ const content = document.createElement("span");
65
+ content.classList.add("mo-cm-tooltip", "docs-documentation");
66
+ const base: Tooltip = {
67
+ pos: 0,
68
+ create: () => ({ dom: content, resize: false }),
69
+ };
70
+
71
+ const view = new EditorView({ state: EditorState.create({}) });
72
+ const { dom } = asSignatureHint(base).create(view);
73
+
74
+ // Outer wrapper carries the tooltip sizing class...
75
+ expect(dom.classList.contains("mo-cm-tooltip")).toBe(true);
76
+ // ...and the documentation content is a descendant (not the same node),
77
+ // so `.cm-tooltip .docs-documentation` padding/font rules match.
78
+ expect(dom).not.toBe(content);
79
+ expect(dom.querySelector(".docs-documentation")).toBe(content);
80
+
81
+ view.destroy();
82
+ });
83
+
84
+ it("preserves other tooltip fields", () => {
85
+ const base: Tooltip = {
86
+ pos: 5,
87
+ above: true,
88
+ create: () => ({ dom: document.createElement("span"), resize: false }),
89
+ };
90
+ const wrapped = asSignatureHint(base);
91
+ expect(wrapped.pos).toBe(5);
92
+ expect(wrapped.above).toBe(true);
93
+ });
94
+ });
@@ -9,6 +9,7 @@ import { documentationAtom } from "@/core/documentation/state";
9
9
  import { store } from "@/core/state/jotai";
10
10
  import { Logger } from "../../../utils/Logger";
11
11
  import { AUTOCOMPLETER, Autocompleter } from "./Autocompleter";
12
+ import { asSignatureHint, setSignatureHintEffect } from "./signature-hint";
12
13
 
13
14
  /**
14
15
  * Completion source for Python, using Jedi.
@@ -36,10 +37,12 @@ export const pythonCompletionSource: CompletionSource = async (
36
37
  cellId: cellId,
37
38
  });
38
39
  if (!result) {
40
+ context.view?.dispatch({ effects: setSignatureHintEffect.of(null) });
39
41
  return null;
40
42
  }
41
43
 
42
- // If it is a tooltip, show it as a Tooltip instead of a completion
44
+ // If it is a tooltip (e.g. a signature after `(` or `,`), show it as a
45
+ // Tooltip instead of a completion.
43
46
  const tooltip = Autocompleter.asHoverTooltip({
44
47
  position: context.pos,
45
48
  message: result,
@@ -50,6 +53,14 @@ export const pythonCompletionSource: CompletionSource = async (
50
53
  documentation: tooltip.html ?? null,
51
54
  });
52
55
  }
56
+ // Surface the signature as a floating hint near the cursor (the LSP path has
57
+ // its own signature help), and clear any stale hint when we instead have a
58
+ // real completion list.
59
+ context.view?.dispatch({
60
+ effects: setSignatureHintEffect.of(
61
+ tooltip ? asSignatureHint(tooltip) : null,
62
+ ),
63
+ });
53
64
  if (tooltip) {
54
65
  return null;
55
66
  }
@@ -0,0 +1,68 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+ import { StateEffect, StateField } from "@codemirror/state";
3
+ import { showTooltip, type Tooltip } from "@codemirror/view";
4
+
5
+ /**
6
+ * Effect to set (or clear, with `null`) the floating signature hint.
7
+ */
8
+ export const setSignatureHintEffect = StateEffect.define<Tooltip | null>();
9
+
10
+ /**
11
+ * Wrap a tooltip so it renders like the completion popup's info box.
12
+ *
13
+ * CodeMirror adds `cm-tooltip` directly to the DOM node returned by `create`,
14
+ * so the documentation content ends up on the same element as `cm-tooltip`.
15
+ * Our styling for padding/font (`.cm-tooltip .docs-documentation`) is a
16
+ * descendant selector, so we nest the content one level deeper to make it
17
+ * apply — mirroring how CodeMirror nests completion info inside its own
18
+ * wrapper. The outer `mo-cm-tooltip` class picks up the shared tooltip sizing.
19
+ */
20
+ export function asSignatureHint(tooltip: Tooltip): Tooltip {
21
+ return {
22
+ ...tooltip,
23
+ create: (view) => {
24
+ const { dom: content, ...rest } = tooltip.create(view);
25
+ const dom = document.createElement("div");
26
+ dom.classList.add("mo-cm-tooltip");
27
+ dom.append(content);
28
+ return { ...rest, dom };
29
+ },
30
+ };
31
+ }
32
+
33
+ /**
34
+ * Holds the floating "signature hint" shown after typing `(` or `,` inside a
35
+ * call on the non-LSP (Jedi) completion path.
36
+ *
37
+ * The LSP path has its own signature help; this fills the gap for users
38
+ * without a language server. The completion source (`pythonCompletionSource`)
39
+ * drives it: it dispatches `setSignatureHintEffect` with the tooltip when the
40
+ * backend returns a signature and with `null` otherwise. The hint is also
41
+ * cleared when the cursor moves via a selection-only change (e.g. clicking
42
+ * away or arrowing out of the call), and kept anchored across edits so it
43
+ * doesn't flicker while a fresh result is in flight.
44
+ */
45
+ export const signatureHintField = StateField.define<Tooltip | null>({
46
+ create: () => null,
47
+ update(tooltip, tr) {
48
+ for (const effect of tr.effects) {
49
+ if (effect.is(setSignatureHintEffect)) {
50
+ return effect.value;
51
+ }
52
+ }
53
+ if (!tooltip) {
54
+ return null;
55
+ }
56
+ // Cursor moved without editing (click / arrow key): dismiss the hint.
57
+ if (tr.selection && !tr.docChanged) {
58
+ return null;
59
+ }
60
+ // Keep the hint anchored across edits; the completion source refreshes or
61
+ // clears it as new results arrive.
62
+ if (tr.docChanged) {
63
+ return { ...tooltip, pos: tr.changes.mapPos(tooltip.pos) };
64
+ }
65
+ return tooltip;
66
+ },
67
+ provide: (field) => showTooltip.from(field),
68
+ });
@@ -31,6 +31,7 @@ import { Logger } from "@/utils/Logger";
31
31
  import { once } from "@/utils/once";
32
32
  import { cellActionsState } from "../../cells/state";
33
33
  import { pythonCompletionSource } from "../../completion/completer";
34
+ import { signatureHintField } from "../../completion/signature-hint";
34
35
  import type { PlaceholderType } from "../../config/types";
35
36
  import { FederatedLanguageServerClient } from "../../lsp/federated-lsp";
36
37
  import { createLspMarkdownRenderer } from "../../lsp/markdown-renderer";
@@ -376,10 +377,15 @@ export class PythonLanguageAdapter implements LanguageAdapter<{}> {
376
377
  ];
377
378
  }
378
379
 
379
- return autocompletion({
380
- ...autocompleteOptions,
381
- override: [pythonCompletionSource],
382
- });
380
+ return [
381
+ autocompletion({
382
+ ...autocompleteOptions,
383
+ override: [pythonCompletionSource],
384
+ }),
385
+ // The Jedi path has no built-in signature help; show a floating hint
386
+ // fed by `pythonCompletionSource` (the LSP path handles this itself).
387
+ signatureHintField,
388
+ ];
383
389
  };
384
390
 
385
391
  return [
@@ -2,6 +2,7 @@
2
2
  import type { EditorState, Transaction } from "@codemirror/state";
3
3
  import type { EditorView, ViewUpdate } from "@codemirror/view";
4
4
  import { getCM } from "@replit/codemirror-vim";
5
+ import type { ReactCodeMirrorRef } from "@uiw/react-codemirror";
5
6
 
6
7
  export function isAtStartOfEditor(ev: { state: EditorState }) {
7
8
  const main = ev.state.selection.main;
@@ -37,6 +38,20 @@ export function moveToEndOfEditor(ev: EditorView | undefined) {
37
38
  });
38
39
  }
39
40
 
41
+ /** We delay the focus and move to end of the editor until React has rendered the prefilled value. */
42
+ export function focusInputAndMoveToEnd(
43
+ ref: React.RefObject<ReactCodeMirrorRef | null>,
44
+ ) {
45
+ requestAnimationFrame(() => {
46
+ const view = ref.current?.view;
47
+ if (!view) {
48
+ return;
49
+ }
50
+ view.focus();
51
+ moveToEndOfEditor(view);
52
+ });
53
+ }
54
+
40
55
  export function isInVimMode(ev: EditorView): boolean {
41
56
  return getCM(ev)?.state.vim != null;
42
57
  }
@@ -13,6 +13,7 @@ import { AppHeader } from "@/components/editor/header/app-header";
13
13
  import { FilenameForm } from "@/components/editor/header/filename-form";
14
14
  import { MultiCellActionToolbar } from "@/components/editor/navigation/multi-cell-action-toolbar";
15
15
  import { ViewerBanner } from "@/components/editor/viewer-banner";
16
+ import { ProgressiveBoundary } from "@/components/lifecycle/ProgressiveBoundary";
16
17
  import { cn } from "@/utils/cn";
17
18
  import { Paths } from "@/utils/paths";
18
19
  import { AppContainer } from "../components/editor/app-container";
@@ -64,7 +65,6 @@ export const EditApp: React.FC<AppProps> = ({
64
65
  useCellActions();
65
66
  const viewState = useAtomValue(viewStateAtom);
66
67
  const numColumns = useAtomValue(numColumnsAtom);
67
- const hasCells = useAtomValue(hasCellsAtom);
68
68
  const filename = useFilename();
69
69
  const setLastSavedNotebook = useSetAtom(lastSavedNotebookAtom);
70
70
  const { sendComponentValues, sendInterrupt } = useRequestClient();
@@ -181,13 +181,16 @@ export const EditApp: React.FC<AppProps> = ({
181
181
 
182
182
  <ViewerBanner />
183
183
 
184
- {/* Don't render until we have a single cell */}
185
- {hasCells && (
184
+ {/* Don't render until we have a single cell. NotStartedConnectionAlert
185
+ still covers the "no remote runtime started" prompt. */}
186
+ <ProgressiveBoundary
187
+ requires={hasCellsAtom}
188
+ fallback={<NotStartedConnectionAlert />}
189
+ >
186
190
  <CellsRenderer appConfig={appConfig} mode={viewState.mode}>
187
191
  {editableCellsArray}
188
192
  </CellsRenderer>
189
- )}
190
- {!hasCells && <NotStartedConnectionAlert />}
193
+ </ProgressiveBoundary>
191
194
  </AppContainer>
192
195
  <MultiCellActionToolbar />
193
196
  {!hideControls && (
@@ -6,6 +6,7 @@ import type { AiCompletionCell } from "../ai/state";
6
6
  import type { CellId } from "../cells/ids";
7
7
  import type { MarimoError } from "../kernel/messages";
8
8
  import { wrapInFunction } from "./utils";
9
+ import { store } from "../state/jotai";
9
10
 
10
11
  interface AIFix {
11
12
  setAiCompletionCell: (opts: AiCompletionCell) => void;
@@ -84,7 +85,7 @@ export function getAutoFixes(
84
85
  description: "Fix the SQL statement",
85
86
  fixType: "ai",
86
87
  onFix: async (ctx) => {
87
- const datasourceContext = getDatasourceContext(ctx.cellId);
88
+ const datasourceContext = getDatasourceContext(ctx.cellId, store);
88
89
  let initialPrompt = `Fix the SQL statement: ${error.msg}.`;
89
90
  if (datasourceContext) {
90
91
  initialPrompt += `\nDatabase schema: ${datasourceContext}`;