Skip to content

Add aurora shader background to empty chat state#250

Merged
twblack88 merged 5 commits into
epic/agent-stylingfrom
tb/ss-5656-branch-shader-background-exploration
May 20, 2026
Merged

Add aurora shader background to empty chat state#250
twblack88 merged 5 commits into
epic/agent-stylingfrom
tb/ss-5656-branch-shader-background-exploration

Conversation

@twblack88
Copy link
Copy Markdown
Contributor

@twblack88 twblack88 commented May 4, 2026

Summary

  • Adds an animated WebGPU aurora shader (via shaders.com) as the background of the empty chat state on desktop
  • Falls back to a CSS radial-gradient on mobile or when WebGL is unavailable
  • Header and bottom chrome get a bg-background/80 backdrop-blur-md glass treatment when the empty state is visible

Bug fixes uncovered during implementation

Three bugs had to be resolved before the shader would render:

  • Missing three depshaders/js imports three/tsl internally but three was only in bun's internal cache, not on the node_modules resolution path Vite uses. Fixed by adding three as an explicit dependency and adding optimizeDeps: { include: ['three'] } to the Vite config.
  • WebGL context leakisWebGLAvailable() was called on every render and leaked a WebGL context each time. With React Strict Mode doubling renders in dev, the browser hit its ~16-context limit and started killing the aurora's context. Fixed by caching the result at module scope and immediately releasing the test context via WEBGL_lose_context.
  • Invalid WGSL identifiers — the shaders library auto-generates node IDs using Math.random(), which produces values like 0.959.... The dot ends up in WGSL struct member names and the WebGPU pipeline rejects the shader. Fixed by passing an explicit id: 'aurora' on the component.

Test plan

  • Open app on desktop — aurora animates behind "How can I help you today?"
  • Send a message — aurora disappears, normal chat view takes over
  • Open on mobile (or narrow window) — CSS gradient fallback shows instead
  • No WebGL console errors or context warnings

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added animated background effects to the chat interface with fallback support for devices without WebGL.
  • Style

    • Updated dashboard header with enhanced visual effects including backdrop blur.
    • Enhanced chat empty state styling with semi-transparent backgrounds and improved visual presentation.

twblack88 and others added 4 commits April 27, 2026 13:48
Uses shaders.com <Shader><Aurora> instead of react-three/fiber — no GLSL,
no render loop, WebGPU-first with WebGL2 fallback built in. ShapeShift
brand palette (purple-500 / green-500 / purple-300) with slow drift.

Gated behind useIsMobile (768px) and a WebGL capability check; falls back
to a CSS radial-gradient on mobile or when WebGL is unavailable. Shader
chunk is lazy-loaded so it doesn't hit the main bundle.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ttom

Animation fix: shaders.com IntersectionObserver only calls startAnimation()
on a not-visible → visible transition. Mounting with display:none then
flipping to block on the next animation frame forces that transition.

UI: header, suggestion strip, and composer get bg/80 backdrop-blur-md
so the aurora bleeds through. Header and suggestion strip get a border
to ground them visually against the background.

Built with Claude
The shaders/react Shader component has a StrictMode bug: cleanup doesn't
reset isInitializedRef, so the second (real) mount returns early from
initializeRenderer() and the animation loop never starts.

Switch to createShader() from shaders/js — a plain async function we
call in a useEffect with proper cancel/destroy handling. Lifecycle is
now fully under our control and StrictMode-safe.

Also cranked props: intensity 90, speed 3.5, waviness 70, curtainCount 4.

Built with Claude
…leak, WGSL id

