fix(ui): theme flash on navigation + search filter button alignment#41
Conversation
- base.html: apply stored theme synchronously in <head> so light-mode users no longer see a brief dark paint on every navigation - search.html: vertically center the All / Ask Logs / Agent Logs filter buttons with the Search heading
📝 WalkthroughWalkthroughThis PR addresses two cosmetic UI issues. It adds an early theme initialization script to ChangesUI Cosmetic Fixes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
templates/base.html (1)
12-13: ⚡ Quick winValidate stored theme before applying it.
At Line 12–Line 13, any
localStorage.themevalue is accepted. A stale/invalid value can leavedata-themein an unsupported state and break styling consistency.Suggested hardening
- var t = localStorage.getItem('theme') || 'dark'; - document.documentElement.setAttribute('data-theme', t); + var t = localStorage.getItem('theme'); + var theme = (t === 'light' || t === 'dark') ? t : 'dark'; + document.documentElement.setAttribute('data-theme', theme);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@templates/base.html` around lines 12 - 13, The code currently trusts localStorage.getItem('theme') and directly sets document.documentElement.setAttribute('data-theme', t'), which can apply stale/invalid themes; update the logic around localStorage.getItem('theme') to validate t against a whitelist of supported values (e.g. 'light' and 'dark') and only call document.documentElement.setAttribute('data-theme', t) when t is one of those values, otherwise fall back to the default ('dark'); reference the existing localStorage.getItem('theme') retrieval and document.documentElement.setAttribute('data-theme', t) lines when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@templates/base.html`:
- Around line 12-13: The code currently trusts localStorage.getItem('theme') and
directly sets document.documentElement.setAttribute('data-theme', t'), which can
apply stale/invalid themes; update the logic around
localStorage.getItem('theme') to validate t against a whitelist of supported
values (e.g. 'light' and 'dark') and only call
document.documentElement.setAttribute('data-theme', t) when t is one of those
values, otherwise fall back to the default ('dark'); reference the existing
localStorage.getItem('theme') retrieval and
document.documentElement.setAttribute('data-theme', t) lines when making the
change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 09503fe9-dc4e-4eee-a80b-6f227282e4fe
📒 Files selected for processing (2)
templates/base.htmltemplates/search.html
Closes #40.
Theme flash: add a synchronous IIFE in
<head>that readslocalStorage.themeand setsdata-themeondocumentElementBEFORE the stylesheet is parsed, so the first paint uses the user's stored palette. Wrapped intry/catchfor storage-blocked browsers. The existingapplyTheme()onDOMContentLoadedstays as the source of truth for runtime toggles.Search button alignment: add
style="align-self:center"to the.btn-groupintemplates/search.htmlso the filter buttons vertically center with the<h1>Search</h1>. Scoped to the search page so other pages using the shared.page-headeraren't touched.Test plan
/search— filter buttons vertically centered with the Search headingSummary by CodeRabbit
New Features
Style