@marimo-team/islands 0.23.15-dev5 → 0.23.15-dev50

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 (112) hide show
  1. package/dist/{ConnectedDataExplorerComponent-CU4fZJzG.js → ConnectedDataExplorerComponent-Cmq_9LVS.js} +4 -4
  2. package/dist/{ErrorBoundary-DE6tzZf-.js → ErrorBoundary-CnMJ8jR9.js} +1 -1
  3. package/dist/{ImageComparisonComponent-CHrI72em.js → ImageComparisonComponent-1i5IBhon.js} +173 -129
  4. package/dist/assets/__vite-browser-external-CjNAy01L.js +1 -0
  5. package/dist/assets/worker-B3XPCb6y.js +98 -0
  6. package/dist/{chat-ui-DinOvbWu.js → chat-ui-Dy0arY8E.js} +3111 -3111
  7. package/dist/{code-visibility-DBuB5MVY.js → code-visibility-B5xe1Xp2.js} +946 -864
  8. package/dist/{constants-T20xxyNf.js → debounce-BOD3DbfP.js} +1 -24
  9. package/dist/{formats-Dzx4J_z1.js → formats-CdvkxTS6.js} +1 -1
  10. package/dist/{glide-data-editor-CjTu7ukN.js → glide-data-editor-D5w23DvC.js} +3 -3
  11. package/dist/{html-to-image-_wGfk8V-.js → html-to-image-f-kPEnn0.js} +2291 -2250
  12. package/dist/{input-DtsN7xm-.js → input-CF5Sgjba.js} +2 -2
  13. package/dist/main.js +1302 -1202
  14. package/dist/{mermaid-BYqXy_NE.js → mermaid-BaZJ2mds.js} +2 -2
  15. package/dist/{process-output-Mh4UrjwM.js → process-output-O9FeFAVM.js} +1 -1
  16. package/dist/{reveal-component-DfOZrkd6.js → reveal-component-BkZp_qsV.js} +618 -605
  17. package/dist/{spec-Cz-Bj1JI.js → spec-DxIove3q.js} +1 -1
  18. package/dist/style.css +1 -1
  19. package/dist/{toDate-CWNNlFEX.js → toDate-CEOdz9nC.js} +14 -5
  20. package/dist/{useAsyncData-KfHB8wQR.js → useAsyncData-Cs0mpJTy.js} +1 -1
  21. package/dist/{useDeepCompareMemoize-nJMtxhm4.js → useDeepCompareMemoize-DoOZicGb.js} +1 -1
  22. package/dist/{useLifecycle-DegSo0lV.js → useLifecycle-DR_F1d7F.js} +1 -1
  23. package/dist/{useTheme-6eZ3GOTS.js → useTheme-BA-8MM7N.js} +63 -27
  24. package/dist/{vega-component-DzyyM9fc.js → vega-component-BN0fz-QA.js} +6 -6
  25. package/package.json +1 -1
  26. package/src/__mocks__/requests.ts +3 -0
  27. package/src/components/chat/__tests__/chat-utils.test.ts +244 -1
  28. package/src/components/chat/__tests__/message-queue.test.tsx +121 -0
  29. package/src/components/chat/chat-panel.tsx +196 -67
  30. package/src/components/chat/chat-utils.ts +111 -2
  31. package/src/components/editor/SortableCell.tsx +6 -2
  32. package/src/components/editor/__tests__/output-persistence.test.tsx +241 -0
  33. package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +153 -0
  34. package/src/components/editor/actions/pair-with-agent-commands.ts +109 -0
  35. package/src/components/editor/actions/pair-with-agent-modal.tsx +20 -64
  36. package/src/components/editor/actions/useNotebookActions.tsx +8 -0
  37. package/src/components/editor/ai/add-cell-with-ai.tsx +14 -5
  38. package/src/components/editor/ai/ai-completion-editor.tsx +4 -1
  39. package/src/components/editor/cell/cell-context-menu.tsx +7 -0
  40. package/src/components/editor/chrome/components/__tests__/feedback-button.test.tsx +221 -0
  41. package/src/components/editor/chrome/components/feedback-button.tsx +308 -77
  42. package/src/components/editor/chrome/panels/packages-panel.tsx +11 -1
  43. package/src/components/editor/columns/__tests__/cell-column.test.tsx +105 -0
  44. package/src/components/editor/columns/cell-column.tsx +34 -4
  45. package/src/components/editor/columns/sortable-column.tsx +24 -4
  46. package/src/components/editor/file-tree/download.ts +46 -0
  47. package/src/components/editor/file-tree/file-explorer.tsx +3 -21
  48. package/src/components/editor/file-tree/file-viewer.tsx +4 -27
  49. package/src/components/editor/navigation/__tests__/navigation.test.ts +33 -0
  50. package/src/components/editor/navigation/navigation.ts +8 -1
  51. package/src/components/editor/notebook-cell.tsx +203 -106
  52. package/src/components/editor/renderers/__tests__/cells-renderer.test.tsx +66 -0
  53. package/src/components/editor/renderers/cell-array.tsx +26 -13
  54. package/src/components/editor/renderers/cells-renderer.tsx +8 -2
  55. package/src/components/editor/renderers/slides-layout/__tests__/plugin.test.ts +29 -0
  56. package/src/components/editor/renderers/slides-layout/types.ts +4 -0
  57. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +19 -19
  58. package/src/components/slides/reveal-component.tsx +37 -4
  59. package/src/components/slides/slide-form.tsx +72 -0
  60. package/src/components/ui/toast.tsx +11 -3
  61. package/src/components/ui/toaster.tsx +65 -9
  62. package/src/core/ai/context/providers/error.ts +6 -158
  63. package/src/core/cells/__tests__/utils.test.ts +59 -0
  64. package/src/core/cells/utils.ts +51 -0
  65. package/src/core/codemirror/completion/__tests__/signature-hint.test.ts +97 -3
  66. package/src/core/codemirror/completion/signature-hint.ts +78 -11
  67. package/src/core/constants.ts +8 -0
  68. package/src/core/diagnostics/__tests__/issue-details.test.ts +173 -0
  69. package/src/core/diagnostics/issue-details.ts +139 -0
  70. package/src/core/errors/__tests__/error-entries.test.ts +25 -0
  71. package/src/core/errors/error-entries.ts +176 -0
  72. package/src/core/islands/__tests__/bridge.test.ts +341 -46
  73. package/src/core/islands/__tests__/main.test.ts +176 -0
  74. package/src/core/islands/__tests__/parse.test.ts +105 -0
  75. package/src/core/islands/bootstrap.ts +8 -3
  76. package/src/core/islands/bridge.ts +117 -23
  77. package/src/core/islands/components/__tests__/web-components.test.tsx +214 -0
  78. package/src/core/islands/components/web-components.tsx +76 -15
  79. package/src/core/islands/constants.ts +1 -0
  80. package/src/core/islands/main.ts +69 -3
  81. package/src/core/islands/parse.ts +70 -23
  82. package/src/core/islands/worker/__tests__/controller.test.ts +173 -0
  83. package/src/core/islands/worker/worker.tsx +145 -57
  84. package/src/core/network/__tests__/requests-lazy.test.ts +18 -0
  85. package/src/core/network/__tests__/requests-network.test.ts +7 -0
  86. package/src/core/network/requests-lazy.ts +13 -1
  87. package/src/core/network/requests-network.ts +3 -0
  88. package/src/core/network/requests-static.ts +1 -0
  89. package/src/core/network/requests-toasting.tsx +1 -0
  90. package/src/core/network/types.ts +3 -0
  91. package/src/core/runtime/__tests__/runtime.test.ts +64 -0
  92. package/src/core/runtime/runtime.ts +30 -10
  93. package/src/core/wasm/bridge.ts +8 -0
  94. package/src/core/wasm/worker/bootstrap.ts +113 -20
  95. package/src/core/wasm/worker/types.ts +2 -0
  96. package/src/css/app/Cell.css +10 -0
  97. package/src/hooks/__tests__/useHotkey.test.tsx +88 -0
  98. package/src/hooks/useHotkey.ts +29 -4
  99. package/src/plugins/impl/anywidget/__tests__/host.test.ts +6 -9
  100. package/src/plugins/impl/anywidget/__tests__/registry.test.ts +3 -1
  101. package/src/plugins/impl/anywidget/__tests__/widget-binding.test.ts +32 -61
  102. package/src/plugins/impl/anywidget/model-proxy.ts +0 -13
  103. package/src/plugins/impl/anywidget/runtime.ts +1 -0
  104. package/src/plugins/impl/anywidget/widget-binding.ts +8 -34
  105. package/src/plugins/impl/image-comparison/ImageComparisonComponent.tsx +53 -2
  106. package/src/plugins/impl/image-comparison/__tests__/ImageComparisonComponent.test.tsx +71 -0
  107. package/src/plugins/impl/matplotlib/__tests__/matplotlib-renderer.test.ts +71 -3
  108. package/src/plugins/impl/matplotlib/matplotlib-renderer.ts +1 -0
  109. package/src/theme/__tests__/useTheme.test.ts +68 -0
  110. package/src/theme/useTheme.ts +16 -1
  111. package/dist/assets/__vite-browser-external-BQCLNwri.js +0 -1
  112. package/dist/assets/worker-DAWRHcPq.js +0 -73
