@marimo-team/islands 0.23.9-dev8 → 0.23.9

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.
Files changed (101) hide show
  1. package/dist/{ConnectedDataExplorerComponent-OzrfMM5L.js → ConnectedDataExplorerComponent-CyV83R2m.js} +4 -4
  2. package/dist/assets/__vite-browser-external-Ci2ZQfXU.js +1 -0
  3. package/dist/assets/{worker-CpBbwbQo.js → worker-ip3AI_sN.js} +2 -2
  4. package/dist/{chat-ui-BDI3FMI8.js → chat-ui-ChD4VvCo.js} +3060 -3033
  5. package/dist/{code-visibility-SqsoLwxQ.js → code-visibility-BkuwTYAm.js} +1368 -1204
  6. package/dist/{formats-DQ5qjo_Q.js → formats-DHxc-FdY.js} +1 -1
  7. package/dist/{glide-data-editor-DqRY9naW.js → glide-data-editor-BOmK9ETQ.js} +2 -2
  8. package/dist/{html-to-image-CiSinpSR.js → html-to-image-BHv7CEU_.js} +2145 -2153
  9. package/dist/{input-CZD2z6X2.js → input-_2sjvfne.js} +1 -1
  10. package/dist/main.js +680 -705
  11. package/dist/{mermaid-IU93XzmY.js → mermaid-lXOw5Py9.js} +2 -2
  12. package/dist/{process-output-5qJjMRKh.js → process-output-BvySRgli.js} +33 -25
  13. package/dist/{reveal-component-v4zHgynl.js → reveal-component-DeBkkDcg.js} +312 -291
  14. package/dist/{spec-a6DaqW__.js → spec-B96zNUEA.js} +1 -1
  15. package/dist/style.css +1 -1
  16. package/dist/{toDate-ZVVIBmdk.js → toDate-x-WRDCH7.js} +1 -1
  17. package/dist/{useAsyncData-C008zUPi.js → useAsyncData-iRgKDT5s.js} +1 -1
  18. package/dist/{useDeepCompareMemoize-BrA3_n61.js → useDeepCompareMemoize-CkQ57VS2.js} +1 -1
  19. package/dist/{useLifecycle-BNaoJ5a4.js → useLifecycle-BBO9PIph.js} +1 -1
  20. package/dist/{useTheme-7O0YWlE5.js → useTheme-DHIrRQOe.js} +34 -21
  21. package/dist/{vega-component-DJNmOdUj.js → vega-component-Dq-SH463.js} +5 -5
  22. package/package.json +1 -1
  23. package/src/components/ai/__tests__/ai-utils.test.ts +43 -38
  24. package/src/components/ai/ai-model-dropdown.tsx +2 -2
  25. package/src/components/app-config/ai-config.tsx +147 -16
  26. package/src/components/app-config/user-config-form.tsx +37 -1
  27. package/src/components/chat/__tests__/chat-utils.test.ts +269 -0
  28. package/src/components/chat/chat-panel.tsx +38 -5
  29. package/src/components/chat/chat-utils.ts +14 -58
  30. package/src/components/data-table/TableBottomBar.tsx +5 -8
  31. package/src/components/data-table/__tests__/column-explorer.test.tsx +128 -0
  32. package/src/components/data-table/__tests__/header-items.test.tsx +220 -10
  33. package/src/components/data-table/column-explorer-panel/column-explorer.tsx +95 -29
  34. package/src/components/data-table/column-header.tsx +17 -12
  35. package/src/components/data-table/data-table.tsx +4 -0
  36. package/src/components/data-table/export-actions.tsx +19 -12
  37. package/src/components/data-table/header-items.tsx +40 -16
  38. package/src/components/data-table/hooks/use-column-visibility.ts +14 -0
  39. package/src/components/data-table/schemas.ts +2 -2
  40. package/src/components/data-table/table-explorer-panel/table-explorer-panel.tsx +16 -6
  41. package/src/components/databases/display.tsx +2 -0
  42. package/src/components/datasources/__tests__/utils.test.ts +82 -0
  43. package/src/components/datasources/utils.ts +16 -15
  44. package/src/components/editor/Disconnected.tsx +1 -60
  45. package/src/components/editor/__tests__/viewer-banner.test.tsx +89 -0
  46. package/src/components/editor/actions/pair-with-agent-modal.tsx +1 -0
  47. package/src/components/editor/actions/useCellActionButton.tsx +3 -3
  48. package/src/components/editor/actions/useNotebookActions.tsx +5 -2
  49. package/src/components/editor/cell/code/cell-editor.tsx +25 -5
  50. package/src/components/editor/chrome/types.ts +13 -6
  51. package/src/components/editor/chrome/wrapper/app-chrome.tsx +6 -4
  52. package/src/components/editor/chrome/wrapper/footer-items/ai-status.tsx +10 -1
  53. package/src/components/editor/chrome/wrapper/sidebar.tsx +7 -5
  54. package/src/components/editor/errors/auto-fix.tsx +3 -3
  55. package/src/components/editor/header/__tests__/status.test.tsx +0 -15
  56. package/src/components/editor/header/app-header.tsx +1 -4
  57. package/src/components/editor/header/status.tsx +4 -13
  58. package/src/components/editor/navigation/__tests__/navigation.test.ts +15 -0
  59. package/src/components/editor/navigation/navigation.ts +5 -0
  60. package/src/components/editor/output/MarimoErrorOutput.tsx +103 -25
  61. package/src/components/editor/output/MarimoTracebackOutput.tsx +28 -39
  62. package/src/components/editor/renderers/cell-array.tsx +27 -24
  63. package/src/components/editor/renderers/slides-layout/__tests__/compute-slide-cells.test.ts +30 -17
  64. package/src/components/editor/renderers/slides-layout/compute-slide-cells.ts +17 -8
  65. package/src/components/editor/renderers/slides-layout/slides-layout.tsx +10 -12
  66. package/src/components/editor/viewer-banner.tsx +82 -0
  67. package/src/components/slides/minimap.tsx +45 -9
  68. package/src/components/slides/reveal-component.tsx +82 -37
  69. package/src/components/slides/slide-cell-view.tsx +12 -1
  70. package/src/components/slides/slide-form.tsx +11 -3
  71. package/src/components/static-html/static-banner.tsx +28 -22
  72. package/src/core/ai/__tests__/model-registry.test.ts +72 -60
  73. package/src/core/ai/model-registry.ts +33 -28
  74. package/src/core/cells/__tests__/actions.test.ts +48 -0
  75. package/src/core/cells/actions.ts +5 -6
  76. package/src/core/codemirror/__tests__/setup.test.ts +29 -0
  77. package/src/core/codemirror/cells/traceback-decorations.ts +1 -1
  78. package/src/core/codemirror/cm.ts +50 -3
  79. package/src/core/codemirror/completion/hints.ts +4 -1
  80. package/src/core/codemirror/format.ts +1 -0
  81. package/src/core/codemirror/keymaps/vim.ts +63 -0
  82. package/src/core/codemirror/language/languages/sql/sql.ts +1 -0
  83. package/src/core/codemirror/language/languages/sql/utils.ts +2 -0
  84. package/src/core/config/__tests__/config-schema.test.ts +4 -0
  85. package/src/core/config/config-schema.ts +4 -0
  86. package/src/core/config/config.ts +16 -0
  87. package/src/core/edit-app.tsx +3 -0
  88. package/src/core/islands/bootstrap.ts +2 -0
  89. package/src/core/kernel/__tests__/handlers.test.ts +5 -0
  90. package/src/core/websocket/__tests__/useMarimoKernelConnection.test.ts +0 -13
  91. package/src/core/websocket/types.ts +0 -6
  92. package/src/core/websocket/useMarimoKernelConnection.tsx +3 -12
  93. package/src/css/app/Cell.css +0 -1
  94. package/src/plugins/impl/DataTablePlugin.tsx +48 -22
  95. package/src/plugins/impl/chat/ChatPlugin.tsx +7 -1
  96. package/src/plugins/impl/chat/__tests__/chat-ui.test.ts +278 -0
  97. package/src/plugins/impl/chat/chat-ui.tsx +106 -59
  98. package/src/plugins/impl/chat/types.ts +5 -0
  99. package/src/utils/__tests__/json-parser.test.ts +1 -69
  100. package/src/utils/json/json-parser.ts +0 -30
  101. package/dist/assets/__vite-browser-external-CAdMKBac.js +0 -1
