Skip to content

Commit 4c4628c

Browse files
akshaykasebbeutler
authored andcommitted
fix: media console outputs from serialized notebook (marimo-team#5388)
When restoring the cell runtime from a serialized notebook, check for the presence of media outputs in the console output area.
1 parent 1794a8e commit 4c4628c

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

frontend/src/core/cells/session.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,24 @@ function createCellRuntimeFromSession(
214214
return {
215215
...runtimeState,
216216
outline: runtimeState.output ? parseOutline(runtimeState.output) : null,
217-
consoleOutputs: consoleOutputs.map((consoleOutput) => ({
218-
channel: consoleOutput.name === "stderr" ? "stderr" : "stdout",
219-
data: consoleOutput.text,
220-
mimetype: "text/plain",
221-
timestamp: DEFAULT_TIMESTAMP,
222-
})),
217+
consoleOutputs: consoleOutputs.map((consoleOutput) => {
218+
// Handle StreamMediaOutput (type: "streamMedia")
219+
if (consoleOutput.type === "streamMedia") {
220+
return {
221+
channel: "media",
222+
data: consoleOutput.data,
223+
mimetype: consoleOutput.mimetype,
224+
timestamp: DEFAULT_TIMESTAMP,
225+
};
226+
}
227+
// Handle StreamOutput (type: "stream")
228+
return {
229+
channel: consoleOutput.name === "stderr" ? "stderr" : "stdout",
230+
data: consoleOutput.text,
231+
mimetype: "text/plain",
232+
timestamp: DEFAULT_TIMESTAMP,
233+
};
234+
}),
223235
};
224236
}
225237

0 commit comments

Comments
 (0)