@marimo-team/islands 0.23.15-dev32 → 0.23.15-dev4

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 (84) hide show
  1. package/dist/{ConnectedDataExplorerComponent-7p7rt9iw.js → ConnectedDataExplorerComponent-CU4fZJzG.js} +4 -4
  2. package/dist/{ErrorBoundary-B_CAG7_e.js → ErrorBoundary-DE6tzZf-.js} +1 -1
  3. package/dist/{ImageComparisonComponent-1i5IBhon.js → ImageComparisonComponent-CHrI72em.js} +129 -173
  4. package/dist/assets/__vite-browser-external-BQCLNwri.js +1 -0
  5. package/dist/assets/worker-DAWRHcPq.js +73 -0
  6. package/dist/{chat-ui-C0wkSwxB.js → chat-ui-DinOvbWu.js} +3111 -3111
  7. package/dist/{code-visibility-CEHWVGz1.js → code-visibility-Dk8cVOny.js} +864 -946
  8. package/dist/{debounce-BOD3DbfP.js → constants-T20xxyNf.js} +24 -1
  9. package/dist/{formats-BX3uDQbB.js → formats-Dzx4J_z1.js} +1 -1
  10. package/dist/{glide-data-editor-CwZz71BD.js → glide-data-editor-CjTu7ukN.js} +3 -3
  11. package/dist/{html-to-image-D8Q5SLSJ.js → html-to-image-_wGfk8V-.js} +2241 -2277
  12. package/dist/{input-BGPrFH3g.js → input-DtsN7xm-.js} +2 -2
  13. package/dist/main.js +1201 -1297
  14. package/dist/{mermaid-UdmxG2PZ.js → mermaid-BYqXy_NE.js} +2 -2
  15. package/dist/{process-output-C_A12w9J.js → process-output-Mh4UrjwM.js} +1 -1
  16. package/dist/{reveal-component-kLDhMoa2.js → reveal-component-B5DXLyO7.js} +605 -618
  17. package/dist/{spec-DSs9v0xx.js → spec-Cz-Bj1JI.js} +1 -1
  18. package/dist/style.css +1 -1
  19. package/dist/{toDate-CKpRx4TS.js → toDate-CWNNlFEX.js} +4 -3
  20. package/dist/{useAsyncData-BSOyAbac.js → useAsyncData-KfHB8wQR.js} +1 -1
  21. package/dist/{useDeepCompareMemoize-BTLeWzuR.js → useDeepCompareMemoize-nJMtxhm4.js} +1 -1
  22. package/dist/{useLifecycle-C6wHjkhW.js → useLifecycle-DegSo0lV.js} +1 -1
  23. package/dist/{useTheme-Df_vGflw.js → useTheme-6eZ3GOTS.js} +27 -62
  24. package/dist/{vega-component-DNHEV0u0.js → vega-component-DzyyM9fc.js} +6 -6
  25. package/package.json +1 -1
  26. package/src/components/chat/__tests__/chat-utils.test.ts +1 -244
  27. package/src/components/chat/chat-panel.tsx +67 -196
  28. package/src/components/chat/chat-utils.ts +2 -111
  29. package/src/components/editor/SortableCell.tsx +2 -6
  30. package/src/components/editor/actions/pair-with-agent-modal.tsx +64 -20
  31. package/src/components/editor/ai/add-cell-with-ai.tsx +5 -14
  32. package/src/components/editor/ai/ai-completion-editor.tsx +1 -4
  33. package/src/components/editor/cell/cell-context-menu.tsx +0 -7
  34. package/src/components/editor/chrome/panels/packages-panel.tsx +1 -11
  35. package/src/components/editor/columns/cell-column.tsx +4 -34
  36. package/src/components/editor/columns/sortable-column.tsx +4 -24
  37. package/src/components/editor/navigation/__tests__/navigation.test.ts +0 -33
  38. package/src/components/editor/navigation/navigation.ts +1 -8
  39. package/src/components/editor/notebook-cell.tsx +106 -203
  40. package/src/components/editor/renderers/cell-array.tsx +13 -26
  41. package/src/components/editor/renderers/cells-renderer.tsx +2 -8
  42. package/src/components/editor/renderers/slides-layout/__tests__/plugin.test.ts +0 -29
  43. package/src/components/editor/renderers/slides-layout/types.ts +0 -4
  44. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +19 -19
  45. package/src/components/slides/reveal-component.tsx +4 -37
  46. package/src/components/slides/slide-form.tsx +0 -72
  47. package/src/core/cells/__tests__/utils.test.ts +0 -59
  48. package/src/core/cells/utils.ts +0 -51
  49. package/src/core/codemirror/completion/__tests__/signature-hint.test.ts +3 -97
  50. package/src/core/codemirror/completion/signature-hint.ts +11 -78
  51. package/src/core/constants.ts +0 -6
  52. package/src/core/islands/__tests__/bridge.test.ts +46 -341
  53. package/src/core/islands/__tests__/parse.test.ts +0 -105
  54. package/src/core/islands/bootstrap.ts +3 -8
  55. package/src/core/islands/bridge.ts +23 -116
  56. package/src/core/islands/components/web-components.tsx +15 -76
  57. package/src/core/islands/constants.ts +0 -1
  58. package/src/core/islands/main.ts +3 -35
  59. package/src/core/islands/parse.ts +23 -70
  60. package/src/core/islands/worker/worker.tsx +57 -145
  61. package/src/core/wasm/worker/bootstrap.ts +20 -113
  62. package/src/css/app/Cell.css +0 -10
  63. package/src/hooks/useHotkey.ts +4 -29
  64. package/src/plugins/impl/anywidget/__tests__/host.test.ts +9 -6
  65. package/src/plugins/impl/anywidget/__tests__/widget-binding.test.ts +61 -22
  66. package/src/plugins/impl/anywidget/model-proxy.ts +13 -0
  67. package/src/plugins/impl/anywidget/widget-binding.ts +34 -4
  68. package/src/plugins/impl/image-comparison/ImageComparisonComponent.tsx +2 -53
  69. package/src/plugins/impl/matplotlib/__tests__/matplotlib-renderer.test.ts +3 -71
  70. package/src/plugins/impl/matplotlib/matplotlib-renderer.ts +0 -1
  71. package/src/theme/useTheme.ts +1 -16
  72. package/dist/assets/__vite-browser-external-CjNAy01L.js +0 -1
  73. package/dist/assets/worker-B3XPCb6y.js +0 -98
  74. package/src/components/chat/__tests__/message-queue.test.tsx +0 -121
  75. package/src/components/editor/__tests__/output-persistence.test.tsx +0 -241
  76. package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +0 -153
  77. package/src/components/editor/actions/pair-with-agent-commands.ts +0 -109
  78. package/src/components/editor/columns/__tests__/cell-column.test.tsx +0 -105
  79. package/src/components/editor/renderers/__tests__/cells-renderer.test.tsx +0 -66
  80. package/src/core/islands/components/__tests__/web-components.test.tsx +0 -214
  81. package/src/core/islands/worker/__tests__/controller.test.ts +0 -173
  82. package/src/hooks/__tests__/useHotkey.test.tsx +0 -88
  83. package/src/plugins/impl/image-comparison/__tests__/ImageComparisonComponent.test.tsx +0 -71
  84. package/src/theme/__tests__/useTheme.test.ts +0 -68
@@ -1,241 +0,0 @@
1
- /* Copyright 2026 Marimo. All rights reserved. */
2
- import { render } from "@testing-library/react";
3
- import { createStore, Provider } from "jotai";
4
- import { beforeAll, describe, expect, it } from "vitest";
5
- import { SetupMocks } from "@/__mocks__/common";
6
- import { MockNotebook } from "@/__mocks__/notebook";
7
- import { MockRequestClient } from "@/__mocks__/requests";
8
- import { cellId } from "@/__tests__/branded";
9
- import { TooltipProvider } from "@/components/ui/tooltip";
10
- import { notebookAtom } from "@/core/cells/cells";
11
- import type { CellRuntimeState } from "@/core/cells/types";
12
- import { createCellRuntimeState } from "@/core/cells/types";
13
- import { defaultUserConfig } from "@/core/config/config-schema";
14
- import type { AppMode } from "@/core/mode";
15
- import { requestClientAtom } from "@/core/network/requests";
16
- import { Cell } from "../notebook-cell";
17
-
18
- const cid = cellId("test");
19
-
20
- function createTestWrapper() {
21
- const store = createStore();
22
- store.set(requestClientAtom, MockRequestClient.create());
23
- const wrapper = ({ children }: { children: React.ReactNode }) => (
24
- <Provider store={store}>{children}</Provider>
25
- );
26
- return { wrapper, store };
27
- }
28
-
29
- function seedNotebook(
30
- store: ReturnType<typeof createStore>,
31
- runtimeOverrides: Partial<CellRuntimeState> = {},
32
- ) {
33
- const notebook = MockNotebook.notebookState({
34
- cellData: {
35
- [cid]: {
36
- code: "1 + 1",
37
- name: "test_cell",
38
- edited: false,
39
- serializedEditorState: null,
40
- config: {
41
- disabled: false,
42
- hide_code: false,
43
- column: null,
44
- },
45
- },
46
- },
47
- });
48
- notebook.cellRuntime[cid] = createCellRuntimeState({
49
- status: "idle",
50
- output: {
51
- channel: "output",
52
- mimetype: "text/html",
53
- data: "<span>persist me</span>",
54
- timestamp: 0,
55
- },
56
- ...runtimeOverrides,
57
- });
58
- store.set(notebookAtom, notebook);
59
- }
60
-
61
- function renderCell(mode: AppMode) {
62
- return (
63
- <TooltipProvider>
64
- <Cell
65
- cellId={cid}
66
- mode={mode}
67
- canDelete={true}
68
- userConfig={defaultUserConfig()}
69
- isCollapsed={false}
70
- collapseCount={0}
71
- canMoveX={false}
72
- theme="light"
73
- showPlaceholder={false}
74
- />
75
- </TooltipProvider>
76
- );
77
- }
78
-
79
- beforeAll(() => {
80
- SetupMocks.resizeObserver();
81
- global.HTMLDivElement.prototype.scrollIntoView = () => {
82
- // do nothing
83
- };
84
- });
85
-
86
- describe("output persistence across mode changes", () => {
87
- it("preserves the output DOM node when toggling edit <-> present", () => {
88
- const { store, wrapper } = createTestWrapper();
89
- seedNotebook(store);
90
-
91
- const { container, rerender } = render(renderCell("edit"), { wrapper });
92
-
93
- const outputNode = container.querySelector<HTMLElement>(
94
- '[data-cell-role="output"]',
95
- );
96
- expect(outputNode).toBeTruthy();
97
- // A property survives only if the exact DOM node instance survives.
98
- (outputNode as HTMLElement & { __sentinel?: string }).__sentinel = "alive";
99
-
100
- rerender(renderCell("present"));
101
- const presentNode = container.querySelector<HTMLElement>(
102
- '[data-cell-role="output"]',
103
- );
104
- expect(presentNode).toBe(outputNode);
105
- expect(presentNode?.isConnected).toBe(true);
106
- expect(
107
- (presentNode as HTMLElement & { __sentinel?: string }).__sentinel,
108
- ).toBe("alive");
109
-
110
- // Edit chrome is hidden but stays mounted while presenting
111
- const tray = container.querySelector<HTMLElement>(
112
- "[data-testid='cell-tray']",
113
- );
114
- expect(tray).toBeTruthy();
115
- expect(tray?.hidden).toBe(true);
116
- // Present styling is applied
117
- expect(
118
- container
119
- .querySelector(`[data-cell-id="${cid}"]`)
120
- ?.classList.contains("published"),
121
- ).toBe(true);
122
-
123
- rerender(renderCell("edit"));
124
- expect(container.querySelector('[data-cell-role="output"]')).toBe(
125
- outputNode,
126
- );
127
- expect(
128
- container.querySelector<HTMLElement>("[data-testid='cell-tray']")?.hidden,
129
- ).toBe(false);
130
- expect(
131
- container
132
- .querySelector(`[data-cell-id="${cid}"]`)
133
- ?.classList.contains("published"),
134
- ).toBe(false);
135
- });
136
-
137
- it("hides all edit chrome while presenting", () => {
138
- const { store, wrapper } = createTestWrapper();
139
- seedNotebook(store);
140
-
141
- const { container, rerender } = render(renderCell("edit"), { wrapper });
142
-
143
- // Returns true when the element is not visible: either gone from the DOM or
144
- // inside a `hidden` ancestor. Edit chrome may unmount while presenting (only
145
- // the cell *output* is contractually kept mounted — see the DOM-node test
146
- // above); either way it must not be visible.
147
- const isHidden = (testId: string) => {
148
- const el = container.querySelector(`[data-testid='${testId}']`);
149
- return el === null || el.closest("[hidden]") !== null;
150
- };
151
-
152
- // Everything visible in edit mode
153
- const editChrome = [
154
- "cell-tray",
155
- "drag-button",
156
- "cell-actions-button",
157
- "delete-button",
158
- "create-cell-button",
159
- "console-output-area",
160
- ];
161
- for (const testId of editChrome) {
162
- expect({ testId, hidden: isHidden(testId) }).toEqual({
163
- testId,
164
- hidden: false,
165
- });
166
- }
167
-
168
- rerender(renderCell("present"));
169
- for (const testId of editChrome) {
170
- expect({ testId, hidden: isHidden(testId) }).toEqual({
171
- testId,
172
- hidden: true,
173
- });
174
- }
175
-
176
- rerender(renderCell("edit"));
177
- for (const testId of editChrome) {
178
- expect({ testId, hidden: isHidden(testId) }).toEqual({
179
- testId,
180
- hidden: false,
181
- });
182
- }
183
- });
184
-
185
- it("does not dim edited-but-not-run outputs as stale while presenting", () => {
186
- const { store, wrapper } = createTestWrapper();
187
- seedNotebook(store);
188
- // Mark the cell as edited without re-running it
189
- const notebook = store.get(notebookAtom);
190
- notebook.cellData[cid] = { ...notebook.cellData[cid], edited: true };
191
- store.set(notebookAtom, { ...notebook });
192
-
193
- const { container, rerender } = render(renderCell("edit"), { wrapper });
194
- expect(container.querySelector(".marimo-output-stale")).toBeTruthy();
195
-
196
- // The read view never dims pending edits; present mode matches it
197
- rerender(renderCell("present"));
198
- expect(container.querySelector(".marimo-output-stale")).toBeFalsy();
199
-
200
- rerender(renderCell("edit"));
201
- expect(container.querySelector(".marimo-output-stale")).toBeTruthy();
202
- });
203
-
204
- it("hides errored cells while presenting without unmounting them", () => {
205
- const { store, wrapper } = createTestWrapper();
206
- seedNotebook(store, {
207
- errored: true,
208
- output: {
209
- channel: "marimo-error",
210
- mimetype: "application/vnd.marimo+error",
211
- data: [{ type: "exception", exception_type: "ValueError", msg: "!" }],
212
- timestamp: 0,
213
- },
214
- });
215
-
216
- const { container, rerender } = render(renderCell("edit"), { wrapper });
217
-
218
- const outputNode = container.querySelector<HTMLElement>(
219
- '[data-cell-role="output"]',
220
- );
221
- expect(outputNode).toBeTruthy();
222
-
223
- const getSortableWrapper = () =>
224
- container.querySelector<HTMLElement>(`[data-cell-id="${cid}"]`)
225
- ?.parentElement;
226
- expect(getSortableWrapper()?.hidden).toBe(false);
227
-
228
- rerender(renderCell("present"));
229
- // Still mounted, but hidden
230
- expect(container.querySelector('[data-cell-role="output"]')).toBe(
231
- outputNode,
232
- );
233
- expect(getSortableWrapper()?.hidden).toBe(true);
234
-
235
- rerender(renderCell("edit"));
236
- expect(container.querySelector('[data-cell-role="output"]')).toBe(
237
- outputNode,
238
- );
239
- expect(getSortableWrapper()?.hidden).toBe(false);
240
- });
241
- });
@@ -1,153 +0,0 @@
1
- /* Copyright 2026 Marimo. All rights reserved. */
2
-
3
- import { afterEach, describe, expect, it, vi } from "vitest";
4
- import {
5
- type ConnectionInfo,
6
- getMarimoCommand,
7
- getRawPrompt,
8
- getTerminalCommand,
9
- maskToken,
10
- shellQuote,
11
- } from "../pair-with-agent-commands";
12
-
13
- const CONNECTION: ConnectionInfo = {
14
- url: "http://localhost:8000",
15
- sessionId: "s_ab12cd",
16
- };
17
-
18
- describe("shellQuote", () => {
19
- it("quotes an empty string", () => {
20
- expect(shellQuote("")).toBe("''");
21
- });
22
-
23
- it("leaves shell-safe values untouched", () => {
24
- expect(shellQuote("http://localhost:8000")).toBe("http://localhost:8000");
25
- expect(shellQuote("s_ab12cd")).toBe("s_ab12cd");
26
- });
27
-
28
- it("quotes values with shell metacharacters", () => {
29
- expect(shellQuote("http://host:8000?a=1&b=2")).toBe(
30
- "'http://host:8000?a=1&b=2'",
31
- );
32
- expect(shellQuote("has space")).toBe("'has space'");
33
- expect(shellQuote("$(rm -rf /)")).toBe("'$(rm -rf /)'");
34
- });
35
-
36
- it("escapes embedded single quotes without breaking out", () => {
37
- // Closes the quote, emits a literal ' via "'", then reopens: '"'"'
38
- expect(shellQuote("a'b")).toBe(`'a'"'"'b'`);
39
- });
40
- });
41
-
42
- describe("getMarimoCommand", () => {
43
- afterEach(() => {
44
- vi.unstubAllEnvs();
45
- });
46
-
47
- it("uses the local checkout in dev", () => {
48
- vi.stubEnv("DEV", true);
49
- expect(getMarimoCommand()).toBe("uv run marimo");
50
- });
51
-
52
- it("uses uvx outside of dev", () => {
53
- vi.stubEnv("DEV", false);
54
- expect(getMarimoCommand()).toBe("uvx marimo@latest");
55
- });
56
- });
57
-
58
- describe("getTerminalCommand", () => {
59
- it("includes the url and session for each agent", () => {
60
- expect(getTerminalCommand("claude", CONNECTION, false)).toBe(
61
- `claude "$(uv run marimo pair prompt --url http://localhost:8000 --session s_ab12cd --claude)"`,
62
- );
63
- expect(getTerminalCommand("codex", CONNECTION, false)).toBe(
64
- `codex "$(uv run marimo pair prompt --url http://localhost:8000 --session s_ab12cd --codex)"`,
65
- );
66
- expect(getTerminalCommand("opencode", CONNECTION, false)).toBe(
67
- `opencode --prompt "$(uv run marimo pair prompt --url http://localhost:8000 --session s_ab12cd --opencode)"`,
68
- );
69
- });
70
-
71
- it("always targets the given session, not a random one", () => {
72
- const command = getTerminalCommand("claude", CONNECTION, false);
73
- expect(command).toContain("--session s_ab12cd");
74
- });
75
-
76
- it("shell-escapes a url containing metacharacters", () => {
77
- const command = getTerminalCommand(
78
- "claude",
79
- { url: "http://host:8000?file=a&b", sessionId: "s_ab12cd" },
80
- false,
81
- );
82
- expect(command).toContain("--url 'http://host:8000?file=a&b'");
83
- });
84
-
85
- it("adds --with-token before the agent flag when requested", () => {
86
- const command = getTerminalCommand("claude", CONNECTION, true);
87
- expect(command).toContain("--with-token --claude");
88
- });
89
-
90
- it("omits --with-token when not requested", () => {
91
- expect(getTerminalCommand("claude", CONNECTION, false)).not.toContain(
92
- "--with-token",
93
- );
94
- });
95
- });
96
-
97
- describe("getRawPrompt", () => {
98
- it("references the session-scoped execute-code command", () => {
99
- const prompt = getRawPrompt(CONNECTION, null);
100
- expect(prompt).toContain(
101
- "execute-code.sh --url http://localhost:8000 --session s_ab12cd",
102
- );
103
- expect(prompt).toContain(
104
- "Connect to the notebook at: http://localhost:8000 (session s_ab12cd)",
105
- );
106
- });
107
-
108
- it("omits the token hint when there is no token", () => {
109
- const prompt = getRawPrompt(CONNECTION, null);
110
- expect(prompt).not.toContain("--token");
111
- expect(prompt).not.toContain("auth token");
112
- });
113
-
114
- it("includes a session-scoped token hint when a token is present", () => {
115
- const prompt = getRawPrompt(CONNECTION, "secret-token");
116
- expect(prompt).toContain(
117
- "execute-code.sh --url http://localhost:8000 --session s_ab12cd --token secret-token",
118
- );
119
- });
120
-
121
- it("shell-escapes a token containing a single quote", () => {
122
- const prompt = getRawPrompt(CONNECTION, "tok'en");
123
- expect(prompt).toContain(`--token 'tok'"'"'en'`);
124
- });
125
-
126
- it("matches the CLI prompt shape", () => {
127
- const prompt = getRawPrompt(CONNECTION, null);
128
- expect(prompt).toMatchInlineSnapshot(`
129
- "Use the /marimo-pair skill to pair-program on a running marimo notebook.
130
-
131
- Connect to the notebook at: http://localhost:8000 (session s_ab12cd)
132
-
133
- Use \`execute-code.sh --url http://localhost:8000 --session s_ab12cd\` from the marimo-pair skill to execute code in the notebook.
134
-
135
- Once you are connected, send a fun toast (mo.status.toast(...)) to the user inside marimo letting them know you're ready to pair."
136
- `);
137
- });
138
- });
139
-
140
- describe("maskToken", () => {
141
- it("masks short tokens entirely", () => {
142
- expect(maskToken("ab")).toBe("****");
143
- expect(maskToken("abcd")).toBe("****");
144
- });
145
-
146
- it("reveals only the last four characters", () => {
147
- expect(maskToken("abcdefgh")).toBe("****efgh");
148
- });
149
-
150
- it("caps the number of mask characters at eight", () => {
151
- expect(maskToken("0123456789abcdef")).toBe("********cdef");
152
- });
153
- });
@@ -1,109 +0,0 @@
1
- /* Copyright 2026 Marimo. All rights reserved. */
2
-
3
- import { assertNever } from "@/utils/assertNever";
4
-
5
- export type AgentTab = "claude" | "codex" | "opencode" | "prompt";
6
-
7
- export const TERMINAL_TABS = ["claude", "codex", "opencode"] as const;
8
-
9
- export const AGENT_TABS = ["claude", "codex", "opencode", "prompt"] as const;
10
-
11
- export const AGENT_LABELS: Record<AgentTab, string> = {
12
- claude: "Claude",
13
- codex: "Codex",
14
- opencode: "OpenCode",
15
- prompt: "Prompt",
16
- };
17
-
18
- export const SKILL_INSTALL = "npx skills add marimo-team/marimo-pair";
19
-
20
- /** How to invoke marimo: from the local checkout in dev, else via uvx. */
21
- export function getMarimoCommand(): string {
22
- return import.meta.env.DEV ? "uv run marimo" : "uvx marimo@latest";
23
- }
24
-
25
- /**
26
- * POSIX-quote a value for safe embedding in a shell command. These commands are
27
- * meant to be copied into a terminal, so a url/token containing shell
28
- * metacharacters (`'`, `&`, `$(...)`, ...) must not break out of its argument.
29
- *
30
- * Mirrors Python's `shlex.quote` (used on the CLI side in
31
- * `marimo/_cli/pair/commands.py`) so both sides produce identical commands:
32
- * values that are already shell-safe are left as-is for readability, and
33
- * anything else is single-quoted with embedded quotes escaped as `'"'"'`.
34
- */
35
- export function shellQuote(value: string): string {
36
- if (value === "") {
37
- return "''";
38
- }
39
- // Same "safe" character set as CPython's shlex.quote (ASCII \w plus a few).
40
- if (/^[\w@%+=:,./-]+$/.test(value)) {
41
- return value;
42
- }
43
- return `'${value.replaceAll("'", `'"'"'`)}'`;
44
- }
45
-
46
- /** Identifies the specific running notebook to pair on. */
47
- export interface ConnectionInfo {
48
- url: string;
49
- /**
50
- * The current session id, so agents connect to *this* notebook rather than
51
- * guessing when multiple sessions are open on the same server.
52
- */
53
- sessionId: string;
54
- }
55
-
56
- /**
57
- * The shell command that wraps an agent CLI, delegating prompt generation to
58
- * `marimo pair prompt` so the terminal and CLI stay in sync.
59
- */
60
- export function getTerminalCommand(
61
- agent: Exclude<AgentTab, "prompt">,
62
- { url, sessionId }: ConnectionInfo,
63
- withToken: boolean,
64
- ): string {
65
- const tokenFlag = withToken ? " --with-token" : "";
66
- const base = `${getMarimoCommand()} pair prompt --url ${shellQuote(url)} --session ${shellQuote(sessionId)}${tokenFlag}`;
67
- switch (agent) {
68
- case "claude":
69
- return `claude "$(${base} --claude)"`;
70
- case "codex":
71
- return `codex "$(${base} --codex)"`;
72
- case "opencode":
73
- return `opencode --prompt "$(${base} --opencode)"`;
74
- default:
75
- assertNever(agent);
76
- }
77
- }
78
-
79
- /**
80
- * The raw prompt for the "Prompt" tab. Mirrors the output of
81
- * `marimo pair prompt` (see `marimo/_cli/pair/commands.py`) so pasting it into
82
- * an agent behaves the same as the terminal commands.
83
- */
84
- export function getRawPrompt(
85
- { url, sessionId }: ConnectionInfo,
86
- token: string | null,
87
- ): string {
88
- const executeCmd = `execute-code.sh --url ${shellQuote(url)} --session ${shellQuote(sessionId)}`;
89
- const tokenHint = token
90
- ? `\n\nUse this auth token when calling \`execute-code.sh\`: \`${executeCmd} --token ${shellQuote(token)}\`.`
91
- : "";
92
- return [
93
- "Use the /marimo-pair skill to pair-program on a running marimo notebook.",
94
- "",
95
- `Connect to the notebook at: ${url} (session ${sessionId})`,
96
- "",
97
- `Use \`${executeCmd}\` from the marimo-pair skill to execute code in the notebook.${tokenHint}`,
98
- "",
99
- "Once you are connected, send a fun toast (mo.status.toast(...)) to the user inside marimo letting them know you're ready to pair.",
100
- ].join("\n");
101
- }
102
-
103
- /** Mask all but the last 4 chars of a token for display. */
104
- export function maskToken(token: string): string {
105
- if (token.length <= 4) {
106
- return "****";
107
- }
108
- return `${"*".repeat(Math.min(token.length - 4, 8))}${token.slice(-4)}`;
109
- }
@@ -1,105 +0,0 @@
1
- /* Copyright 2026 Marimo. All rights reserved. */
2
- import { render } from "@testing-library/react";
3
- import { createStore, Provider } from "jotai";
4
- import { describe, expect, it } from "vitest";
5
- import { TooltipProvider } from "@/components/ui/tooltip";
6
- import type { CellColumnId } from "@/utils/id-tree";
7
- import { Column } from "../cell-column";
8
-
9
- const columnId = "col-1" as CellColumnId;
10
-
11
- function renderColumn({
12
- width,
13
- presenting,
14
- }: {
15
- width: "compact" | "columns";
16
- presenting: boolean;
17
- }) {
18
- const store = createStore();
19
- return render(
20
- <Provider store={store}>
21
- <TooltipProvider>
22
- <Column
23
- columnId={columnId}
24
- index={0}
25
- width={width}
26
- canDelete={false}
27
- canMoveLeft={false}
28
- canMoveRight={false}
29
- presenting={presenting}
30
- >
31
- <div data-testid="column-children" />
32
- </Column>
33
- </TooltipProvider>
34
- </Provider>,
35
- );
36
- }
37
-
38
- describe("Column (single-column notebook)", () => {
39
- it("spaces cells with the --notebook-cell-gap variable", () => {
40
- const { getByTestId } = renderColumn({
41
- width: "compact",
42
- presenting: false,
43
- });
44
- const column = getByTestId("cell-column");
45
- expect(column.classList.contains("gap-(--notebook-cell-gap)")).toBe(true);
46
- expect(column.classList.contains("[--notebook-cell-gap:0px]")).toBe(false);
47
- });
48
-
49
- it("zeroes the cell gap while presenting", () => {
50
- const { getByTestId } = renderColumn({
51
- width: "compact",
52
- presenting: true,
53
- });
54
- const column = getByTestId("cell-column");
55
- expect(column.classList.contains("gap-(--notebook-cell-gap)")).toBe(true);
56
- expect(column.classList.contains("[--notebook-cell-gap:0px]")).toBe(true);
57
- });
58
- });
59
-
60
- describe("Column (multi-column notebook)", () => {
61
- it("shows column chrome when not presenting", () => {
62
- const { getByTestId, getAllByTestId } = renderColumn({
63
- width: "columns",
64
- presenting: false,
65
- });
66
-
67
- expect(getByTestId("column-header").hidden).toBe(false);
68
- expect(getByTestId("column-frame").classList.contains("border")).toBe(true);
69
- for (const handle of getAllByTestId("column-resize-handle")) {
70
- expect(handle.hidden).toBe(false);
71
- }
72
- });
73
-
74
- it("hides column chrome while presenting, without unmounting it", () => {
75
- const { getByTestId, getAllByTestId } = renderColumn({
76
- width: "columns",
77
- presenting: true,
78
- });
79
-
80
- // Header (drag handle, move/delete/add buttons) is hidden but mounted
81
- expect(getByTestId("column-header").hidden).toBe(true);
82
- // No border around the column
83
- expect(getByTestId("column-frame").classList.contains("border")).toBe(
84
- false,
85
- );
86
- // Resize handles are hidden
87
- const handles = getAllByTestId("column-resize-handle");
88
- expect(handles.length).toBeGreaterThan(0);
89
- for (const handle of handles) {
90
- expect(handle.hidden).toBe(true);
91
- }
92
- // Cell gap is zeroed on the column root (cascades to descendants)
93
- const columnRoot = getByTestId("column-frame").parentElement;
94
- expect(columnRoot?.classList.contains("[--notebook-cell-gap:0px]")).toBe(
95
- true,
96
- );
97
- // Editor geometry (saved widths, min-width, gutters) is replaced by the
98
- // published content width
99
- const inner = getByTestId("column-children").parentElement;
100
- expect(inner?.classList.contains("min-w-[500px]")).toBe(false);
101
- expect(inner?.classList.contains("w-(--content-width)")).toBe(true);
102
- // Children stay mounted
103
- expect(getByTestId("column-children")).toBeTruthy();
104
- });
105
- });
@@ -1,66 +0,0 @@
1
- /* Copyright 2026 Marimo. All rights reserved. */
2
- import { render } from "@testing-library/react";
3
- import { createStore, Provider } from "jotai";
4
- import { describe, expect, it } from "vitest";
5
- import { MockRequestClient } from "@/__mocks__/requests";
6
- import { parseAppConfig } from "@/core/config/config-schema";
7
- import { initialLayoutState, layoutStateAtom } from "@/core/layout/layout";
8
- import { type AppMode, kioskModeAtom } from "@/core/mode";
9
- import { requestClientAtom } from "@/core/network/requests";
10
- import { CellsRenderer } from "../cells-renderer";
11
- import type { LayoutType } from "../types";
12
-
13
- function renderWithStore(
14
- mode: AppMode,
15
- {
16
- kiosk = false,
17
- layout = "vertical",
18
- }: { kiosk?: boolean; layout?: LayoutType } = {},
19
- ) {
20
- const store = createStore();
21
- store.set(requestClientAtom, MockRequestClient.create());
22
- store.set(kioskModeAtom, kiosk);
23
- store.set(layoutStateAtom, {
24
- ...initialLayoutState(),
25
- selectedLayout: layout,
26
- });
27
-
28
- return render(
29
- <Provider store={store}>
30
- <CellsRenderer appConfig={parseAppConfig({})} mode={mode}>
31
- <div data-testid="notebook-children" />
32
- </CellsRenderer>
33
- </Provider>,
34
- );
35
- }
36
-
37
- describe("CellsRenderer", () => {
38
- it("renders children in edit mode", () => {
39
- const { queryByTestId } = renderWithStore("edit");
40
- expect(queryByTestId("notebook-children")).toBeTruthy();
41
- });
42
-
43
- it("keeps children mounted in present mode with the vertical layout", () => {
44
- // This preserves cell output DOM across the edit <-> present toggle;
45
- // swapping to the layout renderer would remount every output.
46
- const { queryByTestId } = renderWithStore("present");
47
- expect(queryByTestId("notebook-children")).toBeTruthy();
48
- });
49
-
50
- it("uses the layout renderer in present mode with a non-vertical layout", () => {
51
- // Only present+vertical keeps the editable tree mounted; grid/slides swap
52
- // to their layout renderer (which remounts outputs) per the toggle logic.
53
- const { queryByTestId } = renderWithStore("present", { layout: "grid" });
54
- expect(queryByTestId("notebook-children")).toBeFalsy();
55
- });
56
-
57
- it("uses the layout renderer in read mode", () => {
58
- const { queryByTestId } = renderWithStore("read");
59
- expect(queryByTestId("notebook-children")).toBeFalsy();
60
- });
61
-
62
- it("uses the layout renderer in kiosk mode", () => {
63
- const { queryByTestId } = renderWithStore("edit", { kiosk: true });
64
- expect(queryByTestId("notebook-children")).toBeFalsy();
65
- });
66
- });