The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): stop the rail dropping its end-mark tooltips
finn763e1ffc7bad360
diff --git a/apps/desktop/src/components/ui/tooltip-placement.test.tsx b/apps/desktop/src/components/ui/tooltip-placement.test.tsxindex 2233e0eb5f2..6b9543a122c 100644--- a/apps/desktop/src/components/ui/tooltip-placement.test.tsx+++ b/apps/desktop/src/components/ui/tooltip-placement.test.tsx@@ -40,20 +40,22 @@ afterEach(() => {const latestContent = () => contentProps.mock.calls.at(-1)?.[0]describe('tooltip placement', () => {+ // Rail ticks scroll inside their own strip, flush against its clip box, where+ // Radix's padding-inset `hide` check misfires on them (#115723).it.each([- ['control', 'top'],- ['toolbar', 'bottom'],- ['row', 'right'],- ['left-rail', 'right'],- ['right-rail', 'left']- ] as const)('prefers %s tooltips on the %s', (placement, side) => {+ ['control', 'top', true],+ ['toolbar', 'bottom', true],+ ['row', 'right', true],+ ['left-rail', 'right', false],+ ['right-rail', 'left', false]+ ] as const)('prefers %s tooltips on the %s', (placement, side, hideWhenDetached) => {render(<Tip label="Details" placement={placement}><button>Trigger</button></Tip>)- expect(latestContent()).toMatchObject({ side, align: 'center', hideWhenDetached: true, collisionPadding: 12 })+ expect(latestContent()).toMatchObject({ side, align: 'center', hideWhenDetached, collisionPadding: 12 })expect(latestContent().avoidCollisions).not.toBe(false)})diff --git a/apps/desktop/src/components/ui/tooltip-rail-edge.test.tsx b/apps/desktop/src/components/ui/tooltip-rail-edge.test.tsxnew file mode 100644index 00000000000..ba690e9f598--- /dev/null+++ b/apps/desktop/src/components/ui/tooltip-rail-edge.test.tsx@@ -0,0 +1,90 @@+import { cleanup, fireEvent, render, screen } from '@testing-library/react'+import { afterEach, expect, it, vi } from 'vitest'++import { RootTooltipProvider, Tip } from './tooltip'++const rect = (x: number, y: number, width: number, height: number): DOMRect =>+ ({ top: y, left: x, right: x + width, bottom: y + height, width, height, x, y, toJSON: () => ({}) }) as DOMRect++/** The rail's real shape: `.thread-timeline-ticks` is a 48x300 scrolling strip+ * floating mid-window (the rail is `top: 50%; translateY(-50%)`), its+ * `.thread-timeline-track` is `position: relative`, and `.thread-timeline-tick`+ * is a 7px absolutely positioned button that sits flush against the strip's clip+ * box at both ends. Chromium-like geometry, installed BEFORE render. */+function mockRailGeometry(tickTop: number) {+ vi.spyOn(Element.prototype, 'getBoundingClientRect').mockImplementation(function (this: Element) {+ if (this.hasAttribute('data-rail')) {+ return rect(800, 200, 48, 300)+ }++ if (this.tagName === 'BUTTON') {+ return rect(800, 200 + tickTop, 48, 7)+ }++ return rect(0, 0, 1024, 768)+ })++ // floating-ui reads a clipping ancestor's inner size from clientWidth/Height,+ // which jsdom always reports as 0 — mirror the mocked rects there too. The+ // viewport boundary takes the same path, so the fallback is the window size.+ // Spied on the prototype's own getters, so `vi.restoreAllMocks()` puts the real+ // ones back — no descriptor to clean up by hand.+ for (const [name, size, viewport] of [+ ['clientWidth', 48, 1024],+ ['clientHeight', 300, 768]+ ] as const) {+ vi.spyOn(Element.prototype, name, 'get').mockImplementation(function (this: Element) {+ return this.hasAttribute('data-rail') ? size : viewport+ })+ }+}++afterEach(() => {+ cleanup()+ vi.restoreAllMocks()+})++// A tick at either end of the rail is flush with the strip's clip box. Radix+// feeds `collisionPadding` (12) into the hide (`referenceHidden`) middleware,+// which insets that clip box: a trigger shorter than the padding, sitting on the+// edge, reads as fully scrolled out and its bubble mounts into `visibility:+// hidden` — a mark that looks dead on hover. Middle ticks have room, which is+// why only the first and last marks were reported.+it.each([+ ['first', 0],+ ['middle', 140],+ ['last', 293]+])('opens a visible bubble on the %s mark of a scrolling rail', async (_position, tickTop) => {+ mockRailGeometry(tickTop)++ render(+ <RootTooltipProvider>+ <div data-rail style={{ left: 800, overflowY: 'auto', position: 'absolute', top: 200 }}>+ <div style={{ position: 'relative' }}>+ <Tip label={`Prompt at ${tickTop}`} placement="right-rail">+ <button style={{ height: 7, position: 'absolute', top: tickTop }}>tick</button>+ </Tip>+ </div>+ </div>+ </RootTooltipProvider>+ )++ const trigger = screen.getByRole('button')++ fireEvent.pointerEnter(trigger)+ fireEvent.pointerMove(trigger, { pointerType: 'mouse' })++ await vi.waitFor(+ () => {+ // eslint-disable-next-line no-restricted-globals -- the portal mounts on the live document+ expect(document.querySelector('[data-slot="tooltip-content"]')).not.toBeNull()+ },+ { timeout: 2000 }+ )++ // eslint-disable-next-line no-restricted-globals -- the portal mounts on the live document+ const wrapper = document.querySelector<HTMLElement>('[data-radix-popper-content-wrapper]')++ expect(wrapper).not.toBeNull()+ expect(wrapper?.style.visibility).not.toBe('hidden')+})diff --git a/apps/desktop/src/components/ui/tooltip.tsx b/apps/desktop/src/components/ui/tooltip.tsxindex 54f8e748cd7..7ef1fe4ae80 100644--- a/apps/desktop/src/components/ui/tooltip.tsx+++ b/apps/desktop/src/components/ui/tooltip.tsx@@ -170,7 +170,7 @@ function PaneClippedContent({className,collisionBoundary,collisionPadding = 12,- hideWhenDetached = true,+ hideWhenDetached,placement = 'control',boundary = placement === 'control' || placement === 'toolbar' ? 'pane' : 'viewport',side,@@ -218,7 +218,12 @@ function PaneClippedContent({collisionBoundary={collisionBoundary ?? pane ?? undefined}collisionPadding={collisionPadding}data-slot="tooltip-content"- hideWhenDetached={hideWhenDetached}+ // Radix's `collisionPadding` also insets the hide middleware's clip box, so+ // a 7px rail tick drawn flush against the strip's edge reads as scrolled+ // out and mounts hidden — a mark that looks dead on hover (#115723). Rail+ // ticks unmount when scrolled away, so the middleware has nothing to hide+ // there; leave it to triggers that stay put inside scrolling lists.+ hideWhenDetached={hideWhenDetached ?? (placement !== 'left-rail' && placement !== 'right-rail')}side={side ?? preferred.side}sideOffset={sideOffset}{...props}