@marimo-team/islands 0.25.3-dev173 → 0.25.3-dev176
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/{ErrorBoundary-wT3f3iJ1.js → ErrorBoundary-D66f-xAE.js} +1 -1
- package/dist/{any-language-editor-B92WMzoC.js → any-language-editor-BVFHDDQ3.js} +2 -2
- package/dist/{chat-ui-CuORr6fL.js → chat-ui-X-cWrL9u.js} +1222 -1222
- package/dist/{code-visibility-ZReaeMaF.js → code-visibility-CVVeTAwi.js} +2 -2
- package/dist/{common-DCevHg1m.js → common-DNlm9Cdj.js} +1074 -1078
- package/dist/{data-grid-overlay-editor-CTC-bJus.js → data-grid-overlay-editor-BArE3_zi.js} +1 -1
- package/dist/{dist-F8Ep36rk.js → dist-B1M0bGO3.js} +1 -1
- package/dist/{dist-D6d86eNJ.js → dist-BA13RJj5.js} +1 -1
- package/dist/{dist-Bvs24R_E.js → dist-BJtmSgcE.js} +48 -48
- package/dist/{dist-CN_BeG2I.js → dist-Ba2VIn1K.js} +53 -53
- package/dist/{dist-PXYI_yuP.js → dist-Bj4bmwUm.js} +12 -12
- package/dist/{dist-DoE4XJBC.js → dist-BmS-ZGjl.js} +8626 -8626
- package/dist/{dist-BorMD-uX.js → dist-Bzogh7CW.js} +87 -87
- package/dist/{dist-CN8zI-XC.js → dist-CThPVKaP.js} +1385 -1382
- package/dist/{dist-DiDibOYr.js → dist-CTi5FTiV.js} +87 -87
- package/dist/{dist-diIx5qJW.js → dist-Ck_C32ye.js} +2 -2
- package/dist/{dist-BLfKmR-l.js → dist-D1fnFp1J.js} +1 -1
- package/dist/{dist-OR1OnN-y.js → dist-D3x9__Fu.js} +46 -46
- package/dist/{dist-BMQf5zIS.js → dist-D7mrh5sO.js} +36 -36
- package/dist/{dist-CSJ0MDRw.js → dist-D9Q3xjiP.js} +1 -1
- package/dist/{dist-BuaRHxOc.js → dist-DP60Ubh8.js} +2 -2
- package/dist/{dist-CSbh1PNP.js → dist-DTv9KkpW.js} +12 -12
- package/dist/{dist-D-wwqlzJ.js → dist-DVVwOfrD.js} +109 -109
- package/dist/{dist-C8fAKSH1.js → dist-DYXM73-k.js} +36 -36
- package/dist/{dist-DBtSl3sf.js → dist-DjeybPOb.js} +1 -1
- package/dist/{dist-CrSP_H1M.js → dist-DtGn9N4h.js} +197 -197
- package/dist/{dist-CLdpGQVr.js → dist-KN80qWCP.js} +2 -2
- package/dist/{dist-Cg7gzw-a.js → dist-O0qFpEJh.js} +56 -56
- package/dist/{dist-CkTTIdBe.js → dist-OUle2RT7.js} +207 -207
- package/dist/{dist-BK4Oj99o.js → dist-T5rh6JvL.js} +1 -1
- package/dist/{error-entries-CmWMEsY_.js → error-entries-mpoD5t79.js} +4939 -4983
- package/dist/{esm-D2gTsXEV.js → esm-Bbw_Njjx.js} +575 -575
- package/dist/{esm-AMFssoNp.js → esm-mDQNEFe_.js} +354 -354
- package/dist/{feedback-button-DwXkmewo.js → feedback-button-CyvqdxXN.js} +21 -21
- package/dist/{glide-data-editor-BlmcP-lw.js → glide-data-editor-BxvYRMC3.js} +3 -3
- package/dist/{globals-BdRitZ4p.js → globals-BJla9q8e.js} +1 -1
- package/dist/{html-to-image-bpiQh7ND.js → html-to-image-BoZthB4P.js} +454 -445
- package/dist/main.js +3587 -3587
- package/dist/{number-overlay-editor-DQG-hFHT.js → number-overlay-editor-BWg7xiRF.js} +1 -1
- package/dist/{process-output-BzloOI7F.js → process-output-DLS4Mqg_.js} +2 -2
- package/dist/{reveal-component-D3r3vSTK.js → reveal-component-feAltY24.js} +3 -3
- package/package.json +1 -1
- package/src/__mocks__/document.tsx +54 -0
- package/src/__mocks__/notebook.ts +2 -1
- package/src/__mocks__/requests.ts +0 -2
- package/src/components/chat/chat-panel.tsx +3 -3
- package/src/components/datasources/__tests__/column-preview.test.tsx +6 -8
- package/src/components/datasources/column-preview.tsx +4 -8
- package/src/components/datasources/datasources.tsx +4 -3
- package/src/components/dependency-graph/minimap-content.tsx +2 -6
- package/src/components/dependency-graph/panels.tsx +2 -1
- package/src/components/editor/__tests__/Output.test.tsx +50 -32
- package/src/components/editor/__tests__/data-attributes.test.tsx +22 -11
- package/src/components/editor/__tests__/output-persistence.test.tsx +6 -1
- package/src/components/editor/actions/__tests__/name-cell-input.test.tsx +69 -0
- package/src/components/editor/actions/name-cell-input.tsx +4 -3
- package/src/components/editor/actions/useCellActionButton.tsx +20 -26
- package/src/components/editor/actions/useNotebookActions.tsx +13 -18
- package/src/components/editor/actions/useSetCodeVisibility.ts +10 -11
- package/src/components/editor/actions/useSetOutputsExpanded.ts +13 -18
- package/src/components/editor/cell/CreateCellButton.tsx +5 -9
- package/src/components/editor/cell/__tests__/StagedAICell.test.tsx +3 -1
- package/src/components/editor/cell/code/cell-editor.tsx +13 -20
- package/src/components/editor/cell/useAddCell.ts +4 -8
- package/src/components/editor/cell/useDeleteCell.tsx +10 -36
- package/src/components/editor/cell/useRunCells.ts +2 -5
- package/src/components/editor/cell/useSplitCell.tsx +2 -1
- package/src/components/editor/chrome/panels/logs-panel.tsx +2 -1
- package/src/components/editor/chrome/panels/snippets-panel.tsx +5 -11
- package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +3 -1
- package/src/components/editor/columns/sortable-column.tsx +1 -1
- package/src/components/editor/connections/components.tsx +4 -9
- package/src/components/editor/controls/Controls.tsx +1 -1
- package/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx +9 -3
- package/src/components/editor/documentation.css +34 -11
- package/src/components/editor/errors/auto-fix.tsx +4 -8
- package/src/components/editor/file-tree/file-explorer.tsx +3 -7
- package/src/components/editor/links/__tests__/cell-link.test.tsx +3 -1
- package/src/components/editor/links/cell-link.tsx +2 -1
- package/src/components/editor/navigation/__tests__/clipboard.test.ts +60 -38
- package/src/components/editor/navigation/__tests__/navigation.test.ts +73 -64
- package/src/components/editor/navigation/clipboard.ts +12 -11
- package/src/components/editor/navigation/multi-cell-action-toolbar.tsx +11 -20
- package/src/components/editor/navigation/navigation.ts +20 -28
- package/src/components/editor/notebook-cell.tsx +7 -10
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +125 -69
- package/src/components/editor/renderers/cell-array.tsx +10 -17
- package/src/components/markdown/markdown-renderer.tsx +4 -8
- package/src/components/pages/edit-page.tsx +32 -17
- package/src/components/scratchpad/scratchpad.test.tsx +3 -1
- package/src/components/scratchpad/scratchpad.tsx +4 -7
- package/src/components/slides/__tests__/minimap-actions.test.tsx +9 -25
- package/src/components/slides/minimap.tsx +7 -3
- package/src/components/slides/slide-cell-view.tsx +3 -3
- package/src/components/sort/SortableCellsProvider.tsx +2 -1
- package/src/core/ai/__tests__/staged-cells.test.ts +18 -20
- package/src/core/ai/staged-cells.ts +8 -16
- package/src/core/ai/tools/__tests__/edit-notebook-tool.test.ts +2 -2
- package/src/core/ai/tools/__tests__/run-cells-tool.test.ts +2 -2
- package/src/core/ai/tools/base.ts +2 -2
- package/src/core/ai/tools/edit-notebook-tool.ts +13 -21
- package/src/core/cells/__tests__/actions.test.ts +474 -34
- package/src/core/cells/__tests__/add-missing-import.test.ts +7 -8
- package/src/core/cells/__tests__/cells.test.ts +171 -813
- package/src/core/cells/__tests__/document.test.ts +5 -35
- package/src/core/cells/__tests__/notebook-outline.test.ts +7 -1
- package/src/core/cells/__tests__/outputs.test.tsx +71 -53
- package/src/core/cells/actions.ts +391 -3
- package/src/core/cells/add-missing-import.ts +46 -42
- package/src/core/cells/cells.ts +38 -413
- package/src/core/cells/document.ts +7 -4
- package/src/core/cells/outputs.ts +12 -28
- package/src/core/codemirror/cells/extensions.ts +6 -6
- package/src/core/codemirror/cells/state.ts +1 -1
- package/src/core/codemirror/keymaps/vim.ts +2 -2
- package/src/core/edit-app.tsx +19 -27
- package/src/core/islands/bridge.ts +0 -2
- package/src/core/kernel/handlers.ts +3 -3
- package/src/core/network/__tests__/requests-lazy.test.ts +1 -3
- package/src/core/network/requests-lazy.ts +0 -2
- package/src/core/network/requests-network.ts +0 -16
- package/src/core/network/requests-static.ts +0 -2
- package/src/core/network/requests-toasting.tsx +0 -2
- package/src/core/network/types.ts +0 -7
- package/src/core/notebook/document/__tests__/codemirror.test.ts +5 -0
- package/src/core/notebook/document/__tests__/draft.test.ts +41 -0
- package/src/core/notebook/document/__tests__/state.test.ts +21 -0
- package/src/core/notebook/document/draft.ts +35 -5
- package/src/core/notebook/document/index.ts +1 -0
- package/src/core/notebook/document/state.ts +6 -2
- package/src/core/session/useNotebookSession.tsx +6 -2
- package/src/core/wasm/bridge.ts +0 -16
- package/src/css/globals.css +56 -22
- package/src/stories/runtime-story.tsx +22 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as e } from "./rolldown-runtime-Cb76FRpK.js";
|
|
2
2
|
import { t } from "./react-sHtZdjeP.js";
|
|
3
|
-
import { a as n } from "./glide-data-editor-
|
|
3
|
+
import { a as n } from "./glide-data-editor-BxvYRMC3.js";
|
|
4
4
|
//#region ../node_modules/.pnpm/@glideapps+glide-data-grid@6.0.4-alpha24_lodash@4.17.21_marked@15.0.12_react-dom@19.3.0_27cffe7f1bc30287d59ac27db3240c5b/node_modules/@glideapps/glide-data-grid/dist/esm/internal/data-grid-overlay-editor/private/number-overlay-editor-style.js
|
|
5
5
|
var r = /* @__PURE__ */ e(t()), i = /*#__PURE__*/ n("div")({
|
|
6
6
|
name: "NumberOverlayEditorStyle",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as e } from "./html-to-image-BoZthB4P.js";
|
|
2
2
|
import { m as t } from "./tooltip-s4zZxwKe.js";
|
|
3
|
-
import {
|
|
3
|
+
import { b as n, x as r } from "./error-entries-mpoD5t79.js";
|
|
4
4
|
import { b as i } from "./select-2KOiReNY.js";
|
|
5
5
|
import { n as a } from "./semaphore-89jsoHtS.js";
|
|
6
6
|
var o = t("file", [["path", {
|
|
@@ -3,15 +3,15 @@ import { c as t, g as n, h as r, m as i, t as a } from "./button-BQRdqQi1.js";
|
|
|
3
3
|
import { t as o } from "./react-sHtZdjeP.js";
|
|
4
4
|
import { t as s } from "./compiler-runtime-CldRdSsv.js";
|
|
5
5
|
import { m as c, t as l } from "./tooltip-s4zZxwKe.js";
|
|
6
|
-
import {
|
|
7
|
-
import { $ as d, Q as f, Z as p, an as m, i as h, l as g, ln as _, n as v, on as y, r as b, t as x, u as S } from "./common-
|
|
6
|
+
import { E as u } from "./error-entries-mpoD5t79.js";
|
|
7
|
+
import { $ as d, Q as f, Z as p, an as m, i as h, l as g, ln as _, n as v, on as y, r as b, t as x, u as S } from "./common-DNlm9Cdj.js";
|
|
8
8
|
import { M as C } from "./select-2KOiReNY.js";
|
|
9
9
|
import { J as ee } from "./dropdown-menu-DCMbbQ35.js";
|
|
10
10
|
import { _ as w } from "./toDate-CDzoofJo.js";
|
|
11
11
|
import { t as T } from "./jsx-runtime-3BD1kT0s.js";
|
|
12
12
|
import { X as E } from "./use-restore-focus-BgDTd2tc.js";
|
|
13
13
|
import { A as D, w as O, x as k } from "./useTheme-DMfQYmlG.js";
|
|
14
|
-
import { a as A, n as te, t as ne } from "./code-visibility-
|
|
14
|
+
import { a as A, n as te, t as ne } from "./code-visibility-CVVeTAwi.js";
|
|
15
15
|
/* empty css */
|
|
16
16
|
var j = c("sticky-note", [["path", {
|
|
17
17
|
d: "M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",
|
package/package.json
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { atom, type createStore, Provider } from "jotai";
|
|
4
|
+
import type { ReactNode } from "react";
|
|
5
|
+
import {
|
|
6
|
+
createDocumentModel,
|
|
7
|
+
type DocumentModel,
|
|
8
|
+
DocumentProvider,
|
|
9
|
+
} from "@/core/notebook/document";
|
|
10
|
+
import { document as documentFixture } from "@/core/notebook/document/__tests__/fixtures";
|
|
11
|
+
import type { Document } from "@/core/notebook/replica";
|
|
12
|
+
import { fakeBackend } from "@/core/notebook/replica/__tests__/fixtures";
|
|
13
|
+
import { activeDocumentModelAtom } from "@/core/session/active-notebook";
|
|
14
|
+
|
|
15
|
+
/** A started document model over `document`, for components that edit cells. */
|
|
16
|
+
export function mockDocumentModel(
|
|
17
|
+
store: ReturnType<typeof createStore>,
|
|
18
|
+
document: Document | null = documentFixture(),
|
|
19
|
+
): { model: DocumentModel; stop: () => void } {
|
|
20
|
+
const controller = new AbortController();
|
|
21
|
+
const model = createDocumentModel({
|
|
22
|
+
store,
|
|
23
|
+
documentAtom: atom(document),
|
|
24
|
+
backendAtom: atom(fakeBackend()),
|
|
25
|
+
});
|
|
26
|
+
model.start({ signal: controller.signal });
|
|
27
|
+
store.set(activeDocumentModelAtom, model);
|
|
28
|
+
return {
|
|
29
|
+
model,
|
|
30
|
+
stop: () => {
|
|
31
|
+
controller.abort();
|
|
32
|
+
if (store.get(activeDocumentModelAtom) === model) {
|
|
33
|
+
store.set(activeDocumentModelAtom, null);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Provide `store` and `model` to a rendered hook or component. */
|
|
40
|
+
export function DocumentWrapper({
|
|
41
|
+
store,
|
|
42
|
+
model,
|
|
43
|
+
children,
|
|
44
|
+
}: {
|
|
45
|
+
store: ReturnType<typeof createStore>;
|
|
46
|
+
model: DocumentModel;
|
|
47
|
+
children?: ReactNode;
|
|
48
|
+
}) {
|
|
49
|
+
return (
|
|
50
|
+
<Provider store={store}>
|
|
51
|
+
<DocumentProvider model={model}>{children}</DocumentProvider>
|
|
52
|
+
</Provider>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { createRef } from "react";
|
|
4
4
|
import { vi } from "vitest";
|
|
5
|
-
import type { CellActions
|
|
5
|
+
import type { CellActions } from "@/core/cells/actions";
|
|
6
|
+
import type { NotebookState } from "@/core/cells/cells";
|
|
6
7
|
import { CellId } from "@/core/cells/ids";
|
|
7
8
|
import {
|
|
8
9
|
type CellData,
|
|
@@ -26,11 +26,9 @@ export const MockRequestClient = {
|
|
|
26
26
|
sendRun: vi.fn().mockResolvedValue({}),
|
|
27
27
|
sendRunScratchpad: vi.fn().mockResolvedValue({}),
|
|
28
28
|
sendInstantiate: vi.fn().mockResolvedValue({}),
|
|
29
|
-
sendDeleteCell: vi.fn().mockResolvedValue({}),
|
|
30
29
|
sendCodeCompletionRequest: vi.fn().mockResolvedValue({ items: [] }),
|
|
31
30
|
saveUserConfig: vi.fn().mockResolvedValue({}),
|
|
32
31
|
saveAppConfig: vi.fn().mockResolvedValue({}),
|
|
33
|
-
saveCellConfig: vi.fn().mockResolvedValue({}),
|
|
34
32
|
sendFunctionRequest: vi.fn().mockResolvedValue({}),
|
|
35
33
|
sendInstallMissingPackages: vi.fn().mockResolvedValue({}),
|
|
36
34
|
readCode: vi.fn().mockResolvedValue({ contents: "" }),
|
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
type CopilotMode,
|
|
54
54
|
FRONTEND_TOOL_REGISTRY,
|
|
55
55
|
} from "@/core/ai/tools/registry";
|
|
56
|
-
import { useCellActions } from "@/core/cells/
|
|
56
|
+
import { useCellActions } from "@/core/cells/actions";
|
|
57
57
|
import { aiAtom, aiModelConfiguredAtom } from "@/core/config/config";
|
|
58
58
|
import { DEFAULT_AI_MODEL } from "@/core/config/config-schema";
|
|
59
59
|
import { useRequestClient } from "@/core/network/requests";
|
|
@@ -582,10 +582,10 @@ const ChatPanelBody = () => {
|
|
|
582
582
|
const store = useStore();
|
|
583
583
|
|
|
584
584
|
const { addStagedCell } = useStagedAICellsActions();
|
|
585
|
-
const {
|
|
585
|
+
const { prepareForRun, createCell } = useCellActions();
|
|
586
586
|
const toolContext: ToolNotebookContext = {
|
|
587
587
|
addStagedCell,
|
|
588
|
-
|
|
588
|
+
createCell,
|
|
589
589
|
prepareForRun,
|
|
590
590
|
sendRun,
|
|
591
591
|
store,
|
|
@@ -12,11 +12,10 @@ import { requestClientAtom } from "@/core/network/requests";
|
|
|
12
12
|
import { store } from "@/core/state/jotai";
|
|
13
13
|
import { DatasetColumnPreview } from "../column-preview";
|
|
14
14
|
|
|
15
|
-
const {
|
|
15
|
+
const { createCell } = vi.hoisted(() => ({ createCell: vi.fn() }));
|
|
16
16
|
|
|
17
|
-
vi.mock("@/core/cells/
|
|
18
|
-
|
|
19
|
-
useCellActions: () => ({ createNewCell }),
|
|
17
|
+
vi.mock("@/core/cells/actions", () => ({
|
|
18
|
+
useCellActions: () => ({ createCell }),
|
|
20
19
|
}));
|
|
21
20
|
|
|
22
21
|
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
@@ -179,12 +178,11 @@ describe("DatasetColumnPreview chart actions", () => {
|
|
|
179
178
|
name: `Add chart to notebook for ${column.name}`,
|
|
180
179
|
}),
|
|
181
180
|
);
|
|
182
|
-
expect(
|
|
181
|
+
expect(createCell).toHaveBeenLastCalledWith({
|
|
182
|
+
after: null,
|
|
183
183
|
code: `chart_${column.name}`,
|
|
184
|
-
before: false,
|
|
185
|
-
cellId: "__end__",
|
|
186
184
|
});
|
|
187
185
|
}
|
|
188
|
-
expect(
|
|
186
|
+
expect(createCell).toHaveBeenCalledTimes(2);
|
|
189
187
|
});
|
|
190
188
|
});
|
|
@@ -5,7 +5,7 @@ import { PlusSquareIcon } from "lucide-react";
|
|
|
5
5
|
import React, { Suspense } from "react";
|
|
6
6
|
import { useLocale } from "react-aria";
|
|
7
7
|
import { maybeAddAltairImport } from "@/core/cells/add-missing-import";
|
|
8
|
-
import { useCellActions } from "@/core/cells/
|
|
8
|
+
import { useCellActions } from "@/core/cells/actions";
|
|
9
9
|
import { useLastFocusedCellId } from "@/core/cells/focus";
|
|
10
10
|
import { autoInstantiateAtom } from "@/core/config/config";
|
|
11
11
|
import type { SQLTableContext } from "@/core/datasets/data-source-connections";
|
|
@@ -249,21 +249,17 @@ export const AddDataframeChart: React.FC<{
|
|
|
249
249
|
}> = ({ chartCode, columnName }) => {
|
|
250
250
|
const autoInstantiate = useAtomValue(autoInstantiateAtom);
|
|
251
251
|
const lastFocusedCellId = useLastFocusedCellId();
|
|
252
|
-
const {
|
|
252
|
+
const { createCell } = useCellActions();
|
|
253
253
|
|
|
254
254
|
const handleAddColumn = (chartCode: string) => {
|
|
255
255
|
if (chartCode.includes("alt")) {
|
|
256
256
|
maybeAddAltairImport({
|
|
257
257
|
autoInstantiate,
|
|
258
|
-
|
|
258
|
+
createCell,
|
|
259
259
|
fromCellId: lastFocusedCellId,
|
|
260
260
|
});
|
|
261
261
|
}
|
|
262
|
-
|
|
263
|
-
code: chartCode,
|
|
264
|
-
before: false,
|
|
265
|
-
cellId: lastFocusedCellId ?? "__end__",
|
|
266
|
-
});
|
|
262
|
+
createCell({ after: lastFocusedCellId, code: chartCode });
|
|
267
263
|
};
|
|
268
264
|
|
|
269
265
|
return (
|
|
@@ -17,7 +17,8 @@ import { Button, buttonVariants } from "@/components/ui/button";
|
|
|
17
17
|
import { Command, CommandInput, CommandItem } from "@/components/ui/command";
|
|
18
18
|
import { Tooltip } from "@/components/ui/tooltip";
|
|
19
19
|
import { maybeAddMarimoImport } from "@/core/cells/add-missing-import";
|
|
20
|
-
import { cellIdsAtom
|
|
20
|
+
import { cellIdsAtom } from "@/core/cells/cells";
|
|
21
|
+
import { useCellActions } from "@/core/cells/actions";
|
|
21
22
|
import { useLastFocusedCellId } from "@/core/cells/focus";
|
|
22
23
|
import { autoInstantiateAtom } from "@/core/config/config";
|
|
23
24
|
import {
|
|
@@ -849,13 +850,13 @@ const DatasetTableItem: React.FC<{
|
|
|
849
850
|
|
|
850
851
|
const autoInstantiate = useAtomValue(autoInstantiateAtom);
|
|
851
852
|
const lastFocusedCellId = useLastFocusedCellId();
|
|
852
|
-
const {
|
|
853
|
+
const { createCell } = useCellActions();
|
|
853
854
|
const addCodeToNewCell = useAddCodeToNewCell();
|
|
854
855
|
|
|
855
856
|
const handleAddTable = () => {
|
|
856
857
|
maybeAddMarimoImport({
|
|
857
858
|
autoInstantiate,
|
|
858
|
-
|
|
859
|
+
createCell,
|
|
859
860
|
fromCellId: lastFocusedCellId,
|
|
860
861
|
});
|
|
861
862
|
const getCode = () => {
|
|
@@ -7,12 +7,8 @@ import {
|
|
|
7
7
|
cellGraphsAtom,
|
|
8
8
|
isVariableAffectedBySelectedCell,
|
|
9
9
|
} from "@/components/editor/chrome/wrapper/minimap-state";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
useCellData,
|
|
13
|
-
useCellIds,
|
|
14
|
-
useCellRuntime,
|
|
15
|
-
} from "@/core/cells/cells";
|
|
10
|
+
import { useCellData, useCellIds, useCellRuntime } from "@/core/cells/cells";
|
|
11
|
+
import { useCellActions } from "@/core/cells/actions";
|
|
16
12
|
import { cellFocusAtom, useCellFocusActions } from "@/core/cells/focus";
|
|
17
13
|
import type { CellId } from "@/core/cells/ids";
|
|
18
14
|
import { useVariables } from "@/core/variables/state";
|
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
} from "lucide-react";
|
|
15
15
|
import React, { memo, useId } from "react";
|
|
16
16
|
import { type Edge, Panel } from "reactflow";
|
|
17
|
-
import { getCellEditorView
|
|
17
|
+
import { getCellEditorView } from "@/core/cells/cells";
|
|
18
|
+
import { useCellActions } from "@/core/cells/actions";
|
|
18
19
|
import type { CellId } from "@/core/cells/ids";
|
|
19
20
|
import { goToVariableDefinition } from "@/core/codemirror/go-to-definition/commands";
|
|
20
21
|
import type { Variable, Variables } from "@/core/variables/types";
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
3
3
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { createStore, Provider } from "jotai";
|
|
5
|
+
import { mockDocumentModel } from "@/__mocks__/document";
|
|
4
6
|
import { cellId } from "@/__tests__/branded";
|
|
7
|
+
import { DocumentProvider } from "@/core/notebook/document";
|
|
5
8
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
6
9
|
import { OutputArea, OutputRenderer } from "../Output";
|
|
7
10
|
|
|
11
|
+
const store = createStore();
|
|
12
|
+
const { model } = mockDocumentModel(store, null);
|
|
13
|
+
|
|
8
14
|
describe("OutputRenderer renderFallback prop", () => {
|
|
9
15
|
it("should use renderFallback for unsupported mimetypes", () => {
|
|
10
16
|
const renderFallback = (mimetype: string) => (
|
|
@@ -70,31 +76,39 @@ describe("OutputRenderer renderFallback prop", () => {
|
|
|
70
76
|
describe("OutputArea null/undefined handling", () => {
|
|
71
77
|
it("should render null when output is null", () => {
|
|
72
78
|
const { container } = render(
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
<Provider store={store}>
|
|
80
|
+
<DocumentProvider model={model}>
|
|
81
|
+
<TooltipProvider>
|
|
82
|
+
<OutputArea
|
|
83
|
+
output={null}
|
|
84
|
+
cellId={cellId("test")}
|
|
85
|
+
stale={false}
|
|
86
|
+
loading={false}
|
|
87
|
+
allowExpand={true}
|
|
88
|
+
/>
|
|
89
|
+
</TooltipProvider>
|
|
90
|
+
</DocumentProvider>
|
|
91
|
+
</Provider>,
|
|
82
92
|
);
|
|
83
93
|
expect(container.innerHTML).toBe("");
|
|
84
94
|
});
|
|
85
95
|
|
|
86
96
|
it("should render null when output is undefined", () => {
|
|
87
97
|
const { container } = render(
|
|
88
|
-
<
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
<Provider store={store}>
|
|
99
|
+
<DocumentProvider model={model}>
|
|
100
|
+
<TooltipProvider>
|
|
101
|
+
<OutputArea
|
|
102
|
+
// @ts-expect-error -- testing runtime safety for undefined output
|
|
103
|
+
output={undefined}
|
|
104
|
+
cellId={cellId("test")}
|
|
105
|
+
stale={false}
|
|
106
|
+
loading={false}
|
|
107
|
+
allowExpand={true}
|
|
108
|
+
/>
|
|
109
|
+
</TooltipProvider>
|
|
110
|
+
</DocumentProvider>
|
|
111
|
+
</Provider>,
|
|
98
112
|
);
|
|
99
113
|
expect(container.innerHTML).toBe("");
|
|
100
114
|
});
|
|
@@ -184,19 +198,23 @@ describe("OutputArea fullscreen exit control", () => {
|
|
|
184
198
|
|
|
185
199
|
const renderOutput = () =>
|
|
186
200
|
render(
|
|
187
|
-
<
|
|
188
|
-
<
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
201
|
+
<Provider store={store}>
|
|
202
|
+
<DocumentProvider model={model}>
|
|
203
|
+
<TooltipProvider>
|
|
204
|
+
<OutputArea
|
|
205
|
+
output={{
|
|
206
|
+
channel: "output",
|
|
207
|
+
data: "Hello World",
|
|
208
|
+
mimetype: "text/plain",
|
|
209
|
+
}}
|
|
210
|
+
cellId={cellId("test")}
|
|
211
|
+
stale={false}
|
|
212
|
+
loading={false}
|
|
213
|
+
allowExpand={true}
|
|
214
|
+
/>
|
|
215
|
+
</TooltipProvider>
|
|
216
|
+
</DocumentProvider>
|
|
217
|
+
</Provider>,
|
|
200
218
|
);
|
|
201
219
|
|
|
202
220
|
const enterFullscreen = (container: HTMLElement) => {
|
|
@@ -3,11 +3,13 @@ import { render } from "@testing-library/react";
|
|
|
3
3
|
import { createStore, Provider } from "jotai";
|
|
4
4
|
import { beforeAll, describe, expect, it } from "vitest";
|
|
5
5
|
import { SetupMocks } from "@/__mocks__/common";
|
|
6
|
+
import { mockDocumentModel } from "@/__mocks__/document";
|
|
6
7
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
7
8
|
import { MockRequestClient } from "@/__mocks__/requests";
|
|
8
9
|
import { cellId } from "@/__tests__/branded";
|
|
9
10
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
10
11
|
import { notebookAtom } from "@/core/cells/cells";
|
|
12
|
+
import { DocumentProvider } from "@/core/notebook/document";
|
|
11
13
|
import { createCellRuntimeState } from "@/core/cells/types";
|
|
12
14
|
import type { UserConfig } from "@/core/config/config-schema";
|
|
13
15
|
import type { OutputMessage } from "@/core/kernel/messages";
|
|
@@ -18,9 +20,12 @@ import { OutputArea } from "../Output";
|
|
|
18
20
|
|
|
19
21
|
function createTestWrapper() {
|
|
20
22
|
const store = createStore();
|
|
23
|
+
const { model } = mockDocumentModel(store, null);
|
|
21
24
|
store.set(requestClientAtom, MockRequestClient.create());
|
|
22
25
|
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
23
|
-
<Provider store={store}>
|
|
26
|
+
<Provider store={store}>
|
|
27
|
+
<DocumentProvider model={model}>{children}</DocumentProvider>
|
|
28
|
+
</Provider>
|
|
24
29
|
);
|
|
25
30
|
return { wrapper, store };
|
|
26
31
|
}
|
|
@@ -150,17 +155,23 @@ describe("Output data attributes", () => {
|
|
|
150
155
|
timestamp: 0,
|
|
151
156
|
};
|
|
152
157
|
|
|
158
|
+
const store = createStore();
|
|
159
|
+
const { model } = mockDocumentModel(store, null);
|
|
153
160
|
const { container } = render(
|
|
154
|
-
<
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
<Provider store={store}>
|
|
162
|
+
<DocumentProvider model={model}>
|
|
163
|
+
<TooltipProvider>
|
|
164
|
+
<OutputArea
|
|
165
|
+
output={output}
|
|
166
|
+
cellId={cid}
|
|
167
|
+
stale={false}
|
|
168
|
+
loading={false}
|
|
169
|
+
allowExpand={true}
|
|
170
|
+
className="test-output"
|
|
171
|
+
/>
|
|
172
|
+
</TooltipProvider>
|
|
173
|
+
</DocumentProvider>
|
|
174
|
+
</Provider>,
|
|
164
175
|
);
|
|
165
176
|
|
|
166
177
|
const outputElement = container.querySelector('[data-cell-role="output"]');
|
|
@@ -3,11 +3,13 @@ import { render } from "@testing-library/react";
|
|
|
3
3
|
import { createStore, Provider } from "jotai";
|
|
4
4
|
import { beforeAll, describe, expect, it } from "vitest";
|
|
5
5
|
import { SetupMocks } from "@/__mocks__/common";
|
|
6
|
+
import { mockDocumentModel } from "@/__mocks__/document";
|
|
6
7
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
7
8
|
import { MockRequestClient } from "@/__mocks__/requests";
|
|
8
9
|
import { cellId } from "@/__tests__/branded";
|
|
9
10
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
10
11
|
import { notebookAtom } from "@/core/cells/cells";
|
|
12
|
+
import { DocumentProvider } from "@/core/notebook/document";
|
|
11
13
|
import type { CellRuntimeState } from "@/core/cells/types";
|
|
12
14
|
import { createCellRuntimeState } from "@/core/cells/types";
|
|
13
15
|
import { defaultUserConfig } from "@/core/config/config-schema";
|
|
@@ -19,9 +21,12 @@ const cid = cellId("test");
|
|
|
19
21
|
|
|
20
22
|
function createTestWrapper() {
|
|
21
23
|
const store = createStore();
|
|
24
|
+
const { model } = mockDocumentModel(store, null);
|
|
22
25
|
store.set(requestClientAtom, MockRequestClient.create());
|
|
23
26
|
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
24
|
-
<Provider store={store}>
|
|
27
|
+
<Provider store={store}>
|
|
28
|
+
<DocumentProvider model={model}>{children}</DocumentProvider>
|
|
29
|
+
</Provider>
|
|
25
30
|
);
|
|
26
31
|
return { wrapper, store };
|
|
27
32
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
// @vitest-environment jsdom
|
|
3
|
+
|
|
4
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
5
|
+
import { atom, createStore, Provider } from "jotai";
|
|
6
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
7
|
+
import { cellId } from "@/__tests__/branded";
|
|
8
|
+
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
9
|
+
import {
|
|
10
|
+
createDocumentModel,
|
|
11
|
+
DocumentProvider,
|
|
12
|
+
} from "@/core/notebook/document";
|
|
13
|
+
import {
|
|
14
|
+
cell,
|
|
15
|
+
document as documentOf,
|
|
16
|
+
withCells,
|
|
17
|
+
} from "@/core/notebook/document/__tests__/fixtures";
|
|
18
|
+
import { fakeBackend } from "@/core/notebook/replica/__tests__/fixtures";
|
|
19
|
+
import { NameCellContentEditable } from "../name-cell-input";
|
|
20
|
+
|
|
21
|
+
const controllers: AbortController[] = [];
|
|
22
|
+
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
for (const controller of controllers.splice(0)) {
|
|
25
|
+
controller.abort();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe("NameCellContentEditable", () => {
|
|
30
|
+
it("renames the cell in the document when the name is committed", () => {
|
|
31
|
+
const store = createStore();
|
|
32
|
+
const source = atom(
|
|
33
|
+
withCells(documentOf(), {
|
|
34
|
+
c1: cell("c1", "x = 1", { name: "first" }),
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
const model = createDocumentModel({
|
|
38
|
+
store,
|
|
39
|
+
documentAtom: source,
|
|
40
|
+
backendAtom: atom(fakeBackend()),
|
|
41
|
+
});
|
|
42
|
+
const controller = new AbortController();
|
|
43
|
+
controllers.push(controller);
|
|
44
|
+
model.start({ signal: controller.signal });
|
|
45
|
+
|
|
46
|
+
render(
|
|
47
|
+
<Provider store={store}>
|
|
48
|
+
<DocumentProvider model={model}>
|
|
49
|
+
<TooltipProvider>
|
|
50
|
+
<NameCellContentEditable
|
|
51
|
+
cellId={cellId("c1")}
|
|
52
|
+
value="first"
|
|
53
|
+
className=""
|
|
54
|
+
/>
|
|
55
|
+
</TooltipProvider>
|
|
56
|
+
</DocumentProvider>
|
|
57
|
+
</Provider>,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const field = screen.getByText("first");
|
|
61
|
+
// jsdom does not lay text out, so it has no innerText of its own.
|
|
62
|
+
Object.defineProperty(field, "innerText", { value: " renamed " });
|
|
63
|
+
fireEvent.blur(field);
|
|
64
|
+
|
|
65
|
+
expect(store.get(model.documentAtom)?.cells.get("c1")?.name).toBe(
|
|
66
|
+
"renamed",
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
import React, { useRef, useState } from "react";
|
|
4
4
|
import { Input } from "@/components/ui/input";
|
|
5
5
|
import { Tooltip } from "@/components/ui/tooltip";
|
|
6
|
-
import { getCellNames
|
|
6
|
+
import { getCellNames } from "@/core/cells/cells";
|
|
7
7
|
import type { CellId } from "@/core/cells/ids";
|
|
8
8
|
import {
|
|
9
9
|
getValidName,
|
|
10
10
|
isInternalCellName,
|
|
11
11
|
normalizeName,
|
|
12
12
|
} from "@/core/cells/names";
|
|
13
|
+
import { useNotebookDocumentEdit } from "@/core/notebook/document";
|
|
13
14
|
import { useOnMount } from "@/hooks/useLifecycle";
|
|
14
15
|
import { cn } from "@/utils/cn";
|
|
15
16
|
import { Events } from "@/utils/events";
|
|
@@ -71,9 +72,9 @@ export const NameCellContentEditable: React.FC<{
|
|
|
71
72
|
value: string;
|
|
72
73
|
className: string;
|
|
73
74
|
}> = ({ value, cellId, className }) => {
|
|
74
|
-
const
|
|
75
|
+
const edit = useNotebookDocumentEdit();
|
|
75
76
|
const inputProps = useCellNameInput(value, (newName) =>
|
|
76
|
-
|
|
77
|
+
edit((tx) => tx.setName(cellId, newName)),
|
|
77
78
|
);
|
|
78
79
|
|
|
79
80
|
// If the name is the default, don't render the content editable
|