@marimo-team/islands 0.23.16-dev35 → 0.23.16-dev36

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 (36) hide show
  1. package/dist/{chat-ui-DuPGKU9z.js → chat-ui-DAPduOBU.js} +77 -77
  2. package/dist/{common-Dm9n25i1.js → common-Bj3GHNDa.js} +701 -709
  3. package/dist/{html-to-image-Bza3T2dl.js → html-to-image-CRnU7G8x.js} +5069 -5540
  4. package/dist/main.js +113 -113
  5. package/dist/{process-output-pCEXvnhG.js → process-output-CK1nZFgq.js} +1 -1
  6. package/dist/{reveal-component-Db_uFCrL.js → reveal-component-s04jmX79.js} +11 -11
  7. package/package.json +2 -3
  8. package/src/components/editor/chrome/panels/__tests__/logs-panel.test.tsx +25 -0
  9. package/src/components/editor/chrome/panels/logs-panel.tsx +12 -2
  10. package/src/core/cells/__tests__/cells.test.ts +12 -2
  11. package/src/core/cells/__tests__/logs.test.ts +5 -5
  12. package/src/core/cells/cells.ts +13 -0
  13. package/src/core/cells/document-changes.ts +1 -0
  14. package/src/core/cells/logs.ts +14 -4
  15. package/src/core/codemirror/copilot/__tests__/language-server.test.ts +396 -100
  16. package/src/core/codemirror/copilot/__tests__/transport.test.ts +128 -540
  17. package/src/core/codemirror/copilot/language-server.ts +182 -70
  18. package/src/core/codemirror/copilot/transport.ts +15 -207
  19. package/src/core/codemirror/copilot/types.ts +9 -2
  20. package/src/core/codemirror/language/languages/python.ts +23 -11
  21. package/src/core/codemirror/lsp/__tests__/federated-lsp.test.ts +161 -0
  22. package/src/core/codemirror/lsp/__tests__/log-messages.test.ts +53 -0
  23. package/src/core/codemirror/lsp/__tests__/normalize-markdown-math.test.ts +25 -0
  24. package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +598 -156
  25. package/src/core/codemirror/lsp/__tests__/transports.test.ts +112 -0
  26. package/src/core/codemirror/lsp/federated-lsp.ts +76 -23
  27. package/src/core/codemirror/lsp/log-messages.ts +37 -0
  28. package/src/core/codemirror/lsp/normalize-markdown-math.ts +8 -4
  29. package/src/core/codemirror/lsp/notebook-lsp.ts +220 -56
  30. package/src/core/codemirror/lsp/transports.ts +8 -1
  31. package/src/core/codemirror/lsp/types.ts +68 -8
  32. package/src/core/codemirror/lsp/utils.ts +14 -0
  33. package/src/core/lsp/__tests__/transport.test.ts +509 -337
  34. package/src/core/lsp/transport.ts +304 -132
  35. package/src/css/app/codemirror.css +16 -2
  36. package/src/stories/log-viewer.stories.tsx +12 -6
@@ -0,0 +1,25 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import { render, screen } from "@testing-library/react";
4
+ import { describe, expect, it } from "vitest";
5
+ import type { CellLog } from "@/core/cells/logs";
6
+ import { LogViewer } from "../logs-panel";
7
+
8
+ describe("LogViewer", () => {
9
+ it("labels logs that came from a language server instead of a cell", () => {
10
+ const logs: CellLog[] = [
11
+ {
12
+ timestamp: 0,
13
+ level: "stderr",
14
+ message: "pylsp failed to start",
15
+ source: { type: "lsp", name: "pylsp" },
16
+ },
17
+ ];
18
+
19
+ render(<LogViewer logs={logs} />);
20
+
21
+ expect(screen.getByText("(lsp:pylsp)")).toBeInTheDocument();
22
+ expect(screen.getByText("pylsp failed to start")).toBeInTheDocument();
23
+ expect(screen.getByText("STDERR")).toBeInTheDocument();
24
+ });
25
+ });
@@ -4,7 +4,11 @@ import { FileTextIcon } from "lucide-react";
4
4
  import React from "react";
5
5
  import { ClearButton } from "@/components/buttons/clear-button";
6
6
  import { useCellActions, useCellLogs } from "@/core/cells/cells";
7
- import { type CellLog, formatLogTimestamp } from "@/core/cells/logs";
7
+ import {
8
+ type CellLog,
9
+ formatLogTimestamp,
10
+ logSourceLabel,
11
+ } from "@/core/cells/logs";
8
12
  import { cn } from "@/utils/cn";
9
13
  import { CellLink } from "../../links/cell-link";
10
14
  import { PanelEmptyState } from "./empty-state";
@@ -84,7 +88,13 @@ function formatLog(log: CellLog) {
84
88
  </span>
85
89
  <span className={cn("shrink-0", color)}>{level}</span>
86
90
  <span className="shrink-0 text-(--gray-10)">
87
- (<CellLink cellId={log.cellId} />)
91
+ (
92
+ {log.source.type === "cell" ? (
93
+ <CellLink cellId={log.source.cellId} />
94
+ ) : (
95
+ logSourceLabel(log.source)
96
+ )}
97
+ )
88
98
  </span>
89
99
  {log.message}
90
100
  </>
@@ -1870,8 +1870,18 @@ describe("cell reducer", () => {
1870
1870
 
1871
1871
  it("can clear logs", () => {
1872
1872
  state.cellLogs = [
1873
- { level: "stderr", message: "log1", timestamp: 0, cellId: firstCellId },
1874
- { level: "stderr", message: "log1", timestamp: 0, cellId: firstCellId },
1873
+ {
1874
+ level: "stderr",
1875
+ message: "log1",
1876
+ timestamp: 0,
1877
+ source: { type: "cell", cellId: firstCellId },
1878
+ },
1879
+ {
1880
+ level: "stderr",
1881
+ message: "log1",
1882
+ timestamp: 0,
1883
+ source: { type: "cell", cellId: firstCellId },
1884
+ },
1875
1885
  ];
1876
1886
  actions.clearLogs();
1877
1887
  expect(state.cellLogs).toEqual([]);
@@ -46,7 +46,7 @@ describe("getCellLogsForMessage", () => {
46
46
  timestamp: 1_234_567_890,
47
47
  level: "stdout",
48
48
  message: "Hello, World!",
49
- cellId: "cell-1",
49
+ source: { type: "cell", cellId: "cell-1" },
50
50
  });
51
51
  });
52
52
 
@@ -74,7 +74,7 @@ describe("getCellLogsForMessage", () => {
74
74
  timestamp: 1_234_567_890,
75
75
  level: "stderr",
76
76
  message: "Error occurred",
77
- cellId: "cell-2",
77
+ source: { type: "cell", cellId: "cell-2" },
78
78
  });
79
79
  });
80
80
 
@@ -102,7 +102,7 @@ describe("getCellLogsForMessage", () => {
102
102
  timestamp: 1_234_567_890,
103
103
  level: "stdout",
104
104
  message: "Error: Something went wrong",
105
- cellId: "cell-3",
105
+ source: { type: "cell", cellId: "cell-3" },
106
106
  });
107
107
  });
108
108
 
@@ -130,7 +130,7 @@ describe("getCellLogsForMessage", () => {
130
130
  timestamp: 1_234_567_890,
131
131
  level: "stderr",
132
132
  message: "Critical Error: System failure",
133
- cellId: "cell-4",
133
+ source: { type: "cell", cellId: "cell-4" },
134
134
  });
135
135
  });
136
136
 
@@ -157,7 +157,7 @@ describe("getCellLogsForMessage", () => {
157
157
  expect(logs[0].level).toBe("stderr"); // marimo-error should be treated as stderr
158
158
  expect(logs[0].message).toContain("Traceback (most recent call last):");
159
159
  expect(logs[0].message).toContain('File "test.py", line 1');
160
- expect(logs[0].cellId).toBe("cell-5");
160
+ expect(logs[0].source).toEqual({ type: "cell", cellId: "cell-5" });
161
161
  });
