fix(webapp): org avatars blocked by img-src CSP and avatar overflow on failed load - #4600
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📜 Recent review details⏰ Context from checks skipped due to timeout. (2)
WalkthroughThe webapp now handles failed avatar images, including failures detected before hydration, by rendering a globe fallback. Image CSP matching supports trailing-slash path prefixes and includes Google favicon shards and Trigger.dev changelog images. Tests cover these image sources and path rules. Radio button variants use updated state colors. Preset access options use increased height and top-aligned content. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
7823ead to
f549a98
Compare
@trigger.dev/build
trigger.dev
@trigger.dev/core
@trigger.dev/python
@trigger.dev/react-hooks
@trigger.dev/redis-worker
@trigger.dev/rsc
@trigger.dev/schema-to-json
@trigger.dev/sdk
commit: |
What & why
Org avatars disappeared from the sidebar, replaced by alt text spilling across it. Two bugs stacked: the document img-src CSP pins the Google favicon endpoint org avatars are stored as, but Google 302-redirects it to
tN.gstatic.comand CSP re-checks the redirect target, so the avatar is refused. Changelog images served fromtrigger.devin the agent chat were also missing from the allowlist. AndAvatar.tsxhad no clipping and no error fallback, so a refused image degraded into overflowing alt text.What's inside
CSP allowlist —
app/utils/cspImageOrigins.ts: the base sources gain the four gstatic shardst0–t3.gstatic.com, path-pinned to/faviconV2, plushttps://trigger.dev/changelog/as a path prefix. No wildcards — the no-wildcard beacon policy stands. The shard hosts are Google-operated with no public write path, so the enumeration is as narrow as the existings2/faviconsentry; if Google ever adds at4, the failure mode is one broken avatar, not a broken page.Avatar fallback —
app/components/primitives/Avatar.tsx: the image box clips, and a failed load falls back to the globe icon. That covers failures before hydration too —onErrornever replays for a node that already failed, so a ref checkscomplete && naturalWidth === 0at attach time. The error state resets when the URL changes (key={avatar.url}).Radio card theming —
app/components/primitives/RadioButton.tsx: in the dark themes the checked radio card rendered darker than the unchecked ones. Unchecked cards now sit onbackground-bright(near-black in dark, unchanged white in light) and the checked card uses thesurface-controltokens, so selection reads black → grey in dark themes; light theme keeps its current look. The API keys route keeps its indigo checked-hover via an explicit override.Testing
The CSP test helper now implements CSP's real path-matching rule (trailing slash = prefix, otherwise exact, query ignored) and asserts the pins hold: the gstatic redirect target passes,
beacon.pngon gstatic, at9shard, and non-changelogtrigger.devpaths stay blocked. 39 tests green plus webapp typecheck. Verified against a running webapp that the served directive contains the new sources.