@marimo-team/frontend 0.23.14-dev3 → 0.23.14-dev6

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 (74) hide show
  1. package/dist/assets/{CellStatus-B43aF1fe.js → CellStatus-D3EKlB21.js} +1 -1
  2. package/dist/assets/{JsonOutput-DTeVFctC.js → JsonOutput-BfDKMXVF.js} +1 -1
  3. package/dist/assets/{MarimoErrorOutput-DcImOp4r.js → MarimoErrorOutput-C9ti-mu4.js} +1 -1
  4. package/dist/assets/{RenderHTML-BLBwT24G.js → RenderHTML-FBKVQ49x.js} +1 -1
  5. package/dist/assets/{RunButton-CYnmbljZ.js → RunButton-BRhOWu7V.js} +1 -1
  6. package/dist/assets/{add-cell-with-ai-C5iuH1Jb.js → add-cell-with-ai-nJKSBAPb.js} +1 -1
  7. package/dist/assets/{add-connection-dialog-CXW90r_2.js → add-connection-dialog-CMK4qx7X.js} +1 -1
  8. package/dist/assets/{agent-panel-4NHH_Sae.js → agent-panel-B1Sy_w9H.js} +1 -1
  9. package/dist/assets/{ai-model-dropdown-DVeTiOGS.js → ai-model-dropdown-Brz68_s8.js} +1 -1
  10. package/dist/assets/{app-config-button-DQSFx7vo.js → app-config-button-DP_s193w.js} +1 -1
  11. package/dist/assets/{cell-editor-BZ6ZrToN.js → cell-editor-Dc80BOci.js} +1 -1
  12. package/dist/assets/{cell-link-LArpBcY-.js → cell-link-CaBSvNu3.js} +1 -1
  13. package/dist/assets/{cells-DQ5n6Zef.js → cells-DZEvA3zb.js} +57 -57
  14. package/dist/assets/{chat-display-DegYbxcN.js → chat-display-C2X2R6le.js} +1 -1
  15. package/dist/assets/{chat-panel-CvC2TxDx.js → chat-panel-Mb3VYb6T.js} +1 -1
  16. package/dist/assets/{chat-ui-Ddt6mEIC.js → chat-ui-D5NiPbFP.js} +1 -1
  17. package/dist/assets/{column-preview-VcOeHtkt.js → column-preview-CtFTSUj4.js} +1 -1
  18. package/dist/assets/{command-palette-CGHj_h4K.js → command-palette-RBwjW3re.js} +1 -1
  19. package/dist/assets/{common-XGVukwY0.js → common-DbLcwSDP.js} +1 -1
  20. package/dist/assets/{components-C2HqGrL_.js → components-o-HZCs8Y.js} +1 -1
  21. package/dist/assets/{datasource-BT-L2LDD.js → datasource-C4XU40Hp.js} +1 -1
  22. package/dist/assets/{dependency-graph-panel-DGDP7vz5.js → dependency-graph-panel-BMAOsCZ-.js} +1 -1
  23. package/dist/assets/{documentation-panel-ODnRqsmJ.js → documentation-panel-CtvI61ug.js} +1 -1
  24. package/dist/assets/{download-rKGlekSQ.js → download-DlMo0yoI.js} +1 -1
  25. package/dist/assets/{edit-page-CQkWgVdg.js → edit-page-neW4rs_q.js} +4 -4
  26. package/dist/assets/{error-panel-BjCDBUEW.js → error-panel-Czh-8YVF.js} +1 -1
  27. package/dist/assets/{file-explorer-panel-UL0ND-sz.js → file-explorer-panel-BBIZ5Upt.js} +1 -1
  28. package/dist/assets/{file-icons-DBMviz_K.js → file-icons-C_azZLwC.js} +1 -1
  29. package/dist/assets/{file-name-input-C1PsBoII.js → file-name-input-BxTNV58f.js} +1 -1
  30. package/dist/assets/{floating-outline-CPTvLHMl.js → floating-outline-DWk90U4M.js} +1 -1
  31. package/dist/assets/{focus-Dol5ybck.js → focus-DHgSYMb6.js} +1 -1
  32. package/dist/assets/{form-B9I9mpZy.js → form-ClQGrP6i.js} +1 -1
  33. package/dist/assets/{home-page-MuT1rHVU.js → home-page-CJTghues.js} +1 -1
  34. package/dist/assets/{hooks-C7muIIiV.js → hooks-B_YOAMxc.js} +1 -1
  35. package/dist/assets/{html-to-image-CmK-WSPG.js → html-to-image-DY_stEj0.js} +1 -1
  36. package/dist/assets/{index-Cns3Ex2y.js → index-a3SXFqw7.js} +3 -3
  37. package/dist/assets/{kiosk-mode-CAa5-suK.js → kiosk-mode-BqSHurAE.js} +1 -1
  38. package/dist/assets/{layout-CRzOtEaD.js → layout-CPdBwJdJ.js} +3 -3
  39. package/dist/assets/{logs-panel-DJyCkydj.js → logs-panel-Z4miZLI5.js} +1 -1
  40. package/dist/assets/{markdown-renderer-f3mfGw8u.js → markdown-renderer-duAFwqLF.js} +1 -1
  41. package/dist/assets/{name-cell-input-DteS1CD8.js → name-cell-input-DulIaCIY.js} +1 -1
  42. package/dist/assets/{outline-panel-FvxWzBOw.js → outline-panel-BHR36Fu3.js} +1 -1
  43. package/dist/assets/{packages-panel-Cua7qm1T.js → packages-panel-wvuNuaJ7.js} +1 -1
  44. package/dist/assets/{panels-B1LHhh4P.js → panels-CUvqvTcK.js} +1 -1
  45. package/dist/assets/{process-output-Ll90qx0s.js → process-output-CNAM-uaM.js} +1 -1
  46. package/dist/assets/{radio-group-D7RG9Px_.js → radio-group-C03SYtE4.js} +1 -1
  47. package/dist/assets/{readonly-python-code-DHJTIc4H.js → readonly-python-code-Buc6Cpxg.js} +1 -1
  48. package/dist/assets/{reveal-component-DkKSevqs.js → reveal-component-DKV09ndk.js} +1 -1
  49. package/dist/assets/{run-page-CGrQ4rZG.js → run-page-x5Gp_vjo.js} +1 -1
  50. package/dist/assets/{scratchpad-panel-Dfbdc2Bu.js → scratchpad-panel-DaT9P31r.js} +1 -1
  51. package/dist/assets/{session-panel-Dywriyca.js → session-panel-am6zkzg4.js} +1 -1
  52. package/dist/assets/snippets-panel-Br8drXb6.js +1 -0
  53. package/dist/assets/{state-Cvt1qFuu.js → state-CV4SpBvo.js} +1 -1
  54. package/dist/assets/{state-VxOqftwq.js → state-CvarlPeY.js} +1 -1
  55. package/dist/assets/{textarea-DD5BwHTh.js → textarea-BaOwN3Me.js} +1 -1
  56. package/dist/assets/{tracing-Ckq9673r.js → tracing-DAzqwOSy.js} +1 -1
  57. package/dist/assets/{tracing-panel-7UPP4OM8.js → tracing-panel-DDISd3Mx.js} +2 -2
  58. package/dist/assets/{tree-actions-CjikjOBA.js → tree-actions-CNIHKi7f.js} +1 -1
  59. package/dist/assets/{useCellActionButton-TRa0-mam.js → useCellActionButton-CSYE6DW0.js} +1 -1
  60. package/dist/assets/{useDeleteCell-CICC5IPM.js → useDeleteCell-DeJTCYjE.js} +1 -1
  61. package/dist/assets/{useDependencyPanelTab-DUmpfdwT.js → useDependencyPanelTab-HcfMBFHT.js} +1 -1
  62. package/dist/assets/{useNotebookActions-CFivvltO.js → useNotebookActions-C1Ba1Deq.js} +1 -1
  63. package/dist/assets/{useRunCells-bcK6jTD2.js → useRunCells-CK2uMzyx.js} +1 -1
  64. package/dist/assets/{useSplitCell-CqcM6MQ1.js → useSplitCell-DIWUZzri.js} +1 -1
  65. package/dist/index.html +22 -22
  66. package/package.json +1 -1
  67. package/src/components/editor/chrome/panels/__tests__/snippet-display.test.ts +22 -0
  68. package/src/components/editor/chrome/panels/snippet-display.ts +27 -0
  69. package/src/components/editor/chrome/panels/snippets-panel.tsx +5 -2
  70. package/src/core/codemirror/completion/__tests__/signature-hint.test.ts +94 -0
  71. package/src/core/codemirror/completion/completer.ts +12 -1
  72. package/src/core/codemirror/completion/signature-hint.ts +68 -0
  73. package/src/core/codemirror/language/languages/python.ts +10 -4
  74. package/dist/assets/snippets-panel-Ee_wUGYF.js +0 -1