162
162
 
163
163
  test("handles multiple console outputs with different MIME types", () => {
@@ -927,6 +927,12 @@ const {
927
927
  cellLogs: [...nextState.cellLogs, ...getCellLogsForMessage(message)],
928
928
  };
929
929
  },
930
+ addLogs: (state, action: { logs: CellLog[] }) => {
931
+ return {
932
+ ...state,
933
+ cellLogs: [...state.cellLogs, ...action.logs],
934
+ };
935
+ },
930
936
  setCellIds: (state, action: { cellIds: CellId[] }) => {
931
937
  const isTheSame = isEqual(state.cellIds.inOrderIds, action.cellIds);
932
938
  if (isTheSame) {
@@ -1698,6 +1704,13 @@ export {
1698
1704
  notebookAtom,
1699
1705
  };
1700
1706
 
1707
+ /** Actions for dispatching outside of React. */
1708
+ const imperativeActions = createActions((action) => {
1709
+ store.set(notebookAtom, (state) => reducer(state, action));
1710
+ });
1711
+
1712
+ export const addLogs = imperativeActions.addLogs;
1713
+
1701
1714
  /// ATOMS
1702
1715
 
1703
1716
  export const cellIdsAtom = atom((get) => get(notebookAtom).cellIds);
@@ -369,6 +369,7 @@ export function toDocumentChanges(
369
369
  case "clearCellConsoleOutput":
370
370
  case "clearAllCellOutputs":
371
371
  case "clearLogs":
372
+ case "addLogs":
372
373
  return [];
373
374
 
374
375
  // Editor UI state — no document changes.
@@ -13,11 +13,21 @@ import { tracebackModalAtom } from "../errors/traceback-atom";
13
13
  import React from "react";
14
14
  import { ToastAction } from "@/components/ui/toast";
15
15
 
16
+ /** Logs come from a cell, or from a language server, which has no cell. */
17
+ export type LogSource =
18
+ | { type: "cell"; cellId: CellId }
19
+ | { type: "lsp"; name: string };
20
+
16
21
  export interface CellLog {
22
+ /** Unix timestamp, in seconds. */
17
23
  timestamp: number;
18
24
  level: "stdout" | "stderr";
19
25
  message: string;
20
- cellId: CellId;
26
+ source: LogSource;
27
+ }
28
+
29
+ export function logSourceLabel(source: LogSource): string {
30
+ return source.type === "cell" ? source.cellId : `lsp:${source.name}`;
21
31
  }
22
32
 
23
33
  let didAlreadyToastError = false;
@@ -48,7 +58,7 @@ export function getCellLogsForMessage(cell: CellMessage): CellLog[] {
48
58
  timestamp: output.timestamp || Date.now(),
49
59
  level: isError ? "stderr" : "stdout",
50
60
  message: message,
51
- cellId: cell.cell_id,
61
+ source: { type: "cell", cellId: cell.cell_id },
52
62
  });
53
63
  break;
54
64
  }
@@ -71,7 +81,7 @@ export function getCellLogsForMessage(cell: CellMessage): CellLog[] {
71
81
  cell.output.data.forEach((error) => {
72
82
  CellLogLogger.log({
73
83
  level: "stderr",
74
- cellId: cell.cell_id,
84
+ source: { type: "cell", cellId: cell.cell_id },
75
85
  timestamp: cell.timestamp ?? 0,
76
86
  message: JSON.stringify(error),
77
87
  });
@@ -150,7 +160,7 @@ const CellLogLogger = {
150
160
  `%c[${status}]`,
151
161
  `color:${color}; padding:2px 0; border-radius:2px; font-weight:bold`,
152
162
  `[${formatLogTimestamp(payload.timestamp)}]`,
153
- `(${payload.cellId}) ${payload.message}`,
163
+ `(${logSourceLabel(payload.source)}) ${payload.message}`,
154
164
  );
155
165
  },
156
166
  };