fix: match log/timeline height, DESC sort with scroll-to-top
Give logCard the same max-height and flex layout as timelineCard so both columns are equal height. Revert .toReversed() so events stay in DESC order (newest at top). Override EventFeed's auto-scroll-to- bottom with a requestAnimationFrame that resets scrollTop to 0 after mount, keeping newest entries visible at the top of both panels. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useState, useMemo } from 'react';
|
import { useState, useMemo, useRef, useEffect } from 'react';
|
||||||
import { useParams, Link } from 'react-router';
|
import { useParams, Link } from 'react-router';
|
||||||
import {
|
import {
|
||||||
StatCard, StatusDot, Badge, MonoText, ProgressBar,
|
StatCard, StatusDot, Badge, MonoText, ProgressBar,
|
||||||
@@ -224,6 +224,18 @@ export default function AgentHealth() {
|
|||||||
const { appId } = useParams();
|
const { appId } = useParams();
|
||||||
const { data: agents } = useAgents(undefined, appId);
|
const { data: agents } = useAgents(undefined, appId);
|
||||||
const { data: events } = useAgentEvents(appId);
|
const { data: events } = useAgentEvents(appId);
|
||||||
|
const timelineRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
// Override EventFeed's auto-scroll-to-bottom so newest (DESC) events stay visible at top
|
||||||
|
useEffect(() => {
|
||||||
|
const el = timelineRef.current;
|
||||||
|
if (!el) return;
|
||||||
|
const timer = requestAnimationFrame(() => {
|
||||||
|
const list = el.querySelector('[aria-label="Event feed"]') as HTMLElement | null;
|
||||||
|
if (list) list.scrollTop = 0;
|
||||||
|
});
|
||||||
|
return () => cancelAnimationFrame(timer);
|
||||||
|
}, [events]);
|
||||||
|
|
||||||
const [selectedInstance, setSelectedInstance] = useState<AgentInstance | null>(null);
|
const [selectedInstance, setSelectedInstance] = useState<AgentInstance | null>(null);
|
||||||
const [panelOpen, setPanelOpen] = useState(false);
|
const [panelOpen, setPanelOpen] = useState(false);
|
||||||
@@ -256,7 +268,7 @@ export default function AgentHealth() {
|
|||||||
: ('running' as const),
|
: ('running' as const),
|
||||||
message: `${e.agentId}: ${e.eventType}${e.detail ? ' \u2014 ' + e.detail : ''}`,
|
message: `${e.agentId}: ${e.eventType}${e.detail ? ' \u2014 ' + e.detail : ''}`,
|
||||||
timestamp: new Date(e.timestamp),
|
timestamp: new Date(e.timestamp),
|
||||||
})).toReversed(),
|
})),
|
||||||
[events],
|
[events],
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -500,7 +512,7 @@ export default function AgentHealth() {
|
|||||||
|
|
||||||
{/* EventFeed */}
|
{/* EventFeed */}
|
||||||
{feedEvents.length > 0 && (
|
{feedEvents.length > 0 && (
|
||||||
<div className={styles.eventCard}>
|
<div className={styles.eventCard} ref={timelineRef}>
|
||||||
<div className={styles.eventCardHeader}>
|
<div className={styles.eventCardHeader}>
|
||||||
<span className={styles.sectionTitle}>Timeline</span>
|
<span className={styles.sectionTitle}>Timeline</span>
|
||||||
<span className={styles.sectionMeta}>{feedEvents.length} events</span>
|
<span className={styles.sectionMeta}>{feedEvents.length} events</span>
|
||||||
|
|||||||
@@ -132,6 +132,9 @@
|
|||||||
border-radius: var(--radius-lg);
|
border-radius: var(--radius-lg);
|
||||||
box-shadow: var(--shadow-card);
|
box-shadow: var(--shadow-card);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
max-height: 420px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logHeader {
|
.logHeader {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState, useRef, useEffect } from 'react';
|
||||||
import { useParams, Link } from 'react-router';
|
import { useParams, Link } from 'react-router';
|
||||||
import {
|
import {
|
||||||
StatCard, StatusDot, Badge, LineChart, AreaChart, BarChart,
|
StatCard, StatusDot, Badge, LineChart, AreaChart, BarChart,
|
||||||
@@ -36,10 +36,23 @@ export default function AgentInstance() {
|
|||||||
const timeFrom = timeRange.start.toISOString();
|
const timeFrom = timeRange.start.toISOString();
|
||||||
const timeTo = timeRange.end.toISOString();
|
const timeTo = timeRange.end.toISOString();
|
||||||
|
|
||||||
|
const timelineRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const { data: agents, isLoading } = useAgents(undefined, appId);
|
const { data: agents, isLoading } = useAgents(undefined, appId);
|
||||||
const { data: events } = useAgentEvents(appId, instanceId);
|
const { data: events } = useAgentEvents(appId, instanceId);
|
||||||
const { data: timeseries } = useStatsTimeseries(timeFrom, timeTo, undefined, appId);
|
const { data: timeseries } = useStatsTimeseries(timeFrom, timeTo, undefined, appId);
|
||||||
|
|
||||||
|
// Override EventFeed's auto-scroll-to-bottom so newest (DESC) events stay visible at top
|
||||||
|
useEffect(() => {
|
||||||
|
const el = timelineRef.current;
|
||||||
|
if (!el) return;
|
||||||
|
const timer = requestAnimationFrame(() => {
|
||||||
|
const list = el.querySelector('[aria-label="Event feed"]') as HTMLElement | null;
|
||||||
|
if (list) list.scrollTop = 0;
|
||||||
|
});
|
||||||
|
return () => cancelAnimationFrame(timer);
|
||||||
|
}, [events]);
|
||||||
|
|
||||||
const agent = useMemo(
|
const agent = useMemo(
|
||||||
() => (agents || []).find((a: any) => a.id === instanceId) as any,
|
() => (agents || []).find((a: any) => a.id === instanceId) as any,
|
||||||
[agents, instanceId],
|
[agents, instanceId],
|
||||||
@@ -90,8 +103,7 @@ export default function AgentInstance() {
|
|||||||
: ('running' as const),
|
: ('running' as const),
|
||||||
message: `${e.eventType}${e.detail ? ' \u2014 ' + e.detail : ''}`,
|
message: `${e.eventType}${e.detail ? ' \u2014 ' + e.detail : ''}`,
|
||||||
timestamp: new Date(e.timestamp),
|
timestamp: new Date(e.timestamp),
|
||||||
}))
|
})),
|
||||||
.toReversed(),
|
|
||||||
[events, instanceId],
|
[events, instanceId],
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -436,7 +448,7 @@ export default function AgentInstance() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={styles.timelineCard}>
|
<div className={styles.timelineCard} ref={timelineRef}>
|
||||||
<div className={styles.timelineHeader}>
|
<div className={styles.timelineHeader}>
|
||||||
<span className={styles.chartTitle}>Timeline</span>
|
<span className={styles.chartTitle}>Timeline</span>
|
||||||
<span className={styles.chartMeta}>{feedEvents.length} events</span>
|
<span className={styles.chartMeta}>{feedEvents.length} events</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user