Skip to content

The agent that grows with you

fix(desktop): keep timeline ticks compact outside hover

brooklyn!fdb7b216ecdd
diff --git a/apps/desktop/src/components/assistant-ui/thread/timeline-rail.test.tsx b/apps/desktop/src/components/assistant-ui/thread/timeline-rail.test.tsx
index c23e6936a2e..83588d0ddb5 100644
--- a/apps/desktop/src/components/assistant-ui/thread/timeline-rail.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/timeline-rail.test.tsx
@@ -1,4 +1,4 @@
-import { cleanup, fireEvent, render, screen } from '@testing-library/react'
+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
import type { ReactNode } from 'react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
@@ -39,15 +39,32 @@ describe('TimelineRail', () => {
expect(view.container.querySelector('.thread-timeline-track')?.getAttribute('style')).toContain('35000px')
})
- it('keeps the active bar at maximum width and routes selection by stable ID', () => {
+ it('keeps the active bar compact without hover and routes selection by stable ID', () => {
const onJump = vi.fn()
render(<TimelineRail activeIndex={0} entries={entries} loadingId={null} onJump={onJump} />)
const active = screen.getByRole('button', { name: 'Message 0' })
expect(active.getAttribute('aria-current')).toBe('location')
- expect((active.firstElementChild as HTMLElement).style.width).toBe('1rem')
+ expect((active.firstElementChild as HTMLElement).style.width).toBe('0.5rem')
fireEvent.click(active)
expect(onJump).toHaveBeenCalledWith('message-0')
})
+
+ it('resets every bar on pointer leave even while an item keeps focus', async () => {
+ const { container, rerender } = render(<TimelineRail activeIndex={0} entries={entries} loadingId={null} onJump={vi.fn()} />)
+ const rail = container.querySelector<HTMLElement>('[data-slot="thread-timeline-ticks"]')!
+ const widths = () => Array.from(rail.querySelectorAll<HTMLElement>('[data-slot="timeline-bar"]'), bar => bar.style.width)
+
+ expect(new Set(widths())).toEqual(new Set(['0.5rem']))
+ fireEvent(rail, new MouseEvent('pointermove', { bubbles: true, clientY: 70 }))
+ await waitFor(() => expect(widths()).toContain('1rem'))
+
+ fireEvent.focus(screen.getByRole('button', { name: 'Message 0' }))
+ fireEvent.pointerLeave(rail)
+ await waitFor(() => expect(new Set(widths())).toEqual(new Set(['0.5rem'])))
+
+ rerender(<TimelineRail activeIndex={2} entries={entries} loadingId={null} onJump={vi.fn()} />)
+ expect(new Set(widths())).toEqual(new Set(['0.5rem']))
+ })
})
diff --git a/apps/desktop/src/components/assistant-ui/thread/timeline-rail.tsx b/apps/desktop/src/components/assistant-ui/thread/timeline-rail.tsx
index 52ff592e729..e0cdcb9dca8 100644
--- a/apps/desktop/src/components/assistant-ui/thread/timeline-rail.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/timeline-rail.tsx
@@ -62,7 +62,9 @@ export function TimelineRail({ activeIndex, entries, loadingId, onJump }: Timeli
frame.current = 0
for (const bar of root.current?.querySelectorAll<HTMLElement>('[data-slot="timeline-bar"]') ?? []) {
- const width = `${Number(timelineBarWidth(Number(bar.dataset.index), activeIndex, hover.current).toFixed(4))}rem`
+ const width = pointerY.current === null
+ ? '0.5rem'
+ : `${Number(timelineBarWidth(Number(bar.dataset.index), activeIndex, hover.current).toFixed(4))}rem`
if (bar.style.width !== width) {
bar.style.width = width