Skip to content

perf(ui): stop full trace re-download on complete & window-focus #1043

Description

@XinweiHe

The trace detail view re-downloads the entire trace twice unnecessarily: once when the live stream signals completion (invalidateQueries), and again on window-focus (React Query default staleTime/refetchOnWindowFocus). For a large trace this means repeatedly pulling tens of MB — the user-visible "slow to refresh." A completed trace is immutable, and final spans already arrive via the live stream merge.

Tasks

  • In frontend/ui/src/features/traces/hooks/use-trace-stream.ts, remove the invalidateQueries on trace_complete; rely on the merged streamed spans.
  • For the trace-detail query (features/traces/hooks/index.ts / TraceViewerPanel.tsx), set refetchOnWindowFocus: false and a long/Infinity staleTime.
  • Keep live-streaming merge intact for in-progress traces.

Acceptance

  • Opening a completed trace and switching tabs back triggers no new GET …/traces/{id} request.
  • In-progress traces still stream and complete correctly.

Files: frontend/ui/src/features/traces/hooks/use-trace-stream.ts, frontend/ui/src/features/traces/hooks/index.ts, TraceViewerPanel.tsx, cross-check app/providers.tsx

Part of #1040.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2performancePerformance / scalability workui

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions