@marimo-team/islands 0.25.3-dev388 → 0.25.3-dev394

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 (166) hide show
  1. package/dist/{ConnectedDataExplorerComponent-BpCrAeX0.js → ConnectedDataExplorerComponent-1DGGwl88.js} +9 -9
  2. package/dist/{ErrorBoundary-_mFP3LkM.js → ErrorBoundary-DDIASniH.js} +6 -6
  3. package/dist/{abnfDiagram-VCTEODGH-ZqNgGZlz.js → abnfDiagram-VCTEODGH-CeQEbVik.js} +2 -2
  4. package/dist/{any-language-editor-CFbAr7vc.js → any-language-editor-C_s_ZoaK.js} +2 -2
  5. package/dist/{architectureDiagram-5GKGNRK7-BEUaR96d.js → architectureDiagram-5GKGNRK7-C8xUpTAb.js} +1 -1
  6. package/dist/{assertNever-5uYEbJc8.js → assertNever-DXGfUmPW.js} +2 -2
  7. package/dist/assets/__vite-browser-external-C9HF3uHE.js +1 -0
  8. package/dist/assets/worker-B4Cpvr8b.js +171 -0
  9. package/dist/{chat-ui-BKSYhGMh.js → chat-ui-B6bY_0LF.js} +774 -774
  10. package/dist/{check-BbhVyViy.js → check-ywinAQy6.js} +1 -1
  11. package/dist/{chunk-IMKFNOWR-BdEPmWQI.js → chunk-IMKFNOWR-DY7AWyNi.js} +1 -1
  12. package/dist/{chunk-SHT3W25Y-IvvXM3xf.js → chunk-SHT3W25Y-D4epY9MY.js} +1 -1
  13. package/dist/{chunk-SVP7TREG-C_qpJUv1.js → chunk-SVP7TREG-CKsl2Q6r.js} +1 -1
  14. package/dist/{chunk-TICWLB2K-C4agYVWP.js → chunk-TICWLB2K-CMsD2y0F.js} +1 -1
  15. package/dist/{classDiagram-ZZMXUADV-CT2iq8uF.js → classDiagram-ZZMXUADV-C4FsLnvt.js} +2 -2
  16. package/dist/{classDiagram-v2-VYDZK3BY-Coe_dD0r.js → classDiagram-v2-VYDZK3BY-BJRuFZeI.js} +2 -2
  17. package/dist/{code-visibility-DkMNjdNe.js → code-visibility-CByYqwFv.js} +13 -13
  18. package/dist/{common-Ces9ooG_.js → common-KkgATX2Y.js} +4918 -4910
  19. package/dist/{config-DJ8M-gPL.js → config-DOwBtRkI.js} +3 -3
  20. package/dist/{copy-icon-xWvA8ybp.js → copy-icon-BKcX0ltw.js} +2 -2
  21. package/dist/{createReducer-fp0gX_9U.js → createReducer-Bjx6kuxh.js} +1 -1
  22. package/dist/{cynefinDiagram-5FMLGOSQ-D0LKziUu.js → cynefinDiagram-5FMLGOSQ-DyI_lSsn.js} +1 -1
  23. package/dist/{dagre-GXQ25YYZ-Cmgziaw8.js → dagre-GXQ25YYZ-Buoy6sX-.js} +1 -1
  24. package/dist/{data-grid-overlay-editor-uNMslVKY.js → data-grid-overlay-editor-BHrTJhN3.js} +1 -1
  25. package/dist/{diagram-S7CK7UJ4-D-lZsALU.js → diagram-S7CK7UJ4-CbSD1DUy.js} +1 -1
  26. package/dist/{diagram-UQ7AKVKN-TcbdsFoT.js → diagram-UQ7AKVKN-Dapj2rQm.js} +1 -1
  27. package/dist/{diagram-VX7I27RA-D5BqZi1q.js → diagram-VX7I27RA-CxA3txtC.js} +1 -1
  28. package/dist/{diagram-Z3DM3KII-MNc7jqvr.js → diagram-Z3DM3KII-BEZqz916.js} +1 -1
  29. package/dist/{dialog-Cm0VGdxc.js → dialog-mwa6XN15.js} +2 -2
  30. package/dist/{dropdown-menu-DfamXjVI.js → dropdown-menu-CmgUseHo.js} +5 -5
  31. package/dist/duckdb-keywords-CdzX4o33.js +3 -0
  32. package/dist/{ebnfDiagram-PWID7BFC-Cxt6ywyX.js → ebnfDiagram-PWID7BFC-Dmw-1JV3.js} +2 -2
  33. package/dist/{erDiagram-RLTQ6QDP-BLF-askI.js → erDiagram-RLTQ6QDP-DZpG4cbm.js} +1 -1
  34. package/dist/{error-banner-k06CAftu.js → error-banner-CHPLqogX.js} +1 -1
  35. package/dist/{error-entries-rtPWQkJk.js → error-entries-Bk96zt4w.js} +825 -690
  36. package/dist/{feedback-button-i960qUnq.js → feedback-button-2FaWjlaR.js} +12 -12
  37. package/dist/{flowDiagram-HODETNUW-CsLw2mWn.js → flowDiagram-HODETNUW-B02oHnBv.js} +2 -2
  38. package/dist/{formats-DQ-qq-dU.js → formats-BDqe9cfr.js} +1 -1
  39. package/dist/{glide-data-editor-_EEhlGzS.js → glide-data-editor-B9Yq6Wg1.js} +11 -11
  40. package/dist/{glide-utils-CHrghEu-.js → glide-utils-DYKWS2YV.js} +2 -2
  41. package/dist/{globals-DKkjIolp.js → globals-S4D5AVKN.js} +3 -3
  42. package/dist/{html-to-image-B5nTOeMI.js → html-to-image-BauFF9F_.js} +4842 -4821
  43. package/dist/{infoDiagram-27XIBGKW-CdSApBWg.js → infoDiagram-27XIBGKW-BPbQHO9m.js} +1 -1
  44. package/dist/{ishikawaDiagram-5VMMS53U-BnzQ8SI5.js → ishikawaDiagram-5VMMS53U-DmnKSNi7.js} +1 -1
  45. package/dist/{kanban-definition-UXKFOSKX-D2llTpeX.js → kanban-definition-UXKFOSKX-u5PZbsBe.js} +1 -1
  46. package/dist/main.js +6236 -6175
  47. package/dist/{mermaid-BcNMyKmf.js → mermaid-ffopDjig.js} +34 -34
  48. package/dist/{mindmap-definition-YA3MSWOX-uoEsfD5R.js → mindmap-definition-YA3MSWOX-CX187lhP.js} +1 -1
  49. package/dist/{number-overlay-editor-D5U7jbrh.js → number-overlay-editor-l7DB2HCO.js} +1 -1
  50. package/dist/{pegDiagram-XKGWAZYB-DTWrE0S4.js → pegDiagram-XKGWAZYB-Bj6HGPak.js} +2 -2
  51. package/dist/{pencil-weySvN0N.js → pencil-CijoRsa3.js} +1 -1
  52. package/dist/{pieDiagram-E7YTZNPT-COME2oGN.js → pieDiagram-E7YTZNPT-C_wIgDJM.js} +1 -1
  53. package/dist/{process-output-DNxpsd4n.js → process-output-Deae7dX1.js} +4 -4
  54. package/dist/{railroadDiagram-O6MQD6OU-CUeFcNTY.js → railroadDiagram-O6MQD6OU-CwoJvnvC.js} +2 -2
  55. package/dist/{requirementDiagram-BXWQKSXE-BUR4lDZG.js → requirementDiagram-BXWQKSXE-C8JuhLLL.js} +1 -1
  56. package/dist/{reveal-component-BM9TozVQ.js → reveal-component-VR4UzAUv.js} +37 -37
  57. package/dist/{select-Ca-POp4c.js → select-DW32QOzC.js} +4 -4
  58. package/dist/{sequenceDiagram-WJ2MYXX4-CSPmml3q.js → sequenceDiagram-WJ2MYXX4-RbrRdoiV.js} +1 -1
  59. package/dist/{spec-BgSMwzks.js → spec-Ww0JjShW.js} +4 -4
  60. package/dist/{stateDiagram-D77RDMKH-BDUC8Pi9.js → stateDiagram-D77RDMKH-DWdIvCnU.js} +2 -2
  61. package/dist/{stateDiagram-v2-MP3YSRHH-BH-qyk8a.js → stateDiagram-v2-MP3YSRHH-BG0j9crW.js} +2 -2
  62. package/dist/{static-state-Cqzv5X7B.js → static-state-CnQdTBTW.js} +1 -1
  63. package/dist/style.css +1 -1
  64. package/dist/{swimlanes-42K2YHIH-CLE9Kiir.js → swimlanes-42K2YHIH-B6zUw4gq.js} +1 -1
  65. package/dist/{swimlanesDiagram-VR7AAH4N-Cv8kWAeA.js → swimlanesDiagram-VR7AAH4N-DjVEnsIG.js} +2 -2
  66. package/dist/{timeline-definition-24CTP7MA-fbRGX21i.js → timeline-definition-24CTP7MA-DSAxwqnC.js} +1 -1
  67. package/dist/{toast-0xspcdmv.js → toast-Crofa36R.js} +3 -3
  68. package/dist/{tooltip-BwlFTaNy.js → tooltip-Bg-SDCwa.js} +1 -1
  69. package/dist/{use-restore-focus-fKgXR0nb.js → use-restore-focus-CE9Sflmg.js} +1298 -1283
  70. package/dist/{useDateFormatter-B7LvPmsw.js → useDateFormatter-D5fsC9ot.js} +2 -2
  71. package/dist/{useDeepCompareMemoize-OhBYt-q2.js → useDeepCompareMemoize-Bvrue1iy.js} +1 -1
  72. package/dist/{useLifecycle-D9xcFAIN.js → useLifecycle-Ctr5lECo.js} +1 -1
  73. package/dist/{vega-component-Chak9Aon.js → vega-component-DQZhTzVQ.js} +6 -6
  74. package/dist/{vennDiagram-4TSXK5OY-BzKtg8gL.js → vennDiagram-4TSXK5OY-FAGYRdBj.js} +1 -1
  75. package/dist/{wardleyDiagram-VM6X3IG4-R0SgDvz1.js → wardleyDiagram-VM6X3IG4-BlB973r1.js} +1 -1
  76. package/dist/{xychartDiagram-S5SC5T6Z-DRskTHEM.js → xychartDiagram-S5SC5T6Z-CywvmjIK.js} +1 -1
  77. package/package.json +2 -2
  78. package/src/__mocks__/executions.ts +48 -8
  79. package/src/__mocks__/notebook.ts +20 -42
  80. package/src/components/app-config/__tests__/add-model-discovery.test.tsx +255 -0
  81. package/src/components/app-config/__tests__/model-discovery.test.tsx +183 -0
  82. package/src/components/app-config/ai-config.tsx +20 -24
  83. package/src/components/app-config/model-discovery.tsx +118 -184
  84. package/src/components/app-config/model-provider-config.ts +25 -0
  85. package/src/components/editor/Output.tsx +5 -4
  86. package/src/components/editor/__tests__/data-attributes.test.tsx +1 -6
  87. package/src/components/editor/__tests__/dynamic-favicon.test.tsx +11 -16
  88. package/src/components/editor/__tests__/output-persistence.test.tsx +6 -24
  89. package/src/components/editor/actions/__tests__/useSetOutputsExpanded.test.ts +6 -8
  90. package/src/components/editor/actions/useSetOutputsExpanded.ts +12 -4
  91. package/src/components/editor/cell/cell-context-menu.tsx +3 -2
  92. package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +89 -72
  93. package/src/components/editor/notebook-cell.tsx +15 -10
  94. package/src/components/editor/output/console/process-output.ts +4 -2
  95. package/src/components/editor/renderers/cells-renderer.tsx +3 -1
  96. package/src/components/editor/renderers/grid-layout/__tests__/grid-layout.test.tsx +5 -11
  97. package/src/components/editor/renderers/grid-layout/grid-layout.tsx +9 -8
  98. package/src/components/editor/renderers/types.ts +2 -2
  99. package/src/components/editor/renderers/vertical-layout/utils.ts +4 -4
  100. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +5 -8
  101. package/src/components/scratchpad/scratchpad.tsx +6 -2
  102. package/src/components/slides/__tests__/cell-output-block.test.tsx +7 -8
  103. package/src/components/slides/__tests__/minimap-actions.test.tsx +3 -3
  104. package/src/components/slides/__tests__/slide-cell-view.test.tsx +1 -0
  105. package/src/components/slides/slide-cell-view.tsx +1 -3
  106. package/src/components/slides/slide.tsx +3 -3
  107. package/src/core/ai/context/__tests__/registry.test.ts +7 -11
  108. package/src/core/ai/context/providers/__tests__/cell-output.test.ts +113 -35
  109. package/src/core/ai/context/providers/__tests__/error.test.ts +74 -191
  110. package/src/core/ai/context/providers/cell-output.ts +11 -6
  111. package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +8 -103
  112. package/src/core/cells/__tests__/cells.test.ts +40 -292
  113. package/src/core/cells/__tests__/clear-outputs.test.ts +151 -0
  114. package/src/core/cells/__tests__/harness.ts +14 -12
  115. package/src/core/cells/__tests__/layout.test.ts +20 -26
  116. package/src/core/cells/__tests__/notebook-outline.test.ts +49 -43
  117. package/src/core/cells/__tests__/session.test.ts +26 -146
  118. package/src/core/cells/actions.ts +49 -9
  119. package/src/core/cells/cell.ts +0 -13
  120. package/src/core/cells/cells.ts +53 -62
  121. package/src/core/cells/focus.ts +6 -1
  122. package/src/core/cells/layout.ts +2 -3
  123. package/src/core/cells/outputs.ts +2 -2
  124. package/src/core/cells/session.ts +3 -38
  125. package/src/core/cells/types.ts +6 -8
  126. package/src/core/cells/utils.ts +4 -3
  127. package/src/core/codemirror/ai/__tests__/resources.test.ts +7 -11
  128. package/src/core/config/config-schema.ts +15 -0
  129. package/src/core/errors/__tests__/error-entries.test.ts +52 -18
  130. package/src/core/errors/error-entries.ts +21 -11
  131. package/src/core/executions/__tests__/freshness.test.ts +7 -4
  132. package/src/core/executions/__tests__/hooks.test.tsx +5 -1
  133. package/src/core/executions/__tests__/interrupt.test.ts +2 -0
  134. package/src/core/executions/__tests__/output-lifecycle.test.ts +201 -0
  135. package/src/core/executions/__tests__/output.test.ts +87 -3
  136. package/src/core/executions/__tests__/select.test.ts +17 -10
  137. package/src/core/executions/atoms.ts +73 -15
  138. package/src/core/executions/freshness.ts +1 -1
  139. package/src/core/executions/hooks.ts +18 -8
  140. package/src/core/executions/index.ts +6 -0
  141. package/src/core/executions/output.ts +122 -38
  142. package/src/core/executions/select.ts +2 -2
  143. package/src/core/export/__tests__/hooks.test.ts +20 -29
  144. package/src/core/export/hooks.ts +7 -9
  145. package/src/core/islands/__tests__/iframe-resizer.test.ts +91 -0
  146. package/src/core/islands/__tests__/main.test.ts +17 -0
  147. package/src/core/islands/components/__tests__/web-components.test.tsx +13 -15
  148. package/src/core/islands/components/output-wrapper.tsx +15 -20
  149. package/src/core/islands/iframe-resizer.ts +38 -0
  150. package/src/core/islands/main.ts +3 -0
  151. package/src/core/lifecycle/render-policy.ts +7 -4
  152. package/src/core/network/__tests__/ai.test.ts +41 -0
  153. package/src/core/network/ai.ts +12 -0
  154. package/src/core/notebook/document/__tests__/codemirror.test.ts +2 -0
  155. package/src/core/notebook/replica/__tests__/replica.test.ts +19 -0
  156. package/src/core/notebook/replica/__tests__/results.test.ts +45 -16
  157. package/src/core/notebook/replica/index.ts +1 -1
  158. package/src/core/notebook/replica/replica.ts +19 -4
  159. package/src/core/notebook/replica/resources/executions.ts +100 -9
  160. package/src/core/notebook/replica/resources/results.ts +46 -31
  161. package/src/core/transports/__tests__/static.test.ts +5 -3
  162. package/src/stories/cell.stories.tsx +40 -30
  163. package/src/stories/layout/vertical/one-column.stories.tsx +15 -7
  164. package/dist/assets/__vite-browser-external-C5NhJPNJ.js +0 -1
  165. package/dist/assets/worker-D-n8vtGi.js +0 -171
  166. package/dist/duckdb-keywords-BGArYVVK.js +0 -3
