@marimo-team/frontend 0.23.16-dev36 → 0.23.16-dev38

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 (77) hide show
  1. package/dist/assets/{CellStatus-Dua-Q5qp.js → CellStatus-C6Cj3oJc.js} +1 -1
  2. package/dist/assets/{JsonOutput-BjTsPSAI.js → JsonOutput-CyzvjIjx.js} +6 -6
  3. package/dist/assets/{MarimoErrorOutput-BSyqD6Hg.js → MarimoErrorOutput-CIuzXFFo.js} +8 -8
  4. package/dist/assets/{RenderHTML-DG0Fm01X.js → RenderHTML-Cd-PP5ZR.js} +1 -1
  5. package/dist/assets/{RunButton-DFs1N-c9.js → RunButton-CnYWedW4.js} +1 -1
  6. package/dist/assets/{add-cell-with-ai-C6Kxfu_D.js → add-cell-with-ai-ByOBQT99.js} +10 -10
  7. package/dist/assets/{add-connection-dialog-DAqIrB2O.js → add-connection-dialog-C97ylgk0.js} +1 -1
  8. package/dist/assets/{agent-panel-GtkUm7qc.js → agent-panel-Dxo9WUKV.js} +5 -5
  9. package/dist/assets/{ai-model-dropdown-UEHQ_Tx0.js → ai-model-dropdown-Bvqy98cI.js} +3 -3
  10. package/dist/assets/{app-config-button-BmBlROBo.js → app-config-button-v1lG63C2.js} +1 -1
  11. package/dist/assets/{cell-editor-DKzBZjFa.js → cell-editor-BKrHbyX_.js} +16 -16
  12. package/dist/assets/cell-link-w5IbCQV4.js +1 -0
  13. package/dist/assets/{cells-C-9Qa_6_.js → cells-DzyDERZy.js} +57 -57
  14. package/dist/assets/{chat-display-CqB9H1kF.js → chat-display-Ccgk4vbE.js} +1 -1
  15. package/dist/assets/{chat-panel-C3wpuHtk.js → chat-panel--53TIc3t.js} +4 -4
  16. package/dist/assets/{chat-ui-DF2nZlBy.js → chat-ui-B5rBxgsw.js} +4 -4
  17. package/dist/assets/{column-preview-Bp4QHPE2.js → column-preview-Cb8R9kfl.js} +1 -1
  18. package/dist/assets/{command-palette-DaJdKaQz.js → command-palette-B1S9PjZi.js} +1 -1
  19. package/dist/assets/{common-DeheUlBO.js → common-CJ3baa6D.js} +1 -1
  20. package/dist/assets/{components-Dk-7Tn_8.js → components-DpUIWGaj.js} +1 -1
  21. package/dist/assets/{datasource-D-oZZRFN.js → datasource-D_VcQMEn.js} +2 -2
  22. package/dist/assets/{dependency-graph-panel-JK4qjNID.js → dependency-graph-panel-DY5lvPDx.js} +4 -4
  23. package/dist/assets/{documentation-panel-C_TxLeX8.js → documentation-panel-CGhwxsXK.js} +1 -1
  24. package/dist/assets/{download-QhwPYWYu.js → download-DpS57jyt.js} +2 -2
  25. package/dist/assets/{edit-page-C8yy6X_7.js → edit-page-DA765yQV.js} +6 -6
  26. package/dist/assets/error-entries-CTYMwfsh.js +8 -0
  27. package/dist/assets/{error-panel-BOBOm9wN.js → error-panel-DGAkG5kW.js} +1 -1
  28. package/dist/assets/{file-explorer-panel-CQOFpuIG.js → file-explorer-panel-BKUo-MDh.js} +3 -3
  29. package/dist/assets/{file-icons-DoBeqg86.js → file-icons-DfWENcb8.js} +1 -1
  30. package/dist/assets/{file-name-input-B8d-QPzY.js → file-name-input-CNVZtm5K.js} +1 -1
  31. package/dist/assets/{floating-outline-ylNOBTvA.js → floating-outline-LitP0wCD.js} +1 -1
  32. package/dist/assets/{focus-CJzSyxLL.js → focus-CNKbm-Xz.js} +1 -1
  33. package/dist/assets/{form-C2_p_FeE.js → form-nHzLTU1m.js} +2 -2
  34. package/dist/assets/{home-page-D_6eKuGc.js → home-page-DM9Z_IJ7.js} +1 -1
  35. package/dist/assets/{html-to-image-DfyxinVN.js → html-to-image-JaxFFZcr.js} +2 -2
  36. package/dist/assets/{index-D-wPCBTa.js → index-C7_REKh1.js} +6 -6
  37. package/dist/assets/{layout-BWV4OadK.js → layout-B29hqiiK.js} +5 -5
  38. package/dist/assets/{logs-panel-DpMLUEOB.js → logs-panel-CQRPYS8j.js} +1 -1
  39. package/dist/assets/{markdown-renderer-DtzxgcfB.js → markdown-renderer-sEayY9-m.js} +2 -2
  40. package/dist/assets/{name-cell-input-SbknxDvi.js → name-cell-input-B-aj1KH3.js} +1 -1
  41. package/dist/assets/{outline-panel-kV7ARoXE.js → outline-panel-BOryk60D.js} +1 -1
  42. package/dist/assets/{packages-panel-B3biBPQ1.js → packages-panel-DoYDLty3.js} +1 -1
  43. package/dist/assets/{panels-BsrSW0bC.js → panels-Bb4fIHgH.js} +2 -2
  44. package/dist/assets/{process-output-DCAOrKEU.js → process-output-d-LEMtGI.js} +1 -1
  45. package/dist/assets/{radio-group-BWAhJtjV.js → radio-group-DfioQthW.js} +1 -1
  46. package/dist/assets/readonly-code-display-C9fu8tvK.js +1 -0
  47. package/dist/assets/{readonly-python-code-B5ABqdqK.js → readonly-python-code-DHxOnQGj.js} +1 -1
  48. package/dist/assets/{reveal-component-CrcdxGl_.js → reveal-component-5jf0W625.js} +2 -2
  49. package/dist/assets/{run-page-DFHpKr66.js → run-page-BMKx9ld_.js} +1 -1
  50. package/dist/assets/scratchpad-panel-C8z8vzBX.js +1 -0
  51. package/dist/assets/{session-panel-DWS61Z1x.js → session-panel-BVVk-02h.js} +1 -1
  52. package/dist/assets/{skeleton-PJnQ2_IA.js → skeleton-Bubr9pIj.js} +1 -1
  53. package/dist/assets/{snippets-panel-D1eovB0O.js → snippets-panel-U2-iok-c.js} +1 -1
  54. package/dist/assets/{state-Bu-aMpIc.js → state-DtziTd1T.js} +3 -3
  55. package/dist/assets/{state-BjouLTuw.js → state-DxQhUsG9.js} +1 -1
  56. package/dist/assets/{textarea-DhPaQ0wx.js → textarea-Bmzmbbpo.js} +1 -1
  57. package/dist/assets/{tracing-B2ux60rQ.js → tracing-B5XFvMmV.js} +1 -1
  58. package/dist/assets/{tracing-panel-CF8H5wRv.js → tracing-panel-DnR2bYDe.js} +2 -2
  59. package/dist/assets/{tree-actions-CPSDN4eE.js → tree-actions-Dx9CDaxV.js} +1 -1
  60. package/dist/assets/{useCellActionButton-k2OXllYI.js → useCellActionButton-DypR3yDt.js} +1 -1
  61. package/dist/assets/{useDeleteCell-C3nmnuxK.js → useDeleteCell-vMXAr3rY.js} +1 -1
  62. package/dist/assets/{useDependencyPanelTab-D14Lna3z.js → useDependencyPanelTab-CwdwKf7A.js} +1 -1
  63. package/dist/assets/{useNotebookActions-CHM0Ardg.js → useNotebookActions-jWIcmpv0.js} +3 -3
  64. package/dist/assets/useRunCells-C2dvU2jA.js +1 -0
  65. package/dist/assets/useSplitCell-C1tubdNi.js +1 -0
  66. package/dist/index.html +22 -22
  67. package/package.json +1 -1
  68. package/src/components/editor/cell/code/__tests__/cell-editor-activity-lifecycle.test.ts +250 -0
  69. package/src/components/editor/cell/code/cell-editor.tsx +13 -7
  70. package/src/core/cells/cells.ts +4 -4
  71. package/src/core/rtc/state.ts +9 -0
  72. package/dist/assets/cell-link-CRHwRCw2.js +0 -1
  73. package/dist/assets/error-entries-B8hPG61B.js +0 -8
  74. package/dist/assets/readonly-code-display-D_rgEfAm.js +0 -1
  75. package/dist/assets/scratchpad-panel-CfqnZK3C.js +0 -1
  76. package/dist/assets/useRunCells-C4qD32Ix.js +0 -1
  77. package/dist/assets/useSplitCell-BEebdldD.js +0 -1
