@marimo-team/islands 0.23.16-dev5 → 0.23.16-dev51

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 (156) hide show
  1. package/dist/{ConnectedDataExplorerComponent-CJaUI-S-.js → ConnectedDataExplorerComponent-f9vLjQiF.js} +13 -13
  2. package/dist/{ErrorBoundary-DXlxsrTF.js → ErrorBoundary-DhLqwSWA.js} +3 -3
  3. package/dist/{any-language-editor-P9tjkj4n.js → any-language-editor-DifE-fl7.js} +5 -5
  4. package/dist/{button-BcSml68y.js → button-BSm8IXRU.js} +2 -4
  5. package/dist/{capabilities-BYLFYTYv.js → capabilities-C6OQ5YBO.js} +1 -1
  6. package/dist/{chat-ui-BdSDiVjk.js → chat-ui-1e7PcW56.js} +3117 -3120
  7. package/dist/{check-Cs-KV5XY.js → check-DP7U0H0G.js} +1 -1
  8. package/dist/{code-visibility-C4wLKnSb.js → common-CD6phlRu.js} +1046 -1014
  9. package/dist/{copy-Cs3yt6Vt.js → copy-DNq8q3zw.js} +2 -2
  10. package/dist/{dist-B96tMAst.js → dist-DIlxLFXG.js} +2 -2
  11. package/dist/{error-banner-DR7o3CbX.js → error-banner-B_GQfxxD.js} +2 -2
  12. package/dist/{esm-k8PIvuZW.js → esm-DzZVaNH4.js} +1 -1
  13. package/dist/{extends-Cq2JYHKy.js → extends-w2_S44bV.js} +4 -4
  14. package/dist/{formats-BFhkZJwd.js → formats-Dwq1THhr.js} +3 -3
  15. package/dist/{glide-data-editor--CaN-f27.js → glide-data-editor-B9K6-MJe.js} +9 -9
  16. package/dist/{html-to-image-DDENewl2.js → html-to-image-3w0AakWW.js} +7164 -6240
  17. package/dist/{input-DStQIuqD.js → input-C5K4VBvB.js} +7 -7
  18. package/dist/{label-DIk0QoFe.js → label-DjoYwqmj.js} +2 -2
  19. package/dist/{loader-CTHCI-qe.js → loader-DX-IDS7n.js} +1 -1
  20. package/dist/main.js +1010 -1019
  21. package/dist/{mermaid-CdSvixW2.js → mermaid-hv6IckVw.js} +5 -5
  22. package/dist/{node-sql-parser-DLl_zNw0.js → node-sql-parser-v1Vi-Fft.js} +16867 -16665
  23. package/dist/{process-output-2QPcgBQg.js → process-output-BRwR4QGs.js} +32 -28
  24. package/dist/{reveal-component-BSD4w8YU.js → reveal-component-DmGGKS8z.js} +725 -643
  25. package/dist/{spec-CnaxwDqy.js → spec-CQKL_D3i.js} +4 -4
  26. package/dist/{strings-BYAhZnQi.js → strings-DIy9NAmg.js} +4 -4
  27. package/dist/style.css +1 -1
  28. package/dist/{swiper-component-DE94711u.js → swiper-component-CEdAYjb7.js} +2 -2
  29. package/dist/toDate-CqhBWjvO.js +713 -0
  30. package/dist/{tooltip-B-qh7UPB.js → tooltip-f-qR0iUx.js} +3 -3
  31. package/dist/{types-DQl7jVYK.js → types-DicH9Oi0.js} +1 -1
  32. package/dist/{useAsyncData-CvO8WUy3.js → useAsyncData-CYOQb1EW.js} +1 -1
  33. package/dist/{useDateFormatter-BSoGim-G.js → useDateFormatter-Bt2qr_XS.js} +2 -2
  34. package/dist/{useDeepCompareMemoize-J3MKRdA4.js → useDeepCompareMemoize-CSHQeQEI.js} +1 -1
  35. package/dist/{useIframeCapabilities-POcFXHbw.js → useIframeCapabilities-kA09ykNq.js} +1 -1
  36. package/dist/{useLifecycle-DqPxHgAN.js → useLifecycle-CMJGqBaY.js} +3 -3
  37. package/dist/{useTheme-XMq9mNf_.js → useTheme-DYfby65G.js} +2 -2
  38. package/dist/{vega-component-CrFoZT1S.js → vega-component-C7nO5zcf.js} +10 -10
  39. package/dist/{zod-D0yOqoGe.js → zod-BUcyXSdR.js} +1 -1
  40. package/package.json +3 -4
  41. package/src/__mocks__/requests.ts +45 -4
  42. package/src/components/data-table/__tests__/__snapshots__/chart-spec-model.test.ts.snap +174 -21
  43. package/src/components/data-table/__tests__/chart-spec-model.test.ts +102 -1
  44. package/src/components/data-table/column-summary/chart-spec-model.tsx +163 -103
  45. package/src/components/data-table/column-summary/legacy-chart-spec.ts +15 -7
  46. package/src/components/data-table/column-summary/utils.ts +26 -7
  47. package/src/components/data-table/types.ts +1 -1
  48. package/src/components/editor/__tests__/viewer-banner.test.tsx +14 -0
  49. package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +99 -18
  50. package/src/components/editor/actions/__tests__/pdf-export.test.ts +32 -13
  51. package/src/components/editor/actions/pair-with-agent-commands.ts +21 -10
  52. package/src/components/editor/actions/pair-with-agent-modal.tsx +2 -2
  53. package/src/components/editor/actions/pdf-export.ts +11 -14
  54. package/src/components/editor/actions/useNotebookActions.tsx +18 -18
  55. package/src/components/editor/cell/code/__tests__/cell-editor-activity-lifecycle.test.ts +250 -0
  56. package/src/components/editor/cell/code/cell-editor.tsx +13 -7
  57. package/src/components/editor/chrome/panels/__tests__/logs-panel.test.tsx +25 -0
  58. package/src/components/editor/chrome/panels/logs-panel.tsx +12 -2
  59. package/src/components/editor/chrome/panels/write-secret-modal.tsx +40 -12
  60. package/src/components/editor/connections/__tests__/json-credentials.test.ts +114 -0
  61. package/src/components/editor/connections/__tests__/paths.test.ts +39 -0
  62. package/src/components/editor/connections/components.tsx +6 -2
  63. package/src/components/editor/connections/database/__tests__/__snapshots__/as-code.test.ts.snap +21 -5
  64. package/src/components/editor/connections/database/__tests__/as-code.test.ts +17 -0
  65. package/src/components/editor/connections/database/as-code.ts +16 -2
  66. package/src/components/editor/connections/database/schemas.ts +6 -5
  67. package/src/components/editor/connections/form-renderers.tsx +99 -1
  68. package/src/components/editor/connections/json-credentials.ts +57 -0
  69. package/src/components/editor/connections/paths.ts +21 -0
  70. package/src/components/editor/connections/secret-combobox.tsx +41 -20
  71. package/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap +88 -2
  72. package/src/components/editor/connections/storage/__tests__/as-code.test.ts +128 -8
  73. package/src/components/editor/connections/storage/as-code.ts +79 -36
  74. package/src/components/editor/connections/storage/schemas.ts +85 -44
  75. package/src/components/editor/file-tree/__tests__/renderers.test.ts +31 -0
  76. package/src/components/editor/file-tree/file-viewer.tsx +11 -7
  77. package/src/components/editor/file-tree/renderers.tsx +21 -0
  78. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +1 -1
  79. package/src/components/editor/viewer-banner.tsx +6 -1
  80. package/src/components/forms/options.ts +2 -1
  81. package/src/components/slides/__tests__/cell-output-block.test.tsx +40 -0
  82. package/src/components/slides/__tests__/slide-cell-view.test.tsx +33 -0
  83. package/src/components/slides/__tests__/slide-scroll-hint.test.tsx +198 -0
  84. package/src/components/slides/reveal-component.tsx +25 -19
  85. package/src/components/slides/slide-cell-view.tsx +1 -1
  86. package/src/components/slides/slide-scroll-hint.tsx +161 -0
  87. package/src/components/slides/slides.css +4 -2
  88. package/src/components/static-html/share-modal.tsx +1 -1
  89. package/src/components/ui/input.tsx +1 -1
  90. package/src/core/ai/context/providers/file.ts +8 -29
  91. package/src/core/cells/__tests__/cells.test.ts +12 -2
  92. package/src/core/cells/__tests__/logs.test.ts +5 -5
  93. package/src/core/cells/cells.ts +17 -4
  94. package/src/core/cells/document-changes.ts +1 -0
  95. package/src/core/cells/logs.ts +14 -4
  96. package/src/core/codemirror/copilot/__tests__/language-server.test.ts +396 -100
  97. package/src/core/codemirror/copilot/__tests__/transport.test.ts +128 -540
  98. package/src/core/codemirror/copilot/language-server.ts +182 -70
  99. package/src/core/codemirror/copilot/transport.ts +15 -207
  100. package/src/core/codemirror/copilot/types.ts +9 -2
  101. package/src/core/codemirror/find-replace/__tests__/navigate.test.ts +42 -30
  102. package/src/core/codemirror/find-replace/navigate.ts +2 -0
  103. package/src/core/codemirror/go-to-definition/__tests__/commands.test.ts +24 -3
  104. package/src/core/codemirror/go-to-definition/commands.ts +3 -0
  105. package/src/core/codemirror/keymaps/__tests__/keymaps.test.ts +31 -2
  106. package/src/core/codemirror/keymaps/keymaps.ts +12 -0
  107. package/src/core/codemirror/language/__tests__/sql.test.ts +443 -61
  108. package/src/core/codemirror/language/languages/python.ts +23 -11
  109. package/src/core/codemirror/language/languages/sql/completion-store.ts +5 -1
  110. package/src/core/codemirror/language/languages/sql/sql.ts +210 -3
  111. package/src/core/codemirror/lsp/__tests__/federated-lsp.test.ts +161 -0
  112. package/src/core/codemirror/lsp/__tests__/log-messages.test.ts +53 -0
  113. package/src/core/codemirror/lsp/__tests__/normalize-markdown-math.test.ts +25 -0
  114. package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +598 -156
  115. package/src/core/codemirror/lsp/__tests__/transports.test.ts +112 -0
  116. package/src/core/codemirror/lsp/federated-lsp.ts +76 -23
  117. package/src/core/codemirror/lsp/log-messages.ts +37 -0
  118. package/src/core/codemirror/lsp/normalize-markdown-math.ts +8 -4
  119. package/src/core/codemirror/lsp/notebook-lsp.ts +220 -56
  120. package/src/core/codemirror/lsp/transports.ts +8 -1
  121. package/src/core/codemirror/lsp/types.ts +68 -8
  122. package/src/core/codemirror/lsp/utils.ts +14 -0
  123. package/src/core/codemirror/utils.ts +28 -0
  124. package/src/core/edit-app.tsx +1 -2
  125. package/src/core/export/__tests__/hooks.test.ts +2 -4
  126. package/src/core/export/hooks.ts +4 -3
  127. package/src/core/hotkeys/hotkeys.ts +0 -2
  128. package/src/core/islands/__tests__/bridge.test.ts +107 -0
  129. package/src/core/islands/bridge.ts +16 -0
  130. package/src/core/lsp/__tests__/transport.test.ts +509 -337
  131. package/src/core/lsp/transport.ts +304 -132
  132. package/src/core/mode.ts +10 -0
  133. package/src/core/network/__tests__/api.test.ts +42 -0
  134. package/src/core/network/__tests__/connection.test.ts +45 -0
  135. package/src/core/network/__tests__/requests-lazy.test.ts +32 -1
  136. package/src/core/network/__tests__/requests-network.test.ts +21 -0
  137. package/src/core/network/api.ts +27 -0
  138. package/src/core/network/connection.ts +15 -0
  139. package/src/core/network/requests-lazy.ts +1 -0
  140. package/src/core/network/requests-network.ts +14 -8
  141. package/src/core/network/requests-static.ts +1 -0
  142. package/src/core/network/requests-toasting.tsx +1 -0
  143. package/src/core/network/types.ts +22 -6
  144. package/src/core/rtc/state.ts +9 -0
  145. package/src/core/static/download-html.ts +5 -14
  146. package/src/core/wasm/bridge.ts +4 -2
  147. package/src/core/wasm/worker/types.ts +5 -2
  148. package/src/css/app/codemirror.css +16 -2
  149. package/src/plugins/impl/FormPlugin.tsx +1 -1
  150. package/src/plugins/impl/__tests__/FormPlugin.test.tsx +162 -0
  151. package/src/stories/log-viewer.stories.tsx +12 -6
  152. package/src/utils/__tests__/blob.test.ts +27 -1
  153. package/src/utils/__tests__/download.test.tsx +44 -4
  154. package/src/utils/blob.ts +24 -1
  155. package/src/utils/download.ts +14 -15
  156. 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
