Skip to content

Commit 6c04009

Browse files
committed
Revert ConsoleOutput component, restore original NotebookCell output
1 parent ed6ab57 commit 6c04009

2 files changed

Lines changed: 66 additions & 204 deletions

File tree

src/lib/components/common/ConsoleOutput.svelte

Lines changed: 0 additions & 177 deletions
This file was deleted.

src/lib/components/common/NotebookCell.svelte

Lines changed: 66 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import CodeBlock from './CodeBlock.svelte';
88
import Icon from './Icon.svelte';
99
import { tooltip } from './Tooltip.svelte';
10-
import ConsoleOutput, { type LogEntry } from './ConsoleOutput.svelte';
1110
import { notebookStore, type CellStatus } from '$lib/stores/notebookStore';
1211
import { pyodideState } from '$lib/stores/pyodideStore';
1312
import CellOutput from '$lib/components/notebook/CellOutput.svelte';
@@ -41,8 +40,8 @@
4140
let codeBlockRef = $state<{ getCurrentCode: () => string } | undefined>(undefined);
4241
4342
// Execution output state
44-
let consoleLogs = $state<LogEntry[]>([]);
45-
let nextLogId = 0;
43+
let stdout = $state('');
44+
let stderr = $state('');
4645
let plots = $state<string[]>([]);
4746
let error = $state<{ message: string; traceback?: string } | null>(null);
4847
let duration = $state<number | null>(null);
@@ -56,27 +55,19 @@
5655
// Computed states
5756
let isRunning = $derived(cellState.status === 'running');
5857
let isPending = $derived(cellState.status === 'pending');
59-
let hasLiveOutput = $derived(consoleLogs.length > 0 || plots.length > 0 || error);
58+
let hasLiveOutput = $derived(stdout || stderr || plots.length > 0 || error);
6059
let showStaticOutputs = $derived(!hasLiveOutput && staticOutputs.length > 0);
6160
let hasOutput = $derived(hasLiveOutput || showStaticOutputs);
6261
63-
function addLog(message: string, level: LogEntry['level']) {
64-
consoleLogs = [...consoleLogs, { id: nextLogId++, level, message }];
65-
}
66-
67-
function clearLogs() {
68-
consoleLogs = [];
69-
nextLogId = 0;
70-
}
71-
7262
/**
7363
* Execute this cell's code (called by store during prerequisite chain)
7464
*/
7565
async function executeCell(): Promise<void> {
7666
const codeToRun = codeBlockRef?.getCurrentCode() ?? code;
7767
7868
// Clear previous output
79-
clearLogs();
69+
stdout = '';
70+
stderr = '';
8071
plots = [];
8172
error = null;
8273
duration = null;
@@ -93,23 +84,19 @@
9384
// Execute with streaming callbacks for real-time output
9485
const result = await execute(codeToRun, {
9586
onStdout: (text) => {
96-
addLog(text, 'output');
87+
stdout = stdout ? stdout + '\n' + text : text;
9788
},
9889
onStderr: (text) => {
99-
addLog(text, 'warning');
90+
stderr = stderr ? stderr + '\n' + text : text;
10091
},
10192
onPlot: (data) => {
10293
plots = [...plots, data];
10394
}
10495
});
10596
106-
// Final result - add any output that wasn't streamed
107-
if (result.stdout && consoleLogs.every((log) => log.message !== result.stdout)) {
108-
addLog(result.stdout, 'output');
109-
}
110-
if (result.stderr && consoleLogs.every((log) => log.message !== result.stderr)) {
111-
addLog(result.stderr, 'warning');
112-
}
97+
// Final result (in case any output was missed)
98+
stdout = result.stdout;
99+
stderr = result.stderr;
113100
plots = result.plots;
114101
duration = result.duration;
115102
@@ -146,7 +133,8 @@
146133
}
147134
148135
function clearOutput() {
149-
clearLogs();
136+
stdout = '';
137+
stderr = '';
150138
plots = [];
151139
error = null;
152140
duration = null;
@@ -222,20 +210,38 @@
222210
</div>
223211
{/if}
224212

225-
{#if consoleLogs.length > 0}
213+
{#if stdout}
226214
<div class="output-panel">
227215
<div class="panel-header">
228216
<span>Output</span>
229217
<div class="header-actions">
230218
{#if duration !== null}
231219
<span class="duration">{duration}ms</span>
232220
{/if}
233-
<button class="icon-btn" onclick={clearLogs} use:tooltip={'Clear'}>
221+
<button class="icon-btn" onclick={clearOutput} use:tooltip={'Clear'}>
222+
<Icon name="x" size={14} />
223+
</button>
224+
</div>
225+
</div>
226+
<div class="panel-body">
227+
<div class="output-text">{stdout}</div>
228+
</div>
229+
</div>
230+
{/if}
231+
232+
{#if stderr && !error}
233+
<div class="output-panel warning">
234+
<div class="panel-header">
235+
<span>Stderr</span>
236+
<div class="header-actions">
237+
<button class="icon-btn" onclick={clearOutput} use:tooltip={'Clear'}>
234238
<Icon name="x" size={14} />
235239
</button>
236240
</div>
237241
</div>
238-
<ConsoleOutput logs={consoleLogs} maxHeight={200} />
242+
<div class="panel-body">
243+
<div class="output-text stderr">{stderr}</div>
244+
</div>
239245
</div>
240246
{/if}
241247

@@ -325,6 +331,8 @@
325331
padding: 0;
326332
}
327333
334+
/* output-text styles are in app.css global rules */
335+
328336
/* Duration in header */
329337
.output-panel .duration {
330338
font-family: var(--font-ui);
@@ -355,6 +363,20 @@
355363
border-top: 1px solid var(--border);
356364
}
357365
366+
/* Warning panel (stderr) */
367+
.output-panel.warning {
368+
background: var(--warning-bg);
369+
}
370+
371+
.output-panel.warning .panel-header {
372+
background: transparent;
373+
color: var(--warning);
374+
}
375+
376+
.output-panel.warning .output-text {
377+
color: var(--warning);
378+
}
379+
358380
/* Plots */
359381
.plots-body {
360382
display: flex;
@@ -369,4 +391,21 @@
369391
border-radius: var(--radius-sm);
370392
background: transparent;
371393
}
394+
395+
/* Output text styling */
396+
.output-text {
397+
font-family: var(--font-mono);
398+
font-size: var(--font-base);
399+
font-weight: 400;
400+
line-height: 1.5;
401+
margin: 0;
402+
padding: var(--space-md);
403+
color: var(--text-muted);
404+
white-space: pre-wrap;
405+
word-break: break-word;
406+
}
407+
408+
.output-text.stderr {
409+
color: var(--warning);
410+
}
372411
</style>

0 commit comments

Comments
 (0)