feat: refine robot avatar cursor-follow + center welcome questions#2
Merged
Conversation
Avatar smoothly eases back to a neutral position when isTalking flips true, and resumes following the cursor once it returns to idle. Reuses the existing rAF lerp by zeroing the shared target ref during talking and short-circuiting mousemove updates via an isTalking ref.
- Cache the natural center on mount (with transform briefly cleared) and re-measure on resize/scroll. The previous approach read the live rect on every mousemove, which fed the transformed AABB back into the offset calculation and made the avatar settle to ~idle whenever the cursor was near or over it. - Apply a sqrt response curve so small offsets still produce visible tilt, keeping the avatar reactive when the cursor is close. - Reset to idle when the cursor leaves the viewport via mouseleave on document.documentElement, and on window blur for tab switches. - Stay idle while the cursor is over any input/textarea/contenteditable so the avatar doesn't jitter during typing. - Tune amplitudes (35° tilt -> 28°, 12px -> 10px translate, 350 -> 400 follow radius) for a calmer feel.
Add justify-center to the horizontal flex-wrap container so each wrapped row aligns under the avatar/welcome message. The vertical sidebar layout used during conversations is unaffected.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
UX polish on the robot avatar and welcome screen.
Robot avatar — cursor follow
isTalkingflips true, the avatar smoothly returns to a neutral position (the existing rAF lerp interpolates toward a zeroed target). Mousemoves are ignored while thinking, then tracking resumes on idle.mouseleaveondocument.documentElement(the canonical cross-browser hook for "cursor exited the viewport") +windowblurfor tab switches.input,textarea, or[contenteditable], target is zeroed so the avatar doesn't jitter under the user's typing.getBoundingClientRect()on every mousemove; with a live 3DrotateY/X+perspective+translate3dtransform, the rect's center shifts in non-obvious ways and fed back into the offset calculation, collapsing the response to ~0 whenever the cursor approached the avatar. Now the natural center is cached on mount (with the transform briefly cleared) and re-measured on resize/scroll.onMovecompares against the stable cached point — no feedback loop.sign(v) * sqrt(|v|)) amplifies small offsets so the tilt is visible when the cursor is close, while keeping the same saturation at the radius.MAX_TILT_DEG= 28°,MAX_TRANSLATE_PX= 10,FOLLOW_RADIUS_PX= 400.Welcome screen
justify-centerto the horizontalflex-wrapso each wrapped row sits under the avatar/welcome message. The vertical sidebar layout used during conversations is untouched.Test plan
npx vitest run— 121/121 passingnpx playwright test— 7/7 passing