-
Notifications
You must be signed in to change notification settings - Fork 137
fix(tui): per-route vertical reserve + required panel props (#1069 round-2 follow-up) #1071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,18 +2,25 @@ import { expect, test } from "bun:test" | |
| import { | ||
| FULL_MIN_HEIGHT, | ||
| FULL_MIN_WIDTH, | ||
| HOME_VERTICAL_RESERVE, | ||
| MEDIUM_MIN_HEIGHT, | ||
| MEDIUM_MIN_WIDTH, | ||
| PANEL_VERTICAL_RESERVE, | ||
| PANEL_HORIZONTAL_PADDING, | ||
| SESSION_VERTICAL_RESERVE, | ||
| welcomePanelVariant, | ||
| } from "../../src/component/welcome-panel-utils" | ||
|
|
||
| // Comfortably above the full floor on one axis, used to isolate the OTHER axis | ||
| // so a single gate's removal is provable (each test below fails if its `<` check | ||
| // is deleted from the source). | ||
| // is deleted from the source, or flipped to `<=`). | ||
| const TALL = FULL_MIN_HEIGHT + 10 | ||
| const WIDE = FULL_MIN_WIDTH + 20 | ||
|
|
||
| // Map a terminal size to the AVAILABLE size each route feeds the pure function. | ||
| const home = (w: number, h: number) => welcomePanelVariant(w - PANEL_HORIZONTAL_PADDING, h - HOME_VERTICAL_RESERVE) | ||
| const session = (w: number, h: number, sidebar: boolean) => | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The session test helper duplicates the exact width formula (including the magic sidebar width 42) that lives inline in routes/session/index.tsx:275. If the sidebar width or content-column math changes in the component, this mirror silently diverges and the #1067 pin no longer guards the real path. Consider exporting the sidebar width/formula from welcome-panel-utils (as was done for PANEL_HORIZONTAL_PADDING) and importing it in both the component and this test so they stay in sync. Prompt for AI agents |
||
| welcomePanelVariant(w - (sidebar ? 42 : 0) - PANEL_HORIZONTAL_PADDING, h - SESSION_VERTICAL_RESERVE) | ||
|
|
||
| test("full requires BOTH width and height to clear the full floor", () => { | ||
| expect(welcomePanelVariant(WIDE, TALL)).toBe("full") | ||
| expect(welcomePanelVariant(FULL_MIN_WIDTH, FULL_MIN_HEIGHT)).toBe("full") // exactly at the floor | ||
|
|
@@ -42,20 +49,36 @@ test("compact→medium boundary is exact (at the floor is medium)", () => { | |
| }) | ||
|
|
||
| test("everyday terminals get medium, not the oversized wordmark", () => { | ||
| // Inputs are AVAILABLE size (terminal minus padding/sidebar on width, minus | ||
| // PANEL_VERTICAL_RESERVE on height). A 106x31 terminal → ~(102, 23): | ||
| expect(welcomePanelVariant(102, 23)).toBe("medium") | ||
| // 80x24 terminal → ~(76, 16) — medium exactly at the height floor: | ||
| expect(welcomePanelVariant(76, 16)).toBe("medium") | ||
| expect(home(106, 31)).toBe("medium") | ||
| expect(home(80, 24)).toBe("medium") | ||
| // #1067 session case: a 130-col terminal with the 42-col sidebar leaves ~84 | ||
| // usable cols → medium (was wrongly full when it used the whole terminal width). | ||
| expect(welcomePanelVariant(130 - 42 - 4, 50 - PANEL_VERTICAL_RESERVE)).toBe("medium") | ||
| expect(session(130, 50, true)).toBe("medium") | ||
| }) | ||
|
|
||
| test("the classic 80x24 is medium on both routes, with margin off the compact floor", () => { | ||
| // The review flagged 80x24 sitting on the exact medium floor; it now clears it | ||
| // on both routes (home reserves more chrome, so it's the tighter one). | ||
| expect(home(80, 24)).toBe("medium") | ||
| expect(session(80, 24, false)).toBe("medium") | ||
| }) | ||
|
|
||
| test("full engages on a large window; ~one row below the floor stays medium", () => { | ||
| expect(home(120, 44)).toBe("full") // FULL_MIN_HEIGHT(34) + HOME_VERTICAL_RESERVE(10) | ||
| expect(home(120, 43)).toBe("medium") | ||
| }) | ||
|
|
||
| test("toggling the session sidebar flips the panel full → medium on a wide window (#1067)", () => { | ||
| // The exact regression #1067 reports: on a wide window, opening the 42-col | ||
| // sidebar must shrink the panel out of `full` — it no longer has ~110 usable cols. | ||
| expect(session(150, 50, false)).toBe("full") | ||
| expect(session(150, 50, true)).toBe("medium") | ||
| }) | ||
|
|
||
| test("a short terminal drops to compact once prompt/footer chrome is reserved (#1067 height)", () => { | ||
| // 120x22: wide, but only ~14 usable rows after the ~8-row chrome → compact, | ||
| // where the raw terminal height (22) would have picked medium. | ||
| expect(welcomePanelVariant(120 - 4, 22 - PANEL_VERTICAL_RESERVE)).toBe("compact") | ||
| test("a short terminal drops to compact once the route's chrome is reserved (#1067 height)", () => { | ||
| // 120x22: wide, but too few usable rows after the home chrome → compact, where | ||
| // the raw terminal height (22) would have picked medium. | ||
| expect(home(120, 22)).toBe("compact") | ||
| }) | ||
|
|
||
| test("degenerate sizes collapse to compact", () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The padding centralization is incomplete: PANEL_HORIZONTAL_PADDING is used at the home call site, but the session route's contentWidth still hardcodes the bare
- 4rather than referencing the constant (the new doc comment even acknowledges session "applies the same 4 as part of its own content-column math"). If this constant ever changes, the session width math won't follow and drifts out of sync; consider having session/index.tsx import PANEL_HORIZONTAL_PADDING so both routes share one source of truth.Prompt for AI agents