@marimo-team/islands 0.26.1-dev83 → 0.26.1-dev84

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 (80) hide show
  1. package/dist/{ConnectedDataExplorerComponent-yQVBQBUW.js → ConnectedDataExplorerComponent-CO9uVewH.js} +12 -12
  2. package/dist/{ErrorBoundary-DqCVIA2k.js → ErrorBoundary-T8CwNebX.js} +18 -18
  3. package/dist/{abnfDiagram-VCTEODGH-Ck_lXwQR.js → abnfDiagram-VCTEODGH-Ba0MYVW8.js} +2 -2
  4. package/dist/{any-language-editor-Cx4idbgX.js → any-language-editor-BNe8do3C.js} +2 -2
  5. package/dist/{architectureDiagram-5GKGNRK7-XeVhic7Z.js → architectureDiagram-5GKGNRK7-7MqAehef.js} +1 -1
  6. package/dist/{assertNever-473SFxLt.js → assertNever-5vhHGKOK.js} +2 -2
  7. package/dist/{chat-ui-D1mRz9h6.js → chat-ui-CjZbdpzb.js} +18 -18
  8. package/dist/{check-DmTIavbZ.js → check-DUIc04aK.js} +1 -1
  9. package/dist/{chunk-IMKFNOWR-DdQni67K.js → chunk-IMKFNOWR-CAWA0HGB.js} +1 -1
  10. package/dist/{chunk-SHT3W25Y-BdK-vMct.js → chunk-SHT3W25Y-BIwVQjG5.js} +1 -1
  11. package/dist/{chunk-SVP7TREG-cpFZk4Ca.js → chunk-SVP7TREG-Cux251TB.js} +1 -1
  12. package/dist/{chunk-TICWLB2K-DDgQFRgT.js → chunk-TICWLB2K-DJVQ6khO.js} +1 -1
  13. package/dist/{classDiagram-ZZMXUADV-DeojX9X4.js → classDiagram-ZZMXUADV-Cwve77ev.js} +2 -2
  14. package/dist/{classDiagram-v2-VYDZK3BY-DPfTAiQ6.js → classDiagram-v2-VYDZK3BY-BAeHKXmD.js} +2 -2
  15. package/dist/{code-visibility-Bg6LdTgJ.js → code-visibility-BBgRhs2A.js} +17 -17
  16. package/dist/{common-BXohsH8R.js → common-BF30ifb8.js} +3138 -3130
  17. package/dist/{config-D-lhQq-h.js → config-CShkLThS.js} +35 -33
  18. package/dist/{copy-icon-DuxRkh7T.js → copy-icon-CmNLxT5_.js} +2 -2
  19. package/dist/{createReducer-D3pBhIVD.js → createReducer-BUQhgLOI.js} +5 -5
  20. package/dist/{cynefinDiagram-5FMLGOSQ-DyY9TvuI.js → cynefinDiagram-5FMLGOSQ-t4eEkPJh.js} +1 -1
  21. package/dist/{dagre-GXQ25YYZ-BPCOgtKg.js → dagre-GXQ25YYZ-IuZuI28B.js} +1 -1
  22. package/dist/{data-grid-overlay-editor-A_0tSQlT.js → data-grid-overlay-editor-ChntsIBb.js} +1 -1
  23. package/dist/{diagram-S7CK7UJ4-KaF-C6kd.js → diagram-S7CK7UJ4-D8R5Q_ok.js} +1 -1
  24. package/dist/{diagram-UQ7AKVKN-DkeqoSvK.js → diagram-UQ7AKVKN-BGuMPsr-.js} +1 -1
  25. package/dist/{diagram-VX7I27RA-DExolTAf.js → diagram-VX7I27RA-BkTtpO8P.js} +1 -1
  26. package/dist/{diagram-Z3DM3KII-BioFuBF3.js → diagram-Z3DM3KII-C0__Mxfm.js} +1 -1
  27. package/dist/{dialog-CvyFEwby.js → dialog-BvjfalZ9.js} +30 -30
  28. package/dist/{dropdown-menu-BiXHfje7.js → dropdown-menu-D0DeN-aL.js} +637 -637
  29. package/dist/{ebnfDiagram-PWID7BFC-BSb9k1ed.js → ebnfDiagram-PWID7BFC-CSESPZoz.js} +2 -2
  30. package/dist/{erDiagram-RLTQ6QDP-PWA30a_r.js → erDiagram-RLTQ6QDP-DsDTtabH.js} +1 -1
  31. package/dist/{error-banner-B9HQMSaH.js → error-banner-CXLjTW24.js} +60 -65
  32. package/dist/{error-entries-P6Qpq6wP.js → error-entries-CsXAdy1j.js} +112 -112
  33. package/dist/{feedback-button-DSC9SNgL.js → feedback-button-nmOvfn22.js} +7 -7
  34. package/dist/{flowDiagram-HODETNUW-BPtD__Zz.js → flowDiagram-HODETNUW-qxDPYbfV.js} +2 -2
  35. package/dist/{formats-BF95BoCT.js → formats-BRDSQgKN.js} +1 -1
  36. package/dist/{glide-data-editor-NVoO9114.js → glide-data-editor-SkR9hqZZ.js} +11 -11
  37. package/dist/{glide-utils-iHKKQPJ8.js → glide-utils-CD8BaFTm.js} +2 -2
  38. package/dist/{globals-L7tZEIcx.js → globals-BjiU5aEs.js} +3 -3
  39. package/dist/{html-to-image-DhrFZL7t.js → html-to-image-CwpapHNl.js} +1059 -1059
  40. package/dist/{infoDiagram-27XIBGKW-SJuilBEE.js → infoDiagram-27XIBGKW-B5hq8RM_.js} +1 -1
  41. package/dist/{ishikawaDiagram-5VMMS53U-DjzyxMr8.js → ishikawaDiagram-5VMMS53U-DkHc_9ET.js} +1 -1
  42. package/dist/{kanban-definition-UXKFOSKX-D2_qopGt.js → kanban-definition-UXKFOSKX-CqkTFXmU.js} +1 -1
  43. package/dist/main.js +423 -423
  44. package/dist/{mermaid-DcowNmCx.js → mermaid-pmVHDUQA.js} +34 -34
  45. package/dist/{mindmap-definition-YA3MSWOX-pEra10M0.js → mindmap-definition-YA3MSWOX-D6cNa__z.js} +1 -1
  46. package/dist/{number-overlay-editor-CjeU_gt8.js → number-overlay-editor-GjrMTG9X.js} +1 -1
  47. package/dist/{pegDiagram-XKGWAZYB-CHOPKVOf.js → pegDiagram-XKGWAZYB-CmWJX_s1.js} +2 -2
  48. package/dist/{pencil-FAv6JUvp.js → pencil-CxMgOe04.js} +1 -1
  49. package/dist/{pieDiagram-E7YTZNPT-yGDhsyEN.js → pieDiagram-E7YTZNPT-CAQAxHah.js} +1 -1
  50. package/dist/{process-output-CBPqVQBu.js → process-output-ztSj9cDn.js} +4 -4
  51. package/dist/{railroadDiagram-O6MQD6OU-CeKEPdyc.js → railroadDiagram-O6MQD6OU-jlSsiQg3.js} +2 -2
  52. package/dist/{requirementDiagram-BXWQKSXE-DSAbAzKe.js → requirementDiagram-BXWQKSXE-DkDjfPhn.js} +1 -1
  53. package/dist/{reveal-component-D8H5fBkv.js → reveal-component-BrZbx6s7.js} +11 -11
  54. package/dist/{select-BszV-bbI.js → select-CEnB18uc.js} +350 -350
  55. package/dist/{sequenceDiagram-WJ2MYXX4-DVhWj_9H.js → sequenceDiagram-WJ2MYXX4-DLywsGCW.js} +1 -1
  56. package/dist/{spec-CRfw-lOm.js → spec-Dz-Avv1m.js} +4 -4
  57. package/dist/{stateDiagram-D77RDMKH-CDQ2MltG.js → stateDiagram-D77RDMKH-DUmlKwYU.js} +2 -2
  58. package/dist/{stateDiagram-v2-MP3YSRHH-BQmvwBaz.js → stateDiagram-v2-MP3YSRHH-D646KiXs.js} +2 -2
  59. package/dist/{static-state-BtDNJuc2.js → static-state-DhVFm8Z6.js} +6 -6
  60. package/dist/{swimlanes-42K2YHIH-DLOUTCEL.js → swimlanes-42K2YHIH-L7B1GphF.js} +1 -1
  61. package/dist/{swimlanesDiagram-VR7AAH4N-BVKrkNJ6.js → swimlanesDiagram-VR7AAH4N-DEu2wxtC.js} +2 -2
  62. package/dist/{timeline-definition-24CTP7MA-Cb2JoCSd.js → timeline-definition-24CTP7MA-DDPyx1yG.js} +1 -1
  63. package/dist/{toast-QsOAIPfq.js → toast-BTjH6fIf.js} +187 -187
  64. package/dist/{tooltip-BQZ-Bm6h.js → tooltip-DyLdBIM4.js} +73 -73
  65. package/dist/{use-restore-focus-DT1TZACX.js → use-restore-focus-DJ_-uSn_.js} +1340 -1339
  66. package/dist/{useDateFormatter-D3gyMY-g.js → useDateFormatter-HpKD0jEC.js} +2 -2
  67. package/dist/{useDeepCompareMemoize-CO6rO5Mq.js → useDeepCompareMemoize-CHx-NxMl.js} +1 -1
  68. package/dist/{useLifecycle-C9UTzCY8.js → useLifecycle-tPpAt-OE.js} +1 -1
  69. package/dist/{vega-component-i5lZ23n7.js → vega-component-BxJFcD2G.js} +6 -6
  70. package/dist/{vennDiagram-4TSXK5OY-Cm3EcCcP.js → vennDiagram-4TSXK5OY-CRwWeb7g.js} +1 -1
  71. package/dist/{wardleyDiagram-VM6X3IG4-DjlUs2CC.js → wardleyDiagram-VM6X3IG4-DVlG9eoq.js} +1 -1
  72. package/dist/{xychartDiagram-S5SC5T6Z-DxNDul9l.js → xychartDiagram-S5SC5T6Z-CM32AISp.js} +1 -1
  73. package/package.json +1 -1
  74. package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +240 -93
  75. package/src/components/editor/errors/send-error-report-button.tsx +139 -41
  76. package/src/core/notebook/replica/__tests__/fixtures.ts +1 -0
  77. package/src/core/notebook/replica/backend.ts +4 -1
  78. package/src/core/session/active-notebook.ts +6 -0
  79. package/src/core/transports/__tests__/static.test.ts +21 -18
  80. package/src/core/transports/static.ts +1 -0
