@marimo-team/islands 0.25.3-dev142 → 0.25.3-dev144
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-DxdeETpm.js → ErrorBoundary-h1USoT64.js} +1 -1
- package/dist/{code-visibility-CO8abjLo.js → code-visibility-COfR8EW1.js} +1 -1
- package/dist/{common-CbFJQhaI.js → common-0YnRj3Nk.js} +5147 -5143
- package/dist/{data-grid-overlay-editor-DBjVUS2K.js → data-grid-overlay-editor-D0f9mjF4.js} +1 -1
- package/dist/{feedback-button-CWQoIUKQ.js → feedback-button-BoLxN-to.js} +2 -2
- package/dist/{glide-data-editor-BxT8eGip.js → glide-data-editor-DAFwdDUi.js} +3 -3
- package/dist/{globals-f0UxWZkr.js → globals-Bw3_VBRf.js} +1 -1
- package/dist/main.js +6 -6
- package/dist/{number-overlay-editor-Dso2H7DV.js → number-overlay-editor-BSF_HajG.js} +1 -1
- package/dist/{reveal-component-DMglhlng.js → reveal-component-D0kz9zvJ.js} +2 -2
- package/package.json +1 -1
- package/src/__tests__/module-entry.test.ts +22 -10
- package/src/__tests__/mount.test.ts +1 -1
- package/src/__tests__/{host-imports.test.ts → replica-imports.test.ts} +11 -11
- package/src/{core/attachments/__tests__/toast.test.tsx → components/editor/__tests__/agent-toast.test.tsx} +1 -1
- package/src/components/editor/actions/useRestartKernel.tsx +1 -1
- package/src/components/editor/alerts/__tests__/connection-notice.test.tsx +1 -1
- package/src/components/editor/alerts/connection-notice.tsx +1 -1
- package/src/components/editor/app-container.tsx +1 -1
- package/src/components/editor/boundary/__tests__/ErrorBoundary.test.tsx +1 -1
- package/src/components/editor/cell/CreateCellButton.tsx +2 -2
- package/src/components/editor/cell/DeleteButton.tsx +2 -2
- package/src/components/editor/cell/RunButton.tsx +2 -2
- package/src/components/editor/cell/StopButton.tsx +2 -2
- package/src/components/editor/cell/code/cell-editor.tsx +1 -1
- package/src/components/editor/chrome/components/__tests__/feedback-button.test.tsx +1 -1
- package/src/components/editor/chrome/components/feedback-button.tsx +1 -1
- package/src/components/editor/chrome/panels/__tests__/packages-panel.test.tsx +1 -1
- package/src/components/editor/chrome/panels/__tests__/runtime-details.test.tsx +1 -1
- package/src/components/editor/chrome/panels/__tests__/sandbox-recovery.test.tsx +1 -1
- package/src/components/editor/chrome/wrapper/__tests__/attachment-status.test.tsx +6 -9
- package/src/components/editor/chrome/wrapper/footer-items/attachment-status.tsx +4 -4
- package/src/components/editor/chrome/wrapper/footer-items/backend-status.tsx +1 -1
- package/src/components/editor/chrome/wrapper/footer-items/lsp-status.tsx +1 -1
- package/src/components/editor/chrome/wrapper/footer-items/machine-stats.tsx +1 -1
- package/src/components/editor/controls/Controls.tsx +2 -2
- package/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx +1 -1
- package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +6 -9
- package/src/components/editor/errors/send-error-report-button.tsx +3 -6
- package/src/components/editor/header/__tests__/status.test.tsx +5 -3
- package/src/components/editor/header/app-header.tsx +1 -1
- package/src/components/editor/header/status.tsx +12 -15
- package/src/components/editor/notebook-cell.tsx +1 -1
- package/src/core/codemirror/readonly/__tests__/extension.test.ts +1 -1
- package/src/core/codemirror/readonly/extension.ts +2 -2
- package/src/core/datasets/__tests__/data-source-discovery.test.ts +1 -1
- package/src/core/edit-app.tsx +2 -2
- package/src/core/export/hooks.ts +1 -1
- package/src/core/network/__tests__/connection.test.ts +1 -1
- package/src/core/network/connection-notice.ts +1 -1
- package/src/core/network/connection.ts +1 -1
- package/src/core/network/requests-lazy.ts +1 -1
- package/src/core/notebook/attachments.ts +38 -0
- package/src/core/{document → notebook/document}/__tests__/codemirror.test.ts +7 -7
- package/src/core/{document → notebook/document}/__tests__/fixtures.ts +1 -1
- package/src/core/{document → notebook/document}/__tests__/hooks.test.tsx +43 -38
- package/src/core/{document → notebook/document}/__tests__/model.test.ts +3 -3
- package/src/core/{document → notebook/document}/__tests__/protocol-fixtures.ts +3 -3
- package/src/core/{document → notebook/document}/__tests__/scenario-fixture.ts +1 -1
- package/src/core/{document → notebook/document}/__tests__/state.test.ts +1 -1
- package/src/core/{document → notebook/document}/__tests__/submission.test.ts +1 -1
- package/src/core/{document → notebook/document}/__tests__/test-host.ts +1 -1
- package/src/core/{document → notebook/document}/__tests__/test-notebook.ts +2 -2
- package/src/core/{document → notebook/document}/codemirror.ts +3 -3
- package/src/core/{document → notebook/document}/draft.ts +1 -1
- package/src/core/{document → notebook/document}/hooks.tsx +9 -9
- package/src/core/{document → notebook/document}/index.ts +7 -7
- package/src/core/{document → notebook/document}/model.ts +1 -1
- package/src/core/{document → notebook/document}/state.ts +1 -1
- package/src/core/{document → notebook/document}/sync.ts +1 -1
- package/src/core/notebook/index.ts +18 -0
- package/src/core/notebook/replica/AGENTS.md +11 -0
- package/src/core/{host → notebook/replica}/__tests__/fixtures.ts +1 -1
- package/src/core/{host → notebook/replica}/__tests__/replica.test.ts +1 -1
- package/src/core/{host → notebook/replica}/index.ts +1 -2
- package/src/core/packages/__tests__/useSandboxController.test.tsx +1 -1
- package/src/core/packages/useSandboxController.ts +1 -1
- package/src/core/run-app.tsx +3 -3
- package/src/core/runtime/__tests__/adapter.test.ts +1 -1
- package/src/core/runtime/adapter.ts +1 -1
- package/src/core/runtime/config.ts +2 -2
- package/src/core/saving/filename.ts +1 -1
- package/src/core/saving/save-component.tsx +1 -1
- package/src/core/saving/useAutoSave.ts +1 -1
- package/src/core/{websocket → session}/__tests__/backend.test.ts +3 -3
- package/src/core/{websocket → session}/__tests__/useNotebookReplica.hook.test.tsx +49 -7
- package/src/core/{websocket → session}/__tests__/useNotebookSession.hook.test.tsx +2 -2
- package/src/core/{websocket/state.ts → session/active-notebook.ts} +2 -2
- package/src/core/{websocket → session}/backend.ts +3 -7
- package/src/core/{websocket → session}/types.ts +2 -2
- package/src/core/{websocket → session}/useNotebookReplica.ts +8 -5
- package/src/core/{websocket → session}/useNotebookSession.tsx +1 -1
- package/src/core/{websocket → transports}/__tests__/connection-state.test.ts +1 -1
- package/src/core/{websocket/transports/__tests__/notebook.test.ts → transports/__tests__/server.test.ts} +7 -4
- package/src/core/{host → transports}/__tests__/static.test.ts +2 -2
- package/src/core/{host → transports}/__tests__/wasm.test.ts +1 -1
- package/src/core/{websocket → transports}/connection-state.ts +9 -6
- package/src/core/{websocket/transports/notebook.ts → transports/server.ts} +1 -8
- package/src/core/{host → transports}/static.ts +9 -2
- package/src/core/{host → transports}/wasm.ts +1 -1
- package/src/core/wasm/__tests__/bridge.test.ts +8 -8
- package/src/core/wasm/bridge.ts +3 -3
- package/src/mount.tsx +1 -1
- package/src/stories/cell.stories.tsx +1 -1
- package/src/stories/layout/vertical/one-column.stories.tsx +1 -1
- package/src/stories/runtime-story.tsx +1 -1
- package/src/core/attachments/state.ts +0 -18
- package/src/core/host/AGENTS.md +0 -12
- /package/src/{core/attachments/toast.ts → components/editor/agent-toast.ts} +0 -0
- /package/src/core/{document → notebook/document}/__tests__/draft.test.ts +0 -0
- /package/src/core/{document → notebook/document}/__tests__/lifecycle-scenarios.test.ts +0 -0
- /package/src/core/{document → notebook/document}/__tests__/recovery-scenarios.test.ts +0 -0
- /package/src/core/{document → notebook/document}/__tests__/scenarios.test.ts +0 -0
- /package/src/core/{document → notebook/document}/__tests__/test-host.test.ts +0 -0
- /package/src/core/{document → notebook/document}/__tests__/user.ts +0 -0
- /package/src/core/{document → notebook/document}/select.ts +0 -0
- /package/src/core/{host → notebook/replica}/__tests__/attachments.test.ts +0 -0
- /package/src/core/{host → notebook/replica}/__tests__/document.test.ts +0 -0
- /package/src/core/{host → notebook/replica}/backend.ts +0 -0
- /package/src/core/{host → notebook/replica}/connection.ts +0 -0
- /package/src/core/{host → notebook/replica}/replica.ts +0 -0
- /package/src/core/{host → notebook/replica}/resources/attachments.ts +0 -0
- /package/src/core/{host → notebook/replica}/resources/document.ts +0 -0
- /package/src/core/{websocket → session}/connection-utils.ts +0 -0
|
@@ -4,11 +4,8 @@ import { useAtomValue } from "jotai";
|
|
|
4
4
|
import { SendIcon } from "lucide-react";
|
|
5
5
|
import { useState } from "react";
|
|
6
6
|
import { Button } from "@/components/ui/button";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
attachmentLabel,
|
|
10
|
-
} from "@/core/attachments/state";
|
|
11
|
-
import { agentToast } from "@/core/attachments/toast";
|
|
7
|
+
import { attachmentLabel, useNotebookAttachments } from "@/core/notebook";
|
|
8
|
+
import { agentToast } from "@/components/editor/agent-toast";
|
|
12
9
|
import { pairConfigAtom } from "@/core/config/pair";
|
|
13
10
|
import { stableSessionIdAtom } from "@/core/kernel/session";
|
|
14
11
|
import { API } from "@/core/network/api";
|
|
@@ -20,7 +17,7 @@ export function SendErrorReportButton({
|
|
|
20
17
|
getContent: () => unknown;
|
|
21
18
|
}) {
|
|
22
19
|
const hostEnabled = useAtomValue(pairConfigAtom)?.hostEnabled;
|
|
23
|
-
const agents =
|
|
20
|
+
const agents = useNotebookAttachments("agent");
|
|
24
21
|
const stableSessionId = useAtomValue(stableSessionIdAtom);
|
|
25
22
|
const [sending, setSending] = useState(false);
|
|
26
23
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type ConnectionStatus,
|
|
12
12
|
WebSocketClosedReason,
|
|
13
13
|
ConnectionState,
|
|
14
|
-
} from "@/core/
|
|
14
|
+
} from "@/core/session/types";
|
|
15
15
|
import { StatusOverlay } from "../status";
|
|
16
16
|
|
|
17
17
|
function renderOverlay(
|
|
@@ -55,7 +55,7 @@ describe("StatusOverlay disconnect indicator", () => {
|
|
|
55
55
|
expect(onReconnect).toHaveBeenCalledTimes(1);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
it("
|
|
58
|
+
it("keeps the unavailable reconnect button focusable for its tooltip", () => {
|
|
59
59
|
const { getByTestId } = renderOverlay({
|
|
60
60
|
state: ConnectionState.CLOSED,
|
|
61
61
|
code: WebSocketClosedReason.KERNEL_DISCONNECTED,
|
|
@@ -63,7 +63,9 @@ describe("StatusOverlay disconnect indicator", () => {
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
const button = getByTestId("disconnected-indicator");
|
|
66
|
-
expect(
|
|
66
|
+
expect(button).toHaveAttribute("aria-disabled", "true");
|
|
67
|
+
button.focus();
|
|
68
|
+
expect(button).toHaveFocus();
|
|
67
69
|
});
|
|
68
70
|
|
|
69
71
|
it("leaves editor startup failures to the inline notice", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import React, { type PropsWithChildren } from "react";
|
|
4
|
-
import { type ConnectionStatus, ConnectionState } from "@/core/
|
|
4
|
+
import { type ConnectionStatus, ConnectionState } from "@/core/session/types";
|
|
5
5
|
import { Disconnected } from "../Disconnected";
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type ConnectionStatus,
|
|
12
12
|
WebSocketClosedReason,
|
|
13
13
|
ConnectionState,
|
|
14
|
-
} from "@/core/
|
|
14
|
+
} from "@/core/session/types";
|
|
15
15
|
import { cn } from "@/utils/cn";
|
|
16
16
|
|
|
17
17
|
export const StatusOverlay: React.FC<{
|
|
@@ -61,20 +61,17 @@ const DisconnectedIcon: React.FC<{ onReconnect?: () => void }> = ({
|
|
|
61
61
|
disabled ? "App disconnected" : "App disconnected — click to reconnect"
|
|
62
62
|
}
|
|
63
63
|
>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<UnlinkIcon className="w-[25px] h-[25px] text-(--red-11)" />
|
|
76
|
-
</button>
|
|
77
|
-
</span>
|
|
64
|
+
<button
|
|
65
|
+
type="button"
|
|
66
|
+
className={cn(topLeftStatus, "bg-transparent border-0 p-0")}
|
|
67
|
+
aria-label={disabled ? "App disconnected" : "Reconnect to app"}
|
|
68
|
+
data-testid="disconnected-indicator"
|
|
69
|
+
onClick={onReconnect}
|
|
70
|
+
// Keep the tooltip reachable by keyboard when reconnection is unavailable.
|
|
71
|
+
aria-disabled={disabled}
|
|
72
|
+
>
|
|
73
|
+
<UnlinkIcon className="w-[25px] h-[25px] text-(--red-11)" />
|
|
74
|
+
</button>
|
|
78
75
|
</Tooltip>
|
|
79
76
|
);
|
|
80
77
|
};
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
shouldHidePublishedCell,
|
|
60
60
|
} from "../../core/cells/utils";
|
|
61
61
|
import type { UserConfig } from "../../core/config/config-schema";
|
|
62
|
-
import { isAppInteractionDisabled } from "../../core/
|
|
62
|
+
import { isAppInteractionDisabled } from "../../core/session/connection-utils";
|
|
63
63
|
import { useCellRenderCount } from "../../hooks/useCellRenderCount";
|
|
64
64
|
import type { Theme } from "../../theme/useTheme";
|
|
65
65
|
import { Functions } from "../../utils/functions";
|
|
@@ -4,7 +4,7 @@ import { EditorState } from "@codemirror/state";
|
|
|
4
4
|
import { EditorView } from "@codemirror/view";
|
|
5
5
|
import { createStore } from "jotai";
|
|
6
6
|
import { describe, expect, it } from "vitest";
|
|
7
|
-
import { ConnectionState } from "@/core/
|
|
7
|
+
import { ConnectionState } from "@/core/session/types";
|
|
8
8
|
import { connectionAtom } from "../../../network/connection";
|
|
9
9
|
import { dynamicReadonly, isEditorReadonly } from "../extension";
|
|
10
10
|
|
|
@@ -5,9 +5,9 @@ import type { createStore } from "jotai";
|
|
|
5
5
|
import {
|
|
6
6
|
isAppConnected,
|
|
7
7
|
isAppConnecting,
|
|
8
|
-
} from "@/core/
|
|
8
|
+
} from "@/core/session/connection-utils";
|
|
9
9
|
import { connectionAtom } from "../../network/connection";
|
|
10
|
-
import { ConnectionState } from "../../
|
|
10
|
+
import { ConnectionState } from "../../session/types";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* State effect for updating readonly status based on connection
|
|
@@ -4,7 +4,7 @@ import { requestId } from "@/__tests__/branded";
|
|
|
4
4
|
import type { DataSourceDiscoveryResult } from "@/core/kernel/messages";
|
|
5
5
|
import { connectionAtom } from "@/core/network/connection";
|
|
6
6
|
import { store } from "@/core/state/jotai";
|
|
7
|
-
import { ConnectionState } from "@/core/
|
|
7
|
+
import { ConnectionState } from "@/core/session/types";
|
|
8
8
|
import {
|
|
9
9
|
fetchDataSourceDiscovery,
|
|
10
10
|
invalidateDataSourceDiscovery,
|
package/src/core/edit-app.tsx
CHANGED
|
@@ -41,7 +41,7 @@ import { viewStateAtom } from "./mode";
|
|
|
41
41
|
import { useRequestClient } from "./network/requests";
|
|
42
42
|
import { useFilename } from "./saving/filename";
|
|
43
43
|
import { lastSavedNotebookAtom } from "./saving/state";
|
|
44
|
-
import { useNotebookSession } from "./
|
|
44
|
+
import { useNotebookSession } from "./session/useNotebookSession";
|
|
45
45
|
|
|
46
46
|
interface AppProps {
|
|
47
47
|
/**
|
|
@@ -81,7 +81,7 @@ export const EditApp: React.FC<AppProps> = ({
|
|
|
81
81
|
return () => {
|
|
82
82
|
RuntimeState.INSTANCE.stop();
|
|
83
83
|
};
|
|
84
|
-
}, []);
|
|
84
|
+
}, [sendComponentValues]);
|
|
85
85
|
|
|
86
86
|
const { connection, reconnect } = useNotebookSession({
|
|
87
87
|
autoInstantiate: userConfig.runtime.auto_instantiate,
|
package/src/core/export/hooks.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { connectionAtom } from "../network/connection";
|
|
|
16
16
|
import { useRequestClient } from "../network/requests";
|
|
17
17
|
import type { UpdateCellOutputsRequest } from "../network/types";
|
|
18
18
|
import { VirtualFileTracker } from "../static/virtual-file-tracker";
|
|
19
|
-
import { ConnectionState } from "../
|
|
19
|
+
import { ConnectionState } from "../session/types";
|
|
20
20
|
|
|
21
21
|
const DELAY = 5000; // 5 seconds;
|
|
22
22
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { afterEach, describe, expect, it } from "vitest";
|
|
4
4
|
import { initialModeAtom } from "@/core/mode";
|
|
5
5
|
import { store } from "@/core/state/jotai";
|
|
6
|
-
import { ConnectionState } from "../../
|
|
6
|
+
import { ConnectionState } from "../../session/types";
|
|
7
7
|
import { connectionAtom, waitForConnectionOpenIfNotebook } from "../connection";
|
|
8
8
|
|
|
9
9
|
const NEVER = Symbol("never");
|
|
@@ -4,7 +4,7 @@ import { atomWithReducer } from "jotai/utils";
|
|
|
4
4
|
import type { NotificationMessageData } from "../kernel/messages";
|
|
5
5
|
import { isNotebookPage } from "../mode";
|
|
6
6
|
import { waitFor } from "../state/jotai";
|
|
7
|
-
import { type ConnectionStatus, ConnectionState } from "../
|
|
7
|
+
import { type ConnectionStatus, ConnectionState } from "../session/types";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Shared application state, not the actual event-stream status.
|
|
@@ -7,7 +7,7 @@ import { memoizeLastValue } from "@/utils/once";
|
|
|
7
7
|
import { waitForKernelToBeInstantiated } from "../kernel/state";
|
|
8
8
|
import type { RuntimeManager } from "../runtime/runtime";
|
|
9
9
|
import { store } from "../state/jotai";
|
|
10
|
-
import { ConnectionState } from "../
|
|
10
|
+
import { ConnectionState } from "../session/types";
|
|
11
11
|
import { connectionAtom, waitForConnectionOpen } from "./connection";
|
|
12
12
|
import type { EditRequests, RunRequests } from "./types";
|
|
13
13
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { dequal } from "dequal";
|
|
4
|
+
import { atom, useAtomValue } from "jotai";
|
|
5
|
+
import { selectAtom } from "jotai/vanilla/utils";
|
|
6
|
+
import { useMemo } from "react";
|
|
7
|
+
import type { Attachment } from "@marimo-team/client/protocol";
|
|
8
|
+
import { activeNotebookReplicaAtom } from "../session/active-notebook";
|
|
9
|
+
|
|
10
|
+
export type { Attachment } from "@marimo-team/client/protocol";
|
|
11
|
+
|
|
12
|
+
const EMPTY_ATTACHMENTS: readonly Attachment[] = [];
|
|
13
|
+
|
|
14
|
+
/** Attachments visible to this session, empty while no notebook is available. */
|
|
15
|
+
export const notebookAttachmentsAtom = atom((get) => {
|
|
16
|
+
const replica = get(activeNotebookReplicaAtom);
|
|
17
|
+
return replica ? get(replica.attachmentsAtom) : EMPTY_ATTACHMENTS;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/** Current notebook attachments, optionally restricted to one kind. */
|
|
21
|
+
export function useNotebookAttachments(kind?: Attachment["kind"]) {
|
|
22
|
+
const attachments = useMemo(
|
|
23
|
+
() =>
|
|
24
|
+
kind === undefined
|
|
25
|
+
? notebookAttachmentsAtom
|
|
26
|
+
: selectAtom(
|
|
27
|
+
notebookAttachmentsAtom,
|
|
28
|
+
(value) => value.filter((attachment) => attachment.kind === kind),
|
|
29
|
+
dequal,
|
|
30
|
+
),
|
|
31
|
+
[kind],
|
|
32
|
+
);
|
|
33
|
+
return useAtomValue(attachments);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function attachmentLabel(attachment: Attachment): string {
|
|
37
|
+
return attachment.name || "Agent";
|
|
38
|
+
}
|
|
@@ -9,22 +9,22 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
9
9
|
import { cellId as brandedCellId } from "@/__tests__/branded";
|
|
10
10
|
import { createNotebookActions } from "@/core/cells/cells";
|
|
11
11
|
import { OverridingHotkeyProvider } from "@/core/hotkeys/hotkeys";
|
|
12
|
-
import { cellActionsState } from "
|
|
13
|
-
import { cellConfigExtension } from "
|
|
12
|
+
import { cellActionsState } from "../../../codemirror/cells/state";
|
|
13
|
+
import { cellConfigExtension } from "../../../codemirror/config/extension";
|
|
14
14
|
import {
|
|
15
15
|
adaptiveLanguageConfiguration,
|
|
16
16
|
languageAdapterState,
|
|
17
17
|
switchLanguage,
|
|
18
|
-
} from "
|
|
18
|
+
} from "../../../codemirror/language/extension";
|
|
19
19
|
import {
|
|
20
20
|
languageMetadataField,
|
|
21
21
|
setLanguageMetadata,
|
|
22
|
-
} from "
|
|
23
|
-
import { SCHEMA_CACHE } from "
|
|
24
|
-
import type { Document } from "../../
|
|
22
|
+
} from "../../../codemirror/language/metadata";
|
|
23
|
+
import { SCHEMA_CACHE } from "../../../codemirror/language/languages/sql/completion-store";
|
|
24
|
+
import type { Document } from "../../replica/resources/document";
|
|
25
25
|
import { cellCodeBinding } from "../codemirror";
|
|
26
26
|
import { createDocumentModel } from "../model";
|
|
27
|
-
import { fakeBackend } from "../../
|
|
27
|
+
import { fakeBackend } from "../../replica/__tests__/fixtures";
|
|
28
28
|
import { cell, document, withCells } from "./fixtures";
|
|
29
29
|
|
|
30
30
|
const views: EditorView[] = [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import type { Document } from "../../
|
|
3
|
+
import type { Document } from "../../replica/resources/document";
|
|
4
4
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
5
5
|
|
|
6
6
|
export const CONFIG: Protocol.CellConfig = {
|
|
@@ -5,19 +5,18 @@ import { atom, createStore, Provider } from "jotai";
|
|
|
5
5
|
import type { PropsWithChildren } from "react";
|
|
6
6
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
7
7
|
import { Deferred } from "@/utils/Deferred";
|
|
8
|
-
import type { Document } from "../../
|
|
8
|
+
import type { Document } from "../../replica/resources/document";
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} from "..";
|
|
10
|
+
useNotebookCellCode,
|
|
11
|
+
useNotebookCellConfig,
|
|
12
|
+
useNotebookCellName,
|
|
13
|
+
useNotebookCellOrder,
|
|
14
|
+
useNotebookDocumentEdit,
|
|
15
|
+
useNotebookDocumentSync,
|
|
16
|
+
} from "@/core/notebook";
|
|
17
|
+
import { createDocumentModel, DocumentProvider } from "..";
|
|
19
18
|
import { cell, CONFIG, document, withCells } from "./fixtures";
|
|
20
|
-
import { type FakeEdit, fakeBackend } from "../../
|
|
19
|
+
import { type FakeEdit, fakeBackend } from "../../replica/__tests__/fixtures";
|
|
21
20
|
|
|
22
21
|
const lifetimes: AbortController[] = [];
|
|
23
22
|
|
|
@@ -65,9 +64,9 @@ describe("document hooks", () => {
|
|
|
65
64
|
const { store, source, wrapper, controller } = setup(document(), edit);
|
|
66
65
|
const { result, unmount } = renderHook(
|
|
67
66
|
() => ({
|
|
68
|
-
code:
|
|
69
|
-
edit:
|
|
70
|
-
sync:
|
|
67
|
+
code: useNotebookCellCode("c1"),
|
|
68
|
+
edit: useNotebookDocumentEdit(),
|
|
69
|
+
sync: useNotebookDocumentSync(),
|
|
71
70
|
}),
|
|
72
71
|
{ wrapper, reactStrictMode: true },
|
|
73
72
|
);
|
|
@@ -108,13 +107,13 @@ describe("document hooks", () => {
|
|
|
108
107
|
const { result } = renderHook(
|
|
109
108
|
() => {
|
|
110
109
|
const value = {
|
|
111
|
-
code:
|
|
112
|
-
name:
|
|
113
|
-
config:
|
|
114
|
-
order:
|
|
110
|
+
code: useNotebookCellCode("c1"),
|
|
111
|
+
name: useNotebookCellName("c1"),
|
|
112
|
+
config: useNotebookCellConfig("c1"),
|
|
113
|
+
order: useNotebookCellOrder(),
|
|
115
114
|
};
|
|
116
115
|
seen(value);
|
|
117
|
-
return { ...value, edit:
|
|
116
|
+
return { ...value, edit: useNotebookDocumentEdit() };
|
|
118
117
|
},
|
|
119
118
|
{ wrapper },
|
|
120
119
|
);
|
|
@@ -162,23 +161,23 @@ describe("document hooks", () => {
|
|
|
162
161
|
const onOrder = vi.fn();
|
|
163
162
|
const onEdit = vi.fn();
|
|
164
163
|
function Code() {
|
|
165
|
-
onCode(
|
|
164
|
+
onCode(useNotebookCellCode("c1"));
|
|
166
165
|
return null;
|
|
167
166
|
}
|
|
168
167
|
function Name() {
|
|
169
|
-
onName(
|
|
168
|
+
onName(useNotebookCellName("c1"));
|
|
170
169
|
return null;
|
|
171
170
|
}
|
|
172
171
|
function Config() {
|
|
173
|
-
onConfig(
|
|
172
|
+
onConfig(useNotebookCellConfig("c1"));
|
|
174
173
|
return null;
|
|
175
174
|
}
|
|
176
175
|
function Order() {
|
|
177
|
-
onOrder(
|
|
176
|
+
onOrder(useNotebookCellOrder());
|
|
178
177
|
return null;
|
|
179
178
|
}
|
|
180
179
|
function Edit() {
|
|
181
|
-
onEdit(
|
|
180
|
+
onEdit(useNotebookDocumentEdit());
|
|
182
181
|
return null;
|
|
183
182
|
}
|
|
184
183
|
render(
|
|
@@ -191,7 +190,8 @@ describe("document hooks", () => {
|
|
|
191
190
|
</>,
|
|
192
191
|
{ wrapper },
|
|
193
192
|
);
|
|
194
|
-
const edit: ReturnType<typeof
|
|
193
|
+
const edit: ReturnType<typeof useNotebookDocumentEdit> =
|
|
194
|
+
onEdit.mock.calls[0][0];
|
|
195
195
|
const clear = () =>
|
|
196
196
|
[onCode, onName, onConfig, onOrder, onEdit].forEach((fn) =>
|
|
197
197
|
fn.mockClear(),
|
|
@@ -246,8 +246,8 @@ describe("document hooks", () => {
|
|
|
246
246
|
const { wrapper } = setup();
|
|
247
247
|
const { result, rerender } = renderHook(
|
|
248
248
|
(id) => ({
|
|
249
|
-
code:
|
|
250
|
-
edit:
|
|
249
|
+
code: useNotebookCellCode(id),
|
|
250
|
+
edit: useNotebookDocumentEdit(),
|
|
251
251
|
}),
|
|
252
252
|
{ wrapper, initialProps: "c1" },
|
|
253
253
|
);
|
|
@@ -264,11 +264,11 @@ describe("document hooks", () => {
|
|
|
264
264
|
const { store, source, wrapper } = setup(null);
|
|
265
265
|
const { result } = renderHook(
|
|
266
266
|
() => ({
|
|
267
|
-
order:
|
|
268
|
-
code:
|
|
269
|
-
name:
|
|
270
|
-
config:
|
|
271
|
-
edit:
|
|
267
|
+
order: useNotebookCellOrder(),
|
|
268
|
+
code: useNotebookCellCode("c1"),
|
|
269
|
+
name: useNotebookCellName("c1"),
|
|
270
|
+
config: useNotebookCellConfig("c1"),
|
|
271
|
+
edit: useNotebookDocumentEdit(),
|
|
272
272
|
}),
|
|
273
273
|
{ wrapper },
|
|
274
274
|
);
|
|
@@ -309,8 +309,8 @@ describe("document hooks", () => {
|
|
|
309
309
|
it("preserves drafts across Strict Mode remounts until the session ends", () => {
|
|
310
310
|
const { wrapper, controller, detached } = setup();
|
|
311
311
|
const useProbe = () => ({
|
|
312
|
-
code:
|
|
313
|
-
edit:
|
|
312
|
+
code: useNotebookCellCode("c1"),
|
|
313
|
+
edit: useNotebookDocumentEdit(),
|
|
314
314
|
});
|
|
315
315
|
const first = renderHook(useProbe, { wrapper, reactStrictMode: true });
|
|
316
316
|
const edit = first.result.current.edit;
|
|
@@ -340,7 +340,10 @@ describe("document hooks", () => {
|
|
|
340
340
|
);
|
|
341
341
|
const seen = vi.fn();
|
|
342
342
|
function Probe() {
|
|
343
|
-
seen({
|
|
343
|
+
seen({
|
|
344
|
+
code: useNotebookCellCode("c1"),
|
|
345
|
+
edit: useNotebookDocumentEdit(),
|
|
346
|
+
});
|
|
344
347
|
return null;
|
|
345
348
|
}
|
|
346
349
|
const tree = ({ store, model }: typeof first) => (
|
|
@@ -351,7 +354,7 @@ describe("document hooks", () => {
|
|
|
351
354
|
</Provider>
|
|
352
355
|
);
|
|
353
356
|
const { rerender } = render(tree(first));
|
|
354
|
-
const oldEdit: ReturnType<typeof
|
|
357
|
+
const oldEdit: ReturnType<typeof useNotebookDocumentEdit> =
|
|
355
358
|
seen.mock.calls.at(-1)![0].edit;
|
|
356
359
|
act(() => oldEdit((tx) => tx.setCode("c1", "first draft")));
|
|
357
360
|
rerender(tree(second));
|
|
@@ -359,7 +362,7 @@ describe("document hooks", () => {
|
|
|
359
362
|
expect(first.detached).toHaveBeenCalledOnce();
|
|
360
363
|
const latest: {
|
|
361
364
|
code: string | null | undefined;
|
|
362
|
-
edit: ReturnType<typeof
|
|
365
|
+
edit: ReturnType<typeof useNotebookDocumentEdit>;
|
|
363
366
|
} = seen.mock.calls.at(-1)![0];
|
|
364
367
|
expect(latest.code).toBe("second source");
|
|
365
368
|
expect(latest.edit).not.toBe(oldEdit);
|
|
@@ -381,6 +384,8 @@ describe("document hooks", () => {
|
|
|
381
384
|
});
|
|
382
385
|
|
|
383
386
|
it("requires a document provider", () => {
|
|
384
|
-
expect(() => renderHook(
|
|
387
|
+
expect(() => renderHook(useNotebookDocumentEdit)).toThrow(
|
|
388
|
+
"DocumentProvider",
|
|
389
|
+
);
|
|
385
390
|
});
|
|
386
391
|
});
|
|
@@ -5,10 +5,10 @@ import type * as Protocol from "@marimo-team/client/protocol";
|
|
|
5
5
|
import { atom, createStore } from "jotai/vanilla";
|
|
6
6
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
7
7
|
import { Deferred } from "@/utils/Deferred";
|
|
8
|
-
import type { NotebookBackend } from "../../
|
|
9
|
-
import type { Document } from "../../
|
|
8
|
+
import type { NotebookBackend } from "../../replica/backend";
|
|
9
|
+
import type { Document } from "../../replica/resources/document";
|
|
10
10
|
import { createDocumentModel } from "../model";
|
|
11
|
-
import { type FakeEdit, fakeBackend } from "../../
|
|
11
|
+
import { type FakeEdit, fakeBackend } from "../../replica/__tests__/fixtures";
|
|
12
12
|
import { cell, document, withCells } from "./fixtures";
|
|
13
13
|
|
|
14
14
|
function response(confirmed: Document): Result<Protocol.EditResponseOutput> {
|
|
@@ -4,14 +4,14 @@ import { readFileSync } from "node:fs";
|
|
|
4
4
|
import NodeUrl from "node:url";
|
|
5
5
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
6
6
|
import { invariant } from "@/utils/invariant";
|
|
7
|
-
import { fixtureEvents } from "../../
|
|
8
|
-
import type { Document } from "../../
|
|
7
|
+
import { fixtureEvents } from "../../replica/__tests__/fixtures";
|
|
8
|
+
import type { Document } from "../../replica/resources/document";
|
|
9
9
|
|
|
10
10
|
export function protocolFixture(name: string): unknown {
|
|
11
11
|
return JSON.parse(
|
|
12
12
|
readFileSync(
|
|
13
13
|
new NodeUrl.URL(
|
|
14
|
-
|
|
14
|
+
`../../../../../../protocols/host/fixtures/${name}`,
|
|
15
15
|
import.meta.url,
|
|
16
16
|
),
|
|
17
17
|
"utf8",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { createStore } from "jotai/vanilla";
|
|
4
4
|
import { test as baseTest, vi } from "vitest";
|
|
5
|
-
import type { Document } from "../../
|
|
5
|
+
import type { Document } from "../../replica/resources/document";
|
|
6
6
|
import { createDocumentModel } from "../model";
|
|
7
7
|
import { initialDocument } from "./protocol-fixtures";
|
|
8
8
|
import { createTestNotebook } from "./test-notebook";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { atom, createStore } from "jotai/vanilla";
|
|
4
4
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
|
-
import type { Document } from "../../
|
|
5
|
+
import type { Document } from "../../replica/resources/document";
|
|
6
6
|
import {
|
|
7
7
|
createDocumentState,
|
|
8
8
|
type DocumentEdit,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { atom, createStore } from "jotai/vanilla";
|
|
4
4
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
|
-
import type { Document } from "../../
|
|
5
|
+
import type { Document } from "../../replica/resources/document";
|
|
6
6
|
import { selectCell } from "../select";
|
|
7
7
|
import { createDocumentState, type DocumentSubmission } from "../state";
|
|
8
8
|
import { cell, document, withCells } from "./fixtures";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import type { Result } from "@marimo-team/client";
|
|
5
5
|
import * as Protocol from "@marimo-team/client/protocol";
|
|
6
|
-
import type { Document } from "../../
|
|
6
|
+
import type { Document } from "../../replica/resources/document";
|
|
7
7
|
|
|
8
8
|
export interface EditRequest {
|
|
9
9
|
readonly notebookId: Protocol.NotebookId;
|
|
@@ -6,8 +6,8 @@ import { atom, type createStore } from "jotai/vanilla";
|
|
|
6
6
|
import { vi } from "vitest";
|
|
7
7
|
import { Deferred } from "@/utils/Deferred";
|
|
8
8
|
import { invariant } from "@/utils/invariant";
|
|
9
|
-
import { type FakeEdit, fakeBackend } from "../../
|
|
10
|
-
import type { Document } from "../../
|
|
9
|
+
import { type FakeEdit, fakeBackend } from "../../replica/__tests__/fixtures";
|
|
10
|
+
import type { Document } from "../../replica/resources/document";
|
|
11
11
|
import { createTestHost, type EditRequest } from "./test-host";
|
|
12
12
|
|
|
13
13
|
export interface PendingRequest extends EditRequest {
|
|
@@ -44,12 +44,12 @@ import {
|
|
|
44
44
|
languageAdapterFromCode,
|
|
45
45
|
languageAdapterState,
|
|
46
46
|
switchLanguage,
|
|
47
|
-
} from "
|
|
48
|
-
import { initializeSQLDialect } from "
|
|
47
|
+
} from "../../codemirror/language/extension";
|
|
48
|
+
import { initializeSQLDialect } from "../../codemirror/language/languages/sql/sql";
|
|
49
49
|
import {
|
|
50
50
|
languageMetadataField,
|
|
51
51
|
setLanguageMetadata,
|
|
52
|
-
} from "
|
|
52
|
+
} from "../../codemirror/language/metadata";
|
|
53
53
|
import type { DocumentModel } from "./model";
|
|
54
54
|
import { selectCellField } from "./select";
|
|
55
55
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import type { Document } from "../
|
|
3
|
+
import type { Document } from "../replica";
|
|
4
4
|
import * as Protocol from "@marimo-team/client/protocol";
|
|
5
5
|
|
|
6
6
|
/** The fields a client edits. Null code means the host withheld source. */
|