From ec02f4bc877604c726f07dc790f182df2a1df61a Mon Sep 17 00:00:00 2001 From: Jeremy lewi Date: Fri, 13 Feb 2026 06:51:47 -0800 Subject: [PATCH 1/3] Hide empty observable output panel until content exists Signed-off-by: Jeremy lewi --- app/src/components/Actions/WebContainer.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/components/Actions/WebContainer.tsx b/app/src/components/Actions/WebContainer.tsx index 5891e4a..b951459 100644 --- a/app/src/components/Actions/WebContainer.tsx +++ b/app/src/components/Actions/WebContainer.tsx @@ -46,6 +46,7 @@ const WebContainer = ({ cell, onExitCode, onPid }: ObservableOutputProps) => { const [stdout, setStdout] = useState(""); const [stderr, setStderr] = useState(""); const [lastRunId, setLastRunId] = useState(0); + const [hasRenderableOutput, setHasRenderableOutput] = useState(false); const activeRunIdRef = useRef(null); const runCode = useCallback(async () => { @@ -60,6 +61,7 @@ const WebContainer = ({ cell, onExitCode, onPid }: ObservableOutputProps) => { setLastRunId(runId); setStdout(""); setStderr(""); + setHasRenderableOutput(false); container.innerHTML = ""; onPid(null); @@ -140,6 +142,11 @@ const WebContainer = ({ cell, onExitCode, onPid }: ObservableOutputProps) => { const stdoutText = logBuffer.join("\n"); const stderrText = errorBuffer.join("\n"); + const renderedText = container.textContent?.trim() ?? ""; + const renderedElements = container.querySelectorAll("*").length; + const hasRenderedContent = renderedElements > 0 || renderedText.length > 0; + const hasTerminalOutput = + stdoutText.trim().length > 0 || stderrText.trim().length > 0; const updatedCell = create(parser_pb.CellSchema, cell); updatedCell.outputs = createCellOutputs( @@ -161,6 +168,7 @@ const WebContainer = ({ cell, onExitCode, onPid }: ObservableOutputProps) => { setStdout(stdoutText); setStderr(stderrText); + setHasRenderableOutput(hasRenderedContent || hasTerminalOutput); onExitCode(exitCode); }, [cell, notebookData, onExitCode, onPid]); @@ -185,7 +193,7 @@ const WebContainer = ({ cell, onExitCode, onPid }: ObservableOutputProps) => { return stdout.trim().length > 0 || stderr.trim().length > 0; }, [stderr, stdout]); - return ( + return hasRenderableOutput ? (
Observable Output{" "} @@ -198,7 +206,7 @@ const WebContainer = ({ cell, onExitCode, onPid }: ObservableOutputProps) => { className="mb-2 min-h-[240px] w-full overflow-auto rounded border border-dashed border-nb-cell-border bg-nb-surface-2" /> - {hasStdIO ? ( + {hasStdIO && (
{stdout.trim().length > 0 && (
@@ -221,12 +229,10 @@ const WebContainer = ({ cell, onExitCode, onPid }: ObservableOutputProps) => {
)}
- ) : ( -
- Use d3 (or aisre.render) to draw into the panel above. -
)}
+ ) : ( +