Repository navigation
refactor(studio): use the Tabs and Toggle primitives in two hand-rolled controls - #2334
Conversation
kantord
left a comment
There was a problem hiding this comment.
Requesting one change: the Memory disclosure should use Collapsible, not Accordion. The Tabs and Toggle conversions in delegation-panel.tsx and content-preview-panel.tsx look sound, and the pinning tests plus e2e journeys are good.
Requested change: consolidate-memory-card.tsx
The "Show current values" disclosure is a single, hard-coded item (type="single" collapsible, value="current-values"). That is a disclosure, not an accordion, and it has two costs here:
- A heading and a landmark per suggested change.
AccordionTriggerwraps the button in anh3, and the content is a labelledregion. A list of N suggested changes gets N identical "Show current values" headings and N identical regions.<details>had neither. The PR body notes theh3but treats it as an accepted difference. - It contradicts the stack's own reasoning. #2359 keeps
tool-call-list.tsxon its hand-rolled disclosure because "Accordion doesn't fit: its trigger is wrapped in anh3, which would add a heading for every tool group", and plans to move it toCollapsibleonce #2352 merges. The Memory list repeats the same shape perli.
Collapsible (added in #2352) gives the same open/close state, the same aria-expanded, and no heading, region, extra chevron or padding to override. Suggested path: either rebase this PR's Memory part onto #2352 and use Collapsible, or drop the Memory change from this PR and let it follow #2352. The Tabs and Toggle changes don't depend on it and could merge as they are.
Not blocking, for your call
- Find-in-page. Collapsed values are no longer reachable by browser find, because Radix unmounts closed content (the PR discloses this).
Collapsibleunmounts the same way, so this does not go away. If it matters,hidden="until-found"on the content is the usual remedy. - Tests that assert Radix, not Studio. The new tests for
data-state, PageUp/PageDown and ignored modified arrows cover Radix's own behaviour and will fail on a Radix upgrade without telling us anything about Studio. The pinning tests and e2e journeys are the valuable ones. - Raw/Diff
Toggle. About ten class overrides reproduce the ghostButtonit replaced. A ghost variant onTogglewould be cleaner than the override string. - Raw/Diff label. The label flips between "Raw" and "Diff" while the control also reports
aria-pressed, so it reads as "Diff, pressed". This predates the PR, as the description notes.
Fully or partially written by an AI agent.
Before these hand-rolled controls move to the shadcn Tabs and Toggle primitives, pin what they do today against roles, names and ARIA state, so the same tests hold on both implementations: - the "Activity families" tablist names its tabs, the selected tab labels and controls the one panel, a click or the arrow, Home and End keys choose a family and clear the chosen activity (a click on the selected tab clears it too), and Tab enters on the selected tab and leaves for the panel's first row, in happy-dom and in a real browser; - a roster row is pressed while its activity is chosen, pressing it again keeps it chosen, and Enter and Space choose it; - the tool panel's Raw switch shows the formatted arguments, is pressed and named Diff while they show, and switches back, by pointer or key. Refs #2201 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…bs and Toggle The session activity panel hand-rolled its "Activity families" tablist (role, roving tabindex, and arrow/Home/End handling) and pressed roster rows (aria-pressed on a plain button). They now use the shadcn Tabs and Toggle primitives, with class overrides that keep today's look: the three-column tab grid, the 12px labels with their counts, and the rows' ink, hover, and chosen fill. Behavior that stays as it was: - the tablist, tab, panel and row names, and aria-selected/aria-pressed; - a click on the selected tab clears the chosen activity (the trigger keeps a click handler, since Tabs only reports changes); - Tab goes from the selected tab to the roster's first row: the one panel opts out of the tab stop Radix gives a tab panel, which shadcn styles without an outline; - pressing the chosen row keeps it chosen (a Toggle, not a single-choice ToggleGroup, which would make the rows radios with roving focus). Behavior that now follows Radix Tabs: - Page Up and Page Down jump to the first and last family; - an arrow key pressed with Alt, Ctrl, Meta or Shift is left to the browser, so Alt+Left goes back instead of switching families; - Home on the first family, or End on the last, does nothing when that family is already selected, where it used to clear the chosen activity. Refs #2201 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A Toggle that should look like the ghost Button had to rebuild it with class overrides: the pill shape, the accent hover, the offset focus ring, and no fill while pressed. The new ghost variant carries that look, for a toggle whose label already names the view it switches to. The pressed fill moves from the base classes to the default and outline variants, which render as before. Refs #2201 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The tool panel's Raw/Diff switch was a ghost Button with a hand-set
aria-pressed. It is now the Toggle primitive's ghost variant, which keeps
the ghost button's look: the pill shape, the accent hover, the offset
focus ring, and no fill while pressed, since the label already names the
view it switches to ("Raw", then "Diff"). The call site keeps the size and
colour overrides the Button had, plus min-w-auto in place of the Toggle's
square minimum width.
The name, the pressed state, Enter and Space, and the diff and raw views
are unchanged.
Refs #2201
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ctivity at 390px) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
f4d280e to
acfbf33
Compare
|
Thanks, all agreed. I've dropped the Memory change from this PR: |
Each suggested change's "Show current values" `<details>` becomes a Collapsible, as kantord asked on #2334: one disclosure, so no Accordion heading or region per change. The closed values stay in the page, hidden until found, so find-in-page still reaches them and opens the change. The trigger draws the same disclosure triangle `<summary>` drew, from an empty inside list item, so the text, the marker and the spacing are unchanged. The card test named the `<details>` element; it now reads the content the trigger controls, with the same four assertions. Refs #2340 Refs #2201 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
kantord
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround, and for splitting the Memory change out rather than forcing it through. The changes resolve my requests:
- The Memory disclosure is back to
<details>here, with theCollapsiblemove (andhidden="until-found") planned as a follow-up on top of #2352. - The tests that asserted Radix behaviour are gone, and the pinning tests and e2e journeys remain.
- The Raw/Diff switch now uses a proper
ghostvariant onToggleinstead of a long override string.
Approving. The Raw/Diff label flipping while the control reports aria-pressed is left for later, as agreed.
Fully or partially written by an AI agent.
Summary
An independent slice of #2201: two hand-rolled Studio controls now use the existing shadcn primitives in
apps/web/src/components/ui/, and the Toggle primitive gains a ghost variant.role="tablist"→ Tabs, and thearia-pressedroster rows → Toggle.aria-pressedghost button → Toggle, using the new ghost variant.Names, roles, ARIA state, keyboard use and visuals stay as they were, except where Radix Tabs' standard behaviour differs (listed below). Canvas and Execution are untouched, as agreed.
Scope change after review. This PR no longer touches Memory. The "Show current values" disclosure in
consolidate-memory-card.tsxkeeps main's<details>here and moves to Collapsible in a follow-up once #2352 (which adds Collapsible) merges. A single hard-coded item is a disclosure, not an accordion, and the Accordion would have added anh3and a labelledregionper suggested change. The plan for that follow-up is to keep find-in-page working by rendering the collapsed content withhidden="until-found", since Collapsible unmounts closed content the same way Accordion does.What changed
components/ui/toggle.tsx: a newghostvariant modelled on the ghostButton: pill shape, accent hover, the offset focus ring, and no fill while pressed, for a toggle whose label already names the view it switches to. The pressed fill moves from the base classes to thedefaultandoutlinevariants, so they render as before (toggle.test.tsxpins both).features/chat/content-preview-panel.tsx: the Raw/Diff switch is<Toggle variant="ghost">. The ten-odd override classes are gone; the call site keeps only the size and colour overrides the ghostButtonalready had (mb-1 h-6 px-2 text-xs text-muted-foreground hover:text-foreground), plusmin-w-autoin place of the Toggle's square minimum width.features/chat/delegation-panel.tsx:Tabs/TabsList/TabsTrigger/TabsContentreplace the hand-rolled tablist, roving tabindex and arrow/Home/End handler (about 30 lines of key and focus code removed). Class overrides keep the three-column grid and 12px labels with counts.RosterButtonis aTogglewith overrides that keep the row's ink, hover and chosen fill. A plain Toggle, not a single-choice ToggleGroup: Radix renders that as aradiogroupofradios with roving focus, which would change the rows' roles and the Tab order.Behavior differences
Kept deliberately, as before:
onClick.tabIndex=0) and shadcn styles it without an outline, which would add an invisible stop; the panel opts out.From Radix Tabs' standard behaviour:
aria-controlspoint at unmounted panels, the standard Radix pattern (axe exemptsaria-selected="false").Unchanged and out of scope: the Raw switch's label still flips between "Raw" and "Diff" while also reporting
aria-pressed, as before this PR and as in the prototype.No regression
maincode, then unchanged on the swap):delegation-panel.pinning.test.tsx(11): tablist/tab/panel names, the selected tab labels and controls the panel, click and arrow/Home/End selection with focus and wrap, clearing the chosen activity (including a click on the selected tab), Tab in and out, roster rows'aria-pressed, re-press, Enter and Space.content-preview-panel.pinning.test.tsx(4): Raw/Diff by click and Enter/Space, name andaria-pressed, no switch without a diff.e2e/session-activity.spec.ts, at desktop and 390px.data-state, Page Up/Page Down and ignored modified arrow keys. They asserted Radix's own behaviour rather than Studio's, so a Radix upgrade could break them without telling us anything about Studio. The pins and the e2e journey above cover what Studio relies on..click()-driven tab tests indelegation-panel.test.tsxanddelegation-workspace.test.tsxpass unmodified.onValueChangetoggle.test.tsx)rounded-md[data-slot="button"] svg.lucide, which doesn't cover the Toggle. Measured in Chromium at 390px, Before and After are equal: roster glyphs render at 18×18 (they carrysize-3.5, which the phone rule maps to 18px whatever the parent), and the Raw/Diff toggle holds no icon (40.9×27 pressed, 45.5×27 unpressed). At desktop the glyphs are 14×14 in both. No size change, so no fix is needed.Screenshots
Before (
2ad7d9409, main) | After (acfbf3382) | Prototype (stack-08). Red boxes mark Before/After pixel differences.Raw/Diff toggle, 3× detail: unpressed, pressed, hover, keyboard focus. Pixel-identical.
Tool panel, Raw pressed, desktop light. Identical to Before; matches the prototype's ghost switch.
Tool panel, 390px, unpressed and pressed (light).
Session activity, team member chosen, 390px light. Identical to Before, roster glyphs included. The prototype has a different panel (Agents with Back navigation); this PR keeps Studio's layout.
Tool panel: every theme, viewport and state
Session activity: dark, 390px, keyboard focus, subagent and team member chosen
The red box in the two dark desktop shots is the composer placeholder flicker described above.
Gates
On
acfbf3382, rebased on2ad7d9409:task studio:check: pass (web 1603 tests in 183 files, server 252).task studio:browser: pass (138 passed, 38 skipped as on main).Part of #2201
Part of #2210
🤖 Generated with Claude Code