@marimo-team/islands 0.25.3-dev413 → 0.25.3-dev416

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 (28) hide show
  1. package/dist/{ErrorBoundary-s3y6sc8K.js → ErrorBoundary-BY4PeenT.js} +1 -1
  2. package/dist/{code-visibility-CRGVFzTE.js → code-visibility-1wtkbKPI.js} +1 -1
  3. package/dist/{common-D_i-hATC.js → common-tsgJ9tSZ.js} +1 -1
  4. package/dist/{data-grid-overlay-editor-DS-udUg6.js → data-grid-overlay-editor-CMsUjGiE.js} +1 -1
  5. package/dist/{feedback-button-D175ATV-.js → feedback-button-RuYO6BFL.js} +2 -2
  6. package/dist/{glide-data-editor-BZczmk1g.js → glide-data-editor-Du1g3HJZ.js} +3 -3
  7. package/dist/{globals-CDMCoZBa.js → globals-D-pghEVY.js} +1 -1
  8. package/dist/main.js +153 -176
  9. package/dist/{number-overlay-editor-DIYw9-Ju.js → number-overlay-editor-CBmRSVfZ.js} +1 -1
  10. package/dist/{reveal-component-ChYfcWgk.js → reveal-component-Dg0LNdiW.js} +2 -2
  11. package/dist/style.css +1 -1
  12. package/package.json +1 -1
  13. package/src/__mocks__/requests.ts +0 -1
  14. package/src/components/pages/edit-page.tsx +0 -1
  15. package/src/components/variables/__tests__/variables-table.test.tsx +75 -0
  16. package/src/components/variables/variables-table.tsx +18 -10
  17. package/src/core/islands/bootstrap.ts +0 -2
  18. package/src/core/islands/bridge.ts +0 -5
  19. package/src/core/kernel/__tests__/handlers.test.ts +0 -2
  20. package/src/core/kernel/handlers.ts +3 -47
  21. package/src/core/network/requests-network.ts +0 -9
  22. package/src/core/network/requests-static.ts +0 -4
  23. package/src/core/network/requests-toasting.tsx +0 -1
  24. package/src/core/network/types.ts +0 -2
  25. package/src/core/run-app.tsx +0 -1
  26. package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +0 -3
  27. package/src/core/session/useNotebookSession.tsx +3 -12
  28. package/src/core/wasm/bridge.ts +0 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.25.3-dev413",