- sessionId: "s_ab12cd",
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("s_ab12cd")).toBe("s_ab12cd");
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 session for each agent", () => {
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 --session s_ab12cd --claude)"`,
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 --session s_ab12cd --codex)"`,
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 --session s_ab12cd --opencode)"`,
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("always targets the given session, not a random one", () => {
72
- const command = getTerminalCommand("claude", CONNECTION, false);
73
- expect(command).toContain("--session s_ab12cd");
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?file=a&b", sessionId: "s_ab12cd" },
132
+ { url: "http://host:8000?auth=a&b", file: "notebook.py" },
80
133
  false,
81
134
  );
82
- expect(command).toContain("--url 'http://host:8000?file=a&b'");
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 session-scoped execute-code command", () => {
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 --session s_ab12cd",
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 (session s_ab12cd)",
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 session-scoped token hint when a token is present", () => {
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 --session s_ab12cd --token secret-token",
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 (session s_ab12cd)
212
+ Connect to the notebook at: http://localhost:8000 (file notebooks/example.py)
132
213
 
133
- Use \`execute-code.sh --url http://localhost:8000 --session s_ab12cd\` from the marimo-pair skill to execute code in the notebook.
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("downloads document preset via backend PDF endpoint", async () => {
8
- const downloadPDF = vi.fn().mockResolvedValue(undefined);
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
- filename: "slides.py",
12
- preset: "document",
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
- rasterServer: "static",
34
+ includeOutputs: true,
22
35
  });
23
36
  });
24
37
 
25
- it("downloads slides preset via backend PDF endpoint", async () => {
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
- filename: "slides.py",
30
- preset: "slides",
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
- filename: "slides.py",
36
- webpdf: false,
55
+ webpdf: true,
37
56
  preset: "slides",
38
- includeInputs: true,
39
- rasterServer: "static",
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
- * The current session id, so agents connect to *this* notebook rather than
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, sessionId }: ConnectionInfo,
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)} --session ${shellQuote(sessionId)}${tokenFlag}`;
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, sessionId }: ConnectionInfo,
94
+ { url, file }: ConnectionInfo,
86
95
  token: string | null,
