@marimo-team/islands 0.26.1-dev108 → 0.26.1-dev112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ErrorBoundary-BW4TciqU.js → ErrorBoundary-pNKOBKXw.js} +1 -1
- package/dist/{chat-ui-Be9X-W22.js → chat-ui-C9NZA-bk.js} +3 -3
- package/dist/{code-visibility-BKmktPMd.js → code-visibility-B9s3Hl8z.js} +2 -2
- package/dist/{common-CSJAjJGa.js → common-Bn3jx0X6.js} +6 -4
- package/dist/{data-grid-overlay-editor-DTibdR4H.js → data-grid-overlay-editor-mxwwRaQy.js} +1 -1
- package/dist/{error-entries-23Z_1oDM.js → error-entries-1DC4BiYB.js} +166 -155
- package/dist/{feedback-button-CPu5SV3b.js → feedback-button-BrzbnRTT.js} +3 -3
- package/dist/{glide-data-editor-CC9_NDNi.js → glide-data-editor-Cnsv3NcI.js} +3 -3
- package/dist/{globals-BFlYTNoR.js → globals-BGqfFPx8.js} +1 -1
- package/dist/{html-to-image-Cw7o1IbE.js → html-to-image-CsvAOgd3.js} +1 -1
- package/dist/main.js +10 -10
- package/dist/{number-overlay-editor-qDcRKPE0.js → number-overlay-editor-DuSCOMTK.js} +1 -1
- package/dist/{process-output-DdBM0lmd.js → process-output-CtfJ_Gbp.js} +2 -2
- package/dist/{reveal-component-BE1xhtNc.js → reveal-component-DzmiQyN9.js} +2 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/editor/__tests__/cell-renders.test.tsx +327 -1
- package/src/components/editor/ai/__tests__/completion-utils.test.ts +12 -20
- package/src/components/editor/ai/ai-completion-editor.tsx +391 -289
- package/src/components/editor/ai/completion-utils.ts +9 -7
- package/src/components/editor/cell/CellDeleteShoulder.tsx +82 -0
- package/src/components/editor/cell/DeleteButton.tsx +11 -2
- package/src/components/editor/cell/__tests__/CellDeleteShoulder.test.tsx +181 -0
- package/src/components/editor/cell/code/cell-editor.tsx +15 -25
- package/src/components/editor/chrome/panels/__tests__/logs-panel.test.tsx +26 -2
- package/src/components/editor/chrome/panels/logs-panel.tsx +27 -11
- package/src/components/editor/notebook-cell.tsx +20 -40
- package/src/core/ai/state.ts +6 -0
- package/src/core/cells/__tests__/cells.test.ts +34 -20
- package/src/core/cells/cell-log-chunks.ts +31 -0
- package/src/core/cells/cells.ts +10 -6
- package/src/core/codemirror/lsp/__tests__/log-messages.test.ts +1 -1
- package/src/core/codemirror/lsp/__tests__/transports.test.ts +1 -1
- package/src/core/islands/__tests__/bridge.test.ts +2 -5
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +10 -1
- package/src/css/common.css +11 -0
- package/src/hooks/useFinePointer.ts +30 -0
- package/src/stories/log-viewer.stories.tsx +48 -44
|
@@ -21,6 +21,8 @@ import { MockExecutions } from "@/__mocks__/executions";
|
|
|
21
21
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
22
22
|
import { cellId } from "@/__tests__/branded";
|
|
23
23
|
import type { CellHandle } from "@/components/editor/notebook-cell";
|
|
24
|
+
import { LOG_CHUNK_SIZE } from "../cell-log-chunks";
|
|
25
|
+
import type { CellLog } from "../logs";
|
|
24
26
|
import { CellId, SCRATCH_CELL_ID } from "@/core/cells/ids";
|
|
25
27
|
import { foldAllBulk, unfoldAllBulk } from "@/core/codemirror/editing/commands";
|
|
26
28
|
import { adaptiveLanguageConfiguration } from "@/core/codemirror/language/extension";
|
|
@@ -235,23 +237,33 @@ describe("cell reducer", () => {
|
|
|
235
237
|
expect(unfoldAllBulk).toHaveBeenCalled();
|
|
236
238
|
});
|
|
237
239
|
|
|
238
|
-
it("
|
|
239
|
-
|
|
240
|
-
{
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
it("retains ordered log batches across appends and runtime resets until cleared", () => {
|
|
241
|
+
const logs = Array.from(
|
|
242
|
+
{ length: 3 * LOG_CHUNK_SIZE + 2 },
|
|
243
|
+
(_, i): CellLog => ({
|
|
244
|
+
level: i % 2 === 0 ? "stdout" : "stderr",
|
|
245
|
+
message: String(i),
|
|
246
|
+
timestamp: i,
|
|
244
247
|
source: { type: "cell", cellId: firstCellId },
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
248
|
+
}),
|
|
249
|
+
);
|
|
250
|
+
actions.addLogs({ logs: logs.slice(0, LOG_CHUNK_SIZE + 1) });
|
|
251
|
+
const previous = state;
|
|
252
|
+
actions.addLogs({ logs: [] });
|
|
253
|
+
expect(state).toBe(previous);
|
|
254
|
+
actions.addLogs({ logs: logs.slice(LOG_CHUNK_SIZE + 1, -1) });
|
|
255
|
+
actions.addLogs({ logs: logs.slice(-1) });
|
|
256
|
+
const appended = state.cellLogs;
|
|
257
|
+
expect(appended[0]).toBe(previous.cellLogs[0]);
|
|
258
|
+
expect(previous.cellLogs.flat()).toEqual(logs.slice(0, LOG_CHUNK_SIZE + 1));
|
|
259
|
+
expect(appended.flat()).toEqual(logs);
|
|
260
|
+
actions.resetCellRuntimes(false);
|
|
261
|
+
expect(state.cellLogs).toBe(appended);
|
|
253
262
|
actions.clearLogs();
|
|
254
263
|
expect(state.cellLogs).toEqual([]);
|
|
264
|
+
actions.addLogs({ logs: logs.slice(-1) });
|
|
265
|
+
expect(state.cellLogs.flat()).toEqual(logs.slice(-1));
|
|
266
|
+
expect(appended.flat()).toEqual(logs);
|
|
255
267
|
});
|
|
256
268
|
|
|
257
269
|
describe("releaseCellAtoms", () => {
|
|
@@ -289,12 +301,14 @@ it("keeps layout cells stable when only a notebook log changes", () => {
|
|
|
289
301
|
store.set(notebookAtom, {
|
|
290
302
|
...notebook,
|
|
291
303
|
cellLogs: [
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
304
|
+
[
|
|
305
|
+
{
|
|
306
|
+
level: "stderr",
|
|
307
|
+
message: "log",
|
|
308
|
+
timestamp: 0,
|
|
309
|
+
source: { type: "cell", cellId: id },
|
|
310
|
+
},
|
|
311
|
+
],
|
|
298
312
|
],
|
|
299
313
|
});
|
|
300
314
|
expect(store.get(renderedNotebookCellsAtom)).toBe(cells);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import type { CellLog } from "./logs";
|
|
4
|
+
|
|
5
|
+
export type CellLogChunks = readonly (readonly CellLog[])[];
|
|
6
|
+
export const LOG_CHUNK_SIZE = 128;
|
|
7
|
+
|
|
8
|
+
/** Full chunks stay shared with previous notebook snapshots. */
|
|
9
|
+
export function appendCellLogs(
|
|
10
|
+
chunks: CellLogChunks,
|
|
11
|
+
logs: readonly CellLog[],
|
|
12
|
+
): CellLogChunks {
|
|
13
|
+
if (logs.length === 0) {
|
|
14
|
+
return chunks;
|
|
15
|
+
}
|
|
16
|
+
const next = [...chunks];
|
|
17
|
+
const last = next.at(-1);
|
|
18
|
+
let offset = 0;
|
|
19
|
+
if (last && last.length < LOG_CHUNK_SIZE) {
|
|
20
|
+
const tail = [...last];
|
|
21
|
+
while (offset < logs.length && tail.length < LOG_CHUNK_SIZE) {
|
|
22
|
+
tail.push(logs[offset]);
|
|
23
|
+
offset++;
|
|
24
|
+
}
|
|
25
|
+
next[next.length - 1] = tail;
|
|
26
|
+
}
|
|
27
|
+
for (; offset < logs.length; offset += LOG_CHUNK_SIZE) {
|
|
28
|
+
next.push(logs.slice(offset, offset + LOG_CHUNK_SIZE));
|
|
29
|
+
}
|
|
30
|
+
return next;
|
|
31
|
+
}
|
package/src/core/cells/cells.ts
CHANGED
|
@@ -40,6 +40,7 @@ import { consoleExecution, consoleView } from "./execution-console";
|
|
|
40
40
|
import { applyDocument } from "./document";
|
|
41
41
|
import { isCodeHidden, shownHiddenCodeAtom } from "./editor";
|
|
42
42
|
import { type CellId, SCRATCH_CELL_ID } from "./ids";
|
|
43
|
+
import { appendCellLogs, type CellLogChunks } from "./cell-log-chunks";
|
|
43
44
|
import { type CellLog, getCellLogsForMessage } from "./logs";
|
|
44
45
|
import type { NotebookOutlineItem, Outline } from "./outline";
|
|
45
46
|
import { focusAndScrollCellIntoView } from "./scrollCellIntoView";
|
|
@@ -120,7 +121,7 @@ export interface NotebookState {
|
|
|
120
121
|
/**
|
|
121
122
|
* Logs of all cell messages
|
|
122
123
|
*/
|
|
123
|
-
cellLogs:
|
|
124
|
+
cellLogs: CellLogChunks;
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
function withScratchCell(notebookState: NotebookState): NotebookState {
|
|
@@ -203,10 +204,10 @@ const {
|
|
|
203
204
|
? next
|
|
204
205
|
: {
|
|
205
206
|
...next,
|
|
206
|
-
cellLogs:
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
207
|
+
cellLogs: appendCellLogs(
|
|
208
|
+
next.cellLogs,
|
|
209
|
+
getCellLogsForMessage({ cell_id, console: entries }),
|
|
210
|
+
),
|
|
210
211
|
};
|
|
211
212
|
},
|
|
212
213
|
hideConsoleInputs: (
|
|
@@ -250,9 +251,12 @@ const {
|
|
|
250
251
|
return { ...state, cellRuntime };
|
|
251
252
|
},
|
|
252
253
|
addLogs: (state, action: { logs: CellLog[] }) => {
|
|
254
|
+
if (action.logs.length === 0) {
|
|
255
|
+
return state;
|
|
256
|
+
}
|
|
253
257
|
return {
|
|
254
258
|
...state,
|
|
255
|
-
cellLogs:
|
|
259
|
+
cellLogs: appendCellLogs(state.cellLogs, action.logs),
|
|
256
260
|
};
|
|
257
261
|
},
|
|
258
262
|
/** Follow the host document's cells and order. */
|
|
@@ -24,7 +24,7 @@ describe("handleLogMessage", () => {
|
|
|
24
24
|
handleLogMessage("pylsp", logMessage(2, "plugin not installed"));
|
|
25
25
|
handleLogMessage("pylsp", logMessage(3, "indexing"));
|
|
26
26
|
|
|
27
|
-
expect(store.get(notebookAtom).cellLogs).toMatchObject([
|
|
27
|
+
expect(store.get(notebookAtom).cellLogs.flat()).toMatchObject([
|
|
28
28
|
{ level: "stderr", message: "failed to start" },
|
|
29
29
|
{ level: "stderr", message: "plugin not installed" },
|
|
30
30
|
{
|
|
@@ -96,7 +96,7 @@ describe("createTransport", () => {
|
|
|
96
96
|
params: { uri: "file:///a", diagnostics: [] },
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
expect(store.get(notebookAtom).cellLogs).toMatchObject([
|
|
99
|
+
expect(store.get(notebookAtom).cellLogs.flat()).toMatchObject([
|
|
100
100
|
{
|
|
101
101
|
level: "stderr",
|
|
102
102
|
message: "pylsp failed to start",
|
|
@@ -444,11 +444,8 @@ describe("IslandsPyodideBridge", () => {
|
|
|
444
444
|
expect(
|
|
445
445
|
store
|
|
446
446
|
.get(notebookAtom)
|
|
447
|
-
.cellLogs.
|
|
448
|
-
|
|
449
|
-
message,
|
|
450
|
-
source,
|
|
451
|
-
]),
|
|
447
|
+
.cellLogs.flat()
|
|
448
|
+
.map(({ level, message, source }) => [level, message, source]),
|
|
452
449
|
).toEqual([
|
|
453
450
|
["stdout", "hello", { type: "cell", cellId: "c2" }],
|
|
454
451
|
["stderr", "warning", { type: "cell", cellId: "c2" }],
|
|
@@ -1092,6 +1092,12 @@ it.each(["live", "replay", "batched"])(
|
|
|
1092
1092
|
}
|
|
1093
1093
|
});
|
|
1094
1094
|
expect(rows()).toEqual(["ABC"]);
|
|
1095
|
+
const messages = () =>
|
|
1096
|
+
store
|
|
1097
|
+
.get(notebookAtom)
|
|
1098
|
+
.cellLogs.flat()
|
|
1099
|
+
.map((log) => log.message);
|
|
1100
|
+
expect(messages()).toEqual(mode === "replay" ? [] : ["B", "C"]);
|
|
1095
1101
|
act(() => {
|
|
1096
1102
|
conn.receive({ event: "console.removed", data: { id: "line-0" } });
|
|
1097
1103
|
conn.receive({ event: "console.removed", data: { id: "line-1" } });
|
|
@@ -1337,7 +1343,10 @@ it("clears the private debugger prompt and transcript when editing moves to anot
|
|
|
1337
1343
|
});
|
|
1338
1344
|
expect(rows()).toEqual([]);
|
|
1339
1345
|
expect(
|
|
1340
|
-
store
|
|
1346
|
+
store
|
|
1347
|
+
.get(notebookAtom)
|
|
1348
|
+
.cellLogs.flat()
|
|
1349
|
+
.map((log) => log.message),
|
|
1341
1350
|
).not.toContain("private debugger");
|
|
1342
1351
|
expect(store.get(pendingPdbInputAtom)).toBeNull();
|
|
1343
1352
|
});
|
package/src/css/common.css
CHANGED
|
@@ -20,6 +20,17 @@
|
|
|
20
20
|
display: inline-flex !important;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/*
|
|
24
|
+
* Let the cell's delete control take and keep keyboard focus. A hidden
|
|
25
|
+
* control cannot take focus, so the first selector keeps the control visible
|
|
26
|
+
* in the moment when focus leaves the cell and no element holds focus yet.
|
|
27
|
+
* Focus on any other element in the cell does not show the control.
|
|
28
|
+
*/
|
|
29
|
+
.marimo-cell:focus-within:not(:has(:focus)) .shoulder-bottom.hover-action,
|
|
30
|
+
.shoulder-bottom.hover-action:focus-within {
|
|
31
|
+
display: inline-flex !important;
|
|
32
|
+
}
|
|
33
|
+
|
|
23
34
|
.hover-actions-parent:hover .hover-action,
|
|
24
35
|
.hover-actions-parent:focus .hover-action {
|
|
25
36
|
display: inline-flex !important;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { useSyncExternalStore } from "react";
|
|
4
|
+
import { createSharedSubscription } from "@/utils/shared-resource";
|
|
5
|
+
|
|
6
|
+
/** Matches the media query that common.css uses to hide hover actions. */
|
|
7
|
+
const FINE_POINTER_QUERY = "(hover: hover) and (pointer: fine)";
|
|
8
|
+
|
|
9
|
+
function getQuery(): MediaQueryList | undefined {
|
|
10
|
+
return window.matchMedia?.(FINE_POINTER_QUERY);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const subscribeToFinePointer = createSharedSubscription((notify) => {
|
|
14
|
+
const query = getQuery();
|
|
15
|
+
query?.addEventListener("change", notify);
|
|
16
|
+
return () => query?.removeEventListener("change", notify);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
function getSnapshot(): boolean {
|
|
20
|
+
return getQuery()?.matches ?? false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Whether the primary input can hover precisely (mouse or trackpad).
|
|
25
|
+
* Updates when the pointer capabilities change during a session.
|
|
26
|
+
* Environments without `matchMedia` report `false`.
|
|
27
|
+
*/
|
|
28
|
+
export function useFinePointer(): boolean {
|
|
29
|
+
return useSyncExternalStore(subscribeToFinePointer, getSnapshot, () => false);
|
|
30
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
3
|
+
import { appendCellLogs } from "@/core/cells/cell-log-chunks";
|
|
3
4
|
import { cellId } from "@/__tests__/branded";
|
|
4
5
|
import { LogViewer } from "@/components/editor/chrome/panels/logs-panel";
|
|
5
6
|
import { Dialog } from "../components/ui/dialog";
|
|
@@ -19,50 +20,53 @@ export const Primary: Story = {
|
|
|
19
20
|
<Dialog>
|
|
20
21
|
<TooltipProvider>
|
|
21
22
|
<LogViewer
|
|
22
|
-
logs={
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
23
|
+
logs={appendCellLogs(
|
|
24
|
+
[],
|
|
25
|
+
[
|
|
26
|
+
{
|
|
27
|
+
timestamp: Date.now(),
|
|
28
|
+
level: "stdout",
|
|
29
|
+
source: { type: "cell", cellId: cellId("cell1") },
|
|
30
|
+
message: "Hello world!",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
timestamp: Date.now(),
|
|
34
|
+
level: "stdout",
|
|
35
|
+
source: { type: "cell", cellId: cellId("cell1") },
|
|
36
|
+
message: "Running cell...",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
timestamp: Date.now(),
|
|
40
|
+
level: "stdout",
|
|
41
|
+
source: { type: "cell", cellId: cellId("cell1") },
|
|
42
|
+
message: "Done!",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
timestamp: Date.now(),
|
|
46
|
+
level: "stderr",
|
|
47
|
+
source: { type: "cell", cellId: cellId("cell2") },
|
|
48
|
+
message: "Output is too large!",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
timestamp: Date.now(),
|
|
52
|
+
level: "stderr",
|
|
53
|
+
source: { type: "cell", cellId: cellId("cell2") },
|
|
54
|
+
message: "String length is too short.".repeat(100),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
timestamp: Date.now(),
|
|
58
|
+
level: "stderr",
|
|
59
|
+
source: { type: "lsp", name: "pylsp" },
|
|
60
|
+
message: "Failed to load plugin 'ruff': not installed",
|
|
61
|
+
},
|
|
62
|
+
...Array.from({ length: 100 }).map(() => ({
|
|
63
|
+
timestamp: Date.now(),
|
|
64
|
+
level: "stdout" as const,
|
|
65
|
+
source: { type: "cell", cellId: cellId("cell1") } as const,
|
|
66
|
+
message: "Running cell...",
|
|
67
|
+
})),
|
|
68
|
+
],
|
|
69
|
+
)}
|
|
66
70
|
/>
|
|
67
71
|
</TooltipProvider>
|
|
68
72
|
</Dialog>
|