|
7 | 7 | type ErrorComponentProps, |
8 | 8 | useLocation, |
9 | 9 | useNavigate, |
| 10 | + useParams, |
10 | 11 | } from "@tanstack/react-router"; |
11 | 12 | import { useEffect, useEffectEvent, useRef, useState } from "react"; |
12 | 13 |
|
@@ -50,7 +51,8 @@ import { |
50 | 51 | primaryServerConfigEventAtom, |
51 | 52 | primaryServerWelcomeAtom, |
52 | 53 | } from "../state/server"; |
53 | | -import { readProject, setActiveEnvironmentId, useActiveEnvironmentId } from "../state/entities"; |
| 54 | +import { readProject, setActiveEnvironmentId, useActiveEnvironmentId, useProject, useThreadShell } from "../state/entities"; |
| 55 | +import { resolveThreadRouteRef } from "../threadRoutes"; |
54 | 56 | import { |
55 | 57 | createKeybindingsUpdateToastController, |
56 | 58 | type KeybindingsUpdateToastController, |
@@ -193,14 +195,20 @@ function FontAppearanceSync() { |
193 | 195 | } |
194 | 196 |
|
195 | 197 | function DocumentTitleSync() { |
| 198 | + const threadRef = useParams({ strict: false, select: resolveThreadRouteRef }); |
| 199 | + const thread = useThreadShell(threadRef); |
| 200 | + const project = useProject( |
| 201 | + thread ? scopeProjectRef(thread.environmentId, thread.projectId) : null, |
| 202 | + ); |
196 | 203 | const primaryServerVersion = |
197 | 204 | useAtomValue(primaryServerConfigAtom)?.environment.serverVersion ?? null; |
198 | | - const title = resolveServerBackedAppDisplayName({ |
| 205 | + const appTitle = resolveServerBackedAppDisplayName({ |
199 | 206 | baseName: APP_BASE_NAME, |
200 | 207 | fallbackDisplayName: APP_DISPLAY_NAME, |
201 | 208 | fallbackStageLabel: APP_STAGE_LABEL, |
202 | 209 | primaryServerVersion, |
203 | 210 | }); |
| 211 | + const title = thread && project ? `${thread.title} — ${project.title}` : appTitle; |
204 | 212 |
|
205 | 213 | useEffect(() => { |
206 | 214 | document.title = title; |
|
0 commit comments