From 421dcfdf367a8d5d3fd1526d67d47a3860a249ca Mon Sep 17 00:00:00 2001 From: Random <65575762+rndaom@users.noreply.github.com> Date: Mon, 16 Nov 2026 13:53:31 -0500 Subject: [PATCH 1/2] feat(hud): offer Match to catalog for an imported HUD An imported HUD that is also in the catalog now shows Match to catalog, so it can get update checks without being reinstalled. Folder names such as rayshud-master match their catalog HUD; the button stays hidden when no single catalog HUD fits. --- CHANGELOG.md | 5 +++++ apps/desktop/src/HudPane.tsx | 14 +++++++++----- apps/desktop/src/lib/hud-ui.test.ts | 27 +++++++++++++++++++++++++++ apps/desktop/src/lib/hud-ui.ts | 26 ++++++++++++++++++++++++++ docs/ARCHITECTURE.md | 2 +- docs/guide/hud.md | 2 ++ 6 files changed, 70 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b20ff24..0e05edb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ User-facing changes only. The release workflow publishes the matching ## [Unreleased] +### Fixed + +- HUD: an imported HUD that is also in the catalog now offers Match to catalog, so it can get + updates. The button was missing for imported HUDs. + ## [0.3.0] - 2026-11-15 ### Fixed diff --git a/apps/desktop/src/HudPane.tsx b/apps/desktop/src/HudPane.tsx index 5947611d..9ad0b4da 100644 --- a/apps/desktop/src/HudPane.tsx +++ b/apps/desktop/src/HudPane.tsx @@ -50,6 +50,7 @@ import { HUD_SORTS, hudAuthorCopy, hudCatalogControls, + hudCatalogMatch, hudDisplayName, hudInstallSourceCopy, hudOptionsDirty, @@ -224,6 +225,7 @@ export function HudPane({ const installedEntry = installedId ? (catalog.find((entry) => entry.id.toLowerCase() === installedId.toLowerCase()) ?? null) : null; + const catalogMatch = hudCatalogMatch(catalog, state); const mutationBlocked = locked || dirty || stateLoading || stateError !== null; const mutationReason = running ? "Close TF2 before changing the installed HUD." @@ -371,8 +373,10 @@ export function HudPane({ {installedEntry ? `${hudAuthorCopy(installedEntry)} · ` : ""} {installedLabel}

