diff --git a/packages/tui/src/component/session-tabs.tsx b/packages/tui/src/component/session-tabs.tsx index 7cee2aecf37..da215491fd2 100644 --- a/packages/tui/src/component/session-tabs.tsx +++ b/packages/tui/src/component/session-tabs.tsx @@ -602,9 +602,7 @@ function VerticalSessionTabs(props: { return moveSessionTab(tabs.tabs(), pending.sessionID, pending.index) }) const items = ordered - const highlightColor = createMemo(() => - tint(background(), actionHovered(), actionHovered().a), - ) + const highlightColor = createMemo(() => tint(background(), actionHovered(), actionHovered().a)) const highlighted = (sessionID: string | undefined) => sessionID !== undefined && (activeID() === sessionID || hovered() === sessionID || dragging() === sessionID) const addHighlighted = () => newTab() || addHovered() @@ -845,7 +843,6 @@ function VerticalSessionTabs(props: { () => previous()?.sessionID === activeID() && Boolean(previousStatus().attention), animations, ) - const indicatorWidth = 10 let lastPreviousGlowHue: RGBA | undefined const previousGlowHue = () => { const feedback = tabFeedbackColor(previousStatus(), theme) @@ -856,9 +853,7 @@ function VerticalSessionTabs(props: { const separatorUpperColor = createMemo(() => tint(background(), previousGlowHue(), 0.1 * previousGlowLevel()), ) - const separatorLowerColor = createMemo(() => - tint(background(), glowHue(), 0.12 * glowLevel()), - ) + const separatorLowerColor = createMemo(() => tint(background(), glowHue(), 0.12 * glowLevel())) const titleColor = (index: number, separator: boolean) => { const level = titleGlow.value().level const color = @@ -923,9 +918,7 @@ function VerticalSessionTabs(props: { edge="top" width={width()} color={pulseBackground()} - background={ - highlighted(items()[index() - 1]?.sessionID) ? highlightColor() : background() - } + background={highlighted(items()[index() - 1]?.sessionID) ? highlightColor() : background()} /> ({ sessionID: `closed-${index}`, title: `History ${index + 1}` }))) + setClosed( + Array.from({ length: 11 }, (_, index) => ({ sessionID: `closed-${index}`, title: `History ${index + 1}` })), + ) await app.renderOnce() const historyRows = app.captureCharFrame().split("\n") const newRow = historyRows.findIndex((line) => line.includes("+ New session")) @@ -260,3 +264,82 @@ for (const orientation of ["horizontal", "vertical"] as const) { } }) } + +test.each([SESSION_SIDEBAR_WIDTH, 18])( + "vertical running tab pulse spans the full %i-column tab width", + async (railWidth) => { + const clock = new ManualClock() + const [busy, setBusy] = createSignal(false) + const controller = { + tabs: () => [ + { sessionID: "first", title: "First session" }, + { sessionID: "second", title: "Second session" }, + ], + current: () => "second", + select() {}, + close() {}, + move() {}, + add() {}, + detail: () => "opencode", + status: (sessionID: string) => + sessionID === "second" ? { ...EMPTY_SESSION_TAB_STATUS, busy: busy() } : EMPTY_SESSION_TAB_STATUS, + } satisfies SessionTabsController + + const app = await testRender( + () => ( + + + + + + transcript + + + + + ), + { width: 80, height: 10, clock }, + ) + + try { + app.renderer.pause() + await app.renderOnce() + + const cellRow = (row: number) => + app.captureSpans().lines[row]!.spans.flatMap((span) => + Array.from(span.text, (char) => ({ + char, + fg: span.fg.buffer.join(), + bg: span.bg.buffer.join(), + })), + ) + + const idleAbove = cellRow(3) + const idleTitle = cellRow(4) + const idleDetail = cellRow(5) + const idleBelow = cellRow(6) + + setBusy(true) + await app.renderOnce() + clock.setTime(1850) + await app.renderOnce() + + const runningAbove = cellRow(3) + const runningTitle = cellRow(4) + const runningDetail = cellRow(5) + const runningBelow = cellRow(6) + const rightEdge = railWidth - 1 + + expect(runningAbove.slice(0, railWidth).map((cell) => cell.char)).toEqual(Array(railWidth).fill("▄")) + expect(runningBelow.slice(0, railWidth).map((cell) => cell.char)).toEqual(Array(railWidth).fill("▀")) + expect(runningAbove[rightEdge]!.fg).not.toBe(idleAbove[rightEdge]!.bg) + expect(runningBelow[rightEdge]!.fg).not.toBe(idleBelow[rightEdge]!.bg) + expect(runningTitle[rightEdge]!.bg).not.toBe(idleTitle[rightEdge]!.bg) + expect(runningDetail[rightEdge]!.bg).not.toBe(idleDetail[rightEdge]!.bg) + expect(runningTitle[railWidth]!.bg).toBe(idleTitle[railWidth]!.bg) + expect(runningBelow[railWidth]!.char).toBe(" ") + } finally { + app.renderer.destroy() + } + }, +)