package/dist/index.html CHANGED
@@ -66,7 +66,7 @@
66
66
  <marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
67
67
  <!-- /TODO -->
68
68
  <title>{{ title }}</title>
69
- <script type="module" crossorigin src="./assets/index-Cns3Ex2y.js"></script>
69
+ <script type="module" crossorigin src="./assets/index-a3SXFqw7.js"></script>
70
70
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-y72bE5iF.js">
71
71
  <link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
72
72
  <link rel="modulepreload" crossorigin href="./assets/react-Bj1aDYRI.js">
@@ -133,7 +133,7 @@
133
133
  <link rel="modulepreload" crossorigin href="./assets/debounce-OiXznToA.js">
134
134
  <link rel="modulepreload" crossorigin href="./assets/database-zap-DIlSqcdp.js">
135
135
  <link rel="modulepreload" crossorigin href="./assets/main-DmhaVp6Y.js">
136
- <link rel="modulepreload" crossorigin href="./assets/cells-DQ5n6Zef.js">
136
+ <link rel="modulepreload" crossorigin href="./assets/cells-DZEvA3zb.js">
137
137
  <link rel="modulepreload" crossorigin href="./assets/ErrorBoundary-Bo313Z9X.js">
138
138
  <link rel="modulepreload" crossorigin href="./assets/kbd-BCXa3Ocm.js">
