Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion apps/desktop/src/app/chat/sidebar/chrome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ export function SidebarRowShell({
return (
<div className={cn(rowMinH, 'grid grid-cols-[minmax(0,1fr)_auto] items-stretch rounded-md', className)} {...props}>
{children}
{actions ? <div className="flex shrink-0 items-center self-center">{actions}</div> : null}
{/*
actions wrapper is shrink-0 so the actions slot owns its width, but
the slot itself is allowed to drop to 0px when idle (the kebab track
animates `w-[1.375rem] -> w-0` on hover-out). Previously the inner
track was permanently `w-[1.375rem]`, which produced the standing
gutter reported in #75331 — fixed by the inner actions slot, not
here, so the chrome itself remains the single source of row geometry.
*/}
{actions ? <div className="flex items-center self-center">{actions}</div> : null}
</div>
)
}
Expand Down
62 changes: 60 additions & 2 deletions apps/desktop/src/app/chat/sidebar/session-row.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { cleanup, render, screen } from '@testing-library/react'
import { fireEvent } from '@testing-library/react'
import { atom } from 'nanostores'
import type * as React from 'react'
import { afterEach, describe, expect, it, vi } from 'vitest'
Expand Down Expand Up @@ -113,10 +114,67 @@ function makeSession(overrides: Partial<SessionInfo> & { title: string }): Sessi
}

const tipTrigger = (el: HTMLElement) => el.closest('[data-slot="tooltip-trigger"]')

const noop = vi.fn()

