fix(api): plot of the day shows light preview image in dark mode - #10308
Merged
Conversation
The plot-of-the-day response only carried the legacy preview_url (a synonym for the light variant), so the landing-page terminal card always rendered the light plot image in dark mode. The frontend has been theme-aware since Phase C (selectPreviewUrl), it just never received preview_url_dark from this endpoint. Add preview_url_light / preview_url_dark to PlotOfTheDayResponse and thread the dark URL through the candidate selection. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0162HVVDfD1xUDwP3Gs2b3ns
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0162HVVDfD1xUDwP3Gs2b3ns
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes the “plot of the day” landing-page rendering in dark mode by making the GET /insights/plot-of-the-day API response theme-aware (light/dark preview URLs), aligning the endpoint with the already theme-aware frontend selection logic.
Changes:
- Extend
PlotOfTheDayResponseto includepreview_url_lightandpreview_url_dark, while retaining the legacypreview_url. - Thread
preview_url_darkthrough POTD candidate selection and response construction. - Update unit tests and add a changelog entry documenting the fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
api/routers/insights.py |
Adds themed preview URL fields to the POTD response and threads the dark URL through selection/serialization. |
tests/unit/api/test_routers.py |
Extends the POTD unit test to assert both preview_url_light and preview_url_dark are returned. |
CHANGELOG.md |
Documents the dark-mode POTD preview fix under [Unreleased] → Fixed. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Review feedback: the themed URLs came from the candidate snapshot while code/metadata came from the later full_impl query, so the two could drift. Prefer full_impl's URLs, keeping the snapshot as fallback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0162HVVDfD1xUDwP3Gs2b3ns
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
/roc-curve/python/altair, in German): the "plot of the day" on the landing page was not displayed correctly in dark mode — the terminal card rendered the light-background preview image on the dark page.GET /insights/plot-of-the-dayonly returned the legacypreview_url, which is an ORM synonym forpreview_url_light. The frontend has been theme-aware since Phase C (selectPreviewUrlinapp/src/utils/themedPreview.ts, andPlotOfTheDayDataalready declares the themed fields), but with nopreview_url_darkin the payload it always fell back to the light image.PlotOfTheDayResponsenow carriespreview_url_light/preview_url_dark, and_build_potdthreads the dark URL through the candidate selection. No frontend change needed —PlotOfTheDayTerminalpicks the dark variant up automatically.Test plan
uv run pytest tests/unit/api/test_routers.py— 137 passed, including the extendedtest_potd_with_dbwhich now asserts both themed URLs flow through to the responseuv run ruff check/ruff format --check/uv run mypy api/routers/insights.py— cleanChecklist
CHANGELOG.mdupdated under[Unreleased](follow-up commit on this branch referencing this PR number)Generated by Claude Code