@@ -0,0 +1,250 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ /**
4
+ * Simulates React Activity's effect teardown when mode switches to "hidden":
5
+ * all useEffect cleanups run. On "visible", setups re-run (cleanups do not run
6
+ * again). Component state and DOM are preserved — only effects cycle.
7
+ *
8
+ * Registration order matches cell-editor.tsx: mount effect runs before destroy
9
+ * effect setup. With async editor creation (editorMountScheduler), destroy
10
+ * captures null initially; with sync creation it captures the live editor.
11
+ */
12
+ import { EditorState } from "@codemirror/state";
13
+ import { EditorView } from "@codemirror/view";
14
+ import { describe, expect, it } from "vitest";
15
+ import { Functions } from "@/utils/functions";
16
+
17
+ interface EffectRegistration {
18
+ cleanup: () => void;
19
+ }
20
+
21
+ function createActivitySimulator() {
22
+ const effects: EffectRegistration[] = [];
23
+
24
+ return {
25
+ /** Register effects in order — each setup runs synchronously, like React. */
26
+ useEffect(setup: () => (() => void) | undefined) {
27
+ const cleanup = setup() ?? Functions.NOOP;
28
+ effects.push({ cleanup });
29
+ },
30
+ hide() {
31
+ for (const effect of effects) {
32
+ effect.cleanup();
33
+ }
34
+ },
35
+ show() {
36
+ effects.length = 0;
37
+ },
38
+ };
39
+ }
40
+
41
+ function createEditor(doc = "hello") {
42
+ return new EditorView({
43
+ state: EditorState.create({ doc }),
44
+ });
45
+ }
46
+
47
+ interface RegisterCellEditorEffectsOptions {
48
+ activity: ReturnType<typeof createActivitySimulator>;
49
+ editorViewRef: { current: EditorView | null };
50
+ destroyPattern: "old" | "pr";
51
+ onDestroy?: () => void;
52
+ /** When true, editor creation is deferred like editorMountScheduler.request */
53
+ asyncMount?: boolean;
54
+ }
55
+
56
+ function registerCellEditorEffects({
57
+ activity,
58
+ editorViewRef,
59
+ destroyPattern,
60
+ onDestroy,
61
+ asyncMount = false,
62
+ }: RegisterCellEditorEffectsOptions) {
63
+ activity.useEffect(() => {
64
+ if (editorViewRef.current !== null) {
65
+ return;
66
+ }
67
+ let cancelled = false;
68
+ const mount = () => {
69
+ if (!cancelled && editorViewRef.current === null) {
70
+ editorViewRef.current = createEditor();
71
+ }
72
+ };
73
+ if (asyncMount) {
74
+ const id = setTimeout(mount, 0);
75
+ return () => {
76
+ cancelled = true;
77
+ clearTimeout(id);
78
+ };
79
+ }
80
+ mount();
81
+ return () => {
82
+ cancelled = true;
83
+ };
84
+ });
85
+
86
+ if (destroyPattern === "old") {
87
+ activity.useEffect(() => {
88
+ const ev = editorViewRef.current;
89
+ return () => {
90
+ if (ev) {
91
+ ev.destroy();
92
+ onDestroy?.();
93
+ }
94
+ };
95
+ });
96
+ } else {
97
+ activity.useEffect(() => {
98
+ return () => {
99
+ if (editorViewRef.current) {
100
+ editorViewRef.current.destroy();
101
+ onDestroy?.();
102
+ }
103
+ editorViewRef.current = null;
104
+ };
105
+ });
106
+ }
107
+ }
108
+
109
+ describe("CellEditor Activity lifecycle (simulated)", () => {
110
+ it("old destroy pattern (sync mount): first hide/show leaves stale ref", () => {
111
+ const editorViewRef = { current: null as EditorView | null };
112
+ let destroyCount = 0;
113
+ const activity = createActivitySimulator();
114
+
115
+ registerCellEditorEffects({
116
+ activity,
117
+ editorViewRef,
118
+ destroyPattern: "old",
119
+ onDestroy: () => {
120
+ destroyCount++;
121
+ },
122
+ });
123
+ const liveEditor = editorViewRef.current;
124
+ expect(liveEditor).not.toBeNull();
125
+
126
+ activity.hide();
127
+ expect(destroyCount).toBeGreaterThan(0);
128
+ expect(editorViewRef.current).toBe(liveEditor);
129
+
130
+ activity.show();
131
+ registerCellEditorEffects({
132
+ activity,
133
+ editorViewRef,
134
+ destroyPattern: "old",
135
+ });
136
+ expect(editorViewRef.current).toBe(liveEditor);
137
+ });
138
+
139
+ it("old destroy pattern (async mount): first hide/show preserves editor", async () => {
140
+ const editorViewRef = { current: null as EditorView | null };
141
+ let destroyCount = 0;
142
+ const activity = createActivitySimulator();
143
+
144
+ registerCellEditorEffects({
145
+ activity,
146
+ editorViewRef,
147
+ destroyPattern: "old",
148
+ onDestroy: () => {
149
+ destroyCount++;
150
+ },
151
+ asyncMount: true,
152
+ });
153
+ await new Promise((r) => setTimeout(r, 0));
154
+ const liveEditor = editorViewRef.current;
155
+ expect(liveEditor).not.toBeNull();
156
+
157
+ // Destroy effect captured null at setup (editor created async after effects)
158
+ activity.hide();
159
+ expect(destroyCount).toBe(0);
160
+ expect(editorViewRef.current).toBe(liveEditor);
161
+
162
+ activity.show();
163
+ registerCellEditorEffects({
164
+ activity,
165
+ editorViewRef,
166
+ destroyPattern: "old",
167
+ asyncMount: true,
168
+ });
169
+ await new Promise((r) => setTimeout(r, 0));
170
+ expect(editorViewRef.current).toBe(liveEditor);
171
+ });
172
+
173
+ it("PR destroy pattern (async mount): recreates on first hide/show", async () => {
174
+ const editorViewRef = { current: null as EditorView | null };
175
+ const activity = createActivitySimulator();
176
+
177
+ registerCellEditorEffects({
178
+ activity,
179
+ editorViewRef,
180
+ destroyPattern: "pr",
181
+ asyncMount: true,
182
+ });
183
+ await new Promise((r) => setTimeout(r, 0));
184
+ const firstEditor = editorViewRef.current;
185
+
186
+ activity.hide();
187
+ expect(editorViewRef.current).toBeNull();
188
+
189
+ activity.show();
190
+ registerCellEditorEffects({
191
+ activity,
192
+ editorViewRef,
193
+ destroyPattern: "pr",
194
+ asyncMount: true,
195
+ });
196
+ await new Promise((r) => setTimeout(r, 0));
197
+ expect(editorViewRef.current).not.toBeNull();
198
+ expect(editorViewRef.current).not.toBe(firstEditor);
199
+ });
200
+
201
+ it("PR destroy pattern: nulls ref on hide so mount recreates on show", () => {
202
+ const editorViewRef = { current: null as EditorView | null };
203
+ const activity = createActivitySimulator();
204
+
205
+ registerCellEditorEffects({
206
+ activity,
207
+ editorViewRef,
208
+ destroyPattern: "pr",
209
+ });
210
+ const firstEditor = editorViewRef.current;
211
+
212
+ activity.hide();
213
+ expect(editorViewRef.current).toBeNull();
214
+
215
+ activity.show();
216
+ registerCellEditorEffects({
217
+ activity,
218
+ editorViewRef,
219
+ destroyPattern: "pr",
220
+ });
221
+ expect(editorViewRef.current).not.toBeNull();
222
+ expect(editorViewRef.current).not.toBe(firstEditor);
223
+ });
224
+
225
+ it("PR destroy pattern: stable across repeated hide/show cycles", () => {
226
+ const editorViewRef = { current: null as EditorView | null };
227
+ const activity = createActivitySimulator();
228
+
229
+ for (let i = 0; i < 3; i++) {
230
+ registerCellEditorEffects({
231
+ activity,
232
+ editorViewRef,
233
+ destroyPattern: "pr",
234
+ });
235
+ expect(editorViewRef.current).not.toBeNull();
236
+
237
+ activity.hide();
238
+ expect(editorViewRef.current).toBeNull();
239
+
240
+ activity.show();
241
+ }
242
+
243
+ registerCellEditorEffects({
244
+ activity,
245
+ editorViewRef,
246
+ destroyPattern: "pr",
247
+ });
248
+ expect(editorViewRef.current).not.toBeNull();
249
+ });
250
+ });
@@ -39,7 +39,7 @@ import type { UserConfig } from "@/core/config/config-schema";
39
39
  import { OverridingHotkeyProvider } from "@/core/hotkeys/hotkeys";
