From 4aa7e6b44cdbf0d74dd8289d4abb9f1bbb888a07 Mon Sep 17 00:00:00 2001 From: HawkSE <20862608+HawkSE@users.noreply.github.com> Date: Mon, 31 Aug 2026 20:33:01 +0000 Subject: [PATCH 1/2] Keep legacy version manifests reachable Amp-Thread-ID: https://ampcode.com/threads/T-01a04534-2413-71c9-ac1f-51d83bd1fdbc Co-authored-by: Scott Ellison II --- .../skills/publishing-docs-versions/SKILL.md | 7 +++-- src/components/VersionSelector.tsx | 30 ++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.agents/skills/publishing-docs-versions/SKILL.md b/.agents/skills/publishing-docs-versions/SKILL.md index 55a5a7ac4..c39aa44ea 100644 --- a/.agents/skills/publishing-docs-versions/SKILL.md +++ b/.agents/skills/publishing-docs-versions/SKILL.md @@ -20,10 +20,13 @@ Use this skill for the Sourcegraph docs repo release-version workflow: cutting l - `src/data/versions.ts` - `docs/legacy.mdx` - `src/data/versions.ts` on `origin/main` is the canonical dropdown list. The - current site exposes it through `/docs/api/versions`, and legacy selectors - load that manifest at runtime. + current site exposes it through `/docs/api/versions`. Legacy selectors load + that manifest through the main branch's Vercel origin to avoid cross-subdomain + Cloudflare challenges. - A legacy branch's bundled `src/data/versions.ts` is only a fallback. Its first entry identifies the archived site and must not have the `latest` label. +- A legacy selector shows the current latest version, its selected archived + version, and older versions. It omits versions between latest and selected. ## Standard workflow for a new release diff --git a/src/components/VersionSelector.tsx b/src/components/VersionSelector.tsx index 90b34b93c..d4ffef9b9 100644 --- a/src/components/VersionSelector.tsx +++ b/src/components/VersionSelector.tsx @@ -14,7 +14,7 @@ import {Fragment, useEffect, useState} from 'react'; const versionsUrl = process.env.NEXT_PUBLIC_DOCS_VERSIONS_URL ?? - 'https://sourcegraph.com/docs/api/versions'; + 'https://sourcegraph-docs-git-main-sourcegraph-f8c71130.vercel.app/docs/api/versions'; function isVersion(value: unknown): value is VersionI { if (typeof value !== 'object' || value === null) return false; @@ -27,6 +27,23 @@ function isVersion(value: unknown): value is VersionI { ); } +function versionsForSite(remoteVersions: VersionI[]): VersionI[] { + const selectedIndex = remoteVersions.findIndex( + version => version.name === versions[0].name + ); + + if (selectedIndex === 0) return remoteVersions; + if (selectedIndex > 0) { + return [remoteVersions[0], ...remoteVersions.slice(selectedIndex)]; + } + + return [ + remoteVersions[0], + {...versions[0], label: undefined}, + ...versions.slice(1) + ]; +} + export default function VersionSelector() { const path = usePathname(); const [availableVersions, setAvailableVersions] = @@ -57,16 +74,7 @@ export default function VersionSelector() { return; } - setAvailableVersions( - remoteVersions.some( - version => version.name === versions[0].name - ) - ? remoteVersions - : [ - ...remoteVersions, - {...versions[0], label: undefined} - ] - ); + setAvailableVersions(versionsForSite(remoteVersions)); }) .catch(() => { // Keep this build's version list if the current site is unavailable. From 5bc3b8ba8fae296417899a90c9e29d4e6b3923fb Mon Sep 17 00:00:00 2001 From: HawkSE <20862608+HawkSE@users.noreply.github.com> Date: Tue, 1 Sep 2026 14:04:36 +0000 Subject: [PATCH 2/2] Use Sourcegraph version manifest endpoint Co-authored-by: Scott Ellison II Amp-Thread-ID: https://ampcode.com/threads/T-01a04534-2413-71c9-ac1f-51d83bd1fdbc --- .agents/skills/publishing-docs-versions/SKILL.md | 5 ++--- src/components/VersionSelector.tsx | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.agents/skills/publishing-docs-versions/SKILL.md b/.agents/skills/publishing-docs-versions/SKILL.md index c39aa44ea..ac0d03468 100644 --- a/.agents/skills/publishing-docs-versions/SKILL.md +++ b/.agents/skills/publishing-docs-versions/SKILL.md @@ -20,9 +20,8 @@ Use this skill for the Sourcegraph docs repo release-version workflow: cutting l - `src/data/versions.ts` - `docs/legacy.mdx` - `src/data/versions.ts` on `origin/main` is the canonical dropdown list. The - current site exposes it through `/docs/api/versions`. Legacy selectors load - that manifest through the main branch's Vercel origin to avoid cross-subdomain - Cloudflare challenges. + current site exposes it through `https://sourcegraph.com/docs/api/versions`, + and legacy selectors load that manifest at runtime. - A legacy branch's bundled `src/data/versions.ts` is only a fallback. Its first entry identifies the archived site and must not have the `latest` label. - A legacy selector shows the current latest version, its selected archived diff --git a/src/components/VersionSelector.tsx b/src/components/VersionSelector.tsx index d4ffef9b9..708444a0e 100644 --- a/src/components/VersionSelector.tsx +++ b/src/components/VersionSelector.tsx @@ -14,7 +14,7 @@ import {Fragment, useEffect, useState} from 'react'; const versionsUrl = process.env.NEXT_PUBLIC_DOCS_VERSIONS_URL ?? - 'https://sourcegraph-docs-git-main-sourcegraph-f8c71130.vercel.app/docs/api/versions'; + 'https://sourcegraph.com/docs/api/versions'; function isVersion(value: unknown): value is VersionI { if (typeof value !== 'object' || value === null) return false;