Proxy /api/session/runs on the web client so the Run History panel is filled in (#82) - #83
Merged
Merged
Conversation
The page fetches /api/session/runs from the web client that serves it, but only the backend had that route, so the Run History panel was answered with a 404 and stayed empty wherever /api/* is not routed straight to the backend — including the documented docker-compose setup. The web client now proxies the endpoint like every other per-player one, forwarding the auth cookie and passing the backend's status through so a 401 still triggers the re-login flow. A new GamePageProxyCoverageTest reads the API calls out of the rendered page and fails if any of them has no route here, so the next endpoint cannot slip through the same gap. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
The guard only read the game page, so the same missing-proxy gap could reopen on the pages that post credentials. It now renders every page the web client serves and checks each call they make, and says so in its name. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
Self-reviewScored against the diff and command output at head
FindingsThese are limitations worth stating rather than defects to block on; none were left unfixed where a fix was mechanical.
Two of the three test files exceeded what the original fix strictly needed, deliberately: the guard test was widened from the game page to every page the web client serves, so the login and register pages that post credentials are covered by the same check. This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). |
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.
Summary
fetch('/api/session/runs', ...)is made against the web client's own origin — but no route existed there. The request was answered with a 404 and the Run History panel stayed empty anywhere/api/*is not routed straight to the backend by an external reverse proxy, including thedocker-compose up/localhost:3000setup the README documents.GET /api/session/runsis now proxied byWebController/BackendService, following the pattern already used by/api/session/ruler-stats: the browser'sCookieheader is forwarded to the backend and failures are translated throughproxy(...), so a backend 401 reaches the browser as a 401 and the page's re-login flow still fires.RunHistory/RunRecordresponse shape is mirrored as web-client models (alongside the existingRulerStatsmirror) so the whole record is relayed rather than the subset the panel happens to read today.GamePageProxyCoverageTestreads the API calls out of the rendered game page and asserts each one has a matching route on the web client. The calls are extracted from the markup rather than listed in the test, so an endpoint added later is covered without the test being touched — this class of drift cannot reopen silently.Module(s) touched
web-clientonly. The backend is unchanged; itsGET /api/session/runsendpoint and the README entry describing it were already correct — the web-client half of the contract was what was missing.Test plan
cd backend && mvn test— 267 tests, 0 failures (unchanged module, re-run to confirm nothing regressed)cd web-client && mvn test— 21 tests, 0 failures (17 before this change)WebControllermapping stashed,GamePageProxyCoverageTest.everyApiCallTheGamePageMakesIsServedByTheWebClientand both newWebControllerTestcases fail (404 where 200/401 was expected); with it restored, all pass.node --test web-client/src/test/js/) — no Node interpreter is present in this environment. No JavaScript was changed by this PR, and CI runs that job.Documentation
CHANGELOG.md— entry added under Unreleased → Web Client.README.md— the Technical Architecture → Web Client section now states that the page's/api/*calls are answered and proxied by the web client, and points at the new guard test.PLAYER_GUIDE.md,MVP.md,DOCS.md— checked; no change needed, as they describe the Run History panel's intended behaviour, which this change restores rather than alters.Deferred this cycle
Closes #82
This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).