@@ -1,15 +1,82 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
- import { useAtomValue } from "jotai";
4
- import { SendIcon } from "lucide-react";
3
+ import type { JsonValue } from "@marimo-team/client/protocol";
4
+ import { type ExtractAtomValue, useAtomValue } from "jotai";
5
+ import { ChevronDownIcon, SendIcon } from "lucide-react";
5
6
  import { useState } from "react";
6
- import { Button } from "@/components/ui/button";
7
- import { attachmentLabel, useNotebookAttachments } from "@/core/notebook";
8
7
  import { agentToast } from "@/components/editor/agent-toast";
8
+ import { Button } from "@/components/ui/button";
9
+ import {
10
+ DropdownMenu,
11
+ DropdownMenuContent,
12
+ DropdownMenuItem,
13
+ DropdownMenuSeparator,
14
+ DropdownMenuTrigger,
15
+ } from "@/components/ui/dropdown-menu";
9
16
  import { pairConfigAtom } from "@/core/config/pair";
10
- import { stableSessionIdAtom } from "@/core/kernel/session";
11
- import { API } from "@/core/network/api";
12
- import { HTTPError, prettyError } from "@/utils/errors";
17
+ import { attachmentLabel, useNotebookAttachments } from "@/core/notebook";
18
+ import {
19
+ activeNotebookAtom,
20
+ activeNotebookBackendAtom,
21
+ } from "@/core/session/active-notebook";
22
+ import { uniqueBy } from "@/utils/arrays";
23
+ import { prettyError } from "@/utils/errors";
24
+
25
+ const MAX_MESSAGE_BYTES = 65_536;
26
+
27
+ type NotebookBackend = NonNullable<
28
+ ExtractAtomValue<typeof activeNotebookBackendAtom>
29
+ >;
30
+
31
+ function encodeReport(content: unknown): JsonValue {
32
+ const encoded = JSON.stringify(content);
33
+ if (encoded === undefined) {
34
+ throw new Error("The report must be a JSON value.");
35
+ }
36
+ if (new TextEncoder().encode(encoded).byteLength > MAX_MESSAGE_BYTES) {
37
+ throw new Error("The report exceeds 65,536 bytes as JSON.");
38
+ }
39
+ return JSON.parse(encoded) as JsonValue;
40
+ }
41
+
42
+ /** Sends the report and shows the outcome as a toast. Never rejects. */
43
+ async function sendErrorReport({
44
+ backend,
45
+ notebookId,
46
+ content,
47
+ to,
48
+ setSending,
49
+ }: {
50
+ backend: NotebookBackend;
51
+ notebookId: string;
52
+ content: () => unknown;
53
+ to: string | null;
54
+ setSending: (sending: boolean) => void;
55
+ }): Promise<void> {
56
+ setSending(true);
57
+ try {
58
+ const result = await backend.notebook(notebookId).emit({
59
+ type: "marimo.agents.message.v1",
60
+ data: {
61
+ message: encodeReport(content()),
62
+ to,
63
+ sender: "marimo error report",
64
+ },
65
+ });
66
+ if (!result.ok) {
67
+ throw new Error(result.problem.detail ?? result.problem.title);
68
+ }
69
+ agentToast({ title: "Sent" });
70
+ } catch (error) {
71
+ agentToast({
72
+ variant: "danger",
73
+ title: "Could not send error",
74
+ description: prettyError(error),
75
+ });
76
+ } finally {
77
+ setSending(false);
78
+ }
79
+ }
13
80
 
