Skip to content

Commit bbdcf04

Browse files
committed
[local-explorer-ui] make the trace deep link one-shot by stripping it from the URL
The ?trace=&span= params were consumed but left in the URL. Because the view switcher preserves search params and the Traces route remounts on each visit (resetting the applied/seeded refs), the stale trace param re-seeded the trace:<id> query and re-expanded the row on every return, hiding other traces even after the user cleared the search. Capture the deep link once at mount and strip trace/span from the URL (replace navigation, keeping worker), so it only applies once.
1 parent af35657 commit bbdcf04

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

  • packages/local-explorer-ui/src/routes/observability

packages/local-explorer-ui/src/routes/observability/index.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,14 @@ function ObservabilityView(): JSX.Element {
138138
spansByTraceRef.current = spansByTrace;
139139
// Deep link from an event's "View trace" button (?trace=&span=): open that
140140
// trace's waterfall once its row lands. span picks the right invocation row.
141-
const { trace: deepLinkTrace, span: deepLinkSpan } = Route.useSearch();
141+
// Capture it at mount and strip it from the URL below, so returning to this
142+
// view later (the switcher preserves search params) doesn't re-apply it.
143+
const routeSearch = Route.useSearch();
144+
const navigate = Route.useNavigate();
145+
const deepLinkRef = useRef<{ trace?: string; span?: string } | null>(null);
146+
deepLinkRef.current ??= { trace: routeSearch.trace, span: routeSearch.span };
147+
const deepLinkTrace = deepLinkRef.current.trace;
148+
const deepLinkSpan = deepLinkRef.current.span;
142149
const deepLinkAppliedRef = useRef<string | null>(null);
143150
const deepLinkSeededRef = useRef<string | null>(null);
144151
const [loading, setLoading] = useState(false);
@@ -346,6 +353,18 @@ function ObservabilityView(): JSX.Element {
346353
}
347354
}, [traces, expanded, loadSpans]);
348355

356+
// Strip the deep-link params from the URL once we've captured them, so they
357+
// don't linger and re-seed the query on every later return to this view.
358+
useEffect(() => {
359+
if (routeSearch.trace === undefined && routeSearch.span === undefined) {
360+
return;
361+
}
362+
void navigate({
363+
search: (prev) => ({ ...prev, trace: undefined, span: undefined }),
364+
replace: true,
365+
});
366+
}, [navigate, routeSearch.trace, routeSearch.span]);
367+
349368
// A deep-linked trace can be older than the default trace-list window, so
350369
// seed the search with `trace:<id>` to fetch that specific row. If it still
351370
// doesn't come back, the trace is gone and the empty state explains that.

0 commit comments

Comments
 (0)