This is an automated email from the ASF dual-hosted git repository.

choo121600 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new f5b15584b7c UI: Keep grid and log filters when switching detail tabs 
(#76483)
f5b15584b7c is described below

commit f5b15584b7c33b9d16144a5658c10735f4480c2a
Author: Brent Bovenzi <[email protected]>
AuthorDate: Tue Nov 24 01:39:06 2026 -0500

    UI: Keep grid and log filters when switching detail tabs (#76483)
    
    * UI: Keep grid and log filters when switching detail tabs
    
    Tab links on the dag, run and task instance pages rebuild the query
    string from scratch, so any filter set in the grid, gantt, graph or task
    log was dropped on every tab change, even though the panel it filters
    stays on screen. Switching task instances kept them only because grid
    links carry the params forward.
    
    The details layout now hands NavTabs the keys its panel owns, and NavTabs
    copies them onto every tab link. Those keys live in one list per source,
    read by the filters that write them and the views that apply them, with
    date ranges resolved to their start and end keys through the filter
    config, so a new filter is carried without a second list to keep in
    sync. Table paging and sorting stay behind, since they belong to one
    tab's list, and the browse and asset tabs carry nothing, as before.
    
    The log search query moves into the url (debounced), so it survives the
    unmount a tab change causes and a filtered log can be shared as a link.
    
    The XCom and Task Instances tables applied a run id pattern even with a
    run pinned by the route, where they offer no run id filter to clear it,
    so a pattern carried from the grid could empty them. They now apply it
    only on their lists across runs.
    
    Co-Authored-By: Claude <[email protected]>
    
    * UI: Keep log and grid filters when picking a map index
    
    Opening one map index from the mapped task instances table or the
    breadcrumb map index picker built the link from the region alone, so a
    log source, level or search set on the logs tab was gone by the time the
    instance's logs loaded, even though the same filters survive a tab
    change on that page. Those links now carry the panel's filters the way
    tab links do, while still leaving the list's paging and the previous
    try and region behind.
    
    Co-Authored-By: Claude <[email protected]>
    
    * UI: Keep the log search box in step with the url on Back/Forward
    
    The log search box read log_search once on mount, so Back or Forward
    changed the url while the box and its highlights kept the old query.
    Adopt the url value when it changes, unless a typed edit is still
    waiting to be written.
    
    Also test that typing writes log_search to the url and clearing the
    box removes it.
    
    Co-Authored-By: Claude <[email protected]>
    
    * Carry a log search typed just before switching tabs
    
    The log search reached the url only after a 200ms debounce, so a tab
    clicked right after typing carried the previous query. Write the pending
    search when the input loses focus, which happens before the link
    navigates. Flushing on unmount instead would run a relative navigate
    after leaving and send the user back to the logs.
    
    The log header and search now read and write their keys through
    LOG_SEARCH_PARAMS, the same list the tab links carry, so a new log
    filter can't be left out of it.
    
    Co-Authored-By: Claude <[email protected]>
    
    * UI: Keep the selected log match when the search reaches the url
    
    The debounced write of the search box's own query changed the url like
    Back/Forward does, so the page adopted it and reset the selected match:
    pressing Enter right after typing jumped back to the first match once
    the write landed. Only adopt a url query that differs from the box.
    
    Co-Authored-By: Claude <[email protected]>
    
    ---------
    
    Co-authored-by: Claude <[email protected]>
---
 .../airflow/ui/src/components/GraphTaskFilters.tsx |  13 +--
 .../ui/src/constants/persistentSearchParams.ts     | 113 ++++++++++++++++++
 .../src/airflow/ui/src/constants/searchParams.ts   |   1 +
 .../ui/src/layouts/Details/DetailsLayout.tsx       |   4 +-
 .../airflow/ui/src/layouts/Details/Gantt/Gantt.tsx |   9 +-
 .../Details/Graph/hooks/useGraphSearchParams.ts    |   9 +-
 .../airflow/ui/src/layouts/Details/Grid/Grid.tsx   |   9 +-
 .../airflow/ui/src/layouts/Details/GridFilters.tsx |  16 +--
 .../ui/src/layouts/Details/NavTabs.test.tsx        | 126 ++++++++++++++++++++-
 .../src/airflow/ui/src/layouts/Details/NavTabs.tsx |  21 +++-
 .../src/layouts/Details/SearchMapIndexes.test.tsx  |  13 +++
 .../ui/src/layouts/Details/SearchMapIndexes.tsx    |  15 ++-
 .../ui/src/layouts/Details/TaskStreamFilter.tsx    |  36 +++---
 .../src/pages/TaskInstance/Logs/LogSearchInput.tsx |   3 +
 .../ui/src/pages/TaskInstance/Logs/Logs.test.tsx   |  93 ++++++++++++++-
 .../ui/src/pages/TaskInstance/Logs/Logs.tsx        |  44 ++++++-
 .../src/pages/TaskInstance/Logs/TaskLogHeader.tsx  |  18 +--
 .../src/pages/TaskInstance/TaskInstance.test.tsx   |  12 +-
 .../src/pages/TaskInstances/TaskInstances.test.tsx |  47 ++++++++
 .../ui/src/pages/TaskInstances/TaskInstances.tsx   |  34 +++++-
 .../src/airflow/ui/src/pages/XCom/XCom.test.tsx    |  37 +++++-
 .../src/airflow/ui/src/pages/XCom/XCom.tsx         |   4 +-
 .../src/airflow/ui/src/utils/AppWrapper.tsx        |  34 +++---
 23 files changed, 602 insertions(+), 109 deletions(-)

diff --git a/airflow-core/src/airflow/ui/src/components/GraphTaskFilters.tsx 
b/airflow-core/src/airflow/ui/src/components/GraphTaskFilters.tsx
index c9ab7047a34..1aa8d9241b7 100644
--- a/airflow-core/src/airflow/ui/src/components/GraphTaskFilters.tsx
+++ b/airflow-core/src/airflow/ui/src/components/GraphTaskFilters.tsx
@@ -37,6 +37,7 @@ import { IconButton, Select, Menu, NumberInputField, 
NumberInputRoot } from "src
 import { AttrSelectFilterMulti } from "src/components/AttrSelectFilterMulti";
 import { StateBadge } from "src/components/StateBadge";
 
+import { GRAPH_FILTER_KEYS } from "src/constants/persistentSearchParams";
 import { SearchParamsKeys } from "src/constants/searchParams";
 import { taskInstanceStateOptions } from "src/constants/stateOptions";
 import { useGroups } from "src/context/groups";
@@ -67,14 +68,6 @@ export const GraphTaskFilters = () => {
     (item) => item.value !== "all" && item.value !== "none",
   );
 
-  const allGraphFilterKeys = [
-    SearchParamsKeys.GRAPH_OPERATOR,
-    SearchParamsKeys.GRAPH_TASK_GROUP,
-    SearchParamsKeys.GRAPH_TASK_STATE,
-    SearchParamsKeys.GRAPH_MAP_INDEX,
-    SearchParamsKeys.GRAPH_DURATION_GTE,
-  ];
-
   const handleMultiChange = (key: string) => (values: Array<string> | 
undefined) => {
     setSearchParams(
       (prev) => {
@@ -112,7 +105,7 @@ export const GraphTaskFilters = () => {
       (prev) => {
         const next = new URLSearchParams(prev);
 
-        allGraphFilterKeys.forEach((key) => next.delete(key));
+        GRAPH_FILTER_KEYS.forEach((key) => next.delete(key));
 
         return next;
       },
@@ -132,7 +125,7 @@ export const GraphTaskFilters = () => {
       (prev) => {
         const next = new URLSearchParams(prev);
 
-        allGraphFilterKeys.forEach((key) => next.delete(key));
+        GRAPH_FILTER_KEYS.forEach((key) => next.delete(key));
 
         return next;
       },
diff --git 
a/airflow-core/src/airflow/ui/src/constants/persistentSearchParams.ts 
b/airflow-core/src/airflow/ui/src/constants/persistentSearchParams.ts
new file mode 100644
index 00000000000..fc5536c75e5
--- /dev/null
+++ b/airflow-core/src/airflow/ui/src/constants/persistentSearchParams.ts
@@ -0,0 +1,113 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import type { FilterableSearchParamsKeys } from "src/utils/useFiltersHandler";
+
+import { useFilterConfigs } from "./filterConfigs";
+import { SearchParamsKeys } from "./searchParams";
+
+/**
+ * Query parameters owned by the page's persistent panel -- the grid, the 
gantt, the graph and the
+ * task log -- rather than by whichever tab is open beside it. The details 
layout's NavTabs carries
+ * all of them onto every tab link, so a filter added to one of these lists 
survives a tab change.
+ *
+ * A table's paging and sorting are deliberately absent. Those describe one 
tab's list, and carrying
+ * them over would open the next tab's list on a page that list need not have.
+ */
+
+// The run filters on the grid's filter bar.
+export const GRID_FILTER_KEYS: ReadonlyArray<FilterableSearchParamsKeys> = [
+  SearchParamsKeys.RUN_ID_PATTERN,
+  SearchParamsKeys.STATE,
+  SearchParamsKeys.RUN_TYPE,
+  SearchParamsKeys.TRIGGERING_USER_NAME_PATTERN,
+  SearchParamsKeys.RUN_AFTER_RANGE,
+];
+
+// Joins the grid's filter bar while the gantt is showing.
+export const GANTT_DATE_FILTER_KEYS: ReadonlyArray<FilterableSearchParamsKeys> 
= [
+  SearchParamsKeys.START_DATE_RANGE,
+  SearchParamsKeys.END_DATE_RANGE,
+];
+
+export const GRAPH_FILTER_KEYS: ReadonlyArray<SearchParamsKeys> = [
+  SearchParamsKeys.GRAPH_OPERATOR,
+  SearchParamsKeys.GRAPH_TASK_GROUP,
+  SearchParamsKeys.GRAPH_TASK_STATE,
+  SearchParamsKeys.GRAPH_MAP_INDEX,
+  SearchParamsKeys.GRAPH_DURATION_GTE,
+];
+
+// The task stream filter has no SearchParamsKeys entries and writes these 
names straight to the url.
+export const TASK_STREAM_SEARCH_PARAMS = {
+  depth: "depth",
+  downstream: "downstream",
+  mode: "mode",
+  root: "root",
+  upstream: "upstream",
+} as const;
+
+// The log header (level and source) and the log search read and write these, 
so a log filter added
+// here is carried across tabs.
+export const LOG_SEARCH_PARAMS = {
+  level: SearchParamsKeys.LOG_LEVEL,
+  search: SearchParamsKeys.LOG_SEARCH,
+  source: SearchParamsKeys.SOURCE,
+} as const;
+
+// A date range filter is listed by its filter key but writes a start and an 
end key, so resolve
+// those through the same config the filter bar uses.
+export const usePersistentSearchParamKeys = (): ReadonlyArray<string> => {
+  const { getFilterConfig } = useFilterConfigs();
+
+  const gridKeys = [...GRID_FILTER_KEYS, 
...GANTT_DATE_FILTER_KEYS].flatMap((key) => {
+    const { endKey, startKey } = getFilterConfig(key);
+
+    return startKey !== undefined && endKey !== undefined ? [startKey, endKey] 
: [key];
+  });
+
+  return [
+    ...gridKeys,
+    ...GRAPH_FILTER_KEYS,
+    ...Object.values(TASK_STREAM_SEARCH_PARAMS),
+    ...Object.values(LOG_SEARCH_PARAMS),
+  ];
+};
+
+/**
+ * The query for a link that leaves one place on the page for another: 
`targetSearch` plus every
+ * persistent key in `currentSearch`. A key the target sets itself (e.g. 
`try_number`) wins.
+ */
+export const mergePersistentSearchParams = (
+  currentSearch: string,
+  targetSearch: string | undefined,
+  persistentKeys: ReadonlyArray<string>,
+) => {
+  const current = new URLSearchParams(currentSearch);
+  const target = new URLSearchParams(targetSearch);
+
+  for (const key of persistentKeys) {
+    if (!target.has(key)) {
+      for (const value of current.getAll(key)) {
+        target.append(key, value);
+      }
+    }
+  }
+
+  return target.toString();
+};
diff --git a/airflow-core/src/airflow/ui/src/constants/searchParams.ts 
b/airflow-core/src/airflow/ui/src/constants/searchParams.ts
index 31147806c15..9021d7d03ab 100644
--- a/airflow-core/src/airflow/ui/src/constants/searchParams.ts
+++ b/airflow-core/src/airflow/ui/src/constants/searchParams.ts
@@ -85,6 +85,7 @@ export enum SearchParamsKeys {
   LAST_DAG_RUN_STATE = "last_dag_run_state",
   LIMIT = "limit",
   LOG_LEVEL = "log_level",
+  LOG_SEARCH = "log_search",
   LOGICAL_DATE_GTE = "logical_date_gte",
   LOGICAL_DATE_LTE = "logical_date_lte",
   LOGICAL_DATE_RANGE = "logical_date_range",
diff --git a/airflow-core/src/airflow/ui/src/layouts/Details/DetailsLayout.tsx 
b/airflow-core/src/airflow/ui/src/layouts/Details/DetailsLayout.tsx
index de230445f38..185f0289ae7 100644
--- a/airflow-core/src/airflow/ui/src/layouts/Details/DetailsLayout.tsx
+++ b/airflow-core/src/airflow/ui/src/layouts/Details/DetailsLayout.tsx
@@ -39,6 +39,7 @@ import { TriggerDAGButton } from 
"src/components/TriggerDag/TriggerDAGButton";
 
 import type { DagView } from "src/constants/dagView";
 import { DEFAULT_DAG_VIEW_KEY } from "src/constants/localStorage";
+import { usePersistentSearchParamKeys } from 
"src/constants/persistentSearchParams";
 import { SearchParamsKeys } from "src/constants/searchParams";
 import { VersionIndicatorOptions } from 
"src/constants/showVersionIndicatorOptions";
 import { GroupsProvider } from "src/context/groups";
@@ -88,6 +89,7 @@ type Props = {
 export const DetailsLayout = ({ children, error, isLoading, outletContext, 
tabs }: Props) => {
   const { t: translate } = useTranslation("dags");
   const { dagId = "", runId } = useParams();
+  const persistentKeys = usePersistentSearchParamKeys();
   const refetchInterval = useAutoRefresh({ dagId });
   const { data: dag } = useDagServiceGetDag({ dagId }, undefined, {
     refetchInterval: (query) => query.state.data?.scheduling_state === 
"draining" && refetchInterval,
@@ -454,7 +456,7 @@ export const DetailsLayout = ({ children, error, isLoading, 
outletContext, tabs
                   >
                     {children}
                     <ProgressBar size="xs" visibility={isLoading ? "visible" : 
"hidden"} />
-                    <NavTabs tabs={tabs} />
+                    <NavTabs persistentKeys={persistentKeys} tabs={tabs} />
                     <Box flexGrow={1} overflow="auto" pb={3} px={2}>
                       <Outlet context={outletContext} />
                     </Box>
diff --git a/airflow-core/src/airflow/ui/src/layouts/Details/Gantt/Gantt.tsx 
b/airflow-core/src/airflow/ui/src/layouts/Details/Gantt/Gantt.tsx
index a384f815553..2ab46c381a9 100644
--- a/airflow-core/src/airflow/ui/src/layouts/Details/Gantt/Gantt.tsx
+++ b/airflow-core/src/airflow/ui/src/layouts/Details/Gantt/Gantt.tsx
@@ -32,6 +32,7 @@ import {
 } from "src/layouts/Details/Grid/constants";
 import { flattenNodes } from "src/layouts/Details/Grid/utils";
 
+import { TASK_STREAM_SEARCH_PARAMS } from 
"src/constants/persistentSearchParams";
 import { SearchParamsKeys } from "src/constants/searchParams";
 import { useGroups } from "src/context/groups";
 import { useTimezone } from "src/context/timezone";
@@ -79,10 +80,10 @@ export const Gantt = ({
   const { openGroupIds, toggleGroupId } = useGroups();
   const { selectedTimezone } = useTimezone();
 
-  const filterRoot = searchParams.get("root") ?? undefined;
-  const includeUpstream = searchParams.get("upstream") === "true";
-  const includeDownstream = searchParams.get("downstream") === "true";
-  const depthParam = searchParams.get("depth");
+  const filterRoot = searchParams.get(TASK_STREAM_SEARCH_PARAMS.root) ?? 
undefined;
+  const includeUpstream = searchParams.get(TASK_STREAM_SEARCH_PARAMS.upstream) 
=== "true";
+  const includeDownstream = 
searchParams.get(TASK_STREAM_SEARCH_PARAMS.downstream) === "true";
+  const depthParam = searchParams.get(TASK_STREAM_SEARCH_PARAMS.depth);
   const depth = depthParam !== null && depthParam !== "" ? 
parseInt(depthParam, 10) : undefined;
 
   // Task-level time window, written by the Start/End Date pills in 
GridFilters.
diff --git 
a/airflow-core/src/airflow/ui/src/layouts/Details/Graph/hooks/useGraphSearchParams.ts
 
b/airflow-core/src/airflow/ui/src/layouts/Details/Graph/hooks/useGraphSearchParams.ts
index 061ec91fa97..dc996425c9e 100644
--- 
a/airflow-core/src/airflow/ui/src/layouts/Details/Graph/hooks/useGraphSearchParams.ts
+++ 
b/airflow-core/src/airflow/ui/src/layouts/Details/Graph/hooks/useGraphSearchParams.ts
@@ -18,6 +18,7 @@
  */
 import { useSearchParams } from "react-router-dom";
 
+import { TASK_STREAM_SEARCH_PARAMS } from 
"src/constants/persistentSearchParams";
 import { SearchParamsKeys } from "src/constants/searchParams";
 
 import type { GraphFilterValues } from "../useGraphFilteredNodes";
@@ -34,10 +35,10 @@ type GraphSearchParams = {
 export const useGraphSearchParams = (): GraphSearchParams => {
   const [searchParams] = useSearchParams();
 
-  const filterRoot = searchParams.get("root") ?? undefined;
-  const includeUpstream = searchParams.get("upstream") === "true";
-  const includeDownstream = searchParams.get("downstream") === "true";
-  const depthParam = searchParams.get("depth");
+  const filterRoot = searchParams.get(TASK_STREAM_SEARCH_PARAMS.root) ?? 
undefined;
+  const includeUpstream = searchParams.get(TASK_STREAM_SEARCH_PARAMS.upstream) 
=== "true";
+  const includeDownstream = 
searchParams.get(TASK_STREAM_SEARCH_PARAMS.downstream) === "true";
+  const depthParam = searchParams.get(TASK_STREAM_SEARCH_PARAMS.depth);
   const depth = depthParam !== null && depthParam !== "" ? 
parseInt(depthParam, 10) : undefined;
   const hasActiveFilter = includeUpstream || includeDownstream;
 
diff --git a/airflow-core/src/airflow/ui/src/layouts/Details/Grid/Grid.tsx 
b/airflow-core/src/airflow/ui/src/layouts/Details/Grid/Grid.tsx
index c453e30b401..c7298957d5e 100644
--- a/airflow-core/src/airflow/ui/src/layouts/Details/Grid/Grid.tsx
+++ b/airflow-core/src/airflow/ui/src/layouts/Details/Grid/Grid.tsx
@@ -28,6 +28,7 @@ import { useParams, useSearchParams } from "react-router-dom";
 
 import type { DagRunState, DagRunType, GridRunsResponse } from 
"openapi/requests";
 
+import { TASK_STREAM_SEARCH_PARAMS } from 
"src/constants/persistentSearchParams";
 import type { VersionIndicatorOptions } from 
"src/constants/showVersionIndicatorOptions";
 import type { GridCell } from "src/context/gridSelection";
 import { useGroups } from "src/context/groups";
@@ -108,10 +109,10 @@ export const Grid = ({
   const { dagId = "", groupId: selectedGroupId, runId: selectedRunId, taskId: 
selectedTaskId } = useParams();
   const [searchParams] = useSearchParams();
 
-  const filterRoot = searchParams.get("root") ?? undefined;
-  const includeUpstream = searchParams.get("upstream") === "true";
-  const includeDownstream = searchParams.get("downstream") === "true";
-  const depthParam = searchParams.get("depth");
+  const filterRoot = searchParams.get(TASK_STREAM_SEARCH_PARAMS.root) ?? 
undefined;
+  const includeUpstream = searchParams.get(TASK_STREAM_SEARCH_PARAMS.upstream) 
=== "true";
+  const includeDownstream = 
searchParams.get(TASK_STREAM_SEARCH_PARAMS.downstream) === "true";
+  const depthParam = searchParams.get(TASK_STREAM_SEARCH_PARAMS.depth);
   const depth = depthParam !== null && depthParam !== "" ? 
parseInt(depthParam, 10) : undefined;
 
   // Over fetch gridRuns and then truncate to limit, in order to check 
pagination
diff --git a/airflow-core/src/airflow/ui/src/layouts/Details/GridFilters.tsx 
b/airflow-core/src/airflow/ui/src/layouts/Details/GridFilters.tsx
index 3b52c5538ac..f1fca39cb02 100644
--- a/airflow-core/src/airflow/ui/src/layouts/Details/GridFilters.tsx
+++ b/airflow-core/src/airflow/ui/src/layouts/Details/GridFilters.tsx
@@ -18,25 +18,15 @@
  */
 import { FilterBar } from "src/components/FilterBar";
 
-import { SearchParamsKeys } from "src/constants/searchParams";
-import { useFiltersHandler, type FilterableSearchParamsKeys } from "src/utils";
+import { GANTT_DATE_FILTER_KEYS, GRID_FILTER_KEYS } from 
"src/constants/persistentSearchParams";
+import { useFiltersHandler } from "src/utils";
 
 type Props = {
   readonly showGanttDateFilters?: boolean;
 };
 
 export const GridFilters = ({ showGanttDateFilters = false }: Props) => {
-  const searchParamKeys: Array<FilterableSearchParamsKeys> = [
-    SearchParamsKeys.RUN_ID_PATTERN,
-    SearchParamsKeys.STATE,
-    SearchParamsKeys.RUN_TYPE,
-    SearchParamsKeys.TRIGGERING_USER_NAME_PATTERN,
-    SearchParamsKeys.RUN_AFTER_RANGE,
-  ];
-
-  if (showGanttDateFilters) {
-    searchParamKeys.push(SearchParamsKeys.START_DATE_RANGE, 
SearchParamsKeys.END_DATE_RANGE);
-  }
+  const searchParamKeys = [...GRID_FILTER_KEYS, ...(showGanttDateFilters ? 
GANTT_DATE_FILTER_KEYS : [])];
 
   const { filterConfigs, handleFiltersChange, initialValues } = 
useFiltersHandler(searchParamKeys);
 
diff --git a/airflow-core/src/airflow/ui/src/layouts/Details/NavTabs.test.tsx 
b/airflow-core/src/airflow/ui/src/layouts/Details/NavTabs.test.tsx
index a7c630feec2..9d92111c661 100644
--- a/airflow-core/src/airflow/ui/src/layouts/Details/NavTabs.test.tsx
+++ b/airflow-core/src/airflow/ui/src/layouts/Details/NavTabs.test.tsx
@@ -22,7 +22,9 @@ import { fireEvent, render, screen, within } from 
"@testing-library/react";
 import { MemoryRouter, Outlet, Route, Routes, useLocation } from 
"react-router-dom";
 import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
 
+import { usePersistentSearchParamKeys } from 
"src/constants/persistentSearchParams";
 import { useContainerWidth } from "src/utils";
+import { BaseWrapper } from "src/utils/Wrapper";
 
 import { NavTabs, type NavTab } from "./NavTabs";
 
@@ -80,7 +82,9 @@ describe("NavTabs", () => {
     vi.spyOn(HTMLElement.prototype, 
"getBoundingClientRect").mockImplementation(function getRect(
       this: HTMLElement,
     ) {
-      return { width: this.textContent === "Wide" ? WIDE_TAB_WIDTH : TAB_WIDTH 
} as DOMRect;
+      return {
+        width: this.textContent === "Wide" ? WIDE_TAB_WIDTH : TAB_WIDTH,
+      } as DOMRect;
     });
   });
 
@@ -235,3 +239,123 @@ describe("NavTabs", () => {
     expect(within(menu).getByRole("menuitem", { name: "Tab 3" 
})).toBeInTheDocument();
   });
 });
+
+const DETAILS_TABS: Array<NavTab> = [
+  { label: "Details", value: "details" },
+  { label: "Logs", search: "try_number=2", value: "logs" },
+];
+
+const DetailsTabs = () => <NavTabs 
persistentKeys={usePersistentSearchParamKeys()} tabs={DETAILS_TABS} />;
+
+const renderDetailsTabs = (search: string, carryFilters = true) => {
+  render(
+    <BaseWrapper>
+      <MemoryRouter initialEntries={[`/dags/my_dag/runs/my_run${search}`]}>
+        {carryFilters ? <DetailsTabs /> : <NavTabs tabs={DETAILS_TABS} />}
+      </MemoryRouter>
+    </BaseWrapper>,
+  );
+};
+
+const linkSearch = (name: string) => {
+  const href = screen.getByRole("link", { name }).getAttribute("href") ?? "";
+
+  return new URL(href, "http://localhost";).searchParams;
+};
+
+describe("NavTabs persistent filters", () => {
+  beforeEach(() => {
+    vi.mocked(useContainerWidth).mockReturnValue(DETAILS_TABS.length * 
TAB_WIDTH);
+  });
+
+  afterEach(() => {
+    vi.restoreAllMocks();
+  });
+
+  it("carries the grid filters onto every tab", () => {
+    
renderDetailsTabs("?state=failed&run_type=manual&run_after_gte=2026-01-01");
+
+    expect(Object.fromEntries(linkSearch("Details"))).toStrictEqual({
+      run_after_gte: "2026-01-01",
+      run_type: "manual",
+      state: "failed",
+    });
+  });
+
+  it("carries the gantt date ranges by the start and end keys they write", () 
=> {
+    
renderDetailsTabs("?start_date_gte=2026-01-01&end_date_lte=2026-02-01&start_date_range=ignored");
+
+    expect(Object.fromEntries(linkSearch("Details"))).toStrictEqual({
+      end_date_lte: "2026-02-01",
+      start_date_gte: "2026-01-01",
+    });
+  });
+
+  it("carries the graph and task stream filters, mode included", () => {
+    renderDetailsTabs(
+      
"?graph-operator=BashOperator&root=extract&upstream=true&downstream=true&depth=2&mode=traverse",
+    );
+
+    expect(Object.fromEntries(linkSearch("Details"))).toStrictEqual({
+      depth: "2",
+      downstream: "true",
+      "graph-operator": "BashOperator",
+      mode: "traverse",
+      root: "extract",
+      upstream: "true",
+    });
+  });
+
+  it("carries a filter that repeats, rather than only its first value", () => {
+    renderDetailsTabs("?log_level=error&log_level=warning");
+
+    expect(linkSearch("Details").getAll("log_level")).toStrictEqual(["error", 
"warning"]);
+  });
+
+  it("leaves one tab's paging and sorting behind", () => {
+    renderDetailsTabs("?state=failed&offset=20&limit=50&sort=-run_after");
+
+    expect(Object.fromEntries(linkSearch("Details"))).toStrictEqual({
+      state: "failed",
+    });
+  });
+
+  it("lets the tab decide the parameters it names itself", () => {
+    renderDetailsTabs("?state=failed&try_number=7");
+
+    expect(Object.fromEntries(linkSearch("Logs"))).toStrictEqual({
+      state: "failed",
+      try_number: "2",
+    });
+  });
+
+  it("carries nothing unless the layout passes the keys", () => {
+    renderDetailsTabs("?state=failed&log_level=error", false);
+
+    expect(Object.fromEntries(linkSearch("Details"))).toStrictEqual({});
+    expect(Object.fromEntries(linkSearch("Logs"))).toStrictEqual({
+      try_number: "2",
+    });
+  });
+
+  it("carries the filters onto a tab moved to the More menu", async () => {
+    vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockReturnValue({
+      width: TAB_WIDTH,
+    } as DOMRect);
+    vi.mocked(useContainerWidth).mockReturnValue(TAB_WIDTH * 1.5);
+
+    renderDetailsTabs("?state=failed");
+
+    fireEvent.click(screen.getByTestId("nav-tabs-more"));
+    const logs = within(await screen.findByRole("menu")).getByRole("menuitem", 
{
+      name: "Logs",
+    });
+
+    expect(
+      Object.fromEntries(new URL(logs.getAttribute("href") ?? "", 
"http://localhost";).searchParams),
+    ).toStrictEqual({
+      state: "failed",
+      try_number: "2",
+    });
+  });
+});
diff --git a/airflow-core/src/airflow/ui/src/layouts/Details/NavTabs.tsx 
b/airflow-core/src/airflow/ui/src/layouts/Details/NavTabs.tsx
index 55fb68857f4..9aa232f1051 100644
--- a/airflow-core/src/airflow/ui/src/layouts/Details/NavTabs.tsx
+++ b/airflow-core/src/airflow/ui/src/layouts/Details/NavTabs.tsx
@@ -25,6 +25,7 @@ import { NavLink, resolvePath, useLocation, useResolvedPath } 
from "react-router
 
 import { Menu } from "src/system-components";
 
+import { mergePersistentSearchParams } from 
"src/constants/persistentSearchParams";
 import { useContainerWidth } from "src/utils";
 
 export type NavTab = {
@@ -38,10 +39,13 @@ export type NavTab = {
 };
 
 type Props = {
+  /** Query parameters to copy from the current url onto every tab link. */
+  readonly persistentKeys?: ReadonlyArray<string>;
   readonly tabs: Array<NavTab>;
 };
 
 const INDICATOR_HEIGHT = "2px";
+const NO_KEYS: ReadonlyArray<string> = [];
 
 const trimTrailingSlash = (path: string) => path.replace(/\/$/u, "");
 
@@ -86,14 +90,17 @@ const TabContent = ({ active, children, ...rest }: { 
readonly active: boolean }
   </Center>
 );
 
-export const NavTabs = ({ tabs }: Props) => {
+export const NavTabs = ({ persistentKeys = NO_KEYS, tabs }: Props) => {
   const { t: translate } = useTranslation();
   const containerRef = useRef<HTMLDivElement>(null);
   const measureRef = useRef<HTMLDivElement>(null);
   const containerWidth = useContainerWidth(containerRef);
-  const [widths, setWidths] = useState<{ more: number; tabs: Array<number> 
}>({ more: 0, tabs: [] });
+  const [widths, setWidths] = useState<{ more: number; tabs: Array<number> }>({
+    more: 0,
+    tabs: [],
+  });
 
-  const { pathname } = useLocation();
+  const { pathname, search: currentSearch } = useLocation();
   const basePath = useResolvedPath(".").pathname;
   // NavLink compares the raw location against its resolved target, and a run 
id carries ":" and
   // "+". Landing on a link where those arrived percent-encoded leaves the two 
spellings of the
@@ -131,6 +138,10 @@ export const NavTabs = ({ tabs }: Props) => {
       <TabLabel label={label} />
     );
   };
+  const getTabLink = ({ search, value }: NavTab) => ({
+    pathname: value,
+    search: mergePersistentSearchParams(currentSearch, search, persistentKeys),
+  });
   const moreLabel = showLabels ? (
     <HStack as="span" gap={1}>
       {translate("moreTabs")}
@@ -189,7 +200,7 @@ export const NavTabs = ({ tabs }: Props) => {
     >
       {tabs.map((tab, index) =>
         visibleIndexes.has(index) ? (
-          <NavLink end key={tab.value} title={tab.label} to={{ pathname: 
tab.value, search: tab.search }}>
+          <NavLink end key={tab.value} title={tab.label} to={getTabLink(tab)}>
             <TabContent
               active={index === activeIndex}
               aria-current={index === activeIndex ? "page" : undefined}
@@ -218,7 +229,7 @@ export const NavTabs = ({ tabs }: Props) => {
               // The index tabs' value is "", which the menu treats as no 
item, so keyboard
               // navigation could not move off them.
               <Menu.Item asChild key={tab.value} value={`tab:${tab.value}`}>
-                <NavLink to={{ pathname: tab.value, search: tab.search }}>
+                <NavLink to={getTabLink(tab)}>
                   {/* The label names the item; a plugin icon's alt text would 
repeat it. */}
                   <span aria-hidden>{tab.icon}</span>
                   {tab.label}
diff --git 
a/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.test.tsx 
b/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.test.tsx
index e089cb531d2..4d4e2f23adb 100644
--- a/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.test.tsx
+++ b/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.test.tsx
@@ -149,6 +149,19 @@ describe("SearchMapIndexes", () => {
     expect(onClose).toHaveBeenCalled();
   });
 
+  it("keeps the log filters but not the old pass or try across the switch", () 
=> {
+    renderSearch(
+      
`/dags/my_dag/runs/run_1/tasks/task_1/mapped/2/logs?region_id=other&region_index=2&try_number=3&log_level=info&log_source=task&offset=20`,
+      `${MAPPED_ROUTE}/logs`,
+    );
+
+    fireEvent.click(screen.getByRole("button", { name: "alpha (success)" }));
+
+    expect(screen.getByTestId("search").textContent).toBe(
+      `?region_id=${REGION_ID}&region_index=0&log_level=info&log_source=task`,
+    );
+  });
+
   it("keeps the open tab across the switch", () => {
     renderSearch("/dags/my_dag/runs/run_1/tasks/task_1/mapped/2/xcom", 
`${MAPPED_ROUTE}/xcom`);
 
diff --git 
a/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.tsx 
b/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.tsx
index b9ab6011fae..0d717a65988 100644
--- a/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.tsx
+++ b/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.tsx
@@ -32,6 +32,10 @@ import type { TaskInstanceCollectionResponse } from 
"openapi/requests/types.gen"
 import { SearchSelect } from "src/components/SearchSelect";
 import { StateBadge } from "src/components/StateBadge";
 
+import {
+  mergePersistentSearchParams,
+  usePersistentSearchParamKeys,
+} from "src/constants/persistentSearchParams";
 import { SearchParamsKeys } from "src/constants/searchParams";
 import { buildTaskInstanceUrl } from "src/utils/links";
 import type { MapIndexSearchOption } from "src/utils/option";
@@ -72,6 +76,7 @@ export const SearchMapIndexes = ({
   const navigate = useNavigate();
   const { pathname } = useLocation();
   const [searchParams] = useSearchParams();
+  const persistentKeys = usePersistentSearchParamKeys();
 
   const onSelect = (selected: SingleValue<MapIndexSearchOption>) => {
     if (!selected) {
@@ -106,11 +111,15 @@ export const SearchMapIndexes = ({
     // which instance was picked.
     const coordinate =
       selected.regionId === undefined
-        ? ""
-        : `?${new URLSearchParams({ region_id: selected.regionId, 
region_index: String(selected.regionIndex) })}`;
+        ? undefined
+        : new URLSearchParams({
+            region_id: selected.regionId,
+            region_index: String(selected.regionIndex),
+          }).toString();
+    const instanceQuery = mergePersistentSearchParams(searchParams.toString(), 
coordinate, persistentKeys);
 
     onClose();
-    void Promise.resolve(navigate(`${path}${coordinate}`));
+    void Promise.resolve(navigate(`${path}${instanceQuery === "" ? "" : 
`?${instanceQuery}`}`));
   };
 
   const search = useDebouncedCallback((value: string) => {
diff --git 
a/airflow-core/src/airflow/ui/src/layouts/Details/TaskStreamFilter.tsx 
b/airflow-core/src/airflow/ui/src/layouts/Details/TaskStreamFilter.tsx
index b7c19407696..498d6f53898 100644
--- a/airflow-core/src/airflow/ui/src/layouts/Details/TaskStreamFilter.tsx
+++ b/airflow-core/src/airflow/ui/src/layouts/Details/TaskStreamFilter.tsx
@@ -25,16 +25,18 @@ import { useParams, useSearchParams } from 
"react-router-dom";
 
 import { IconButton, Tooltip, Menu } from "src/system-components";
 
+import { TASK_STREAM_SEARCH_PARAMS } from 
"src/constants/persistentSearchParams";
+
 export const TaskStreamFilter = () => {
   const { t: translate } = useTranslation(["common", "dag"]);
   const { taskId: currentTaskId } = useParams();
   const [searchParams, setSearchParams] = useSearchParams();
 
-  const filterRoot = searchParams.get("root") ?? undefined;
-  const includeUpstream = searchParams.get("upstream") === "true";
-  const includeDownstream = searchParams.get("downstream") === "true";
-  const depth = searchParams.get("depth") ?? undefined;
-  const mode = searchParams.get("mode") ?? "static";
+  const filterRoot = searchParams.get(TASK_STREAM_SEARCH_PARAMS.root) ?? 
undefined;
+  const includeUpstream = searchParams.get(TASK_STREAM_SEARCH_PARAMS.upstream) 
=== "true";
+  const includeDownstream = 
searchParams.get(TASK_STREAM_SEARCH_PARAMS.downstream) === "true";
+  const depth = searchParams.get(TASK_STREAM_SEARCH_PARAMS.depth) ?? undefined;
+  const mode = searchParams.get(TASK_STREAM_SEARCH_PARAMS.mode) ?? "static";
 
   const hasActiveFilter = includeUpstream || includeDownstream;
   const isCurrentTaskTheRoot = currentTaskId === filterRoot;
@@ -51,7 +53,7 @@ export const TaskStreamFilter = () => {
       currentTaskId !== "" &&
       currentTaskId !== filterRoot
     ) {
-      searchParams.set("root", currentTaskId);
+      searchParams.set(TASK_STREAM_SEARCH_PARAMS.root, currentTaskId);
       setSearchParams(searchParams, { replace: true });
     }
   }, [currentTaskId, mode, hasActiveFilter, filterRoot, searchParams, 
setSearchParams]);
@@ -68,25 +70,25 @@ export const TaskStreamFilter = () => {
     const hasDepth = newDepth !== undefined && newDepth !== "";
 
     if (upstream) {
-      searchParams.set("upstream", "true");
+      searchParams.set(TASK_STREAM_SEARCH_PARAMS.upstream, "true");
     } else {
-      searchParams.delete("upstream");
+      searchParams.delete(TASK_STREAM_SEARCH_PARAMS.upstream);
     }
     if (downstream) {
-      searchParams.set("downstream", "true");
+      searchParams.set(TASK_STREAM_SEARCH_PARAMS.downstream, "true");
     } else {
-      searchParams.delete("downstream");
+      searchParams.delete(TASK_STREAM_SEARCH_PARAMS.downstream);
     }
     if (hasRoot && hasDirection) {
-      searchParams.set("root", root);
+      searchParams.set(TASK_STREAM_SEARCH_PARAMS.root, root);
     } else {
-      searchParams.delete("root");
-      searchParams.delete("mode");
+      searchParams.delete(TASK_STREAM_SEARCH_PARAMS.root);
+      searchParams.delete(TASK_STREAM_SEARCH_PARAMS.mode);
     }
     if (hasDepth && hasDirection) {
-      searchParams.set("depth", newDepth);
+      searchParams.set(TASK_STREAM_SEARCH_PARAMS.depth, newDepth);
     } else {
-      searchParams.delete("depth");
+      searchParams.delete(TASK_STREAM_SEARCH_PARAMS.depth);
     }
     setSearchParams(searchParams);
   };
@@ -228,7 +230,7 @@ export const TaskStreamFilter = () => {
                   disabled={!hasActiveFilter}
                   flex="1"
                   onClick={() => {
-                    searchParams.set("mode", "static");
+                    searchParams.set(TASK_STREAM_SEARCH_PARAMS.mode, "static");
                     setSearchParams(searchParams);
                   }}
                   variant={mode === "static" ? "solid" : "outline"}
@@ -239,7 +241,7 @@ export const TaskStreamFilter = () => {
                   disabled={!hasActiveFilter}
                   flex="1"
                   onClick={() => {
-                    searchParams.set("mode", "traverse");
+                    searchParams.set(TASK_STREAM_SEARCH_PARAMS.mode, 
"traverse");
                     setSearchParams(searchParams);
                   }}
                   variant={mode === "traverse" ? "solid" : "outline"}
diff --git 
a/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/LogSearchInput.tsx 
b/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/LogSearchInput.tsx
index a04d9a82d73..d2bad4d606f 100644
--- a/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/LogSearchInput.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/LogSearchInput.tsx
@@ -29,6 +29,7 @@ import { useShortcut } from "src/hooks/useShortcut";
 
 export type LogSearchInputProps = {
   readonly currentMatchIndex: number;
+  readonly onSearchBlur?: () => void;
   readonly onSearchChange: (query: string) => void;
   readonly onSearchNext: () => void;
   readonly onSearchPrevious: () => void;
@@ -38,6 +39,7 @@ export type LogSearchInputProps = {
 
 export const LogSearchInput = ({
   currentMatchIndex,
+  onSearchBlur,
   onSearchChange,
   onSearchNext,
   onSearchPrevious,
@@ -108,6 +110,7 @@ export const LogSearchInput = ({
       >
         <Input
           data-testid="log-search-input"
+          onBlur={onSearchBlur}
           onChange={(event) => onSearchChange(event.target.value)}
           onKeyDown={handleSearchKeyDown}
           placeholder={translate("logs.search.placeholder")}
diff --git 
a/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/Logs.test.tsx 
b/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/Logs.test.tsx
index 7258da33b3c..667a629b3d5 100644
--- a/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/Logs.test.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/Logs.test.tsx
@@ -17,13 +17,16 @@
  * under the License.
  */
 import "@testing-library/jest-dom/vitest";
-import { fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { act, fireEvent, render, screen, waitFor } from 
"@testing-library/react";
 import { afterEach, beforeAll, describe, expect, it } from "vitest";
 
 // Resolve the route module during test collection, outside the per-test 
timeout.
 import "src/pages/TaskInstance";
 
-import { AppWrapper } from "src/utils/AppWrapper";
+import i18n from "src/i18n/config";
+import { AppWrapper, createAppRouter } from "src/utils/AppWrapper";
+
+import dagLocale from "../../../../public/i18n/locales/en/dag.json";
 
 const ITEM_HEIGHT = 20;
 
@@ -97,10 +100,10 @@ const selectSetting = async (testId: string) => {
   fireEvent.click(await screen.findByTestId(testId));
 };
 
-const renderLogSourceTask = async () => {
-  render(
-    <AppWrapper 
initialEntries={["/dags/log_grouping/runs/manual__2025-02-18T12:19/tasks/log_source"]}
 />,
-  );
+const logSourcePath = 
"/dags/log_grouping/runs/manual__2025-02-18T12:19/tasks/log_source";
+
+const renderLogSourceTask = async (search = "") => {
+  render(<AppWrapper initialEntries={[`${logSourcePath}${search}`]} />);
   await waitForLogs();
 
   return screen.getByTestId("virtualized-list");
@@ -311,6 +314,84 @@ describe("Task log search", () => {
     expect(screen.getByTestId("log-search-input")).toBeInTheDocument();
   });
 
+  it("seeds the search query from the url, so it outlives the unmount a tab 
change causes", async () => {
+    await renderLogSourceTask("?log_search=running");
+
+    expect(screen.getByTestId("log-search-input")).toHaveValue("running");
+  });
+
+  it("writes the search query to the url and removes it when cleared", async 
() => {
+    const router = createAppRouter([logSourcePath]);
+
+    render(<AppWrapper router={router} />);
+    await waitForLogs();
+
+    fireEvent.change(screen.getByTestId("log-search-input"), { target: { 
value: "running state" } });
+    await waitFor(() =>
+      expect(new 
URLSearchParams(router.state.location.search).get("log_search")).toBe("running 
state"),
+    );
+
+    fireEvent.change(screen.getByTestId("log-search-input"), { target: { 
value: "" } });
+    await waitFor(() => 
expect(router.state.location.search).not.toContain("log_search"));
+  });
+
+  it("puts a search typed just before leaving on the tab links", async () => {
+    render(<AppWrapper initialEntries={[logSourcePath]} />);
+    await waitForLogs();
+
+    const searchInput = screen.getByTestId("log-search-input");
+
+    fireEvent.change(searchInput, { target: { value: "running" } });
+    // A real click blurs the focused input on mousedown, before the link 
navigates. The short timeout
+    // keeps the 200ms debounce from writing the url on its own.
+    fireEvent.blur(searchInput);
+    await waitFor(
+      () =>
+        
expect(document.querySelector(`a[href^="${logSourcePath}/xcom"]`)?.getAttribute("href")).toContain(
+          "log_search=running",
+        ),
+      { timeout: 100 },
+    );
+  });
+
+  it("keeps the selected match when the debounced url write lands", async () 
=> {
+    // Only the counter's string, so the other tests keep matching buttons by 
their keys.
+    i18n.addResource("en", "dag", "logs.search.matchCount", 
dagLocale.logs.search.matchCount);
+    const router = createAppRouter([logSourcePath]);
+
+    render(<AppWrapper router={router} />);
+    await waitForLogs();
+
+    const searchInput = screen.getByTestId("log-search-input");
+    const matchCount = () => screen.getByRole("button", { name: 
/previousMatch/u }).previousElementSibling;
+
+    fireEvent.change(searchInput, { target: { value: "state" } });
+    fireEvent.keyDown(searchInput, { key: "Enter" });
+    const afterEnter = matchCount()?.textContent;
+
+    await waitFor(() => 
expect(router.state.location.search).toContain("log_search=state"));
+    // Let the page re-render from the new url before reading the counter 
again.
+    await act(() => Promise.resolve());
+
+    expect(afterEnter).toMatch(/^2 of /u);
+    expect(matchCount()?.textContent).toBe(afterEnter);
+  });
+
+  it("follows the url search query on back navigation", async () => {
+    const router = createAppRouter(
+      [`${logSourcePath}?log_search=running`, 
`${logSourcePath}?log_search=state`],
+      1,
+    );
+
+    render(<AppWrapper router={router} />);
+    await waitForLogs();
+    expect(screen.getByTestId("log-search-input")).toHaveValue("state");
+
+    await act(() => router.navigate(-1));
+
+    expect(screen.getByTestId("log-search-input")).toHaveValue("running");
+  });
+
   it("typing in the search input enables navigation buttons for a known term", 
async () => {
     render(
       <AppWrapper 
initialEntries={["/dags/log_grouping/runs/manual__2025-02-18T12:19/tasks/log_source"]}
 />,
diff --git a/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/Logs.tsx 
b/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/Logs.tsx
index 6baed126def..dba32e4cd1a 100644
--- a/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/Logs.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/Logs.tsx
@@ -21,6 +21,7 @@ import { useState } from "react";
 import { Box, Button, Heading } from "@chakra-ui/react";
 import { useTranslation } from "react-i18next";
 import { useParams, useSearchParams } from "react-router-dom";
+import { useDebouncedCallback } from "use-debounce";
 import { useLocalStorage } from "usehooks-ts";
 
 import { Alert, Modal } from "src/system-components";
@@ -33,6 +34,7 @@ import {
   LOG_SHOW_TIMESTAMP_KEY,
   LOG_WRAP_KEY,
 } from "src/constants/localStorage";
+import { LOG_SEARCH_PARAMS } from "src/constants/persistentSearchParams";
 import { SearchParamsKeys } from "src/constants/searchParams";
 import { SHORTCUTS } from "src/context/keyboardShortcuts";
 import { useShortcut } from "src/hooks/useShortcut";
@@ -45,6 +47,8 @@ import { TaskLogContent, type TaskLogContentProps } from 
"./TaskLogContent";
 import { TaskLogHeader, type TaskLogHeaderProps } from "./TaskLogHeader";
 import { getDownloadText } from "./utils";
 
+const debounceDelay = 200;
+
 export const Logs = () => {
   const { dagId = "", taskId = "" } = useParams();
   const [searchParams, setSearchParams] = useSearchParams();
@@ -52,8 +56,8 @@ export const Logs = () => {
   const { t: translate } = useTranslation("dag");
 
   const tryNumberParam = searchParams.get(SearchParamsKeys.TRY_NUMBER);
-  const logLevelFilters = searchParams.getAll(SearchParamsKeys.LOG_LEVEL);
-  const sourceFilters = searchParams.getAll(SearchParamsKeys.SOURCE);
+  const logLevelFilters = searchParams.getAll(LOG_SEARCH_PARAMS.level);
+  const sourceFilters = searchParams.getAll(LOG_SEARCH_PARAMS.source);
 
   const defaultTryNumber = taskInstance?.try_number;
 
@@ -115,7 +119,9 @@ export const Logs = () => {
 
   const getLogString = () => downloadTextLines.filter((line) => line !== 
"").join("\n");
 
-  const [searchQuery, setSearchQuery] = useState("");
+  const urlSearchQuery = searchParams.get(LOG_SEARCH_PARAMS.search) ?? "";
+  const [searchQuery, setSearchQuery] = useState(urlSearchQuery);
+  const [lastUrlSearchQuery, setLastUrlSearchQuery] = useState(urlSearchQuery);
   const [activeSearchIndex, setActiveSearchIndex] = useState(0);
 
   const searchMatchIndices = (() => {
@@ -134,9 +140,37 @@ export const Logs = () => {
     return indices;
   })();
 
+  // Local state keeps the highlighting responsive; the url follows 
(debounced) so the query survives a
+  // tab change and can be shared.
+  const syncSearchParam = useDebouncedCallback((query: string) => {
+    setSearchParams(
+      (params) => {
+        if (query === "") {
+          params.delete(LOG_SEARCH_PARAMS.search);
+        } else {
+          params.set(LOG_SEARCH_PARAMS.search, query);
+        }
+
+        return params;
+      },
+      { replace: true },
+    );
+  }, debounceDelay);
+
+  // Back/Forward can change the url without remounting; adopt it unless a 
typed edit is still pending.
+  // The debounced write of the box's own query also lands here, and must not 
reset the selected match.
+  if (urlSearchQuery !== lastUrlSearchQuery) {
+    setLastUrlSearchQuery(urlSearchQuery);
+    if (!syncSearchParam.isPending() && urlSearchQuery !== searchQuery) {
+      setSearchQuery(urlSearchQuery);
+      setActiveSearchIndex(0);
+    }
+  }
+
   const handleSearchChange = (query: string) => {
     setSearchQuery(query);
     setActiveSearchIndex(0);
+    syncSearchParam(query);
   };
 
   const handleSearchNext = () => {
@@ -219,6 +253,10 @@ export const Logs = () => {
     onSelectTryNumber,
     search: {
       currentMatchIndex: activeSearchIndex,
+      // Clicking a tab blurs the input before the link navigates, so the link 
carries the last keystrokes.
+      onSearchBlur: () => {
+        syncSearchParam.flush();
+      },
       onSearchChange: handleSearchChange,
       onSearchNext: handleSearchNext,
       onSearchPrevious: handleSearchPrevious,
diff --git 
a/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogHeader.tsx 
b/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogHeader.tsx
index d10c92e1f07..18900179049 100644
--- a/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogHeader.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogHeader.tsx
@@ -37,7 +37,7 @@ import { IconButton, Menu, Select, LazyClipboard } from 
"src/system-components";
 
 import { TaskTrySelect } from "src/components/TaskTrySelect";
 
-import { SearchParamsKeys } from "src/constants/searchParams";
+import { LOG_SEARCH_PARAMS } from "src/constants/persistentSearchParams";
 import { defaultSystem } from "src/theme";
 import { type LogLevel, logLevelColorMapping, logLevelOptions } from 
"src/utils/logs";
 
@@ -88,8 +88,8 @@ export const TaskLogHeader = ({
 }: TaskLogHeaderProps) => {
   const { t: translate } = useTranslation(["common", "dag", "components"]);
   const [searchParams, setSearchParams] = useSearchParams();
-  const sources = searchParams.getAll(SearchParamsKeys.SOURCE);
-  const logLevels = searchParams.getAll(SearchParamsKeys.LOG_LEVEL);
+  const sources = searchParams.getAll(LOG_SEARCH_PARAMS.source);
+  const logLevels = searchParams.getAll(LOG_SEARCH_PARAMS.level);
   const hasLogLevels = logLevels.length > 0;
 
   // Have select zIndex greater than dialog zIndex in fullscreen so that
@@ -112,12 +112,12 @@ export const TaskLogHeader = ({
     const [val, ...rest] = value;
 
     if (((val === undefined || val === "all") && rest.length === 0) || 
rest.includes("all")) {
-      searchParams.delete(SearchParamsKeys.LOG_LEVEL);
+      searchParams.delete(LOG_SEARCH_PARAMS.level);
     } else {
-      searchParams.delete(SearchParamsKeys.LOG_LEVEL);
+      searchParams.delete(LOG_SEARCH_PARAMS.level);
       value
         .filter((state) => state !== "all")
-        .map((state) => searchParams.append(SearchParamsKeys.LOG_LEVEL, 
state));
+        .map((state) => searchParams.append(LOG_SEARCH_PARAMS.level, state));
     }
     setSearchParams(searchParams);
   };
@@ -126,12 +126,12 @@ export const TaskLogHeader = ({
     const [val, ...rest] = value;
 
     if (((val === undefined || val === "all") && rest.length === 0) || 
rest.includes("all")) {
-      searchParams.delete(SearchParamsKeys.SOURCE);
+      searchParams.delete(LOG_SEARCH_PARAMS.source);
     } else {
-      searchParams.delete(SearchParamsKeys.SOURCE);
+      searchParams.delete(LOG_SEARCH_PARAMS.source);
       value
         .filter((state) => state !== "all")
-        .map((state) => searchParams.append(SearchParamsKeys.SOURCE, state));
+        .map((state) => searchParams.append(LOG_SEARCH_PARAMS.source, state));
     }
     setSearchParams(searchParams);
   };
diff --git 
a/airflow-core/src/airflow/ui/src/pages/TaskInstance/TaskInstance.test.tsx 
b/airflow-core/src/airflow/ui/src/pages/TaskInstance/TaskInstance.test.tsx
index b4d18fa47f5..9c810888040 100644
--- a/airflow-core/src/airflow/ui/src/pages/TaskInstance/TaskInstance.test.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/TaskInstance/TaskInstance.test.tsx
@@ -30,6 +30,8 @@ import { TaskInstanceService, type TaskInstanceResponse } 
from "openapi/requests
 
 import { NavTabs, type NavTab } from "src/layouts/Details/NavTabs";
 
+import { usePersistentSearchParamKeys } from 
"src/constants/persistentSearchParams";
+
 import { HITLResponse } from "./HITLResponse";
 import { TaskInstance } from "./TaskInstance";
 
@@ -61,7 +63,7 @@ vi.mock("src/layouts/Details/DetailsLayout", () => ({
     <>
       {children}
       {error === null || error === undefined ? undefined : <div 
data-testid="layout-error" />}
-      <NavTabs tabs={tabs} />
+      <NavTabs persistentKeys={usePersistentSearchParamKeys()} tabs={tabs} />
       <Outlet />
     </>
   ),
@@ -332,8 +334,8 @@ describe("TaskInstance", () => {
     
expect(screen.getByTestId("location").textContent).toContain("region_index=3");
   });
 
-  it.each(["", "?try_number=1&log_level=error"])(
-    "keeps the selected try across task tabs with %s",
+  it.each(["", 
"?try_number=1&log_level=error&log_source=task&log_search=boom&offset=20"])(
+    "keeps the selected try and the log filters across task tabs with %s",
     async (search) => {
       const queryClient = new QueryClient({ defaultOptions: { queries: { 
retry: false } } });
 
@@ -354,7 +356,7 @@ describe("TaskInstance", () => {
         { wrapper: createWrapper(queryClient) },
       );
       expect(await screen.findByText(`${TASK_A}:up_for_retry:2`)).toBeTruthy();
-      const expectedSearch = search ? "?try_number=1" : "";
+      const expectedSearch = search ? 
"?try_number=1&log_level=error&log_search=boom&log_source=task" : "";
 
       fireEvent.click(screen.getByRole("link", { name: "tabs.details" }));
       
expect(screen.getByTestId("location")).toHaveTextContent(`${path}/details${expectedSearch}`);
@@ -362,7 +364,7 @@ describe("TaskInstance", () => {
       
expect(screen.getByTestId("location")).toHaveTextContent(`${path}/required_actions${expectedSearch}`);
       fireEvent.click(screen.getByRole("link", { name: "tabs.logs" }));
       
expect(screen.getByTestId("location")).toHaveTextContent(`${path}${expectedSearch}`);
-      
expect(screen.getByTestId("location")).not.toHaveTextContent("log_level");
+      expect(screen.getByTestId("location")).not.toHaveTextContent("offset");
     },
   );
 
diff --git 
a/airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.test.tsx 
b/airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.test.tsx
index d4a60bf3ecd..e02fb8f631a 100644
--- a/airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.test.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.test.tsx
@@ -227,6 +227,29 @@ describe("TaskInstances", () => {
     );
   });
 
+  it.each([
+    {
+      description: "keeps the log and grid filters inside a Dag",
+      expected: "&state=failed&log_source=task",
+      params: { dagId: "example_dag", runId: 
"manual__2026-06-07T00:00:00+00:00", taskId: "mapped_task" },
+    },
+    { description: "carries nothing from the list across Dags", expected: "", 
params: {} },
+  ])("$description, but never the list's paging", ({ expected, params }) => {
+    mockParams = params;
+    mockSearchParams = new 
URLSearchParams("log_source=task&state=failed&offset=50");
+    vi.mocked(useTaskInstanceServiceGetTaskInstances).mockReturnValue(
+      getTaskInstancesResponse([mappedTaskInstance]),
+    );
+
+    render(<TaskInstances />, { wrapper: Wrapper });
+
+    expect(screen.getByRole("link", { name: "1" })).toHaveAttribute(
+      "href",
+      
`/dags/example_dag/runs/manual__2026-06-07T00:00:00+00:00/tasks/mapped_task/mapped/1?region_id=11111111-1111-4111-8111-111111111111&region_index=1${expected}`,
+    );
+    mockSearchParams = new URLSearchParams();
+  });
+
   it("does not link non-mapped task instances from the map index column", () 
=> {
     vi.mocked(useTaskInstanceServiceGetTaskInstances).mockReturnValue(
       getTaskInstancesResponse([{ ...mappedTaskInstance, map_index: -1, 
rendered_map_index: null }]),
@@ -327,6 +350,30 @@ describe("TaskInstances", () => {
   });
 });
 
+// The pattern reaches the api as a prefix match unless advanced search is on, 
so check both names.
+const runIdFilter = () =>
+  
vi.mocked(useTaskInstanceServiceGetTaskInstances).mock.lastCall?.[0]?.runIdPattern
 ??
+  
vi.mocked(useTaskInstanceServiceGetTaskInstances).mock.lastCall?.[0]?.runIdPrefixPattern;
+
+describe("TaskInstances run id filter", () => {
+  beforeEach(() => {
+    
vi.mocked(useTaskInstanceServiceGetTaskInstances).mockReturnValue(getTaskInstancesResponse([]));
+    mockSearchParams = new URLSearchParams("run_id_pattern=nomatch");
+  });
+
+  it("ignores a run id pattern once the route already pins the run", () => {
+    mockParams = { dagId: "example_dag", runId: 
"manual__2026-06-07T00:00:00+00:00" };
+    render(<TaskInstances />, { wrapper: Wrapper });
+    expect(runIdFilter()).toBeUndefined();
+  });
+
+  it("still applies a run id pattern on the list across runs", () => {
+    mockParams = { dagId: "example_dag" };
+    render(<TaskInstances />, { wrapper: Wrapper });
+    expect(runIdFilter()).toBe("nomatch");
+  });
+});
+
 describe("TaskInstances date filters", () => {
   beforeEach(() => {
     mockParams = { dagId: "example_dag", runId: 
"manual__2026-06-07T00:00:00+00:00" };
diff --git 
a/airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx 
b/airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx
index 479ceaf0fa5..6a1a2af3f0a 100644
--- a/airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/TaskInstances/TaskInstances.tsx
@@ -49,6 +49,10 @@ import { TeamName } from "src/components/TeamName";
 import Time from "src/components/Time";
 import { TruncatedText } from "src/components/TruncatedText";
 
+import {
+  mergePersistentSearchParams,
+  usePersistentSearchParamKeys,
+} from "src/constants/persistentSearchParams";
 import { SearchParamsKeys, type SearchParamsKeysType } from 
"src/constants/searchParams";
 import { useAdvancedSearchArg } from "src/hooks/useAdvancedSearch";
 import { usePluginActions } from "src/hooks/usePluginActions";
@@ -96,6 +100,7 @@ const {
 
 type ColumnProps = {
   readonly dagId?: string;
+  readonly getLink: (ti: TaskInstanceResponse) => string;
   readonly hasLoopIteration: boolean;
   readonly runId?: string;
   readonly taskId?: string;
@@ -104,6 +109,7 @@ type ColumnProps = {
 
 const taskInstanceColumns = ({
   dagId,
+  getLink,
   hasLoopIteration,
   multiTeam,
   runId,
@@ -141,7 +147,7 @@ const taskInstanceColumns = ({
           accessorKey: "run_after",
           cell: ({ row: { original } }: TaskInstanceRow) =>
             Boolean(taskId) ? (
-              <RouterLink fontWeight="bold" to={getTaskInstanceLink(original)}>
+              <RouterLink fontWeight="bold" to={getLink(original)}>
                 <Time datetime={original.run_after} />
               </RouterLink>
             ) : (
@@ -166,7 +172,7 @@ const taskInstanceColumns = ({
         {
           accessorKey: "task_display_name",
           cell: ({ row: { original } }: TaskInstanceRow) => (
-            <RouterLink fontWeight="bold" to={getTaskInstanceLink(original)}>
+            <RouterLink fontWeight="bold" to={getLink(original)}>
               <TruncatedText text={original.task_display_name} />
             </RouterLink>
           ),
@@ -179,7 +185,7 @@ const taskInstanceColumns = ({
     // Map index remains visible before a mapped task instance starts.
     cell: ({ row: { original } }) =>
       original.map_index >= 0 ? (
-        <RouterLink fontWeight="bold" to={getTaskInstanceLink(original)}>
+        <RouterLink fontWeight="bold" to={getLink(original)}>
           {original.rendered_map_index ?? original.map_index}
         </RouterLink>
       ) : (
@@ -235,7 +241,7 @@ const taskInstanceColumns = ({
     accessorKey: "start_date",
     cell: ({ row: { original } }) =>
       Boolean(taskId) && Boolean(runId) ? (
-        <RouterLink fontWeight="bold" to={getTaskInstanceLink(original)}>
+        <RouterLink fontWeight="bold" to={getLink(original)}>
           <Time datetime={original.start_date} />
         </RouterLink>
       ) : (
@@ -359,7 +365,9 @@ export const TaskInstances = () => {
   const operatorNamePattern = searchParams.get(OPERATOR_NAME_PATTERN_PARAM);
   const renderedMapIndexFilter = searchParams.get(RENDERED_MAP_INDEX_PARAM);
   const filteredDagIdPattern = searchParams.get(DAG_ID_PATTERN_PARAM);
-  const filteredRunId = searchParams.get(RUN_ID_PATTERN_PARAM);
+  // TaskInstancesFilter only offers a run id filter when no run is in the 
route. Applying one anyway
+  // lets a pattern carried over from the grid empty this table with no filter 
chip there to clear it.
+  const filteredRunId = runId === undefined ? 
searchParams.get(RUN_ID_PATTERN_PARAM) : null;
   const hasFilteredState = filteredState.length > 0;
   const taskDisplayNamePattern = searchParams.get(NAME_PATTERN_PARAM);
   const teams = searchParams.getAll(TEAMS_PARAM);
@@ -471,8 +479,24 @@ export const TaskInstances = () => {
 
   const pluginActions = usePluginActions("task_instance");
 
+  const persistentKeys = usePersistentSearchParamKeys();
+  // Inside a Dag the grid and the log panel stay on screen, so a row link 
keeps their filters
+  // the way a tab link does.
+  const getLink = (ti: TaskInstanceResponse) => {
+    const link = getTaskInstanceLink(ti);
+
+    if (dagId === undefined) {
+      return link;
+    }
+    const [pathname = "", linkSearch] = link.split("?");
+    const query = mergePersistentSearchParams(searchParams.toString(), 
linkSearch, persistentKeys);
+
+    return query === "" ? pathname : `${pathname}?${query}`;
+  };
+
   const columns = taskInstanceColumns({
     dagId,
+    getLink,
     hasLoopIteration: (data?.task_instances ?? []).some(
       (ti) => ti.loop_iteration !== null && ti.loop_iteration !== undefined,
     ),
diff --git a/airflow-core/src/airflow/ui/src/pages/XCom/XCom.test.tsx 
b/airflow-core/src/airflow/ui/src/pages/XCom/XCom.test.tsx
index 7e2f9f2b3ca..995cea20b40 100644
--- a/airflow-core/src/airflow/ui/src/pages/XCom/XCom.test.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/XCom/XCom.test.tsx
@@ -25,7 +25,9 @@ import type * as ColorMode from "src/context/colorMode";
 import { server } from "src/mocks/server";
 import { AppWrapper, preloadAppRoutes } from "src/utils/AppWrapper";
 
-beforeAll(() => preloadAppRoutes(["/xcoms"]));
+const TI_XCOM_PATH = 
"/dags/log_grouping/runs/manual__2025-02-18T12:19/tasks/log_source/xcom";
+
+beforeAll(() => preloadAppRoutes(["/xcoms", TI_XCOM_PATH]));
 
 vi.mock("src/components/MonacoEditor", () => ({
   default: ({ value }: { readonly value?: string }) => <div 
data-testid="monaco-editor">{value}</div>,
@@ -92,3 +94,36 @@ describe("XCom list", () => {
     expect(requested).toContain("true");
   });
 });
+
+// The pattern reaches the api as a prefix match unless advanced search is on, 
so check both names.
+const runIdFilter = (search: URLSearchParams) =>
+  search.get("run_id_pattern") ?? search.get("run_id_prefix_pattern");
+
+const requestedSearch = (): Promise<URLSearchParams> =>
+  new Promise((resolve) => {
+    server.use(
+      
http.get("/api/v2/dags/:dagId/dagRuns/:runId/taskInstances/:taskId/xcomEntries",
 ({ request }) => {
+        resolve(new URL(request.url).searchParams);
+
+        return HttpResponse.json({ total_entries: 1, xcom_entries: [xcomEntry] 
});
+      }),
+    );
+  });
+
+describe("XCom run id filter", () => {
+  it("ignores a run id pattern once the route already pins the run", async () 
=> {
+    const search = requestedSearch();
+
+    render(<AppWrapper 
initialEntries={[`${TI_XCOM_PATH}?run_id_pattern=nomatch`]} />);
+
+    expect(runIdFilter(await search)).toBeNull();
+  });
+
+  it("still applies a run id pattern on the list across runs", async () => {
+    const search = requestedSearch();
+
+    render(<AppWrapper initialEntries={["/xcoms?run_id_pattern=manual"]} />);
+
+    expect(runIdFilter(await search)).toBe("manual");
+  });
+});
diff --git a/airflow-core/src/airflow/ui/src/pages/XCom/XCom.tsx 
b/airflow-core/src/airflow/ui/src/pages/XCom/XCom.tsx
index 118bf242aa8..6265547392e 100644
--- a/airflow-core/src/airflow/ui/src/pages/XCom/XCom.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/XCom/XCom.tsx
@@ -200,7 +200,9 @@ export const XCom = () => {
   const filteredKey = searchParams.get(KEY_PATTERN_PARAM);
   const filteredDagDisplayName = 
searchParams.get(DAG_DISPLAY_NAME_PATTERN_PARAM);
   const filteredMapIndex = searchParams.get(MAP_INDEX_PARAM);
-  const filteredRunId = searchParams.get(RUN_ID_PATTERN_PARAM);
+  // XComFilters only offers a run id filter when no run is in the route. 
Applying one anyway lets a
+  // pattern carried over from the grid empty this table with no filter chip 
there to clear it.
+  const filteredRunId = runId === "~" ? searchParams.get(RUN_ID_PATTERN_PARAM) 
: null;
   const filteredTaskId = searchParams.get(TASK_ID_PATTERN_PARAM);
   const teams = searchParams.getAll(TEAMS_PARAM);
 
diff --git a/airflow-core/src/airflow/ui/src/utils/AppWrapper.tsx 
b/airflow-core/src/airflow/ui/src/utils/AppWrapper.tsx
index e637feba5f6..8ed0b271efc 100644
--- a/airflow-core/src/airflow/ui/src/utils/AppWrapper.tsx
+++ b/airflow-core/src/airflow/ui/src/utils/AppWrapper.tsx
@@ -23,7 +23,8 @@ import { routerConfig } from "src/router";
 import { BaseWrapper } from "src/utils/Wrapper";
 
 type Props = {
-  readonly initialEntries: Array<string>;
+  readonly initialEntries?: Array<string>;
+  readonly router?: ReturnType<typeof createAppRouter>;
 };
 
 export const preloadAppRoutes = async (initialEntries: Array<string>) => {
@@ -40,20 +41,19 @@ export const preloadAppRoutes = async (initialEntries: 
Array<string>) => {
   await Promise.all([...routeLoaders].map((loadRoute) => loadRoute()));
 };
 
-export const AppWrapper = ({ initialEntries }: Props) => {
-  // Strip the config loader from tests
-  const config = routerConfig.map((route) => ({
-    ...route,
-    loader: undefined,
-  }));
-
-  const router = createMemoryRouter(config, { basename: "/", initialEntries });
-
-  return (
-    <BaseWrapper>
-      <TimezoneProvider>
-        <RouterProvider router={router} />
-      </TimezoneProvider>
-    </BaseWrapper>
+export const createAppRouter = (initialEntries: Array<string>, initialIndex?: 
number) =>
+  createMemoryRouter(
+    // Strip the config loader from tests
+    routerConfig.map((route) => ({ ...route, loader: undefined })),
+    { basename: "/", initialEntries, initialIndex },
   );
-};
+
+const rootEntries = ["/"];
+
+export const AppWrapper = ({ initialEntries = rootEntries, router }: Props) => 
(
+  <BaseWrapper>
+    <TimezoneProvider>
+      <RouterProvider router={router ?? createAppRouter(initialEntries)} />
+    </TimezoneProvider>
+  </BaseWrapper>
+);

Reply via email to