Skip to content

fix(server): keep results when applying a scope/rule from the served page#84

Merged
ErikChevalier merged 1 commit into
mainfrom
fix/served-scope-rank-keeps-results
Jun 10, 2026
Merged

fix(server): keep results when applying a scope/rule from the served page#84
ErikChevalier merged 1 commit into
mainfrom
fix/served-scope-rank-keeps-results

Conversation

@ErikChevalier

Copy link
Copy Markdown
Contributor

Mirrors the Android sibling fix (FlintWave/SearchMob#70).

The bug

On the served browser page, applying a scope or a per-result block/raise/lower/pin rule sent the user to the home page with an empty box, discarding the results.

Root cause

set_scope / set_domain_rule called _redirect_back, which builds its target from the Referer. Every response sets Referrer-Policy: no-referrer, so the browser strips the Referer and the redirect always fell through to "/".

Fix

Carry the current search as hidden q/sort/vertical fields on the scope and rank forms (_search_context_fields helper), and a new _redirect_to_results redirects the mutation POSTs to /search?q=…&vertical=…&sort=… — back to the same results with the new ranking applied. The home-page / settings scope selector (no query) still falls back to /.

Tests

test_mutation_redirects_back_to_the_results_page + test_mutation_without_a_query_falls_back_home. ruff, mypy src, and the full server suite pass.

🤖 Generated with Claude Code

…page

Applying a scope or a per-result block/raise/lower/pin rule on the served search
page dumped the user on the home page with an empty box, losing the results.
`_redirect_back` derives its target from the Referer, but every response sets
`Referrer-Policy: no-referrer`, so the Referer is stripped and the redirect
always fell through to "/".

Carry the current search (q/sort/vertical) as hidden fields on the scope and
rank forms, and redirect the mutation POSTs to `/search?q=...&vertical=...
&sort=...` so the owner lands on the same results with the new ranking applied.
The home-page / settings scope selector (no query) still falls back to "/".

Mirrors the Android sibling fix. Regression tests assert the redirect target and
the no-query fallback; ruff, mypy, and the server suite pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ErikChevalier ErikChevalier merged commit cdc6aa5 into main Jun 10, 2026
1 check passed
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