Skip to content

refactor(studio): use the Tabs and Toggle primitives in two hand-rolled controls - #2334

Merged
peppescg merged 4 commits into
mainfrom
refactor/studio-primitives-disclosure-tabs-2201
Oct 16, 2026
Merged

peppescg merged 4 commits into
mainfrom
refactor/studio-primitives-disclosure-tabs-2201

Conversation

@peppescg

@peppescg peppescg commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • Session activity panel: the hand-rolled role="tablist" → Tabs, and the aria-pressed roster rows → Toggle.
  • Tool panel: the Raw/Diff aria-pressed ghost 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.tsx keeps 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 an h3 and a labelled region per suggested change. The plan for that follow-up is to keep find-in-page working by rendering the collapsed content with hidden="until-found", since Collapsible unmounts closed content the same way Accordion does.

What changed

  • components/ui/toggle.tsx: a new ghost variant modelled on the ghost Button: 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 the default and outline variants, so they render as before (toggle.test.tsx pins 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 ghost Button already had (mb-1 h-6 px-2 text-xs text-muted-foreground hover:text-foreground), plus min-w-auto in place of the Toggle's square minimum width.
  • features/chat/delegation-panel.tsx: Tabs/TabsList/TabsTrigger/TabsContent replace 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. RosterButton is a Toggle with overrides that keep the row's ink, hover and chosen fill. A plain Toggle, not a single-choice ToggleGroup: Radix renders that as a radiogroup of radios with roving focus, which would change the rows' roles and the Tab order.

Behavior differences

Kept deliberately, as before:

  • A click on the selected family tab still clears the chosen activity. Tabs only reports changes, so the trigger keeps an onClick.
  • Tab still goes from the selected tab to the roster's first row. Radix makes a tab panel a tab stop (tabIndex=0) and shadcn styles it without an outline, which would add an invisible stop; the panel opts out.
  • Pressing the chosen roster row keeps it chosen.

From Radix Tabs' standard behaviour:

  • Page Up and Page Down jump to the first and last family. An arrow key with Alt, Ctrl, Meta or Shift is left to the browser (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. Inactive tabs' aria-controls point at unmounted panels, the standard Radix pattern (axe exempts aria-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

  • Pins first (first commit, passing on unchanged main code, 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 and aria-pressed, no switch without a diff.
    • Real browser: a new arrow/Home/End/Tab journey in e2e/session-activity.spec.ts, at desktop and 390px.
  • Radix-behaviour tests removed. The earlier revision added tests for 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.
  • Existing .click()-driven tab tests in delegation-panel.test.tsx and delegation-workspace.test.tsx pass unmodified.
  • Mutation proof (each applied alone, focused tests rerun, all caught):
Broken change Caught by
Tabs without onValueChange 1 test (arrow/Home/End pin)
Tabs trigger without its click handler 2 tests (selected-tab-click pin plus an existing test)
Panel keeps Radix's own tab stop 1 test (Tab pin)
Tablist loses its name 1 test
Roster Toggle not bound to the chosen row 4 tests
Roster Toggle chooses only when turning on 1 test (re-press pin)
Raw Toggle can't switch / ignores its pressed state 2 / 2 tests
Ghost variant gets the pressed fill back 1 test (toggle.test.tsx)
Ghost variant loses its focus ring 1 test
Ghost variant falls back to rounded-md 1 test
Default variant loses its pressed fill 1 test
  • Pixels. Each tree was captured twice (Before: main's three source files; After: this head). Activity panel and tool panel, desktop and 390px, light and dark: Before = After in every shot and state, including the Raw/Diff toggle unpressed, pressed, hovered and keyboard-focused. The only differing pixels (126 to 175 px, at most) are the composer's "Send a message…" placeholder, which flickers between two captures of the same tree.
  • Phone icon sizes. Studio's 20px phone glyph rule matches [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 carry size-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 on 2ad7d9409:

  • 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

@kantord kantord left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. A heading and a landmark per suggested change. AccordionTrigger wraps the button in an h3, and the content is a labelled region. A list of N suggested changes gets N identical "Show current values" headings and N identical regions. <details> had neither. The PR body notes the h3 but treats it as an accepted difference.
  2. It contradicts the stack's own reasoning. #2359 keeps tool-call-list.tsx on its hand-rolled disclosure because "Accordion doesn't fit: its trigger is wrapped in an h3, which would add a heading for every tool group", and plans to move it to Collapsible once #2352 merges. The Memory list repeats the same shape per li.

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). Collapsible unmounts 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 ghost Button it replaced. A ghost variant on Toggle would 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.

peppescg and others added 4 commits October 15, 2026 17:43
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]>
peppescg added a commit that referenced this pull request Oct 15, 2026
…ctivity at 390px)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@peppescg
peppescg force-pushed the refactor/studio-primitives-disclosure-tabs-2201 branch from f4d280e to acfbf33 Compare October 15, 2026 15:59
@peppescg peppescg changed the title refactor(studio): use the Accordion, Tabs and Toggle primitives in three hand-rolled controls refactor(studio): use the Tabs and Toggle primitives in two hand-rolled controls Oct 15, 2026
@peppescg
peppescg requested a review from kantord October 15, 2026 16:45
@peppescg

Copy link
Copy Markdown
Contributor Author

Thanks, all agreed. I've dropped the Memory change from this PR: consolidate-memory-card.tsx is back to main's <details>, and it will move to Collapsible in a follow-up stacked on #2352, using hidden="until-found" on the content so find-in-page keeps working. I've removed the tests that asserted Radix behaviour (data-state, Page Up/Down, modified arrows); the pinning tests and e2e journeys stay. Toggle now has a ghost variant modelled on the ghost Button, and the Raw/Diff switch uses it with just the size and colour overrides the Button already had. The screenshots are pixel-identical to main in every state, at desktop and 390px. I've left the Raw/Diff label alone for now, since that predates the PR. History is rewritten, rebased on main, and CI is green.

peppescg added a commit that referenced this pull request Oct 15, 2026
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 kantord left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the Collapsible move (and hidden="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 ghost variant on Toggle instead 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.

@peppescg
peppescg merged commit 8d48608 into main Oct 16, 2026
31 checks passed
@peppescg
peppescg deleted the refactor/studio-primitives-disclosure-tabs-2201 branch October 16, 2026 08:36
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 20, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants