"use client"; // Hub variant of the /ask chat: wires the federated site registry into the // multi-origin search data source so AskChat's retrieval (runQueryTree) searches // the archives the hub's search covers. Mirrors HubHome's MultiSiteDataProvider // wiring from the same list (useFederatedSites): the same order, the same // colour per archive, and the same scope — an archive this browser switched off // with its chip on the front page is not fetched here either, so the chat // grounds in what the search showed. Not progressive: the chat waits until // every archive in scope has settled, so it never answers from a half-loaded // federation — nor before the hub's own list is in (`listed`: the archives a // browser added are known at once, /hub-sites.json's a moment later). With // NONE in scope it is not ready at all; once the list is in AskChat says why // (NO_ARCHIVES_ON_HUB, NO_ARCHIVES_IN_SCOPE), and AskScope says how many of // the hub's archives the chat searches (ASK_SCOPE_LINE). import { PlayerProvider } from "yt-dlp-transcript-common/components/PlayerProvider"; import TranscriptModal from "yt-dlp-transcript-common/components/TranscriptModal"; import PostModal from "yt-dlp-transcript-common/components/PostModal"; import { MultiSiteDataProvider } from "yt-dlp-transcript-common/components/SearchDataContext"; import { SearchSessionProvider } from "yt-dlp-transcript-common/components/SearchSessionContext"; import { useFederatedSites } from "../components/hub/useHubSites"; import AskChat from "./AskChat"; import AskScope from "./AskScope"; // `transcriptDownloads` comes from the server parent's currentSite() (a client // component cannot read site.json): false hides the modal's per-video export // controls. export default function AskHub({ transcriptDownloads = true, }: { transcriptDownloads?: boolean; }) { const { federated, listed } = useFederatedSites(); // The whole provider stack, in the order SiteWorkspace mounts it for a single // site — PlayerProvider, then the data source, then the session — because // hub mode bypasses that shell entirely and /ask is on its own here. // // None of these are optional: AskChat's retrieval reads the committed query // tree, the filters and runQueryTree out of useSearchSession, and the session // itself calls usePlayer (it opens a transcript at a cited timestamp). A // missing provider THROWS, so the hub build's prerender of /ask failed and // took the whole route with it — which is why e2e:2origin was red. The fix is // the stack, never an opt-out of prerendering. return ( {/* The viewers a citation opens into, siblings of the session exactly as HubHome and SiteWorkspace mount them — a cited link with nothing to open is the failure this avoids. */} ); }