From ad4d7eb8bf26bad2ea5da12e2b792a494b1cdfc3 Mon Sep 17 00:00:00 2001 From: Juan Denis Date: Sat, 20 Jun 2026 12:47:47 -0400 Subject: [PATCH] feat(logs): full-bleed Terminal/Logs with follow-tail + LIVE badge Terminal/Logs now fills the viewport like the Servers ops view (full-bleed flex layout through the Radix tab panel). LogContent sticks to the newest line on new content/selection (respecting manual scroll-up) and shows a floating LIVE badge while a log auto-follows its tail. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/components/log-viewer/LogContent.jsx | 103 +++++++++++++----- frontend/src/pages/Terminal.jsx | 8 +- frontend/src/styles/pages/_terminal.scss | 83 ++++++++++++++ 3 files changed, 163 insertions(+), 31 deletions(-) diff --git a/frontend/src/components/log-viewer/LogContent.jsx b/frontend/src/components/log-viewer/LogContent.jsx index 6494ab4f..a27518bb 100644 --- a/frontend/src/components/log-viewer/LogContent.jsx +++ b/frontend/src/components/log-viewer/LogContent.jsx @@ -1,4 +1,4 @@ -import { forwardRef, useMemo } from 'react'; +import { forwardRef, useMemo, useRef, useCallback, useLayoutEffect } from 'react'; import { severityOf, splitOnMatch } from './logHelpers'; const LogContent = forwardRef(function LogContent({ @@ -8,10 +8,44 @@ const LogContent = forwardRef(function LogContent({ showLineNumbers, wrapLines, searchPattern, + live = false, + scrollKey, }, ref) { - const lines = useMemo(() => { - if (!content) return []; - return content.split('\n'); + const innerRef = useRef(null); + // Whether the viewer is parked at the bottom (following the tail). Starts + // true so a freshly opened log lands on its newest line. + const followRef = useRef(true); + + // Merge our internal ref with the forwarded ref so the parent keeps its + // direct scroll access (jump-to-end button, etc.) while we manage tailing. + const setRefs = useCallback((node) => { + innerRef.current = node; + if (typeof ref === 'function') ref(node); + else if (ref) ref.current = node; + }, [ref]); + + const lines = useMemo(() => (content ? content.split('\n') : []), [content]); + + // Stop following once the user scrolls up; resume when they return to the + // bottom — so live updates don't yank them away while reading history. + const handleScroll = useCallback(() => { + const el = innerRef.current; + if (!el) return; + followRef.current = el.scrollHeight - el.scrollTop - el.clientHeight < 48; + }, []); + + // New selection (different file / unit / service): jump to the newest line + // and re-arm follow. + useLayoutEffect(() => { + followRef.current = true; + const el = innerRef.current; + if (el) el.scrollTop = el.scrollHeight; + }, [scrollKey]); + + // New content while following: stick to the last record. + useLayoutEffect(() => { + const el = innerRef.current; + if (el && followRef.current) el.scrollTop = el.scrollHeight; }, [content]); if (loading) { @@ -27,33 +61,42 @@ const LogContent = forwardRef(function LogContent({ } return ( -
-
- {lines.map((line, idx) => { - const sev = severityOf(line); - const segments = searchPattern ? splitOnMatch(line, searchPattern) : null; - return ( -
- {showLineNumbers && ( - {idx + 1} - )} - - {segments - ? segments.map((seg, i) => - seg.match ? ( - {seg.text} - ) : ( - {seg.text} +
+ {live && ( + + + LIVE + + )} +
+
+ {lines.map((line, idx) => { + const sev = severityOf(line); + const segments = searchPattern ? splitOnMatch(line, searchPattern) : null; + return ( +
+ {showLineNumbers && ( + {idx + 1} + )} + + {segments + ? segments.map((seg, i) => + seg.match ? ( + {seg.text} + ) : ( + {seg.text} + ) ) - ) - : (line || ' ')} - -
- ); - })} + : (line || ' ')} + +
+ ); + })} +
); diff --git a/frontend/src/pages/Terminal.jsx b/frontend/src/pages/Terminal.jsx index 4f63f991..79426f98 100644 --- a/frontend/src/pages/Terminal.jsx +++ b/frontend/src/pages/Terminal.jsx @@ -27,7 +27,7 @@ const Terminal = () => { const [activeTab, setActiveTab] = useTabParam('/terminal', VALID_TABS); return ( -
+
} title="Terminal / Logs" @@ -452,6 +452,8 @@ const LogFilesTab = () => { { {
.sk-topbar { flex-shrink: 0; } + + > [data-orientation] { + flex: 1; + min-height: 0; + display: flex; + flex-direction: column; + } + + .tab-content { + flex: 1; + min-height: 0; + display: flex; + flex-direction: column; + } + + .tab-content > [role="tabpanel"] { + flex: 1; + min-height: 0; + } + + .term-shell, + .lv-page:not(.fullscreen), + .proc-page, + .svc-page { + height: 100%; + min-height: 0; + } +} + .lv-content-loading, .lv-content-empty { display: flex;