Repository navigation
refactor(studio): use the Toggle primitive in the chat composer area - #2362
Merged
Merged
Conversation
Pins the composer's and the side thread's dictation buttons and the phone sheet's Mode rows, Model rows and Effort pills before they move to the Toggle primitive: names, aria-pressed, click, Enter and Space, picking the current choice again, and one Tab stop per choice. Refs #2336 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…essed controls The composer's and the side thread's dictation buttons, and the phone sheet's Mode rows, Model rows and Effort pills, become Toggles. Each choice stays its own Toggle rather than a single-choice ToggleGroup, which would turn them into radios with roving focus. Class overrides keep the previous look; names, pressed state and keyboard use are unchanged. Closes #2336 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
kantord
approved these changes
Oct 16, 2026
kantord
left a comment
Member
There was a problem hiding this comment.
Thanks for this, and for documenting why these are separate Toggles rather than a single-choice ToggleGroup (that would have changed roles and Tab order). I traced the class merging and the handlers: onPressedChange={voice.toggle} is safe because toggle takes no arguments, and pressing the already-pressed pill or row still re-selects it. Approving, with a few non-blocking nits:
- The rows and pills need long override strings (
toggleRowClass,effortPillClass, the model rows) to undo the Toggle's defaults, and the dictation class is duplicated between the composer and the side thread. #2334 solved the same smell with aghostvariant, so a variant (or a shared constant for the dictation class) may be worth a follow-up. - Each mic icon gets
size-4by hand because a Toggle isn't a Button, so the phone glyph rule doesn't cover it. That is the same class of problem #2368 fixes for Buttons, one primitive over. - In
model-effort-menu.tsx, the comment says hovering the chosen row keeps the zinc fill in dark "as before". As far as I can tell,dark:data-[state=on]:hover:bg-zinc-800is new and the dark pressed-hover fill changes frommuted/50to zinc-800. I'm only moderately sure of the specificity, so please double-check the comment and the screenshot.
Fully or partially written by an AI agent.
Merged
2 tasks
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
Group A of #2201 covers the chat composer area:
chat-composer.tsx,composer-options-sheet.tsx,model-effort-menu.tsxandside-thread-panel.tsxunderapps/web/src/features/chat/. The six hand-rolledaria-pressedcontrols in these files now use the Toggle primitive. The #2340 and #2337 call sites inchat-composer.tsxwere reviewed. All of them are kept, for the reasons in the decision table.Names, roles, pressed state, keyboard use and pixels are unchanged in every captured state. Computed colours are also unchanged in every captured state: rest, hover and keyboard focus, in light and dark.
Closes #2336
Part of #2340
Part of #2337
Part of #2201
Part of #2210
The Execution picker's native
<select>(on hold, #2326/#2335), Canvas and everytitle=attribute are untouched. Draft #2099 also editschat-composer.tsxandmodel-effort-menu.tsx, in different areas.What changed
chat-composer.tsx(Studio: replace the remaining hand-rolled toggles with the Toggle primitive #2336). The dictation button is aToggle.pressedfollowsvoice.isListening, andonPressedChangecallsvoice.toggle.buttonVariants({ variant: "ghost", size: "icon" })and keeps the ghost button's look. The brand tint while listening moves from a conditional class todata-[state=on]:classes.Micicon now carriessize-4. Studio's phone rule that draws glyphs at 20px coverssize-4icons and Button's bare icons, but not a Toggle's (data-slot="toggle").side-thread-panel.tsx(Studio: replace the remaining hand-rolled toggles with the Toggle primitive #2336). The thread's dictation button gets the same change.MicandMicOffcarrysize-4for the same reason.composer-options-sheet.tsx(Studio: replace the remaining hand-rolled toggles with the Toggle primitive #2336).OptionView) are oneToggleeach.Toggleeach.toggleRowClassandeffortPillClass, undo the Toggle's own height, minimum width, shape, weight, ink, hover fill and pressed fill. The rows and pills therefore keep their previous look.model-effort-menu.tsx(Studio: replace the remaining hand-rolled toggles with the Toggle primitive #2336). In the phone sheet's model list (ModelSheetSection), the Default row and each model row are oneToggleeach.data-[state=on]:.Decision table
Line numbers are on
main(550c67fee). For #2340, #2352 listed the same three sites at L720, L725 and L950 on its own base.apps/web/src/features/chat/)chat-composer.tsx:793aria-pressedside-thread-panel.tsx:368aria-pressedcomposer-options-sheet.tsx:221aria-pressedToggleGroup type="single": Radix renders that as aradiogroupofradios with roving focus. That would replacearia-pressedwitharia-checked, collapse the six Tab stops into one, and add arrow-key movement inside a sheet that closes on each pick. This follows #2334's roster rows.composer-options-sheet.tsx:297aria-pressedmodel-effort-menu.tsx:291aria-pressedmodel-effort-menu.tsx:315aria-pressedchat-composer.tsx:735role="alert", attachment errorchat-composer.tsx:740role="alert", dictation errorchat-composer.tsx:965<label><select>, which is on hold (#2326/#2335). The picker may be redesigned or removed, so its label moves with it.aria-expandeddisclosurescomponents/ui/collapsible.tsxonly exists in the still-open #2352.)chat-composer.tsx:655animate-pulseAfter this PR, no hand-rolled
aria-pressedremains in the four files.delegation-panel.tsxandcontent-preview-panel.tsxare covered by #2334.Behaviour differences
data-state="on|off"to each Toggle, anddata-disabledwhen it is disabled. Everything else stays the same: element (button,type="button"), role, name,aria-pressed, Tab order, and Enter and Space handling.disabled:pointer-events-none. Before, a native disabledbuttonstill matched:hoverand showed a faded hover fill. The dictation buttons already had this through Button.onPressedChangeruns on every press, whatever the new pressed value.justify-content,align-itemsandgap(inline-flex instead of a native button's centring). Theirtransition-propertyisnoneinstead ofallwith a duration of 0. Both render the same pixels.No regression
Pins first (
ef4574648):composer-toggles.pinning.test.tsx(16 tests). They pass onmain's code and unchanged on the head. They cover:aria-pressedand "Listening" by click, Enter and Space. Focus is kept, and the button is disabled while busy.buttonwith noroleoraria-checked, and its own Tab stop.No existing test was modified. The existing
aria-pressedassertion inchat-composer.alignment.test.tsxpasses unchanged.Mutation proof. Each mutation was applied alone and the pins rerun:
onPressedChangepressedinvertedonPressedChangepressedinvertedToggleGroupPixels. Each tree was captured twice. Before = After in every shot and state, within the noise seen between two captures of the same tree (at most 34 px, outside the controls).
Computed styles. The two trees were also probed in Chromium for every converted control, pressed and unpressed, at rest, under the mouse and with keyboard focus, in light and dark. The phone sheet was probed at 390px with a mouse so hover applies. Colours, borders, radii, sizes, padding, font, outline and ring match. The only differences are the layout properties listed under Behaviour differences.
Two mismatches were found and fixed this way before the head commit: the 16px vs 20px phone glyph, and the chosen model row's light-mode hover fill.
Screenshots
Before (
550c67fee,main) | After (03b14d115) | Prototype (stack-08). Amber boxes mark the converted controls. A red box would mark a Before/After pixel difference; there are none. The sheet views are phone-only (min-[500px]:hidden), so they have no desktop shots.Composer, dictation on (pressed), desktop light (zoomed). The prototype has the same tinted pressed mic. Its label reads "Stop listening" where Studio's reads "Stop dictation", which this PR doesn't change.
Phone sheet, Model view with GPT-5 and High chosen, light. The rows and pills match the prototype's structure. The prototype's star buttons and model list come from its own fixtures.
Composer: dictation off and on, desktop and 390px, light and dark
composer-off-desktop-lightcomposer-on-desktop-lightcomposer-off-mobile-lightcomposer-on-mobile-lightcomposer-off-desktop-darkcomposer-on-desktop-darkcomposer-off-mobile-darkcomposer-on-mobile-darkcomposer-off-desktop-light-zoomcomposer-on-desktop-light-zoomcomposer-off-desktop-dark-zoomcomposer-on-desktop-dark-zoomPhone sheet: Mode view (Manual chosen) and Model view, light and dark
sheet-mode-mobile-lightsheet-mode-mobile-darksheet-model-mobile-lightsheet-model-mobile-darkSide thread: dictation off and on, desktop and 390px, light and dark (the prototype column is its unpressed thread composer)
thread-off-desktop-lightthread-on-desktop-lightthread-off-mobile-lightthread-on-mobile-lightthread-off-desktop-darkthread-on-desktop-darkthread-off-mobile-darkthread-on-mobile-darkthread-off-desktop-light-zoomthread-on-desktop-light-zoomthread-off-desktop-dark-zoomthread-on-desktop-dark-zoomIn the side thread shots, the thread body reads "Loading thread..." in both trees because of the offline fixture. Only the composer row is under test there.
Gates
Both run on the head through the shared gate lock.
task studio:check: passes.task studio:browser: passes, 136 passed and 38 skipped, unchanged from base (no browser journey was added or changed).🤖 Generated with Claude Code