Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 修复会话浮层状态溢出 (#1273)
Chris Zhang4ab8e0ae3eab
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionTooltip.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionTooltip.tsxindex dfd261f70a..8751fec20b 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionTooltip.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionTooltip.tsx@@ -216,12 +216,16 @@ function PrLine({ prRef, status }: { prRef: SessionPrRef; status: PrStatusResultconst unresolved = status?.ok && status.unresolvedCount ? status.unresolvedCount : 0;return (- <div className="flex max-w-80 items-center gap-1.5">+ <div className="flex min-w-0 max-w-80 items-center gap-1.5"><Icon size={12} strokeWidth={1.75} className="shrink-0" style={{ color }} />- <span className="shrink-0">+ <span className="min-w-0 truncate">{prRef.owner}/{prRef.repo}#{prRef.prNumber}</span>- {kind && <span className="shrink-0">· {t(`ccAgent.gitContext.pr.status.${kind}`)}</span>}+ {kind && (+ <span className="shrink-0 whitespace-nowrap">+ · {t(`ccAgent.gitContext.pr.status.${kind}`)}+ </span>+ )}{unresolved > 0 && (<spanclassName="inline-flex shrink-0 items-center gap-0.5"diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionTooltip.test.ts b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionTooltip.test.tsindex 0b05bc3442..3f9099a64b 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionTooltip.test.ts+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionTooltip.test.ts@@ -7,6 +7,11 @@ import { afterEach, describe, expect, it, vi } from 'vitest';import { Tooltip } from '@/components/ui/tooltip';import { SessionTooltip } from '../SessionTooltip';import type { SessionPrRef } from '@/lib/gitContext.types';+import { prStatusKey } from '@/hooks/useSessionGitContext';++const { prStatuses } = vi.hoisted(() => ({+ prStatuses: new Map(),+}));vi.mock('react-i18next', () => ({useTranslation: () => ({@@ -16,13 +21,14 @@ vi.mock('react-i18next', () => ({vi.mock('@/contexts/PrRefsContext', () => ({usePrStatuses: () => ({- statuses: new Map(),+ statuses: prStatuses,fetchStatusesForSession: vi.fn(),}),}));afterEach(() => {cleanup();+ prStatuses.clear();});const prRef: SessionPrRef = {@@ -85,4 +91,49 @@ describe('SessionTooltip', () => {expect(screen.queryByText('XDMaker')).toBeNull();});++ it('lets a long repository label shrink without pushing the PR status outside the tooltip', async () => {+ const longRepoRef = {+ ...prRef,+ repo: 'repository-name-that-is-much-wider-than-the-tooltip-content-area',+ };+ prStatuses.set(prStatusKey(longRepoRef), {+ ok: true,+ owner: longRepoRef.owner,+ repo: longRepoRef.repo,+ prNumber: longRepoRef.prNumber,+ status: 'merged',+ branch: 'fix/long-repository-name',+ title: 'Keep the merged state inside the tooltip',+ htmlUrl: longRepoRef.url,+ unresolvedCount: 0,+ });++ render(+ createElement(+ SessionTooltip,+ { sessionId: 'session-1', prRefs: [longRepoRef] } as unknown as ComponentProps<+ typeof SessionTooltip+ >,+ createElement('div', null, 'Session row'),+ ),+ );++ fireEvent.pointerMove(screen.getByText('Session row'), { pointerType: 'mouse' });++ const repoLabels = await screen.findAllByText(+ `makecindy/${longRepoRef.repo}#${longRepoRef.prNumber}`,+ );+ const statusLabels = screen.getAllByText('· ccAgent.gitContext.pr.status.merged');++ for (const repoLabel of repoLabels) {+ expect(repoLabel.classList.contains('min-w-0')).toBe(true);+ expect(repoLabel.classList.contains('truncate')).toBe(true);+ expect(repoLabel.classList.contains('shrink-0')).toBe(false);+ }+ for (const statusLabel of statusLabels) {+ expect(statusLabel.classList.contains('shrink-0')).toBe(true);+ expect(statusLabel.classList.contains('whitespace-nowrap')).toBe(true);+ }+ });});