@@ -5,17 +5,13 @@ import { useAtomValue } from "jotai";
5
5
  import {
6
6
  BugPlayIcon,
7
7
  ChevronDown,
8
+ ChevronRight,
8
9
  CopyIcon,
9
10
  ExternalLinkIcon,
10
11
  MessageCircleIcon,
11
12
  SearchIcon,
12
13
  } from "lucide-react";
13
14
  import { type JSX, useState } from "react";
14
- import {
15
- Accordion,
16
- AccordionContent,
17
- AccordionItem,
18
- } from "@/components/ui/accordion";
19
15
  import { Button } from "@/components/ui/button";
20
16
  import {
21
17
  DropdownMenu,
@@ -29,7 +25,7 @@ import { getCellEditorView } from "@/core/cells/cells";
29
25
  import type { CellId } from "@/core/cells/ids";
30
26
  import { SCRATCH_CELL_ID } from "@/core/cells/ids";
31
27
  import { insertDebuggerAtLine } from "@/core/codemirror/editing/debugging";
32
- import { aiEnabledAtom } from "@/core/config/config";
28
+ import { aiFeaturesEnabledAtom } from "@/core/config/config";
33
29
  import { getRequestClient } from "@/core/network/requests";
34
30
  import { isStaticNotebook } from "@/core/static/static-state";
35
31
  import { isWasm } from "@/core/wasm/utils";
@@ -45,7 +41,6 @@ import {
45
41
  extractAllTracebackInfo,
46
42
  getTracebackInfo,
47
43
  } from "@/utils/traceback";
48
- import { cn } from "../../../utils/cn";
49
44
  import { AIFixButton } from "../errors/auto-fix";
50
45
  import { MangledSegments } from "../errors/mangled-local-chip";
51
46
  import { CellLinkTraceback } from "../links/cell-link";
@@ -57,8 +52,6 @@ interface Props {
57
52
  onRefactorWithAI?: OnRefactorWithAI;
58
53
  }
59
54
 
60
- const KEY = "item";
61
-
62
55
  /**
63
56
  * List of errors due to violations of Marimo semantics.
64
57
  */
@@ -75,10 +68,9 @@ export const MarimoTracebackOutput = ({
75
68
  replaceMangledLocal,
76
69
  ],
77
70
  });
