mobile ux + logs: hide title on phone and preload last 10 logs

This commit is contained in:
DBT
2026-02-26 00:41:27 +00:00
parent ba2d68105a
commit b4d24e5c2c
3 changed files with 68 additions and 1 deletions

View File

@@ -12,6 +12,19 @@ const Logs: React.FC = () => {
const logEndRef = useRef<HTMLDivElement>(null);
const abortControllerRef = useRef<AbortController | null>(null);
const loadRecent = async () => {
try {
const r = await fetch(`/webui/api/logs/recent${q ? `${q}&limit=10` : '?limit=10'}`);
if (!r.ok) return;
const j = await r.json();
if (Array.isArray(j.logs)) {
setLogs(j.logs as LogEntry[]);
}
} catch (e) {
console.error('load recent logs failed', e);
}
};
const startStreaming = async () => {
if (abortControllerRef.current) abortControllerRef.current.abort();
abortControllerRef.current = new AbortController();
@@ -51,6 +64,7 @@ const Logs: React.FC = () => {
};
useEffect(() => {
loadRecent();
if (isStreaming) {
startStreaming();
} else {