From d4cfb24a4a47f2da07f657461db17038751b5f00 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 27 Feb 2026 14:26:28 -0500 Subject: [PATCH] fix: update document title when switching agents on the agents page (#22401) When navigating to a specific agent on the Agents page, the browser tab title now reflects the agent's chat title (e.g. `Fix login bug - Agents - Coder`). When the title hasn't loaded yet or when navigating away, it falls back to `Agents - Coder`. **Changes:** - Added a `useEffect` in `AgentDetail` that sets `document.title` via the existing `pageTitle` utility whenever the chat title changes. - The cleanup function resets the title back to `Agents - Coder` when unmounting (navigating away from the agent). --- site/src/pages/AgentsPage/AgentDetail.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/site/src/pages/AgentsPage/AgentDetail.tsx b/site/src/pages/AgentsPage/AgentDetail.tsx index 0d59555cfc..116ed2ae17 100644 --- a/site/src/pages/AgentsPage/AgentDetail.tsx +++ b/site/src/pages/AgentsPage/AgentDetail.tsx @@ -27,6 +27,7 @@ import { import { useMutation, useQuery, useQueryClient } from "react-query"; import { useNavigate, useOutletContext, useParams } from "react-router"; import { toast } from "sonner"; +import { pageTitle } from "utils/page"; import { AgentChatInput } from "./AgentChatInput"; import { selectChatStatus, @@ -675,6 +676,17 @@ const AgentDetail: FC = () => { const topBarActionsRef = outletContext?.topBarActionsRef; const rightPanelRef = outletContext?.rightPanelRef; const chatTitle = chatQuery.data?.chat?.title; + + // Update the browser tab title when navigating to / between agents. + useEffect(() => { + document.title = chatTitle + ? pageTitle(chatTitle, "Agents") + : pageTitle("Agents"); + return () => { + document.title = pageTitle("Agents"); + }; + }, [chatTitle]); + const parentChatID = getParentChatID(chatQuery.data?.chat); const parentChat = parentChatID ? chatsQuery.data?.find((chat) => chat.id === parentChatID)