-
Notifications
You must be signed in to change notification settings - Fork 2
epic: agent styling — aurora background, softer radii, popular actions carousel #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
twblack88
wants to merge
10
commits into
main
Choose a base branch
from
epic/agent-styling
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1390e31
chore: gitignore Nx cache and workspace-data
twblack88 2987fc9
adding rounder feels
twblack88 991d8fa
feat(SS-5656): aurora shader background on empty chat state
twblack88 b01149a
fix(SS-5656): start aurora animation loop + glass chrome on header/bo…
twblack88 5c65bb5
fix(SS-5656): bypass React wrapper, use JS API for aurora animation
twblack88 a1dc177
fix(SS-5656): fix aurora shader rendering — three dep, WebGL context …
twblack88 9709490
fixing coderabbitnit
twblack88 d86dfed
feat: add popular actions carousel for SS-5653
twblack88 18d3ab4
feat: reorder popular actions for clearer carousel ordering
twblack88 71fd57b
fix: aurora background resize and mobile fallback
twblack88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| import { useEffect, useRef, useState } from 'react' | ||
|
|
||
| import { useIsMobile } from '@/hooks/use-mobile' | ||
|
|
||
| let cachedWebGLAvailable: boolean | null = null | ||
| function isWebGLAvailable(): boolean { | ||
| if (cachedWebGLAvailable !== null) return cachedWebGLAvailable | ||
| try { | ||
| const canvas = document.createElement('canvas') | ||
| const ctx = window.WebGLRenderingContext && (canvas.getContext('webgl2') ?? canvas.getContext('webgl')) | ||
| if (ctx) { | ||
| // Release the test context immediately so we don't exhaust the browser's limit | ||
| const ext = (ctx as WebGLRenderingContext).getExtension('WEBGL_lose_context') | ||
| ext?.loseContext() | ||
| } | ||
| cachedWebGLAvailable = !!ctx | ||
| } catch { | ||
| cachedWebGLAvailable = false | ||
| } | ||
| return cachedWebGLAvailable | ||
| } | ||
|
|
||
| function CSSFallback() { | ||
| // Approximates the WebGL Aurora's purple-to-green palette (colorA #7B2FBE, | ||
| // colorB #00CD98, colorC #A855F7) with layered radial gradients. | ||
| return ( | ||
| <div | ||
| className="absolute inset-0 w-full h-full" | ||
| style={{ | ||
| background: [ | ||
| 'radial-gradient(ellipse 110% 55% at 50% 0%, rgba(123, 47, 190, 0.55) 0%, rgba(123, 47, 190, 0.18) 38%, transparent 70%)', | ||
| 'radial-gradient(ellipse 80% 60% at 50% 95%, rgba(0, 205, 152, 0.45) 0%, transparent 72%)', | ||
| 'radial-gradient(ellipse 65% 50% at 22% 28%, rgba(168, 85, 247, 0.32) 0%, transparent 68%)', | ||
| 'radial-gradient(ellipse 55% 45% at 82% 62%, rgba(0, 205, 152, 0.22) 0%, transparent 70%)', | ||
| ].join(', '), | ||
| }} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| function AuroraCanvas({ onError }: { onError: () => void }) { | ||
| const canvasRef = useRef<HTMLCanvasElement>(null) | ||
|
|
||
| useEffect(() => { | ||
| const canvas = canvasRef.current | ||
| if (!canvas) return | ||
|
|
||
| let cleanup: (() => void) | null = null | ||
| let cancelled = false | ||
|
|
||
| import('shaders/js') | ||
| .then(({ createShader }) => { | ||
| if (cancelled) return Promise.resolve(null) | ||
| return createShader( | ||
| canvas, | ||
| { | ||
| components: [ | ||
| { | ||
| id: 'aurora', | ||
| type: 'Aurora', | ||
| props: { | ||
| colorA: '#7B2FBE', | ||
| colorB: '#00CD98', | ||
| colorC: '#A855F7', | ||
| speed: 3.5, | ||
| waviness: 70, | ||
| intensity: 90, | ||
| curtainCount: 4, | ||
| rayDensity: 25, | ||
| height: 150, | ||
| balance: 40, | ||
| colorSpace: 'linear', | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| { disableTelemetry: true } | ||
| ) | ||
| }) | ||
| .then(shader => { | ||
| if (!shader) return | ||
| if (cancelled) { | ||
| shader.destroy() | ||
| return | ||
| } | ||
|
|
||
| // createShader pins the canvas to a fixed pixel size and watches the | ||
| // canvas itself for resizes — so CSS-driven layout changes (e.g. the | ||
| // sidebar opening/closing) never reach it. Observe the parent instead | ||
| // and resize explicitly. | ||
| const parent = canvas.parentElement | ||
| let resizeObserver: ResizeObserver | null = null | ||
| if (parent) { | ||
| resizeObserver = new ResizeObserver(([entry]) => { | ||
| if (!entry) return | ||
| const { width, height } = entry.contentRect | ||
| if (width > 0 && height > 0) shader.resize(width, height) | ||
| }) | ||
| resizeObserver.observe(parent) | ||
| } | ||
|
|
||
| cleanup = () => { | ||
| resizeObserver?.disconnect() | ||
| shader.destroy() | ||
| } | ||
| }) | ||
| .catch(err => { | ||
| console.error('[AuroraBackground] shader init failed, falling back to CSS:', err) | ||
| cleanup?.() | ||
| cleanup = null | ||
| if (!cancelled) onError() | ||
| }) | ||
|
|
||
| return () => { | ||
| cancelled = true | ||
| cleanup?.() | ||
| } | ||
| }, [onError]) | ||
|
|
||
| return <canvas ref={canvasRef} className="absolute inset-0 w-full h-full" style={{ display: 'block' }} /> | ||
| } | ||
|
|
||
| export function AuroraBackground() { | ||
| const isMobile = useIsMobile() | ||
| const [shaderFailed, setShaderFailed] = useState(false) | ||
|
|
||
| if (isMobile || !isWebGLAvailable() || shaderFailed) { | ||
| return <CSSFallback /> | ||
| } | ||
|
|
||
| return <AuroraCanvas onError={() => setShaderFailed(true)} /> | ||
| } |
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
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
134 changes: 134 additions & 0 deletions
134
apps/agentic-chat/src/components/PopularActionsCarousel.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| import { useCallback, useEffect, useRef, useState } from 'react' | ||
|
|
||
| import { Button } from './ui/Button' | ||
|
|
||
| type PopularActionsCarouselProps = { | ||
| actions: string[] | ||
| onActionClick: (action: string) => void | ||
| } | ||
|
|
||
| const AUTO_ADVANCE_MS = 5000 | ||
|
|
||
| export function PopularActionsCarousel({ actions, onActionClick }: PopularActionsCarouselProps) { | ||
| const containerRef = useRef<HTMLDivElement | null>(null) | ||
| const [activeIndex, setActiveIndex] = useState(0) | ||
| const [isPaused, setIsPaused] = useState(false) | ||
| const pauseTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null) | ||
| const rafRef = useRef<number | null>(null) | ||
|
|
||
| const stopResumeTimer = useCallback(() => { | ||
| if (!pauseTimeoutRef.current) return | ||
| clearTimeout(pauseTimeoutRef.current) | ||
| pauseTimeoutRef.current = null | ||
| }, []) | ||
|
|
||
| const resumeAfterInteraction = useCallback(() => { | ||
| stopResumeTimer() | ||
| pauseTimeoutRef.current = setTimeout(() => { | ||
| setIsPaused(false) | ||
| pauseTimeoutRef.current = null | ||
| }, 1200) | ||
| }, [stopResumeTimer]) | ||
|
|
||
| const goToSlide = useCallback((index: number) => { | ||
| const container = containerRef.current | ||
| if (!container) return | ||
| const item = container.querySelector<HTMLButtonElement>(`[data-action-index="${index}"]`) | ||
| if (!item) return | ||
| item.scrollIntoView({ behavior: 'smooth', inline: 'start', block: 'nearest' }) | ||
| setActiveIndex(index) | ||
| }, []) | ||
|
|
||
| const handleScroll = useCallback(() => { | ||
| if (rafRef.current) cancelAnimationFrame(rafRef.current) | ||
|
|
||
| rafRef.current = requestAnimationFrame(() => { | ||
| const container = containerRef.current | ||
| if (!container) return | ||
|
|
||
| const children = Array.from(container.querySelectorAll<HTMLButtonElement>('[data-action-index]')) | ||
| if (children.length === 0) return | ||
|
|
||
| let closestIndex = 0 | ||
| let closestDistance = Number.POSITIVE_INFINITY | ||
|
|
||
| children.forEach((child, index) => { | ||
| const distance = Math.abs(child.offsetLeft - container.scrollLeft) | ||
| if (distance < closestDistance) { | ||
| closestDistance = distance | ||
| closestIndex = index | ||
| } | ||
| }) | ||
|
|
||
| setActiveIndex(closestIndex) | ||
| }) | ||
| }, []) | ||
|
|
||
| useEffect(() => { | ||
| if (actions.length <= 1 || isPaused) return | ||
|
|
||
| const timer = setInterval(() => { | ||
| const nextIndex = (activeIndex + 1) % actions.length | ||
| goToSlide(nextIndex) | ||
| }, AUTO_ADVANCE_MS) | ||
|
|
||
| return () => clearInterval(timer) | ||
| }, [actions.length, activeIndex, goToSlide, isPaused]) | ||
|
|
||
| useEffect(() => { | ||
| return () => { | ||
| stopResumeTimer() | ||
| if (rafRef.current) cancelAnimationFrame(rafRef.current) | ||
| } | ||
| }, [stopResumeTimer]) | ||
|
|
||
| return ( | ||
| <div | ||
| className="bg-background/80 backdrop-blur-md border-t border-border" | ||
| onMouseEnter={() => setIsPaused(true)} | ||
| onMouseLeave={() => setIsPaused(false)} | ||
| onFocusCapture={() => setIsPaused(true)} | ||
| onBlurCapture={() => setIsPaused(false)} | ||
| > | ||
| <div className="mx-auto max-w-2xl px-4 py-3"> | ||
| <div | ||
| ref={containerRef} | ||
| className="flex snap-x snap-mandatory gap-2 overflow-x-auto scroll-smooth pb-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden" | ||
| onScroll={handleScroll} | ||
| onTouchStart={() => { | ||
| stopResumeTimer() | ||
| setIsPaused(true) | ||
| }} | ||
| onTouchEnd={resumeAfterInteraction} | ||
| onTouchCancel={resumeAfterInteraction} | ||
| role="region" | ||
| aria-label="Popular actions" | ||
| > | ||
| {actions.map((action, index) => ( | ||
| <Button | ||
| key={action} | ||
| data-action-index={index} | ||
| onClick={() => onActionClick(action)} | ||
| title={action} | ||
| variant="outline" | ||
| className="h-[52px] w-[85%] shrink-0 snap-start whitespace-normal text-left leading-tight sm:w-[calc(50%-0.25rem)]" | ||
| > | ||
| {action} | ||
| </Button> | ||
| ))} | ||
| </div> | ||
| <div className="mt-2 flex justify-center gap-1.5"> | ||
| {actions.map((action, index) => ( | ||
| <button | ||
| key={`dot-${action}`} | ||
| type="button" | ||
| onClick={() => goToSlide(index)} | ||
| aria-label={`Show action ${index + 1}`} | ||
| className={`h-1.5 w-1.5 rounded-full transition-colors ${index === activeIndex ? 'bg-foreground' : 'bg-muted-foreground/30'}`} | ||
| /> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gate glass header styles by empty-chat state.
The new glass treatment is always on. Based on the PR objective, this should only apply when the empty state is visible; otherwise the header styling will be inconsistent during active chats.
Suggested direction
🤖 Prompt for AI Agents