diff --git a/client/src/components/Chat/PullRequest/Card.tsx b/client/src/components/Chat/PullRequest/Card.tsx index dcb5e1d9fa..08f2d3e799 100644 --- a/client/src/components/Chat/PullRequest/Card.tsx +++ b/client/src/components/Chat/PullRequest/Card.tsx @@ -55,7 +55,7 @@ function PullRequestCard({ rel="noopener noreferrer" aria-label={openLabel} data-testid="pull-request-github-link" - className="text-text-secondary hover:bg-surface-hover hover:text-text-primary focus-visible:ring-text-primary flex size-7 shrink-0 items-center justify-center rounded-md outline-hidden focus-visible:ring-2" + className="text-text-secondary hover:text-text-primary focus-visible:ring-text-primary flex size-7 shrink-0 items-center justify-center rounded-md outline-hidden focus-visible:ring-2 [&_svg]:size-4" > diff --git a/client/src/components/Chat/PullRequest/Chip.tsx b/client/src/components/Chat/PullRequest/Chip.tsx index fbd5763748..ca0de7ebf7 100644 --- a/client/src/components/Chat/PullRequest/Chip.tsx +++ b/client/src/components/Chat/PullRequest/Chip.tsx @@ -1,52 +1,25 @@ import { memo } from 'react'; import * as Ariakit from '@ariakit/react'; import { useConversationPullRequestQuery } from '~/data-provider'; -import { useAgentsMapContext, useChatContext } from '~/Providers'; import { TONE_DOT_CLASS, presentPullRequest } from './status'; -import { URLIcon } from '~/components/Endpoints/URLIcon'; +import PullRequestPanel, { panelBelowClass } from './Panel'; import { summarizePullRequest } from './summary'; -import PullRequestPanel from './Panel'; import { useLocalize } from '~/hooks'; import PullRequestIcon from './Icon'; import CiDot from './CiDot'; -/** The agent's picture with the CI dot on its corner. */ -function AgentAvatar({ - avatar, - name, - dotClass, -}: { - avatar: string; - name?: string | null; - dotClass: string | null; -}) { - return ( - - ); -} - /** * Desktop header control for the pull request a code conversation opened. It renders nothing * until a pull request is known: a conversation without one, a disabled feature and a failed * first lookup all leave the header exactly as it was, so the row never shifts. The details - * open to the right of the chip on hover or keyboard focus and slide in from the left. The card + * open below the chip on hover or keyboard focus and slide down. The card * holds a link, so it is an Ariakit hovercard: it stays open while the pointer or focus is * inside it, and Tab moves from the chip into it. */ function PullRequestChip({ conversationId }: { conversationId: string }) { const localize = useLocalize(); - const { conversation } = useChatContext(); - const agentsMap = useAgentsMapContext(); const hovercard = Ariakit.useHovercardStore({ - placement: 'right-start', + placement: 'bottom-start', showTimeout: 100, hideTimeout: 150, }); @@ -59,12 +32,6 @@ function PullRequestChip({ conversationId }: { conversationId: string }) { const view = presentPullRequest(pullRequest); const label = summarizePullRequest(pullRequest, localize); const dotClass = view.dotTone == null ? null : TONE_DOT_CLASS[view.dotTone]; - /** The chat state can lag the route by a render; only its own conversation's agent applies. */ - const agentId = - conversation?.conversationId === conversationId ? conversation.agent_id : undefined; - const agent = agentId == null ? undefined : agentsMap?.[agentId]; - const avatar = agent?.avatar?.filepath ?? ''; - const hasAvatar = avatar !== ''; return ( @@ -77,10 +44,9 @@ function PullRequestChip({ conversationId }: { conversationId: string }) { onFocus={() => hovercard.show()} className="border-border-light bg-presentation text-text-primary hover:bg-surface-tertiary aria-expanded:bg-surface-tertiary inline-flex h-9 max-w-[14rem] min-w-0 flex-shrink items-center gap-1.5 rounded-xl border px-2 text-sm transition-all ease-in-out" > - {hasAvatar && } - {!hasAvatar && dotClass != null && } + {dotClass != null && } {pullRequest.title} @@ -88,6 +54,7 @@ function PullRequestChip({ conversationId }: { conversationId: string }) { /> void refetch()} diff --git a/client/src/components/Chat/PullRequest/Panel.tsx b/client/src/components/Chat/PullRequest/Panel.tsx index b9881e9407..fb8ffb3587 100644 --- a/client/src/components/Chat/PullRequest/Panel.tsx +++ b/client/src/components/Chat/PullRequest/Panel.tsx @@ -13,6 +13,15 @@ export const panelClass = cn( 'motion-reduce:translate-x-0 motion-reduce:transition-opacity', ); +/** Slides down from an anchor above it and fades; reduced motion only fades. */ +export const panelBelowClass = cn( + 'border-border-light bg-surface-secondary text-text-primary z-[200] w-80 max-w-[calc(100vw-2rem)] rounded-xl border shadow-lg focus:outline-none', + 'origin-top -translate-y-2 opacity-0 transition duration-200 ease-out', + 'data-[enter]:translate-y-0 data-[enter]:opacity-100', + 'data-[leave]:-translate-y-2 data-[leave]:opacity-0', + 'motion-reduce:translate-y-0 motion-reduce:transition-opacity', +); + /** * The card as a hovercard beside its anchor. It is portaled, and a portal's events still bubble * to the React tree that rendered it, so anything that sits inside a clickable row stops them @@ -23,7 +32,9 @@ export default function PullRequestPanel({ pullRequest, refreshFailed, onRetry, + className = panelClass, }: { + className?: string; store: Ariakit.HovercardStore; pullRequest: TConversationPullRequest; refreshFailed: boolean; @@ -41,7 +52,7 @@ export default function PullRequestPanel({ unmountOnHide autoFocusOnShow={false} aria-label={localize('com_ui_pull_request')} - className={panelClass} + className={className} onClick={stop} onDoubleClick={stop} onContextMenu={stop} diff --git a/client/src/components/Chat/PullRequest/__tests__/Card.test.tsx b/client/src/components/Chat/PullRequest/__tests__/Card.test.tsx index 84b90506f0..d8391eca49 100644 --- a/client/src/components/Chat/PullRequest/__tests__/Card.test.tsx +++ b/client/src/components/Chat/PullRequest/__tests__/Card.test.tsx @@ -41,6 +41,19 @@ describe('PullRequestCard', () => { } }); + it('gives the GitHub mark a viewBox, so shrinking the icon scales it instead of clipping it', () => { + render(); + const svg = screen.getByTestId('pull-request-github-link').querySelector('svg'); + expect(svg).toHaveAttribute('viewBox', '0 0 25 25'); + }); + + it('dims only the GitHub icon on hover, never the background behind it', () => { + render(); + const link = screen.getByTestId('pull-request-github-link'); + expect(link).toHaveClass('hover:text-text-primary'); + expect(link.className).not.toMatch(/hover:bg-/); + }); + it('puts the GitHub tooltip in the layer the card lives in, not behind it', async () => { const layer = document.createElement('div'); document.body.appendChild(layer); diff --git a/client/src/components/Chat/PullRequest/__tests__/Chip.test.tsx b/client/src/components/Chat/PullRequest/__tests__/Chip.test.tsx index dc3db2d59a..52a176e33d 100644 --- a/client/src/components/Chat/PullRequest/__tests__/Chip.test.tsx +++ b/client/src/components/Chat/PullRequest/__tests__/Chip.test.tsx @@ -27,16 +27,6 @@ jest.mock('~/hooks', () => ({ useLocalize: () => (key: string, values?: Record) => values == null ? key : `${key}:${Object.values(values).join(',')}`, })); -const mockAgents: { current: Record } = { - current: { 'agent-1': { name: 'Coder' } }, -}; -const mockChat: { current: { conversationId?: string; agent_id?: string } } = { - current: { conversationId: 'convo-1', agent_id: 'agent-1' }, -}; -jest.mock('~/Providers', () => ({ - useAgentsMapContext: () => mockAgents.current, - useChatContext: () => ({ conversation: mockChat.current }), -})); /** * Ariakit opens a hovercard only for a pointer that is really moving, and only accepts a bare @@ -82,8 +72,6 @@ const renderChip = () => { describe('PullRequestChip', () => { beforeEach(() => { mockGet.mockReset(); - mockAgents.current = { 'agent-1': { name: 'Coder' } }; - mockChat.current = { conversationId: 'convo-1', agent_id: 'agent-1' }; }); it('renders nothing while loading, so the header does not shift', () => { @@ -127,30 +115,16 @@ describe('PullRequestChip', () => { expect(await screen.findByTestId('pull-request-ci-dot')).toHaveClass(dotClass); }); - it('puts the dot on the agent picture when the agent has one, and not on the icon', async () => { - mockAgents.current = { - 'agent-1': { name: 'Coder', avatar: { filepath: '/images/coder.png' } }, - }; + it('never shows the agent picture, even when the agent has one', async () => { mockGet.mockResolvedValue({ pullRequest: pr }); renderChip(); const dot = await screen.findByTestId('pull-request-ci-dot'); expect(screen.getAllByTestId('pull-request-ci-dot')).toHaveLength(1); - expect(dot.parentElement?.querySelector('img')).not.toBeNull(); - }); - - it('does not borrow the agent of the previous conversation while the chat state catches up', async () => { - mockAgents.current = { - 'agent-1': { name: 'Coder', avatar: { filepath: '/images/coder.png' } }, - }; - mockChat.current = { conversationId: 'previous-convo', agent_id: 'agent-1' }; - mockGet.mockResolvedValue({ pullRequest: pr }); - renderChip(); - const dot = await screen.findByTestId('pull-request-ci-dot'); - expect(dot.parentElement?.querySelector('img')).toBeNull(); + expect(screen.getByTestId('header-pull-request-button').querySelector('img')).toBeNull(); expect(dot.parentElement?.querySelector('svg')).not.toBeNull(); }); - it('keeps the dot on the pull request icon when the agent has no picture', async () => { + it('keeps the dot on the pull request icon', async () => { mockGet.mockResolvedValue({ pullRequest: pr }); renderChip(); const dot = await screen.findByTestId('pull-request-ci-dot'); diff --git a/packages/client/src/svgs/GithubIcon.tsx b/packages/client/src/svgs/GithubIcon.tsx index e637d3ad3c..e120f8a92c 100644 --- a/packages/client/src/svgs/GithubIcon.tsx +++ b/packages/client/src/svgs/GithubIcon.tsx @@ -3,7 +3,14 @@ import { JSX } from 'react/jsx-runtime'; export default function GithubIcon(): JSX.Element { return ( -