78
- const [expanded, setExpanded] = useState(true);
79
71
 
80
72
  const lastTracebackLine = lastLine(traceback);
81
- const aiEnabled = useAtomValue(aiEnabledAtom);
73
+ const aiFeaturesEnabled = useAtomValue(aiFeaturesEnabledAtom);
82
74
 
83
75
  // Get last traceback info
84
76
  const tracebackInfo = extractAllTracebackInfo(traceback)?.at(0);
@@ -91,10 +83,13 @@ export const MarimoTracebackOutput = ({
91
83
  !isStaticNotebook() &&
92
84
  cellId !== SCRATCH_CELL_ID;
93
85
 
94
- const showAIFix = onRefactorWithAI && aiEnabled && !isStaticNotebook();
86
+ const showAIFix =
87
+ onRefactorWithAI && aiFeaturesEnabled && !isStaticNotebook();
95
88
 
96
89
  const showSearch = !isStaticNotebook();
97
90
 
91
+ const [isOpen, setIsOpen] = useState(true);
92
+
98
93
  const handleRefactorWithAI = (triggerImmediately: boolean) => {
99
94
  onRefactorWithAI?.({
100
95
  prompt: `My code gives the following error:\n\n${lastTracebackLine}`,
@@ -102,35 +97,29 @@ export const MarimoTracebackOutput = ({
102
97
  });
103
98
  };
104
99
 
105
- const [error, errorMessage] = lastTracebackLine.split(":", 2);
106
- const errorMessageSegments = errorMessage
107
- ? splitMangledLocals(errorMessage)
108
- : [];
109
-
110
100
  return (
111
101
  <div className="flex flex-col gap-2 min-w-full w-fit">
112
- <Accordion type="single" collapsible={true} value={expanded ? KEY : ""}>
113
- <AccordionItem value={KEY} className="border-none">
114
- <div
115
- className="flex gap-2 h-10 px-2 hover:bg-muted rounded-sm select-none items-center cursor-pointer transition-all"
116
- onClick={() => setExpanded((prev) => !prev)}
117
- >
118
- <ChevronDown
119
- className={cn(
120
- "h-4 w-4 text-muted-foreground transition-transform duration-200 shrink-0",
121
- expanded ? "rotate-180" : "rotate-0",
122
- )}
123
- />
124
- <div className="text-sm inline font-mono">
125
- <span className="text-destructive">{error || "Error"}:</span>{" "}
126
- <MangledSegments segments={errorMessageSegments} />
127
- </div>
128
- </div>
129
- <AccordionContent className="text-muted-foreground px-4 pt-2 text-xs overflow-auto">
130
- {htmlTraceback}
131
- </AccordionContent>
132
- </AccordionItem>
133
- </Accordion>
102
+ <button
103
+ type="button"
104
+ onClick={() => setIsOpen(!isOpen)}
105
+ aria-expanded={isOpen}
106
+ aria-label={isOpen ? "Collapse traceback" : "Expand traceback"}
107
+ className="self-start flex items-center gap-1 pt-2 text-muted-foreground/70 hover:text-muted-foreground transition-colors"
108
+ >
109
+ {isOpen ? (
110
+ <ChevronDown className="h-3 w-3" />
111
+ ) : (
112
+ <ChevronRight className="h-3 w-3" />
113
+ )}
114
+ <span className="text-[0.6875rem] uppercase tracking-wider">
115
+ Traceback
116
+ </span>
117
+ </button>
118
+ {isOpen && (
119
+ <div className="text-muted-foreground pr-4 text-xs overflow-auto">
120
+ {htmlTraceback}
121
+ </div>
122
+ )}
134
123
  <div className="flex gap-2">
135
124
  {showAIFix && (
136
125
  <AIFixButton
@@ -24,7 +24,7 @@ import { maybeAddMarimoImport } from "@/core/cells/add-missing-import";
24
24
  import { SETUP_CELL_ID } from "@/core/cells/ids";
25
25
  import { LanguageAdapters } from "@/core/codemirror/language/LanguageAdapters";
26
26
  import { MARKDOWN_INITIAL_HIDE_CODE } from "@/core/codemirror/language/languages/markdown";
27
- import { aiEnabledAtom } from "@/core/config/config";
27
+ import { aiEnabledAtom, aiFeaturesEnabledAtom } from "@/core/config/config";
28
28
  import { canInteractWithAppAtom } from "@/core/network/connection";
29
29
  import { useBoolean } from "@/hooks/useBoolean";
30
30
  import { cn } from "@/utils/cn";
@@ -261,6 +261,7 @@ const AddCellButtons: React.FC<{
261
261
  const { createNewCell } = useCellActions();
262
262
  const [isAiButtonOpen, isAiButtonOpenActions] = useBoolean(false);
263
263
  const aiEnabled = useAtomValue(aiEnabledAtom);
264
+ const aiFeaturesEnabled = useAtomValue(aiFeaturesEnabledAtom);
264
265
  const canInteractWithApp = useAtomValue(canInteractWithAppAtom);
265
266
  const { handleClick } = useOpenSettingsToTab();
266
267
 
@@ -270,7 +271,7 @@ const AddCellButtons: React.FC<{
270
271
  );
271
272
 
272
273
  const renderBody = () => {
273
- if (isAiButtonOpen) {
274
+ if (aiEnabled && isAiButtonOpen) {
274
275
  return <AddCellWithAI onClose={isAiButtonOpenActions.toggle} />;
275
276
  }
276
277
 
@@ -328,30 +329,32 @@ const AddCellButtons: React.FC<{
328
329
  <DatabaseIcon className="mr-2 size-4 shrink-0" />
329
330
  SQL
330
331
  </Button>
331
- <Tooltip
332
- content={
333
- aiEnabled ? null : (
334
- <span>AI provider not found or Edit model not selected</span>
335
- )
336
- }
337
- delayDuration={100}
338
- asChild={false}
339
- >
340
- <Button
341
- className={buttonClass}
342
- variant="text"
343
- size="sm"
344
- disabled={!canInteractWithApp}
345
- onClick={
346
- aiEnabled
347
- ? isAiButtonOpenActions.toggle
348
- : () => handleClick("ai", "ai-providers")
332
+ {aiEnabled && (
333
+ <Tooltip
334
+ content={
335
+ aiFeaturesEnabled ? null : (
336
+ <span>AI provider not found or Edit model not selected</span>
337
+ )
349
338
  }
339
+ delayDuration={100}
340
+ asChild={false}
350
341
  >
351
- <SparklesIcon className="mr-2 size-4 shrink-0" />
352
- Generate with AI
353
- </Button>
354
- </Tooltip>
342
+ <Button
343
+ className={buttonClass}
344
+ variant="text"
345
+ size="sm"
346
+ disabled={!canInteractWithApp}
347
+ onClick={
348
+ aiFeaturesEnabled
349
+ ? isAiButtonOpenActions.toggle
350
+ : () => handleClick("ai", "ai-providers")
351
+ }
352
+ >
353
+ <SparklesIcon className="mr-2 size-4 shrink-0" />
354
+ Generate with AI
355
+ </Button>
356
+ </Tooltip>
357
+ )}
355
358
  </>
356
359
  );
357
360
  };
@@ -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.cellsWithOutput).toEqual([]);
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("filters out cells with no output", () => {
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.cellsWithOutput.map((c) => c.id)).toEqual(["a", "c"]);
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("filters out cells whose output data is empty string", () => {
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.cellsWithOutput.map((c) => c.id)).toEqual(["a", "c"]);
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.cellsWithOutput.map((c) => c.id)).toEqual(["a", "b", "c"]);
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.cellsWithOutput.map((c) => c.id)).toEqual(["a", "b", "c"]);
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("ignores layout entries for cells that have no output", () => {
129
- // If a cell was skipped in the layout but no longer produces output (e.g.
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.cellsWithOutput.map((c) => c.id)).toEqual(["a"]);
140
- expect(result.skippedIds.size).toBe(0);
141
- expect(result.slideTypes.has(cellId("b"))).toBe(false);
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 cellsWithOutput", () => {
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.cellsWithOutput.map((c) => c.id)).toEqual(["c", "a", "b"]);
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
- cellsWithOutput: T[];
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 `cellsWithOutput` that is not skipped
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 cellsWithOutput = cells.filter(
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 cellsWithOutput.entries()) {
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 (type === "skip") {
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
- cellsWithOutput,
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 { cellsWithOutput, skippedIds, slideTypes, startCellIndex } = useMemo(
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
- ? cellsWithOutput.findIndex((c) => c.id === activeCellId)
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 = cellsWithOutput[index];
43
+ const cell = slideCells[index];
46
44
  if (cell) {
47
45
  setActiveCellId(cell.id);
48
46
  }
@@ -50,12 +48,13 @@ export const SlidesLayoutRenderer: React.FC<Props> = ({
50
48
 
51
49
  const slides = (
52
50
  <LazySlidesComponent
53
- cellsWithOutput={cellsWithOutput}
51
+ slideCells={slideCells}
54
52
  layout={layout}
55
53
  setLayout={setLayout}
54
+ noOutputIds={noOutputIds}
56
55
  activeIndex={resolvedIndex}
57
56
  onSlideChange={handleSlideChange}
58
- configWidth={300}
57
+ configWidth={280}
59
58
  mode={isReading ? "read" : mode}
60
59
  isEditable={!isReading}
61
60
  />
@@ -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={cellsWithOutput}
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
+ };