@@ -1,6 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
  /* oxlint-disable typescript/no-explicit-any */
3
3
 
4
+ import type * as Protocol from "@marimo-team/client/protocol";
4
5
  import { createStore } from "jotai";
5
6
  import { beforeEach, describe, expect, it } from "vitest";
6
7
  import { MockNotebook } from "@/__mocks__/notebook";
@@ -8,6 +9,16 @@ import { notebookAtom } from "@/core/cells/cells";
8
9
  import { type CellId, CellId as CellIdClass } from "@/core/cells/ids";
9
10
  import { ErrorContextProvider } from "../error";
10
11
 
12
+ const SYNTAX: Partial<Protocol.Error> = {
13
+ kind: "invalid-syntax",
14
+ message: "Invalid syntax",
15
+ };
16
+ const RUNTIME: Partial<Protocol.Error> = {
17
+ kind: "exception",
18
+ name: "RuntimeError",
19
+ message: "Runtime error",
20
+ };
21
+
11
22
  describe("ErrorContextProvider", () => {
12
23
  let provider: ErrorContextProvider;
13
24
  let store: ReturnType<typeof createStore>;
@@ -18,11 +29,8 @@ describe("ErrorContextProvider", () => {
18
29
  });
19
30
 
20
31
  const createMockNotebookWithErrors = (
21
- errors: Parameters<typeof MockNotebook.notebookStateWithErrors>[0],
22
- ) => {
23
- const notebookState = MockNotebook.notebookStateWithErrors(errors);
24
- store.set(notebookAtom, notebookState);
25
- };
32
+ errors: Parameters<typeof MockNotebook.withErrors>[1],
33
+ ) => MockNotebook.withErrors(store, errors);
26
34
 
27
35
  describe("provider properties", () => {
28
36
  it("should have correct provider properties", () => {
@@ -43,16 +51,8 @@ describe("ErrorContextProvider", () => {
43
51
  const cellId2 = CellIdClass.create();
44
52
 
45
53
  createMockNotebookWithErrors([
46
- {
47
- cellId: cellId1,
48
- cellName: "Cell 1",
49
- errorData: [MockNotebook.errors.syntax("Invalid syntax")],
50
- },
51
- {
52
- cellId: cellId2,
53
- cellName: "Cell 2",
54
- errorData: [MockNotebook.errors.exception("Runtime error")],
55
- },
54
+ { cellId: cellId1, cellName: "Cell 1", error: SYNTAX },
55
+ { cellId: cellId2, cellName: "Cell 2", error: RUNTIME },
56
56
  ]);
57
57
 
58
58
  const items = provider.getItems();
@@ -95,13 +95,7 @@ describe("ErrorContextProvider", () => {
95
95
  it("should handle cells without names", () => {
96
96
  const cellId = CellIdClass.create();
97
97
 
98
- createMockNotebookWithErrors([
99
- {
100
- cellId,
101
- cellName: "",
102
- errorData: [MockNotebook.errors.syntax("Invalid syntax")],
103
- },
104
- ]);
98
+ createMockNotebookWithErrors([{ cellId, cellName: "", error: SYNTAX }]);
105
99
 
106
100
  const items = provider.getItems();
107
101
  expect(items[1].data).toMatchObject({
@@ -119,16 +113,8 @@ describe("ErrorContextProvider", () => {
119
113
  const cellId2 = CellIdClass.create();
120
114
 
121
115
  createMockNotebookWithErrors([
122
- {
123
- cellId: cellId1,
124
- cellName: "Cell 1",
125
- errorData: [MockNotebook.errors.syntax("Invalid syntax")],
126
- },
127
- {
128
- cellId: cellId2,
129
- cellName: "Cell 2",
130
- errorData: [MockNotebook.errors.exception("Runtime error")],
131
- },
116
+ { cellId: cellId1, cellName: "Cell 1", error: SYNTAX },
117
+ { cellId: cellId2, cellName: "Cell 2", error: RUNTIME },
132
118
  ]);
133
119
 
134
120
  const items = provider.getItems();
@@ -169,11 +155,7 @@ describe("ErrorContextProvider", () => {
169
155
  const cellId = CellIdClass.create();
170
156
 
171
157
  createMockNotebookWithErrors([
172
- {
173
- cellId,
174
- cellName: "Cell 1",
175
- errorData: [MockNotebook.errors.syntax("Invalid syntax")],
176
- },
158
+ { cellId, cellName: "Cell 1", error: SYNTAX },
177
159
  ]);
178
160
 
179
161
  const items = provider.getItems();
@@ -185,11 +167,7 @@ describe("ErrorContextProvider", () => {
185
167
  const cellId = CellIdClass.create();
186
168
 
187
169
  createMockNotebookWithErrors([
188
- {
189
- cellId,
190
- cellName: "Cell 1",
191
- errorData: [MockNotebook.errors.syntax("Invalid syntax")],
192
- },
170
+ { cellId, cellName: "Cell 1", error: SYNTAX },
193
171
  ]);
194
172
 
195
173
  const items = provider.getItems();
@@ -230,11 +208,7 @@ describe("ErrorContextProvider", () => {
230
208
  const cellId = CellIdClass.create();
231
209
 
232
210
  createMockNotebookWithErrors([
233
- {
234
- cellId,
235
- cellName: "Cell 1",
236
- errorData: [MockNotebook.errors.syntax("Invalid syntax")],
237
- },
211
+ { cellId, cellName: "Cell 1", error: SYNTAX },
238
212
  ]);
239
213
 
240
214
  const items = provider.getItems();
@@ -243,26 +217,19 @@ describe("ErrorContextProvider", () => {
243
217
  expect(context).toContain("Code:");
244
218
  });
245
219
 
246
- it("should format context for multiple error types", () => {
220
+ it("should format context for several kinds of error", () => {
247
221
  const cellId1 = "cell-1" as CellId;
248
222
  const cellId2 = "cell-2" as CellId;
249
223
 
250
224
  createMockNotebookWithErrors([
251
- {
252
- cellId: cellId1,
253
- cellName: "Cell 1",
254
- errorData: [
255
- MockNotebook.errors.syntax("Invalid syntax"),
256
- MockNotebook.errors.exception("Runtime error"),
257
- ],
258
- },
225
+ { cellId: cellId1, cellName: "Cell 1", error: SYNTAX },
259
226
  {
260
227
  cellId: cellId2,
261
228
  cellName: "",
262
- errorData: [
263
- MockNotebook.errors.cycle(),
264
- MockNotebook.errors.multipleDefs("variable_x"),
265
- ],
229
+ error: {
230
+ kind: "cycle-dependencies",
231
+ message: "This cell is in a cycle",
232
+ },
266
233
  },
267
234
  ]);
268
235
 
@@ -270,23 +237,13 @@ describe("ErrorContextProvider", () => {
270
237
  const context = provider.formatContext(items[0]);
271
238
 
272
239
  expect(context).toContain("Invalid syntax");
273
- expect(context).toContain("Runtime error");
274
240
  expect(context).toContain("This cell is in a cycle");
275
- expect(context).toContain(
276
- "The variable 'variable_x' was defined by another cell",
277
- );
278
241
  });
279
242
 
280
243
  it("should handle cells without names", () => {
281
244
  const cellId = CellIdClass.create();
282
245
 
283
- createMockNotebookWithErrors([
284
- {
285
- cellId,
286
- cellName: "",
287
- errorData: [MockNotebook.errors.syntax("Invalid syntax")],
288
- },
289
- ]);
246
+ createMockNotebookWithErrors([{ cellId, cellName: "", error: SYNTAX }]);
290
247
 
291
248
  const items = provider.getItems();
292
249
  const context = provider.formatContext(items[1]);
@@ -301,15 +258,15 @@ describe("ErrorContextProvider", () => {
301
258
  {
302
259
  cellId,
303
260
  cellName: "Cell 1",
304
- errorData: [
305
- {
306
- type: "exception",
307
- msg: "boom",
308
- exception_type: "ValueError",
309
- raising_cell: null,
310
- traceback: "<pre>line 1\nline 2</pre>",
261
+ error: {
262
+ kind: "exception",
263
+ name: "ValueError",
264
+ message: "boom",
265
+ traceback: {
266
+ mimetype: "text/html",
267
+ data: "<pre>line 1\nline 2</pre>",
311
268
  },
312
- ],
269
+ },
313
270
  },
314
271
  ]);
315
272
 
@@ -320,61 +277,18 @@ describe("ErrorContextProvider", () => {
320
277
  expect(context).toContain("line 2");
321
278
  });
322
279
 
323
- it("includes traceback-only cell outputs", () => {
324
- const cellId = CellIdClass.create();
325
- const notebookState = MockNotebook.notebookState({
326
- cellData: {
327
- [cellId]: {
328
- name: "Cell 1",
329
- code: "raise ValueError('boom')",
330
- },
331
- },
332
- });
333
- notebookState.cellRuntime[cellId] = {
334
- ...notebookState.cellRuntime[cellId],
335
- output: {
336
- channel: "marimo-error",
337
- data: "<pre>ValueError: boom\n line 1</pre>",
338
- mimetype: "application/vnd.marimo+traceback",
339
- timestamp: Date.now(),
340
- },
341
- };
342
- store.set(notebookAtom, notebookState);
343
-
344
- const items = provider.getItems();
345
- expect(items).toHaveLength(2);
346
- expect(items[1].description).toBe("ValueError: boom");
347
- const context = provider.formatContext(items[1]);
348
- expect(context).toContain("raise ValueError('boom')");
349
- expect(context).toContain("ValueError: boom");
350
- expect(context).toContain("line 1");
351
- });
352
-
353
280
  it("includes console tracebacks for marimo error outputs", () => {
354
281
  const cellId = CellIdClass.create();
355
- const notebookState = MockNotebook.notebookState({
356
- cellData: {
357
- [cellId]: {
358
- name: "Cell 1",
359
- code: "raise ValueError('boom')",
360
- },
282
+ const notebookState = createMockNotebookWithErrors([
283
+ {
284
+ cellId,
285
+ cellName: "Cell 1",
286
+ code: "raise ValueError('boom')",
287
+ error: { kind: "exception", name: "ValueError", message: "boom" },
361
288
  },
362
- });
289
+ ]);
363
290
  notebookState.cellRuntime[cellId] = {
364
291
  ...notebookState.cellRuntime[cellId],
365
- output: {
366
- channel: "marimo-error",
367
- data: [
368
- {
369
- type: "exception",
370
- msg: "boom",
371
- exception_type: "ValueError",
372
- raising_cell: null,
373
- },
374
- ],
375
- mimetype: "application/vnd.marimo+error",
376
- timestamp: Date.now(),
377
- },
378
292
  consoleOutputs: [
379
293
  {
380
294
  channel: "stderr",
@@ -396,30 +310,24 @@ describe("ErrorContextProvider", () => {
396
310
 
397
311
  it("does not duplicate console traceback when error already has one", () => {
398
312
  const cellId = CellIdClass.create();
399
- const notebookState = MockNotebook.notebookState({
400
- cellData: {
401
- [cellId]: {
402
- name: "Cell 1",
403
- code: "raise ValueError('boom')",
313
+ const notebookState = createMockNotebookWithErrors([
314
+ {
315
+ cellId,
316
+ cellName: "Cell 1",
317
+ code: "raise ValueError('boom')",
318
+ error: {
319
+ kind: "exception",
320
+ name: "ValueError",
321
+ message: "boom",
322
+ traceback: {
323
+ mimetype: "text/html",
324
+ data: "<pre>embedded line 1</pre>",
325
+ },
404
326
  },
405
327
  },
406
- });
328
+ ]);
407
329
  notebookState.cellRuntime[cellId] = {
408
330
  ...notebookState.cellRuntime[cellId],
409
- output: {
410
- channel: "marimo-error",
411
- data: [
412
- {
413
- type: "exception",
414
- msg: "boom",
415
- exception_type: "ValueError",
416
- raising_cell: null,
417
- traceback: "<pre>embedded line 1</pre>",
418
- },
419
- ],
420
- mimetype: "application/vnd.marimo+error",
421
- timestamp: Date.now(),
422
- },
423
331
  consoleOutputs: [
424
332
  {
425
333
  channel: "stderr",
@@ -445,56 +353,41 @@ describe("ErrorContextProvider", () => {
445
353
  });
446
354
 
447
355
  describe("error description handling", () => {
448
- it("should handle all error types correctly", () => {
449
- // Note: ancestor-* error types are intentionally filtered out by cellErrorsAtom
450
- const errorTypes = [
451
- {
452
- error: MockNotebook.errors.setupRefs(),
453
- expected: "The setup cell cannot have references",
454
- },
455
- {
456
- error: MockNotebook.errors.cycle(),
457
- expected: "This cell is in a cycle",
458
- },
459
- {
460
- error: MockNotebook.errors.multipleDefs("var_x"),
461
- expected: "The variable 'var_x' was defined by another cell",
462
- },
463
- {
464
- error: MockNotebook.errors.importStar("Import star error"),
465
- expected: "Import star error",
466
- },
356
+ it("describes each kind of host error", () => {
357
+ const errors: { error: Partial<Protocol.Error>; expected: string }[] = [
467
358
  {
468
- error: MockNotebook.errors.exception("Runtime exception"),
359
+ error: { kind: "exception", message: "Runtime exception" },
469
360
  expected: "Runtime exception",
470
361
  },
471
362
  {
472
- error: MockNotebook.errors.strictException("Strict exception", "ref"),
473
- expected: "Strict exception",
363
+ error: { kind: "invalid-syntax", message: "Syntax error" },
364
+ expected: "Syntax error",
474
365
  },
475
366
  {
476
- error: MockNotebook.errors.interruption(),
367
+ error: { kind: "interrupted", message: "" },
477
368
  expected: "This cell was interrupted and needs to be re-run",
478
369
  },
479
370
  {
480
- error: MockNotebook.errors.syntax("Syntax error"),
481
- expected: "Syntax error",
371
+ error: { kind: "internal", message: "Unknown error" },
372
+ expected: "Unknown error",
482
373
  },
483
374
  {
484
- error: MockNotebook.errors.unknown("Unknown error"),
485
- expected: "Unknown error",
375
+ // Any other kind is a diagnostic, shown as the host wrote it.
376
+ error: {
377
+ kind: "multiple-definitions",
378
+ message: "x is defined twice",
379
+ },
380
+ expected: "x is defined twice",
486
381
  },
487
382
  ];
488
383
 
489
- for (const { error, expected } of errorTypes) {
384
+ for (const { error, expected } of errors) {
490
385
  // Create a fresh store and provider for each error type
491
386
  const testStore = createStore();
492
387
  const testProvider = new ErrorContextProvider(testStore);
493
-
494
- const { notebookState } = MockNotebook.cellWithErrors("Cell 1", [
495
- error,
388
+ MockNotebook.withErrors(testStore, [
389
+ { cellId: CellIdClass.create(), cellName: "Cell 1", error },
496
390
  ]);
497
- testStore.set(notebookAtom, notebookState);
498
391
 
499
392
  const items = testProvider.getItems();
500
393
  // One "all-errors" item plus one per-cell error item.
@@ -503,15 +396,5 @@ describe("ErrorContextProvider", () => {
503
396
  expect(context).toContain(expected);
504
397
  }
505
398
  });
506
-
507
- it("should handle unknown error type gracefully", () => {
508
- const error = { type: "unknown-type" as any };
509
- const { notebookState } = MockNotebook.cellWithErrors("Cell 1", [error]);
510
- store.set(notebookAtom, notebookState);
511
-
512
- const items = provider.getItems();
513
- const context = provider.formatContext(items[0]);
514
- expect(context).toContain("Unknown error");
515
- });
516
399
  });
517
400
  });
@@ -7,6 +7,7 @@ import { type NotebookState, notebookAtom } from "@/core/cells/cells";
7
7
  import { type CellId, CellOutputId } from "@/core/cells/ids";
8
8
  import { displayCellName } from "@/core/cells/names";
9
9
  import { isOutputEmpty } from "@/core/cells/outputs";
10
+ import { type CellOutput, cellOutputAtom } from "@/core/executions";
10
11
  import type { OutputMessage } from "@/core/kernel/messages";
11
12
  import type { JotaiStore } from "@/core/state/jotai";
12
13
  import { toPng } from "@/utils/html-to-image";
@@ -19,7 +20,7 @@ export interface BaseOutput {
19
20
  processedContent?: string;
20
21
  imageUrl?: string;
21
22
  shouldDownloadImage?: boolean;
22
- output: OutputMessage;
23
+ output: CellOutput;
23
24
  outputType: "text" | "media";
24
25
  }
25
26
 
@@ -94,7 +95,11 @@ export class CellOutputContextProvider extends AIContextProvider<CellOutputConte
94
95
  const items: CellOutputContextItem[] = [];
95
96
 
96
97
  for (const cellId of notebook.cellIds) {
97
- const cellContextData = getCellContextData(cellId, notebook);
98
+ const cellContextData = getCellContextData(
99
+ cellId,
100
+ notebook,
101
+ this.store.get(cellOutputAtom(cellId)),
102
+ );
98
103
  const cellOutput = cellContextData.cellOutput;
99
104
 
100
105
  // Skip cells with no output
@@ -308,7 +313,7 @@ export async function getAttachmentsForOutputs(
308
313
  }
309
314
  }
310
315
 
311
- function getBaseOutput(output: OutputMessage): BaseOutput | null {
316
+ function getBaseOutput(output: CellOutput): BaseOutput | null {
312
317
  if (isOutputEmpty(output)) {
313
318
  return null;
314
319
  }
@@ -350,6 +355,7 @@ function getBaseOutput(output: OutputMessage): BaseOutput | null {
350
355
  export function getCellContextData(
351
356
  cellId: CellId,
352
357
  notebook: NotebookState,
358
+ output: CellOutput | null,
353
359
  opts?: {
354
360
  includeConsoleOutput: boolean;
355
361
  },
@@ -369,9 +375,8 @@ export function getCellContextData(
369
375
  }
370
376
 
371
377
  let cellOutput: BaseOutput | undefined;
372
- const rawCellOutput = cellRuntime.output;
373
- if (rawCellOutput && !isOutputEmpty(rawCellOutput)) {
374
- cellOutput = getBaseOutput(rawCellOutput) ?? undefined;
378
+ if (output !== null && !isOutputEmpty(output)) {
379
+ cellOutput = getBaseOutput(output) ?? undefined;
375
380
  }
376
381
 
377
382
  return {