87
96
  ): string {
88
- const executeCmd = `execute-code.sh --url ${shellQuote(url)} --session ${shellQuote(sessionId)}`;
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} (session ${sessionId})`,
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
- sessionId: getSessionId(),
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
- type DownloadPDF = (opts: {
5
- filename: string;
4
+ interface PDFExportOptions {
6
5
  webpdf: boolean;
7
6
  preset: Preset;
8
7
  includeInputs: boolean;
9
- rasterServer: "live" | "static";
10
- }) => Promise<void>;
8
+ includeOutputs: boolean;
9
+ }
10
+ type DownloadPDF = (opts: PDFExportOptions) => Promise<void>;
11
11
 
12
12
  export async function runServerSidePDFDownload(opts: {
13
- filename: string;
14
- preset: Preset;
13
+ exportOptions: PDFExportOptions;
14
+ captureOutputs: () => Promise<void>;
15
15
  downloadPDF: DownloadPDF;
16
16
  }): Promise<void> {
17
- const { filename, preset, downloadPDF } = opts;
17
+ const { exportOptions, captureOutputs, downloadPDF } = opts;
18
18
 
19
- await downloadPDF({
20
- filename,
21
- webpdf: false,
22
- preset,
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";
@@ -192,13 +193,18 @@ export function useNotebookActions() {
192
193
  }
193
194
 
194
195
  const runDownload = async (progress: ProgressState) => {
195
- await updateCellOutputsWithScreenshots({
196
- takeScreenshots: () => takeScreenshots({ progress }),
197
- updateCellOutputs,
198
- });
199
196
  await runServerSidePDFDownload({
200
- filename,
201
- preset,
197
+ exportOptions: {
198
+ webpdf: false,
199
+ preset,
200
+ includeInputs: true,
201
+ includeOutputs: true,
202
+ },
203
+ captureOutputs: () =>
204
+ updateCellOutputsWithScreenshots({
205
+ takeScreenshots: () => takeScreenshots({ progress }),
206
+ updateCellOutputs,
207
+ }),
202
208
  downloadPDF: downloadAsPDF,
203
209
  });
204
210
  };
@@ -231,11 +237,8 @@ export function useNotebookActions() {
231
237
  takeScreenshots: () => takeScreenshots({ progress }),
232
238
  updateCellOutputs,
233
239
  });
234
- const ipynb = await exportAsIPYNB({ download: false });
235
- downloadBlob(
236
- new Blob([ipynb], { type: "application/x-ipynb+json" }),
237
- Filenames.toIPYNB(document.title),
238
- );
240
+ const exportedFile = await exportAsIPYNB({ download: false });
241
+ downloadExportedFile(exportedFile);
239
242
  };
240
243
 
241
244
  await withLoadingToast("Downloading IPYNB...", runDownload);
@@ -255,7 +258,7 @@ export function useNotebookActions() {
255
258
  toastNotebookMustBeNamed();
256
259
  return;
257
260
  }
258
- await downloadAsHTML({ filename, includeCode: true });
261
+ await downloadAsHTML({ includeCode: true });
259
262
  },
260
263
  },
261
264
  {
@@ -266,7 +269,7 @@ export function useNotebookActions() {
266
269
  toastNotebookMustBeNamed();
267
270
  return;
268
271
  }
269
- await downloadAsHTML({ filename, includeCode: false });
272
+ await downloadAsHTML({ includeCode: false });
270
273
  },
271
274
  },
272
275
  {
@@ -275,11 +278,8 @@ export function useNotebookActions() {
275
278
  ),
276
279
  label: "Download as Markdown",
277
280
  handle: async () => {
278
- const md = await exportAsMarkdown({ download: false });
279
- downloadBlob(
280
- new Blob([md], { type: "text/plain" }),
281
- Filenames.toMarkdown(document.title),
282
- );
281
+ const exportedFile = await exportAsMarkdown({ download: false });
282
+ downloadExportedFile(exportedFile);
283
283
  },
284
284
  },
285
285
  {