14
81
  export function SendErrorReportButton({
15
82
  getContent,
@@ -17,50 +84,81 @@ export function SendErrorReportButton({
17
84
  getContent: () => unknown;
18
85
  }) {
19
86
  const hostEnabled = useAtomValue(pairConfigAtom)?.hostEnabled;
20
- const agents = useNotebookAttachments("agent");
21
- const stableSessionId = useAtomValue(stableSessionIdAtom);
87
+ const attachments = useNotebookAttachments("agent");
88
+ const notebook = useAtomValue(activeNotebookAtom);
89
+ const backend = useAtomValue(activeNotebookBackendAtom);
22
90
  const [sending, setSending] = useState(false);
91
+ const agents = uniqueBy(
92
+ attachments.flatMap((attachment) =>
93
+ attachment.identity
94
+ ? [{ id: attachment.identity, name: attachmentLabel(attachment) }]
95
+ : [],
96
+ ),
97
+ (agent) => agent.id,
98
+ );
23
99
 
24
- if (!hostEnabled) {
100
+ if (
101
+ !hostEnabled ||
102
+ !notebook?.operations.includes("notebook.emit") ||
103
+ !backend ||
104
+ agents.length === 0
105
+ ) {
25
106
  return null;
26
107
  }
27
108
 
28
- const send = async () => {
29
- if (sending || agents.length === 0 || !stableSessionId) {
109
+ const send = async (to: string | null) => {
110
+ if (sending) {
30
111
  return;
31
112
  }
32
- setSending(true);
33
- try {
34
- await API.post<unknown, string>(
35
- `/pair/notebooks/${encodeURIComponent(stableSessionId)}/messages`,
36
- getContent(),
37
- );
38
- agentToast({
39
- title: `Sent to ${agents.map(attachmentLabel).join(", ")}`,
40
- });
41
- } catch (error) {
42
- agentToast({
43
- variant: "danger",
44
- title:
45
- error instanceof HTTPError && error.status === 409
46
- ? "No agent attached"
47
- : "Could not send error",
48
- description: prettyError(error),
49
- });
50
- } finally {
51
- setSending(false);
52
- }
113
+ await sendErrorReport({
114
+ backend,
115
+ notebookId: notebook.id,
116
+ content: getContent,
117
+ to,
118
+ setSending,
119
+ });
53
120
  };
54
121
 
55
- return (
56
- <Button
57
- size="xs"
58
- variant="outline"
59
- disabled={sending || agents.length === 0 || !stableSessionId}
60
- onClick={send}
61
- >
122
+ const label = (
123
+ <>
62
124
  <SendIcon className="h-3 w-3 mr-2" />
63
125
  Send error to agent
64
- </Button>
126
+ </>
127
+ );
128
+ if (agents.length === 1) {
129
+ return (
130
+ <Button
131
+ size="xs"
132
+ variant="outline"
133
+ disabled={sending}
134
+ onClick={() => send(agents[0].id)}
135
+ >
136
+ {label}
137
+ </Button>
138
+ );
139
+ }
140
+
141
+ return (
142
+ <DropdownMenu>
143
+ <DropdownMenuTrigger asChild={true}>
144
+ <Button size="xs" variant="outline" disabled={sending}>
145
+ {label}
146
+ <ChevronDownIcon className="h-3 w-3 ml-2" />
147
+ </Button>
148
+ </DropdownMenuTrigger>
149
+ <DropdownMenuContent align="start">
150
+ {agents.map(({ id, name }) => (
151
+ <DropdownMenuItem key={id} onSelect={() => send(id)}>
152
+ {agents.some((other) => other.id !== id && other.name === name)
153
+ ? `${name} (${id})`
154
+ : name}
155
+ </DropdownMenuItem>
156
+ ))}
157
+ <DropdownMenuSeparator />
158
+ <DropdownMenuItem onSelect={() => send(null)}>
159
+ Send to all agents
160
+ </DropdownMenuItem>
161
+ </DropdownMenuContent>
162
+ </DropdownMenu>
65
163
  );
66
164
  }
@@ -57,6 +57,7 @@ export function fakeBackend({
57
57
  transport,
58
58
  notebook: (notebookId) => ({
59
59
  edit: (...args) => edit(notebookId, ...args),
60
+ emit: vi.fn<Commands["emit"]>(),
60
61
  save: (...args) => save(notebookId, ...args),
61
62
  run: (...args) => run(notebookId, ...args),
62
63
  input: (...args) => input(notebookId, ...args),
@@ -15,7 +15,10 @@ export interface NotebookBackend {
15
15
  */
16
16
  notebook(
17
17
  id: NotebookId,
18
- ): Pick<NotebookClient, "edit" | "save" | "run" | "input" | "interrupt">;
18
+ ): Pick<
19
+ NotebookClient,
20
+ "edit" | "emit" | "save" | "run" | "input" | "interrupt"
21
+ >;
19
22
  /** Whether the host is reachable before an explicit reconnect. Absent means always. */
20
23
  checkHealth?(): Promise<boolean>;
21
24
  }
@@ -10,6 +10,12 @@ export const activeNotebookReplicaAtom = atom<NotebookReplica | null>(null);
10
10
  /** Display state published once per frame by the mounted session. */
11
11
  export const activeNotebookFrameAtom = atom<ReplicaFrame | null>(null);
12
12
 
13
+ /** The identity and operations advertised by the ready notebook. */
14
+ export const activeNotebookAtom = atom((get) => {
15
+ const replica = get(activeNotebookReplicaAtom);
16
+ return replica === null ? null : get(replica.notebookAtom);
17
+ });
18
+
13
19
  /** The last analysis, kept while the host analyzes a newer revision. */
14
20
  export const notebookAnalysisAtom = atom((get) => {
15
21
  const replica = get(activeNotebookReplicaAtom);
@@ -206,25 +206,28 @@ describe("static notebook backend", () => {
206
206
  expect(events.at(-1)).toEqual({ event: "ready", id: "static", data: {} });
207
207
  });
208
208
 
209
- it.each(["edit", "save"] as const)(
210
- "rejects direct %s commands",
211
- async (operation) => {
212
- const backend = createStaticNotebookBackend(snapshot());
213
- const client = backend.notebook(snapshot().notebook.id);
214
- const result =
215
- operation === "edit" ? await client.edit([]) : await client.save();
216
- expect(result).toEqual({
217
- ok: false,
209
+ it.each([
210
+ ["edit", (client) => client.edit([])],
211
+ ["emit", (client) => client.emit({ type: "example.message", data: null })],
212
+ ["save", (client) => client.save()],
213
+ ] satisfies [
214
+ string,
215
+ (client: ReturnType<NotebookBackend["notebook"]>) => Promise<unknown>,
216
+ ][])("rejects direct %s commands", async (_operation, send) => {
217
+ const backend = createStaticNotebookBackend(snapshot());
218
+ const client = backend.notebook(snapshot().notebook.id);
219
+ const result = await send(client);
220
+ expect(result).toEqual({
221
+ ok: false,
222
+ status: 501,
223
+ problem: {
224
+ type: "urn:marimo:problem:unsupported-operation",
225
+ title: "Unsupported operation",
218
226
  status: 501,
219
- problem: {
220
- type: "urn:marimo:problem:unsupported-operation",
221
- title: "Unsupported operation",
222
- status: 501,
223
- detail: "Static notebooks do not support mutations",
224
- },
225
- });
226
- },
227
- );
227
+ detail: "Static notebooks do not support mutations",
228
+ },
229
+ });
230
+ });
228
231
 
229
232
  it("respects cancellation before opening, during delivery, and for commands", async () => {
230
233
  const backend = createStaticNotebookBackend(snapshot());
@@ -178,6 +178,7 @@ export function createStaticNotebookBackend(
178
178
  };
179
179
  return {
180
180
  edit: (_changes, options) => unsupported(options),
181
+ emit: (_event, options) => unsupported(options),
181
182
  save: unsupported,
182
183
  run: unsupported,
183
184
  input: (_inputId, _reply, options) => unsupported(options),