@marimo-team/islands 0.23.16-dev36 → 0.23.16-dev37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chat-ui-DAPduOBU.js → chat-ui-BhycUrBk.js} +2 -2
- package/dist/{common-Bj3GHNDa.js → common-B3EcjNx8.js} +2 -2
- package/dist/{html-to-image-CRnU7G8x.js → html-to-image-3w0AakWW.js} +2090 -2087
- package/dist/main.js +5 -5
- package/dist/{process-output-CK1nZFgq.js → process-output-YXcQTd1Y.js} +1 -1
- package/dist/{reveal-component-s04jmX79.js → reveal-component-OOb_vEEG.js} +2 -2
- package/package.json +1 -1
- package/src/components/editor/cell/code/__tests__/cell-editor-activity-lifecycle.test.ts +250 -0
- package/src/components/editor/cell/code/cell-editor.tsx +13 -7
- package/src/core/cells/cells.ts +4 -4
- package/src/core/rtc/state.ts +9 -0
package/dist/main.js
CHANGED
|
@@ -22,17 +22,17 @@ import { _ as Functions, c as useEventListener, f as composeRefs, g as Logger, h
|
|
|
22
22
|
import { t as require_react } from "./react-DA-nE2FX.js";
|
|
23
23
|
import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
24
24
|
import { n as Copy, r as toast, t as copyToClipboard } from "./copy-DNq8q3zw.js";
|
|
25
|
-
import { $ as notebookOutline, $t as publishedCellClasses, A as ChevronDownIcon, An as Root2$1, At as DeferredRequestRegistry, Bn as Info, C as Accordion, Cn as atomWithReducer, Ct as MarkdownLanguageAdapter, D as BorderAllIcon, E as AccordionTrigger, Et as Paths, Fn as PaintRoller, G as hasRunAnyCellAtom, Gn as Columns2, H as renderHTML, Hn as Eye, Ht as DATA_TYPE_ICON, I as base64ToDataView, Jn as Braces, Jt as convertStatsName, K as cellIdsAtom, Lt as repl, Nn as Trash2, On as Content2, Pn as Table2, Pt as jotaiJsonStorage, Q as notebookAtom, Qt as isUninstantiated, R as dataViewToBase64, Rn as LoaderCircle, Rt as SQLParser, St as isRecord, T as AccordionItem, Tn as selectAtom, Tt as PathBuilder, U as getMarimoExportContext, V as safeExtractSetUIElementMessageBuffers, Vn as FileText, Vt as PluralWords, W as hasTrustedExportContext, Wn as Database, Wt as require_client, X as hasOnlyOneCellAtom, Xt as requestClientAtom, Y as getCellNames, Yt as getRequestClient, Z as initialNotebookState, Zt as useRequestClient, _n as UIElementId, _t as isInternalCellName, a as useCellFocusActions, at as createCell, bn as RANDOM_ID_ATTR, bt as customPythonLanguageSupport, cn as NotebookScopedLocalStorage, dn as parseAttrValue, dt as headingToIdentifier, en as shouldHidePublishedCell, et as numColumnsAtom, f as isOutputEmpty, fn as parseDataset, gt as getValidName, hn as HTMLCellId, i as LazyAnyLanguageCodeMirror, jn as Trigger2, jt as generateUUID, kn as Item$1, lt as outputIsLoading, n as Spinner, nt as useCellActions, o as useLastFocusedCellId, p as useExpandedConsoleOutput, pn as parseInitialValue, q as createActions, qn as CircleAlert, rt as useCellIds, s as maybeAddAltairImport, tt as reducer, ut as outputIsStale, vn as findCellId, vt as normalizeName, w as AccordionContent, wn as atomWithStorage, xn as jsonParseWithSpecialChar, xt as hasFunctionProperty, yn as OBJECT_ID_ATTR, yt as Checkbox, zn as Layers, zt as MarkdownParser, __tla as __tla_0 } from "./html-to-image-
|
|
25
|
+
import { $ as notebookOutline, $t as publishedCellClasses, A as ChevronDownIcon, An as Root2$1, At as DeferredRequestRegistry, Bn as Info, C as Accordion, Cn as atomWithReducer, Ct as MarkdownLanguageAdapter, D as BorderAllIcon, E as AccordionTrigger, Et as Paths, Fn as PaintRoller, G as hasRunAnyCellAtom, Gn as Columns2, H as renderHTML, Hn as Eye, Ht as DATA_TYPE_ICON, I as base64ToDataView, Jn as Braces, Jt as convertStatsName, K as cellIdsAtom, Lt as repl, Nn as Trash2, On as Content2, Pn as Table2, Pt as jotaiJsonStorage, Q as notebookAtom, Qt as isUninstantiated, R as dataViewToBase64, Rn as LoaderCircle, Rt as SQLParser, St as isRecord, T as AccordionItem, Tn as selectAtom, Tt as PathBuilder, U as getMarimoExportContext, V as safeExtractSetUIElementMessageBuffers, Vn as FileText, Vt as PluralWords, W as hasTrustedExportContext, Wn as Database, Wt as require_client, X as hasOnlyOneCellAtom, Xt as requestClientAtom, Y as getCellNames, Yt as getRequestClient, Z as initialNotebookState, Zt as useRequestClient, _n as UIElementId, _t as isInternalCellName, a as useCellFocusActions, at as createCell, bn as RANDOM_ID_ATTR, bt as customPythonLanguageSupport, cn as NotebookScopedLocalStorage, dn as parseAttrValue, dt as headingToIdentifier, en as shouldHidePublishedCell, et as numColumnsAtom, f as isOutputEmpty, fn as parseDataset, gt as getValidName, hn as HTMLCellId, i as LazyAnyLanguageCodeMirror, jn as Trigger2, jt as generateUUID, kn as Item$1, lt as outputIsLoading, n as Spinner, nt as useCellActions, o as useLastFocusedCellId, p as useExpandedConsoleOutput, pn as parseInitialValue, q as createActions, qn as CircleAlert, rt as useCellIds, s as maybeAddAltairImport, tt as reducer, ut as outputIsStale, vn as findCellId, vt as normalizeName, w as AccordionContent, wn as atomWithStorage, xn as jsonParseWithSpecialChar, xt as hasFunctionProperty, yn as OBJECT_ID_ATTR, yt as Checkbox, zn as Layers, zt as MarkdownParser, __tla as __tla_0 } from "./html-to-image-3w0AakWW.js";
|
|
26
26
|
import { __tla as __tla_1 } from "./chunk-5FQGJX7Z-B9WoXK1R.js";
|
|
27
27
|
import { o as useSize, s as Root$1, u as createLucideIcon } from "./dist-DIlxLFXG.js";
|
|
28
28
|
import { A as SquareFunction, C as DEFAULT_COLOR_SCHEME, D as SCALE_TYPE_DESCRIPTIONS, E as EMPTY_VALUE$1, O as TIME_UNIT_DESCRIPTIONS, S as DEFAULT_AGGREGATION, T as DEFAULT_TIME_UNIT, _ as AGGREGATION_TYPE_DESCRIPTIONS, a as AGGREGATION_FNS$1, b as COLOR_SCHEMES, c as COLOR_BY_FIELDS, d as NONE_VALUE, f as SELECTABLE_DATA_TYPES, g as TIME_UNITS, h as STRING_AGGREGATION_FNS, i as convertDataTypeToSelectable, j as ChartColumn, k as escapeFieldName, l as COMBINED_TIME_UNITS, m as SORT_TYPES, n as createSpecWithoutData, o as BIN_AGGREGATION, p as SINGLE_TIME_UNITS, r as isFieldSet, s as CHART_TYPES, t as augmentSpecWithData, u as ChartType, v as AGGREGATION_TYPE_ICON, w as DEFAULT_MAX_BINS_FACET, x as COUNT_FIELD, y as CHART_TYPE_ICON } from "./spec-CQKL_D3i.js";
|
|
29
|
-
import { $ as CommandSeparator, $t as Kbd, A as ErrorState, At as getPageIndexForRow, B as ContextMenuTrigger, Bt as dateToLocalISODate, C as downloadHTMLAsImage, Ct as inferFieldTypes, D as ColumnName, Dt as DelayMount, E as downloadSizeLimitAtom, Et as ColumnChartSpecModel, F as getUserColumnVisibilityCounts, Ft as TOO_MANY_ROWS, G as DateRangePicker, Gt as TabsList, H as useSelectList, Ht as dateToLocalISOTime, I as ContextMenu, It as toFieldTypes, J as Command, Jt as ChartInfoState, K as Combobox, Kt as TabsTrigger, L as ContextMenuContent, Lt as getMimeValues, M as prettifyRowColumnCount, Mt as loadTableData, N as prettifyRowCount, Nt as INDEX_COLUMN_NAME, O as ColumnPreviewContainer, Ot as useIntersectionObserver, P as getColumnCountForDisplay, Pt as SELECT_COLUMN_ID, Q as CommandList, Qt as RenderTextWithLinks, R as ContextMenuItem, Rt as isNullishFilter, S as downloadExportedFile, St as generateColumns, T as Filenames, Tt as ColumnChartContext, U as CompactChipRow, Ut as Tabs, V as useInternalStateWithSync, Vt as dateToLocalISODateTime, W as DatePicker, Wt as TabsContent, X as CommandInput, Xt as LazyVegaEmbed, Y as CommandEmpty, Yt as ChartLoadingState, Z as CommandItem, Zt as useOverflowDetection, _ as DataTable, _n as ChevronLeft, _t as TableCell, an as TextWrap, at as contextAwarePanelType, b as downloadBlob, bt as TableRow, c as SLIDE_TYPE_OPTIONS_BY_VALUE, cn as EyeOff, ct as slotsController, d as Switch, dn as Download, en as HtmlOutput, et as smartMatch, f as RadioGroup, fn as Code, g as OutputRenderer, gn as ChevronsDownUp, gt as TableBody, h as OutputArea, hn as ChevronsLeft, ht as Table, i as showCodeInRunModeAtom, in as $fae977aafc393c5c$export$6b862160d295c8e, it as contextAwarePanelOwner, j as LoadingState, jt as loadTableAndRawData, k as EmptyState, kt as usePrevious$1, lt as Toggle, m as JsonOutput, mn as ChevronsRight, mt as Provider$1, n as useNotebookCodeAvailable, nn as safeLocale, nt as PANEL_TYPES, on as GripHorizontal, ot as isCellAwareAtom, p as RadioGroupItem, pn as ChevronsUpDown, pt as Fill, q as ComboboxItem, qt as ChartErrorState, r as marimoVersionAtom, rn as $fae977aafc393c5c$export$588937bcd60ade55, rt as contextAwarePanelOpen, sn as Funnel, st as SlotNames, t as cellDomProps, tn as EmotionCacheProvider, tt as ContextAwarePanelItem, u as Slide, un as Ellipsis, v as InstallPackageButton, vn as ArrowDownWideNarrow, vt as TableHead, w as Progress, wt as renderCellValue, x as downloadByURL, xt as NAMELESS_COLUMN_PREFIX, y as ADD_PRINTING_CLASS, yt as TableHeader, z as ContextMenuSeparator, zt as Maps, __tla as __tla_2 } from "./common-
|
|
29
|
+
import { $ as CommandSeparator, $t as Kbd, A as ErrorState, At as getPageIndexForRow, B as ContextMenuTrigger, Bt as dateToLocalISODate, C as downloadHTMLAsImage, Ct as inferFieldTypes, D as ColumnName, Dt as DelayMount, E as downloadSizeLimitAtom, Et as ColumnChartSpecModel, F as getUserColumnVisibilityCounts, Ft as TOO_MANY_ROWS, G as DateRangePicker, Gt as TabsList, H as useSelectList, Ht as dateToLocalISOTime, I as ContextMenu, It as toFieldTypes, J as Command, Jt as ChartInfoState, K as Combobox, Kt as TabsTrigger, L as ContextMenuContent, Lt as getMimeValues, M as prettifyRowColumnCount, Mt as loadTableData, N as prettifyRowCount, Nt as INDEX_COLUMN_NAME, O as ColumnPreviewContainer, Ot as useIntersectionObserver, P as getColumnCountForDisplay, Pt as SELECT_COLUMN_ID, Q as CommandList, Qt as RenderTextWithLinks, R as ContextMenuItem, Rt as isNullishFilter, S as downloadExportedFile, St as generateColumns, T as Filenames, Tt as ColumnChartContext, U as CompactChipRow, Ut as Tabs, V as useInternalStateWithSync, Vt as dateToLocalISODateTime, W as DatePicker, Wt as TabsContent, X as CommandInput, Xt as LazyVegaEmbed, Y as CommandEmpty, Yt as ChartLoadingState, Z as CommandItem, Zt as useOverflowDetection, _ as DataTable, _n as ChevronLeft, _t as TableCell, an as TextWrap, at as contextAwarePanelType, b as downloadBlob, bt as TableRow, c as SLIDE_TYPE_OPTIONS_BY_VALUE, cn as EyeOff, ct as slotsController, d as Switch, dn as Download, en as HtmlOutput, et as smartMatch, f as RadioGroup, fn as Code, g as OutputRenderer, gn as ChevronsDownUp, gt as TableBody, h as OutputArea, hn as ChevronsLeft, ht as Table, i as showCodeInRunModeAtom, in as $fae977aafc393c5c$export$6b862160d295c8e, it as contextAwarePanelOwner, j as LoadingState, jt as loadTableAndRawData, k as EmptyState, kt as usePrevious$1, lt as Toggle, m as JsonOutput, mn as ChevronsRight, mt as Provider$1, n as useNotebookCodeAvailable, nn as safeLocale, nt as PANEL_TYPES, on as GripHorizontal, ot as isCellAwareAtom, p as RadioGroupItem, pn as ChevronsUpDown, pt as Fill, q as ComboboxItem, qt as ChartErrorState, r as marimoVersionAtom, rn as $fae977aafc393c5c$export$588937bcd60ade55, rt as contextAwarePanelOpen, sn as Funnel, st as SlotNames, t as cellDomProps, tn as EmotionCacheProvider, tt as ContextAwarePanelItem, u as Slide, un as Ellipsis, v as InstallPackageButton, vn as ArrowDownWideNarrow, vt as TableHead, w as Progress, wt as renderCellValue, x as downloadByURL, xt as NAMELESS_COLUMN_PREFIX, y as ADD_PRINTING_CLASS, yt as TableHeader, z as ContextMenuSeparator, zt as Maps, __tla as __tla_2 } from "./common-B3EcjNx8.js";
|
|
30
30
|
import { c as Calendar, i as createReducerAndAtoms, n as useOnUnmount, o as ToggleLeft, t as useOnMount } from "./useLifecycle-CMJGqBaY.js";
|
|
31
31
|
import { t as Check } from "./check-DP7U0H0G.js";
|
|
32
32
|
import { A as Icon, C as logNever, D as $18f2051aff69b9bf$export$a54013f0d02a8f82, E as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7, F as createCollection, I as X, M as clamp$2, N as usePrevious$2, P as useDirection, R as ChevronDown, S as assertNever, a as SelectGroup, c as SelectSeparator, d as NativeSelect, i as SelectContent, j as Trigger$1, l as SelectTrigger, n as capitalize, o as SelectItem, r as Select, s as SelectLabel, t as Strings, u as SelectValue, w as $a916eb452884faea$export$b7a616150fdb9f44 } from "./strings-DIy9NAmg.js";
|
|
33
33
|
import { B as $64fa3d84918910a7$export$4d86445c2cf5e3, C as DropdownMenuTrigger, Ft as $65484d02dcb7eb3e$export$457c3d6518dd4c6f, It as $3ef42575df84b30b$export$9d1611c77c2fe928, W as $64fa3d84918910a7$export$df3a06d6289f983e, Wt as $ff5963eb1fccf552$export$e08e3b67e392101e, X as useDebouncedCallback, Y as useDebounceControlledState, a as NumberField, d as roundToFractionDigits, f as DropdownMenu, g as DropdownMenuLabel, gn as ChevronRight, h as DropdownMenuItem, hn as Circle, i as OnBlurredInput, l as prettyNumber, m as DropdownMenuGroup, n as DebouncedNumberInput, o as maxFractionDigitsForSteps, ot as $f7dceffc5ad7768b$export$4e328f61c538687f, p as DropdownMenuContent, pt as $6179b936705e76d3$export$ae780daf29e6d456, r as Input, st as $701a24aa0da5b062$export$ea18c227d4417cc3, t as DebouncedInput, u as prettyScientificNumber, v as DropdownMenuSeparator, xt as $458b0a5536c1a7cf$export$40bfa8c7b0832715, y as DropdownMenuShortcut, z as $64fa3d84918910a7$export$29f1550f4b0d4415 } from "./input-C5K4VBvB.js";
|
|
34
34
|
import { S as isWasm, _ as initialModeAtom, b as viewStateAtom, c as asRemoteURL, d as isStaticNotebook, f as appendQueryParams, g as getInitialAppMode, m as require_cuid2, u as getStaticVirtualFiles, v as kioskModeAtom, w as CircleQuestionMark, x as Deferred } from "./toDate-CqhBWjvO.js";
|
|
35
|
-
import { a as MarimoIncomingMessageEvent, c as MarimoValueUpdateEvent, d as Square, f as File, i as PythonIcon, l as createInputEvent, n as blobToString, o as MarimoValueInputEvent, r as filesToBase64, s as MarimoValueReadyEvent, t as processOutput, u as deserializeBlob } from "./process-output-
|
|
35
|
+
import { a as MarimoIncomingMessageEvent, c as MarimoValueUpdateEvent, d as Square, f as File, i as PythonIcon, l as createInputEvent, n as blobToString, o as MarimoValueInputEvent, r as filesToBase64, s as MarimoValueReadyEvent, t as processOutput, u as deserializeBlob } from "./process-output-YXcQTd1Y.js";
|
|
36
36
|
import { n as Trash, r as Pencil, t as BulkEdit } from "./types-DicH9Oi0.js";
|
|
37
37
|
import { n as require_prop_types, r as Plus, t as ErrorBoundary } from "./ErrorBoundary-DhLqwSWA.js";
|
|
38
38
|
import { t as require_react_dom } from "./react-dom-BTJzcVJ9.js";
|
|
@@ -9009,7 +9009,7 @@ let __tla = Promise.all([
|
|
|
9009
9009
|
};
|
|
9010
9010
|
}
|
|
9011
9011
|
};
|
|
9012
|
-
var LazyChatbot = import_react.lazy(() => import("./chat-ui-
|
|
9012
|
+
var LazyChatbot = import_react.lazy(() => import("./chat-ui-BhycUrBk.js").then((e) => ({
|
|
9013
9013
|
default: e.Chatbot
|
|
9014
9014
|
}))), messageSchema = array(object({
|
|
9015
9015
|
id: string(),
|
|
@@ -38147,7 +38147,7 @@ ${c}
|
|
|
38147
38147
|
function _temp2$2(e) {
|
|
38148
38148
|
e.target === e.currentTarget && e.key === "Enter" && (e.preventDefault(), e.stopPropagation(), e.currentTarget.click());
|
|
38149
38149
|
}
|
|
38150
|
-
var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-
|
|
38150
|
+
var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-OOb_vEEG.js"));
|
|
38151
38151
|
const SlidesLayoutRenderer = ({ layout: e, setLayout: r, cells: c, mode: l }) => {
|
|
38152
38152
|
var _a5;
|
|
38153
38153
|
let u = useAtomValue(kioskModeAtom), d = l === "read" || u, f = useAtomValue(numColumnsAtom) > 1, [p, m] = (0, import_react.useState)(null), { slideCells: h, skippedIds: g, noOutputIds: _, slideTypes: v, startCellIndex: y } = (0, import_react.useMemo)(() => computeSlideCellsInfo(c, e), [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as __toESM } from "./chunk-BNovOVIE.js";
|
|
2
2
|
import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
3
|
-
import { ot as ansiToPlainText, st as parseHtmlContent } from "./html-to-image-
|
|
3
|
+
import { ot as ansiToPlainText, st as parseHtmlContent } from "./html-to-image-3w0AakWW.js";
|
|
4
4
|
import { u as createLucideIcon } from "./dist-DIlxLFXG.js";
|
|
5
5
|
import { t as Strings } from "./strings-DIy9NAmg.js";
|
|
6
6
|
import { t as require_jsx_runtime } from "./jsx-runtime-DebpN0FN.js";
|
|
@@ -6,10 +6,10 @@ import { s as __toESM } from "./chunk-BNovOVIE.js";
|
|
|
6
6
|
import { c as useEventListener, g as Logger, h as cn, m as Events, t as Button } from "./button-BSm8IXRU.js";
|
|
7
7
|
import { t as require_react } from "./react-DA-nE2FX.js";
|
|
8
8
|
import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
9
|
-
import { ut as outputIsStale } from "./html-to-image-
|
|
9
|
+
import { ut as outputIsStale } from "./html-to-image-3w0AakWW.js";
|
|
10
10
|
import "./chunk-5FQGJX7Z-B9WoXK1R.js";
|
|
11
11
|
import { u as createLucideIcon } from "./dist-DIlxLFXG.js";
|
|
12
|
-
import { a as DEFAULT_DECK_TRANSITION, cn as EyeOff, dt as PanelGroup, fn as Code, ft as PanelResizeHandle, l as SlideSidebar, ln as Expand, n as useNotebookCodeAvailable, o as DEFAULT_DECK_VERTICAL_ALIGN, s as DEFAULT_SLIDE_TYPE, t as cellDomProps, u as Slide, ut as Panel } from "./common-
|
|
12
|
+
import { a as DEFAULT_DECK_TRANSITION, cn as EyeOff, dt as PanelGroup, fn as Code, ft as PanelResizeHandle, l as SlideSidebar, ln as Expand, n as useNotebookCodeAvailable, o as DEFAULT_DECK_VERTICAL_ALIGN, s as DEFAULT_SLIDE_TYPE, t as cellDomProps, u as Slide, ut as Panel } from "./common-B3EcjNx8.js";
|
|
13
13
|
import { R as ChevronDown } from "./strings-DIy9NAmg.js";
|
|
14
14
|
import { X as useDebouncedCallback } from "./input-C5K4VBvB.js";
|
|
15
15
|
import { v as kioskModeAtom } from "./toDate-CqhBWjvO.js";
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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 (
|
|
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}>
|
package/src/core/cells/cells.ts
CHANGED
|
@@ -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
|
-
//
|
|
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);
|
package/src/core/rtc/state.ts
CHANGED
|
@@ -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
|
+
}
|