3
+ "version": "0.25.3-dev416",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -22,7 +22,6 @@ export const MockRequestClient = {
22
22
  sendFormat: vi.fn().mockResolvedValue({ codes: {} }),
23
23
  sendShutdown: vi.fn().mockResolvedValue({}),
24
24
  sendRunScratchpad: vi.fn().mockResolvedValue({}),
25
- sendInstantiate: vi.fn().mockResolvedValue({}),
26
25
  sendCodeCompletionRequest: vi.fn().mockResolvedValue({ items: [] }),
27
26
  saveUserConfig: vi.fn().mockResolvedValue({}),
28
27
  saveAppConfig: vi.fn().mockResolvedValue({}),
@@ -21,7 +21,6 @@ const hideChrome = (() => {
21
21
  /** Own the notebook session and provide its document model to the editor and its chrome. */
22
22
  const EditPage = (props: Props) => {
23
23
  const { connection, reconnect, documentModel } = useNotebookSession({
24
- autoInstantiate: props.userConfig.runtime.auto_instantiate,
25
24
  sessionId: getSessionId(),
26
25
  });
27
26
  const app = (
@@ -108,3 +108,78 @@ describe("VariableTable cell links", () => {
108
108
  );
109
109
  });
110
110
  });
111
+
112
+ describe("VariableTable search", () => {
113
+ const importCell = cellId("Hbol");
114
+ const summaryCell = cellId("Xref");
115
+
116
+ const renderTable = () => {
117
+ store.set(
118
+ notebookAtom,
119
+ MockNotebook.notebookState({
120
+ cellData: {
121
+ [importCell]: { name: "_" },
122
+ [summaryCell]: { name: "report" },
123
+ },
124
+ }),
125
+ );
126
+ const variables: Variables = {
127
+ [variableName("reference")]: {
128
+ dataType: "str",
129
+ declaredBy: [importCell],
130
+ name: variableName("reference"),
131
+ usedBy: [],
132
+ value: "ORDER-1042",
133
+ },
134
+ [variableName("Total")]: {
135
+ dataType: "float",
136
+ declaredBy: [importCell],
137
+ name: variableName("Total"),
138
+ usedBy: [summaryCell],
139
+ value: "50.7",
140
+ },
141
+ [variableName("summary")]: {
142
+ dataType: "Html",
143
+ declaredBy: [summaryCell],
144
+ name: variableName("summary"),
145
+ usedBy: [],
146
+ value: null,
147
+ },
148
+ };
149
+ render(
150
+ <Provider store={store}>
151
+ <TooltipProvider>
152
+ <VariableTable
153
+ cellIds={[importCell, summaryCell]}
154
+ variables={variables}
155
+ />
156
+ </TooltipProvider>
157
+ </Provider>,
158
+ );
159
+ };
160
+
161
+ const search = (query: string) => {
162
+ fireEvent.change(screen.getByPlaceholderText("Search"), {
163
+ target: { value: query },
164
+ });
165
+ return ["reference", "Total", "summary"].filter(
166
+ (name) => screen.queryByText(name) !== null,
167
+ );
168
+ };
169
+
170
+ test("does not match the IDs of the declaring or using cells", () => {
171
+ renderTable();
172
+ expect(search("ref")).toEqual(["reference"]);
173
+ expect(search("Hbol")).toEqual([]);
174
+ });
175
+
176
+ test("matches name, type, value and cell names, ignoring case", () => {
177
+ renderTable();
178
+ expect(search("TOTAL")).toEqual(["Total"]);
179
+ expect(search("float")).toEqual(["Total"]);
180
+ expect(search("order-10")).toEqual(["reference"]);
181
+ expect(search("report")).toEqual(["Total", "summary"]);
182
+ expect(search("cell-0")).toEqual(["reference", "Total"]);
183
+ expect(search("")).toEqual(["reference", "Total", "summary"]);
184
+ });
185
+ });
@@ -110,15 +110,7 @@ const COLUMNS = [
110
110
  }),
111
111
  columnDefOf({
112
112
  id: ColumnIds.defs,
113
- // Include declaredByNames and usedByNames for filtering
114
- accessorFn: (v) =>
115
- [
116
- v.declaredBy,
117
- v.usedBy,
118
- v.name,
119
- v.declaredByNames,
120
- v.usedByNames,
121
- ] as const,
113
+ accessorFn: (v) => [v.declaredBy, v.usedBy, v.name] as const,
122
114
  enableSorting: true,
123
115
  sortingFn: "basic",
124
116
  header: ({ column }) => (
@@ -192,6 +184,21 @@ const COLUMNS = [
192
184
  }),
193
185
  ];
194
186
 
187
+ /**
188
+ * Search the text the table shows. Cell IDs are internal, so they are left
189
+ * out; cells are searched by name instead.
190
+ */
191
+ function matchesSearch(variable: ResolvedVariable, search: string): boolean {
192
+ const query = search.toLowerCase();
193
+ return [
194
+ variable.name,
195
+ variable.dataType,
196
+ variable.value,
197
+ ...variable.declaredByNames,
198
+ ...variable.usedByNames,
199
+ ].some((text) => text?.toLowerCase().includes(query));
200
+ }
201
+
195
202
  /**
196
203
  * Sort the variables by the specified column sort
197
204
  * Defaults to the order they are defined in the notebook
@@ -277,7 +284,8 @@ export const VariableTable: React.FC<Props> = memo(
277
284
  // Opt-out only
278
285
  return column.columnDef.enableGlobalFilter ?? true;
279
286
  },
280
- globalFilterFn: "auto",
287
+ globalFilterFn: (row, _columnId, search: string) =>
288
+ matchesSearch(row.original, search),
281
289
  // sorting
282
290
  manualSorting: true,
283
291
  locale: locale,
@@ -223,12 +223,10 @@ function handleNotification(
223
223
 
224
224
  case "kernel-ready":
225
225
  handleKernelReady(msg, {
226
- autoInstantiate: true,
227
226
  cells: notebookCells(store.get(notebookAtom)),
228
227
  resetCellRuntimes: actions.resetCellRuntimes,
229
228
  setLayoutData: Functions.NOOP,
230
229
  setCapabilities: Functions.NOOP,
231
- onError: Logger.error,
232
230
  });
233
231
  if (!window.customElements?.get(ISLAND_TAG_NAMES.ISLAND)) {
234
232
  defineCustomElement(ISLAND_TAG_NAMES.ISLAND, MarimoIslandElement);
@@ -338,11 +338,6 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
338
338
  return null;
339
339
  };
340
340
 
341
- public sendInstantiate: RunRequests["sendInstantiate"] =
342
- async (): Promise<null> => {
343
- return null;
344
- };
345
-
346
341
  public sendFunctionRequest: RunRequests["sendFunctionRequest"] = async (
347
342
  request,
348
343
  ): Promise<null> => {
@@ -81,7 +81,6 @@ describe("buildLayoutState", () => {
81
81
  capabilities: {
82
82
  terminal: false,
83
83
  },
84
- auto_instantiated: false,
85
84
  consumer_capabilities: { edit: true, interact: true },
86
85
  };
87
86
 
@@ -121,7 +120,6 @@ describe("buildLayoutState", () => {
121
120
  capabilities: {
122
121
  terminal: false,
123
122
  },
124
- auto_instantiated: false,
125
123
  consumer_capabilities: { edit: true, interact: true },
126
124
  };
127
125
 
@@ -7,7 +7,6 @@ import type { CellData } from "../cells/types";
7
7
  import { UI_ELEMENT_REGISTRY } from "../dom/uiregistry";
8
8
  import { deserializeLayoutState } from "../layout/layout";
9
9
  import type { LayoutData, LayoutState } from "../layout/state";
10
- import { getRequestClient } from "../network/requests";
11
10
  import { VirtualFileTracker } from "../static/virtual-file-tracker";
12
11
  import type {
13
12
  Capabilities,
@@ -41,23 +40,9 @@ export function buildLayoutState(
41
40
  return layoutState;
42
41
  }
43
42
 
44
- /**
45
- * Collect current UI element values from the registry.
46
- */
47
- function collectUIElementValues() {
48
- const objectIds: UIElementId[] = [];
49
- const values: unknown[] = [];
50
- UI_ELEMENT_REGISTRY.entries.forEach((entry, objectId) => {
51
- objectIds.push(objectId);
52
- values.push(entry.value);
53
- });
54
- return { objectIds, values };
55
- }
56
-
57
43
  export function handleKernelReady(
58
44
  data: KernelReadyData,
59
45
  opts: {
60
- autoInstantiate: boolean;
61
46
  /** The notebook's cells, as the host document provided them. */
62
47
  cells: CellData[];
63
48
  resetCellRuntimes: ReducerCellActions["resetCellRuntimes"];
@@ -66,30 +51,17 @@ export function handleKernelReady(
66
51
  data: LayoutData;
67
52
  }) => void;
68
53
  setCapabilities: (capabilities: Capabilities) => void;
69
- onError: (error: Error) => void;
70
54
  },
71
55
  ): LayoutState {
72
- const {
73
- autoInstantiate,
74
- cells,
75
- resetCellRuntimes,
76
- setLayoutData,
77
- setCapabilities,
78
- onError,
79
- } = opts;
80
- const { resumed, ui_values, capabilities, auto_instantiated } = data;
56
+ const { cells, resetCellRuntimes, setLayoutData, setCapabilities } = opts;
57
+ const { resumed, ui_values, capabilities } = data;
81
58
 
82
59
  resetCellRuntimes();
83
60
  const layoutState = buildLayoutState(data, cells, setLayoutData);
84
61
 
85
62
  setCapabilities(capabilities);
86
63
 
87
- // If the kernel was already instantiated server-side (e.g. run mode), we're done
88
- if (auto_instantiated) {
89
- return layoutState;
90
- }
91
-
92
- // If resumed, restore UI element values from kernel and we're done
64
+ // A resumed kernel holds the values its UI elements had.
93
65
  if (resumed) {
94
66
  for (const [objectId, value] of Objects.entries(ui_values || {})) {
95
67
  // @ts-expect-error - TODO: We need to fix the types for KernelReadyNotification["ui_values"]
@@ -97,24 +69,8 @@ export function handleKernelReady(
97
69
  const uiObjectId: UIElementId = objectId;
98
70
  UI_ELEMENT_REGISTRY.set(uiObjectId, value);
99
71
  }
100
- return layoutState;
101
72
  }
102
73
 
103
- // If we already have values for some objects, we should
104
- // send them to the kernel. This may happen after re-connecting
105
- // to the kernel after the computer wakes from sleep.
106
- const { objectIds, values } = collectUIElementValues();
107
-
108
- // Send instantiate request to kernel
109
- void getRequestClient()
110
- .sendInstantiate({
111
- objectIds,
112
- values,
113
- autoRun: autoInstantiate,
114
- })
115
- .catch((error) => {
116
- onError(new Error("Failed to instantiate", { cause: error }));
117
- });
118
74
  return layoutState;
119
75
  }
120
76
 
@@ -108,15 +108,6 @@ export function createNetworkRequests(): EditRequests & RunRequests {
108
108
  })
109
109
  .then(handleResponseReturnNull);
110
110
  },
