Skip to content

Fix/proxy scores sort mutation - #48

Open
MayurK-cmd wants to merge 1 commit into
Anakin-Inc:masterfrom
MayurK-cmd:fix/proxy-scores-sort-mutation
Open

Fix/proxy scores sort mutation#48
MayurK-cmd wants to merge 1 commit into
Anakin-Inc:masterfrom
MayurK-cmd:fix/proxy-scores-sort-mutation

Conversation

@MayurK-cmd

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #47
Fixes an impure render in webapp/src/pages/ProxyScores.tsx where the per-host
proxy score array was sorted in-place (data.scores[host].sort(...)) during
render, mutating state derived from the API response. Under <StrictMode> the
render runs twice in dev, amplifying the side effect.

The sort is now applied to a copy of the array:

const scores = [...data.scores[host]].sort((a, b) => b.score - a.score);

No behavior change — the displayed order is identical.

How to test

  1. Start the server with PROXY_URLS configured and scrape a few URLs so
    scores are populated.
  2. Open the web dashboard → Proxy Scores and confirm scores still render
    best-first per host (unchanged ordering).
  3. In dev, confirm no render-time mutation warnings appear under StrictMode.

Checklist

  • Tests pass (cd server && go test ./...) — no Go code changed
  • No breaking changes to existing API endpoints
  • Documentation updated — N/A

@MayurK-cmd
MayurK-cmd force-pushed the fix/proxy-scores-sort-mutation branch from 9fbfc82 to 536898f Compare August 4, 2026 12:52
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.

ProxyScores page mutates API response state during render (in-place sort)

1 participant