@marimo-team/islands 0.25.3-dev447 → 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-DVbdKroW.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-DmsDqWUx.js → code-visibility-BQE60zOk.js} +7 -7
- package/dist/{common-BDo_Jwoz.js → common-DfUux6zJ.js} +4902 -4893
- package/dist/{data-grid-overlay-editor-CpHB_knU.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-B_Wmi4to.js → feedback-button-BEUh4iQQ.js} +129 -129
- package/dist/{glide-data-editor-CMiIW5WP.js → glide-data-editor-CbdIXPTZ.js} +3 -3
- package/dist/{globals-DaC3pk9F.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-Dd4cOJ5I.js → number-overlay-editor-BFzdth50.js} +1 -1
- package/dist/{process-output-hcyVRJCC.js → process-output-B8HPq5iZ.js} +2 -2
- package/dist/{reveal-component-CTmvBdvu.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
package/src/core/cells/types.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import type { CellOutput } from "../executions";
|
|
4
4
|
import type { OutputMessage } from "../kernel/messages";
|
|
5
5
|
import type { CellConfig } from "../network/types";
|
|
6
|
+
import type { CommandConsole, CommandOutputMessage } from "./command-console";
|
|
6
7
|
import type { CellId } from "./ids";
|
|
7
8
|
import { DEFAULT_CELL_NAME } from "./names";
|
|
8
9
|
|
|
@@ -42,8 +43,7 @@ export function createCellRuntimeState(
|
|
|
42
43
|
state?: Partial<CellRuntimeState>,
|
|
43
44
|
): CellRuntimeState {
|
|
44
45
|
return {
|
|
45
|
-
|
|
46
|
-
debuggerActive: false,
|
|
46
|
+
embeddedConsole: [],
|
|
47
47
|
...state,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
@@ -61,34 +61,47 @@ export interface CellData {
|
|
|
61
61
|
config: CellConfig;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
/**
|
|
65
|
-
* What the kernel's cell-ops still own. Status, timing, and how a cell last
|
|
66
|
-
* ended come from the host's executions (see `@/core/executions`).
|
|
67
|
-
*
|
|
68
|
-
* TODO(MO-8407): Delete.
|
|
69
|
-
*/
|
|
64
|
+
/** Console presentation and editor-session hints for a cell. */
|
|
70
65
|
export interface CellRuntimeState {
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
|
|
66
|
+
/** Embedded console output until the notebook reports an execution. */
|
|
67
|
+
embeddedConsole: ConsoleOutputMessage[];
|
|
68
|
+
commandConsole?: CommandConsole;
|
|
69
|
+
/** Last write hidden by this browser for each command transcript. */
|
|
70
|
+
clearedCommandIds?: Partial<Record<CommandOutputMessage["op"], string>>;
|
|
71
|
+
/** Settled input IDs hidden by this execution’s clear_console(). */
|
|
72
|
+
clearedConsoleInputs?: { executionId: string; ids: ReadonlySet<string> };
|
|
73
|
+
/** Only the browser that answered a prompt knows its non-secret reply. */
|
|
74
|
+
answers?: ReadonlyMap<string, string>;
|
|
75
|
+
/** Rows this browser hid, except prompts that were still pending. */
|
|
76
|
+
clearedConsole?: {
|
|
77
|
+
executionId: string;
|
|
78
|
+
seq: number;
|
|
79
|
+
prompts: ReadonlySet<string>;
|
|
80
|
+
};
|
|
76
81
|
/** serialization message. TODO(MO-8414) */
|
|
77
82
|
serialization?: string | null;
|
|
78
83
|
}
|
|
79
84
|
|
|
85
|
+
/** The cell runtime fields available to renderers. */
|
|
86
|
+
export interface CellRuntimeView extends Pick<
|
|
87
|
+
CellRuntimeState,
|
|
88
|
+
"serialization"
|
|
89
|
+
> {
|
|
90
|
+
consoleOutputs: ConsoleOutputMessage[];
|
|
91
|
+
}
|
|
92
|
+
|
|
80
93
|
/** A cell as the layout renderers take it, with what it shows from the host. */
|
|
81
94
|
export type RuntimeCell = CellData &
|
|
82
|
-
|
|
95
|
+
CellRuntimeView & {
|
|
83
96
|
output: CellOutput | null;
|
|
84
97
|
};
|
|
85
98
|
|
|
86
99
|
export type WithResponse<T> = T & {
|
|
87
100
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
101
|
+
* The locally accepted reply. Undefined means the prompt is pending.
|
|
102
|
+
* Null closes the prompt when its answer is unavailable or secret.
|
|
90
103
|
*/
|
|
91
|
-
response?: string;
|
|
104
|
+
response?: string | null;
|
|
92
105
|
};
|
|
93
106
|
|
|
94
107
|
/**
|
|
@@ -99,9 +112,3 @@ export type WithResponse<T> = T & {
|
|
|
99
112
|
export type ConsoleOutputMessage = WithResponse<OutputMessage> & {
|
|
100
113
|
id?: number;
|
|
101
114
|
};
|
|
102
|
-
|
|
103
|
-
export function withPdbOutput(cell: CellRuntimeState): CellRuntimeState {
|
|
104
|
-
return cell?.pdbOutput?.length
|
|
105
|
-
? { ...cell, consoleOutputs: [...cell.consoleOutputs, ...cell.pdbOutput] }
|
|
106
|
-
: cell;
|
|
107
|
-
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import { useStore } from "jotai";
|
|
3
|
+
import useEvent from "react-use-event-hook";
|
|
4
|
+
import { Logger } from "@/utils/Logger";
|
|
5
|
+
import { replyInput } from "@/core/executions";
|
|
6
|
+
import { consoleExecution } from "./execution-console";
|
|
7
|
+
import { useCellActions } from "./actions";
|
|
8
|
+
import type { CellId } from "./ids";
|
|
9
|
+
|
|
10
|
+
/** Show the local answer once the host accepts it for this prompt. */
|
|
11
|
+
export function useAnswerPrompt(cellId: CellId) {
|
|
12
|
+
const store = useStore();
|
|
13
|
+
const actions = useCellActions();
|
|
14
|
+
return useEvent(async (text: string, inputId?: string) => {
|
|
15
|
+
if (inputId === undefined) {
|
|
16
|
+
Logger.error("The prompt has no id to answer it by");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const item = consoleExecution(store.get, cellId)?.items.get(inputId);
|
|
20
|
+
if (
|
|
21
|
+
(await replyInput(store, inputId, text)) &&
|
|
22
|
+
item?.kind === "input" &&
|
|
23
|
+
!item.password &&
|
|
24
|
+
consoleExecution(store.get, cellId)?.record.id === item.execution_id
|
|
25
|
+
) {
|
|
26
|
+
actions.setStdinResponse({ cellId, response: text, inputId });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { notebookAtom } from "@/core/cells/cells";
|
|
3
|
+
import { cellRuntimeAtom, notebookAtom } from "@/core/cells/cells";
|
|
5
4
|
import type { CellId } from "@/core/cells/ids";
|
|
6
5
|
import { displayCellName } from "@/core/cells/names";
|
|
7
6
|
import {
|
|
@@ -83,7 +82,7 @@ function resolveTracebackHtml(
|
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
export function getCellErrorEntries(store: JotaiStore): CellErrorEntry[] {
|
|
86
|
-
const { cellIds,
|
|
85
|
+
const { cellIds, cellData } = store.get(notebookAtom);
|
|
87
86
|
const entries: CellErrorEntry[] = [];
|
|
88
87
|
|
|
89
88
|
for (const [cellIndex, cellId] of cellIds.entries()) {
|
|
@@ -108,7 +107,7 @@ export function getCellErrorEntries(store: JotaiStore): CellErrorEntry[] {
|
|
|
108
107
|
errorData: parsed.errorData,
|
|
109
108
|
tracebackHtml: resolveTracebackHtml(
|
|
110
109
|
parsed,
|
|
111
|
-
|
|
110
|
+
store.get(cellRuntimeAtom(cellId)).consoleOutputs,
|
|
112
111
|
),
|
|
113
112
|
});
|
|
114
113
|
}
|
|
@@ -5,7 +5,6 @@ import { describe, expect, it } from "vitest";
|
|
|
5
5
|
import { MockExecutions } from "@/__mocks__/executions";
|
|
6
6
|
import { cellId } from "@/__tests__/branded";
|
|
7
7
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
8
|
-
import type { CellMessage } from "@/core/kernel/messages";
|
|
9
8
|
import {
|
|
10
9
|
document as documentOf,
|
|
11
10
|
withCells,
|
|
@@ -15,7 +14,7 @@ import {
|
|
|
15
14
|
acceptRun,
|
|
16
15
|
cellExecutionInputsAtom,
|
|
17
16
|
notebookQueuedOrRunningCountAtom,
|
|
18
|
-
|
|
17
|
+
setCellBlocked,
|
|
19
18
|
requestRun,
|
|
20
19
|
type RunRequest,
|
|
21
20
|
withdrawRequest,
|
|
@@ -48,16 +47,6 @@ function withRuns(executions: Executions, runs: Protocol.Run[]): Executions {
|
|
|
48
47
|
return { ...executions, runs: new Map(runs.map((r) => [r.id, r])) };
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
function cellOp(status: CellMessage["status"]): CellMessage {
|
|
52
|
-
return {
|
|
53
|
-
cell_id: C1,
|
|
54
|
-
output: null,
|
|
55
|
-
console: null,
|
|
56
|
-
status,
|
|
57
|
-
timestamp: 1,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
50
|
/** A store whose replica shows the two-cell fixture document. */
|
|
62
51
|
function shown() {
|
|
63
52
|
const store = createStore();
|
|
@@ -117,10 +106,7 @@ describe("requestRun", () => {
|
|
|
117
106
|
it("forgets requests and blocked cells with the notebook they were made in", () => {
|
|
118
107
|
const { store, replica } = shown();
|
|
119
108
|
request(store, [C1]);
|
|
120
|
-
|
|
121
|
-
...cellOp("disabled-transitively"),
|
|
122
|
-
cell_id: C2,
|
|
123
|
-
});
|
|
109
|
+
setCellBlocked(store, C2, true);
|
|
124
110
|
|
|
125
111
|
store.set(replica.notebookAtom, MockExecutions.notebook("n2"));
|
|
126
112
|
|
|
@@ -130,13 +116,13 @@ describe("requestRun", () => {
|
|
|
130
116
|
});
|
|
131
117
|
});
|
|
132
118
|
|
|
133
|
-
describe("
|
|
119
|
+
describe("setCellBlocked", () => {
|
|
134
120
|
it("does not show a requested cell as queued once the kernel reports it blocked", () => {
|
|
135
121
|
const { store } = shown();
|
|
136
122
|
request(store, [C1]);
|
|
137
123
|
expect(statusOf(store)).toBe("queued");
|
|
138
124
|
|
|
139
|
-
|
|
125
|
+
setCellBlocked(store, C1, true);
|
|
140
126
|
|
|
141
127
|
const view = cellExecutionView(store.get(cellExecutionInputsAtom), C1);
|
|
142
128
|
expect(view.status).toBe("idle");
|
|
@@ -147,7 +133,7 @@ describe("observeCellMessage", () => {
|
|
|
147
133
|
it("forgets requests and blocked cells with the replica they were made for", () => {
|
|
148
134
|
const { store } = shown();
|
|
149
135
|
request(store, [C1]);
|
|
150
|
-
|
|
136
|
+
setCellBlocked(store, C1, true);
|
|
151
137
|
|
|
152
138
|
MockExecutions.seed(store, [], null, documentOf());
|
|
153
139
|
|
|
@@ -161,7 +147,7 @@ describe("observeCellMessage", () => {
|
|
|
161
147
|
const { store } = shown();
|
|
162
148
|
request(store, [C1]);
|
|
163
149
|
|
|
164
|
-
|
|
150
|
+
setCellBlocked(store, C1, false);
|
|
165
151
|
|
|
166
152
|
expect(statusOf(store)).toBe("queued");
|
|
167
153
|
});
|
|
@@ -47,7 +47,7 @@ describe("replyInput", () => {
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
it("answers the prompt by id in the connected notebook", async () => {
|
|
50
|
-
await replyInput(store, "prompt-1", "marimo");
|
|
50
|
+
expect(await replyInput(store, "prompt-1", "marimo")).toBe(true);
|
|
51
51
|
|
|
52
52
|
expect(input).toHaveBeenCalledWith("n1", "prompt-1", { value: "marimo" });
|
|
53
53
|
expect(toast).not.toHaveBeenCalled();
|
|
@@ -65,7 +65,7 @@ describe("replyInput", () => {
|
|
|
65
65
|
},
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
await replyInput(store, "prompt-1", "marimo");
|
|
68
|
+
expect(await replyInput(store, "prompt-1", "marimo")).toBe(false);
|
|
69
69
|
|
|
70
70
|
expect(toast).toHaveBeenCalledWith(
|
|
71
71
|
expect.objectContaining({
|
|
@@ -78,7 +78,7 @@ describe("replyInput", () => {
|
|
|
78
78
|
it("does nothing without a connected notebook", async () => {
|
|
79
79
|
store.set(activeNotebookReplicaAtom, null);
|
|
80
80
|
|
|
81
|
-
await replyInput(store, "prompt-1", "marimo");
|
|
81
|
+
expect(await replyInput(store, "prompt-1", "marimo")).toBe(false);
|
|
82
82
|
|
|
83
83
|
expect(input).not.toHaveBeenCalled();
|
|
84
84
|
expect(toast).not.toHaveBeenCalled();
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
cellOutputAtom,
|
|
21
21
|
clearCellOutputs,
|
|
22
22
|
isCurrent,
|
|
23
|
-
|
|
23
|
+
setCellBlocked,
|
|
24
24
|
requestRun,
|
|
25
25
|
withdrawRequest,
|
|
26
26
|
} from "../atoms";
|
|
@@ -120,13 +120,7 @@ describe("output lifetime", () => {
|
|
|
120
120
|
const pending = requestRun(store, [C1])!;
|
|
121
121
|
acceptRun(store, pending, run);
|
|
122
122
|
const late = requestRun(store, [C1])!;
|
|
123
|
-
|
|
124
|
-
cell_id: C1,
|
|
125
|
-
status: "disabled-transitively",
|
|
126
|
-
timestamp: 1,
|
|
127
|
-
output: null,
|
|
128
|
-
console: null,
|
|
129
|
-
});
|
|
123
|
+
setCellBlocked(store, C1, true);
|
|
130
124
|
clearCellOutputs(store, [C1]);
|
|
131
125
|
expect(store.get(cellExecutionInputsAtom).blocked.has(C1)).toBe(true);
|
|
132
126
|
expect(store.get(cellOutputAtom(C1))).toBeNull();
|
|
@@ -9,7 +9,6 @@ import { atomFamily, selectAtom } from "jotai/utils";
|
|
|
9
9
|
import type { CellId } from "@/core/cells/ids";
|
|
10
10
|
import type { Outline } from "@/core/cells/outline";
|
|
11
11
|
import { parseOutline } from "@/core/dom/outline";
|
|
12
|
-
import type { CellMessage } from "@/core/kernel/messages";
|
|
13
12
|
import {
|
|
14
13
|
ConnectionState,
|
|
15
14
|
type Executions,
|
|
@@ -84,7 +83,7 @@ const requestsAtom = atom<Marks<ReadonlySet<RunRequest>>>(null);
|
|
|
84
83
|
|
|
85
84
|
/**
|
|
86
85
|
* Cells the kernel reports as blocked by a disabled ancestor. Written only
|
|
87
|
-
* by
|
|
86
|
+
* by the editor session.
|
|
88
87
|
*
|
|
89
88
|
* TODO(MO-8463): Derive from the document and the analysis stream.
|
|
90
89
|
*/
|
|
@@ -383,7 +382,7 @@ export function acceptRun(
|
|
|
383
382
|
check();
|
|
384
383
|
}
|
|
385
384
|
|
|
386
|
-
function setCellBlocked(
|
|
385
|
+
export function setCellBlocked(
|
|
387
386
|
store: Store,
|
|
388
387
|
cellId: Protocol.CellId,
|
|
389
388
|
blocked: boolean,
|
|
@@ -403,21 +402,3 @@ function setCellBlocked(
|
|
|
403
402
|
store.set(blockedCellsAtom, { notebook, value: next });
|
|
404
403
|
}
|
|
405
404
|
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* Learn from a cell-op whether the kernel considers the cell blocked by a
|
|
409
|
-
* disabled ancestor. A blocked cell will not run, so a run that names it
|
|
410
|
-
* does not show it as queued.
|
|
411
|
-
*
|
|
412
|
-
* TODO(MO-8407): Delete with the cell-op case. The blocked read goes with
|
|
413
|
-
* MO-8463.
|
|
414
|
-
*/
|
|
415
|
-
export function observeCellMessage(store: Store, message: CellMessage): void {
|
|
416
|
-
if (message.status != null) {
|
|
417
|
-
setCellBlocked(
|
|
418
|
-
store,
|
|
419
|
-
message.cell_id,
|
|
420
|
-
message.status === "disabled-transitively",
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
@@ -19,7 +19,7 @@ export {
|
|
|
19
19
|
clearCellOutputs,
|
|
20
20
|
notebookIsRunningAtom,
|
|
21
21
|
notebookQueuedOrRunningCountAtom,
|
|
22
|
-
|
|
22
|
+
setCellBlocked,
|
|
23
23
|
releaseCellOutputAtoms,
|
|
24
24
|
runtimeStatusAtom,
|
|
25
25
|
waitForRuntimeRunning,
|
|
@@ -43,6 +43,7 @@ export {
|
|
|
43
43
|
type CellOutput,
|
|
44
44
|
cellOutputsView,
|
|
45
45
|
cellOutputView,
|
|
46
|
+
executionSource,
|
|
46
47
|
type HostDiagnostic,
|
|
47
48
|
scratchOutputView,
|
|
48
49
|
} from "./output";
|
|
@@ -23,20 +23,20 @@ export async function replyInput(
|
|
|
23
23
|
store: Store,
|
|
24
24
|
inputId: Protocol.ItemId,
|
|
25
25
|
value: string,
|
|
26
|
-
): Promise<
|
|
26
|
+
): Promise<boolean> {
|
|
27
27
|
const replica = store.get(activeNotebookReplicaAtom);
|
|
28
28
|
const notebook = replica === null ? null : store.get(replica.notebookAtom);
|
|
29
29
|
const backend = replica === null ? null : store.get(replica.backendAtom);
|
|
30
30
|
if (notebook === null || backend === null) {
|
|
31
31
|
Logger.warn("No notebook is connected to answer the prompt in");
|
|
32
|
-
return;
|
|
32
|
+
return false;
|
|
33
33
|
}
|
|
34
34
|
try {
|
|
35
35
|
const result = await backend
|
|
36
36
|
.notebook(notebook.id)
|
|
37
37
|
.input(inputId, { value });
|
|
38
38
|
if (result.ok) {
|
|
39
|
-
return;
|
|
39
|
+
return true;
|
|
40
40
|
}
|
|
41
41
|
Logger.error("The host refused the input reply", result.problem);
|
|
42
42
|
toast({
|
|
@@ -52,4 +52,5 @@ export async function replyInput(
|
|
|
52
52
|
variant: "danger",
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
+
return false;
|
|
55
56
|
}
|
|
@@ -186,9 +186,9 @@ function skippedOutput(
|
|
|
186
186
|
* confirmed cell's fingerprint names the source the host holds, which is
|
|
187
187
|
* the execution's own until an edit is confirmed.
|
|
188
188
|
*/
|
|
189
|
-
function
|
|
189
|
+
export function executionSource(
|
|
190
190
|
record: Protocol.Execution,
|
|
191
|
-
cells: ReadonlyMap<Protocol.CellId, Protocol.Cell
|
|
191
|
+
cells: ReadonlyMap<Protocol.CellId, Protocol.Cell> = NO_CELLS,
|
|
192
192
|
): string | undefined {
|
|
193
193
|
const cell = record.cell_id === null ? undefined : cells.get(record.cell_id);
|
|
194
194
|
return cell !== undefined &&
|
|
@@ -207,7 +207,7 @@ export function outcomeOutput(
|
|
|
207
207
|
cells: ReadonlyMap<Protocol.CellId, Protocol.Cell> = NO_CELLS,
|
|
208
208
|
): CellOutput | null {
|
|
209
209
|
const output = outcomeDisplay(record);
|
|
210
|
-
const code =
|
|
210
|
+
const code = executionSource(record, cells);
|
|
211
211
|
return output === null || code === undefined ? output : { ...output, code };
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import type { components } from "@marimo-team/marimo-api";
|
|
4
|
+
import { createStore } from "jotai";
|
|
4
5
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { MockExecutions } from "@/__mocks__/executions";
|
|
5
7
|
import { requestId, uiElementId, widgetModelId } from "@/__tests__/branded";
|
|
6
8
|
import { notebookAtom } from "@/core/cells/cells";
|
|
7
9
|
import { islandsPendingInitialRunsAtom } from "@/core/islands/state";
|
|
@@ -394,6 +396,63 @@ describe("IslandsPyodideBridge", () => {
|
|
|
394
396
|
expect(consumeMessage.mock.calls).toEqual([notification]);
|
|
395
397
|
});
|
|
396
398
|
|
|
399
|
+
it("logs live stdout and stderr from other active apps under the owning cell", async () => {
|
|
400
|
+
const store = createStore();
|
|
401
|
+
bridge = new IslandsPyodideBridge({ store });
|
|
402
|
+
mockParseMarimoIslandApps.mockReturnValue([app(), app("app-2")]);
|
|
403
|
+
mockCreateMarimoFile
|
|
404
|
+
.mockReturnValueOnce("first")
|
|
405
|
+
.mockReturnValueOnce("second");
|
|
406
|
+
signalWorkerReady();
|
|
407
|
+
await bridge.initializeApps();
|
|
408
|
+
const handlers = { open: vi.fn(), message: vi.fn() };
|
|
409
|
+
void bridge.notebookBackend.transport(
|
|
410
|
+
{ signal: new AbortController().signal, cursor: null },
|
|
411
|
+
handlers,
|
|
412
|
+
);
|
|
413
|
+
const record = {
|
|
414
|
+
event: "execution",
|
|
415
|
+
data: {
|
|
416
|
+
execution: MockExecutions.completed("c2", {
|
|
417
|
+
id: "e1",
|
|
418
|
+
status: "running",
|
|
419
|
+
outcome: null,
|
|
420
|
+
completed_at: null,
|
|
421
|
+
}),
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
const write = (name: "stdout" | "stderr", text: string, seq = 0) => ({
|
|
425
|
+
event: "console",
|
|
426
|
+
data: { console: { id: text, execution_id: "e1", seq, name, text } },
|
|
427
|
+
});
|
|
428
|
+
sendNotebookEvent(2, record);
|
|
429
|
+
sendNotebookEvent(2, write("stdout", "snapshot"));
|
|
430
|
+
sendNotebookEvent(2, { ...write("stdout", "hello"), id: "1" });
|
|
431
|
+
sendNotebookEvent(2, { ...write("stderr", "warning", 1), id: "2" });
|
|
432
|
+
sendNotebookEvent(2, {
|
|
433
|
+
event: "execution.removed",
|
|
434
|
+
data: { id: "e1" },
|
|
435
|
+
id: "3",
|
|
436
|
+
});
|
|
437
|
+
sendNotebookEvent(2, { ...write("stdout", "retired", 2), id: "4" });
|
|
438
|
+
sendNotebookEvent(3, { ...write("stdout", "inactive"), id: "3" });
|
|
439
|
+
const managed = { ...write("stdout", "managed"), id: "4" };
|
|
440
|
+
sendNotebookEvent(1, managed);
|
|
441
|
+
expect(handlers.message.mock.calls).toEqual([[managed]]);
|
|
442
|
+
expect(
|
|
443
|
+
store
|
|
444
|
+
.get(notebookAtom)
|
|
445
|
+
.cellLogs.map(({ level, message, source }) => [
|
|
446
|
+
level,
|
|
447
|
+
message,
|
|
448
|
+
source,
|
|
449
|
+
]),
|
|
450
|
+
).toEqual([
|
|
451
|
+
["stdout", "hello", { type: "cell", cellId: "c2" }],
|
|
452
|
+
["stderr", "warning", { type: "cell", cellId: "c2" }],
|
|
453
|
+
]);
|
|
454
|
+
});
|
|
455
|
+
|
|
397
456
|
it("forwards the managed session's host events to the notebook stream", async () => {
|
|
398
457
|
await initializeSingleApp();
|
|
399
458
|
const handlers = { open: vi.fn(), message: vi.fn() };
|
|
@@ -25,12 +25,9 @@ import { MarimoValueInputEvent } from "../dom/events";
|
|
|
25
25
|
import { UI_ELEMENT_REGISTRY } from "../dom/uiregistry";
|
|
26
26
|
import { FUNCTIONS_REGISTRY } from "../functions/FunctionRegistry";
|
|
27
27
|
import { createNotebookReplica } from "../notebook/replica";
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
handleKernelReady,
|
|
32
|
-
handleRemoveUIElements,
|
|
33
|
-
} from "../kernel/handlers";
|
|
28
|
+
import { consoleObservers } from "../cells/execution-console";
|
|
29
|
+
import { setCellBlocked } from "../executions";
|
|
30
|
+
import { handleKernelReady, handleRemoveUIElements } from "../kernel/handlers";
|
|
34
31
|
import type { NotificationMessage } from "../kernel/messages";
|
|
35
32
|
import { queryParamHandlers } from "../kernel/queryParamHandlers";
|
|
36
33
|
import { RuntimeState } from "../kernel/RuntimeState";
|
|
@@ -138,7 +135,7 @@ export async function initializeIslands(
|
|
|
138
135
|
const replica = createNotebookReplica(store);
|
|
139
136
|
replica.connect(bridge.notebookBackend, {
|
|
140
137
|
onNotification: Functions.NOOP,
|
|
141
|
-
|
|
138
|
+
...consoleObservers(actions),
|
|
142
139
|
});
|
|
143
140
|
store.set(activeNotebookReplicaAtom, replica);
|
|
144
141
|
const documentModel = createDocumentModel({
|
|
@@ -190,8 +187,8 @@ function handleNotification(
|
|
|
190
187
|
case "completion-result":
|
|
191
188
|
case "reload":
|
|
192
189
|
case "focus-cell":
|
|
193
|
-
case "pdb-output":
|
|
194
190
|
case "pdb-input":
|
|
191
|
+
case "pdb-output":
|
|
195
192
|
case "breakpoints":
|
|
196
193
|
case "active-line":
|
|
197
194
|
case "variables":
|
|
@@ -256,11 +253,32 @@ function handleNotification(
|
|
|
256
253
|
FUNCTIONS_REGISTRY.resolve(msg.function_call_id, msg);
|
|
257
254
|
return;
|
|
258
255
|
|
|
256
|
+
case "console-inputs-cleared":
|
|
257
|
+
actions.hideConsoleInputs({
|
|
258
|
+
cellId: msg.cell_id,
|
|
259
|
+
executionId: msg.execution_id,
|
|
260
|
+
inputIds: msg.input_ids,
|
|
261
|
+
});
|
|
262
|
+
return;
|
|
259
263
|
case "cell-op":
|
|
260
|
-
|
|
261
|
-
|
|
264
|
+
if (msg.status != null) {
|
|
265
|
+
setCellBlocked(
|
|
266
|
+
store,
|
|
267
|
+
msg.cell_id,
|
|
268
|
+
msg.status === "disabled-transitively",
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
if (msg.serialization !== undefined) {
|
|
272
|
+
actions.setCellReusability({
|
|
273
|
+
cell_id: msg.cell_id,
|
|
274
|
+
serialization: msg.serialization,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
return;
|
|
278
|
+
case "callback-output":
|
|
279
|
+
VirtualFileTracker.INSTANCE.trackCallbackOutput(msg);
|
|
280
|
+
actions.showCommandOutput(msg);
|
|
262
281
|
return;
|
|
263
|
-
|
|
264
282
|
case "alert":
|
|
265
283
|
toast({
|
|
266
284
|
title: msg.title,
|
|
@@ -287,7 +305,6 @@ function handleNotification(
|
|
|
287
305
|
return;
|
|
288
306
|
|
|
289
307
|
case "consumer-capabilities":
|
|
290
|
-
case "execution":
|
|
291
308
|
return;
|
|
292
309
|
default:
|
|
293
310
|
logNever(msg);
|