Commit 9a175e1
fix(api): plot of the day shows light preview image in dark mode (#10308)
## Summary
- Fixes a user bug report (on `/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.
- Root cause: `GET /insights/plot-of-the-day` only returned the legacy
`preview_url`, which is an ORM synonym for `preview_url_light`. The
frontend has been theme-aware since Phase C (`selectPreviewUrl` in
`app/src/utils/themedPreview.ts`, and `PlotOfTheDayData` already
declares the themed fields), but with no `preview_url_dark` in the
payload it always fell back to the light image.
- Fix: `PlotOfTheDayResponse` now carries `preview_url_light` /
`preview_url_dark`, and `_build_potd` threads the dark URL through the
candidate selection. No frontend change needed — `PlotOfTheDayTerminal`
picks the dark variant up automatically.
## Test plan
- [x] `uv run pytest tests/unit/api/test_routers.py` — 137 passed,
including the extended `test_potd_with_db` which now asserts both themed
URLs flow through to the response
- [x] `uv run ruff check` / `ruff format --check` / `uv run mypy
api/routers/insights.py` — clean
## Checklist
- [x] `CHANGELOG.md` updated under `[Unreleased]` (follow-up commit on
this branch referencing this PR number)
- [x] Related documentation updated if behavior changed — none needed
(no analytics events, workflows, or user-facing docs touched)
---
_Generated by [Claude
Code](https://claude.ai/code/session_0162HVVDfD1xUDwP3Gs2b3ns)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 68babbc commit 9a175e1
3 files changed
Lines changed: 27 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
141 | 146 | | |
142 | 147 | | |
143 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
| |||
422 | 424 | | |
423 | 425 | | |
424 | 426 | | |
425 | | - | |
| 427 | + | |
426 | 428 | | |
427 | 429 | | |
428 | 430 | | |
| |||
436 | 438 | | |
437 | 439 | | |
438 | 440 | | |
| 441 | + | |
439 | 442 | | |
440 | 443 | | |
441 | 444 | | |
| |||
445 | 448 | | |
446 | 449 | | |
447 | 450 | | |
448 | | - | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
449 | 454 | | |
450 | 455 | | |
451 | 456 | | |
452 | 457 | | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
453 | 464 | | |
454 | 465 | | |
455 | 466 | | |
| |||
459 | 470 | | |
460 | 471 | | |
461 | 472 | | |
| 473 | + | |
| 474 | + | |
462 | 475 | | |
463 | 476 | | |
464 | 477 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1775 | 1775 | | |
1776 | 1776 | | |
1777 | 1777 | | |
1778 | | - | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
1779 | 1781 | | |
1780 | 1782 | | |
1781 | 1783 | | |
| |||
1784 | 1786 | | |
1785 | 1787 | | |
1786 | 1788 | | |
| 1789 | + | |
| 1790 | + | |
1787 | 1791 | | |
1788 | 1792 | | |
1789 | 1793 | | |
| |||
1799 | 1803 | | |
1800 | 1804 | | |
1801 | 1805 | | |
| 1806 | + | |
| 1807 | + | |
1802 | 1808 | | |
1803 | 1809 | | |
1804 | 1810 | | |
| |||
0 commit comments