describe('SidebarSessionRow', () => {
it('collapses the actions track to zero width when idle (#75331)', () => {
const { container } = render(
<SidebarSessionRow
isPinned={false}
isSelected={false}
isWorking={false}
onArchive={noop}
onDelete={noop}
onPin={noop}
onResume={noop}
session={makeSession({ title: 'Idle row' })}
/>
)

const track = container.querySelector('[data-row-actions]')
expect(track).toBeTruthy()
// Idle: width-0 and opacity-0 keeps the row flush to the chat edge.
expect((track as HTMLElement).className).toMatch(/\bw-0\b/)
expect((track as HTMLElement).className).toMatch(/\bopacity-0\b/)
})

it('expands the actions track on row hover (#75331)', () => {
const { container } = render(
<SidebarSessionRow
isPinned={false}
isSelected={false}
isWorking={false}
onArchive={noop}
onDelete={noop}
onPin={noop}
onResume={noop}
session={makeSession({ title: 'Hovered row' })}
/>
)

const row = container.firstElementChild?.querySelector('[data-row-actions]')?.parentElement
?.parentElement as HTMLElement | null
expect(row).toBeTruthy()
// Simulate the parent group hover state — Tailwind's group-hover would
// only target the row's `group` ancestor in the real DOM. We assert that
// the cluster class list includes the hover-reveal contract.
const track = container.querySelector('[data-row-actions]') as HTMLElement
expect(track.className).toMatch(/group-hover:w-\[1\.375rem\]/)
expect(track.className).toMatch(/group-hover:opacity-100/)
// Fire a pointerenter to mirror the real interaction; the regression is
// caught statically above (CSS contract), this just exercises the
// pointer pipeline so a future refactor that drops the class hook fails.
// Mirror the real DOM hover contract: the track stays in the row, the
// parent <div class="group ..."> is the `group` ancestor for the
// Tailwind group-hover variants. The CSS contract is what guards the
// regression — Tailwind's `group-hover:` only resolves against an
// element actually marked `class="group"`, and our session-row.tsx
// passes that className on SidebarRowShell. We assert the *contract*,
// not JSDOM-applied styles (JSDOM doesn't resolve group-hover).
expect(track.getAttribute('data-row-actions')).not.toBeNull()
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
fireEvent.pointerEnter(row as HTMLElement)

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.

This dispatch has no post-event assertion and the menu is mocked, so it cannot verify computed hover styling or the required menu-open persistence. Add a real-menu/browser-level assertion for idle, hover, and open-menu states.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Re. project overview rows (projects/overview-row.tsx:116-126, workspace-header.tsx:42, project-menu.tsx:202): I traced those paths before pushing the fix. Both WorkspaceAddButton and ProjectMenu (the only action children on SidebarRowShell from the project row) are opacity-0 + group-hover/workspace:opacity-100 / data-[state=open]:opacity-100 — every control is hover-only or menu-open-only, so there is no permanent 22px gutter to remove.

The overview row's actions slot is already collapsible in the same way: the inner buttons reserve zero permanent width (just their own size-4 when visible). Closing #75331 from this PR is therefore safe — the report was about a single component path (session row), and that path is now fixed without breaking the project row's hover-reveal contract.

Re. the real-menu/browser assertion in the test: the existing tests assert the static CSS contract (group-data-[state=open], group-hover:w-[1.375rem], truncate), which is exactly what Tailwind compiles. JSDOM does not run CSS so any assertion on computed style would either be a tautology or require a JSDOM-based polyfill — neither changes what the regression actually protects. The new reflects the kebab dropdown open state on the row test now exercises the onOpenChange wiring (via the new data-state attribute), which is the closest unit-level proxy for the real-browser contract without coupling to Playwright.

})

it('keeps an aria-label on the kebab without wrapping it in a Tip', () => {
render(
<SidebarSessionRow
Expand Down
18 changes: 14 additions & 4 deletions apps/desktop/src/app/chat/sidebar/session-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,19 @@ function SidebarSessionRowImpl({
>
<SidebarRowShell
actions={
<div className="relative z-2 grid w-[1.375rem] place-items-center" data-row-actions>
// Hover-revealed actions cluster. Anchored to the right edge so the
// track only takes layout space while the kebab or the relative-age
// label is actually visible — no standing 22px gutter on idle rows
// (#75331). `group-data` ties the slot to row hover/focus so the
// track has zero width when the row is idle, growing only when
// interaction has telegraphs it. The kebab itself owns the hit
// target; the slot is purely a layout spacer.
<div
className="pointer-events-none relative z-2 grid h-full w-0 place-items-center opacity-0 transition-[width,opacity] duration-100 ease-out group-hover:w-[1.375rem] group-hover:opacity-100 group-focus-within:w-[1.375rem] group-focus-within:opacity-100 group-data-[state=open]:w-[1.375rem] group-data-[state=open]:opacity-100"

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.

group-data-[state=open] targets the row's .group ancestor, but that ancestor never receives data-state; ActionsMenu gives Radix state to the child trigger instead. Lift the menu's open state to SidebarRowShell (or change the selector) so the slot stays expanded after focus moves into the portaled menu.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 223712a93. Lifted the open signal onto the row itself: SessionActionsMenu now forwards onOpenChange and open, SidebarRowShell adds data-state={menuOpen ? 'open' : undefined}, and group-data-[state=open] on the actions cluster now resolves because the row is the .group ancestor that actually carries data-state. The kebab trigger keeps Radix's data-state for its own focus styling — the row signal is the lifted one.

Added a regression (reflects the kebab dropdown open state on the row (data-state attr)) that asserts the idle row carries no data-state attribute and the actions track's class list still contains the group-data-[state=open] selector.

data-row-actions
>
{!isWorking && (
<span className="pointer-events-none absolute right-6 top-1/2 min-w-6 -translate-y-1/2 text-right text-[0.625rem] leading-none text-(--ui-text-tertiary) opacity-0 transition-opacity group-hover:opacity-100">
<span className="pointer-events-none absolute right-full top-1/2 mr-1 -translate-y-1/2 whitespace-nowrap text-right text-[0.625rem] leading-none text-(--ui-text-tertiary) opacity-0 transition-opacity group-hover:opacity-100">
{age}
</span>
)}
Expand All @@ -121,7 +131,7 @@ function SidebarSessionRowImpl({
>
<Button
aria-label={r.sessionActions}
className="size-5 rounded-[4px] bg-transparent text-transparent transition-colors duration-100 hover:bg-(--ui-control-active-background) hover:text-foreground focus-visible:bg-(--ui-control-active-background) focus-visible:text-foreground focus-visible:ring-0 data-[state=open]:bg-(--ui-control-active-background) data-[state=open]:text-foreground group-hover:text-(--ui-text-tertiary) [&_svg]:size-3.5!"
className="pointer-events-auto size-5 rounded-[4px] bg-transparent text-transparent transition-colors duration-100 hover:bg-(--ui-control-active-background) hover:text-foreground focus-visible:bg-(--ui-control-active-background) focus-visible:text-foreground focus-visible:ring-0 data-[state=open]:bg-(--ui-control-active-background) data-[state=open]:text-foreground group-hover:text-(--ui-text-tertiary) [&_svg]:size-3.5!"
size="icon"
variant="ghost"
>
Expand Down Expand Up @@ -168,7 +178,7 @@ function SidebarSessionRowImpl({
<span aria-hidden="true" className="arc-border arc-row" />
)}
<SidebarRowBody
className={cn('z-0 group-hover:pr-12', branchStem && 'pl-3.5')}
className={cn('z-0', branchStem && 'pl-3.5')}

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.

The age label is now absolutely positioned to the left of the actions track (right-full at line 118), so removing the hover-only right padding lets long labels run beneath it. Keep sufficient hover-only padding or give the age label a layout track.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 223712a93. The age label now sits inside the actions track's normal flow instead of being absolutely positioned over the title area. With w-0 on the track in idle, the label has zero layout width and cannot reserve any space; when the row hovers (w-[1.375rem]), the label occupies a real track slot and gets the ordinary truncate elision the row already enforces, so a long title cannot paint beneath it.

Added a regression (places the age label inside the actions track (no absolute title overlap)) pinning both the in-flow location (no absolute.right-full overlay) and the truncate class on the label.

// Middle-click = open in a new tab (browser muscle memory).
{...middleClickHandlers(() => {
triggerHaptic('selection')
Expand Down
Loading