Skip to content

fix(site/src/pages/AgentsPage): add click alternatives to dragging in the agents sidebar - #32670

Merged
chrifro merged 6 commits into
mainfrom
a11y/dragging-no-alternative
Nov 24, 2026
Merged

chrifro merged 6 commits into
mainfrom
a11y/dragging-no-alternative

Conversation

@bartekgatzcoder

@bartekgatzcoder bartekgatzcoder commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

The agents sidebar had two interactions that needed a drag, with no single-pointer alternative (WCAG 2.5.7 Dragging Movements). This PR adds one for each and leaves the drags as they are:

  • Resizing the sidebar. Right-clicking (or long-pressing) the resize handle opens a "Sidebar width" menu with Decrease width, Increase width (64px steps), and Reset width. A step is disabled when the width is already at that limit. Widths use the same clamp-and-persist path as dragging and the keyboard arrows.
  • Reordering pinned chats. A pinned chat's actions menu (the "…" button and the right-click menu) now has Move up and Move down. The first pin has no Move up and the last pin has no Move down. Both items call the existing reorderPinnedChat mutation through the handler the drop path now shares, so the optimistic order and the error toast behave the same as for a drag. The items are hidden while filters disable reordering, as dragging already is.

Closes DEQ-147

Ticket UI surface Screenshots
DEQ-147 (element 1) ResizableChatsSidebarFrame: resize separator of the agents sidebar before/after
DEQ-147 (element 2) ChatActionsMenuItems / SortableChatTreeNode: Pinned section of the agents sidebar before/after

Open UX question (the ticket is labeled ux-input-needed). The resize menu works and meets 2.5.7, but nothing on screen tells users it exists: it only opens with a right-click or long-press on a 4px handle. If design would rather have a visible control, for example width presets in a sidebar menu, that can replace this menu.

Tests: Vitest covers Move up and Move down sending the right pin_order, and each resize menu item persisting the new width. New ReorderPinMenu and ResizableSidebarContextMenu stories capture the open menus, including Decrease width disabled at the minimum width.

Dropped review findings

  • DF2 (nit): add a mutation scope to reorderPinnedChat so overlapping reorders run in order. Dropped because the menu closes after each move, and fast keyboard drags already send absolute orders through the same unscoped mutation. It is a separate change to shared query code.
Grouping and decision log
  • Prior work: checked before starting. DEQ-147 had no PRs, comments, or attachments, and had stayed in Open since it was created. Tracy's open sidebar PRs (feat(site/src/pages/AgentsPage/components/ChatsSidebar): make Pinned a top-level sidebar section #31064 moves the Pinned section, fix(site/src/pages): scroll the whole sidebar tab into view on focus #31394 fixes focus scroll) do not touch either drag. Moving chats into projects already has a menu alternative (feat(site/src): move chats between projects from the chat menu #30895), so it is out of scope.
  • Grouping: one PR. Both elements are the same rule on the same sidebar, and the change is about 125 non-test lines, well under the 300-line gate. Shipping them together lets the ticket close in one PR.
  • Pin reorder alternative: menu items rather than visible up/down buttons. The row already has an actions menu, so this adds no UI to every row, and it follows the "Move to project" alternative used for the project drag.
  • Resize alternative: options were (a) a plain click on the handle that steps or toggles the width, (b) a context menu on the handle, (c) handing the ticket to design, and (d) a width setting. (a) has no direction and conflicts with drag detection, and (d) is a new preference surface, which is a product decision. (b) uses the shared ContextMenu primitive and adds no permanent UI, so I chose it and raised discoverability above as the open UX question.
  • Step size: 64px, so the menu covers the 240px to 660px range in a few clicks. The 16px keyboard step would take about 26.
  • Accessibility audit (axe 4.11 in Storybook, open-menu states): no violations introduced. These are already present on main and appear on both base and branch: color-contrast on the faded relative timestamp in chat rows, and aria-hidden-focus on #storybook-root whenever any Radix context menu is open, including the existing chat-row context menu.
  • Touch and pen (round 2): pointerdown calls preventDefault only for mouse. Calling it for touch and pen cancelled Radix's long-press timer, and the handle is already touch-none. Opening the menu ends any drag in progress, so a press that is held and then moved does not keep resizing under the menu.
  • Review nits (round 2): moved the menu step to sidebarWidth.ts (LEFT_SIDEBAR_MENU_RESIZE_STEP), restored the prop docs on ChatTreeNode, and switched the story wait to screen.findByRole. I kept different conventions at the limits on purpose. The width menu always has the same three items, so a disabled step tells the user it has reached a limit. The pin menu hides Move up and Move down, the same way it already hides Pin or Unpin when they don't apply.

🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.

@linear-code

linear-code Bot commented Nov 24, 2026

Copy link
Copy Markdown

DEQ-147

@bartekgatzcoder
bartekgatzcoder marked this pull request as ready for review November 24, 2026 13:09
@bartekgatzcoder
bartekgatzcoder requested a review from a team as a code owner November 24, 2026 13:09

