Skip to content

Stop sticky language tabs from overriding non-language tab choices - #2956

Merged
dbrian57 merged 2 commits into
mainfrom
fix-sticky-tabs-non-language
Jul 24, 2026
Merged

Stop sticky language tabs from overriding non-language tab choices#2956
dbrian57 merged 2 commits into
mainfrom
fix-sticky-tabs-non-language

Conversation

@dbrian57

Copy link
Copy Markdown
Contributor

Problem

#2759 added cross-page persistence for the Python/TypeScript tab choice. But restore() re-ran after every DOM mutation (via a MutationObserver meant to catch SPA route changes). Switching a tab is itself a DOM mutation, so on any page whose tab group mixes a saved language with other labels — e.g. Python / TypeScript / HTTP API on /weave/guides/tracking/querying-calls, or Command Line / Python / Python notebook on /models/quickstart — clicking a non-language tab triggered a restore ~80ms later that snapped the group right back to the saved language. Those tabs were effectively unselectable.

Fix

Two complementary changes to code-group-language-persist.js:

  1. Manual overrides win. A trusted click on a non-language tab marks its group as reader-overridden, and restore() skips overridden groups for the rest of that page view. Overrides live in a WeakSet keyed by the group's DOM node, so they clear naturally when navigation replaces the page content. Clicking a language tab in an overridden group un-marks it. Synthetic clicks dispatched by restore() itself are ignored (isTrusted check), so they can never register as reader choices.
  2. Restore on navigation, not on every mutation. The MutationObserver now re-applies the saved language only when location.pathname actually changed, with the same hydration retry ladder as initial load.

Verification (local mint dev)

  • On /weave/guides/tracking/querying-calls (Python / TypeScript / HTTP API): picked TypeScript (preference saved), then clicked HTTP API — it stayed selected 2s later, well past all restore timers. Previously it reverted within ~80ms.
  • The second tab group on the same page kept the TypeScript preference — overrides are scoped per group.
  • SPA-navigated to /weave/quickstart — the saved TypeScript preference was auto-restored there (Python is the default first tab).
  • No console errors from the script.

🤖 Generated with Claude Code

The tab-language persistence script re-ran restore() after every DOM
mutation, so on pages whose tab groups mix a saved language with other
labels (Python / TypeScript / HTTP API, Command Line / Python), clicking
a non-language tab mutated the DOM and triggered a restore that snapped
the group straight back to the saved language, making those tabs
unselectable.

Two fixes:
- Manual overrides win: a trusted click on a non-language tab marks its
  group as reader-overridden for the rest of the page view, and
  restore() skips overridden groups. Overrides are held in a WeakSet
  keyed by the group node, so they clear naturally when navigation
  replaces the DOM.
- Restore only on navigation: the MutationObserver now re-applies the
  saved language only when location.pathname actually changed, instead
  of after every mutation burst.

Verified locally with mint dev: HTTP API stays selected on
/weave/guides/tracking/querying-calls, and the saved TypeScript
preference still restores on SPA navigation to /weave/quickstart.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@w-b-hivemind

w-b-hivemind Bot commented Jul 23, 2026

Copy link
Copy Markdown

HiveMind Sessions

1 session · 21m · $5.59

Session Agent Duration Tokens Cost Lines
Fix Sticky Code Language Tab Script
12f5fc89-18cd-4063-876e-35289cf276de
claude 21m 28.6K $5.59 +76 -14
Total 21m 28.6K $5.59 +76 -14
Screenshots

View all sessions in HiveMind →

Run claude --resume 12f5fc89-18cd-4063-876e-35289cf276de to pickup where you left off.

@mintlify

mintlify Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
wandb 🟢 Ready View Preview Jul 23, 2026, 3:42 PM

@mintlify

mintlify Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
wandb 🟡 Building Jul 23, 2026, 3:39 PM

@dbrian57
dbrian57 marked this pull request as ready for review July 23, 2026 18:05
@dbrian57
dbrian57 requested a review from a team as a code owner July 23, 2026 18:05
@dbrian57
dbrian57 merged commit 9a337bc into main Jul 24, 2026
10 checks passed
@dbrian57
dbrian57 deleted the fix-sticky-tabs-non-language branch July 24, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant