diff --git a/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.test.tsx b/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.test.tsx new file mode 100644 index 00000000000..ae2c93a71dd --- /dev/null +++ b/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.test.tsx @@ -0,0 +1,57 @@ +// @vitest-environment happy-dom + +import { cleanup, render } from '@testing-library/react' +import { afterEach, describe, expect, it } from 'vitest' +import { TooltipProvider } from '@/components/ui/tooltip' +import { CloudAgentSignInStrip, type CloudStripActions } from './CloudAgentSignInStrip' +import type { CloudStripModel } from './cloud-agent-strip-model' + +afterEach(() => cleanup()) + +const noop = (): void => {} +const actions: CloudStripActions = { + primary: noop, + submitCode: noop, + pasteCode: noop, + useCode: noop, + useApiKey: noop, + cancel: noop +} +const model: CloudStripModel = { + status: 'warning', + title: 'A title long enough that a narrow pane would cut it off', + detail: 'A detail sentence that also runs past the width of a narrow pane', + description: null, + primary: { label: 'Restart', action: { kind: 'restart' } }, + code: null, + paste: null, + otherWays: false, + announcement: 'A title' +} + +function strip(wrap?: boolean): HTMLElement { + const { container } = render( + + + + ) + return container.querySelector('[data-cloud-sign-in-strip]')! +} + +describe('CloudAgentSignInStrip wrap', () => { + it('keeps every existing strip at the fixed 56 px, one truncated line each', () => { + const element = strip() + expect(element.className).toContain('h-14') + expect(element.className).not.toContain('min-h-14') + expect(element.querySelector('[data-strip-text] span')?.className).toContain('truncate') + }) + + it('opt-in wrap grows the strip and lets title and detail wrap up to 3 lines', () => { + const element = strip(true) + expect(element.className).toContain('min-h-14') + expect(element.className).not.toMatch(/(^|\s)h-14(\s|$)/) + const text = element.querySelector('[data-strip-text] span') + expect(text?.className).toContain('line-clamp-3') + expect(text?.className).not.toContain('truncate') + }) +}) diff --git a/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.tsx b/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.tsx index 490da903f06..3a7fe13d653 100644 --- a/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.tsx +++ b/src/renderer/src/components/agent-sign-in-strip/CloudAgentSignInStrip.tsx @@ -130,13 +130,19 @@ export function CloudAgentSignInStrip({ model, prompt, width: initialWidth = 'wide', - actions + actions, + wrap = false }: { model: CloudStripModel prompt: string | null /** The first render's class; after that the strip follows its own live width. */ width?: CloudStripWidth actions: CloudStripActions + /** + * A warning that must be read whole (GIT-SETUP): title and detail wrap (up to 3 lines each) and the + * strip grows; actions stay top-right. Pane strips keep the fixed 56 px height. + */ + wrap?: boolean }): React.JSX.Element { const sectionRef = useRef(null) const width = useLiveStripWidth(sectionRef, initialWidth) @@ -144,7 +150,8 @@ export function CloudAgentSignInStrip({ // The detail leaves the line when there's no room for it beside the title: below 360 px, and on the // paste step under ~560 px (its input takes the space). It stays the region's description and the // title's tooltip. - const quietDetail = compact || (model.paste !== null && width === 'tiny') + const quietDetail = !wrap && (compact || (model.paste !== null && width === 'tiny')) + const lineFit = wrap ? 'line-clamp-3 break-words' : 'truncate' const t = useTranslate() const titleId = React.useId() const detailId = React.useId() @@ -166,7 +173,8 @@ export function CloudAgentSignInStrip({ } }} className={cn( - 'grid h-14 items-center gap-2.5 border-b border-border bg-card px-3 text-foreground outline-none', + 'grid gap-2.5 border-b border-border bg-card px-3 text-foreground outline-none', + wrap ? 'min-h-14 items-start py-2.5 [&>svg]:mt-0.5' : 'h-14 items-center', GRID[width] )} > @@ -174,7 +182,7 @@ export function CloudAgentSignInStrip({ - + {compact ? (model.compactTitle ?? model.title) : model.title} @@ -185,7 +193,8 @@ export function CloudAgentSignInStrip({ @@ -217,7 +226,10 @@ export function CloudAgentSignInStrip({ ) ) : null} - + {model.code ? ( {model.code}
{model.code}