@marimo-team/islands 0.23.16-dev6 → 0.23.16-dev62
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.
- package/dist/{ConnectedDataExplorerComponent-CJaUI-S-.js → ConnectedDataExplorerComponent-f9vLjQiF.js} +13 -13
- package/dist/{ErrorBoundary-DXlxsrTF.js → ErrorBoundary-DhLqwSWA.js} +3 -3
- package/dist/{any-language-editor-P9tjkj4n.js → any-language-editor-DifE-fl7.js} +5 -5
- package/dist/{button-BcSml68y.js → button-BSm8IXRU.js} +2 -4
- package/dist/{capabilities-BYLFYTYv.js → capabilities-C6OQ5YBO.js} +1 -1
- package/dist/{chat-ui-BdSDiVjk.js → chat-ui-DsZJj75A.js} +3117 -3120
- package/dist/{check-Cs-KV5XY.js → check-DP7U0H0G.js} +1 -1
- package/dist/{code-visibility-CfBftiVM.js → common-Bpnmu1Yz.js} +1085 -1053
- package/dist/{copy-Cs3yt6Vt.js → copy-DNq8q3zw.js} +2 -2
- package/dist/{dist-B96tMAst.js → dist-DIlxLFXG.js} +2 -2
- package/dist/{error-banner-DR7o3CbX.js → error-banner-B_GQfxxD.js} +2 -2
- package/dist/{esm-k8PIvuZW.js → esm-DzZVaNH4.js} +1 -1
- package/dist/{extends-Cq2JYHKy.js → extends-w2_S44bV.js} +4 -4
- package/dist/{formats-BFhkZJwd.js → formats-Dwq1THhr.js} +3 -3
- package/dist/{glide-data-editor--CaN-f27.js → glide-data-editor-B9K6-MJe.js} +9 -9
- package/dist/{html-to-image-DDENewl2.js → html-to-image-CZ1kLKkq.js} +7350 -6356
- package/dist/{input-DStQIuqD.js → input-C5K4VBvB.js} +7 -7
- package/dist/{label-DIk0QoFe.js → label-DjoYwqmj.js} +2 -2
- package/dist/{loader-CTHCI-qe.js → loader-DX-IDS7n.js} +1 -1
- package/dist/main.js +259 -194
- package/dist/{mermaid-CdSvixW2.js → mermaid-hv6IckVw.js} +5 -5
- package/dist/{node-sql-parser-DLl_zNw0.js → node-sql-parser-v1Vi-Fft.js} +16867 -16665
- package/dist/{process-output-2QPcgBQg.js → process-output-bVfbcx5_.js} +32 -28
- package/dist/{reveal-component-BclLkYnV.js → reveal-component-JIt3oSeU.js} +642 -634
- package/dist/{spec-CnaxwDqy.js → spec-CQKL_D3i.js} +4 -4
- package/dist/{strings-BYAhZnQi.js → strings-DIy9NAmg.js} +4 -4
- package/dist/style.css +1 -1
- package/dist/{swiper-component-DE94711u.js → swiper-component-CEdAYjb7.js} +2 -2
- package/dist/toDate-CqhBWjvO.js +713 -0
- package/dist/{tooltip-B-qh7UPB.js → tooltip-f-qR0iUx.js} +3 -3
- package/dist/{types-DQl7jVYK.js → types-DicH9Oi0.js} +1 -1
- package/dist/{useAsyncData-CvO8WUy3.js → useAsyncData-CYOQb1EW.js} +1 -1
- package/dist/{useDateFormatter-BSoGim-G.js → useDateFormatter-Bt2qr_XS.js} +2 -2
- package/dist/{useDeepCompareMemoize-J3MKRdA4.js → useDeepCompareMemoize-CSHQeQEI.js} +1 -1
- package/dist/{useIframeCapabilities-POcFXHbw.js → useIframeCapabilities-kA09ykNq.js} +1 -1
- package/dist/{useLifecycle-DqPxHgAN.js → useLifecycle-CMJGqBaY.js} +3 -3
- package/dist/{useTheme-XMq9mNf_.js → useTheme-DYfby65G.js} +2 -2
- package/dist/{vega-component-CrFoZT1S.js → vega-component-C7nO5zcf.js} +10 -10
- package/dist/{zod-D0yOqoGe.js → zod-BUcyXSdR.js} +1 -1
- package/package.json +3 -4
- package/src/__mocks__/requests.ts +56 -4
- package/src/components/data-table/__tests__/__snapshots__/chart-spec-model.test.ts.snap +174 -21
- package/src/components/data-table/__tests__/chart-spec-model.test.ts +102 -1
- package/src/components/data-table/__tests__/columns.test.tsx +9 -1
- package/src/components/data-table/column-summary/chart-spec-model.tsx +163 -103
- package/src/components/data-table/column-summary/legacy-chart-spec.ts +15 -7
- package/src/components/data-table/column-summary/utils.ts +26 -7
- package/src/components/data-table/columns.tsx +11 -1
- package/src/components/data-table/types.ts +1 -1
- package/src/components/editor/__tests__/viewer-banner.test.tsx +14 -0
- package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +99 -18
- package/src/components/editor/actions/__tests__/pdf-export.test.ts +32 -13
- package/src/components/editor/actions/pair-with-agent-commands.ts +21 -10
- package/src/components/editor/actions/pair-with-agent-modal.tsx +2 -2
- package/src/components/editor/actions/pdf-export.ts +11 -14
- package/src/components/editor/actions/useNotebookActions.tsx +28 -19
- package/src/components/editor/cell/code/__tests__/cell-editor-activity-lifecycle.test.ts +250 -0
- package/src/components/editor/cell/code/cell-editor.tsx +13 -7
- package/src/components/editor/chrome/__tests__/state.test.ts +7 -1
- package/src/components/editor/chrome/panels/__tests__/logs-panel.test.tsx +25 -0
- package/src/components/editor/chrome/panels/__tests__/panel-accordion-state.test.ts +42 -0
- package/src/components/editor/chrome/panels/file-explorer-panel.tsx +6 -17
- package/src/components/editor/chrome/panels/logs-panel.tsx +12 -2
- package/src/components/editor/chrome/panels/panel-accordion-state.ts +51 -0
- package/src/components/editor/chrome/panels/session-panel.tsx +5 -16
- package/src/components/editor/chrome/panels/write-secret-modal.tsx +40 -12
- package/src/components/editor/chrome/state.ts +10 -0
- package/src/components/editor/connections/__tests__/json-credentials.test.ts +114 -0
- package/src/components/editor/connections/__tests__/paths.test.ts +39 -0
- package/src/components/editor/connections/__tests__/quick-add-data-sources.test.tsx +113 -0
- package/src/components/editor/connections/add-connection-dialog.tsx +2 -0
- package/src/components/editor/connections/components.tsx +6 -2
- package/src/components/editor/connections/database/__tests__/__snapshots__/as-code.test.ts.snap +27 -5
- package/src/components/editor/connections/database/__tests__/as-code.test.ts +33 -0
- package/src/components/editor/connections/database/as-code.ts +37 -13
- package/src/components/editor/connections/database/schemas.ts +6 -5
- package/src/components/editor/connections/form-renderers.tsx +99 -1
- package/src/components/editor/connections/json-credentials.ts +57 -0
- package/src/components/editor/connections/paths.ts +21 -0
- package/src/components/editor/connections/quick-add-data-sources.tsx +106 -0
- package/src/components/editor/connections/secret-combobox.tsx +41 -20
- package/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap +88 -2
- package/src/components/editor/connections/storage/__tests__/as-code.test.ts +128 -8
- package/src/components/editor/connections/storage/as-code.ts +79 -36
- package/src/components/editor/connections/storage/schemas.ts +85 -44
- package/src/components/editor/file-tree/__tests__/renderers.test.ts +31 -0
- package/src/components/editor/file-tree/file-viewer.tsx +11 -7
- package/src/components/editor/file-tree/renderers.tsx +21 -0
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +2 -2
- package/src/components/editor/viewer-banner.tsx +6 -1
- package/src/components/forms/form.tsx +59 -24
- package/src/components/forms/options.ts +2 -1
- package/src/components/slides/__tests__/cell-output-block.test.tsx +40 -0
- package/src/components/slides/__tests__/slide-cell-view.test.tsx +33 -0
- package/src/components/slides/reveal-component.tsx +22 -17
- package/src/components/slides/slide-cell-view.tsx +1 -1
- package/src/components/slides/slides.css +4 -2
- package/src/components/static-html/share-modal.tsx +1 -1
- package/src/components/ui/input.tsx +1 -1
- package/src/core/ai/context/providers/file.ts +8 -29
- package/src/core/cells/__tests__/cells.test.ts +12 -2
- package/src/core/cells/__tests__/logs.test.ts +5 -5
- package/src/core/cells/cells.ts +17 -4
- package/src/core/cells/document-changes.ts +1 -0
- package/src/core/cells/logs.ts +14 -4
- package/src/core/codemirror/cm.ts +3 -0
- package/src/core/codemirror/code-lens/__tests__/actions.test.ts +68 -0
- package/src/core/codemirror/code-lens/__tests__/analyzer.test.ts +224 -0
- package/src/core/codemirror/code-lens/__tests__/entities.test.ts +175 -0
- package/src/core/codemirror/code-lens/__tests__/extension.test.ts +325 -0
- package/src/core/codemirror/code-lens/__tests__/perf.test.ts +121 -0
- package/src/core/codemirror/code-lens/__tests__/popover.test.ts +93 -0
- package/src/core/codemirror/code-lens/actions.ts +33 -0
- package/src/core/codemirror/code-lens/analyzer.ts +284 -0
- package/src/core/codemirror/code-lens/entities.ts +123 -0
- package/src/core/codemirror/code-lens/extension.ts +298 -0
- package/src/core/codemirror/code-lens/icons.ts +36 -0
- package/src/core/codemirror/code-lens/popover.tsx +240 -0
- package/src/core/codemirror/copilot/__tests__/language-server.test.ts +396 -100
- package/src/core/codemirror/copilot/__tests__/transport.test.ts +128 -540
- package/src/core/codemirror/copilot/language-server.ts +182 -70
- package/src/core/codemirror/copilot/transport.ts +15 -207
- package/src/core/codemirror/copilot/types.ts +9 -2
- package/src/core/codemirror/find-replace/__tests__/navigate.test.ts +42 -30
- package/src/core/codemirror/find-replace/navigate.ts +2 -0
- package/src/core/codemirror/go-to-definition/__tests__/commands.test.ts +24 -3
- package/src/core/codemirror/go-to-definition/commands.ts +93 -90
- package/src/core/codemirror/keymaps/__tests__/keymaps.test.ts +31 -2
- package/src/core/codemirror/keymaps/keymaps.ts +12 -0
- package/src/core/codemirror/language/__tests__/sql.test.ts +627 -61
- package/src/core/codemirror/language/languages/python.ts +23 -11
- package/src/core/codemirror/language/languages/sql/completion-store.ts +5 -1
- package/src/core/codemirror/language/languages/sql/renderers.tsx +3 -3
- package/src/core/codemirror/language/languages/sql/sql.ts +251 -16
- package/src/core/codemirror/lsp/__tests__/federated-lsp.test.ts +161 -0
- package/src/core/codemirror/lsp/__tests__/log-messages.test.ts +53 -0
- package/src/core/codemirror/lsp/__tests__/normalize-markdown-math.test.ts +25 -0
- package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +598 -156
- package/src/core/codemirror/lsp/__tests__/transports.test.ts +112 -0
- package/src/core/codemirror/lsp/federated-lsp.ts +76 -23
- package/src/core/codemirror/lsp/log-messages.ts +37 -0
- package/src/core/codemirror/lsp/normalize-markdown-math.ts +8 -4
- package/src/core/codemirror/lsp/notebook-lsp.ts +220 -56
- package/src/core/codemirror/lsp/transports.ts +8 -1
- package/src/core/codemirror/lsp/types.ts +68 -8
- package/src/core/codemirror/lsp/utils.ts +14 -0
- package/src/core/codemirror/python-node-names.ts +90 -0
- package/src/core/codemirror/reactive-references/analyzer.ts +52 -57
- package/src/core/codemirror/utils.ts +28 -0
- package/src/core/config/feature-flag.tsx +3 -1
- package/src/core/datasets/data-source-discovery.ts +5 -0
- package/src/core/datasets/request-registry.ts +11 -0
- package/src/core/edit-app.tsx +1 -2
- package/src/core/export/__tests__/hooks.test.ts +2 -4
- package/src/core/export/hooks.ts +4 -3
- package/src/core/hotkeys/hotkeys.ts +0 -2
- package/src/core/islands/__tests__/bridge.test.ts +107 -0
- package/src/core/islands/bootstrap.ts +1 -0
- package/src/core/islands/bridge.ts +18 -0
- package/src/core/kernel/messages.ts +2 -0
- package/src/core/lsp/__tests__/transport.test.ts +509 -337
- package/src/core/lsp/transport.ts +304 -132
- package/src/core/mode.ts +10 -0
- package/src/core/network/__tests__/api.test.ts +42 -0
- package/src/core/network/__tests__/connection.test.ts +45 -0
- package/src/core/network/__tests__/requests-lazy.test.ts +47 -1
- package/src/core/network/__tests__/requests-network.test.ts +48 -0
- package/src/core/network/api.ts +27 -0
- package/src/core/network/connection.ts +15 -0
- package/src/core/network/requests-lazy.ts +3 -0
- package/src/core/network/requests-network.ts +31 -8
- package/src/core/network/requests-static.ts +3 -0
- package/src/core/network/requests-toasting.tsx +3 -0
- package/src/core/network/types.ts +27 -6
- package/src/core/rtc/state.ts +9 -0
- package/src/core/static/download-html.ts +5 -14
- package/src/core/wasm/__tests__/bridge.test.ts +99 -5
- package/src/core/wasm/bridge.ts +42 -9
- package/src/core/wasm/worker/types.ts +10 -3
- package/src/core/wasm/worker/worker.ts +7 -8
- package/src/core/websocket/useMarimoKernelConnection.tsx +4 -0
- package/src/css/app/codemirror.css +16 -2
- package/src/hooks/__tests__/useDataSourceDiscovery.test.ts +80 -0
- package/src/hooks/useDataSourceDiscovery.ts +18 -0
- package/src/plugins/impl/DataTablePlugin.tsx +4 -1
- package/src/plugins/impl/FormPlugin.tsx +1 -1
- package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +158 -0
- package/src/plugins/impl/__tests__/FormPlugin.test.tsx +162 -0
- package/src/plugins/impl/anywidget/__tests__/model.test.ts +55 -0
- package/src/plugins/impl/anywidget/model.ts +20 -5
- package/src/plugins/impl/data-frames/forms/__tests__/__snapshots__/form.test.tsx.snap +33 -21
- package/src/plugins/impl/data-frames/forms/renderers.tsx +11 -8
- package/src/stories/log-viewer.stories.tsx +12 -6
- package/src/utils/__tests__/blob.test.ts +27 -1
- package/src/utils/__tests__/download.test.tsx +44 -4
- package/src/utils/blob.ts +24 -1
- package/src/utils/download.ts +14 -15
- package/dist/toDate-B3IRfHhw.js +0 -692
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
4
4
|
import {
|
|
5
5
|
type ConnectionInfo,
|
|
6
|
+
getFileFromURL,
|
|
6
7
|
getMarimoCommand,
|
|
7
8
|
getRawPrompt,
|
|
8
9
|
getTerminalCommand,
|
|
@@ -12,7 +13,11 @@ import {
|
|
|
12
13
|
|
|
13
14
|
const CONNECTION: ConnectionInfo = {
|
|
14
15
|
url: "http://localhost:8000",
|
|
15
|
-
|
|
16
|
+
file: "notebooks/example.py",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const CONNECTION_WITHOUT_FILE: ConnectionInfo = {
|
|
20
|
+
url: "http://localhost:8000",
|
|
16
21
|
};
|
|
17
22
|
|
|
18
23
|
describe("shellQuote", () => {
|
|
@@ -22,7 +27,7 @@ describe("shellQuote", () => {
|
|
|
22
27
|
|
|
23
28
|
it("leaves shell-safe values untouched", () => {
|
|
24
29
|
expect(shellQuote("http://localhost:8000")).toBe("http://localhost:8000");
|
|
25
|
-
expect(shellQuote("
|
|
30
|
+
expect(shellQuote("notebooks/example.py")).toBe("notebooks/example.py");
|
|
26
31
|
});
|
|
27
32
|
|
|
28
33
|
it("quotes values with shell metacharacters", () => {
|
|
@@ -37,6 +42,49 @@ describe("shellQuote", () => {
|
|
|
37
42
|
// Closes the quote, emits a literal ' via "'", then reopens: '"'"'
|
|
38
43
|
expect(shellQuote("a'b")).toBe(`'a'"'"'b'`);
|
|
39
44
|
});
|
|
45
|
+
|
|
46
|
+
it.each([
|
|
47
|
+
["/tmp/my notebook.py", "'/tmp/my notebook.py'"],
|
|
48
|
+
[
|
|
49
|
+
String.raw`C:\Users\Jane Doe\notebook.py`,
|
|
50
|
+
String.raw`'C:\Users\Jane Doe\notebook.py'`,
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
String.raw`\\server\share\my notebook.py`,
|
|
54
|
+
String.raw`'\\server\share\my notebook.py'`,
|
|
55
|
+
],
|
|
56
|
+
])("quotes non-portable path %s as one argument", (path, expected) => {
|
|
57
|
+
expect(shellQuote(path)).toBe(expected);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe("getFileFromURL", () => {
|
|
62
|
+
it("returns undefined when the file query parameter is absent or empty", () => {
|
|
63
|
+
expect(getFileFromURL("http://localhost:8000")).toBeUndefined();
|
|
64
|
+
expect(getFileFromURL("http://localhost:8000?file=")).toBeUndefined();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("decodes spaces and literal plus signs", () => {
|
|
68
|
+
expect(
|
|
69
|
+
getFileFromURL(
|
|
70
|
+
"http://localhost:8000?file=relative%2Fmy%20notebook%2Bdata.py",
|
|
71
|
+
),
|
|
72
|
+
).toBe("relative/my notebook+data.py");
|
|
73
|
+
expect(getFileFromURL("http://localhost:8000?file=my+notebook.py")).toBe(
|
|
74
|
+
"my notebook.py",
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("preserves decoded Windows paths and uses the first duplicate value", () => {
|
|
79
|
+
expect(
|
|
80
|
+
getFileFromURL(
|
|
81
|
+
"http://localhost:8000?file=C%3A%5CUsers%5CJane%20Doe%5Cnotebook.py",
|
|
82
|
+
),
|
|
83
|
+
).toBe(String.raw`C:\Users\Jane Doe\notebook.py`);
|
|
84
|
+
expect(
|
|
85
|
+
getFileFromURL("http://localhost:8000?file=first.py&file=second.py"),
|
|
86
|
+
).toBe("first.py");
|
|
87
|
+
});
|
|
40
88
|
});
|
|
41
89
|
|
|
42
90
|
describe("getMarimoCommand", () => {
|
|
@@ -56,30 +104,56 @@ describe("getMarimoCommand", () => {
|
|
|
56
104
|
});
|
|
57
105
|
|
|
58
106
|
describe("getTerminalCommand", () => {
|
|
59
|
-
it("includes the url and
|
|
107
|
+
it("includes the url and file for each agent", () => {
|
|
60
108
|
expect(getTerminalCommand("claude", CONNECTION, false)).toBe(
|
|
61
|
-
`claude "$(uv run marimo pair prompt --url http://localhost:8000 --
|
|
109
|
+
`claude "$(uv run marimo pair prompt --url http://localhost:8000 --file notebooks/example.py --claude)"`,
|
|
62
110
|
);
|
|
63
111
|
expect(getTerminalCommand("codex", CONNECTION, false)).toBe(
|
|
64
|
-
`codex "$(uv run marimo pair prompt --url http://localhost:8000 --
|
|
112
|
+
`codex "$(uv run marimo pair prompt --url http://localhost:8000 --file notebooks/example.py --codex)"`,
|
|
65
113
|
);
|
|
66
114
|
expect(getTerminalCommand("opencode", CONNECTION, false)).toBe(
|
|
67
|
-
`opencode --prompt "$(uv run marimo pair prompt --url http://localhost:8000 --
|
|
115
|
+
`opencode --prompt "$(uv run marimo pair prompt --url http://localhost:8000 --file notebooks/example.py --opencode)"`,
|
|
68
116
|
);
|
|
69
117
|
});
|
|
70
118
|
|
|
71
|
-
it("
|
|
72
|
-
const command = getTerminalCommand(
|
|
73
|
-
|
|
119
|
+
it("omits the file flag when the page URL has no file", () => {
|
|
120
|
+
const command = getTerminalCommand(
|
|
121
|
+
"claude",
|
|
122
|
+
CONNECTION_WITHOUT_FILE,
|
|
123
|
+
false,
|
|
124
|
+
);
|
|
125
|
+
expect(command).not.toContain("--file");
|
|
126
|
+
expect(command).not.toContain("--session");
|
|
74
127
|
});
|
|
75
128
|
|
|
76
129
|
it("shell-escapes a url containing metacharacters", () => {
|
|
77
130
|
const command = getTerminalCommand(
|
|
78
131
|
"claude",
|
|
79
|
-
{ url: "http://host:8000?
|
|
132
|
+
{ url: "http://host:8000?auth=a&b", file: "notebook.py" },
|
|
80
133
|
false,
|
|
81
134
|
);
|
|
82
|
-
expect(command).toContain("--url 'http://host:8000?
|
|
135
|
+
expect(command).toContain("--url 'http://host:8000?auth=a&b'");
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it.each([
|
|
139
|
+
["relative/my notebook.py", "--file 'relative/my notebook.py'"],
|
|
140
|
+
["/tmp/my notebook.py", "--file '/tmp/my notebook.py'"],
|
|
141
|
+
[
|
|
142
|
+
String.raw`C:\Users\Jane Doe\notebook.py`,
|
|
143
|
+
String.raw`--file 'C:\Users\Jane Doe\notebook.py'`,
|
|
144
|
+
],
|
|
145
|
+
[
|
|
146
|
+
String.raw`\\server\share\my notebook.py`,
|
|
147
|
+
String.raw`--file '\\server\share\my notebook.py'`,
|
|
148
|
+
],
|
|
149
|
+
["notebooks/it's.py", `--file 'notebooks/it'"'"'s.py'`],
|
|
150
|
+
])("shell-escapes file path %s", (file, expected) => {
|
|
151
|
+
const command = getTerminalCommand(
|
|
152
|
+
"claude",
|
|
153
|
+
{ url: CONNECTION.url, file },
|
|
154
|
+
false,
|
|
155
|
+
);
|
|
156
|
+
expect(command).toContain(expected);
|
|
83
157
|
});
|
|
84
158
|
|
|
85
159
|
it("adds --with-token before the agent flag when requested", () => {
|
|
@@ -95,26 +169,33 @@ describe("getTerminalCommand", () => {
|
|
|
95
169
|
});
|
|
96
170
|
|
|
97
171
|
describe("getRawPrompt", () => {
|
|
98
|
-
it("references the
|
|
172
|
+
it("references the file-scoped execute-code command", () => {
|
|
99
173
|
const prompt = getRawPrompt(CONNECTION, null);
|
|
100
174
|
expect(prompt).toContain(
|
|
101
|
-
"execute-code.sh --url http://localhost:8000 --
|
|
175
|
+
"execute-code.sh --url http://localhost:8000 --file notebooks/example.py",
|
|
102
176
|
);
|
|
103
177
|
expect(prompt).toContain(
|
|
104
|
-
"Connect to the notebook at: http://localhost:8000 (
|
|
178
|
+
"Connect to the notebook at: http://localhost:8000 (file notebooks/example.py)",
|
|
105
179
|
);
|
|
106
180
|
});
|
|
107
181
|
|
|
182
|
+
it("omits file targeting when the page URL has no file", () => {
|
|
183
|
+
const prompt = getRawPrompt(CONNECTION_WITHOUT_FILE, null);
|
|
184
|
+
expect(prompt).toContain("execute-code.sh --url http://localhost:8000");
|
|
185
|
+
expect(prompt).not.toContain("--file");
|
|
186
|
+
expect(prompt).not.toContain("--session");
|
|
187
|
+
});
|
|
188
|
+
|
|
108
189
|
it("omits the token hint when there is no token", () => {
|
|
109
190
|
const prompt = getRawPrompt(CONNECTION, null);
|
|
110
191
|
expect(prompt).not.toContain("--token");
|
|
111
192
|
expect(prompt).not.toContain("auth token");
|
|
112
193
|
});
|
|
113
194
|
|
|
114
|
-
it("includes a
|
|
195
|
+
it("includes a file-scoped token hint when a token is present", () => {
|
|
115
196
|
const prompt = getRawPrompt(CONNECTION, "secret-token");
|
|
116
197
|
expect(prompt).toContain(
|
|
117
|
-
"execute-code.sh --url http://localhost:8000 --
|
|
198
|
+
"execute-code.sh --url http://localhost:8000 --file notebooks/example.py --token secret-token",
|
|
118
199
|
);
|
|
119
200
|
});
|
|
120
201
|
|
|
@@ -128,9 +209,9 @@ describe("getRawPrompt", () => {
|
|
|
128
209
|
expect(prompt).toMatchInlineSnapshot(`
|
|
129
210
|
"Use the /marimo-pair skill to pair-program on a running marimo notebook.
|
|
130
211
|
|
|
131
|
-
Connect to the notebook at: http://localhost:8000 (
|
|
212
|
+
Connect to the notebook at: http://localhost:8000 (file notebooks/example.py)
|
|
132
213
|
|
|
133
|
-
Use \`execute-code.sh --url http://localhost:8000 --
|
|
214
|
+
Use \`execute-code.sh --url http://localhost:8000 --file notebooks/example.py\` from the marimo-pair skill to execute code in the notebook.
|
|
134
215
|
|
|
135
216
|
Once you are connected, send a fun toast (mo.status.toast(...)) to the user inside marimo letting them know you're ready to pair."
|
|
136
217
|
`);
|
|
@@ -4,39 +4,58 @@ import { describe, expect, it, vi } from "vitest";
|
|
|
4
4
|
import { runServerSidePDFDownload } from "../pdf-export";
|
|
5
5
|
|
|
6
6
|
describe("runServerSidePDFDownload", () => {
|
|
7
|
-
it("
|
|
8
|
-
const
|
|
7
|
+
it("captures current outputs before downloading the PDF", async () => {
|
|
8
|
+
const calls: string[] = [];
|
|
9
|
+
const captureOutputs = vi.fn(async () => {
|
|
10
|
+
calls.push("capture:start");
|
|
11
|
+
await Promise.resolve();
|
|
12
|
+
calls.push("capture:end");
|
|
13
|
+
});
|
|
14
|
+
const downloadPDF = vi.fn(async () => {
|
|
15
|
+
calls.push("download");
|
|
16
|
+
});
|
|
9
17
|
|
|
10
18
|
await runServerSidePDFDownload({
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
exportOptions: {
|
|
20
|
+
webpdf: false,
|
|
21
|
+
preset: "document",
|
|
22
|
+
includeInputs: true,
|
|
23
|
+
includeOutputs: true,
|
|
24
|
+
},
|
|
25
|
+
captureOutputs,
|
|
13
26
|
downloadPDF,
|
|
14
27
|
});
|
|
15
28
|
|
|
29
|
+
expect(calls).toEqual(["capture:start", "capture:end", "download"]);
|
|
16
30
|
expect(downloadPDF).toHaveBeenCalledWith({
|
|
17
|
-
filename: "slides.py",
|
|
18
31
|
webpdf: false,
|
|
19
32
|
preset: "document",
|
|
20
33
|
includeInputs: true,
|
|
21
|
-
|
|
34
|
+
includeOutputs: true,
|
|
22
35
|
});
|
|
23
36
|
});
|
|
24
37
|
|
|
25
|
-
it("
|
|
38
|
+
it("skips browser capture when outputs are excluded", async () => {
|
|
39
|
+
const captureOutputs = vi.fn().mockResolvedValue(undefined);
|
|
26
40
|
const downloadPDF = vi.fn().mockResolvedValue(undefined);
|
|
27
41
|
|
|
28
42
|
await runServerSidePDFDownload({
|
|
29
|
-
|
|
30
|
-
|
|
43
|
+
exportOptions: {
|
|
44
|
+
webpdf: true,
|
|
45
|
+
preset: "slides",
|
|
46
|
+
includeInputs: false,
|
|
47
|
+
includeOutputs: false,
|
|
48
|
+
},
|
|
49
|
+
captureOutputs,
|
|
31
50
|
downloadPDF,
|
|
32
51
|
});
|
|
33
52
|
|
|
53
|
+
expect(captureOutputs).not.toHaveBeenCalled();
|
|
34
54
|
expect(downloadPDF).toHaveBeenCalledWith({
|
|
35
|
-
|
|
36
|
-
webpdf: false,
|
|
55
|
+
webpdf: true,
|
|
37
56
|
preset: "slides",
|
|
38
|
-
includeInputs:
|
|
39
|
-
|
|
57
|
+
includeInputs: false,
|
|
58
|
+
includeOutputs: false,
|
|
40
59
|
});
|
|
41
60
|
});
|
|
42
61
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import { assertNever } from "@/utils/assertNever";
|
|
4
|
+
import { KnownQueryParams } from "@/core/constants";
|
|
4
5
|
|
|
5
6
|
export type AgentTab = "claude" | "codex" | "opencode" | "prompt";
|
|
6
7
|
|
|
@@ -43,14 +44,21 @@ export function shellQuote(value: string): string {
|
|
|
43
44
|
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
/** Return the server file key from a page URL, preserving its decoded value. */
|
|
48
|
+
export function getFileFromURL(href: string): string | undefined {
|
|
49
|
+
const file = new URL(href).searchParams.get(KnownQueryParams.filePath);
|
|
50
|
+
return file === null || file === "" ? undefined : file;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getFileFlag(file: string | undefined): string {
|
|
54
|
+
return file ? ` --file ${shellQuote(file)}` : "";
|
|
55
|
+
}
|
|
56
|
+
|
|
46
57
|
/** Identifies the specific running notebook to pair on. */
|
|
47
58
|
export interface ConnectionInfo {
|
|
48
59
|
url: string;
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
* guessing when multiple sessions are open on the same server.
|
|
52
|
-
*/
|
|
53
|
-
sessionId: string;
|
|
60
|
+
/** The server's file key, when the page URL identifies a notebook. */
|
|
61
|
+
file?: string;
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
/**
|
|
@@ -59,11 +67,12 @@ export interface ConnectionInfo {
|
|
|
59
67
|
*/
|
|
60
68
|
export function getTerminalCommand(
|
|
61
69
|
agent: Exclude<AgentTab, "prompt">,
|
|
62
|
-
{ url,
|
|
70
|
+
{ url, file }: ConnectionInfo,
|
|
63
71
|
withToken: boolean,
|
|
64
72
|
): string {
|
|
73
|
+
const fileFlag = getFileFlag(file);
|
|
65
74
|
const tokenFlag = withToken ? " --with-token" : "";
|
|
66
|
-
const base = `${getMarimoCommand()} pair prompt --url ${shellQuote(url)}
|
|
75
|
+
const base = `${getMarimoCommand()} pair prompt --url ${shellQuote(url)}${fileFlag}${tokenFlag}`;
|
|
67
76
|
switch (agent) {
|
|
68
77
|
case "claude":
|
|
69
78
|
return `claude "$(${base} --claude)"`;
|
|
@@ -82,17 +91,19 @@ export function getTerminalCommand(
|
|
|
82
91
|
* an agent behaves the same as the terminal commands.
|
|
83
92
|
*/
|
|
84
93
|
export function getRawPrompt(
|
|
85
|
-
{ url,
|
|
94
|
+
{ url, file }: ConnectionInfo,
|
|
86
95
|
token: string | null,
|
|
87
96
|
): string {
|
|
88
|
-
const
|
|
97
|
+
const fileFlag = getFileFlag(file);
|
|
98
|
+
const fileHint = file ? ` (file ${file})` : "";
|
|
99
|
+
const executeCmd = `execute-code.sh --url ${shellQuote(url)}${fileFlag}`;
|
|
89
100
|
const tokenHint = token
|
|
90
101
|
? `\n\nUse this auth token when calling \`execute-code.sh\`: \`${executeCmd} --token ${shellQuote(token)}\`.`
|
|
91
102
|
: "";
|
|
92
103
|
return [
|
|
93
104
|
"Use the /marimo-pair skill to pair-program on a running marimo notebook.",
|
|
94
105
|
"",
|
|
95
|
-
`Connect to the notebook at: ${url}
|
|
106
|
+
`Connect to the notebook at: ${url}${fileHint}`,
|
|
96
107
|
"",
|
|
97
108
|
`Use \`${executeCmd}\` from the marimo-pair skill to execute code in the notebook.${tokenHint}`,
|
|
98
109
|
"",
|
|
@@ -16,12 +16,12 @@ import { Events } from "@/utils/events";
|
|
|
16
16
|
import { Tooltip } from "@/components/ui/tooltip";
|
|
17
17
|
import { asRemoteURL, useRuntimeManager } from "@/core/runtime/config";
|
|
18
18
|
import { API } from "@/core/network/api";
|
|
19
|
-
import { getSessionId } from "@/core/kernel/session";
|
|
20
19
|
import {
|
|
21
20
|
AGENT_LABELS,
|
|
22
21
|
AGENT_TABS,
|
|
23
22
|
type AgentTab,
|
|
24
23
|
type ConnectionInfo,
|
|
24
|
+
getFileFromURL,
|
|
25
25
|
getRawPrompt,
|
|
26
26
|
getTerminalCommand,
|
|
27
27
|
maskToken,
|
|
@@ -53,7 +53,7 @@ export const PairWithAgentModal: React.FC<{
|
|
|
53
53
|
const hasToken = Boolean(authToken);
|
|
54
54
|
const connection: ConnectionInfo = {
|
|
55
55
|
url: runtimeManager.httpURL.toString(),
|
|
56
|
-
|
|
56
|
+
file: getFileFromURL(window.location.href),
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
return (
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
type Preset = "document" | "slides";
|
|
4
|
-
|
|
5
|
-
filename: string;
|
|
4
|
+
interface PDFExportOptions {
|
|
6
5
|
webpdf: boolean;
|
|
7
6
|
preset: Preset;
|
|
8
7
|
includeInputs: boolean;
|
|
9
|
-
|
|
10
|
-
}
|
|
8
|
+
includeOutputs: boolean;
|
|
9
|
+
}
|
|
10
|
+
type DownloadPDF = (opts: PDFExportOptions) => Promise<void>;
|
|
11
11
|
|
|
12
12
|
export async function runServerSidePDFDownload(opts: {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
exportOptions: PDFExportOptions;
|
|
14
|
+
captureOutputs: () => Promise<void>;
|
|
15
15
|
downloadPDF: DownloadPDF;
|
|
16
16
|
}): Promise<void> {
|
|
17
|
-
const {
|
|
17
|
+
const { exportOptions, captureOutputs, downloadPDF } = opts;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
includeInputs: true,
|
|
24
|
-
rasterServer: "static",
|
|
25
|
-
});
|
|
19
|
+
if (exportOptions.includeOutputs) {
|
|
20
|
+
await captureOutputs();
|
|
21
|
+
}
|
|
22
|
+
await downloadPDF(exportOptions);
|
|
26
23
|
}
|
|
@@ -83,6 +83,7 @@ import {
|
|
|
83
83
|
ADD_PRINTING_CLASS,
|
|
84
84
|
downloadAsPDF,
|
|
85
85
|
downloadBlob,
|
|
86
|
+
downloadExportedFile,
|
|
86
87
|
downloadHTMLAsImage,
|
|
87
88
|
withLoadingToast,
|
|
88
89
|
} from "@/utils/download";
|
|
@@ -140,6 +141,7 @@ export function useNotebookActions() {
|
|
|
140
141
|
const {
|
|
141
142
|
exportAsIPYNB,
|
|
142
143
|
exportAsMarkdown,
|
|
144
|
+
exportAsScript,
|
|
143
145
|
readCode,
|
|
144
146
|
saveCellConfig,
|
|
145
147
|
updateCellOutputs,
|
|
@@ -192,13 +194,18 @@ export function useNotebookActions() {
|
|
|
192
194
|
}
|
|
193
195
|
|
|
194
196
|
const runDownload = async (progress: ProgressState) => {
|
|
195
|
-
await updateCellOutputsWithScreenshots({
|
|
196
|
-
takeScreenshots: () => takeScreenshots({ progress }),
|
|
197
|
-
updateCellOutputs,
|
|
198
|
-
});
|
|
199
197
|
await runServerSidePDFDownload({
|
|
200
|
-
|
|
201
|
-
|
|
198
|
+
exportOptions: {
|
|
199
|
+
webpdf: false,
|
|
200
|
+
preset,
|
|
201
|
+
includeInputs: true,
|
|
202
|
+
includeOutputs: true,
|
|
203
|
+
},
|
|
204
|
+
captureOutputs: () =>
|
|
205
|
+
updateCellOutputsWithScreenshots({
|
|
206
|
+
takeScreenshots: () => takeScreenshots({ progress }),
|
|
207
|
+
updateCellOutputs,
|
|
208
|
+
}),
|
|
202
209
|
downloadPDF: downloadAsPDF,
|
|
203
210
|
});
|
|
204
211
|
};
|
|
@@ -231,11 +238,8 @@ export function useNotebookActions() {
|
|
|
231
238
|
takeScreenshots: () => takeScreenshots({ progress }),
|
|
232
239
|
updateCellOutputs,
|
|
233
240
|
});
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
new Blob([ipynb], { type: "application/x-ipynb+json" }),
|
|
237
|
-
Filenames.toIPYNB(document.title),
|
|
238
|
-
);
|
|
241
|
+
const exportedFile = await exportAsIPYNB({ download: false });
|
|
242
|
+
downloadExportedFile(exportedFile);
|
|
239
243
|
};
|
|
240
244
|
|
|
241
245
|
await withLoadingToast("Downloading IPYNB...", runDownload);
|
|
@@ -255,7 +259,7 @@ export function useNotebookActions() {
|
|
|
255
259
|
toastNotebookMustBeNamed();
|
|
256
260
|
return;
|
|
257
261
|
}
|
|
258
|
-
await downloadAsHTML({
|
|
262
|
+
await downloadAsHTML({ includeCode: true });
|
|
259
263
|
},
|
|
260
264
|
},
|
|
261
265
|
{
|
|
@@ -266,7 +270,7 @@ export function useNotebookActions() {
|
|
|
266
270
|
toastNotebookMustBeNamed();
|
|
267
271
|
return;
|
|
268
272
|
}
|
|
269
|
-
await downloadAsHTML({
|
|
273
|
+
await downloadAsHTML({ includeCode: false });
|
|
270
274
|
},
|
|
271
275
|
},
|
|
272
276
|
{
|
|
@@ -275,11 +279,8 @@ export function useNotebookActions() {
|
|
|
275
279
|
),
|
|
276
280
|
label: "Download as Markdown",
|
|
277
281
|
handle: async () => {
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
new Blob([md], { type: "text/plain" }),
|
|
281
|
-
Filenames.toMarkdown(document.title),
|
|
282
|
-
);
|
|
282
|
+
const exportedFile = await exportAsMarkdown({ download: false });
|
|
283
|
+
downloadExportedFile(exportedFile);
|
|
283
284
|
},
|
|
284
285
|
},
|
|
285
286
|
{
|
|
@@ -289,7 +290,7 @@ export function useNotebookActions() {
|
|
|
289
290
|
},
|
|
290
291
|
{
|
|
291
292
|
icon: <CodeIcon size={14} strokeWidth={1.5} />,
|
|
292
|
-
label: "Download
|
|
293
|
+
label: "Download notebook source",
|
|
293
294
|
handle: async () => {
|
|
294
295
|
const code = await readCode();
|
|
295
296
|
downloadBlob(
|
|
@@ -298,6 +299,14 @@ export function useNotebookActions() {
|
|
|
298
299
|
);
|
|
299
300
|
},
|
|
300
301
|
},
|
|
302
|
+
{
|
|
303
|
+
icon: <CodeIcon size={14} strokeWidth={1.5} />,
|
|
304
|
+
label: "Download flat script",
|
|
305
|
+
handle: async () => {
|
|
306
|
+
const exportedFile = await exportAsScript({ download: false });
|
|
307
|
+
downloadExportedFile(exportedFile);
|
|
308
|
+
},
|
|
309
|
+
},
|
|
301
310
|
{
|
|
302
311
|
divider: true,
|
|
303
312
|
icon: <ImageIcon size={14} strokeWidth={1.5} />,
|