@marimo-team/islands 0.25.3-dev446 → 0.25.3-dev453
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-CBvdOZsh.js → ErrorBoundary-CIYMOu2p.js} +1 -1
- package/dist/assets/__vite-browser-external-D2z_TiUO.js +1 -0
- package/dist/assets/{worker-BUqfWMtI.js → worker-DLJ9P24O.js} +2 -2
- package/dist/{chat-ui-9oyUBL6M.js → chat-ui-DEHpKH2l.js} +17 -19
- package/dist/{code-visibility-BVsBD2bm.js → code-visibility-BQE60zOk.js} +7 -7
- package/dist/{common-Cz5kXzjw.js → common-DfUux6zJ.js} +4902 -4893
- package/dist/{data-grid-overlay-editor-B-PHwg_F.js → data-grid-overlay-editor-B9zW4oN1.js} +1 -1
- package/dist/{error-entries-CWdDf7iZ.js → error-entries-BG7ifiDg.js} +1368 -996
- package/dist/{feedback-button-DKfgWMh1.js → feedback-button-BEUh4iQQ.js} +129 -129
- package/dist/{glide-data-editor-BMrcgCud.js → glide-data-editor-CbdIXPTZ.js} +3 -3
- package/dist/{globals-vjja83iL.js → globals-BkxG-Y8L.js} +1 -1
- package/dist/{html-to-image-CexRSGAZ.js → html-to-image-9HLBGrIx.js} +4115 -4103
- package/dist/main.js +6562 -6671
- package/dist/{number-overlay-editor-CQvIdVeX.js → number-overlay-editor-BFzdth50.js} +1 -1
- package/dist/{process-output-hcyVRJCC.js → process-output-B8HPq5iZ.js} +2 -2
- package/dist/{reveal-component-DF7VRfN2.js → reveal-component-DK_-9fAX.js} +166 -167
- package/package.json +1 -1
- package/src/__mocks__/executions.ts +7 -4
- package/src/__mocks__/notebook.ts +20 -4
- package/src/components/editor/cell/DeleteButton.tsx +2 -2
- package/src/components/editor/cell/StopButton.tsx +2 -2
- package/src/components/editor/cell/useRunCells.ts +0 -3
- package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +1 -1
- package/src/components/editor/notebook-cell.tsx +4 -35
- package/src/components/editor/output/ansi-reduce.ts +124 -61
- package/src/components/editor/output/console/ConsoleOutput.tsx +7 -25
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +15 -44
- package/src/components/editor/renderers/cells-renderer.tsx +2 -5
- package/src/components/editor/renderers/grid-layout/__tests__/grid-layout.test.tsx +1 -1
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +3 -6
- package/src/components/editor/stdin-blocking-alert.tsx +14 -18
- package/src/components/scratchpad/scratchpad.test.tsx +1 -1
- package/src/components/scratchpad/scratchpad.tsx +5 -6
- package/src/components/slides/__tests__/cell-output-block.test.tsx +2 -2
- package/src/components/slides/__tests__/slide-cell-view.test.tsx +2 -2
- package/src/components/tracing/tracing-spec.ts +11 -1
- package/src/components/tracing/tracing.tsx +4 -0
- package/src/core/ai/context/providers/__tests__/cell-output.test.ts +10 -20
- package/src/core/ai/context/providers/__tests__/error.test.ts +5 -27
- package/src/core/ai/context/providers/cell-output.ts +4 -12
- package/src/core/cells/__tests__/cell.test.ts +1 -169
- package/src/core/cells/__tests__/cells.test.ts +32 -709
- package/src/core/cells/__tests__/clear-outputs.test.ts +21 -14
- package/src/core/cells/__tests__/collapseConsoleOutputs.test.ts +71 -2
- package/src/core/cells/__tests__/logs.test.ts +18 -29
- package/src/core/cells/__tests__/runs.test.ts +128 -431
- package/src/core/cells/__tests__/session.test.ts +9 -9
- package/src/core/cells/actions.ts +29 -7
- package/src/core/cells/cell.ts +1 -96
- package/src/core/cells/cells.ts +147 -117
- package/src/core/cells/collapseConsoleOutputs.tsx +71 -40
- package/src/core/cells/command-console.ts +46 -0
- package/src/core/cells/execution-console.ts +230 -0
- package/src/core/cells/focus.ts +9 -29
- package/src/core/cells/logs.ts +10 -2
- package/src/core/cells/runs.ts +62 -118
- package/src/core/cells/session.ts +2 -2
- package/src/core/cells/types.ts +30 -23
- package/src/core/cells/useAnswerPrompt.ts +29 -0
- package/src/core/errors/error-entries.ts +3 -4
- package/src/core/executions/__tests__/atoms.test.ts +6 -20
- package/src/core/executions/__tests__/input.test.ts +3 -3
- package/src/core/executions/__tests__/output-lifecycle.test.ts +2 -8
- package/src/core/executions/atoms.ts +2 -21
- package/src/core/executions/index.ts +2 -1
- package/src/core/executions/input.ts +4 -3
- package/src/core/executions/output.ts +3 -3
- package/src/core/islands/__tests__/bridge.test.ts +59 -0
- package/src/core/islands/bootstrap.ts +29 -12
- package/src/core/islands/bridge.ts +67 -13
- package/src/core/kernel/handlers.ts +2 -21
- package/src/core/kernel/messages.ts +0 -1
- package/src/core/network/types.ts +0 -1
- package/src/core/notebook/document/__tests__/codemirror.test.ts +1 -0
- package/src/core/notebook/replica/__tests__/executions.test.ts +1 -0
- package/src/core/notebook/replica/__tests__/replica.test.ts +113 -0
- package/src/core/notebook/replica/replica.ts +106 -12
- package/src/core/notebook/replica/resources/executions.ts +57 -4
- package/src/core/session/__tests__/backend.test.ts +2 -4
- package/src/core/session/__tests__/useNotebookReplica.hook.test.tsx +1 -0
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +601 -35
- package/src/core/session/useNotebookReplica.ts +20 -6
- package/src/core/session/useNotebookSession.tsx +63 -33
- package/src/core/static/virtual-file-tracker.ts +26 -8
- package/src/stories/layout/vertical/one-column.stories.tsx +18 -12
- package/dist/assets/__vite-browser-external-CpRgw4M_.js +0 -1
- package/src/components/editor/alerts/stdin-blocking-alert.tsx +0 -68
- package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +0 -703
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
/** The editor session's replica, following its backend while mounted. */
|
|
4
4
|
|
|
5
|
+
import type { Execution } from "@marimo-team/client/protocol";
|
|
6
|
+
import { consoleObservers } from "../cells/execution-console";
|
|
7
|
+
import { useReducerActions } from "../cells/cells";
|
|
5
8
|
import { useStore } from "jotai";
|
|
6
9
|
import { useEffect, useMemo } from "react";
|
|
7
10
|
import useEvent from "react-use-event-hook";
|
|
@@ -13,16 +16,17 @@ import {
|
|
|
13
16
|
createNotebookReplica,
|
|
14
17
|
type NotebookReplica,
|
|
15
18
|
} from "../notebook/replica";
|
|
16
|
-
import { VirtualFileTracker } from "../static/virtual-file-tracker";
|
|
17
19
|
import { activeNotebookReplicaAtom } from "./active-notebook";
|
|
18
20
|
import { createEditorBackend, type EditorBackendOptions } from "./backend";
|
|
19
21
|
|
|
20
22
|
type Options = EditorBackendOptions & {
|
|
23
|
+
onExecution: (execution: Execution) => void;
|
|
21
24
|
onNotification: (notification: NotificationPayload) => void;
|
|
22
25
|
};
|
|
23
26
|
|
|
24
27
|
export function useNotebookReplica(options: Options): NotebookReplica {
|
|
25
28
|
const store = useStore();
|
|
29
|
+
const { addLogs, startCellConsole } = useReducerActions();
|
|
26
30
|
const { static: isStatic, snapshot, transportType } = options;
|
|
27
31
|
const replica = useMemo(() => createNotebookReplica(store), [store]);
|
|
28
32
|
const url = useEvent(options.url);
|
|
@@ -30,6 +34,7 @@ export function useNotebookReplica(options: Options): NotebookReplica {
|
|
|
30
34
|
const notebookUrl = useEvent(options.notebookUrl);
|
|
31
35
|
const waitUntilReady = useEvent(options.waitUntilReady);
|
|
32
36
|
const checkHealth = useEvent(options.checkHealth);
|
|
37
|
+
const onExecution = useEvent(options.onExecution);
|
|
33
38
|
const onNotification = useEvent(options.onNotification);
|
|
34
39
|
// Opens nothing until the replica follows it.
|
|
35
40
|
const backend = useMemo(
|
|
@@ -59,11 +64,12 @@ export function useNotebookReplica(options: Options): NotebookReplica {
|
|
|
59
64
|
useEffect(() => {
|
|
60
65
|
store.set(activeNotebookReplicaAtom, replica);
|
|
61
66
|
const disconnect = replica.connect(backend, {
|
|
62
|
-
onExecution
|
|
63
|
-
VirtualFileTracker.INSTANCE.trackExecution(record),
|
|
67
|
+
...consoleObservers({ addLogs, startCellConsole }, onExecution),
|
|
64
68
|
// The host validates the envelope, not the native notification contents.
|
|
65
|
-
onNotification: (notification) =>
|
|
66
|
-
|
|
69
|
+
onNotification: (notification) => {
|
|
70
|
+
const data = notification as NotificationMessage;
|
|
71
|
+
onNotification({ data });
|
|
72
|
+
},
|
|
67
73
|
});
|
|
68
74
|
return () => {
|
|
69
75
|
disconnect();
|
|
@@ -71,7 +77,15 @@ export function useNotebookReplica(options: Options): NotebookReplica {
|
|
|
71
77
|
store.set(activeNotebookReplicaAtom, null);
|
|
72
78
|
}
|
|
73
79
|
};
|
|
74
|
-
}, [
|
|
80
|
+
}, [
|
|
81
|
+
replica,
|
|
82
|
+
backend,
|
|
83
|
+
store,
|
|
84
|
+
onNotification,
|
|
85
|
+
onExecution,
|
|
86
|
+
addLogs,
|
|
87
|
+
startCellConsole,
|
|
88
|
+
]);
|
|
75
89
|
|
|
76
90
|
return replica;
|
|
77
91
|
}
|
|
@@ -4,14 +4,10 @@ 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
6
|
import { toast } from "@/components/ui/use-toast";
|
|
7
|
-
import {
|
|
8
|
-
getNotebook,
|
|
9
|
-
notebookAtom,
|
|
10
|
-
useReducerActions,
|
|
11
|
-
} from "@/core/cells/cells";
|
|
7
|
+
import { notebookAtom, useReducerActions } from "@/core/cells/cells";
|
|
12
8
|
import { useStagedAICellsActions } from "@/core/ai/staged-cells";
|
|
13
9
|
import { followDocument } from "@/core/cells/document";
|
|
14
|
-
import type
|
|
10
|
+
import { SCRATCH_CELL_ID, type CellId } from "@/core/cells/ids";
|
|
15
11
|
import { AUTOCOMPLETER } from "@/core/codemirror/completion/Autocompleter";
|
|
16
12
|
import { createDocumentModel } from "@/core/notebook/document";
|
|
17
13
|
import type { NotificationPayload } from "@/core/kernel/messages";
|
|
@@ -53,18 +49,16 @@ import { useDatasetsActions } from "../datasets/state";
|
|
|
53
49
|
import { UI_ELEMENT_REGISTRY } from "../dom/uiregistry";
|
|
54
50
|
import { kernelStartupErrorAtom, useBannersActions } from "../errors/state";
|
|
55
51
|
import { FUNCTIONS_REGISTRY } from "../functions/FunctionRegistry";
|
|
56
|
-
import {
|
|
57
|
-
handleCellNotificationeration,
|
|
58
|
-
handleKernelReady,
|
|
59
|
-
handleRemoveUIElements,
|
|
60
|
-
} from "../kernel/handlers";
|
|
52
|
+
import { handleKernelReady, handleRemoveUIElements } from "../kernel/handlers";
|
|
61
53
|
import { queryParamHandlers } from "../kernel/queryParamHandlers";
|
|
62
54
|
import {
|
|
63
55
|
type SessionId,
|
|
64
56
|
type StableSessionId,
|
|
65
57
|
stableSessionIdAtom,
|
|
66
58
|
} from "../kernel/session";
|
|
67
|
-
import {
|
|
59
|
+
import { cellError } from "../executions/output";
|
|
60
|
+
import { getCellLogsForMessage } from "../cells/logs";
|
|
61
|
+
import { setCellBlocked } from "../executions";
|
|
68
62
|
import { initialRunCompletedAtom } from "../kernel/state";
|
|
69
63
|
import { useLayoutActions } from "../layout/state";
|
|
70
64
|
import { kioskModeAtom } from "../mode";
|
|
@@ -74,6 +68,7 @@ import type { RequestId } from "../network/DeferredRequestRegistry";
|
|
|
74
68
|
import { useRuntimeManager } from "../runtime/config";
|
|
75
69
|
import { SECRETS_REGISTRY } from "../secrets/request-registry";
|
|
76
70
|
import { isStaticNotebook } from "../static/static-state";
|
|
71
|
+
import { VirtualFileTracker } from "../static/virtual-file-tracker";
|
|
77
72
|
import {
|
|
78
73
|
DownloadStorage,
|
|
79
74
|
ListStorageEntries,
|
|
@@ -81,7 +76,8 @@ import {
|
|
|
81
76
|
import { useStorageActions } from "../storage/state";
|
|
82
77
|
import { useVariablesActions } from "../variables/state";
|
|
83
78
|
import type { VariableName } from "../variables/types";
|
|
84
|
-
import { activeDocumentModelAtom } from "./active-notebook";
|
|
79
|
+
import { activeDocumentModelAtom, confirmedDocumentAtom } from "./active-notebook";
|
|
80
|
+
import { executionSource } from "@/core/executions";
|
|
85
81
|
import { embeddedSnapshotAtom } from "./embedded";
|
|
86
82
|
import { WebSocketClosedReason, ConnectionState } from "./types";
|
|
87
83
|
|
|
@@ -91,14 +87,15 @@ export function useNotebookSession(opts: { sessionId: SessionId }) {
|
|
|
91
87
|
const store = useStore();
|
|
92
88
|
|
|
93
89
|
const {
|
|
94
|
-
|
|
90
|
+
setCellReusability,
|
|
91
|
+
showCommandOutput,
|
|
92
|
+
hideConsoleInputs,
|
|
95
93
|
clearDebuggerOutput,
|
|
96
|
-
handleCellMessage,
|
|
97
94
|
reconcileDocument,
|
|
98
95
|
resetCellRuntimes,
|
|
99
96
|
} = useReducerActions();
|
|
100
97
|
const { reconcileStagedCells } = useStagedAICellsActions();
|
|
101
|
-
const {
|
|
98
|
+
const { addExecution } = useRunsActions();
|
|
102
99
|
const setInitialRunCompleted = useSetAtom(initialRunCompletedAtom);
|
|
103
100
|
const { setVariables, setMetadata } = useVariablesActions();
|
|
104
101
|
const { addColumnPreview } = useDatasetsActions();
|
|
@@ -169,9 +166,6 @@ export function useNotebookSession(opts: { sessionId: SessionId }) {
|
|
|
169
166
|
return;
|
|
170
167
|
}
|
|
171
168
|
|
|
172
|
-
case "pdb-output":
|
|
173
|
-
showPdbOutput(msg.data);
|
|
174
|
-
return;
|
|
175
169
|
case "pdb-input": {
|
|
176
170
|
const { cell_id, input_id } = msg.data;
|
|
177
171
|
store.set(
|
|
@@ -184,8 +178,6 @@ export function useNotebookSession(opts: { sessionId: SessionId }) {
|
|
|
184
178
|
case "completed-run":
|
|
185
179
|
setInitialRunCompleted(true);
|
|
186
180
|
return;
|
|
187
|
-
case "execution":
|
|
188
|
-
return;
|
|
189
181
|
case "interrupted":
|
|
190
182
|
return;
|
|
191
183
|
|
|
@@ -221,20 +213,35 @@ export function useNotebookSession(opts: { sessionId: SessionId }) {
|
|
|
221
213
|
case "function-call-result":
|
|
222
214
|
FUNCTIONS_REGISTRY.resolve(msg.data.function_call_id, msg.data);
|
|
223
215
|
return;
|
|
224
|
-
case "
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
addCellNotification({
|
|
232
|
-
cellNotification: msg.data,
|
|
233
|
-
code: cellData.code,
|
|
216
|
+
case "console-inputs-cleared":
|
|
217
|
+
hideConsoleInputs({
|
|
218
|
+
cellId: msg.data.cell_id,
|
|
219
|
+
executionId: msg.data.execution_id,
|
|
220
|
+
inputIds: msg.data.input_ids,
|
|
234
221
|
});
|
|
235
222
|
return;
|
|
236
|
-
|
|
237
|
-
|
|
223
|
+
case "cell-op":
|
|
224
|
+
if (msg.data.status != null) {
|
|
225
|
+
setCellBlocked(
|
|
226
|
+
store,
|
|
227
|
+
msg.data.cell_id,
|
|
228
|
+
msg.data.status === "disabled-transitively",
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
if (msg.data.serialization !== undefined) {
|
|
232
|
+
setCellReusability({
|
|
233
|
+
cell_id: msg.data.cell_id,
|
|
234
|
+
serialization: msg.data.serialization,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
return;
|
|
238
|
+
case "callback-output":
|
|
239
|
+
VirtualFileTracker.INSTANCE.trackCallbackOutput(msg.data);
|
|
240
|
+
showCommandOutput(msg.data);
|
|
241
|
+
return;
|
|
242
|
+
case "pdb-output":
|
|
243
|
+
showCommandOutput(msg.data);
|
|
244
|
+
return;
|
|
238
245
|
case "variables":
|
|
239
246
|
const variableNames = msg.data.variables.map((v) => v.name);
|
|
240
247
|
setVariables(
|
|
@@ -425,6 +432,29 @@ export function useNotebookSession(opts: { sessionId: SessionId }) {
|
|
|
425
432
|
}
|
|
426
433
|
},
|
|
427
434
|
checkHealth: () => runtimeManager.reconcileFromHealth(),
|
|
435
|
+
onExecution: (record) => {
|
|
436
|
+
const cellId = (record.cell_id ?? SCRATCH_CELL_ID) as CellId;
|
|
437
|
+
const time = record.completed_at ?? record.started_at;
|
|
438
|
+
const timestamp =
|
|
439
|
+
time === null ? Date.now() / 1000 : Date.parse(time) / 1000;
|
|
440
|
+
if (record.status === "completed" && record.outcome?.kind === "error") {
|
|
441
|
+
getCellLogsForMessage({
|
|
442
|
+
cell_id: cellId,
|
|
443
|
+
timestamp,
|
|
444
|
+
output: {
|
|
445
|
+
channel: "marimo-error",
|
|
446
|
+
mimetype: "application/vnd.marimo+error",
|
|
447
|
+
data: [cellError(record.outcome.error)],
|
|
448
|
+
timestamp,
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
addExecution({
|
|
453
|
+
record,
|
|
454
|
+
code: executionSource(record, store.get(confirmedDocumentAtom)?.cells),
|
|
455
|
+
receivedAt: timestamp,
|
|
456
|
+
});
|
|
457
|
+
},
|
|
428
458
|
onNotification: (notification) => {
|
|
429
459
|
try {
|
|
430
460
|
handleNotification(notification);
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import type { Execution } from "@marimo-team/client/protocol";
|
|
4
4
|
import { type CellId, SCRATCH_CELL_ID } from "../cells/ids";
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
OutputMessage,
|
|
7
|
+
NotificationMessageData,
|
|
8
|
+
} from "../kernel/messages";
|
|
6
9
|
|
|
7
10
|
// Virtual files are of the form /@file/<file-name>.<extension>
|
|
8
11
|
const VIRTUAL_FILE_REGEX = /\/@file\/([^\s"&'/]+)\.([\dA-Za-z]+)/g;
|
|
@@ -23,15 +26,14 @@ export class VirtualFileTracker {
|
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
public virtualFiles = new Map<CellId, Set<string>>();
|
|
29
|
+
private callbackFiles = new Map<CellId, Set<string>>();
|
|
26
30
|
|
|
27
31
|
private constructor() {
|
|
28
32
|
// Private
|
|
29
33
|
}
|
|
30
34
|
|
|
31
|
-
public track(message:
|
|
32
|
-
|
|
33
|
-
this.trackValue(message.cell_id, message.output);
|
|
34
|
-
}
|
|
35
|
+
public track(message: { cell_id: CellId; output: OutputMessage }): void {
|
|
36
|
+
this.trackValue(message.cell_id, message.output);
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
public trackExecution(record: Execution): void {
|
|
@@ -45,17 +47,29 @@ export class VirtualFileTracker {
|
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
public trackCallbackOutput(
|
|
51
|
+
message: NotificationMessageData<"callback-output">,
|
|
52
|
+
): void {
|
|
53
|
+
if (message.replace || message.entries.length === 0) {
|
|
54
|
+
this.callbackFiles.delete(message.cell_id);
|
|
55
|
+
}
|
|
56
|
+
for (const entry of message.entries) {
|
|
57
|
+
this.trackValue(message.cell_id, entry, this.callbackFiles);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
48
61
|
private trackValue(
|
|
49
62
|
cellId: CellId,
|
|
50
63
|
output: { mimetype: string; data: unknown },
|
|
64
|
+
files = this.virtualFiles,
|
|
51
65
|
): void {
|
|
52
66
|
switch (output.mimetype) {
|
|
53
67
|
case "application/json":
|
|
54
68
|
case "text/html": {
|
|
55
|
-
const prev =
|
|
69
|
+
const prev = files.get(cellId);
|
|
56
70
|
const matches = findVirtualFiles(output.data);
|
|
57
71
|
prev?.forEach((file) => matches.add(file));
|
|
58
|
-
|
|
72
|
+
files.set(cellId, matches);
|
|
59
73
|
return;
|
|
60
74
|
}
|
|
61
75
|
default:
|
|
@@ -65,7 +79,10 @@ export class VirtualFileTracker {
|
|
|
65
79
|
|
|
66
80
|
public filenames(): string[] {
|
|
67
81
|
const set = new Set<string>();
|
|
68
|
-
for (const files of
|
|
82
|
+
for (const files of [
|
|
83
|
+
...this.virtualFiles.values(),
|
|
84
|
+
...this.callbackFiles.values(),
|
|
85
|
+
]) {
|
|
69
86
|
files.forEach((file) => set.add(file));
|
|
70
87
|
}
|
|
71
88
|
|
|
@@ -74,6 +91,7 @@ export class VirtualFileTracker {
|
|
|
74
91
|
|
|
75
92
|
public removeForCellId(cellId: CellId): void {
|
|
76
93
|
this.virtualFiles.delete(cellId);
|
|
94
|
+
this.callbackFiles.delete(cellId);
|
|
77
95
|
}
|
|
78
96
|
}
|
|
79
97
|
|
|
@@ -25,8 +25,24 @@ const LONG_REPR =
|
|
|
25
25
|
|
|
26
26
|
/** Show the long repr as the cell's result. */
|
|
27
27
|
function seedLongRepr(store: ReturnType<typeof createStore>, cellId: CellId) {
|
|
28
|
+
const record = MockExecutions.shown(cellId, {
|
|
29
|
+
mimetype: "text/plain",
|
|
30
|
+
data: LONG_REPR,
|
|
31
|
+
});
|
|
28
32
|
MockExecutions.seed(store, [
|
|
29
|
-
|
|
33
|
+
{
|
|
34
|
+
...record,
|
|
35
|
+
items: [
|
|
36
|
+
{
|
|
37
|
+
kind: "console",
|
|
38
|
+
id: "printed",
|
|
39
|
+
execution_id: record.id,
|
|
40
|
+
seq: 0,
|
|
41
|
+
name: "stdout",
|
|
42
|
+
text: "hello",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
30
46
|
]);
|
|
31
47
|
}
|
|
32
48
|
|
|
@@ -55,17 +71,7 @@ LongReprA()`,
|
|
|
55
71
|
},
|
|
56
72
|
cellIds: [cellId],
|
|
57
73
|
cellRuntime: {
|
|
58
|
-
[cellId]: createCellRuntimeState(
|
|
59
|
-
consoleOutputs: [
|
|
60
|
-
{
|
|
61
|
-
channel: "stdout",
|
|
62
|
-
mimetype: "text/plain",
|
|
63
|
-
data: "hello",
|
|
64
|
-
timestamp: 1_686_863_705,
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
debuggerActive: false,
|
|
68
|
-
}),
|
|
74
|
+
[cellId]: createCellRuntimeState(),
|
|
69
75
|
},
|
|
70
76
|
cellHandles: {
|
|
71
77
|
[cellId]: createRef(),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./worker-BUqfWMtI.js";var t=/* @__PURE__ */ e(((e,t)=>{t.exports={}}));export default t();
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
-
|
|
3
|
-
import { atom, useAtomValue } from "jotai";
|
|
4
|
-
import { notebookAtom } from "@/core/cells/cells";
|
|
5
|
-
import { cellExecutionInputsAtom, cellExecutionView } from "@/core/executions";
|
|
6
|
-
import { pendingPdbInputAtom } from "@/core/codemirror/cells/debugger-state";
|
|
7
|
-
import { kioskModeAtom } from "@/core/mode";
|
|
8
|
-
import { Logger } from "@/utils/Logger";
|
|
9
|
-
import { Button } from "../../ui/button";
|
|
10
|
-
import { Kbd } from "../../ui/kbd";
|
|
11
|
-
import { FloatingAlert } from "./floating-alert";
|
|
12
|
-
|
|
13
|
-
// Atom to check if there is a cell with unresolved stdin
|
|
14
|
-
const hasBlockingStdinAtom = atom((get) => {
|
|
15
|
-
const notebook = get(notebookAtom);
|
|
16
|
-
const executions = get(cellExecutionInputsAtom);
|
|
17
|
-
if (!get(kioskModeAtom) && get(pendingPdbInputAtom) !== null) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Check each cell in order
|
|
22
|
-
for (const cellId of notebook.cellIds) {
|
|
23
|
-
// Check if the cell is idle and has unresolved stdin
|
|
24
|
-
const runtime = notebook.cellRuntime[cellId];
|
|
25
|
-
if (cellExecutionView(executions, cellId).status === "idle") {
|
|
26
|
-
const hasUnresolvedStdin = runtime.consoleOutputs.some(
|
|
27
|
-
(output) => output.channel === "stdin" && output.response === undefined,
|
|
28
|
-
);
|
|
29
|
-
if (hasUnresolvedStdin) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return false;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
export const StdinBlockingAlert: React.FC = () => {
|
|
39
|
-
const hasBlockingStdin = useAtomValue(hasBlockingStdinAtom);
|
|
40
|
-
|
|
41
|
-
const handleJumpToStdin = () => {
|
|
42
|
-
const el = document.querySelector<HTMLElement>("[data-stdin-blocking]");
|
|
43
|
-
if (el) {
|
|
44
|
-
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
45
|
-
requestAnimationFrame(() => {
|
|
46
|
-
el.focus();
|
|
47
|
-
});
|
|
48
|
-
} else {
|
|
49
|
-
Logger.error("No element with data-stdin-blocking found");
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<FloatingAlert title="Program waiting for input" show={hasBlockingStdin}>
|
|
55
|
-
<p>
|
|
56
|
-
The program is still running, but blocked on{" "}
|
|
57
|
-
<Kbd className="inline">stdin</Kbd>.
|
|
58
|
-
<Button
|
|
59
|
-
variant="link"
|
|
60
|
-
className="h-auto font-normal"
|
|
61
|
-
onClick={handleJumpToStdin}
|
|
62
|
-
>
|
|
63
|
-
Jump to the cell
|
|
64
|
-
</Button>
|
|
65
|
-
</p>
|
|
66
|
-
</FloatingAlert>
|
|
67
|
-
);
|
|
68
|
-
};
|