Skip to content

Traceid cross page pagination - #395

Merged
thorrester merged 4 commits into
mainfrom
traceid-cross-page-pagination
May 2, 2026
Merged

thorrester merged 4 commits into
mainfrom
traceid-cross-page-pagination

Conversation

@thorrester

@thorrester thorrester commented Apr 29, 2026 •

Copy link
Copy Markdown
Member

Pull Request

Short Summary

Adds deep-link trace navigation from evaluation records and workflows to the Observability dashboard, including a new Rust endpoint (GET /scouter/trace/{id}/spans) that fetches a trace without time bounds so the UI can center its time window on the trace automatically. Alongside this, fixes a silent data loss bug where workflow trace links disappeared after paginating records, extracts a shared DashboardTimeBar component, and wires global refresh state coordination across evaluation dashboards.

Context

Trace deep-link navigation — Previously, clicking a record or workflow in the evaluation dashboard had no way to jump to the associated trace in Observability. The blocker was that trace lookups require a time range, but the dashboard didn't know what range contained that specific trace. This PR adds GET /opsml/api/scouter/trace/{id}/spans to the Rust server — no time bounds, just fetch by ID — then the +page.ts load function uses the root span's timestamp to derive a centered time window and pre-selects the trace to open the sidebar immediately on navigation. The trace link appears in EvalRecordContent, AgentEvalWorkflowContent, and TaskDetailView, all building the observability path by stripping /evaluation from the current URL.

_traceId cross-page pagination fix — workflowPage was a $derived block that rebuilt recordTraceMap from the current record page only. Since records and workflows paginate independently, after the user paged records forward, any workflow referencing a record on the previous page silently lost its trace link. Fix: lifted recordTraceMap to module-level $state, appended to it on each handleRecordPageChange, and reset it on full time-range refresh. Svelte 5 proxies Map mutations so the $derived recomputes correctly.

DashboardTimeBar extraction — The refresh button + time range selector combo was duplicated in TraceDashboard.svelte. Extracted into DashboardTimeBar.svelte with selectedRange, refreshing, onRangeChange, and onRefresh props. TraceDashboard now uses it directly.

Global refresh state — Added isRefreshing, beginRefresh(), and endRefresh() to timeRangeState. Evaluation dashboards (AgentEvalDashboard, PromptEvalDashboard) now call these around every fetch so the global time bar can show a loading state without each dashboard managing it independently. Also prevents timeRangeState.refresh() from double-firing if already in progress.

PromptEvalDashboard range-change detection — The previous detection compared monitoringData.selectedTimeRange to the new range, but that field gets mutated by the same effect, creating an unreliable comparison. Replaced with a stable lastSeenRange snapshot (same fix applied to AgentEvalDashboard in an earlier commit). Also removed the floating "Syncing..." overlay — the global refresh state handles this now.

ComparisonView.svelte string rendering — Plain string expected/actual values were being routed through a JSON CodeBlock, which escaped and syntax-highlighted them as JSON. Strings now render as <span class="font-mono whitespace-pre-wrap"> and only objects go through CodeBlock.

isPromptCard comparison fix — The type guard was using === against RegistryType.Prompt (a lowercase string enum), but card.registry_type coming from the API could have different casing depending on serialization. Changed to String(card.registry_type).toLowerCase() === RegistryType.Prompt.

Mock mode for task loading — AgentEvalWorkflowContent was gating mock task data with import { dev } from '$app/environment', which means it only worked in dev builds, not when the mock toggle was on in production-like environments. Changed to devMockStore.enabled.

File Change
src/core/scouter/trace/route.rs New GET /scouter/trace/{id}/spans endpoint, registered in router
src/lib/components/utils/DashboardTimeBar.svelte New shared time bar component (refresh button + range selector)
src/lib/components/utils/timeState.svelte.ts Added isRefreshing, beginRefresh(), endRefresh()
src/lib/components/card/agent/evaluation/AgentEvalDashboard.svelte Persistent recordTraceMap, beginRefresh/endRefresh wiring, style fixes
src/lib/components/card/prompt/PromptEvalDashboard.svelte Stable lastSeenRange, removed floating overlay, refresh wiring
src/lib/components/trace/TraceDashboard.svelte Uses DashboardTimeBar, passes initialTrace/initialTraceSpans, strips trace_id param on refresh
src/lib/components/trace/utils.ts getServerTraceSpansById, traceListItemFromSpans helpers
routes/api/scouter/observability/trace/[id]/spans/+server.ts New BFF proxy for spans-by-ID
routes/.../observability/+page.ts Pre-fetches trace by ?trace_id= param, derives centered time window
src/lib/components/scouter/agent/record/EvalRecordContent.svelte "Trace" link button navigating to observability
src/lib/components/scouter/agent/workflow/AgentEvalWorkflowContent.svelte Passes traceId + observability path through to TaskDetailView, switches to devMockStore
src/lib/components/scouter/agent/task/TaskDetailView.svelte "Trace" link button at task level
src/lib/components/scouter/agent/task/ComparisonView.svelte String values rendered as plain text, not JSON CodeBlock
src/lib/components/card/card_interfaces/promptcard.ts Case-insensitive isPromptCard registry type comparison
src/lib/components/scouter/dashboard/utils.test.ts Tests for refreshAgentMonitoringData mock and time-range behavior
src/lib/components/utils/DashboardTimeBar.test.ts Tests for new component
src/lib/components/utils/timeState.test.ts Tests for refresh state

Is this a Breaking Change?

No. The new Rust endpoint is additive. All existing TypeScript types are extended with optional fields (_traceId?: string, trace_id?: string, initialTrace?, initialTraceSpans?) and no existing prop signatures changed. The DashboardTimeBar extraction doesn't affect any other callers since TimeRangeFilter is still exported. The isPromptCard fix changes behavior only for cards where the API returns non-lowercase registry_type, which was already broken.

@thorrester
thorrester marked this pull request as ready for review April 29, 2026 11:53

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 6 additional findings.

Open in Devin Review

@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Manifest Files

@thorrester
thorrester merged commit edca6bb into main May 2, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant