Skip to content

fix(search): never auto-enable ADS compatibility mode - #944

Open
thostetler wants to merge 3 commits into
adsabs:masterfrom
thostetler:fix/no-auto-ads-compat-mode
Open

thostetler wants to merge 3 commits into
adsabs:masterfrom
thostetler:fix/no-auto-ads-compat-mode

Conversation

@thostetler

Copy link
Copy Markdown
Member

ADS Compatibility search mode was turning on without the user asking: legacy-ADS referrers seeded it into the prefs cookie, the classic form forced it on every submit, and the landing page announced it with a toast. All three are removed; the mode is still reachable from the Search mode menu or an explicit ads_compat=1 URL.

  • Users already auto-enrolled under the old code keep searchMode=ADS_COMPAT in their prefs cookie — it's not cleared, since the cookie carries no marker distinguishing a machine-written value from a real preference, and clearing it would erase genuine choices. They can leave via the Search mode menu, or by switching to a non-Astrophysics discipline, which clears it.

The legacy-ADS referrer path seeded searchMode=ADS_COMPAT into the prefs
cookie and the classic form forced ads_compat=1 on every submit, so the
mode turned on without the user asking. The landing page then announced
it with a toast.

Astrophysics discipline seeding and the fromADS redirect-loop guard stay.
The mode itself is unchanged and still reachable from the Search mode menu
or an explicit ads_compat=1 URL.
@thostetler
thostetler requested a review from shinyichen October 1, 2026 15:43
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Bundle size

Shared by all pages: 629.6 kB (—) ⚪

No route changed by more than 1 kB. ✅

First load = polyfills + shared _app chunks + route chunks, gzipped.

@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 55.1%. Comparing base (ef57c7e) to head (ed1c3d8).

Files with missing lines Patch % Lines
src/ssr-utils.ts 66.7% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #944     +/-   ##
========================================
+ Coverage    55.0%   55.1%   +0.1%     
========================================
  Files         374     374             
  Lines       11462   11467      +5     
  Branches     2514    2518      +4     
========================================
+ Hits         6303    6310      +7     
+ Misses       4527    4525      -2     
  Partials      632     632             
Files with missing lines Coverage Δ
src/components/ClassicForm/ClassicForm.tsx 81.3% <ø> (+1.7%) ⬆️
src/middleware.ts 94.0% <100.0%> (+0.2%) ⬆️
src/ssr-utils.ts 82.3% <66.7%> (-1.4%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Arriving from legacy ADS redirects to /?fromADS=true and stamps the
discipline into the prefs cookie, but visiting that link directly did
nothing: the redirect block skips once fromADS is present, so a forwarded
link never seeded anything.

The discipline is resolved server-side so the first render already has it,
which is what selects the ADS variant of the site tour. Scoped to the home
page, matching where the cookie is written, so the param cannot override a
persisted discipline on other pages. Search mode is untouched.
@thostetler
thostetler marked this pull request as ready for review October 1, 2026 19:03
Copilot AI balanced review requested due to automatic review settings October 1, 2026 19:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Middleware can persist Astrophysics even when an explicit valid forceMode selects another discipline.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Removes automatic ADS Compatibility activation while retaining explicit user preferences and Astrophysics handoff.

Risk: Medium—fromADS can persist Astrophysics despite an explicit forceMode.

Changes:

  • Stops legacy referrals and Classic Form submissions from enabling compatibility mode.
  • Removes the automatic compatibility toast.
  • Adds middleware and SSR regression coverage.
File Description
src/​ssr-utils.ts Resolves fromADS as Astrophysics only.
src/​pages/​index.tsx Removes the compatibility-mode toast.
src/​middleware.ts Stops seeding ADS_COMPAT; retains discipline seeding.
src/​middlewares/​__tests__/​middleware.routes.integration.test.ts Tests referral cookie behavior.
src/​components/​ClassicForm/​ClassicForm.tsx Removes forced compatibility URL parameter.
src/​components/​ClassicForm/​ClassicForm.test.tsx Verifies compatibility is not forced.
src/​__tests__/​ssr-utils.test.ts Tests fromADS precedence and scope.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/middleware.ts Outdated
Comment on lines +488 to +490
if (path === '/' && req.nextUrl.searchParams.get('fromADS') === 'true') {
setPrefsCookie(res, req, { mode: 'ASTROPHYSICS' });
}
fromADS's direct-hit cookie stamp ignored forceMode, so a page rendered
under a forced discipline would silently revert to ASTROPHYSICS on the
next navigation. Gate the stamp on forceMode not mapping to a discipline,
matching updateUserStateSSR's own precedence.

This branch has not been deployed

No deployments
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.

2 participants