139
139
  <link rel="modulepreload" crossorigin href="./assets/useInstallPackage-DEHK-C20.js">
@@ -147,38 +147,38 @@
147
147
  <link rel="modulepreload" crossorigin href="./assets/usePress-mjvipKvz.js">
148
148
  <link rel="modulepreload" crossorigin href="./assets/input-b2KTOk0X.js">
149
149
  <link rel="modulepreload" crossorigin href="./assets/ImperativeModal-MQnbMIO2.js">
150
- <link rel="modulepreload" crossorigin href="./assets/cell-link-LArpBcY-.js">
150
+ <link rel="modulepreload" crossorigin href="./assets/cell-link-CaBSvNu3.js">
151
151
  <link rel="modulepreload" crossorigin href="./assets/multi-map-9ogswH46.js">
152
152
  <link rel="modulepreload" crossorigin href="./assets/alert-Bjh7v4lb.js">
153
153
  <link rel="modulepreload" crossorigin href="./assets/chevron-right-C7RH0Nc7.js">
154
154
  <link rel="modulepreload" crossorigin href="./assets/dropdown-menu-DfGLyCbP.js">
155
155
  <link rel="modulepreload" crossorigin href="./assets/links-DK7te6sJ.js">
156
- <link rel="modulepreload" crossorigin href="./assets/useRunCells-bcK6jTD2.js">
156
+ <link rel="modulepreload" crossorigin href="./assets/useRunCells-CK2uMzyx.js">
157
157
  <link rel="modulepreload" crossorigin href="./assets/copy-CyasABTK.js">
158
158
  <link rel="modulepreload" crossorigin href="./assets/copy-IBNGDypD.js">
159
159
  <link rel="modulepreload" crossorigin href="./assets/copy-icon-BCIGtBo0.js">
160
- <link rel="modulepreload" crossorigin href="./assets/RenderHTML-BLBwT24G.js">
161
- <link rel="modulepreload" crossorigin href="./assets/datasource-BT-L2LDD.js">
162
- <link rel="modulepreload" crossorigin href="./assets/state-VxOqftwq.js">
160
+ <link rel="modulepreload" crossorigin href="./assets/RenderHTML-FBKVQ49x.js">
161
+ <link rel="modulepreload" crossorigin href="./assets/datasource-C4XU40Hp.js">
162
+ <link rel="modulepreload" crossorigin href="./assets/state-CvarlPeY.js">
163
163
  <link rel="modulepreload" crossorigin href="./assets/package-BoMcg6sy.js">
164
164
  <link rel="modulepreload" crossorigin href="./assets/sparkles-DctOjjEz.js">
165
- <link rel="modulepreload" crossorigin href="./assets/MarimoErrorOutput-DcImOp4r.js">
165
+ <link rel="modulepreload" crossorigin href="./assets/MarimoErrorOutput-C9ti-mu4.js">
166
166
  <link rel="modulepreload" crossorigin href="./assets/eye-off-DI0EQXw0.js">
