fix: console scroll to bottom on change + more logs + dont wrap

This commit is contained in:
Felix Roos
2026-01-22 20:40:35 +01:00
parent 8e5ca57edd
commit 4993ec4cbf
2 changed files with 12 additions and 3 deletions
@@ -2,13 +2,21 @@ import cx from '@src/cx.mjs';
import { useSettings } from '../../../settings.mjs';
import { useStore } from '@nanostores/react';
import { $strudel_log_history } from '../useLogger';
import { useEffect, useRef } from 'react';
export function ConsoleTab() {
const log = useStore($strudel_log_history);
const { fontFamily } = useSettings();
const scrollRef = useRef();
// scroll to bottom when log changes
useEffect(() => {
if (scrollRef.current) {
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
}
}, [log]);
return (
<div id="console-tab" className="break-all w-full h-full" style={{ fontFamily }}>
<div className="h-full w-full overflow-auto space-y-1 p-2 rounded-md">
<div className="h-full w-full overflow-auto space-y-1 p-2 rounded-md" ref={scrollRef}>
{' '}
{/* bg-background */}
{log.map((l, i) => {
@@ -18,12 +26,13 @@ export function ConsoleTab() {
<div
key={l.id}
className={cx(
'whitespace-nowrap',
l.type === 'error' ? 'text-background bg-foreground' : 'text-foreground',
l.type === 'highlight' && 'underline',
)}
style={color ? { color } : {}}
>
<span dangerouslySetInnerHTML={{ __html: message }} />
<span dangerouslySetInnerHTML={{ __html: message }} className="whitespace-nowrap" />
{l.count ? ` (${l.count})` : ''}
</div>
);
+1 -1
View File
@@ -21,7 +21,7 @@ function getUpdatedLog(log, event) {
} else {
log = log.concat([{ message, type, id, data }]);
}
return log.slice(-20);
return log.slice(-40);
}
export function useLogger() {