111
- sendInstantiate: async (request) => {
112
- await waitForConnectionOpen();
113
- return getClient()
114
- .POST("/api/kernel/instantiate", {
115
- body: request,
116
- params: getParams(),
117
- })
118
- .then(handleResponseReturnNull);
119
- },
120
111
  sendCodeCompletionRequest: async (request) => {
121
112
  await waitForConnectionOpen();
122
113
  return getClient()
@@ -30,10 +30,6 @@ export function createStaticRequests(): EditRequests & RunRequests {
30
30
  Logger.log("Updating model values is not supported in static mode");
31
31
  return null;
32
32
  },
33
- sendInstantiate: async () => {
34
- Logger.log("Viewing as static notebook");
35
- return null;
36
- },
37
33
  sendFunctionRequest: async () => {
38
34
  showStaticNotebookToast();
39
35
  Logger.log("Function requests are not supported in static mode");
@@ -12,7 +12,6 @@ export function createErrorToastingRequests(
12
12
  const MESSAGES: Record<RequestKey, string> = {
13
13
  sendComponentValues: "Failed update value",
14
14
  sendModelValue: "Failed to update model value",
15
- sendInstantiate: "Failed to instantiate",
16
15
  sendFunctionRequest: "Failed to send function request",
17
16
  sendRestart: "Failed to restart",
18
17
  sendRunScratchpad: "Failed to run scratchpad",
@@ -72,7 +72,6 @@ export type SandboxResponse = schemas["SandboxResponse"];
72
72
  export type UpdateManifestRequest = schemas["UpdateManifestRequest"];
73
73
  export type SyncSandboxResponse = schemas["SyncSandboxResponse"];
74
74
  export type PackageOperationResponse = schemas["PackageOperationResponse"];
75
- export type InstantiateNotebookRequest = schemas["InstantiateNotebookRequest"];
76
75
  export type MarimoConfig = schemas["MarimoConfig"];
77
76
  export type MarimoFile = schemas["MarimoFile"];
78
77
  export type ListSecretKeysRequest = schemas["ListSecretKeysRequest"];
@@ -147,7 +146,6 @@ export type StorageDownloadRequest = schemas["StorageDownloadRequest"];
147
146
  export interface RunRequests {
148
147
  sendComponentValues: (request: UpdateUIElementValuesRequest) => Promise<null>;
149
148
  sendModelValue: (request: ModelRequest) => Promise<null>;
150
- sendInstantiate: (request: InstantiateNotebookRequest) => Promise<null>;
151
149
  sendFunctionRequest: (request: InvokeFunctionRequest) => Promise<null>;
152
150
  }
153
151
 
@@ -49,7 +49,6 @@ export const RunApp: React.FC<AppProps> = ({ appConfig, hideHeader }) => {
49
49
  }, [sendComponentValues]);
50
50
 
51
51
  const { connection, reconnect, documentModel } = useNotebookSession({
52
- autoInstantiate: true,
53
52
  sessionId: getSessionId(),
54
53
  });
55
54
 
@@ -166,7 +166,6 @@ function renderConnectionHook(
166
166
  () =>
167
167
  useNotebookSession({
168
168
  sessionId: SESSION_ID,
169
- autoInstantiate: false,
170
169
  }),
171
170
  { wrapper, reactStrictMode },
172
171
  );
@@ -451,7 +450,6 @@ it("does not mark the session connected on kernel-ready alone", async () => {
451
450
  app_config: { width: "normal" },
452
451
  kiosk: false,
453
452
  capabilities: { terminal: false },
454
- auto_instantiated: false,
455
453
  consumer_capabilities: { edit: true, interact: true },
456
454
  }),
457
455
  );
@@ -470,7 +468,6 @@ describe("connection notice", () => {
470
468
  const Connection = () => {
471
469
  const { reconnect } = useNotebookSession({
472
470
  sessionId: SESSION_ID,
473
- autoInstantiate: false,
474
471
  });
475
472
  return (
476
473
  <ConnectionNotice
@@ -3,7 +3,6 @@
3
3
  import { invalidatePackageData } from "@/core/packages/package-data";
4
4
  import { atom, useAtom, useAtomValue, useSetAtom, useStore } from "jotai";
5
5
  import { useEffect, useLayoutEffect, useMemo } from "react";
6
- import { useErrorBoundary } from "react-error-boundary";
7
6
  import { toast } from "@/components/ui/use-toast";
8
7
  import {
9
8
  getNotebook,
@@ -84,12 +83,8 @@ import { embeddedSnapshotAtom } from "./embedded";
84
83
  import { WebSocketClosedReason, ConnectionState } from "./types";
85
84
 
86
85
  /** Coordinate session startup and apply notifications to the editor. */
87
- export function useNotebookSession(opts: {
88
- sessionId: SessionId;
89
- autoInstantiate: boolean;
90
- }) {
91
- const { autoInstantiate, sessionId } = opts;
92
- const { showBoundary } = useErrorBoundary();
86
+ export function useNotebookSession(opts: { sessionId: SessionId }) {
87
+ const { sessionId } = opts;
93
88
  const store = useStore();
94
89
 
95
90
  const { handleCellMessage, reconcileDocument, resetCellRuntimes } =
@@ -142,16 +137,12 @@ export function useNotebookSession(opts: {
142
137
  return;
143
138
  }
144
139
  case "kernel-ready": {
145
- setInitialRunCompleted(
146
- Boolean(msg.data.resumed || msg.data.auto_instantiated),
147
- );
140
+ setInitialRunCompleted(msg.data.resumed);
148
141
  const layout = handleKernelReady(msg.data, {
149
- autoInstantiate,
150
142
  cells: notebookCells(store.get(notebookAtom)),
151
143
  resetCellRuntimes,
152
144
  setLayoutData,
153
145
  setCapabilities,
154
- onError: showBoundary,
155
146
  });
156
147
  store.set(savedLayoutAtom, layout);
157
148
  if (!msg.data.resumed) {
@@ -536,10 +536,6 @@ export class PyodideBridge implements RunRequests, EditRequests {
536
536
  return null;
537
537
  };
538
538
 
539
- public sendInstantiate: RunRequests["sendInstantiate"] = async () => {
540
- return null;
541
- };
542
-
543
539
  public sendFunctionRequest: RunRequests["sendFunctionRequest"] = async (
544
540
  request,
545
541
  ) => {