fix(server): keep results when applying a scope/rule from the served page#84
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_rulecalled_redirect_back, which builds its target from the Referer. Every response setsReferrer-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/verticalfields on the scope and rank forms (_search_context_fieldshelper), and a new_redirect_to_resultsredirects 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