@@ -0,0 +1,176 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import { notebookAtom } from "@/core/cells/cells";
4
+ import type { CellId } from "@/core/cells/ids";
5
+ import { displayCellName } from "@/core/cells/names";
6
+ import type { MarimoError, OutputMessage } from "@/core/kernel/messages";
7
+ import { isErrorMime, isMarimoErrorsMime, isTracebackMime } from "@/core/mime";
8
+ import type { JotaiStore } from "@/core/state/jotai";
9
+ import { logNever } from "@/utils/assertNever";
10
+ import { parseHtmlContent } from "@/utils/dom";
11
+
12
+ export interface CellErrorEntry {
13
+ cellId: CellId;
14
+ cellName: string;
15
+ cellCode: string;
16
+ errorData: MarimoError[];
17
+ tracebackHtml?: string;
18
+ }
19
+
20
+ function parseCellErrorOutput(
21
+ output: OutputMessage,
22
+ ): Pick<CellErrorEntry, "errorData" | "tracebackHtml"> | null {
23
+ if (isMarimoErrorsMime(output.mimetype)) {
24
+ if (!Array.isArray(output.data)) {
25
+ return null;
26
+ }
27
+ const errorData = output.data.filter(
28
+ (error) => !error.type.includes("ancestor"),
29
+ );
30
+ if (errorData.length === 0) {
31
+ return null;
32
+ }
33
+ return { errorData };
34
+ }
35
+
36
+ if (isTracebackMime(output.mimetype)) {
37
+ if (typeof output.data !== "string" || output.data.length === 0) {
38
+ return null;
39
+ }
40
+ return { errorData: [], tracebackHtml: output.data };
41
+ }
42
+
43
+ return null;
44
+ }
45
+
46
+ function errorDataHasTraceback(errorData: MarimoError[]): boolean {
47
+ return errorData.some((error) => "traceback" in error && error.traceback);
48
+ }
49
+
50
+ function getTracebackFromConsole(
51
+ consoleOutputs: OutputMessage[] | undefined,
52
+ ): string | undefined {
53
+ const tracebackOutput = consoleOutputs?.find((output) =>
54
+ isTracebackMime(output.mimetype),
55
+ );
56
+ if (
57
+ !tracebackOutput ||
58
+ typeof tracebackOutput.data !== "string" ||
59
+ tracebackOutput.data.length === 0
60
+ ) {
61
+ return undefined;
62
+ }
63
+ return tracebackOutput.data;
64
+ }
65
+
66
+ function resolveTracebackHtml(
67
+ parsed: Pick<CellErrorEntry, "errorData" | "tracebackHtml">,
68
+ consoleOutputs: OutputMessage[] | undefined,
69
+ ): string | undefined {
70
+ if (parsed.tracebackHtml) {
71
+ return parsed.tracebackHtml;
72
+ }
73
+ if (errorDataHasTraceback(parsed.errorData)) {
74
+ return undefined;
75
+ }
76
+ return getTracebackFromConsole(consoleOutputs);
77
+ }
78
+
79
+ export function getCellErrorEntries(store: JotaiStore): CellErrorEntry[] {
80
+ const { cellIds, cellRuntime, cellData } = store.get(notebookAtom);
81
+ const entries: CellErrorEntry[] = [];
82
+
83
+ for (const [cellIndex, cellId] of cellIds.inOrderIds.entries()) {
84
+ const cell = cellRuntime[cellId];
85
+ const output = cell.output;
86
+ if (!output || !isErrorMime(output.mimetype)) {
87
+ continue;
88
+ }
89
+
90
+ const parsed = parseCellErrorOutput(output);
91
+ if (!parsed) {
92
+ continue;
93
+ }
94
+
95
+ const cellName = displayCellName(cellData[cellId].name, cellIndex);
96
+ // Prefer the code from the last execution: runtime errors correspond to
97
+ // the previous run, while `code` may already contain unsaved edits.
98
+ const cellCode = cellData[cellId].lastCodeRun ?? cellData[cellId].code;
99
+
100
+ entries.push({
101
+ cellId,
102
+ cellName,
103
+ cellCode,
104
+ errorData: parsed.errorData,
105
+ tracebackHtml: resolveTracebackHtml(parsed, cell.consoleOutputs),
106
+ });
107
+ }
108
+
109
+ return entries;
110
+ }
111
+
112
+ export function describeError(error: MarimoError): string {
113
+ if (error.type === "setup-refs") {
114
+ return "The setup cell cannot have references";
115
+ }
116
+ if (error.type === "cycle") {
117
+ return "This cell is in a cycle";
118
+ }
119
+ if (error.type === "multiple-defs") {
120
+ return `The variable '${error.name}' was defined by another cell`;
121
+ }
122
+ if (error.type === "import-star") {
123
+ return error.msg;
124
+ }
125
+ if (error.type === "ancestor-stopped") {
126
+ return error.msg;
127
+ }
128
+ if (error.type === "ancestor-prevented") {
129
+ return error.msg;
130
+ }
131
+ if (error.type === "exception") {
132
+ return error.msg;
133
+ }
134
+ if (error.type === "strict-exception") {
135
+ return error.msg;
136
+ }
137
+ if (error.type === "interruption") {
138
+ return "This cell was interrupted and needs to be re-run";
139
+ }
140
+ if (error.type === "syntax") {
141
+ return error.msg;
142
+ }
143
+ if (error.type === "unknown") {
144
+ return error.msg;
145
+ }
146
+ if (error.type === "sql-error") {
147
+ return error.msg;
148
+ }
149
+ if (error.type === "internal") {
150
+ return error.msg || "An internal error occurred";
151
+ }
152
+ logNever(error);
153
+ return "Unknown error";
154
+ }
155
+
156
+ export function formatSingleError(error: MarimoError): string {
157
+ let text = describeError(error);
158
+ if ("traceback" in error && error.traceback) {
159
+ text += `\n\nTraceback:\n${parseHtmlContent(error.traceback)}`;
160
+ }
161
+ return text;
162
+ }
163
+
164
+ export function formatCellError(entry: CellErrorEntry): string {
165
+ const parts = [entry.cellName];
166
+
167
+ if (entry.tracebackHtml) {
168
+ parts.push(parseHtmlContent(entry.tracebackHtml));
169
+ }
170
+
171
+ if (entry.errorData.length > 0) {
172
+ parts.push(entry.errorData.map(formatSingleError).join("\n\n"));
173
+ }
174
+
175
+ return parts.join("\n\n");
176
+ }