- {state.inferred ? ( -

Match it to hud-db to enable updates.

+ {catalogMatch ? ( +

+ Match it to {hudDisplayName(catalogMatch)} in the catalog to get updates. +

) : null}
{state.updateAvailable ? ( @@ -387,16 +391,16 @@ export function HudPane({ {running ? "Close TF2 to update" : "Update HUD"} ) : null} - {state.inferred ? ( + {catalogMatch ? ( ) : null} + ) : null} + {onDismissModsImportHint ? ( + + ) : null} + + + ) : null} +
void>>; +let onNavigate: ReturnType void>>; function makeApi() { return { getFilesContext: vi.fn(async () => ({ profileId, root: "fixture", layer: "vanilla" })), @@ -104,6 +105,7 @@ async function render() { onBindSyncHandled={() => {}} onBusyChange={() => {}} onPendingChange={onPendingChange} + onNavigate={onNavigate} onError={() => {}} /> @@ -131,6 +133,7 @@ beforeEach(() => { refreshKey = 1; api = makeApi(); onPendingChange = vi.fn(); + onNavigate = vi.fn(); }); afterEach(async () => { await act(async () => root.unmount()); @@ -322,6 +325,25 @@ describe("HUD loading through the real settings host and pane", () => { expect(element("toast").getAttribute("data-kind")).toBe("saved"); }); + it("points an import that is not a HUD to Mods instead of a bare failure", async () => { + await render(); + api.importHudArchive.mockRejectedValueOnce({ + code: "NotAHud", + message: "No HUD folder was found (missing info.vdf).", + }); + await click("hud-import"); + await click("hud-import-archive"); + const hint = element("hud-import-not-a-hud"); + expect(hint.textContent).toContain("That isn't a HUD"); + expect(container.querySelector('[data-testid="toast"][data-kind="error"]')).toBeNull(); + const open = Array.from(hint.querySelectorAll("button")).find( + (button) => button.textContent === "Open Mods", + ); + await act(async () => open?.click()); + expect(onNavigate).toHaveBeenCalledWith("mods"); + expect(container.querySelector('[data-testid="hud-import-not-a-hud"]')).toBeNull(); + }); + it("retains a same-HUD dirty draft through schema failure and retry without saving unavailable controls", async () => { vi.useFakeTimers(); running = true; diff --git a/apps/desktop/src/SettingsHost.tsx b/apps/desktop/src/SettingsHost.tsx index 55e9e043..4d0e57c0 100644 --- a/apps/desktop/src/SettingsHost.tsx +++ b/apps/desktop/src/SettingsHost.tsx @@ -272,6 +272,13 @@ export function SettingsHost({ }, [settled, onSettledChange]); // biome-ignore lint/correctness/useExhaustiveDependencies: Profile changes invalidate guidance from the previous import attempt. useEffect(() => setModsHudImportRequired(null), [profileId]); + // An import refused because the pick belongs in Mods, kept on its pane. + const [modsImportHint, setModsImportHint] = useState<{ + tab: "hud" | "viewmodels"; + message: string; + } | null>(null); + // biome-ignore lint/correctness/useExhaustiveDependencies: the notice belongs to the profile it was raised in. + useEffect(() => setModsImportHint(null), [profileId]); const hud = useHudResources( api, profileId, @@ -654,6 +661,15 @@ export function SettingsHost({ options?.onHandledFailure?.("review-required"); return false; } + if (failure.code === "NotAHud" || failure.code === "ViewmodelMixedContent") { + if (started) toast.cancelSave(copy?.source); + setModsImportHint({ + tab: failure.code === "NotAHud" ? "hud" : "viewmodels", + message: failure.message, + }); + options?.onFailure?.(failure.message); + return false; + } if ( (failure.code === "HudReviewRequired" || failure.code === "HudLiveReviewRequired") && expectedProfileId && @@ -1105,8 +1121,15 @@ export function SettingsHost({ await hud.reloadLocal(); }); }} + modsImportHint={modsImportHint?.tab === "hud" ? modsImportHint.message : null} + onOpenMods={() => { + setModsImportHint(null); + onNavigate?.("mods"); + }} + onDismissModsImportHint={() => setModsImportHint(null)} onImportArchive={() => { setModsHudImportRequired(null); + setModsImportHint(null); return write( async () => { if ((await api.importHudArchive()) === null) return null; @@ -1118,6 +1141,7 @@ export function SettingsHost({ }} onImportFolder={() => { setModsHudImportRequired(null); + setModsImportHint(null); return write( async () => { if ((await api.importHudFolder()) === null) return null; @@ -1223,7 +1247,14 @@ export function SettingsHost({ }} profilePreload={modsPayload?.profilePreload ?? null} loadCatalog={api.getViewmodelSourceCatalog} + modsImportHint={modsImportHint?.tab === "viewmodels" ? modsImportHint.message : null} + onOpenMods={() => { + setModsImportHint(null); + onNavigate?.("mods"); + }} + onDismissModsImportHint={() => setModsImportHint(null)} onImport={(preload) => { + setModsImportHint(null); return write( async () => { if ((await api.importViewmodels(preload)) === null) return null; diff --git a/apps/desktop/src/ViewmodelPane.tsx b/apps/desktop/src/ViewmodelPane.tsx index 70add161..41f2ce7d 100644 --- a/apps/desktop/src/ViewmodelPane.tsx +++ b/apps/desktop/src/ViewmodelPane.tsx @@ -1,5 +1,6 @@ import { DownloadSimple, Trash } from "@phosphor-icons/react"; import { useState } from "react"; +import { Alert } from "./components/ui/Alert"; import { ClassTabs } from "./components/ui/ClassTabs"; import { PaneHeader } from "./components/ui/PaneHeader"; import { useAppStatus, useCanWrite } from "./hooks/useAppStatus"; @@ -24,6 +25,9 @@ export function ViewmodelPane({ onImport, onBuild, onRemove, + modsImportHint = null, + onOpenMods, + onDismissModsImportHint, }: { active: boolean; profileId: string | null; @@ -33,6 +37,10 @@ export function ViewmodelPane({ profilePreload: boolean | null; loadCatalog: () => Promise; onImport: (preload: boolean) => void; + /** Why the last VPK was refused for carrying more than viewmodels. */ + modsImportHint?: string | null; + onOpenMods?: () => void; + onDismissModsImportHint?: () => void; onBuild: (request: ViewmodelBuildRequest) => Promise; onRemove: () => void; }) { @@ -69,6 +77,25 @@ export function ViewmodelPane({ onRemovePack={onRemove} /> + {modsImportHint ? ( + + That pack has more than viewmodels + {modsImportHint} + + {onOpenMods ? ( + + ) : null} + {onDismissModsImportHint ? ( + + ) : null} + + + ) : null} +