167
167
  <link rel="modulepreload" crossorigin href="./assets/refresh-cw-DcEasnos.js">
168
- <link rel="modulepreload" crossorigin href="./assets/tree-actions-CjikjOBA.js">
168
+ <link rel="modulepreload" crossorigin href="./assets/tree-actions-CNIHKi7f.js">
169
169
  <link rel="modulepreload" crossorigin href="./assets/spinner-DTBVbtl-.js">
170
- <link rel="modulepreload" crossorigin href="./assets/html-to-image-CmK-WSPG.js">
171
- <link rel="modulepreload" crossorigin href="./assets/focus-Dol5ybck.js">
170
+ <link rel="modulepreload" crossorigin href="./assets/html-to-image-DY_stEj0.js">
171
+ <link rel="modulepreload" crossorigin href="./assets/focus-DHgSYMb6.js">
172
172
  <link rel="modulepreload" crossorigin href="./assets/useAsyncData-CT1LpOBD.js">
173
173
  <link rel="modulepreload" crossorigin href="./assets/LazyAnyLanguageCodeMirror-CUQODgGJ.js">
174
174
  <link rel="modulepreload" crossorigin href="./assets/micromark-factory-space-P--XWZhg.js">
175
175
  <link rel="modulepreload" crossorigin href="./assets/chunk-5FQGJX7Z-C6VN0dQj.js">
176
- <link rel="modulepreload" crossorigin href="./assets/markdown-renderer-f3mfGw8u.js">
176
+ <link rel="modulepreload" crossorigin href="./assets/markdown-renderer-duAFwqLF.js">
177
177
  <link rel="modulepreload" crossorigin href="./assets/command-CsbsBLBw.js">
178
178
  <link rel="modulepreload" crossorigin href="./assets/field-CA9HCE2Y.js">
179
179
  <link rel="modulepreload" crossorigin href="./assets/popover-DMNO6Poc.js">
180
180
  <link rel="modulepreload" crossorigin href="./assets/errors-48KFPvCp.js">
181
- <link rel="modulepreload" crossorigin href="./assets/download-rKGlekSQ.js">
181
+ <link rel="modulepreload" crossorigin href="./assets/download-DlMo0yoI.js">
182
182
  <link rel="modulepreload" crossorigin href="./assets/table-Fk_msRcD.js">
183
183
  <link rel="modulepreload" crossorigin href="./assets/useIframeCapabilities-DuGyzPVb.js">
184
184
  <link rel="modulepreload" crossorigin href="./assets/error-banner-C4DZksWV.js">
@@ -198,21 +198,21 @@
198
198
  <link rel="modulepreload" crossorigin href="./assets/plus-CExKUszm.js">
199
199
  <link rel="modulepreload" crossorigin href="./assets/trash-2-CjPoUZCP.js">
200
200
  <link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-CgWOEYeG.js">
201
- <link rel="modulepreload" crossorigin href="./assets/JsonOutput-DTeVFctC.js">
201
+ <link rel="modulepreload" crossorigin href="./assets/JsonOutput-BfDKMXVF.js">
202
202
  <link rel="modulepreload" crossorigin href="./assets/chart-no-axes-column-DVEV2j1H.js">
203
203
  <link rel="modulepreload" crossorigin href="./assets/square-function-CPbVtjKW.js">
204
204
  <link rel="modulepreload" crossorigin href="./assets/spec-BzxoPflZ.js">
205
- <link rel="modulepreload" crossorigin href="./assets/column-preview-VcOeHtkt.js">
205
+ <link rel="modulepreload" crossorigin href="./assets/column-preview-CtFTSUj4.js">
206
206
  <link rel="modulepreload" crossorigin href="./assets/icons-D3YFXNmD.js">
207
- <link rel="modulepreload" crossorigin href="./assets/radio-group-D7RG9Px_.js">
208
- <link rel="modulepreload" crossorigin href="./assets/floating-outline-CPTvLHMl.js">
207
+ <link rel="modulepreload" crossorigin href="./assets/radio-group-C03SYtE4.js">
208
+ <link rel="modulepreload" crossorigin href="./assets/floating-outline-DWk90U4M.js">
209
209
  <link rel="modulepreload" crossorigin href="./assets/objectWithoutPropertiesLoose-Msf1n32r.js">