@chrifro chrifro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Round 1. The pin reorder alternative is solid: Move up and Move down share movePinnedChat with the drop path, child rows and filtered views get no items, and the Vitest coverage hits the mutation. One should-fix on the resize alternative, inline below.

[should-fix] On touch and pen, long-press never opens the "Sidebar width" menu, though the PR body says it does. Details and a fix are inline on ResizableChatsSidebarFrame.tsx:135.

Nits (optional):

  • ResizableChatsSidebarFrame.tsx:20: MENU_RESIZE_STEP could live in sidebarWidth.ts next to LEFT_SIDEBAR_KEYBOARD_RESIZE_STEP and be exported, so ResizableChatsSidebarFrame.test.tsx:101-102 uses it instead of a hardcoded 64.
  • At the limits, the width menu disables its items but the pin menu hides them. Either is fine; one convention reads better.
  • ChatTreeNode.tsx:51-52: the new props lack the "When omitted, the item is hidden" doc that ChatActionsMenuItems has.
  • AgentsPageLayout.stories.tsx:768: if the wait is needed for the portaled menu, screen.findByRole("menuitem", { name: "Reset width" }) reads better than within(document.body).findByText.

Follow-up filed (pre-existing, not blocking): DEQ-652: the resize handle is a 4px pointer target (2.5.8).

🤖 Generated by Coder Agents on behalf of @chrifro.

/>
{/* The menu is the single-pointer alternative to dragging (WCAG 2.5.7). */}
<ContextMenu>
<ContextMenuTrigger asChild>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[should-fix] Long-press can't open this menu on touch or pen. ContextMenuTrigger asChild composes its onPointerDown after the child's, and Radix's composeEventHandlers skips its long-press timer when event.defaultPrevented is set. handlePointerDown (line 65) calls e.preventDefault() for every primary button-0 pointer, which includes touch and pen. So the menu opens only with a right-click, and on a tablet at sm+ width there is still no single-pointer alternative to the drag (2.5.7). The PR body's "or long-press" claim is also wrong.

I checked this locally with a throwaway Vitest probe: a touch or pen pointerDown plus 1s of fake timers leaves the menu closed. With isPrimary: false, which skips the drag handler, the same press opens it.

Suggested fix: call e.preventDefault() only for e.pointerType === "mouse". The handle is already touch-none, so touch needs no preventDefault, and Radix clears the long-press timer on pointermove, so a real drag won't pop the menu. Please add a Vitest case for touch long-press, and drop the long-press claim if you go another way.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 48b26b1 and 22e8afb. handlePointerDown now calls preventDefault only when pointerType === "mouse", so Radix starts its long-press timer for touch and pen. I added a touch and pen Vitest case: it long-presses, picks Increase width, and checks the saved width. It fails with the old preventDefault.

The second commit covers an edge case: a finger that rests for 700ms and then moves would open the menu while still resizing under it. The ContextMenu's onOpenChange(true) now ends the drag. The same test moves the pointer after the menu opens and fails without that guard.

🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.

@chrifro
chrifro marked this pull request as draft November 24, 2026 13:24
@bartekgatzcoder
bartekgatzcoder marked this pull request as ready for review November 24, 2026 14:02
@bartekgatzcoder

Copy link
Copy Markdown
Collaborator Author

@chrifro could you take another look? Round 2 is up at 22e8afb and CI is green.

  • should-fix (touch and pen long-press): fixed. Only mouse presses call preventDefault now, and opening the width menu ends any drag in progress. A new touch and pen Vitest case covers both. Details are in the inline thread.
  • Nits: I moved the step to sidebarWidth.ts, restored the ChatTreeNode prop docs, and switched the story to screen.findByRole. I left disabled vs. hidden as it is, with the reason in the PR body.

🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.

@chrifro chrifro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Round 2 at 22e8afb fixes the touch/pen long-press: preventDefault now runs only for mouse, and opening the menu ends the drag. I verified both in Storybook (mouse right-click and left-drag, a touch long-press that opens the width menu, and a touch drag that resizes without it), along with Move up and Move down in the pinned chat menu. The 188 ChatsSidebar Vitest tests pass, and frontend-review and frontend-deep-review found nothing blocking or should-fix. Nit: LEFT_SIDEBAR_MENU_RESIZE_STEP in sidebarWidth.ts uses a // comment, not JSDoc, which matches the file. Follow-ups: none new (DEQ-652 already covers the 4px target).

🤖 Generated by Coder Agents on behalf of @chrifro.

@chrifro
chrifro merged commit 9a01095 into main Nov 24, 2026
37 checks passed
@chrifro
chrifro deleted the a11y/dragging-no-alternative branch November 24, 2026 15:16
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 24, 2026

This branch had an error being deployed

1 failed deployment
docs-preview — 22e8afb6 Deployed Nov 24, 2026 by chrifro via cleanup #419
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants