diff --git a/packages/webui/src/components/debug/live-activity.tsx b/packages/webui/src/components/debug/live-activity.tsx index 4ab93647..632dc3f4 100644 --- a/packages/webui/src/components/debug/live-activity.tsx +++ b/packages/webui/src/components/debug/live-activity.tsx @@ -25,12 +25,15 @@ function IconBtn({ onClick, title, children }: { onClick: () => void; title: str ); } -function StatusPill({ status }: { status: 'open' | 'reconnecting' | 'closed' }) { - const map = { - open: { dot: 'bg-emerald-500', label: '已连接', glow: 'shadow-[0_0_0_3px_rgb(16_185_129/0.15)]' }, - reconnecting: { dot: 'bg-amber-500', label: '重连中', glow: 'shadow-[0_0_0_3px_rgb(245_158_11/0.15)]' }, - closed: { dot: 'bg-muted-foreground/50', label: '未连接', glow: '' }, - }[status]; +function StatusPill({ status, paused }: { status: 'open' | 'reconnecting' | 'closed'; paused?: boolean }) { + // A deliberate pause reads as "已暂停", distinct from an unwanted disconnect. + const map = paused + ? { dot: 'bg-muted-foreground/50', label: '已暂停', glow: '' } + : { + open: { dot: 'bg-emerald-500', label: '已连接', glow: 'shadow-[0_0_0_3px_rgb(16_185_129/0.15)]' }, + reconnecting: { dot: 'bg-amber-500', label: '重连中', glow: 'shadow-[0_0_0_3px_rgb(245_158_11/0.15)]' }, + closed: { dot: 'bg-muted-foreground/50', label: '未连接', glow: '' }, + }[status]; return (
@@ -94,14 +97,18 @@ export function LiveActivity() { const [status, setStatus] = useState<'open' | 'reconnecting' | 'closed'>('closed'); const [kindFilter, setKindFilter] = useState<'all' | 'event' | 'action'>('all'); const [query, setQuery] = useState(''); - const pausedRef = useRef(paused); - useEffect(() => { pausedRef.current = paused; }, [paused]); const idRef = useRef(0); + // Pausing truly drops the EventSource instead of connecting-and-discarding: + // `paused` is an effect dependency, so it closes the stream on pause and + // reopens it on resume. (The always-on-across-tabs behaviour is intentional — + // debug-page keeps this mounted so actions fired from other tabs still land in + // the feed — so only an explicit pause severs the connection.) useEffect(() => { + if (paused) return; const off = api.debug.stream( (m) => { - if (m.kind === 'ready' || pausedRef.current) return; + if (m.kind === 'ready') return; setRows((prev) => { // Precompute the search haystack once at enqueue, so filtering never // re-stringifies every row on each keystroke. @@ -112,7 +119,7 @@ export function LiveActivity() { (s) => setStatus(s), ); return off; - }, [api]); + }, [paused, api]); const visible = useMemo(() => { const q = query.trim().toLowerCase(); @@ -149,7 +156,7 @@ export function LiveActivity() {

实时活动

{visible.length} - +