The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): pin that Space on a row control never arms a sidebar reorder drag
kshitijk4poor5d59a43593e7
diff --git a/apps/desktop/src/app/chat/sidebar/session-row.test.tsx b/apps/desktop/src/app/chat/sidebar/session-row.test.tsxindex 932a8070c91..2fe55edeb08 100644--- a/apps/desktop/src/app/chat/sidebar/session-row.test.tsx+++ b/apps/desktop/src/app/chat/sidebar/session-row.test.tsx@@ -1,3 +1,5 @@+import { KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core'+import { sortableKeyboardCoordinates } from '@dnd-kit/sortable'import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'import { atom } from 'nanostores'import type * as React from 'react'@@ -13,6 +15,7 @@ import { clearAllSessionStates, publishSessionState } from '@/store/session-statimport type * as SessionStatesStore from '@/store/session-states'import type * as WindowsStore from '@/store/windows'+import { ReorderableList, useSortableBindings } from './reorderable-list'import { SidebarSessionRow } from './session-row'afterEach(cleanup)@@ -439,3 +442,67 @@ describe('Inbox-style session card', () => {expect(screen.getByText('133 messages')).toBeTruthy()})})++// Regression for #83617: the row shell once spread the FULL dnd-kit handle, so+// Space on a focused control inside the row (the ⋯ button that opens Rename)+// reached the KeyboardSensor's activator — a drag armed, and the sensor then+// ate the next Space at window level (the rename input dropped the keystroke).+describe('SidebarSessionRow inside the sortable list', () => {+ function SortableRow({ session }: { session: SessionInfo }) {+ const { dragHandleProps, dragging, ref, reorderable, style } = useSortableBindings(session.id)++ return (+ <SidebarSessionRow+ dragging={dragging}+ dragHandleProps={dragHandleProps}+ isPinned={false}+ isSelected={false}+ onArchive={noop}+ onDelete={noop}+ onPin={noop}+ onResume={noop}+ onToggleUnread={noop}+ ref={ref}+ reorderable={reorderable}+ session={session}+ style={style}+ unread={false}+ />+ )+ }++ function Host({ session }: { session: SessionInfo }) {+ // The sidebar's own sensor set (index.tsx dndSensors).+ const sensors = useSensors(+ useSensor(PointerSensor, { activationConstraint: { distance: 6 } }),+ useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates })+ )++ return (+ <ReorderableList ids={[session.id]} onReorder={noop} sensors={sensors}>+ <SortableRow session={session} />+ </ReorderableList>+ )+ }++ const space = { code: 'Space', key: ' ' }++ it('lets Space through to a focused row control instead of arming a keyboard drag', () => {+ const { container } = render(<Host session={makeSession({ title: 'Renamable' })} />)+ const kebab = screen.getByRole('button', { name: 'Session actions' })+ kebab.focus()++ // Not defaultPrevented: dnd-kit's activator never saw it.+ expect(fireEvent.keyDown(kebab, space)).toBe(true)+ expect(container.querySelector('[aria-pressed="true"]')).toBeNull()+ })++ it('still starts a keyboard reorder from the grabber', () => {+ const { container } = render(<Host session={makeSession({ title: 'Renamable' })} />)+ const grabber = container.querySelector<HTMLElement>('[data-reorder-handle]')!++ grabber.focus()+ fireEvent.keyDown(grabber, space)+ expect(grabber.getAttribute('aria-pressed')).toBe('true')+ })+})