- Add `three` as direct dep so Vite can resolve `three/tsl` (was only in
  bun's internal cache, not on the node_modules resolution path)
- Add `optimizeDeps: { include: ['three'] }` to vite config so Vite
  pre-bundles it before the dynamic `import('shaders/js')` fires
- Cache `isWebGLAvailable()` at module scope and immediately release the
  test context via WEBGL_lose_context — previously leaked one context per
  render, exhausting the browser limit and killing the aurora's context
- Pass explicit `id: 'aurora'` on the shader component so the library
  doesn't auto-generate an ID containing a dot (Math.random()), which
  produced invalid WGSL struct member names and crashed the GPU pipeline
- Add `.nx/` to .gitignore

Built with Claude
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
shapeshift-agentic Ready Ready Preview, Comment May 20, 2026 8:20pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

This PR adds an animated WebGL aurora background component to the agentic chat dashboard with automatic fallback to CSS gradients on unsupported devices. It introduces Three.js and Shaders dependencies, implements WebGL capability detection, updates UI styling with glassmorphism effects, and configures Vite for Three.js pre-bundling.

Changes

Aurora Background Feature

Layer / File(s) Summary
Dependencies
apps/agentic-chat/package.json
Added three (^0.184.0) and shaders (^2.5.109) runtime dependencies.
Build Configuration
apps/agentic-chat/vite.config.mjs, apps/agentic-chat/vite.config.mts
Vite optimizeDeps configured to pre-bundle three dependency for efficient loading.
Component Implementation
apps/agentic-chat/src/components/AuroraBackground.tsx
New component with cached WebGL detection via isWebGLAvailable(), animated AuroraCanvas with lazy shader loading and proper cleanup, and CSSFallback gradient for fallback rendering.
UI Integration & Styling
apps/agentic-chat/src/components/Chat.tsx, apps/agentic-chat/src/app/dashboard/page.tsx
Chat empty state renders AuroraBackground with backdrop blur; dashboard header and suggestion panels updated with bg-background/80 backdrop-blur-md glassmorphism styling.
Repository Configuration
.gitignore
Added .nx/ cache directory to ignore patterns.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A canvas that glows with aurora so bright,
WebGL dances with fallback's light,
Shaders and Three paint dreams in the sky,
Blur and backdrop blur catch the eye,
Chat feels alive, with shimmer and grace!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding an aurora shader background to the empty chat state, which is the primary feature delivered across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tb/ss-5656-branch-shader-background-exploration

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/agentic-chat/src/components/AuroraBackground.tsx (1)

6-21: 💤 Low value

isWebGLAvailable() called during render with DOM side-effect — verify SSR safety.

document.createElement is called synchronously on the first render to probe WebGL. The try/catch handles SSR gracefully (returns false → CSS fallback), but be aware that repeated hot-reloads in development will re-execute this module and the cached result from a previous build run may be stale. This is a known limitation of module-level mutable state in HMR environments.

No change needed if SSR is not in scope — just noting the edge case.

🤖 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 `@apps/agentic-chat/src/components/AuroraBackground.tsx` around lines 6 - 21,
The function isWebGLAvailable() performs document.createElement and caches the
result in cachedWebGLAvailable at module/runtime time which can produce DOM
side-effects during render and stale state across HMR; to fix, avoid running DOM
checks during SSR or synchronous render by making the probe lazy and
client-only: move the WebGL probe into a client-only effect or a safe runtime
check invoked inside useEffect or a guard like typeof window !== 'undefined'
before calling document.createElement, and remove or reset module-level
cachedWebGLAvailable on HMR if necessary (reference: isWebGLAvailable,
cachedWebGLAvailable, and the code that calls isWebGLAvailable so it uses the
new client-only check).
apps/agentic-chat/vite.config.mjs (1)

7-9: ⚡ Quick win

optimizeDeps addition is correct; consider removing the duplicate .mjs config.

The optimizeDeps: { include: ['three'] } change is the right fix. However, both vite.config.mjs and vite.config.mts now exist with near-identical content. Vite will prefer vite.config.mts over .mjs; keeping both risks them silently diverging on future edits (as just demonstrated — the same change had to be applied to both files).

♻️ Suggested cleanup

Delete vite.config.mjs and keep only vite.config.mts, since .mts provides TypeScript checking of the config itself.

🤖 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 `@apps/agentic-chat/vite.config.mjs` around lines 7 - 9, Remove the duplicate
JavaScript config file and keep the TypeScript config: delete the
vite.config.mjs file and ensure vite.config.mts contains the intended
optimizeDeps change (include: ['three']) so only vite.config.mts remains as the
authoritative Vite config to avoid future drift between vite.config.mjs and
vite.config.mts.
🤖 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.

Inline comments:
In `@apps/agentic-chat/src/components/AuroraBackground.tsx`:
- Line 82: The current .catch(console.error) on the createShader promise
swallows runtime shader failures and leaves the canvas blank; update the
AuroraBackground component to track a fallback state (e.g., useState boolean
like showCSSFallback), replace the .catch(console.error) with a handler that
logs the error and sets that fallback state, and then render the CSSFallback
component when showCSSFallback is true (same fallback used for mobile/no-WebGL).
Ensure any existing createShader success path clears the fallback state and that
you perform the same cleanup/disposing logic on error as on unmount.

---

Nitpick comments:
In `@apps/agentic-chat/src/components/AuroraBackground.tsx`:
- Around line 6-21: The function isWebGLAvailable() performs
document.createElement and caches the result in cachedWebGLAvailable at
module/runtime time which can produce DOM side-effects during render and stale
state across HMR; to fix, avoid running DOM checks during SSR or synchronous
render by making the probe lazy and client-only: move the WebGL probe into a
client-only effect or a safe runtime check invoked inside useEffect or a guard
like typeof window !== 'undefined' before calling document.createElement, and
remove or reset module-level cachedWebGLAvailable on HMR if necessary
(reference: isWebGLAvailable, cachedWebGLAvailable, and the code that calls
isWebGLAvailable so it uses the new client-only check).

In `@apps/agentic-chat/vite.config.mjs`:
- Around line 7-9: Remove the duplicate JavaScript config file and keep the
TypeScript config: delete the vite.config.mjs file and ensure vite.config.mts
contains the intended optimizeDeps change (include: ['three']) so only
vite.config.mts remains as the authoritative Vite config to avoid future drift
between vite.config.mjs and vite.config.mts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 093972cc-c323-48db-b69c-a37a406f063c

📥 Commits

Reviewing files that changed from the base of the PR and between 113fed0 and 34a417c.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • .gitignore
  • apps/agentic-chat/package.json
  • apps/agentic-chat/src/app/dashboard/page.tsx
  • apps/agentic-chat/src/components/AuroraBackground.tsx
  • apps/agentic-chat/src/components/Chat.tsx
  • apps/agentic-chat/vite.config.mjs
  • apps/agentic-chat/vite.config.mts

Comment thread apps/agentic-chat/src/components/AuroraBackground.tsx Outdated
@twblack88 twblack88 changed the base branch from main to epic/agent-styling May 20, 2026 17:26
@twblack88
Copy link
Copy Markdown
Contributor Author

Screenshot 2026-05-20 at 1 16 48 PM

@twblack88 twblack88 merged commit 9709490 into epic/agent-styling May 20, 2026
4 checks passed
@twblack88 twblack88 deleted the tb/ss-5656-branch-shader-background-exploration branch May 20, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant