fix(traces): restore logs URL params from service graph

"View Related Logs" on a service graph node pushed the stream as
`stream_value`, but restoreUrlQueryParams() early-returns when
`queryParams.stream` is absent — so the stream, time range and filter in the
pushed URL were all dropped and the Logs page showed the previous session.

Push `stream` instead, and cover the two paths that decide whether the URL is
read at all:

- setupLogsTab() only restores when `logs.isInitialized` is false, and
  isRouteChanged() clears it only on a stream or org change — so navigating
  with the same stream but a different filter kept the stale session.
  Dispatch setIsInitialized(false) explicitly.
- The Logs route is keep-alive, so a repeat visit runs onActivated ->
  handleActivation(), which restores the URL only on the trace-explorer
  branch. Send `type=trace_explorer`, matching the trace-details "View Logs".
This commit is contained in:
Bhargav
2026-08-06 13:48:13 +05:30
parent a7cbf9cfdd
commit 1b02f512a1
2 changed files with 30 additions and 2 deletions
@@ -771,12 +771,31 @@ describe("ServiceGraphNodeSidePanel", () => {
path: "/logs",
query: expect.objectContaining({
stream_type: "logs",
stream_value: "k8s-logs",
// `stream` (not `stream_value`) — restoreUrlQueryParams only reads `stream`,
// and `type` routes the Logs page through its trace-explorer restore branch.
stream: "k8s-logs",
type: "trace_explorer",
}),
}),
);
});
it("should clear the logs isInitialized flag so the URL params win over the previous session", async () => {
const dispatchSpy = vi.spyOn(store, "dispatch");
const viewRelatedLogsBtn = wrapper.find(
'[data-test="service-graph-node-panel-view-related-logs-btn"]',
);
await viewRelatedLogsBtn.trigger("click");
await flushPromises();
// Without this the Logs page restores its stored session and silently drops
// the stream, time range and filter carried in the pushed URL.
expect(dispatchSpy).toHaveBeenCalledWith("logs/setIsInitialized", false);
dispatchSpy.mockRestore();
});
it("should NOT show a warning notification when a valid log stream is found", async () => {
const viewRelatedLogsBtn = wrapper.find(
'[data-test="service-graph-node-panel-view-related-logs-btn"]',
@@ -2399,12 +2399,21 @@ export default defineComponent({
sql_mode: "false",
query: b64EncodeUnicode(filterQuery),
org_identifier: org,
// The Logs route is keep-alive, so a repeat visit only runs onActivated —
// which restores the URL params solely on the trace-explorer branch.
type: "trace_explorer",
};
if (streamName) {
queryParams.stream_value = streamName;
queryParams.stream = streamName;
}
// The Logs page keeps `isInitialized` in the store across unmounts, and while
// it is set it restores the previous session from the store instead of reading
// these params — dropping the stream, time range and filter. Clearing it makes
// the URL the source of truth, same as the trace-details "View Logs" button.
store.dispatch("logs/setIsInitialized", false);
router.push({
path: "/logs",
query: queryParams,