@@ -12,6 +12,7 @@ import {
1212 setup_mathjax ,
1313 useState ,
1414 useErrorBoundary ,
15+ useMemo ,
1516} from "@plutojl/rainbow/ui" ;
1617import { type RendererContext } from "vscode-notebook-renderer" ;
1718
@@ -85,7 +86,35 @@ export function PlutoOutput({ state, context }: PlutoOutputProps) {
8586 } ) ;
8687 return ( ) => d ?. dispose ( ) ;
8788 } , [ state . cell_id , context ] ) ;
89+
90+ const OUTPUT = useMemo ( ( ) => {
91+ // This is probably a bug in the immer bundling; the mime edits don't propagate ;/
92+ // TODO: @pankgeorg investigate pls
93+ const fixedMime =
94+ localState . output . mime === "application/vnd.pluto.stacktrace+object" &&
95+ ( typeof localState . output . body !== "object" ||
96+ ! ( "stacktrace" in localState . output . body ) )
97+ ? "text/plain"
98+ : localState . output . mime ;
99+ if ( localState . output ?. mime )
100+ return html `< ${ OutputBody }
101+ persist _js_state ="${ localState . output . persist_js_state } "
102+ body ="${ localState . output ?. body } "
103+ mime ="${ fixedMime } "
104+ sanitize_html ="${ false /* Maybe reconsider */ } "
105+ > </ ${ OutputBody } > ` ;
106+ return "Loading..." ;
107+ } , [
108+ localState ,
109+ localState . cell_id ,
110+ localState . output . mime ,
111+ localState . output . body ,
112+ localState . running ,
113+ localState . errored ,
114+ ] ) ;
115+
88116 if ( error ) {
117+ console . error ( error ) ;
89118 return html `< div onclick =${ resetError } >
90119 An error occured. Click < button onClick =${ resetError } > here</ button > to
91120 reset the view
@@ -108,14 +137,7 @@ export function PlutoOutput({ state, context }: PlutoOutputProps) {
108137 > </ progress >
109138 </ div > `
110139 : null }
111- ${ localState . output ?. mime
112- ? html `< ${ OutputBody }
113- persist _js_state ="${ localState . output . persist_js_state } "
114- body ="${ localState . output ?. body } "
115- mime ="${ localState . output ?. mime } "
116- sanitize_html ="${ false /* Maybe reconsider */ } "
117- > </ ${ OutputBody } > `
118- : "Loading..." }
140+ ${ OUTPUT }
119141 ${ terminal ?. length
120142 ? html `< details >
121143 < summary > stdout</ summary >
0 commit comments