@marimo-team/frontend 0.25.3-dev40 → 0.25.3-dev44

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 (100) hide show
  1. package/dist/assets/{CellStatus-BGIWF94J.js → CellStatus-BpOBz-8m.js} +1 -1
  2. package/dist/assets/{ErrorBoundary-hliG40Pk.js → ErrorBoundary-DmXl4Nre.js} +2 -2
  3. package/dist/assets/{JsonOutput-9tmC-p6h.js → JsonOutput-DsMCKg5f.js} +2 -2
  4. package/dist/assets/{MarimoErrorOutput-BaHdbtck.js → MarimoErrorOutput-DVjK8RgY.js} +1 -1
  5. package/dist/assets/{RenderHTML-B1FzB5NY.js → RenderHTML-BFaztTR0.js} +1 -1
  6. package/dist/assets/{RunButton-DpGokdF1.js → RunButton-B44xE_d5.js} +1 -1
  7. package/dist/assets/{add-cell-with-ai-BYWG0iKO.js → add-cell-with-ai-CkjslziO.js} +1 -1
  8. package/dist/assets/{add-connection-dialog-BWbUVPJk.js → add-connection-dialog-CWLLVKju.js} +1 -1
  9. package/dist/assets/{agent-panel-DKNiQrAl.js → agent-panel-DVUZ4l17.js} +1 -1
  10. package/dist/assets/{ai-model-dropdown-CIg9eu47.js → ai-model-dropdown-F3mm17Wa.js} +1 -1
  11. package/dist/assets/{app-config-button-BvkL2eSY.js → app-config-button-D0uDs5nC.js} +1 -1
  12. package/dist/assets/{blob-BQfLiwKr.js → blob-BSfsdCNF.js} +1 -1
  13. package/dist/assets/{cell-editor-BKKUv4d5.js → cell-editor-BXMAe73i.js} +1 -1
  14. package/dist/assets/{cell-link-B_QkRkm-.js → cell-link-DFPHORAO.js} +1 -1
  15. package/dist/assets/{cells-CdH98VSn.js → cells-BdgzY0of.js} +1 -1
  16. package/dist/assets/{chat-display-CNbRSebo.js → chat-display-BrcwdhKJ.js} +1 -1
  17. package/dist/assets/{chat-panel-HbEKDf0c.js → chat-panel-C__3iSyI.js} +1 -1
  18. package/dist/assets/{chat-ui-BwMev8Bf.js → chat-ui-NlBK3kK6.js} +1 -1
  19. package/dist/assets/{code-visibility-sQ37CBNo.js → code-visibility-Cs-Vv3jV.js} +1 -1
  20. package/dist/assets/{column-preview-CsEBzIUE.js → column-preview-D-MQXrz3.js} +1 -1
  21. package/dist/assets/{command-palette-BzZ86pUz.js → command-palette-BbCoQAH7.js} +1 -1
  22. package/dist/assets/{common-S2v8dsEy.js → common-BcEY1yDS.js} +1 -1
  23. package/dist/assets/{components-D-TnFWjo.js → components-lkCfd2vy.js} +1 -1
  24. package/dist/assets/{config-CYsbZpwa.js → config-BwHT0yGp.js} +2 -2
  25. package/dist/assets/{config-BoBwH7CU.js → config-DXjnAwtL.js} +1 -1
  26. package/dist/assets/{datasource-BA7YF4eo.js → datasource-dKk3JHSQ.js} +1 -1
  27. package/dist/assets/{dependency-graph-panel-DsjI61Qa.js → dependency-graph-panel-BaisS9Zt.js} +1 -1
  28. package/dist/assets/{documentation-panel-hk3IdeXy.js → documentation-panel-CpSUoM8r.js} +1 -1
  29. package/dist/assets/{download-CCZkq0y4.js → download-RV4i1fWI.js} +1 -1
  30. package/dist/assets/{edit-page-BgS6tjth.js → edit-page-OQUBqPxV.js} +4 -4
  31. package/dist/assets/{error-entries-BVXrGOTZ.js → error-entries-CJS0gOId.js} +1 -1
  32. package/dist/assets/{error-panel-DYethUUR.js → error-panel-BxCKpZtN.js} +1 -1
  33. package/dist/assets/feedback-button-BLvwvndE.js +1 -0
  34. package/dist/assets/{feedback-button-DaNc3uJa.js → feedback-button-DYjae3_b.js} +1 -1
  35. package/dist/assets/{file-explorer-panel-CqnzSSYc.js → file-explorer-panel-Cg48iuPg.js} +1 -1
  36. package/dist/assets/{file-name-input-D4AvwZV9.js → file-name-input-BpfSzvEB.js} +1 -1
  37. package/dist/assets/{floating-outline-CTy-Iakk.js → floating-outline-CrWdiNQ2.js} +1 -1
  38. package/dist/assets/{gallery-page-ByjlvM6k.js → gallery-page-W_b-XWq6.js} +1 -1
  39. package/dist/assets/{glide-data-editor-CABBj2b0.js → glide-data-editor-C_bIL30J.js} +1 -1
  40. package/dist/assets/{home-page-DejRSjeJ.js → home-page-D1teQDdF.js} +1 -1
  41. package/dist/assets/{hooks-BJgCcVXZ.js → hooks-B2jmXrjG.js} +1 -1
  42. package/dist/assets/{index-PDJQd7X6.js → index-CnvKSoR0.js} +5 -5
  43. package/dist/assets/index-evFWHKmM.css +2 -0
  44. package/dist/assets/{layout-Ct0rjb-5.js → layout-Ckm5arvO.js} +3 -3
  45. package/dist/assets/{logs-panel-TyeqEvOY.js → logs-panel-DVSgfMgv.js} +1 -1
  46. package/dist/assets/{markdown-renderer-BFyD6Jhs.js → markdown-renderer-DX2O5YiE.js} +1 -1
  47. package/dist/assets/{name-cell-input-D-0VF3qd.js → name-cell-input-DL1i8Mj0.js} +1 -1
  48. package/dist/assets/{outline-panel-DMTjk2WC.js → outline-panel-DPKPT2eg.js} +1 -1
  49. package/dist/assets/{packages-panel-DrT69k9L.js → packages-panel-CZZwD9YV.js} +1 -1
  50. package/dist/assets/{panel-accordion-state-Ban6j---.js → panel-accordion-state-C7vvsYz1.js} +1 -1
  51. package/dist/assets/panels-B2HvGLkD.js +4 -0
  52. package/dist/assets/{process-output-DzpQYlpY.js → process-output-BKhybJBb.js} +1 -1
  53. package/dist/assets/{readonly-code-display-Cyn3k5TX.js → readonly-code-display-9QrSm_7D.js} +1 -1
  54. package/dist/assets/{readonly-python-code-DrXDDAnA.js → readonly-python-code-BLotL3XP.js} +1 -1
  55. package/dist/assets/{reveal-component-_lKImPWP.js → reveal-component-CxQ9fVAB.js} +1 -1
  56. package/dist/assets/{run-page-7UNg--Rj.js → run-page-DtWhVRu3.js} +1 -1
  57. package/dist/assets/{runtime-details-state-CKOKhMhv.js → runtime-details-state-B25uM-Ps.js} +1 -1
  58. package/dist/assets/{scratchpad-panel-C7h4MgqN.js → scratchpad-panel-DsqDHGr7.js} +1 -1
  59. package/dist/assets/{session-panel-CLiWXc5y.js → session-panel-CjJ0nwoT.js} +1 -1
  60. package/dist/assets/{snippets-panel-Wrqaorxa.js → snippets-panel-IxIxfxNc.js} +1 -1
  61. package/dist/assets/{state-TVREh4u4.js → state-BHuYDaxs.js} +1 -1
  62. package/dist/assets/{state-_uXVmwuN.js → state-CVgqwwCU.js} +1 -1
  63. package/dist/assets/{terminal-Dp5gyJ7l.js → terminal-CjvCrRrA.js} +1 -1
  64. package/dist/assets/{tracing-fUNLyKuj.js → tracing-V5zejPsw.js} +1 -1
  65. package/dist/assets/{tracing-panel-Cx4OqOoP.js → tracing-panel-DLS3iwK6.js} +2 -2
  66. package/dist/assets/{tree-actions-B1vsdenY.js → tree-actions-Be_mzC1C.js} +1 -1
  67. package/dist/assets/{useAddCell-DZ-50qEG.js → useAddCell-DK79W1vA.js} +1 -1
  68. package/dist/assets/{useBoolean-5g-bBaYF.js → useBoolean-j0qHaJxu.js} +1 -1
  69. package/dist/assets/{useCellActionButton-DINnRstv.js → useCellActionButton-Cw9Ob12j.js} +1 -1
  70. package/dist/assets/{useDeleteCell-CREJXVNp.js → useDeleteCell-BNqX6PPu.js} +1 -1
  71. package/dist/assets/{useDependencyPanelTab-Cw5VT16Q.js → useDependencyPanelTab-GnTnqKJo.js} +1 -1
  72. package/dist/assets/{useInstallPackage-Cw0dVELh.js → useInstallPackage-CVItDn1e.js} +1 -1
  73. package/dist/assets/{useNotebookActions-B4av4mLc.js → useNotebookActions-BTkKQpGk.js} +1 -1
  74. package/dist/assets/{useRunCells-BHBMk9zW.js → useRunCells-DP09DHT6.js} +1 -1
  75. package/dist/assets/{useSplitCell-DAgwZV0q.js → useSplitCell-IfumZ4sm.js} +1 -1
  76. package/dist/assets/{vega-component-pQE2mKc1.js → vega-component-CMn031HF.js} +1 -1
  77. package/dist/index.html +25 -25
  78. package/package.json +2 -4
  79. package/src/__tests__/host-imports.test.ts +1 -0
  80. package/src/components/data-table/__tests__/export-actions.test.tsx +88 -0
  81. package/src/components/data-table/export-actions.tsx +71 -45
  82. package/src/core/attachments/state.ts +2 -2
  83. package/src/core/host/AGENTS.md +6 -2
  84. package/src/core/host/__tests__/attachments.test.ts +9 -10
  85. package/src/core/host/__tests__/document.test.ts +18 -16
  86. package/src/core/host/__tests__/events.test.ts +5 -2
  87. package/src/core/host/__tests__/fixtures.ts +6 -4
  88. package/src/core/host/events.ts +18 -2
  89. package/src/core/host/notebook-client.ts +46 -13
  90. package/src/core/host/resources/attachments.ts +3 -3
  91. package/src/core/host/resources/document.ts +3 -3
  92. package/src/core/websocket/__tests__/useNotebookSession.hook.test.tsx +1 -1
  93. package/dist/assets/feedback-button-DDzObtF2.js +0 -1
  94. package/dist/assets/index-ChfDZJzP.css +0 -2
  95. package/dist/assets/panels-BLYQRkEc.js +0 -4
  96. package/src/core/host/__tests__/protocol.test.ts +0 -229
  97. package/src/core/host/__tests__/stream.test.ts +0 -209
  98. package/src/core/host/protocol.ts +0 -1948
  99. package/src/core/host/resources/resource.ts +0 -47
  100. package/src/core/host/stream.ts +0 -211
@@ -2,7 +2,7 @@
2
2
 
3
3
  import NodeFs from "node:fs";
4
4
  import NodeUrl from "node:url";
5
- import { parseNotebookEvent, type NotebookEvent } from "../events";
5
+ import * as Protocol from "@marimo-team/client/protocol";
6
6
 
7
7
  /** Read the protocol's portable examples as transport messages. */
8
8
  export function fixtureMessages(name: string) {
@@ -33,7 +33,9 @@ export function fixtureMessages(name: string) {
33
33
  });
34
34
  }
35
35
 
36
- /** Read the protocol's portable examples as decoded notebook events. */
37
- export function fixtureEvents(name: string): NotebookEvent[] {
38
- return fixtureMessages(name).map(parseNotebookEvent);
36
+ /** Read the protocol's portable examples as decoded protocol events. */
37
+ export function fixtureEvents(name: string): Protocol.EventOutput[] {
38
+ return fixtureMessages(name).map(({ id, ...message }) =>
39
+ Protocol.Event.parse(id === undefined ? message : { ...message, id }),
40
+ );
39
41
  }
@@ -1,7 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
3
  import { z } from "zod";
4
- import * as Protocol from "./protocol";
4
+ import * as Protocol from "@marimo-team/client/protocol";
5
5
 
6
6
  /**
7
7
  * Notebook stream events, including native marimo notifications.
@@ -29,16 +29,29 @@ const knownNames = new Set<string>(
29
29
  Protocol.Event.options.flatMap((schema) => schema.shape.event.options),
30
30
  );
31
31
 
32
+ /**
33
+ * A native marimo message carried by a host stream.
34
+ *
35
+ * The protocol leaves extension events to their producer. The payload is
36
+ * passed through for the session handler to interpret.
37
+ */
38
+ const MarimoEvent = z.object({
39
+ event: z.literal("marimo"),
40
+ id: z.string().min(1).optional(),
41
+ data: z.object({ marimo: z.unknown() }),
42
+ });
43
+
32
44
  /** A decoded event, or the name and cursor of an unrecognized event. */
33
45
  export type NotebookEvent =
34
46
  | Protocol.EventOutput
47
+ | z.output<typeof MarimoEvent>
35
48
  | {
36
49
  readonly event: "unknown";
37
50
  readonly name: string;
38
51
  readonly id?: string;
39
52
  };
40
53
 
41
- const sessionEnvelope = z.object({ data: Protocol.MarimoNotification });
54
+ const sessionEnvelope = z.object({ data: z.unknown() });
42
55
 
43
56
  /**
44
57
  * Decode a host event or a legacy `{ data: notification }` session message.
@@ -54,6 +67,9 @@ export function parseNotebookEvent(value: unknown): NotebookEvent {
54
67
  };
55
68
  }
56
69
  const parsed = envelope.parse(value);
70
+ if (parsed.event === "marimo") {
71
+ return MarimoEvent.parse(parsed);
72
+ }
57
73
  if (knownNames.has(parsed.event)) {
58
74
  return Protocol.Event.parse(parsed);
59
75
  }
@@ -1,6 +1,8 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
3
  import { Logger } from "@/utils/Logger";
4
+ import type { Attachment } from "@marimo-team/client/protocol";
5
+ import { createReducer } from "@marimo-team/client/reducer";
4
6
  import { type Atom, atom, type createStore } from "jotai/vanilla";
5
7
  import {
6
8
  type ConnectionStatus,
@@ -10,11 +12,16 @@ import {
10
12
  type NotebookTransport,
11
13
  TransportReadyState,
12
14
  } from "./connection";
13
- import { parseNotebookEvent } from "./events";
14
- import type { Attachment } from "./protocol";
15
+ import { type NotebookEvent, parseNotebookEvent } from "./events";
15
16
  import { attachments } from "./resources/attachments";
16
17
  import { type Document, document } from "./resources/document";
17
- import { createStream } from "./stream";
18
+
19
+ /** Events that may arrive without a cursor after `ready`. */
20
+ const UNCURSORED = new Set<NotebookEvent["event"]>([
21
+ "reset",
22
+ "marimo",
23
+ "unknown",
24
+ ]);
18
25
 
19
26
  /** A connection to a notebook on a marimo host. */
20
27
  export interface NotebookClient {
@@ -64,8 +71,8 @@ export function createNotebookClient(store: ReturnType<typeof createStore>) {
64
71
  state: ConnectionState.NOT_STARTED,
65
72
  });
66
73
  // One atom holds the whole stream, which resource atoms derive from.
67
- const stream = createStream({ document, attachments });
68
- const streamAtom = atom(stream.initial);
74
+ const reducer = createReducer({ document, attachments });
75
+ const streamAtom = atom(reducer.initial);
69
76
  // A resumed stream is live, but presence waits for this connection's ready.
70
77
  const readyAtom = atom(false);
71
78
  const documentAtom = atom(
@@ -103,6 +110,8 @@ export function createNotebookClient(store: ReturnType<typeof createStore>) {
103
110
  let terminal = false;
104
111
  let checkingHealth = false;
105
112
  let streamKey: string | undefined;
113
+ // The id of the last live event. Null before `ready` and after `reset`.
114
+ let cursor: string | null = null;
106
115
  const transport = createTransport(() => {
107
116
  if (messageFormat === "session") {
108
117
  return url();
@@ -118,15 +127,23 @@ export function createNotebookClient(store: ReturnType<typeof createStore>) {
118
127
  identity.searchParams.delete("access_token");
119
128
  identity.searchParams.sort();
120
129
  const key = identity.toString();
130
+ const current = store.get(streamAtom);
131
+ // A live stream keeps its state and resumes from the cursor. An
132
+ // incomplete snapshot starts over.
121
133
  const state =
122
- key === streamKey
123
- ? stream.resume(store.get(streamAtom))
124
- : stream.initial;
134
+ key !== streamKey
135
+ ? reducer.initial
136
+ : current.phase === "snapshot"
137
+ ? { ...reducer.initial, notebookId: current.notebookId }
138
+ : current;
139
+ if (state.phase === "snapshot") {
140
+ cursor = null;
141
+ }
125
142
  streamKey = key;
126
143
  store.set(readyAtom, false);
127
144
  store.set(streamAtom, state);
128
- if (state.cursor !== null) {
129
- next.searchParams.set("cursor", state.cursor);
145
+ if (cursor !== null) {
146
+ next.searchParams.set("cursor", cursor);
130
147
  }
131
148
  return next.toString();
132
149
  });
@@ -188,7 +205,22 @@ export function createNotebookClient(store: ReturnType<typeof createStore>) {
188
205
  let event;
189
206
  try {
190
207
  event = parseNotebookEvent(decodeJson(message.data));
191
- store.set(streamAtom, stream.reduce(store.get(streamAtom), event));
208
+ const state = store.get(streamAtom);
209
+ if (
210
+ state.phase === "live" &&
211
+ event.id === undefined &&
212
+ !UNCURSORED.has(event.event)
213
+ ) {
214
+ throw new Error("Live notebook event is missing its cursor");
215
+ }
216
+ if (event.event !== "marimo" && event.event !== "unknown") {
217
+ store.set(streamAtom, reducer.reduce(state, event));
218
+ }
219
+ if (event.event === "reset") {
220
+ cursor = null;
221
+ } else if (event.event === "ready" || state.phase === "live") {
222
+ cursor = event.id ?? cursor;
223
+ }
192
224
  if (event.event === "ready" || event.event === "reset") {
193
225
  store.set(readyAtom, event.event === "ready");
194
226
  }
@@ -198,7 +230,8 @@ export function createNotebookClient(store: ReturnType<typeof createStore>) {
198
230
  onMessageError(error);
199
231
  return;
200
232
  }
201
- store.set(streamAtom, stream.initial);
233
+ store.set(streamAtom, reducer.initial);
234
+ cursor = null;
202
235
  terminal = true;
203
236
  setStatus({
204
237
  ...disconnected,
@@ -256,7 +289,7 @@ export function createNotebookClient(store: ReturnType<typeof createStore>) {
256
289
  transport.removeEventListener("message", onMessage);
257
290
  transport.close();
258
291
  reconnect = undefined;
259
- store.set(streamAtom, stream.initial);
292
+ store.set(streamAtom, reducer.initial);
260
293
  setStatus({ state: ConnectionState.NOT_STARTED });
261
294
  },
262
295
  { once: true },
@@ -1,10 +1,10 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
- import type { Attachment } from "../protocol";
4
- import type { Resource } from "./resource";
3
+ import type { Attachment } from "@marimo-team/client/protocol";
4
+ import type { Resource } from "@marimo-team/client/reducer";
5
5
 
6
6
  /** Attachment records retained with the stream's resume cursor. */
7
- export const attachments: Resource<readonly Attachment[]> = {
7
+ export const attachments: Resource<readonly Attachment[], "attachment"> = {
8
8
  initial: [],
9
9
  on: {
10
10
  attachment: (state, { data: { attachment } }) =>
@@ -1,7 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
- import type * as Protocol from "../protocol";
4
- import type { Resource } from "./resource";
3
+ import type * as Protocol from "@marimo-team/client/protocol";
4
+ import type { Resource } from "@marimo-team/client/reducer";
5
5
 
6
6
  /**
7
7
  * The notebook's content at one revision.
@@ -58,7 +58,7 @@ function publish(
58
58
  return { current: { revision, cells }, pending: null };
59
59
  }
60
60
 
61
- export const document: Resource<DocumentState> = {
61
+ export const document: Resource<DocumentState, "cell" | "document"> = {
62
62
  initial: { current: null, pending: null },
63
63
  on: {
64
64
  cell: (state, { data }) => {
@@ -45,7 +45,7 @@ import { notebookAtom } from "@/core/cells/cells";
45
45
  import { AppConfigSchema } from "@/core/config/config-schema";
46
46
  import { ConnectionNotice } from "@/components/editor/alerts/connection-notice";
47
47
  import { kernelStartupErrorAtom } from "@/core/errors/state";
48
- import type { RunEvent } from "@/core/host/protocol";
48
+ import type { RunEvent } from "@marimo-team/client/protocol";
49
49
  import type { NotificationPayload } from "@/core/kernel/messages";
50
50
  import { useRuntimeManager } from "@/core/runtime/config";
51
51
  import { initialRunCompletedAtom } from "../../kernel/state";
@@ -1 +0,0 @@
1
- import{n as e}from"./feedback-button-DaNc3uJa.js";export{e as FeedbackModal};