diff --git a/apps/web/src/cloud/managedRelayState.ts b/apps/web/src/cloud/managedRelayState.ts index 679f362fdf5a0..7efdf9dc63b1f 100644 --- a/apps/web/src/cloud/managedRelayState.ts +++ b/apps/web/src/cloud/managedRelayState.ts @@ -190,10 +190,13 @@ export function useManagedTunnelUsage() { (environment) => environment.endpoint.providerKind === "cloudflare_tunnel", ).length ?? null); const cap = t3Chat.accountId !== null && t3Chat.data ? managedTunnelCap(t3Chat.data) : null; + const firstLoad = (query: { accountId: string | null; data: unknown; isPending: boolean }) => + query.accountId !== null && query.data === null && query.isPending; return { used, limit: cap?.limit ?? null, upgrade: cap?.upgrade ?? null, + loading: firstLoad(environments) || firstLoad(t3Chat), refresh: refreshManagedTunnelUsage, }; } diff --git a/apps/web/src/components/cloud/TunnelUsage.tsx b/apps/web/src/components/cloud/TunnelUsage.tsx index 5fe4f34e8f5ce..f9d170f9dbea4 100644 --- a/apps/web/src/components/cloud/TunnelUsage.tsx +++ b/apps/web/src/components/cloud/TunnelUsage.tsx @@ -8,6 +8,7 @@ import { m, type MessageResolver } from "../../i18n/messages"; import { cn } from "../../lib/utils"; import { Alert, AlertAction, AlertDescription, AlertTitle } from "../ui/alert"; import { Button } from "../ui/button"; +import { Skeleton } from "../ui/skeleton"; // Above this, one slot per tunnel is too thin to read, so the bar fills instead. const MAX_SEGMENTS = 10; @@ -40,6 +41,18 @@ export function tunnelUpgradeCopy( } } +/** Holds the meter's height while usage loads, so the rows below it stay put. */ +export function TunnelUsageMeterSkeleton() { + return ( +
+
+ +
+ +
+ ); +} + /** "2 of 3 tunnels in use" with one bar slot per tunnel. */ export function TunnelUsageMeter({ used, diff --git a/apps/web/src/components/settings/KeybindingsSettings.tsx b/apps/web/src/components/settings/KeybindingsSettings.tsx index bbe05c925be25..b3a754b3e8786 100644 --- a/apps/web/src/components/settings/KeybindingsSettings.tsx +++ b/apps/web/src/components/settings/KeybindingsSettings.tsx @@ -18,6 +18,7 @@ import { type KeyboardEvent, type ReactNode, type RefObject, + useDeferredValue, useReducer, useRef, useState, @@ -50,6 +51,7 @@ import { serverEnvironment } from "../../state/server"; import { useSettingsScope } from "./SettingsScopeContext"; import { useClientSettings } from "../../hooks/useSettings"; import { Badge } from "../ui/badge"; +import { Skeleton } from "../ui/skeleton"; import { Button } from "../ui/button"; import { Input } from "../ui/input"; import { InputGroup, InputGroupAddon, InputGroupInput } from "../ui/input-group"; @@ -1463,6 +1465,21 @@ function KeybindingsGroups(props: KeybindingsGroupsProps) { )); } +function KeybindingsGroupsSkeleton() { + return ( + <> +
+ + +
+
+ + +
+ + ); +} + function BrowserKeybindingNotice() { const gt = useGT(); const message = gt( @@ -1548,6 +1565,9 @@ export function KeybindingsSettingsPanel() { const { commandOptions, allRows } = useKeybindingCatalog(); const rows = filterKeybindingRows(allRows, query, m); const groups = groupKeybindingRows(rows); + // Building every row takes a long frame, so the page opens at once and the list fills in + // without blocking input. A search the user types renders the same way. + const shownGroups = useDeferredValue(groups, null); const anchorIds = keybindingAnchorIds(rows); const openKeybindingsFile = () => { @@ -1744,9 +1764,11 @@ export function KeybindingsSettingsPanel() { ) : null} - {groups.length > 0 ? ( + {shownGroups === null ? ( + + ) : shownGroups.length > 0 ? ( + ) : usage.loading ? ( + ) : null; return ( <> diff --git a/apps/web/src/components/settings/ScheduledTasksSettings.browser.test.tsx b/apps/web/src/components/settings/ScheduledTasksSettings.browser.test.tsx index 9f774250922e9..15807fee7f5db 100644 --- a/apps/web/src/components/settings/ScheduledTasksSettings.browser.test.tsx +++ b/apps/web/src/components/settings/ScheduledTasksSettings.browser.test.tsx @@ -1,6 +1,6 @@ import { RegistryContext } from "@effect/atom-react"; import * as Effect from "effect/Effect"; -import { Atom, AtomRegistry } from "effect/reactivity"; +import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity"; import { DEFAULT_UNIFIED_SETTINGS, EnvironmentId, @@ -71,6 +71,16 @@ const state = vi.hoisted(() => ({ })); const secondaryId = EnvironmentId.make("secondary"); const permissions = new Map>(); +type TaskList = { readonly tasks: ReadonlyArray; readonly timeZone: string }; +// The list each machine streams when several are in scope; unset machines are still loading. +const taskLists = new Map>>(); +function taskList(id: string) { + const existing = taskLists.get(id); + if (existing) return existing; + const created = Atom.make>(AsyncResult.initial()); + taskLists.set(id, created); + return created; +} function setup() { state.connected = true; @@ -82,6 +92,7 @@ function setup() { state.settings = DEFAULT_UNIFIED_SETTINGS; state.upsert.mockReset().mockReturnValue(Effect.succeed({ id: task.id })); permissions.clear(); + taskLists.clear(); permissions.set(environmentId, Atom.make(true)); permissions.set(secondaryId, Atom.make(true)); permissions.set("", Atom.make(false)); @@ -100,6 +111,7 @@ function environment() { return { environmentId, label: "Laptop", + entry: { target: { _tag: "PrimaryConnectionTarget" } }, connection: { phase: state.connected ? "connected" : "disconnected" }, serverConfig: state.connected ? { environment: { platform: "linux", capabilities: { oneTimeSchedules: true } } } @@ -140,6 +152,8 @@ vi.mock(import("../../state/server"), async (original) => { run: state.remove, }, providersValueAtom: (() => state.providers) as never, + scheduledTasksLive: (({ environmentId }: { environmentId: string }) => + taskList(environmentId)) as never, upsertScheduledTask: { ...actual.serverEnvironment.upsertScheduledTask, run: state.upsert, @@ -346,6 +360,35 @@ describe("ScheduledTasksSettings", () => { await expect.element(page.getByLabelText("Runs on")).toHaveTextContent("Secondary"); }); + it("waits for every machine before saying there are no tasks", async () => { + setup(); + state.secondary = true; + const registry = AtomRegistry.make(); + using _registry = { [Symbol.dispose]: () => registry.dispose() }; + registry.set(taskList(secondaryId), AsyncResult.success({ tasks: [], timeZone: "UTC" })); + await using screen = await render( + + + , + ); + await expect + .element(screen.getByRole("status", { name: "Loading scheduled tasks…" })) + .toBeVisible(); + await expect.element(screen.getByText("No scheduled tasks")).not.toBeInTheDocument(); + + await act(() => + registry.set( + taskList(environmentId), + AsyncResult.success({ tasks: [task], timeZone: "UTC" }), + ), + ); + await expect.element(screen.getByText("Review issues")).toBeVisible(); + await expect.element(screen.getByText("No scheduled tasks")).not.toBeInTheDocument(); + await expect + .element(screen.getByRole("status", { name: "Loading scheduled tasks…" })) + .not.toBeInTheDocument(); + }); + it("keeps the permitted representative as the creation target", async () => { setup(); state.secondary = true; diff --git a/apps/web/src/components/settings/ScheduledTasksSettings.tsx b/apps/web/src/components/settings/ScheduledTasksSettings.tsx index 7a42aae22219a..4c95e6138aaf3 100644 --- a/apps/web/src/components/settings/ScheduledTasksSettings.tsx +++ b/apps/web/src/components/settings/ScheduledTasksSettings.tsx @@ -117,6 +117,7 @@ import { Label } from "../ui/label"; import { Menu, MenuTrigger, MenuPopup, MenuItem, MenuSeparator } from "../ui/menu"; import { ToggleGroup, Toggle } from "../ui/toggle-group"; import { Empty, EmptyHeader, EmptyTitle, EmptyDescription, EmptyMedia } from "../ui/empty"; +import { Skeleton } from "../ui/skeleton"; import { ProviderModelPicker } from "../chat/ProviderModelPicker"; import { TraitsPicker } from "../chat/TraitsPicker"; import { createModelSelection } from "@t3tools/shared/model"; @@ -576,6 +577,9 @@ function ScheduledTaskEnvironmentList({ const loaded = states.filter((state) => state.connected && state.error === null && state.tasks); const populated = loaded.filter((state) => state.tasks && state.tasks.length > 0); + const loading = states.some((state) => state.connected && state.error === null && !state.tasks); + // Until one machine has tasks to show, rows stand in for the list instead of a status line. + const placeholder = loading && populated.length === 0; const summaries: Record = { "Not connected:": [], "Loading scheduled tasks on": [], @@ -591,7 +595,7 @@ function ScheduledTaskEnvironmentList({ } else if (error !== null) { summaries["Could not load scheduled tasks:"]!.push(`${label}: ${error}`); } else if (!tasks) { - summaries["Loading scheduled tasks on"]!.push(label); + if (!placeholder) summaries["Loading scheduled tasks on"]!.push(label); } else if (tasks.length === 0 && populated.length > 0) { summaries["No tasks on"]!.push(label); } @@ -639,7 +643,8 @@ function ScheduledTaskEnvironmentList({ role="status" /> ) : null} - {populated.length === 0 && loaded.length > 0 ? ( + {placeholder ? : null} + {populated.length === 0 && loaded.length > 0 && !loading ? ( ) : !tasks ? ( - + ) : ( <> {taskId && !linkedTask ? ( @@ -768,6 +773,37 @@ function ScheduledTaskEnvironmentSection({ ); } +const SKELETON_ROWS = [0, 1] as const; + +function ScheduledTaskRowsSkeleton() { + const gt = useGT(); + return ( +
+ {SKELETON_ROWS.map((row) => ( +
+
+ + + +
+
+ + +
+
+ ))} +
+ ); +} + function ScheduledTaskRow({ environmentId, task, diff --git a/apps/web/src/components/settings/SettingsFontPreviews.tsx b/apps/web/src/components/settings/SettingsFontPreviews.tsx index c5cb74db5c484..f45aac370ac76 100644 --- a/apps/web/src/components/settings/SettingsFontPreviews.tsx +++ b/apps/web/src/components/settings/SettingsFontPreviews.tsx @@ -16,6 +16,7 @@ import { DEFAULT_COMPOSER_PLACEHOLDER } from "../../composerPlaceholder"; import { resolveDiffThemeName, type DiffThemeName } from "../../lib/diffRendering"; import { PREFERRED_HIGHLIGHTER } from "../../lib/syntaxHighlighting"; import { GhosttyTerminalSurface } from "~/terminal/ghostty/surface"; +import { Skeleton } from "../ui/skeleton"; const PREVIEW_SKILLS: ReadonlyArray = [ { name: "frontend-design", path: ".agents/skills/frontend-design/SKILL.md", enabled: true }, @@ -122,7 +123,7 @@ export function CodeFontPreview() { // An appearance switch keeps the previous theme's preview up while the new one renders. const [htmlByFile, setHtmlByFile] = useState(loadedHtml); if (loadedHtml !== null && loadedHtml !== htmlByFile) setHtmlByFile(loadedHtml); - if (htmlByFile === null) return null; + if (htmlByFile === null) return ; return (
{htmlByFile.map((html) => ( diff --git a/apps/web/src/components/settings/SettingsScopeNotice.tsx b/apps/web/src/components/settings/SettingsScopeNotice.tsx index 50df07b78ebf0..d0f1bf7b3771b 100644 --- a/apps/web/src/components/settings/SettingsScopeNotice.tsx +++ b/apps/web/src/components/settings/SettingsScopeNotice.tsx @@ -1,5 +1,5 @@ import { resolveEnvironmentMachineKind, type EnvironmentId } from "@t3tools/contracts"; -import { useLocation, useNavigate } from "@tanstack/react-router"; +import { useNavigate } from "@tanstack/react-router"; import { useGT } from "gt-react"; import { ChevronRightIcon, LayersIcon } from "lucide-react"; import type { ReactNode } from "react"; @@ -21,6 +21,7 @@ import { settingsScopeEnvironmentLabels, settingsScopeProjectMachines, } from "./settingsScopeAxis"; +import { useRenderedSettingsPathname } from "./useRenderedSettingsPathname"; import { SharedTooltipTrigger } from "../ui/shared-tooltip"; interface ScopeChoice { @@ -47,7 +48,7 @@ export function SettingsScopeNotice({ const gt = useGT(); const { selectScope, search, groups } = useSettingsScope(); const navigate = useNavigate({ from: "/settings" }); - const pathname = useLocation({ select: (location) => location.pathname }); + const pathname = useRenderedSettingsPathname(); const { environments } = useEnvironments(); const environmentIcon = (environment: EnvironmentPresentation | undefined) => environment ? ( diff --git a/apps/web/src/components/settings/SettingsScopeSentence.tsx b/apps/web/src/components/settings/SettingsScopeSentence.tsx index 356b4ca9fcf58..a4d9cca6fea68 100644 --- a/apps/web/src/components/settings/SettingsScopeSentence.tsx +++ b/apps/web/src/components/settings/SettingsScopeSentence.tsx @@ -1,6 +1,5 @@ import { resolveEnvironmentMachineKind } from "@t3tools/contracts"; import { fileDisplayName } from "@t3tools/shared/path"; -import { useLocation } from "@tanstack/react-router"; import { CheckIcon, ChevronDownIcon, FolderIcon, LayersIcon } from "lucide-react"; import { Fragment, useState, type ReactNode } from "react"; import { T, useGT, useMessages, Var } from "gt-react"; @@ -47,6 +46,7 @@ import { settingsScopeEnvironmentLabels, settingsScopeProjectMachines, } from "./settingsScopeAxis"; +import { useRenderedSettingsPathname } from "./useRenderedSettingsPathname"; export const SETTINGS_DEVICE_ONLY_PATHS: ReadonlySet = new Set([ "/settings/general", @@ -70,7 +70,7 @@ interface SettingsScopeMenuProps { export function SettingsScopeSentence() { const scope = useOptionalSettingsScope(); - const pathname = useLocation({ select: (location) => location.pathname }); + const pathname = useRenderedSettingsPathname(); const { environments } = useEnvironments(); if (scope === null || SETTINGS_DEVICE_ONLY_PATHS.has(pathname)) return null; const props: SettingsScopeMenuProps = { diff --git a/apps/web/src/components/settings/SettingsSidebarNav.tsx b/apps/web/src/components/settings/SettingsSidebarNav.tsx index 3c0c506ef9912..088673194ed48 100644 --- a/apps/web/src/components/settings/SettingsSidebarNav.tsx +++ b/apps/web/src/components/settings/SettingsSidebarNav.tsx @@ -50,6 +50,7 @@ import { SidebarInput, } from "../ui/sidebar"; import { scrollToSettingsTarget } from "./settingsLayout"; +import { useSettingsSectionPrefetch } from "./useSettingsSectionPrefetch"; import { searchSettings, revealSettingsSearchTarget, @@ -138,6 +139,7 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) { const m = useMessages(); const navArea = workspaceAreaProps("settings-nav", 0, gt("Settings sections")); const navigate = useNavigate(); + const preloadSection = useSettingsSectionPrefetch(); const currentHash = useLocation({ select: (location) => location.hash }); const activePath = SETTINGS_DETAIL_PAGE_PARENTS[pathname] ?? pathname; const searchInputRef = useRef(null); @@ -243,12 +245,18 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) { if (results.length === 0) return; if (event.key === "ArrowDown") { event.preventDefault(); - setActiveResultIndex((activeResultIndex + 1) % results.length); + const next = (activeResultIndex + 1) % results.length; + setActiveResultIndex(next); + const result = results[next]; + if (result) preloadSection(result.to); return; } if (event.key === "ArrowUp") { event.preventDefault(); - setActiveResultIndex((activeResultIndex - 1 + results.length) % results.length); + const next = (activeResultIndex - 1 + results.length) % results.length; + setActiveResultIndex(next); + const result = results[next]; + if (result) preloadSection(result.to); return; } if (event.key === "Enter") { @@ -353,6 +361,7 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) { isActive={index === activeResultIndex} className="h-auto min-h-10 items-start" onMouseMove={() => setActiveResultIndex(index)} + onPointerEnter={() => preloadSection(item.to)} onClick={() => handleSearchResultClick(item)} > @@ -409,6 +418,8 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) { data-settings-section={to} aria-current={isActive ? "page" : undefined} isActive={isActive} + onPointerEnter={() => preloadSection(to)} + onFocus={() => preloadSection(to)} onClick={() => handleSectionClick(to)} > diff --git a/apps/web/src/components/settings/StorageSettings.tsx b/apps/web/src/components/settings/StorageSettings.tsx index db7e0f9a86752..956b8aac831ae 100644 --- a/apps/web/src/components/settings/StorageSettings.tsx +++ b/apps/web/src/components/settings/StorageSettings.tsx @@ -915,17 +915,17 @@ export function StorageCleanupSections() { if (!supportsStorageCleanup(connectedEnvironments)) { return ( <> - {databaseStorageNotice} + {databaseStorageNotice} ); } + // Machines report their databases after the page renders, so the notice goes last to push nothing down. return ( <> - {databaseStorageNotice} + {databaseStorageNotice} ); } diff --git a/apps/web/src/components/settings/VoiceSettingsPanel.browser.test.tsx b/apps/web/src/components/settings/VoiceSettingsPanel.browser.test.tsx index 0afeb94210029..f096f056d51ee 100644 --- a/apps/web/src/components/settings/VoiceSettingsPanel.browser.test.tsx +++ b/apps/web/src/components/settings/VoiceSettingsPanel.browser.test.tsx @@ -593,6 +593,66 @@ it("recovers from a failed download progress poll without notifying, but reports ); }); +it("holds the Language row while the model status loads, and drops it if loading fails", async () => { + const target = new PrimaryConnectionTarget({ + environmentId: EnvironmentId.make("voice-language-loading"), + label: "Test environment", + httpBaseUrl: window.location.origin, + wsBaseUrl: "ws://localhost", + }); + const prepared = { ...target, target, socketUrl: target.wsBaseUrl, httpAuthorization: null }; + const status = { + supported: true, + state: "ready", + modelId: "tiny", + model: "Tiny", + size: 100, + supportsStreaming: false, + supportsTranslation: false, + supportsLanguageDetection: true, + acceleration: "cpu", + benchmarkTier: "cpu", + modelUnloadTimeout: "never", + gpuDevices: [], + }; + const pending = [Promise.withResolvers(), Promise.withResolvers()]; + let requests = 0; + const fetch = globalThis.fetch; + using _network = vi.spyOn(globalThis, "fetch").mockImplementation((input, init) => { + const url = new URL(input instanceof Request ? input.url : input, window.location.href); + if (url.pathname === "/api/voice/status") return pending[requests++]!.promise; + if (url.pathname === "/api/voice/models") return Promise.resolve(Response.json({ models: [] })); + return fetch(input, init); + }); + using _notify = vi.spyOn(toastManager, "add").mockReturnValue("test"); + await vi.mocked(useVoiceTranscriptionDestination).withImplementation( + () => ({ environmentId: target.environmentId, label: target.label, grantId: "test", prepared }), + async () => { + const panel = (key: string) => ( + {}}> + + + ); + await using screen = await render(panel("first")); + const checking = screen.getByText("Checking which languages the model supports…"); + await expect.element(checking).toBeVisible(); + pending[0]!.resolve(Response.json(status)); + await expect + .element(screen.getByRole("combobox", { name: "Transcription language" })) + .toBeVisible(); + await expect.element(checking).not.toBeInTheDocument(); + + await screen.rerender(panel("reopened")); + await expect.element(checking).toBeVisible(); + pending[1]!.resolve(new Response(null, { status: 503 })); + await expect.element(checking).not.toBeInTheDocument(); + await expect + .element(screen.getByRole("combobox", { name: "Transcription language" })) + .not.toBeInTheDocument(); + }, + ); +}); + it.each([ ["speech-models", "voice-transcription-destination"], ["speech-hardware", "voice-transcription-destination"], diff --git a/apps/web/src/components/settings/VoiceSettingsPanel.tsx b/apps/web/src/components/settings/VoiceSettingsPanel.tsx index a7eebed9d8af0..361d9b720ded9 100644 --- a/apps/web/src/components/settings/VoiceSettingsPanel.tsx +++ b/apps/web/src/components/settings/VoiceSettingsPanel.tsx @@ -101,6 +101,7 @@ import { TraitsPicker } from "../chat/TraitsPicker"; import { VoiceInputSetup } from "../chat/VoiceInputSetup"; import { Badge } from "../ui/badge"; import { Button } from "../ui/button"; +import { Skeleton } from "../ui/skeleton"; import { Input } from "../ui/input"; import { InputGroup, InputGroupAddon, InputGroupInput } from "../ui/input-group"; import { @@ -685,6 +686,7 @@ function useVoiceModels(prepared: PreparedConnection | null) { const canManage = useEnvironmentScope(prepared?.environmentId ?? null, AuthSettingsWriteScope); const [models, setModels] = useState([]); const [status, setStatus] = useState(null); + const [loadFailed, setLoadFailed] = useState(false); const [busy, setBusy] = useState(false); const [requestedDownload, setRequestedDownload] = useState(null); const [actionConnection, setActionConnection] = useState(prepared); @@ -694,6 +696,7 @@ function useVoiceModels(prepared: PreparedConnection | null) { setRequestedDownload(null); setModels([]); setStatus(null); + setLoadFailed(false); } const epoch = useRef(0); const refreshRevision = useRef(0); @@ -719,6 +722,7 @@ function useVoiceModels(prepared: PreparedConnection | null) { } catch (error) { if (mode === "progress") return; if (current !== epoch.current || revision !== refreshRevision.current) return; + setLoadFailed(true); toastManager.add({ type: "error", title: gt("Could not load transcription models"), @@ -784,6 +788,7 @@ function useVoiceModels(prepared: PreparedConnection | null) { return { models, status, + loading: prepared !== null && status === null && !loadFailed, run, controlsDisabled: busy || downloading || !canManage, canCancel: canManage && !busy, @@ -1692,6 +1697,13 @@ export function VoiceSettingsPanel() { close={() => setPendingCloud(null)} /> )} + {!destination.cloudProvider && !destination.device && catalog.loading ? ( + } + /> + ) : null} {(model || destination.cloudProvider || destination.device) && ( +

{useRenderedSettingsPathname()}

+ + + ); +} + +it("names the page on screen, not the one still loading", async () => { + const slowPage = Promise.withResolvers(); + const root = createRootRoute({ component: Chrome }); + const router = createRouter({ + routeTree: root.addChildren([ + createRoute({ + getParentRoute: () => root, + path: "/settings/general", + component: () =>

General page

, + }), + createRoute({ + getParentRoute: () => root, + path: "/settings/voice", + // Stands in for a lazy route chunk that has not arrived yet. + loader: () => slowPage.promise, + component: () =>

Voice page

, + }), + ]), + history: createMemoryHistory({ initialEntries: ["/settings/general"] }), + }); + await using screen = await render(, { router: false }); + const chrome = screen.getByTestId("chrome"); + await expect.element(chrome).toHaveTextContent("/settings/general"); + + const navigation = router.navigate({ to: "/settings/voice" }); + await expect.poll(() => router.state.location.pathname).toBe("/settings/voice"); + await expect.element(screen.getByText("General page")).toBeVisible(); + await expect.element(chrome).toHaveTextContent("/settings/general"); + + slowPage.resolve(); + await navigation; + await expect.element(screen.getByText("Voice page")).toBeVisible(); + await expect.element(chrome).toHaveTextContent("/settings/voice"); +}); diff --git a/apps/web/src/components/settings/useRenderedSettingsPathname.ts b/apps/web/src/components/settings/useRenderedSettingsPathname.ts new file mode 100644 index 0000000000000..0d6815f7fdef5 --- /dev/null +++ b/apps/web/src/components/settings/useRenderedSettingsPathname.ts @@ -0,0 +1,7 @@ +import { useMatches } from "@tanstack/react-router"; + +// useLocation switches as soon as a navigation starts, while keeps the old page until +// the next route's lazy chunk loads. Chrome that frames the page must follow the committed match. +export function useRenderedSettingsPathname(): string { + return useMatches({ select: (matches) => matches.at(-1)?.pathname ?? "" }); +} diff --git a/apps/web/src/components/settings/useSettingsSectionPrefetch.ts b/apps/web/src/components/settings/useSettingsSectionPrefetch.ts new file mode 100644 index 0000000000000..90415987a4c84 --- /dev/null +++ b/apps/web/src/components/settings/useSettingsSectionPrefetch.ts @@ -0,0 +1,42 @@ +import { RegistryContext } from "@effect/atom-react"; +import { useRouter } from "@tanstack/react-router"; +import { useContext } from "react"; + +import { peerLinkEnvironment, usePeerLinkHosts } from "../../state/peerLinks"; +import { serverEnvironment } from "../../state/server"; +import { sourceControlEnvironment } from "../../state/sourceControl"; +import type { SettingsPath } from "./settingsSearch"; +import { useOptionalSettingsScope } from "./SettingsScopeContext"; + +/** + * Starts loading a settings section on hover or focus: its lazy route chunk, plus the slow + * queries it opens with. Each query keeps its result for its idle TTL, so mounting and + * releasing at once is enough for the page to find it warm. + */ +export function useSettingsSectionPrefetch() { + const router = useRouter(); + const registry = useContext(RegistryContext); + const scope = useOptionalSettingsScope(); + const environment = scope?.environment ?? null; + const peerLinkHosts = usePeerLinkHosts(); + return (to: SettingsPath) => { + void router.preloadRoute({ to }); + if (to === "/settings/source-control" && environment?.connection.phase === "connected") { + const input = { environmentId: environment.environmentId, input: {} }; + registry.mount(sourceControlEnvironment.discovery(input))(); + } + if (to === "/settings/scheduled-tasks") { + for (const entry of scope?.environments ?? []) { + if (entry.connection.phase !== "connected" || entry.serverConfig === null) continue; + const input = { environmentId: entry.environmentId, input: {} }; + registry.mount(serverEnvironment.scheduledTasksLive(input))(); + } + } + if (to === "/settings/connections") { + for (const host of peerLinkHosts) { + const input = { environmentId: host.environmentId, input: {} }; + registry.mount(peerLinkEnvironment.list(input))(); + } + } + }; +} diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json index b13f7ab485459..b430923cefe87 100644 --- a/apps/web/src/i18n/translations/de.json +++ b/apps/web/src/i18n/translations/de.json @@ -12985,5 +12985,6 @@ "201490988858b511": "zurückgezogen von {by}", "99451a5d2d40440f": "Zurückgezogen von {by}.", "3ee30a50b70fffab": "Zurückgezogen von {by}: {reason}", - "92e129bf413a1220": "zurückgezogen" + "92e129bf413a1220": "zurückgezogen", + "800966eb58181745": "Prüfe, welche Sprachen das Modell unterstützt…" } diff --git a/apps/web/src/i18n/translations/en.json b/apps/web/src/i18n/translations/en.json index 21dee89d7f65d..94b002a6175fe 100644 --- a/apps/web/src/i18n/translations/en.json +++ b/apps/web/src/i18n/translations/en.json @@ -12994,5 +12994,6 @@ "201490988858b511": "withdrawn by {by}", "99451a5d2d40440f": "Withdrawn by {by}.", "3ee30a50b70fffab": "Withdrawn by {by}: {reason}", - "92e129bf413a1220": "withdrawn" + "92e129bf413a1220": "withdrawn", + "800966eb58181745": "Checking which languages the model supports…" } diff --git a/apps/web/src/i18n/translations/es.json b/apps/web/src/i18n/translations/es.json index bab41e1dfdb40..9f8d3d0d0dc1d 100644 --- a/apps/web/src/i18n/translations/es.json +++ b/apps/web/src/i18n/translations/es.json @@ -12980,5 +12980,6 @@ "201490988858b511": "retirada por {by}", "99451a5d2d40440f": "Retirada por {by}.", "3ee30a50b70fffab": "Retirada por {by}: {reason}", - "92e129bf413a1220": "retirada" + "92e129bf413a1220": "retirada", + "800966eb58181745": "Comprobando qué idiomas admite el modelo…" } diff --git a/apps/web/src/i18n/translations/fr.json b/apps/web/src/i18n/translations/fr.json index 99c8bf1bda944..ec5eaaf8f6726 100644 --- a/apps/web/src/i18n/translations/fr.json +++ b/apps/web/src/i18n/translations/fr.json @@ -12985,5 +12985,6 @@ "201490988858b511": "retirée par {by}", "99451a5d2d40440f": "Retirée par {by}.", "3ee30a50b70fffab": "Retirée par {by} : {reason}", - "92e129bf413a1220": "retirée" + "92e129bf413a1220": "retirée", + "800966eb58181745": "Vérification des langues prises en charge par le modèle…" } diff --git a/apps/web/src/i18n/translations/ja.json b/apps/web/src/i18n/translations/ja.json index f3d4adb8e69ed..6e884ceea12be 100644 --- a/apps/web/src/i18n/translations/ja.json +++ b/apps/web/src/i18n/translations/ja.json @@ -12921,5 +12921,6 @@ "201490988858b511": "{by} が取り下げ", "99451a5d2d40440f": "{by} が取り下げました。", "3ee30a50b70fffab": "{by} が取り下げました: {reason}", - "92e129bf413a1220": "取り下げ済み" + "92e129bf413a1220": "取り下げ済み", + "800966eb58181745": "モデルが対応している言語を確認しています…" } diff --git a/apps/web/src/i18n/translations/ko.json b/apps/web/src/i18n/translations/ko.json index 6fce5b1289e69..1f39e6dcdaaf7 100644 --- a/apps/web/src/i18n/translations/ko.json +++ b/apps/web/src/i18n/translations/ko.json @@ -12918,5 +12918,6 @@ "201490988858b511": "{by}에서 철회함", "99451a5d2d40440f": "{by}에서 철회했습니다.", "3ee30a50b70fffab": "{by}에서 철회했습니다: {reason}", - "92e129bf413a1220": "철회됨" + "92e129bf413a1220": "철회됨", + "800966eb58181745": "모델이 지원하는 언어를 확인하는 중…" } diff --git a/apps/web/src/i18n/translations/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json index 8650f35ce7fe5..252b8dad8d401 100644 --- a/apps/web/src/i18n/translations/pt-BR.json +++ b/apps/web/src/i18n/translations/pt-BR.json @@ -12985,5 +12985,6 @@ "201490988858b511": "retirada por {by}", "99451a5d2d40440f": "Retirada por {by}.", "3ee30a50b70fffab": "Retirada por {by}: {reason}", - "92e129bf413a1220": "retirada" + "92e129bf413a1220": "retirada", + "800966eb58181745": "Verificando quais idiomas o modelo suporta…" } diff --git a/apps/web/src/i18n/translations/ru.json b/apps/web/src/i18n/translations/ru.json index 607583733cd1b..7d8023821d3ae 100644 --- a/apps/web/src/i18n/translations/ru.json +++ b/apps/web/src/i18n/translations/ru.json @@ -12985,5 +12985,6 @@ "201490988858b511": "отозван: {by}", "99451a5d2d40440f": "Отозван: {by}.", "3ee30a50b70fffab": "Отозван ({by}): {reason}", - "92e129bf413a1220": "отозван" + "92e129bf413a1220": "отозван", + "800966eb58181745": "Проверяем, какие языки поддерживает модель…" } diff --git a/apps/web/src/i18n/translations/sv.json b/apps/web/src/i18n/translations/sv.json index e1edb737e6e38..3d0607cbfac74 100644 --- a/apps/web/src/i18n/translations/sv.json +++ b/apps/web/src/i18n/translations/sv.json @@ -12992,5 +12992,6 @@ "201490988858b511": "återkallad av {by}", "99451a5d2d40440f": "Återkallad av {by}.", "3ee30a50b70fffab": "Återkallad av {by}: {reason}", - "92e129bf413a1220": "återkallad" + "92e129bf413a1220": "återkallad", + "800966eb58181745": "Kontrollerar vilka språk modellen stöder…" } diff --git a/apps/web/src/i18n/translations/zh.json b/apps/web/src/i18n/translations/zh.json index 19eaa76dc93de..a043c239e7651 100644 --- a/apps/web/src/i18n/translations/zh.json +++ b/apps/web/src/i18n/translations/zh.json @@ -12999,5 +12999,6 @@ "201490988858b511": "已由 {by} 撤回", "99451a5d2d40440f": "已由 {by} 撤回。", "3ee30a50b70fffab": "已由 {by} 撤回:{reason}", - "92e129bf413a1220": "已撤回" + "92e129bf413a1220": "已撤回", + "800966eb58181745": "正在检查模型支持哪些语言…" } diff --git a/apps/web/src/routes/_chat.settings.tsx b/apps/web/src/routes/_chat.settings.tsx index 6ed424cdb7701..04026e0373fa8 100644 --- a/apps/web/src/routes/_chat.settings.tsx +++ b/apps/web/src/routes/_chat.settings.tsx @@ -1,5 +1,5 @@ import { workspaceAreaProps } from "../lib/workspaceFocus"; -import { Outlet, createFileRoute, redirect, useLocation } from "@tanstack/react-router"; +import { Outlet, createFileRoute, redirect, useLocation, useRouter } from "@tanstack/react-router"; import { useState, type ReactNode } from "react"; import { T, useGT, useMessages, Var } from "gt-react"; import { RotateCcwIcon } from "lucide-react"; @@ -17,6 +17,7 @@ import { useEnvironments } from "../state/environments"; import { SettingsScopeNotice } from "../components/settings/SettingsScopeNotice"; import { SETTINGS_DEVICE_ONLY_PATHS } from "../components/settings/SettingsScopeSentence"; import { SettingsPageContainer } from "../components/settings/settingsLayout"; +import { useRenderedSettingsPathname } from "../components/settings/useRenderedSettingsPathname"; import { retainSettingsScope, validateSettingsRouteSearch, @@ -50,7 +51,10 @@ function SettingsScopeBoundary({ pathname, children }: { pathname: string; child const { environments } = useEnvironments(); const gt = useGT(); const m = useMessages(); - const hash = useLocation({ select: (location) => location.hash }); + // A pending navigation's hash targets the page still loading, not the one on screen. + const hash = useLocation({ + select: (location) => (location.pathname === pathname ? location.hash : ""), + }); const searchTarget = getSettingsSearchTargetScope(hash); const agentFeedbackAvailability = searchTarget?.agentFeedbackOnly ? { @@ -143,10 +147,11 @@ function SettingsScopeBoundary({ pathname, children }: { pathname: string; child function SettingsContentLayout() { const gt = useGT(); const contentArea = workspaceAreaProps("settings", 1, gt("Settings content")); - const location = useLocation(); + const navPathname = useLocation({ select: (location) => location.pathname }); + const pathname = useRenderedSettingsPathname(); const { search, environment } = useSettingsScope(); const contentScopeKey = - location.pathname === "/settings/diagnostics" || location.pathname === "/settings/providers" + pathname === "/settings/diagnostics" || pathname === "/settings/providers" ? environment?.environmentId : JSON.stringify(search); const [restoreSignal, setRestoreSignal] = useState(0); @@ -154,12 +159,12 @@ function SettingsContentLayout() { return (
- +
- +
- {location.pathname === "/settings/general" ? ( + {pathname === "/settings/general" ? ( setRestoreSignal((value) => value + 1)} /> @@ -168,7 +173,7 @@ function SettingsContentLayout() {
- +
@@ -181,7 +186,8 @@ function SettingsContentLayout() { function SettingsRouteLayout() { const rawSearch = Route.useSearch(); const navigate = Route.useNavigate(); - const pathname = useLocation({ select: (location) => location.pathname }); + const router = useRouter(); + const pathname = useRenderedSettingsPathname(); return ( { // Send every axis so retain middleware recognizes "all" as an explicit target. void navigate({ - to: pathname, + // Read at call time: subscribing would hand every scope consumer a new context value on + // each click. A pending navigation's target wins over the page still on screen. + to: router.state.location.pathname, search: () => ({ project: next.project, machine: next.machine,