From 649549482c74dd4324cc1109690e705301f0b70b Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Sun, 15 Nov 2026 07:54:58 -0700 Subject: [PATCH] Wait before showing the events viewer's loading message A load that finishes at once flashed "Loading events..." for a frame or two each time a streaming flow was selected. The message now shows only after the load has run for 200ms. Co-Authored-By: Claude Fable 5.2 --- .../ui/src/components/events/EventViewer.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/ui/src/components/events/EventViewer.tsx b/packages/ui/src/components/events/EventViewer.tsx index 0a2b95592..c1f4c9801 100644 --- a/packages/ui/src/components/events/EventViewer.tsx +++ b/packages/ui/src/components/events/EventViewer.tsx @@ -2,7 +2,7 @@ import type { Virtualizer } from "@tanstack/react-virtual"; import classNames from "classnames"; import { format } from "date-fns"; import type { ReactNode } from "react"; -import { useCallback, useMemo, useRef, useState } from "react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useEventViewerKeyboard } from "../../hooks/useEventViewerKeyboard"; import { Banner } from "../Banner"; import { Button } from "../Button"; @@ -15,6 +15,9 @@ import { SplitLayout } from "../SplitLayout"; import { HStack } from "../Stacks"; import { AutoScroller } from "./AutoScroller"; +/** How long a load runs before the loading message shows */ +const LOADING_MESSAGE_DELAY_MS = 200; + interface EventViewerProps { /** Array of events to display */ events: T[]; @@ -86,6 +89,17 @@ export function EventViewer({ const [activeIndex, setActiveIndexInternal] = useState(null); const [isPanelOpen, setIsPanelOpen] = useState(false); + // The loading message waits a moment, so a load that finishes at once never flashes it + const [showLoading, setShowLoading] = useState(false); + useEffect(() => { + if (!isLoading) { + setShowLoading(false); + return; + } + const timer = setTimeout(() => setShowLoading(true), LOADING_MESSAGE_DELAY_MS); + return () => clearTimeout(timer); + }, [isLoading]); + // Wrap setActiveIndex to notify parent const setActiveIndex = useCallback( (indexOrUpdater: number | null | ((prev: number | null) => number | null)) => { @@ -149,6 +163,7 @@ export function EventViewer({ }, []); if (isLoading) { + if (!showLoading) return null; return
{loadingMessage}
; }