@marimo-team/islands 0.23.9-dev45 → 0.23.9-dev47
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-CDsEg2QC.js → code-visibility-B_FaVMb1.js} +1 -1
- package/dist/main.js +1097 -1071
- package/dist/{reveal-component-X3DvD8Y2.js → reveal-component-BsF-TmCD.js} +300 -279
- 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/renderers/slides-layout/__tests__/compute-slide-cells.test.ts +30 -17
- package/src/components/editor/renderers/slides-layout/compute-slide-cells.ts +17 -8
- package/src/components/editor/renderers/slides-layout/slides-layout.tsx +9 -11
- package/src/components/editor/viewer-banner.tsx +82 -0
- package/src/components/slides/minimap.tsx +45 -9
- package/src/components/slides/reveal-component.tsx +79 -34
- 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
|
|
@@ -26,8 +26,9 @@ const layoutOf = (entries: Array<[string, SlideConfig]>): SlidesLayout => ({
|
|
|
26
26
|
describe("computeSlideCellsInfo", () => {
|
|
27
27
|
it("returns empty results for empty input", () => {
|
|
28
28
|
const result = computeSlideCellsInfo([], layoutOf([]));
|
|
29
|
-
expect(result.
|
|
29
|
+
expect(result.slideCells).toEqual([]);
|
|
30
30
|
expect(result.skippedIds.size).toBe(0);
|
|
31
|
+
expect(result.noOutputIds.size).toBe(0);
|
|
31
32
|
expect(result.slideTypes.size).toBe(0);
|
|
32
33
|
expect(result.startCellIndex).toBe(0);
|
|
33
34
|
});
|
|
@@ -62,22 +63,26 @@ describe("computeSlideCellsInfo", () => {
|
|
|
62
63
|
expect(result.startCellIndex).toBe(0);
|
|
63
64
|
});
|
|
64
65
|
|
|
65
|
-
it("
|
|
66
|
+
it("keeps cells with no output for the minimap", () => {
|
|
66
67
|
const result = computeSlideCellsInfo(
|
|
67
68
|
[cell("a"), cell("b", null), cell("c")],
|
|
68
69
|
layoutOf([]),
|
|
69
70
|
);
|
|
70
|
-
expect(result.
|
|
71
|
+
expect(result.slideCells.map((c) => c.id)).toEqual(["a", "b", "c"]);
|
|
72
|
+
expect([...result.noOutputIds]).toEqual(["b"]);
|
|
73
|
+
expect([...result.skippedIds]).toEqual(["b"]);
|
|
71
74
|
});
|
|
72
75
|
|
|
73
|
-
it("
|
|
76
|
+
it("keeps cells whose output data is empty string for the minimap", () => {
|
|
74
77
|
// Mirrors the editor contract: an explicit empty-string payload means the
|
|
75
|
-
// cell rendered nothing, so it should not occupy a slide.
|
|
78
|
+
// cell rendered nothing, so it should not occupy a reveal slide.
|
|
76
79
|
const result = computeSlideCellsInfo(
|
|
77
80
|
[cell("a"), cell("b", { data: "" }), cell("c")],
|
|
78
81
|
layoutOf([]),
|
|
79
82
|
);
|
|
80
|
-
expect(result.
|
|
83
|
+
expect(result.slideCells.map((c) => c.id)).toEqual(["a", "b", "c"]);
|
|
84
|
+
expect([...result.noOutputIds]).toEqual(["b"]);
|
|
85
|
+
expect([...result.skippedIds]).toEqual(["b"]);
|
|
81
86
|
});
|
|
82
87
|
|
|
83
88
|
it("keeps cells whose output data is a non-empty value (including falsy ones)", () => {
|
|
@@ -91,7 +96,8 @@ describe("computeSlideCellsInfo", () => {
|
|
|
91
96
|
],
|
|
92
97
|
layoutOf([]),
|
|
93
98
|
);
|
|
94
|
-
expect(result.
|
|
99
|
+
expect(result.slideCells.map((c) => c.id)).toEqual(["a", "b", "c"]);
|
|
100
|
+
expect(result.noOutputIds.size).toBe(0);
|
|
95
101
|
});
|
|
96
102
|
|
|
97
103
|
it("populates slideTypes only for cells with an explicit type", () => {
|
|
@@ -121,14 +127,12 @@ describe("computeSlideCellsInfo", () => {
|
|
|
121
127
|
expect([...result.skippedIds]).toEqual(["b", "c"]);
|
|
122
128
|
// Skipped cells are still "visible" deck cells — they just aren't rendered
|
|
123
129
|
// in reveal. The minimap relies on the full list plus skippedIds.
|
|
124
|
-
expect(result.
|
|
130
|
+
expect(result.slideCells.map((c) => c.id)).toEqual(["a", "b", "c"]);
|
|
125
131
|
expect(result.slideTypes.get(cellId("b"))).toBe("skip");
|
|
126
132
|
});
|
|
127
133
|
|
|
128
|
-
it("
|
|
129
|
-
//
|
|
130
|
-
// the user deleted its code), it should drop out of both maps — otherwise
|
|
131
|
-
// the skip set would reference ghosts.
|
|
134
|
+
it("preserves configured slide types for cells that have no output", () => {
|
|
135
|
+
// The missing output is transient runtime state, not persisted slide config.
|
|
132
136
|
const result = computeSlideCellsInfo(
|
|
133
137
|
[cell("a"), cell("b", null)],
|
|
134
138
|
layoutOf([
|
|
@@ -136,16 +140,25 @@ describe("computeSlideCellsInfo", () => {
|
|
|
136
140
|
["b", { type: "skip" }],
|
|
137
141
|
]),
|
|
138
142
|
);
|
|
139
|
-
expect(result.
|
|
140
|
-
expect(result.
|
|
141
|
-
expect(result.
|
|
143
|
+
expect(result.slideCells.map((c) => c.id)).toEqual(["a", "b"]);
|
|
144
|
+
expect([...result.noOutputIds]).toEqual(["b"]);
|
|
145
|
+
expect([...result.skippedIds]).toEqual(["b"]);
|
|
146
|
+
expect(result.slideTypes.get(cellId("b"))).toBe("skip");
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("skips no-output cells when computing the starting cell", () => {
|
|
150
|
+
const result = computeSlideCellsInfo(
|
|
151
|
+
[cell("a", null), cell("b", { data: "" }), cell("c")],
|
|
152
|
+
layoutOf([]),
|
|
153
|
+
);
|
|
154
|
+
expect(result.startCellIndex).toBe(2);
|
|
142
155
|
});
|
|
143
156
|
|
|
144
|
-
it("preserves the input order of cells in
|
|
157
|
+
it("preserves the input order of cells in slideCells", () => {
|
|
145
158
|
const result = computeSlideCellsInfo(
|
|
146
159
|
[cell("c"), cell("a"), cell("b")],
|
|
147
160
|
layoutOf([]),
|
|
148
161
|
);
|
|
149
|
-
expect(result.
|
|
162
|
+
expect(result.slideCells.map((c) => c.id)).toEqual(["c", "a", "b"]);
|
|
150
163
|
});
|
|
151
164
|
});
|
|
@@ -9,32 +9,40 @@ export interface SlideCellLike {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface SlideCellsInfo<T extends SlideCellLike> {
|
|
12
|
-
|
|
12
|
+
slideCells: T[];
|
|
13
13
|
skippedIds: Set<CellId>;
|
|
14
|
+
noOutputIds: Set<CellId>;
|
|
14
15
|
slideTypes: Map<CellId, SlideType>;
|
|
15
|
-
// Index of the first cell in `
|
|
16
|
+
// Index of the first cell in `slideCells` that is not effectively skipped.
|
|
16
17
|
startCellIndex: number;
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
export function hasRenderableOutput(cell: SlideCellLike): boolean {
|
|
21
|
+
return cell.output != null && cell.output.data !== "";
|
|
22
|
+
}
|
|
23
|
+
|
|
19
24
|
export function computeSlideCellsInfo<T extends SlideCellLike>(
|
|
20
25
|
cells: readonly T[],
|
|
21
26
|
layout: Pick<SlidesLayout, "cells">,
|
|
22
27
|
): SlideCellsInfo<T> {
|
|
23
|
-
const
|
|
24
|
-
(cell) => cell.output != null && cell.output.data !== "",
|
|
25
|
-
);
|
|
28
|
+
const slideCells = [...cells];
|
|
26
29
|
const skippedIds = new Set<CellId>();
|
|
30
|
+
const noOutputIds = new Set<CellId>();
|
|
27
31
|
const slideTypes = new Map<CellId, SlideType>();
|
|
28
32
|
|
|
29
33
|
let startCell: T | null = null;
|
|
30
34
|
let startCellIndex = 0;
|
|
31
35
|
|
|
32
|
-
for (const [index, cell] of
|
|
36
|
+
for (const [index, cell] of slideCells.entries()) {
|
|
33
37
|
const type = layout.cells.get(cell.id)?.type;
|
|
38
|
+
const hasOutput = hasRenderableOutput(cell);
|
|
34
39
|
if (type) {
|
|
35
40
|
slideTypes.set(cell.id, type);
|
|
36
41
|
}
|
|
37
|
-
if (
|
|
42
|
+
if (!hasOutput) {
|
|
43
|
+
noOutputIds.add(cell.id);
|
|
44
|
+
}
|
|
45
|
+
if (type === "skip" || !hasOutput) {
|
|
38
46
|
skippedIds.add(cell.id);
|
|
39
47
|
} else if (startCell === null) {
|
|
40
48
|
startCell = cell;
|
|
@@ -42,8 +50,9 @@ export function computeSlideCellsInfo<T extends SlideCellLike>(
|
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
return {
|
|
45
|
-
|
|
53
|
+
slideCells,
|
|
46
54
|
skippedIds,
|
|
55
|
+
noOutputIds,
|
|
47
56
|
slideTypes,
|
|
48
57
|
startCellIndex,
|
|
49
58
|
};
|
|
@@ -30,19 +30,17 @@ export const SlidesLayoutRenderer: React.FC<Props> = ({
|
|
|
30
30
|
const isMultiColumn = numColumns > 1;
|
|
31
31
|
const [activeCellId, setActiveCellId] = useState<CellId | null>(null);
|
|
32
32
|
|
|
33
|
-
const {
|
|
34
|
-
() => computeSlideCellsInfo(cells, layout),
|
|
35
|
-
[cells, layout],
|
|
36
|
-
);
|
|
33
|
+
const { slideCells, skippedIds, noOutputIds, slideTypes, startCellIndex } =
|
|
34
|
+
useMemo(() => computeSlideCellsInfo(cells, layout), [cells, layout]);
|
|
37
35
|
|
|
38
36
|
const activeSlideIndex = activeCellId
|
|
39
|
-
?
|
|
37
|
+
? slideCells.findIndex((c) => c.id === activeCellId)
|
|
40
38
|
: startCellIndex;
|
|
41
39
|
const resolvedIndex =
|
|
42
40
|
activeSlideIndex === -1 ? startCellIndex : activeSlideIndex;
|
|
43
41
|
|
|
44
42
|
const handleSlideChange = useEvent((index: number) => {
|
|
45
|
-
const cell =
|
|
43
|
+
const cell = slideCells[index];
|
|
46
44
|
if (cell) {
|
|
47
45
|
setActiveCellId(cell.id);
|
|
48
46
|
}
|
|
@@ -50,9 +48,10 @@ export const SlidesLayoutRenderer: React.FC<Props> = ({
|
|
|
50
48
|
|
|
51
49
|
const slides = (
|
|
52
50
|
<LazySlidesComponent
|
|
53
|
-
|
|
51
|
+
slideCells={slideCells}
|
|
54
52
|
layout={layout}
|
|
55
53
|
setLayout={setLayout}
|
|
54
|
+
noOutputIds={noOutputIds}
|
|
56
55
|
activeIndex={resolvedIndex}
|
|
57
56
|
onSlideChange={handleSlideChange}
|
|
58
57
|
configWidth={280}
|
|
@@ -85,13 +84,12 @@ export const SlidesLayoutRenderer: React.FC<Props> = ({
|
|
|
85
84
|
return (
|
|
86
85
|
<div className="flex-1 pr-18 pb-2 flex flex-row gap-2 min-h-0">
|
|
87
86
|
<SlidesMinimap
|
|
88
|
-
cells={
|
|
87
|
+
cells={slideCells}
|
|
89
88
|
thumbnailWidth={220}
|
|
90
89
|
canReorder={!isMultiColumn}
|
|
91
|
-
activeCellId={
|
|
92
|
-
activeCellId ?? cellsWithOutput[startCellIndex]?.id ?? null
|
|
93
|
-
}
|
|
90
|
+
activeCellId={activeCellId ?? slideCells[startCellIndex]?.id ?? null}
|
|
94
91
|
skippedIds={skippedIds}
|
|
92
|
+
noOutputIds={noOutputIds}
|
|
95
93
|
slideTypes={slideTypes}
|
|
96
94
|
onSlideClick={handleSlideChange}
|
|
97
95
|
/>
|
|
@@ -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
|
+
};
|