@marimo-team/islands 0.23.9-dev46 → 0.23.9-dev48
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/{code-visibility-5tqUgLbx.js → code-visibility-CdpiX8Ib.js} +1 -1
- package/dist/main.js +4 -2
- package/dist/{reveal-component-8MW3DINl.js → reveal-component-omMDI-na.js} +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/editor/Disconnected.tsx +1 -60
- package/src/components/editor/__tests__/viewer-banner.test.tsx +89 -0
- package/src/components/editor/header/__tests__/status.test.tsx +0 -15
- package/src/components/editor/header/app-header.tsx +1 -4
- package/src/components/editor/header/status.tsx +4 -13
- package/src/components/editor/viewer-banner.tsx +82 -0
- package/src/core/edit-app.tsx +3 -0
- package/src/core/islands/bootstrap.ts +2 -0
- package/src/core/kernel/__tests__/handlers.test.ts +5 -0
- package/src/core/websocket/__tests__/useMarimoKernelConnection.test.ts +0 -13
- package/src/core/websocket/types.ts +0 -6
- package/src/core/websocket/useMarimoKernelConnection.tsx +3 -12
package/package.json
CHANGED
|
@@ -1,69 +1,10 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import { ArrowRightSquareIcon } from "lucide-react";
|
|
4
|
-
import { API } from "@/core/network/api";
|
|
5
|
-
import { Banner } from "@/plugins/impl/common/error-banner";
|
|
6
|
-
import { prettyError } from "@/utils/errors";
|
|
7
|
-
import { reloadSafe } from "@/utils/reload-safe";
|
|
8
|
-
import { Button } from "../ui/button";
|
|
9
|
-
import { toast } from "../ui/use-toast";
|
|
10
|
-
|
|
11
3
|
interface DisconnectedProps {
|
|
12
4
|
reason: string;
|
|
13
|
-
canTakeover: boolean | undefined;
|
|
14
5
|
}
|
|
15
6
|
|
|
16
|
-
export const Disconnected = ({
|
|
17
|
-
reason,
|
|
18
|
-
canTakeover = false,
|
|
19
|
-
}: DisconnectedProps) => {
|
|
20
|
-
const handleTakeover = async () => {
|
|
21
|
-
try {
|
|
22
|
-
const searchParams = new URL(window.location.href).searchParams;
|
|
23
|
-
await API.post(`/kernel/takeover?${searchParams.toString()}`, {});
|
|
24
|
-
|
|
25
|
-
// Refresh the page to reconnect
|
|
26
|
-
reloadSafe();
|
|
27
|
-
} catch (error) {
|
|
28
|
-
toast({
|
|
29
|
-
title: "Failed to take over session",
|
|
30
|
-
description: prettyError(error),
|
|
31
|
-
variant: "danger",
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
if (canTakeover) {
|
|
37
|
-
return (
|
|
38
|
-
<div className="flex justify-center">
|
|
39
|
-
<Banner
|
|
40
|
-
kind="info"
|
|
41
|
-
className="mt-10 flex flex-col rounded p-3 max-w-[800px] mx-4"
|
|
42
|
-
>
|
|
43
|
-
<div className="flex justify-between">
|
|
44
|
-
<span className="font-bold text-xl flex items-center mb-2">
|
|
45
|
-
Notebook already connected
|
|
46
|
-
</span>
|
|
47
|
-
</div>
|
|
48
|
-
<div className="flex justify-between items-end text-base gap-20">
|
|
49
|
-
<span>{reason}</span>
|
|
50
|
-
{canTakeover && (
|
|
51
|
-
<Button
|
|
52
|
-
onClick={handleTakeover}
|
|
53
|
-
variant="outline"
|
|
54
|
-
data-testid="takeover-button"
|
|
55
|
-
className="shrink-0"
|
|
56
|
-
>
|
|
57
|
-
<ArrowRightSquareIcon className="w-4 h-4 mr-2" />
|
|
58
|
-
Take over session
|
|
59
|
-
</Button>
|
|
60
|
-
)}
|
|
61
|
-
</div>
|
|
62
|
-
</Banner>
|
|
63
|
-
</div>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
7
|
+
export const Disconnected = ({ reason }: DisconnectedProps) => {
|
|
67
8
|
return (
|
|
68
9
|
<div className="font-mono text-center text-base text-(--red-11)">
|
|
69
10
|
<p>{reason}</p>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { createStore, Provider } from "jotai";
|
|
4
|
+
import { describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
6
|
+
import { layoutStateAtom } from "@/core/layout/layout";
|
|
7
|
+
import { kioskModeAtom, viewStateAtom } from "@/core/mode";
|
|
8
|
+
import { API } from "@/core/network/api";
|
|
9
|
+
import { ViewerBanner } from "../viewer-banner";
|
|
10
|
+
|
|
11
|
+
describe("ViewerBanner", () => {
|
|
12
|
+
it("renders nothing when not in kiosk mode", () => {
|
|
13
|
+
const store = createStore();
|
|
14
|
+
store.set(kioskModeAtom, false);
|
|
15
|
+
const { container } = render(
|
|
16
|
+
<Provider store={store}>
|
|
17
|
+
<TooltipProvider>
|
|
18
|
+
<ViewerBanner />
|
|
19
|
+
</TooltipProvider>
|
|
20
|
+
</Provider>,
|
|
21
|
+
);
|
|
22
|
+
expect(container).toBeEmptyDOMElement();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("renders nothing for an intentional kiosk client (?kiosk=true)", () => {
|
|
26
|
+
const store = createStore();
|
|
27
|
+
store.set(kioskModeAtom, true);
|
|
28
|
+
window.history.pushState({}, "", "/?kiosk=true");
|
|
29
|
+
try {
|
|
30
|
+
const { container } = render(
|
|
31
|
+
<Provider store={store}>
|
|
32
|
+
<TooltipProvider>
|
|
33
|
+
<ViewerBanner />
|
|
34
|
+
</TooltipProvider>
|
|
35
|
+
</Provider>,
|
|
36
|
+
);
|
|
37
|
+
expect(container).toBeEmptyDOMElement();
|
|
38
|
+
} finally {
|
|
39
|
+
window.history.pushState({}, "", "/");
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("renders nothing in a non-vertical layout (grid/slides)", () => {
|
|
44
|
+
const store = createStore();
|
|
45
|
+
store.set(kioskModeAtom, true);
|
|
46
|
+
store.set(layoutStateAtom, { selectedLayout: "grid", layoutData: {} });
|
|
47
|
+
const { container } = render(
|
|
48
|
+
<Provider store={store}>
|
|
49
|
+
<TooltipProvider>
|
|
50
|
+
<ViewerBanner />
|
|
51
|
+
</TooltipProvider>
|
|
52
|
+
</Provider>,
|
|
53
|
+
);
|
|
54
|
+
expect(container).toBeEmptyDOMElement();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("renders nothing in present mode", () => {
|
|
58
|
+
const store = createStore();
|
|
59
|
+
store.set(kioskModeAtom, true);
|
|
60
|
+
store.set(viewStateAtom, { mode: "present", cellAnchor: null });
|
|
61
|
+
const { container } = render(
|
|
62
|
+
<Provider store={store}>
|
|
63
|
+
<TooltipProvider>
|
|
64
|
+
<ViewerBanner />
|
|
65
|
+
</TooltipProvider>
|
|
66
|
+
</Provider>,
|
|
67
|
+
);
|
|
68
|
+
expect(container).toBeEmptyDOMElement();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("shows take over and posts without reload when viewing", () => {
|
|
72
|
+
const store = createStore();
|
|
73
|
+
store.set(kioskModeAtom, true);
|
|
74
|
+
const post = vi.spyOn(API, "post").mockResolvedValue({} as never);
|
|
75
|
+
render(
|
|
76
|
+
<Provider store={store}>
|
|
77
|
+
<TooltipProvider>
|
|
78
|
+
<ViewerBanner />
|
|
79
|
+
</TooltipProvider>
|
|
80
|
+
</Provider>,
|
|
81
|
+
);
|
|
82
|
+
const button = screen.getByTestId("takeover-button");
|
|
83
|
+
button.click();
|
|
84
|
+
expect(post).toHaveBeenCalledWith(
|
|
85
|
+
expect.stringContaining("/kernel/takeover"),
|
|
86
|
+
{},
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -90,19 +90,4 @@ describe("StatusOverlay disconnect indicator", () => {
|
|
|
90
90
|
expect(onReconnect).not.toHaveBeenCalled();
|
|
91
91
|
},
|
|
92
92
|
);
|
|
93
|
-
|
|
94
|
-
it("does not render the disconnect icon when another tab has taken over", () => {
|
|
95
|
-
const onReconnect = vi.fn();
|
|
96
|
-
const { queryByTestId } = renderOverlay(
|
|
97
|
-
{
|
|
98
|
-
state: WebSocketState.CLOSED,
|
|
99
|
-
code: WebSocketClosedReason.ALREADY_RUNNING,
|
|
100
|
-
reason: "another browser tab is already connected to the kernel",
|
|
101
|
-
canTakeover: true,
|
|
102
|
-
},
|
|
103
|
-
onReconnect,
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
expect(queryByTestId("disconnected-indicator")).toBeNull();
|
|
107
|
-
});
|
|
108
93
|
});
|
|
@@ -18,10 +18,7 @@ export const AppHeader: React.FC<PropsWithChildren<Props>> = ({
|
|
|
18
18
|
<div className={className}>
|
|
19
19
|
{children}
|
|
20
20
|
{connection.state === WebSocketState.CLOSED && (
|
|
21
|
-
<Disconnected
|
|
22
|
-
reason={connection.reason}
|
|
23
|
-
canTakeover={connection.canTakeover}
|
|
24
|
-
/>
|
|
21
|
+
<Disconnected reason={connection.reason} />
|
|
25
22
|
)}
|
|
26
23
|
</div>
|
|
27
24
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import { useAtomValue } from "jotai";
|
|
4
|
-
import { HourglassIcon,
|
|
4
|
+
import { HourglassIcon, UnlinkIcon } from "lucide-react";
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { Tooltip } from "@/components/ui/tooltip";
|
|
7
7
|
import { notebookScrollToRunning } from "@/core/cells/actions";
|
|
@@ -24,13 +24,13 @@ export const StatusOverlay: React.FC<{
|
|
|
24
24
|
const isOpen = connection.state === WebSocketState.OPEN;
|
|
25
25
|
// Only KERNEL_DISCONNECTED is recoverable by a retry. Other terminal
|
|
26
26
|
// reasons (MALFORMED_QUERY, KERNEL_STARTUP_ERROR) would deterministically
|
|
27
|
-
// fail the same way
|
|
27
|
+
// fail the same way.
|
|
28
28
|
const canReconnect =
|
|
29
29
|
isClosed && connection.code === WebSocketClosedReason.KERNEL_DISCONNECTED;
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<>
|
|
33
|
-
{isClosed &&
|
|
33
|
+
{isClosed && <NoiseBackground />}
|
|
34
34
|
<div
|
|
35
35
|
className={cn(
|
|
36
36
|
"z-50 top-4 left-4",
|
|
@@ -38,12 +38,11 @@ export const StatusOverlay: React.FC<{
|
|
|
38
38
|
)}
|
|
39
39
|
>
|
|
40
40
|
{isOpen && isRunning && <RunningIcon />}
|
|
41
|
-
{isClosed &&
|
|
41
|
+
{isClosed && (
|
|
42
42
|
<DisconnectedIcon
|
|
43
43
|
onReconnect={canReconnect ? onReconnect : undefined}
|
|
44
44
|
/>
|
|
45
45
|
)}
|
|
46
|
-
{isClosed && connection.canTakeover && <LockedIcon />}
|
|
47
46
|
</div>
|
|
48
47
|
</>
|
|
49
48
|
);
|
|
@@ -79,14 +78,6 @@ const DisconnectedIcon: React.FC<{ onReconnect?: () => void }> = ({
|
|
|
79
78
|
);
|
|
80
79
|
};
|
|
81
80
|
|
|
82
|
-
const LockedIcon = () => (
|
|
83
|
-
<Tooltip content="Notebook locked">
|
|
84
|
-
<div className={topLeftStatus}>
|
|
85
|
-
<LockIcon className="w-[25px] h-[25px] text-(--blue-11)" />
|
|
86
|
-
</div>
|
|
87
|
-
</Tooltip>
|
|
88
|
-
);
|
|
89
|
-
|
|
90
81
|
const RunningIcon = () => {
|
|
91
82
|
const scratchpadOnly = useAtomValue(onlyScratchpadIsRunningAtom);
|
|
92
83
|
const tooltip = scratchpadOnly
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { useAtomValue } from "jotai/react";
|
|
4
|
+
import { ArrowRightSquareIcon, EyeIcon } from "lucide-react";
|
|
5
|
+
import { KnownQueryParams } from "@/core/constants";
|
|
6
|
+
import { useLayoutState } from "@/core/layout/layout";
|
|
7
|
+
import { kioskModeAtom, viewStateAtom } from "@/core/mode";
|
|
8
|
+
import { API } from "@/core/network/api";
|
|
9
|
+
import { Banner } from "@/plugins/impl/common/error-banner";
|
|
10
|
+
import { prettyError } from "@/utils/errors";
|
|
11
|
+
import { Button } from "../ui/button";
|
|
12
|
+
import { Tooltip } from "../ui/tooltip";
|
|
13
|
+
import { toast } from "../ui/use-toast";
|
|
14
|
+
|
|
15
|
+
export const ViewerBanner = () => {
|
|
16
|
+
const isViewing = useAtomValue(kioskModeAtom);
|
|
17
|
+
const { selectedLayout } = useLayoutState();
|
|
18
|
+
const { mode } = useAtomValue(viewStateAtom);
|
|
19
|
+
|
|
20
|
+
// Only a demoted editor (a second tab auto-routed to read-only) is offered
|
|
21
|
+
// takeover. A client that explicitly requested kiosk (?kiosk=true: embeds,
|
|
22
|
+
// slide previews, dashboards) is an intentional viewer and gets no banner.
|
|
23
|
+
const isIntentionalKiosk = new URL(window.location.href).searchParams.has(
|
|
24
|
+
KnownQueryParams.kiosk,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// Takeover is an editing affordance: only surface it in the default vertical
|
|
28
|
+
// reading view. Grid/slides layouts and present mode are app-style views
|
|
29
|
+
// where a floating take-over banner is out of place.
|
|
30
|
+
if (
|
|
31
|
+
!isViewing ||
|
|
32
|
+
isIntentionalKiosk ||
|
|
33
|
+
selectedLayout !== "vertical" ||
|
|
34
|
+
mode === "present"
|
|
35
|
+
) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const handleTakeover = async () => {
|
|
40
|
+
try {
|
|
41
|
+
const searchParams = new URL(window.location.href).searchParams;
|
|
42
|
+
// No reload: the server replies with consumer-capabilities
|
|
43
|
+
// (edit: true), which flips kiosk mode off and hides this banner.
|
|
44
|
+
await API.post(`/kernel/takeover?${searchParams.toString()}`, {});
|
|
45
|
+
} catch (error) {
|
|
46
|
+
toast({
|
|
47
|
+
title: "Failed to take over session",
|
|
48
|
+
description: prettyError(error),
|
|
49
|
+
variant: "danger",
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div className="absolute top-2 left-2 z-50 w-fit print:hidden">
|
|
56
|
+
<Banner
|
|
57
|
+
kind="info"
|
|
58
|
+
className="flex items-center gap-2 rounded px-2 py-1 text-xs shadow-sm"
|
|
59
|
+
>
|
|
60
|
+
<span className="flex items-center gap-1 text-muted-foreground">
|
|
61
|
+
<EyeIcon className="w-3.5 h-3.5 shrink-0" />
|
|
62
|
+
You are currently connected as a reader.
|
|
63
|
+
</span>
|
|
64
|
+
<Tooltip
|
|
65
|
+
content="Switch editing to this tab. The current editor becomes read-only."
|
|
66
|
+
side="bottom"
|
|
67
|
+
>
|
|
68
|
+
<Button
|
|
69
|
+
onClick={handleTakeover}
|
|
70
|
+
variant="outline"
|
|
71
|
+
size="xs"
|
|
72
|
+
data-testid="takeover-button"
|
|
73
|
+
className="shrink-0"
|
|
74
|
+
>
|
|
75
|
+
<ArrowRightSquareIcon className="w-3 h-3 mr-1" />
|
|
76
|
+
Take over
|
|
77
|
+
</Button>
|
|
78
|
+
</Tooltip>
|
|
79
|
+
</Banner>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
package/src/core/edit-app.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import { Controls } from "@/components/editor/controls/Controls";
|
|
|
12
12
|
import { AppHeader } from "@/components/editor/header/app-header";
|
|
13
13
|
import { FilenameForm } from "@/components/editor/header/filename-form";
|
|
14
14
|
import { MultiCellActionToolbar } from "@/components/editor/navigation/multi-cell-action-toolbar";
|
|
15
|
+
import { ViewerBanner } from "@/components/editor/viewer-banner";
|
|
15
16
|
import { cn } from "@/utils/cn";
|
|
16
17
|
import { Paths } from "@/utils/paths";
|
|
17
18
|
import { AppContainer } from "../components/editor/app-container";
|
|
@@ -164,6 +165,8 @@ export const EditApp: React.FC<AppProps> = ({
|
|
|
164
165
|
)}
|
|
165
166
|
</AppHeader>
|
|
166
167
|
|
|
168
|
+
<ViewerBanner />
|
|
169
|
+
|
|
167
170
|
{/* Don't render until we have a single cell */}
|
|
168
171
|
{hasCells && (
|
|
169
172
|
<CellsRenderer appConfig={appConfig} mode={viewState.mode}>
|
|
@@ -90,6 +90,7 @@ describe("buildCellData", () => {
|
|
|
90
90
|
terminal: false,
|
|
91
91
|
},
|
|
92
92
|
auto_instantiated: false,
|
|
93
|
+
consumer_capabilities: { edit: true, interact: true },
|
|
93
94
|
};
|
|
94
95
|
|
|
95
96
|
const cells = buildCellData(kernelReadyData);
|
|
@@ -158,6 +159,7 @@ describe("buildCellData", () => {
|
|
|
158
159
|
terminal: false,
|
|
159
160
|
},
|
|
160
161
|
auto_instantiated: false,
|
|
162
|
+
consumer_capabilities: { edit: true, interact: true },
|
|
161
163
|
};
|
|
162
164
|
|
|
163
165
|
const cells = buildCellData(kernelReadyData);
|
|
@@ -191,6 +193,7 @@ describe("buildCellData", () => {
|
|
|
191
193
|
terminal: false,
|
|
192
194
|
},
|
|
193
195
|
auto_instantiated: false,
|
|
196
|
+
consumer_capabilities: { edit: true, interact: true },
|
|
194
197
|
};
|
|
195
198
|
|
|
196
199
|
const cells = buildCellData(kernelReadyData);
|
|
@@ -223,6 +226,7 @@ describe("buildLayoutState", () => {
|
|
|
223
226
|
terminal: false,
|
|
224
227
|
},
|
|
225
228
|
auto_instantiated: false,
|
|
229
|
+
consumer_capabilities: { edit: true, interact: true },
|
|
226
230
|
};
|
|
227
231
|
|
|
228
232
|
const cells = buildCellData(kernelReadyData);
|
|
@@ -271,6 +275,7 @@ describe("buildLayoutState", () => {
|
|
|
271
275
|
terminal: false,
|
|
272
276
|
},
|
|
273
277
|
auto_instantiated: false,
|
|
278
|
+
consumer_capabilities: { edit: true, interact: true },
|
|
274
279
|
};
|
|
275
280
|
|
|
276
281
|
const cells = buildCellData(kernelReadyData);
|
|
@@ -31,19 +31,6 @@ describe("classifyCloseEvent", () => {
|
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
describe("terminal closes (server-initiated)", () => {
|
|
34
|
-
it("MARIMO_ALREADY_CONNECTED → terminal + closeTransport, with takeover", () => {
|
|
35
|
-
const decision = classify("MARIMO_ALREADY_CONNECTED");
|
|
36
|
-
expect(decision.kind).toBe("terminal");
|
|
37
|
-
expect(decision.status).toMatchObject({
|
|
38
|
-
state: WebSocketState.CLOSED,
|
|
39
|
-
code: WebSocketClosedReason.ALREADY_RUNNING,
|
|
40
|
-
canTakeover: true,
|
|
41
|
-
});
|
|
42
|
-
if (decision.kind === "terminal") {
|
|
43
|
-
expect(decision.closeTransport).toBe(true);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
34
|
it.each([
|
|
48
35
|
"MARIMO_WRONG_KERNEL_ID",
|
|
49
36
|
"MARIMO_NO_FILE_KEY",
|
|
@@ -14,7 +14,6 @@ export type WebSocketState =
|
|
|
14
14
|
|
|
15
15
|
export const WebSocketClosedReason = {
|
|
16
16
|
KERNEL_DISCONNECTED: "KERNEL_DISCONNECTED",
|
|
17
|
-
ALREADY_RUNNING: "ALREADY_RUNNING",
|
|
18
17
|
MALFORMED_QUERY: "MALFORMED_QUERY",
|
|
19
18
|
KERNEL_STARTUP_ERROR: "KERNEL_STARTUP_ERROR",
|
|
20
19
|
} as const;
|
|
@@ -30,11 +29,6 @@ export type ConnectionStatus =
|
|
|
30
29
|
* Human-readable reason for closing the connection.
|
|
31
30
|
*/
|
|
32
31
|
reason: string;
|
|
33
|
-
/**
|
|
34
|
-
* Whether the current session can be taken over by another session,
|
|
35
|
-
* since we only allow single-user editing.
|
|
36
|
-
*/
|
|
37
|
-
canTakeover?: boolean;
|
|
38
32
|
}
|
|
39
33
|
| {
|
|
40
34
|
state:
|
|
@@ -82,7 +82,6 @@ const SUPPORTS_LAZY_KERNELS = true;
|
|
|
82
82
|
// (marimo/_server/api/endpoints/ws_endpoint.py and ws/*.py). Keep in sync with
|
|
83
83
|
// the backend literals.
|
|
84
84
|
export type CloseReason =
|
|
85
|
-
| "MARIMO_ALREADY_CONNECTED"
|
|
86
85
|
| "MARIMO_WRONG_KERNEL_ID"
|
|
87
86
|
| "MARIMO_NO_FILE_KEY"
|
|
88
87
|
| "MARIMO_NO_SESSION_ID"
|
|
@@ -99,17 +98,6 @@ export type CloseDecision =
|
|
|
99
98
|
|
|
100
99
|
export function classifyCloseEvent(event: { reason?: string }): CloseDecision {
|
|
101
100
|
switch (event.reason as CloseReason | undefined) {
|
|
102
|
-
case "MARIMO_ALREADY_CONNECTED":
|
|
103
|
-
return {
|
|
104
|
-
kind: "terminal",
|
|
105
|
-
status: {
|
|
106
|
-
state: WebSocketState.CLOSED,
|
|
107
|
-
code: WebSocketClosedReason.ALREADY_RUNNING,
|
|
108
|
-
reason: "another browser tab is already connected to the kernel",
|
|
109
|
-
canTakeover: true,
|
|
110
|
-
},
|
|
111
|
-
closeTransport: true,
|
|
112
|
-
};
|
|
113
101
|
case TRANSPORT_EXHAUSTED_REASON:
|
|
114
102
|
return {
|
|
115
103
|
kind: "gave-up",
|
|
@@ -421,6 +409,9 @@ export function useMarimoKernelConnection(opts: {
|
|
|
421
409
|
case "notebook-document-transaction":
|
|
422
410
|
handleDocumentTransaction(msg.data.transaction);
|
|
423
411
|
return;
|
|
412
|
+
case "consumer-capabilities":
|
|
413
|
+
setKioskMode(!msg.data.consumer_capabilities.edit);
|
|
414
|
+
return;
|
|
424
415
|
default:
|
|
425
416
|
logNever(msg.data);
|
|
426
417
|
}
|