Skip to content

Commit 4e75380

Browse files
committed
fix(shell-docs): framework selector reflects effectiveFramework
The selector's display label and dropdown checkmark were keyed off URL framework + stored only, so on `/` (URL null, no localStorage) it read "Pick a backend" even though the page was rendering Built-in Agent code. Switch both to `effectiveFramework` so the chrome stays honest about what the page is actually rendering. Renames the legacy "Clear selection" affordance to "Reset to default (Built-in Agent)" — the action now means "go back to soft-default," not "have nothing selected." Only shown when storedFramework is set, so it doesn't surface for fresh visitors who never picked.
1 parent f80a29c commit 4e75380

1 file changed

Lines changed: 19 additions & 18 deletions

File tree

showcase/shell-docs/src/components/framework-selector.tsx

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ export function FrameworkSelector({
7272
}: FrameworkSelectorProps) {
7373
const router = useRouter();
7474
const pathname = usePathname() ?? "";
75-
const { framework, storedFramework, knownFrameworks, setStoredFramework } =
76-
useFramework();
75+
const {
76+
framework,
77+
storedFramework,
78+
effectiveFramework,
79+
knownFrameworks,
80+
setStoredFramework,
81+
} = useFramework();
7782
const [open, setOpen] = useState(false);
7883
const panelRef = useRef<HTMLDivElement>(null);
7984
const buttonRef = useRef<HTMLButtonElement>(null);
@@ -107,13 +112,11 @@ export function FrameworkSelector({
107112
};
108113
}, [open]);
109114

110-
// Display the URL-derived framework when present; fall back to the
111-
// stored choice so unscoped pages (/, /quickstart, etc.) still show
112-
// the user's last pick instead of resetting to the placeholder. Same
113-
// precedence used by the Clear-Selection button below (line ~262).
114-
const current = options.find(
115-
(o) => o.slug === (framework ?? storedFramework),
116-
);
115+
// Display whatever the page is currently rendering as: URL framework
116+
// when present, then stored choice, then the soft-default
117+
// (Built-in Agent). The selector should never read "Pick a backend"
118+
// when the docs are actually rendering BIA code — that's misleading.
119+
const current = options.find((o) => o.slug === effectiveFramework);
117120
const label = current?.name ?? "Pick an agentic backend";
118121

119122
// Compute the target href for a given framework option given the current
@@ -265,18 +268,16 @@ export function FrameworkSelector({
265268
: "absolute top-full left-0 mt-1 w-[340px] max-h-[70vh] overflow-y-auto rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] shadow-lg z-50 p-2"
266269
}
267270
>
268-
{(framework || storedFramework) && (
271+
{storedFramework && (
269272
<button
270273
type="button"
271274
className="w-full text-left px-2 py-1.5 text-[11px] text-[var(--text-muted)] hover:text-[var(--text)] cursor-pointer"
272275
onClick={() => {
273276
setStoredFramework(null);
274-
// If we're on a framework-scoped route, flip back to the
275-
// equivalent `/docs/<feature>` page. On `/docs/*` and
276-
// other non-scoped routes, clearing a stale stored pick
277-
// is purely a preference change — no navigation needed,
278-
// which is why the escape hatch is reachable even when
279-
// `framework` is null.
277+
// If we're on a framework-scoped route, flip back to
278+
// the unscoped equivalent so the soft-default takes
279+
// over. On already-unscoped pages, clearing is just a
280+
// preference change with no navigation needed.
280281
const frameworkTail = stripFrameworkPrefix(
281282
pathname,
282283
knownFrameworks,
@@ -287,7 +288,7 @@ export function FrameworkSelector({
287288
setOpen(false);
288289
}}
289290
>
290-
Clear selection
291+
Reset to default (Built-in Agent)
291292
</button>
292293
)}
293294

@@ -302,7 +303,7 @@ export function FrameworkSelector({
302303
{catLabel}
303304
</div>
304305
{opts.map((opt) => {
305-
const isActive = opt.slug === framework;
306+
const isActive = opt.slug === effectiveFramework;
306307
return (
307308
<button
308309
key={opt.slug}

0 commit comments

Comments
 (0)