fix(web): keep the composer command menu anchored to the composer - #5336
Conversation
The `/`, `@`, and `$` menus are portaled to the body and positioned from the anchor's rect, refreshed on window resize, scroll, and a ResizeObserver on the anchor itself. The composer is centered and capped at `max-w-3xl`, so opening the right panel or the terminal drawer slides it without ever resizing it: the observer stays silent and the menu is left behind, floating next to or on top of the composer it belongs to. Observe the anchor's ancestors as well. They are what actually shrink, and they resize on every frame of the panel animation, so the menu tracks the composer through the transition instead of snapping late. Positions are compared before committing to state to keep the extra observations from re-rendering the menu on no-op resizes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
ApprovabilityVerdict: Approved 4f68017 Straightforward UI bug fix that ensures the composer command menu stays properly anchored when side panels open. Changes are limited to adding ancestor element observation and optimizing state updates with position comparison. You can customize Macroscope's approvability policy. Learn more. |
## What's Changed * fix(mcp): unblock Kimi models in OpenCode with preview tools by @hwanseoc in pingdotgg/t3code#5128 * fix(web): clear main branch lint warnings by @t3dotgg in pingdotgg/t3code#5384 * fix(mobile): preserve grouped project workspaces by @shivamhwp in pingdotgg/t3code#4642 * fix(mobile): prevent Android thread search crash by @shivamhwp in pingdotgg/t3code#5386 * fix(web): truncate long project switcher names by @FllipEis in pingdotgg/t3code#5348 * fix(mobile): avoid double dividers between thread sections by @shivamhwp in pingdotgg/t3code#5391 * fix(web): keep the composer command menu anchored to the composer by @StiensWout in pingdotgg/t3code#5336 * fix(web): restore terminal link hover styles by @StiensWout in pingdotgg/t3code#5382 * fix(ci): isolate releases from shared API rate limits by @t3dotgg in pingdotgg/t3code#5394 **Full Changelog**: pingdotgg/t3code@v0.0.32-nightly.20260805.1002...v0.0.32-nightly.20260805.1005 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.32-nightly.20260805.1005
…ngdotgg#5336) (cherry picked from commit 9235c83)
…ngdotgg#5336) (cherry picked from commit 9235c83)
…ngdotgg#5336) (cherry picked from commit 9235c83)
…ngdotgg#5336) (cherry picked from commit 9235c83)
…ngdotgg#5336) (cherry picked from commit 9235c83)
…ngdotgg#5336) (cherry picked from commit 9235c83)
Problem
Type
/,@, or$in the composer, then open the right panel (or the terminal drawer) while the menu is up: the menu stays exactly where it was and detaches from the composer it belongs to.The menu is portaled to the body and positioned from the anchor's rect, refreshed on window
resize,scroll, and aResizeObserveron the anchor itself. But the composer is centered and capped atmax-w-3xl, so on a wide window opening a side panel slides it without ever resizing it. The observer never fires and the menu is left behind.Measured at a 2200px viewport, menu vs. composer left edge:
846, composer574576, composer574536, composer top404(overlapping)396, composer top404Fix
Observe the anchor's ancestors as well. They are what actually shrink, and they resize on every frame of the panel animation, so the menu tracks the composer through the transition instead of snapping late. Positions are compared before committing to state so the extra observations don't re-render the menu on no-op resizes.
Same layer backs the slash/mention/skill menus and the stash menu, so all of them are fixed.
Testing
$skills menu, then toggled the right panel and the terminal drawer, with and without the patch — numbers above.vp lintandtypecheckon the touched scope.Surfaces
ComposerCommandPopoverwith React Native layout and is unaffected; desktop wraps web and inherits the fix./,@,$, stash) share this layer.🤖 Generated with Claude Code
Note
Low Risk
Localized UI positioning fix in ChatComposer with no auth, data, or API changes.
Overview
Fixes composer command menus (
/,@,$, stash) drifting away from the composer when the right panel or terminal drawer opens.The portaled
ComposerCommandMenuLayeronly watched the anchor for resize; on wide layouts the composer slides when a side panel opens without changing size, so the menu never repositioned. The layer now attaches ResizeObserver to the anchor’s ancestor chain so layout shrinks during panel animation trigger updates.Position updates are deduplicated via a
ComposerCommandMenuPositiontype and equality check beforesetState, so extra observer callbacks don’t re-render on no-op geometry.Reviewed by Cursor Bugbot for commit 4f68017. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix composer command menu position to track ancestor element resizes
The
ComposerCommandMenuLayerin ChatComposer.tsx was only observing the anchor element for resize events, causing the menu to drift when parent containers resized.ResizeObserverto observe the anchor and all its DOM ancestors, so position updates trigger on any ancestor resize.composerCommandMenuPositionsEqualto skip redundant state updates when the computed position is unchanged.Macroscope summarized 4f68017.