210
210
  <link rel="modulepreload" crossorigin href="./assets/esm-DSv-aO_T.js">
211
- <link rel="modulepreload" crossorigin href="./assets/readonly-python-code-DHJTIc4H.js">
211
+ <link rel="modulepreload" crossorigin href="./assets/readonly-python-code-Buc6Cpxg.js">
212
212
  <link rel="modulepreload" crossorigin href="./assets/file-headphone-CUN2DC78.js">
213
213
  <link rel="modulepreload" crossorigin href="./assets/file-BvoBtS_V.js">
214
214
  <link rel="modulepreload" crossorigin href="./assets/image-jhXeQEgs.js">
215
- <link rel="modulepreload" crossorigin href="./assets/file-icons-DBMviz_K.js">
215
+ <link rel="modulepreload" crossorigin href="./assets/file-icons-C_azZLwC.js">
216
216
  <link rel="modulepreload" crossorigin href="./assets/switch-DHhZkGEv.js">
217
217
  <link rel="modulepreload" crossorigin href="./assets/events-BRbNg7Li.js">
218
218
  <link rel="modulepreload" crossorigin href="./assets/globals-BDWM3c_z.js">
@@ -221,11 +221,11 @@
221
221
  <link rel="modulepreload" crossorigin href="./assets/memoize-Tp7rARFe.js">
222
222
  <link rel="modulepreload" crossorigin href="./assets/get-C-qh_et5.js">
223
223
  <link rel="modulepreload" crossorigin href="./assets/_baseSet-CsW0tABf.js">
224
- <link rel="modulepreload" crossorigin href="./assets/state-Cvt1qFuu.js">
224
+ <link rel="modulepreload" crossorigin href="./assets/state-CV4SpBvo.js">
225
225
  <link rel="modulepreload" crossorigin href="./assets/label-CFvCMYuj.js">
226
- <link rel="modulepreload" crossorigin href="./assets/textarea-DD5BwHTh.js">
226
+ <link rel="modulepreload" crossorigin href="./assets/textarea-BaOwN3Me.js">
227
227
  <link rel="modulepreload" crossorigin href="./assets/refresh-ccw-CUkO1Vlo.js">
228
- <link rel="modulepreload" crossorigin href="./assets/form-B9I9mpZy.js">
228
+ <link rel="modulepreload" crossorigin href="./assets/form-ClQGrP6i.js">
229
229
  <link rel="modulepreload" crossorigin href="./assets/renderShortcut-CKbqJyj4.js">
230
230
  <link rel="modulepreload" crossorigin href="./assets/useBoolean-48bgGoSa.js">
231
231
  <link rel="modulepreload" crossorigin href="./assets/useDeepCompareMemoize-zUHU--0D.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/frontend",
3
- "version": "0.23.14-dev3",
3
+ "version": "0.23.14-dev6",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -0,0 +1,22 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import { describe, expect, it } from "vitest";
4
+ import { getSnippetDisplay } from "../snippet-display";
5
+
6
+ describe("getSnippetDisplay", () => {
7
+ it("shows sql cells as the sql query", () => {
8
+ const { language, value } = getSnippetDisplay(
9
+ 'df = mo.sql("""SELECT * FROM users LIMIT 5""")',
10
+ );
11
+ expect(language).toBe("sql");
12
+ expect(value).toBe("SELECT * FROM users LIMIT 5");
13
+ });
14
+
15
+ it("keeps plain python cells as python", () => {
16
+ const code = "x = 1 + 2\nprint(x)";
17
+ expect(getSnippetDisplay(code)).toEqual({
18
+ language: "python",
19
+ value: code,
20
+ });
21
+ });
22
+ });
@@ -0,0 +1,27 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import { SQLParser } from "@marimo-team/smart-cells";
4
+
5
+ export type SnippetLanguage = "python" | "sql";
6
+
7
+ export interface SnippetDisplay {
8
+ language: SnippetLanguage;
9
+ value: string;
10
+ }
11
+
12
+ const sqlParser = new SQLParser();
13
+
14
+ /**
15
+ * Decide how a snippet's code should be shown in the panel.
16
+ *
17
+ * SQL cells are stored as python `mo.sql(...)`. Unwrap the inner query and
18
+ * highlight it as SQL, matching how the cell renders once the snippet is
19
+ * inserted. Everything else stays python.
20
+ */
21
+ export function getSnippetDisplay(code: string): SnippetDisplay {
22
+ if (sqlParser.isSupported(code)) {
23
+ const { code: query } = sqlParser.transformIn(code);
24
+ return { language: "sql", value: query };
25
+ }
26
+ return { language: "python", value: code };
27
+ }
@@ -31,6 +31,7 @@ import { cn } from "@/utils/cn";
31
31
  import { HideInKioskMode } from "../../kiosk-mode";
32
32
  import { ContributeSnippetButton } from "../components/contribute-snippet-button";
33
33
  import { usePanelOrientation, usePanelSection } from "./panel-context";
34
+ import { getSnippetDisplay } from "./snippet-display";
34
35
 
35
36
  const extensions = [EditorView.lineWrapping];
36
37
 
@@ -187,6 +188,8 @@ const SnippetViewer: React.FC<{ snippet: Snippet; onClose: () => void }> = ({
187
188
  return null;
188
189
  }
189
190
 
191
+ const { language, value } = getSnippetDisplay(code);
192
+
190
193
  return (
191
194
  <div
192
195
  className="relative hover-actions-parent pr-2"
@@ -210,10 +213,10 @@ const SnippetViewer: React.FC<{ snippet: Snippet; onClose: () => void }> = ({
210
213
  <LazyAnyLanguageCodeMirror
211
214
  key={`${snippet.title}-${id}`}
212
215
  theme={theme === "dark" ? "dark" : "light"}
213
- language="python"
216
+ language={language}
214
217
  className="cm border rounded overflow-hidden"
215
218
  extensions={extensions}
216
- value={code}
219
+ value={value}
217
220
  readOnly={true}
218
221
  />
219
222
  </Suspense>
@@ -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 [
@@ -1 +0,0 @@
1
- import{s as I}from"./chunk-LvLJmgfZ.js";import"./useEvent-D91BmmQi.js";import{t as O}from"./react-Bj1aDYRI.js";import{D as P}from"./cells-DQ5n6Zef.js";import"./react-dom-CSu739Rf.js";import{t as $}from"./compiler-runtime-B3qBwwSJ.js";import{n as q}from"./useEventListener-BakX-tnw.js";import{n as F}from"./constants-B9JJ72XE.js";import{t as G}from"./cn-X2M2usMq.js";import{t as R}from"./jsx-runtime-PbYoItBR.js";import"./fullscreen-BXI8V5i6.js";import{t as T}from"./tooltip-CgQpRVyN.js";import{t as w}from"./button-BF7GSjhW.js";import{st as W}from"./dist-Dez1I5M9.js";import"./cjs-DXo9vDEJ.js";import"./main-DmhaVp6Y.js";import"./useNonce-0SWz6w4W.js";import{r as A}from"./requests-KshNNAOp.js";import{n as M,t as B}from"./LazyAnyLanguageCodeMirror-CUQODgGJ.js";import{t as J}from"./x-9vLEgLY6.js";import{t as K}from"./spinner-DTBVbtl-.js";import{t as L}from"./plus-CExKUszm.js";import"./dist-DHMtQYxT.js";import"./dist-Bj9Iedc0.js";import"./dist-D-o1OXc9.js";import"./dist-BZhJ1bTM.js";import"./dist-DnIl7RU-.js";import"./session-B6_8umQX.js";import{r as U}from"./useTheme-CWoNQwFz.js";import"./purify.es-DdxMtdqK.js";import{t as V}from"./RenderHTML-BLBwT24G.js";import{a as X,c as Y,i as Q,n as Z,r as ee}from"./dialog-Dr_Y1zNi.js";import{n as te}from"./ImperativeModal-MQnbMIO2.js";import{n as se}from"./error-banner-C4DZksWV.js";import{o as re}from"./focus-Dol5ybck.js";import{n as le}from"./useAsyncData-CT1LpOBD.js";import{n as oe,r as ie,t as D}from"./react-resizable-panels.browser.esm-CgWOEYeG.js";import{a as ae,f as ne,o as me,r as ce,t as de}from"./command-CsbsBLBw.js";import{t as pe}from"./empty-state-vKu4k0Y4.js";import{n as he,r as fe}from"./panel-context-RKllh8pM.js";import{t as E}from"./kiosk-mode-CAa5-suK.js";var H=$(),C=I(O(),1),s=I(R(),1),xe=q;const ue=t=>{let e=(0,H.c)(6),{children:r}=t,{openModal:i,closeModal:o}=te(),l;e[0]!==o||e[1]!==i?(l=()=>i((0,s.jsx)(je,{onClose:o})),e[0]=o,e[1]=i,e[2]=l):l=e[2];let a;return e[3]!==r||e[4]!==l?(a=(0,s.jsx)(xe,{onClick:l,children:r}),e[3]=r,e[4]=l,e[5]=a):a=e[5],a};var je=t=>{let e=(0,H.c)(4),{onClose:r}=t,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)(Y,{children:"Contribute a Snippet"}),e[0]=i):i=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=(0,s.jsxs)(X,{children:[i,(0,s.jsxs)(ee,{children:["Have a useful snippet you want to share with the community? Make a pull request"," ",(0,s.jsx)("a",{href:F.githubPage,target:"_blank",className:"underline",children:"on GitHub"}),"."]})]}),e[1]=o):o=e[1];let l;return e[2]===r?l=e[3]:(l=(0,s.jsxs)(Z,{className:"max-w-md",children:[o,(0,s.jsx)(Q,{children:(0,s.jsx)(w,{"data-testid":"snippet-close-button",variant:"default",onClick:r,children:"Close"})})]}),e[2]=r,e[3]=l),l},k=$(),be=[W.lineWrapping],ve=()=>{let t=(0,k.c)(24),{readSnippets:e}=A(),[r,i]=C.useState(),o=he(),l=fe(),a;t[0]===e?a=t[1]:(a=()=>e(),t[0]=e,t[1]=a);let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=[],t[2]=c):c=t[2];let{data:N,error:j,isPending:g}=le(a,c);if(j){let m;return t[3]===j?m=t[4]:(m=(0,s.jsx)(se,{error:j}),t[3]=j,t[4]=m),m}if(g||!N){let m;return t[5]===Symbol.for("react.memo_cache_sentinel")?(m=(0,s.jsx)(K,{size:"medium",centered:!0}),t[5]=m):m=t[5],m}let _=o==="vertical",b;t[6]===Symbol.for("react.memo_cache_sentinel")?(b=(0,s.jsx)(ae,{placeholder:"Search snippets...",className:"h-6 m-1",rootClassName:"flex-1 border-r"}),t[6]=b):b=t[6];let h,f;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=(0,s.jsxs)("div",{className:"flex items-center w-full border-b",children:[b,(0,s.jsx)(ue,{children:(0,s.jsx)("button",{className:"float-right px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",children:(0,s.jsx)(L,{className:"h-4 w-4"})})})]}),f=(0,s.jsx)(ce,{children:"No results"}),t[7]=h,t[8]=f):(h=t[7],f=t[8]);let v;t[9]===Symbol.for("react.memo_cache_sentinel")?(v=m=>i(m),t[9]=v):v=t[9];let d;t[10]===N.snippets?d=t[11]:(d=(0,s.jsx)(D,{defaultSize:40,minSize:20,maxSize:70,children:(0,s.jsxs)(de,{className:"h-full rounded-none",children:[h,f,(0,s.jsx)(_e,{onSelect:v,snippets:N.snippets})]})}),t[10]=N.snippets,t[11]=d);let u=_?"h-1":"w-1",p;t[12]===u?p=t[13]:(p=G("bg-border hover:bg-primary/50 transition-colors",u),t[12]=u,t[13]=p);let x;t[14]===p?x=t[15]:(x=(0,s.jsx)(ie,{className:p}),t[14]=p,t[15]=x);let n;t[16]===r?n=t[17]:(n=(0,s.jsx)(D,{defaultSize:60,minSize:20,children:(0,s.jsx)(C.Suspense,{children:(0,s.jsx)("div",{className:"h-full snippet-viewer flex flex-col overflow-hidden",children:r?(0,s.jsx)(Ne,{snippet:r,onClose:()=>i(void 0)},r.title):(0,s.jsx)(pe,{title:"",description:"Click on a snippet to view its content."})})})}),t[16]=r,t[17]=n);let S;return t[18]!==o||t[19]!==l||t[20]!==n||t[21]!==d||t[22]!==x?(S=(0,s.jsx)("div",{className:"flex-1 overflow-hidden h-full",children:(0,s.jsxs)(oe,{direction:o,className:"h-full",children:[d,x,n]},l)}),t[18]=o,t[19]=l,t[20]=n,t[21]=d,t[22]=x,t[23]=S):S=t[23],S},Ne=t=>{let e=(0,k.c)(33),{snippet:r,onClose:i}=t,{theme:o}=U(),{createNewCell:l}=P(),a=re(),c;e[0]!==l||e[1]!==a||e[2]!==r.sections?(c=()=>{for(let n of r.sections.toReversed())n.code&&l({code:n.code,before:!1,cellId:a??"__end__",skipIfCodeExists:!0})},e[0]=l,e[1]=a,e[2]=r.sections,e[3]=c):c=e[3];let N=c,j;e[4]!==l||e[5]!==a?(j=n=>{l({code:n,before:!1,cellId:a??"__end__"})},e[4]=l,e[5]=a,e[6]=j):j=e[6];let g=j,_;e[7]===r.title?_=e[8]:(_=(0,s.jsx)("span",{children:r.title}),e[7]=r.title,e[8]=_);let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=(0,s.jsx)(J,{className:"h-4 w-4"}),e[9]=b):b=e[9];let h;e[10]===i?h=e[11]:(h=(0,s.jsx)(w,{size:"sm",variant:"ghost",onClick:i,className:"h-6 w-6 p-0 hover:bg-muted-foreground/10",children:b}),e[10]=i,e[11]=h);let f;e[12]!==_||e[13]!==h?(f=(0,s.jsxs)("div",{className:"text-sm font-semibold bg-muted border-y px-2 py-1 flex justify-between items-center",children:[_,h]}),e[12]=_,e[13]=h,e[14]=f):f=e[14];let v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=(0,s.jsx)(M,{className:"ml-2 h-4 w-4"}),e[15]=v):v=e[15];let d;e[16]===N?d=e[17]:(d=(0,s.jsx)("div",{className:"flex justify-end",children:(0,s.jsx)(E,{children:(0,s.jsxs)(w,{className:"float-right",size:"xs",variant:"outline",onClick:N,children:["Insert snippet",v]})})}),e[16]=N,e[17]=d);let u;if(e[18]!==g||e[19]!==r.sections||e[20]!==r.title||e[21]!==o){let n;e[23]!==g||e[24]!==r.title||e[25]!==o?(n=S=>{let{code:m,html:z,id:y}=S;return z?(0,s.jsx)("div",{children:V({html:z})},`${r.title}-${y}`):m?(0,s.jsxs)("div",{className:"relative hover-actions-parent pr-2",children:[(0,s.jsx)(E,{children:(0,s.jsx)(T,{content:"Insert snippet",children:(0,s.jsx)(w,{className:"absolute -top-2 -right-1 z-10 hover-action px-2 bg-background",size:"sm",variant:"outline",onClick:()=>{g(m)},children:(0,s.jsx)(M,{className:"h-5 w-5"})})})}),(0,s.jsx)(C.Suspense,{children:(0,s.jsx)(B,{theme:o==="dark"?"dark":"light",language:"python",className:"cm border rounded overflow-hidden",extensions:be,value:m,readOnly:!0},`${r.title}-${y}`)})]},`${r.title}-${y}`):null},e[23]=g,e[24]=r.title,e[25]=o,e[26]=n):n=e[26],u=r.sections.map(n),e[18]=g,e[19]=r.sections,e[20]=r.title,e[21]=o,e[22]=u}else u=e[22];let p;e[27]!==d||e[28]!==u?(p=(0,s.jsxs)("div",{className:"px-2 py-2 space-y-4 overflow-auto flex-1",children:[d,u]}),e[27]=d,e[28]=u,e[29]=p):p=e[29];let x;return e[30]!==p||e[31]!==f?(x=(0,s.jsxs)(s.Fragment,{children:[f,p]}),e[30]=p,e[31]=f,e[32]=x):x=e[32],x},_e=t=>{let e=(0,k.c)(7),{snippets:r,onSelect:i}=t,o;if(e[0]!==i||e[1]!==r){let a;e[3]===i?a=e[4]:(a=c=>(0,s.jsx)(me,{className:"rounded-none",onSelect:()=>i(c),children:(0,s.jsx)("div",{className:"flex flex-row gap-2 items-center",children:(0,s.jsx)("span",{className:"mt-1 text-accent-foreground",children:c.title})})},c.title),e[3]=i,e[4]=a),o=r.map(a),e[0]=i,e[1]=r,e[2]=o}else o=e[2];let l;return e[5]===o?l=e[6]:(l=(0,s.jsx)(ne,{className:"flex flex-col overflow-auto",children:o}),e[5]=o,e[6]=l),l};export{ve as default};