40
40
  import { connectionAtom } from "@/core/network/connection";
41
41
  import { useRequestClient } from "@/core/network/requests";
42
- import { isRtcEnabled } from "@/core/rtc/state";
42
+ import { canUseRtc, isRtcEnabled } from "@/core/rtc/state";
43
43
  import { useSaveNotebook } from "@/core/saving/save-component";
44
44
  import { isAppConnecting } from "@/core/websocket/connection-utils";
45
45
  import type { Theme } from "@/theme/useTheme";
@@ -342,7 +342,7 @@ const CellEditorInternal = ({
342
342
  saveOrNameNotebook,
343
343
  ]);
344
344
 
345
- const rtcEnabled = isRtcEnabled();
345
+ const rtcEnabled = isRtcEnabled() && canUseRtc(cellId);
346
346
  const handleInitializeEditor = useEvent(() => {
347
347
  // If rtc is enabled, use collaborative editing
348
348
  if (rtcEnabled) {
@@ -451,6 +451,7 @@ const CellEditorInternal = ({
451
451
  setIsEditorMounted(true);
452
452
  return;
453
453
  }
454
+ setIsEditorMounted(false);
454
455
  if (serializedEditorState !== null) {
455
456
  handleDeserializeEditor();
456
457
  setIsEditorMounted(true);
@@ -479,11 +480,12 @@ const CellEditorInternal = ({
479
480
  handleReconfigureEditor();
480
481
  }, [handleReconfigureEditor, extensions, editorViewRef]);
481
482
 
482
- // Destroy the editor when the component is unmounted
483
+ // Destroy the editor when the component is unmounted. Read the ref in cleanup
484
+ // (not setup) so Activity hide/show cycles don't leave a stale destroyed view.
483
485
  useEffect(() => {
484
- const ev = editorViewRef.current;
485
486
  return () => {
486
- ev?.destroy();
487
+ editorViewRef.current?.destroy();
488
+ editorViewRef.current = null;
487
489
  };
488
490
  }, [editorViewRef]);
489
491
 
@@ -635,14 +637,18 @@ CellCodeMirrorEditor.displayName = "CellCodeMirrorEditor";
635
637
  // Wait until the websocket connection is open before rendering the editor
636
638
  // This is used for real-time collaboration since the backend needs the connection started
637
639
  // before connecting the rtc websockets
638
- function WithWaitUntilConnected<T extends {}>(
640
+ function WithWaitUntilConnected<T extends Pick<CellEditorProps, "id">>(
639
641
  Component: React.ComponentType<T>,
640
642
  ) {
641
643
  const WaitUntilConnectedComponent = (props: T) => {
642
644
  const connection = useAtomValue(connectionAtom);
643
645
  const [rtcDoc, setRtcDoc] = useAtom(connectedDocAtom);
644
646
 
645
- if (isAppConnecting(connection.state) || rtcDoc === undefined) {
647
+ if (
648
+ isRtcEnabled() &&
649
+ canUseRtc(props.id) &&
650
+ (isAppConnecting(connection.state) || rtcDoc === undefined)
651
+ ) {
646
652
  return (
647
653
  <div className="flex h-full w-full items-baseline p-4">
648
654
  <DelayMount milliseconds={1000} fallback={null}>
@@ -28,7 +28,7 @@ import { findCollapseRange, mergeOutlines } from "../dom/outline";
28
28
  import type { CellMessage } from "../kernel/messages";
29
29
  import { isErrorMime } from "../mime";
30
30
  import type { CellConfig } from "../network/types";
31
- import { isRtcEnabled } from "../rtc/state";
31
+ import { canUseRtc, isRtcEnabled } from "../rtc/state";
32
32
  import { createDeepEqualAtom, store } from "../state/jotai";
33
33
  import { isWasm } from "../wasm/utils";
34
34
  import { prepareCellForExecution, transitionCell } from "./cell";
@@ -1043,9 +1043,9 @@ const {
1043
1043
  };
1044
1044
  }
1045
1045
 
1046
- // Update codemirror if mounted
1047
- // If RTC is enabled, the editor view will already be updated, so we don't need to do this
1048
- if (!isRtcEnabled()) {
1046
+ // Update codemirror if mounted. RTC-backed cells sync via Loro; others
1047
+ // (e.g. scratchpad) still need an explicit editor update.
1048
+ if (!isRtcEnabled() || !canUseRtc(cellId)) {
1049
1049
  const cellHandle = nextState.cellHandles[cellId].current;
1050
1050
  if (cellHandle?.editorViewOrNull) {
1051
1051
  updateEditorCodeFromPython(cellHandle.editorViewOrNull, code);
@@ -1,5 +1,6 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
  import { atomWithStorage } from "jotai/utils";
3
+ import { SCRATCH_CELL_ID, type CellId } from "@/core/cells/ids";
3
4
  import { once } from "@/utils/once";
4
5
  import { jotaiJsonStorage } from "@/utils/storage/jotai";
5
6
  import { getFeatureFlag } from "../config/feature-flag";
@@ -23,3 +24,11 @@ export const usernameAtom = atomWithStorage<string>(
23
24
  export const isRtcEnabled = once(() => {
24
25
  return getFeatureFlag("rtc_v2");
25
26
  });
27
+
28
+ /**
29
+ * Whether this cell type can participate in real-time collaboration.
30
+ * Scratchpad cells are local-only.
31
+ */
32
+ export function canUseRtc(cellId: CellId): boolean {
33
+ return cellId !== SCRATCH_CELL_ID;
34
+ }
@@ -1 +0,0 @@
1
- import{s as j}from"./chunk-LvLJmgfZ.js";import{d as L,l as O,n as P,u as E}from"./useEvent-D91BmmQi.js";import{E as T,N as w,Ot as y,Zi as A,cn as S,j as $,zi as b}from"./cells-C-9Qa_6_.js";import{t as _}from"./compiler-runtime-B3qBwwSJ.js";import{g as D}from"./useEventListener-C0195JsF.js";import{m as F}from"./utils-BWBBpCkT.js";import{r as N}from"./constants-CDyU_g2F.js";import{T as q,v as z}from"./config-B-Q7J_6d.js";import{t as B}from"./cn-DYvqRARy.js";import{t as H}from"./jsx-runtime-Blw4afVn.js";import{r as M}from"./requests-9-v2bhoi.js";import{n as Q}from"./paths-BKO-pHK6.js";import{s as R}from"./session-BmukRjSi.js";import{n as U}from"./ImperativeModal-fY-ZfT0b.js";var V=_();function I(){return E(b)}function Z(){let r=(0,V.c)(5),[t]=O(z),e=L(b),{openAlert:s}=U(),{sendRename:o}=M(),a;return r[0]!==t.state||r[1]!==s||r[2]!==o||r[3]!==e?(a=async l=>{let n=F();return t.state===q.OPEN?(R(i=>{l===null?i.delete(N.filePath):i.set(N.filePath,l)}),o({filename:l}).then(()=>(e(l),document.title=n.app_title||Q.basename(l)||"Untitled Notebook",l)).catch(i=>(s(i.message),null))):(s("Failed to save notebook: not connected to a kernel."),null)},r[0]=t.state,r[1]=s,r[2]=o,r[3]=e,r[4]=a):a=r[4],P(a)}var p=_(),v=j(H(),1);const h=r=>{let t=(0,p.c)(12),{className:e,cellId:s,variant:o,onClick:a,formatCellName:l,skipScroll:n}=r,i=w()[s]??"",C=$().inOrderIds.indexOf(s),{showCellIfHidden:d}=T(),g=l??K,c;t[0]===e?c=t[1]:(c=B("inline-block cursor-pointer text-link hover:underline",e),t[0]=e,t[1]=c);let m;t[2]!==s||t[3]!==a||t[4]!==d||t[5]!==n||t[6]!==o?(m=k=>{if(s==="__scratch__")return!1;d({cellId:s}),k.stopPropagation(),k.preventDefault(),requestAnimationFrame(()=>{x(s,o,n)&&(a==null||a())})},t[2]=s,t[3]=a,t[4]=d,t[5]=n,t[6]=o,t[7]=m):m=t[7];let f=g(y(i,C)),u;return t[8]!==c||t[9]!==m||t[10]!==f?(u=(0,v.jsx)("div",{className:c,role:"link",tabIndex:-1,onClick:m,children:f}),t[8]=c,t[9]=m,t[10]=f,t[11]=u):u=t[11],u},G=r=>{let t=(0,p.c)(2),e;return t[0]===r?e=t[1]:(e=(0,v.jsx)(h,{...r,variant:"destructive"}),t[0]=r,t[1]=e),e},J=r=>{let t=(0,p.c)(10),{cellId:e,lineNumber:s}=r,o=I(),a;t[0]!==e||t[1]!==s?(a=()=>S(e,s),t[0]=e,t[1]=s,t[2]=a):a=t[2];let l;t[3]!==e||t[4]!==o?(l=i=>e==="__scratch__"?"scratch":`marimo://${o||"untitled"}#cell=${i}`,t[3]=e,t[4]=o,t[5]=l):l=t[5];let n;return t[6]!==e||t[7]!==a||t[8]!==l?(n=(0,v.jsx)(h,{cellId:e,onClick:a,skipScroll:!0,variant:"destructive",className:"traceback-cell-link",formatCellName:l}),t[6]=e,t[7]=a,t[8]=l,t[9]=n):n=t[9],n};function x(r,t,e){let s=A.create(r),o=document.getElementById(s),a=o==null?void 0:o.classList.contains("has-error");return o===null?(D.error(`Cell ${s} not found on page.`),!1):(e||o.scrollIntoView({behavior:"smooth",block:"center"}),(t==="destructive"||a&&t===void 0)&&(o.classList.add("error-outline"),setTimeout(()=>{o.classList.remove("error-outline")},2e3)),(t==="focus"||!a&&t===void 0)&&(o.classList.add("focus-outline"),setTimeout(()=>{o.classList.remove("focus-outline")},2e3)),!0)}function K(r){return r}export{I as a,x as i,G as n,Z as o,J as r,h as t};
@@ -1,8 +0,0 @@
1
- import{Ot as b,_i as s,gi as h,hi as k,rt as u,y as g}from"./cells-C-9Qa_6_.js";import{i as D}from"./strings--BknHX9C.js";function H(t){if(h(t.mimetype)){if(!Array.isArray(t.data))return null;let r=t.data.filter(e=>!e.type.includes("ancestor"));return r.length===0?null:{errorData:r}}return s(t.mimetype)?typeof t.data!="string"||t.data.length===0?null:{errorData:[],tracebackHtml:t.data}:null}function T(t){return t.some(r=>"traceback"in r&&r.traceback)}function w(t){let r=t==null?void 0:t.find(e=>s(e.mimetype));if(!(!r||typeof r.data!="string"||r.data.length===0))return r.data}function x(t,r){if(t.tracebackHtml)return t.tracebackHtml;if(!T(t.errorData))return w(r)}function v(t){let{cellIds:r,cellRuntime:e,cellData:n}=t.get(g),i=[];for(let[f,a]of r.inOrderIds.entries()){let o=e[a],c=o.output;if(!c||!k(c.mimetype))continue;let l=H(c);if(!l)continue;let d=b(n[a].name,f),y=n[a].lastCodeRun??n[a].code;i.push({cellId:a,cellName:d,cellCode:y,errorData:l.errorData,tracebackHtml:x(l,o.consoleOutputs)})}return i}function p(t){return t.type==="setup-refs"?"The setup cell cannot have references":t.type==="cycle"?"This cell is in a cycle":t.type==="multiple-defs"?`The variable '${t.name}' was defined by another cell`:t.type==="import-star"||t.type==="ancestor-stopped"||t.type==="ancestor-prevented"||t.type==="exception"||t.type==="strict-exception"?t.msg:t.type==="interruption"?"This cell was interrupted and needs to be re-run":t.type==="syntax"||t.type==="unknown"||t.type==="sql-error"?t.msg:t.type==="internal"?t.msg||"An internal error occurred":(D(t),"Unknown error")}function m(t){let r=p(t);return"traceback"in t&&t.traceback&&(r+=`
2
-
3
- Traceback:
4
- ${u(t.traceback)}`),r}function A(t){let r=[t.cellName];return t.tracebackHtml&&r.push(u(t.tracebackHtml)),t.errorData.length>0&&r.push(t.errorData.map(m).join(`
5
-
6
- `)),r.join(`
7
-
8
- `)}export{v as i,A as n,m as r,p as t};
@@ -1 +0,0 @@
1
- import{er as t,tr as a}from"./cells-C-9Qa_6_.js";var o=new a,r=new t;function d(n){let e=n.trim();return e?o.isSupported(e)?{code:o.transformIn(e).code,language:"markdown"}:r.isSupported(e)?{code:r.transformIn(e).code,language:"sql"}:{code:n,language:"python"}:{code:n,language:"python"}}export{d as t};
@@ -1 +0,0 @@
1
- import{s as oe}from"./chunk-LvLJmgfZ.js";import{d as be,l as ye,n as V,p as ae,u as we}from"./useEvent-D91BmmQi.js";import{t as Ne}from"./react-Bj1aDYRI.js";import{E as ke,F as ze,Qi as n,Rn as Ce,Ui as Se,Zi as Oe,__tla as Ae}from"./cells-C-9Qa_6_.js";import"./react-dom-CSu739Rf.js";import{t as ie}from"./compiler-runtime-B3qBwwSJ.js";import{_ as se}from"./useEventListener-C0195JsF.js";import{C as Ie}from"./utils-BWBBpCkT.js";import{t as Ee}from"./constants-CDyU_g2F.js";import"./readonly-python-code-B5ABqdqK.js";import{t as le}from"./cn-DYvqRARy.js";import{t as Le}from"./jsx-runtime-Blw4afVn.js";import"./fullscreen-CTDqNQr6.js";import"./popover-Bcz1Zikb.js";import{n as Me,__tla as Pe}from"./JsonOutput-BjTsPSAI.js";import"./download-QhwPYWYu.js";import{t as z}from"./tooltip-4bZlU7jl.js";import{t as C}from"./button-DDGiD1NW.js";import"./dist-12S8I4CH.js";import"./cjs-D5tzp-Y6.js";import"./main-BNL5rxQw.js";import"./useNonce-CbdaHKzX.js";import{r as Re}from"./requests-9-v2bhoi.js";import{t as me}from"./createLucideIcon-w-Qo9n0R.js";import{f as De,__tla as He}from"./layout-BWV4OadK.js";import{n as Ve,t as qe,__tla as Te}from"./LazyAnyLanguageCodeMirror-B2JvSXP-.js";import{__tla as Ue}from"./markdown-renderer-DtzxgcfB.js";import{u as Fe}from"./toDate-Ct2FT81-.js";import{t as Ge,__tla as Qe}from"./cell-editor-DKzBZjFa.js";import{t as Ze}from"./spinner-D-V4psAa.js";import{i as Be}from"./useDeleteCell-C3nmnuxK.js";import"./dist-DcwTQG1A.js";import"./dist-DnjsPBRJ.js";import"./dist-BJZAIIze.js";import"./dist-aRc_dRed.js";import"./dist-CPjTeT8p.js";import"./session-BmukRjSi.js";import{r as Je}from"./useTheme-Bxv9B31g.js";import"./purify.es-CWmnYhGI.js";import"./dates-C2LWzsCZ.js";import"./tooltip-B7U4xkIN.js";import"./vega-loader.browser-Dun7Qe4B.js";import"./defaultLocale-DOVIEEPN.js";import"./defaultLocale-BUCH2FMc.js";import{__tla as Ke}from"./chunk-5FQGJX7Z-Cp0LZT-a.js";import"./html-to-image-DfyxinVN.js";import{o as We}from"./focus-CJzSyxLL.js";import{n as Xe,r as Ye,t as ne}from"./react-resizable-panels.browser.esm-Z-MD3n3J.js";import{a as $e}from"./renderShortcut-Bl8_FVn8.js";import"./esm-B30N1GS0.js";import"./name-cell-input-SbknxDvi.js";import{n as et,r as tt}from"./panel-context-CH75ubGG.js";import{__tla as rt}from"./loro_wasm_bg-RNUly1SE.js";import"./ws-BmTnbVEi.js";import"./Inputs-B8-VCb_j.js";import"./dist-D5ToCtv8.js";import"./dist-D35OyUMQ.js";import"./dist-ByK00N0T.js";import"./dist-C5kf6g-d.js";import"./dist-BaKJ0-Tb.js";import"./dist-DNGKAtWk.js";import"./dist-56ul6-mm.js";import"./dist-3N7-WLqi.js";import"./dist-CM-lWxt3.js";import"./esm-Cmv0Nuxi.js";import{t as ot}from"./kiosk-mode-BumOFEtY.js";let ce,at=Promise.all([(()=>{try{return Ae}catch{}})(),(()=>{try{return Pe}catch{}})(),(()=>{try{return He}catch{}})(),(()=>{try{return Te}catch{}})(),(()=>{try{return Ue}catch{}})(),(()=>{try{return Qe}catch{}})(),(()=>{try{return Ke}catch{}})(),(()=>{try{return rt}catch{}})()]).then(async()=>{var de=me("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]),pe=me("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),he=ie(),q=oe(Ne(),1),ue=15;const T=Se("marimo:scratchpadHistory:v1",[],Ce),fe=ae(!1),xe=ae(null,(e,i,s)=>{if(s=s.trim(),!s)return;let m=e(T);i(T,[s,...m.filter(c=>c!==s)].slice(0,ue))});var t=oe(Le(),1),_e={hide_code:!1,disabled:!1};const ve=()=>{var re;let e=(0,he.c)(60),i=ze(),[s]=Ie(),{theme:m}=Je(),c=(0,q.useRef)(null),U=We(),{createNewCell:F,updateCellCode:d}=ke(),{sendRunScratchpad:p}=Re(),S=et(),G=tt(),l=i.cellRuntime[n],Q=l==null?void 0:l.output,O=l==null?void 0:l.status,Z=l==null?void 0:l.consoleOutputs,r=((re=i.cellData.__scratch__)==null?void 0:re.code)??"",B=be(xe),[a,h]=ye(fe),u=we(T),A;e[0]!==B||e[1]!==r||e[2]!==p?(A=()=>{p({code:r}),B(r)},e[0]=B,e[1]=r,e[2]=p,e[3]=A):A=e[3];let f=V(A),I;e[4]!==r||e[5]!==F||e[6]!==U?(I=()=>{r.trim()&&F({code:r,before:!1,cellId:U??"__end__"})},e[4]=r,e[5]=F,e[6]=U,e[7]=I):I=e[7];let J=V(I),E;e[8]!==p||e[9]!==d?(E=()=>{d({cellId:n,code:"",formattingChange:!1}),p({code:""});let o=c.current;o&&o.dispatch({changes:{from:0,to:o.state.doc.length,insert:""}})},e[8]=p,e[9]=d,e[10]=E):E=e[10];let K=V(E),L;e[11]!==h||e[12]!==d?(L=o=>{h(!1),d({cellId:n,code:o,formattingChange:!1});let k=c.current;k&&k.dispatch({changes:{from:0,to:k.state.doc.length,insert:o}})},e[11]=h,e[12]=d,e[13]=L):L=e[13];let W=V(L),[X,ge]=(0,q.useState)(),M;e[14]!==W||e[15]!==u||e[16]!==a||e[17]!==m?(M=()=>a?(0,t.jsx)("div",{className:"absolute inset-0 z-100 bg-background p-3 border-none overflow-auto",children:(0,t.jsx)("div",{className:"overflow-auto flex flex-col gap-3",children:u.map((o,k)=>(0,t.jsx)("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>W(o),children:(0,t.jsx)(q.Suspense,{children:(0,t.jsx)(qe,{language:"python",theme:m,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},value:o.trim(),editable:!1,readOnly:!0})})},k))})}):null,e[14]=W,e[15]=u,e[16]=a,e[17]=m,e[18]=M):M=e[18];let Y=M,P;e[19]!==K||e[20]!==J||e[21]!==f||e[22]!==u.length||e[23]!==a||e[24]!==h||e[25]!==O?(P=()=>(0,t.jsxs)("div",{className:"flex items-center shrink-0 border-b",children:[(0,t.jsx)(z,{content:$e("cell.run"),children:(0,t.jsx)(C,{"data-testid":"scratchpad-run-button",onClick:f,disabled:a,variant:"text",size:"xs",children:(0,t.jsx)(Be,{color:"var(--grass-11)",size:16})})}),(0,t.jsx)(z,{content:"Clear code and outputs",children:(0,t.jsx)(C,{disabled:a,size:"xs",variant:"text",onClick:K,children:(0,t.jsx)(de,{size:16})})}),(0,t.jsx)(ot,{children:(0,t.jsx)(z,{content:"Insert code",children:(0,t.jsx)(C,{disabled:a,size:"xs",variant:"text",onClick:J,children:(0,t.jsx)(Ve,{size:16})})})}),(O==="running"||O==="queued")&&(0,t.jsx)(Ze,{className:"inline",size:"small"}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsx)(z,{content:"Toggle history",children:(0,t.jsx)(C,{size:"xs",variant:"text",className:le(a&&"bg-(--sky-3) rounded-none"),onClick:()=>h(!a),disabled:u.length===0,children:(0,t.jsx)(pe,{size:16})})}),(0,t.jsx)(z,{content:(0,t.jsx)("span",{className:"block max-w-prose",children:"Use this scratchpad to experiment with code without restrictions on variable names. Variables defined here aren't saved to notebook memory, and the code is not saved in the notebook file."}),children:(0,t.jsx)(C,{size:"xs",variant:"text",children:(0,t.jsx)(Fe,{size:16})})})]}),e[19]=K,e[20]=J,e[21]=f,e[22]=u.length,e[23]=a,e[24]=h,e[25]=O,e[26]=P):P=e[26];let $=P,je=S==="vertical",R;e[27]===Symbol.for("react.memo_cache_sentinel")?(R=Oe.create(n),e[27]=R):R=e[27];let x;e[28]===$?x=e[29]:(x=$(),e[28]=$,e[29]=x);let D;e[30]===Symbol.for("react.memo_cache_sentinel")?(D=o=>{c.current=o},e[30]=D):D=e[30];let _;e[31]!==r||e[32]!==f||e[33]!==X||e[34]!==m||e[35]!==s?(_=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Ge,{theme:m,showPlaceholder:!1,id:n,code:r,config:_e,status:"idle",serializedEditorState:null,runCell:f,userConfig:s,editorViewRef:c,setEditorView:D,hidden:!1,showHiddenCode:se.NOOP,languageAdapter:X,setLanguageAdapter:ge})}),e[31]=r,e[32]=f,e[33]=X,e[34]=m,e[35]=s,e[36]=_):_=e[36];let v;e[37]===Y?v=e[38]:(v=Y(),e[37]=Y,e[38]=v);let g;e[39]!==v||e[40]!==x||e[41]!==_?(g=(0,t.jsx)(ne,{defaultSize:40,minSize:20,maxSize:70,children:(0,t.jsxs)("div",{className:"h-full flex flex-col overflow-hidden relative",children:[x,_,v]})}),e[39]=v,e[40]=x,e[41]=_,e[42]=g):g=e[42];let ee=je?"h-1":"w-1",j;e[43]===ee?j=e[44]:(j=le("bg-border hover:bg-primary/50 transition-colors",ee),e[43]=ee,e[44]=j);let b;e[45]===j?b=e[46]:(b=(0,t.jsx)(Ye,{className:j}),e[45]=j,e[46]=b);let y;e[47]===Q?y=e[48]:(y=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Me,{allowExpand:!1,output:Q,className:Ee.outputArea,cellId:n,stale:!1,loading:!1})}),e[47]=Q,e[48]=y);let w;e[49]===Z?w=e[50]:(w=(0,t.jsx)("div",{className:"overflow-auto shrink-0 max-h-[50%]",children:(0,t.jsx)(De,{consoleOutputs:Z,className:"overflow-auto",stale:!1,interrupted:!1,cellName:"_",onSubmitDebugger:se.NOOP,cellId:n,debuggerActive:!1})}),e[49]=Z,e[50]=w);let N;e[51]!==y||e[52]!==w?(N=(0,t.jsx)(ne,{defaultSize:60,minSize:20,children:(0,t.jsxs)("div",{className:"h-full flex flex-col divide-y overflow-hidden",children:[y,w]})}),e[51]=y,e[52]=w,e[53]=N):N=e[53];let H;return e[54]!==S||e[55]!==G||e[56]!==g||e[57]!==b||e[58]!==N?(H=(0,t.jsx)("div",{className:"flex flex-col h-full overflow-hidden",id:R,children:(0,t.jsxs)(Xe,{direction:S,className:"h-full",children:[g,b,N]},G)}),e[54]=S,e[55]=G,e[56]=g,e[57]=b,e[58]=N,e[59]=H):H=e[59],H};let te;te=ie(),ce=()=>{let e=(0,te.c)(1),i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(ve,{}),e[0]=i):i=e[0],i}});export{at as __tla,ce as default};
@@ -1 +0,0 @@
1
- import{d as k,n as i,p as v}from"./useEvent-D91BmmQi.js";import{E as w,Un as y,m as p,mi as F,mt as b,si as x}from"./cells-C-9Qa_6_.js";import{t as D}from"./compiler-runtime-B3qBwwSJ.js";import{g as E}from"./useEventListener-C0195JsF.js";import{o as H}from"./dist-DYEuVkEX.js";import{r as U}from"./requests-9-v2bhoi.js";var u=D();const g=v(!1);function V(){let r=(0,u.c)(2),n=m(),t;return r[0]===n?t=r[1]:(t=()=>n(F(p())),r[0]=n,r[1]=t),i(t)}function _(r){let n=(0,u.c)(3),t=m(),o;return n[0]!==r||n[1]!==t?(o=()=>{r!==void 0&&t([r])},n[0]=r,n[1]=t,n[2]=o):o=n[2],i(o)}function j(){let r=(0,u.c)(2),n=m(),t;return r[0]===n?t=r[1]:(t=()=>n(x(p())),r[0]=n,r[1]=t),i(t)}function m(){let r=(0,u.c)(4),{prepareForRun:n}=w(),{sendRun:t}=U(),o=k(g),e;return r[0]!==n||r[1]!==t||r[2]!==o?(e=async s=>{if(s.length===0)return;let c=p();return o(!0),I({cellIds:s,sendRun:t,prepareForRun:n,notebook:c})},r[0]=n,r[1]=t,r[2]=o,r[3]=e):e=r[3],i(e)}async function I({cellIds:r,sendRun:n,prepareForRun:t,notebook:o}){var d,R,h;if(r.length===0)return;let{cellHandles:e,cellData:s}=o,c=[];for(let a of r){let l=(R=(d=e[a])==null?void 0:d.current)==null?void 0:R.editorView,f;l?(y(l)!=="markdown"&&H(l),f=b(l)):f=((h=s[a])==null?void 0:h.code)||"",c.push(f),t({cellId:a})}await n({cellIds:r,codes:c}).catch(a=>{E.error(a)})}export{m as a,_ as i,I as n,V as o,j as r,g as t};
@@ -1 +0,0 @@
1
- import{s as e}from"./chunk-LvLJmgfZ.js";import{n as p}from"./useEvent-D91BmmQi.js";import{E as d,d as f,mt as u}from"./cells-C-9Qa_6_.js";import{t as c}from"./compiler-runtime-B3qBwwSJ.js";import{t as C}from"./jsx-runtime-Blw4afVn.js";import{r as h}from"./useDeleteCell-C3nmnuxK.js";import{t as v}from"./use-toast-BwJoaaDM.js";var x=c(),b=e(C(),1);function j(){let t=(0,x.c)(3),{splitCell:i,undoSplitCell:r}=d(),o;return t[0]!==i||t[1]!==r?(o=s=>{let l=f(s.cellId);if(!l)return;let a=u(l);i(s);let{dismiss:m}=v({title:"Cell split",action:(0,b.jsx)(h,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{r({...s,snapshot:a}),n()},children:"Undo"})}),n=m},t[0]=i,t[1]=r,t[2]=o):o=t[2],p(o)}export{j as t};