diff --git a/web/src/plugins/traces/ServiceGraphNodeSidePanel.spec.ts b/web/src/plugins/traces/ServiceGraphNodeSidePanel.spec.ts index 10a8fa8f48..be3f8e2f7c 100644 --- a/web/src/plugins/traces/ServiceGraphNodeSidePanel.spec.ts +++ b/web/src/plugins/traces/ServiceGraphNodeSidePanel.spec.ts @@ -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"]', diff --git a/web/src/plugins/traces/ServiceGraphNodeSidePanel.vue b/web/src/plugins/traces/ServiceGraphNodeSidePanel.vue index 19002f7cdf..2ef25a9214 100644 --- a/web/src/plugins/traces/ServiceGraphNodeSidePanel.vue +++ b/web/src/plugins/traces/ServiceGraphNodeSidePanel.vue @@ -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,