Skip to content

Commit a5e1b50

Browse files
saravmajesticclaude
andcommitted
fix(tui): wrap panel-sizing memos in altimate_change markers; per-test renderer isolation; derive contentWidth from panelAvailable
- Marker Guard: home.tsx panelAvailable and session contentWidth/panelAvailable are edits in upstream-shared files, now wrapped in altimate_change markers - derive contentWidth from panelAvailable().width — one definition, can't drift - render test: own the renderer per test (destroy + reset in finally) instead of a shared module-level var, safe under parallel bun test Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 2762efb commit a5e1b50

3 files changed

Lines changed: 38 additions & 30 deletions

File tree

‎packages/tui/src/routes/home.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ export function Home() {
6868
if (configured === "auto") return Math.max(75, Math.floor(dimensions().width * 0.7))
6969
return configured ?? 75
7070
})
71-
// Panel's available space (terminal minus this route's padding + vertical
72-
// reserve). Shared arithmetic in welcome-panel-utils so tests exercise it.
71+
// altimate_change start — WelcomePanel responsive sizing (#1067): the panel's
72+
// available space = terminal minus this route's padding + vertical reserve.
73+
// Shared arithmetic in welcome-panel-utils so the tests exercise it.
7374
const panelAvailable = createMemo(() => homeAvailable(dimensions().width, dimensions().height))
75+
// altimate_change end
7476
let sent = false
7577

7678
onMount(() => {

‎packages/tui/src/routes/session/index.tsx‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,15 @@ export function Session() {
272272
return false
273273
})
274274
const showTimestamps = createMemo(() => timestamps() === "show")
275-
const contentWidth = createMemo(
276-
() => dimensions().width - (sidebarVisible() ? SIDEBAR_WIDTH : 0) - PANEL_HORIZONTAL_PADDING,
277-
)
278-
// Welcome panel's available space — same content-column basis as contentWidth
279-
// (narrows with the sidebar whenever open, incl. the dimmed overlay on narrow
280-
// terminals) so the panel stays aligned with the messages and both restore
281-
// together when it closes. Height reserves the prompt row. Shared arithmetic in
282-
// welcome-panel-utils so the tests exercise this exact math.
275+
// altimate_change start — WelcomePanel responsive sizing (#1067). panelAvailable is the single
276+
// source of the panel's usable size (via welcome-panel-utils, unit-tested); it narrows with the
277+
// sidebar whenever open — including the dimmed full-area overlay on narrow terminals — so the
278+
// panel and the messages stay aligned and both restore to full width when it closes. contentWidth
279+
// (the shared content-column width) derives from it, so the width math has one definition and the
280+
// two cannot structurally drift.
283281
const panelAvailable = createMemo(() => sessionAvailable(dimensions().width, dimensions().height, sidebarVisible()))
282+
const contentWidth = createMemo(() => panelAvailable().width)
283+
// altimate_change end
284284
const providers = createMemo(() => Model.index(sync.data.provider))
285285

286286
const scrollAcceleration = createMemo(() => getScrollAcceleration(tuiConfig))

‎packages/tui/test/component/welcome-panel.test.tsx‎

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsxImportSource @opentui/solid */
22
import { testRender } from "@opentui/solid"
3-
import { afterEach, expect, test } from "bun:test"
3+
import { expect, test } from "bun:test"
44
import { resetSetupComplete } from "../../src/component/altimate-onboarding"
55
import { WelcomePanel } from "../../src/component/welcome-panel"
66
import { TuiConfigProvider } from "../../src/config"
@@ -67,31 +67,37 @@ async function renderPanel(availableWidth: number, availableHeight: number) {
6767
return { app, frame }
6868
}
6969

70-
let current: Awaited<ReturnType<typeof testRender>> | undefined
71-
afterEach(() => {
72-
current?.renderer.destroy()
73-
current = undefined
74-
})
70+
// Own the renderer per test and destroy it in the same test's finally (plus reset
71+
// onboarding state), so nothing leaks between tests or races under parallel bun test.
72+
async function withPanel(width: number, height: number, check: (frame: string) => void) {
73+
const { app, frame } = await renderPanel(width, height)
74+
try {
75+
check(frame)
76+
} finally {
77+
app.renderer.destroy()
78+
resetSetupComplete()
79+
}
80+
}
7581

7682
test("full variant renders the wordmark + what-is section at a large available size", async () => {
77-
const { app, frame } = await renderPanel(FULL_MIN_WIDTH, FULL_MIN_HEIGHT)
78-
current = app
79-
// "What is Altimate Code" is unique to the full two-column box.
80-
expect(frame).toContain("What is Altimate Code")
83+
await withPanel(FULL_MIN_WIDTH, FULL_MIN_HEIGHT, (frame) => {
84+
// "What is Altimate Code" is unique to the full two-column box.
85+
expect(frame).toContain("What is Altimate Code")
86+
})
8187
})
8288

8389
test("medium variant renders the condensed line (no what-is section) below the full width floor", async () => {
84-
const { app, frame } = await renderPanel(FULL_MIN_WIDTH - 1, FULL_MIN_HEIGHT)
85-
current = app
86-
expect(frame).toContain("Gives your AI real context")
87-
expect(frame).not.toContain("What is Altimate Code")
90+
await withPanel(FULL_MIN_WIDTH - 1, FULL_MIN_HEIGHT, (frame) => {
91+
expect(frame).toContain("Gives your AI real context")
92+
expect(frame).not.toContain("What is Altimate Code")
93+
})
8894
})
8995

9096
test("compact variant renders a single line below the medium width floor", async () => {
91-
const { app, frame } = await renderPanel(MEDIUM_MIN_WIDTH - 1, FULL_MIN_HEIGHT)
92-
current = app
93-
// Unconnected → the connect CTA; neither the medium nor full body is present.
94-
expect(frame).toContain("Connect your AI model to start")
95-
expect(frame).not.toContain("Gives your AI real context")
96-
expect(frame).not.toContain("What is Altimate Code")
97+
await withPanel(MEDIUM_MIN_WIDTH - 1, FULL_MIN_HEIGHT, (frame) => {
98+
// Unconnected → the connect CTA; neither the medium nor full body is present.
99+
expect(frame).toContain("Connect your AI model to start")
100+
expect(frame).not.toContain("Gives your AI real context")
101+
expect(frame).not.toContain("What is Altimate Code")
102+
})
97103
})

0 commit comments

Comments
 (0)