Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): preserve trace URL filters when opening shared links in new tab (#13665)

Pratima Patel9c825ad025dc
diff --git a/web/src/features/filters/savedViewImplicitEnvironmentRegression.clienttest.tsx b/web/src/features/filters/savedViewImplicitEnvironmentRegression.clienttest.tsx
index f1d7404298..dde4bc89b6 100644
--- a/web/src/features/filters/savedViewImplicitEnvironmentRegression.clienttest.tsx
+++ b/web/src/features/filters/savedViewImplicitEnvironmentRegression.clienttest.tsx
@@ -571,3 +571,89 @@ describe("Saved view restore with implicit environment defaults", () => {
);
});
});
+
+describe("Explicit filter in URL without viewId", () => {
+ const URL_ONLY_FILTERS: FilterState = [
+ {
+ column: "name",
+ type: "stringOptions",
+ operator: "any of",
+ value: ["search"],
+ },
+ ];
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ sessionStorage.clear();
+ queryParamStore.clear();
+
+ const encoded = encodeFiltersGeneric(URL_ONLY_FILTERS);
+ queryParamStore.set("filter", encoded);
+ mockUseRouter.mockReturnValue({
+ isReady: true,
+ query: { filter: encoded },
+ });
+
+ sessionStorage.setItem("traces-project-1-viewId", JSON.stringify("view-1"));
+
+ mockGetDefaultUseQuery.mockReturnValue({
+ data: null,
+ isLoading: false,
+ });
+
+ mockGetByIdUseQuery.mockReturnValue({
+ data: {
+ id: "view-1",
+ name: "Session saved view",
+ tableName: TableViewPresetTableName.Traces,
+ projectId: "project-1",
+ orderBy: null,
+ filters: OLD_SAVED_VIEW_FILTERS,
+ columnOrder: null,
+ columnVisibility: null,
+ searchQuery: "",
+ createdAt: new Date("2026-01-01T00:00:00.000Z"),
+ updatedAt: new Date("2026-01-01T00:00:00.000Z"),
+ createdBy: "user-1",
+ createdByUser: null,
+ },
+ error: null,
+ });
+ });
+
+ it("does not overwrite URL filters when session storage has a last-used viewId", async () => {
+ render(<SavedViewHarness />);
+
+ await waitFor(() => {
+ expect(screen.getByTestId("loading-state").textContent).toBe("ready");
+ });
+
+ expect(screen.getByTestId("explicit-state").textContent).toContain(
+ "search",
+ );
+ expect(screen.getByTestId("explicit-state").textContent).not.toContain(
+ "checkout",
+ );
+ });
+
+ it("does not overwrite URL filters when the project has a default viewId", async () => {
+ sessionStorage.clear();
+ mockGetDefaultUseQuery.mockReturnValue({
+ data: { viewId: "view-1", scope: "project" },
+ isLoading: false,
+ });
+
+ render(<SavedViewHarness />);
+
+ await waitFor(() => {
+ expect(screen.getByTestId("loading-state").textContent).toBe("ready");
+ });
+
+ expect(screen.getByTestId("explicit-state").textContent).toContain(
+ "search",
+ );
+ expect(screen.getByTestId("explicit-state").textContent).not.toContain(
+ "checkout",
+ );
+ });
+});