Skip to content

Commit 03b9459

Browse files
fix(tui): make the welcome panel responsive to terminal size (#1067) (#1069)
* fix(tui): make the welcome panel responsive to terminal size (#1067) The full two-column boot box (block wordmark + description) is ~65 cols wide and ~13 rows tall, so on a typical terminal it ate ~40-50% of the screen with no way to shrink it (#1067). It now scales by terminal size, using the repo's breakpoint idiom (useTerminalDimensions + createMemo, cf. routes/session/permission.tsx, component/upgrade-indicator.tsx) — reactive, so it adapts live on resize: - full — the two-column wordmark box, reserved for large windows (>=110w & >=44h) - medium — title + one condensed line, no wordmark (the common case, ~6 rows) - compact — a single line; the border title already shows the version (<60w or <18h) The breakpoint decision is a pure function in welcome-panel-utils.ts (mirroring upgrade-indicator-utils.ts) so it's unit-testable without the render/sync context; 4 tests cover the thresholds and that the smaller dimension wins. Scope: responsiveness only — no dismiss/collapse behavior change. Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(tui): size welcome panel from available width+height; strengthen tests (#1069 review) Blocker 1 — the breakpoint read the whole terminal, but the panel never gets it. The home slot pads it and the session view puts it in a content column beside a 42-col sidebar, so `full` was still chosen at ~84 usable cols and swelled back to ~44% (the #1067 bug). WelcomePanel now takes `availableWidth`/`availableHeight`; home passes `width-4` / `height-PANEL_VERTICAL_RESERVE`, session passes the existing `contentWidth()` (already minus sidebar+padding) / `height-RESERVE`. Falls back to the terminal dimension when omitted. Reactive to resize AND sidebar toggle. Height gets the same treatment: subtract the fixed prompt/footer chrome (PANEL_VERTICAL_RESERVE = 8) so a short window drops to a smaller variant instead of a too-tall panel that crowds the prompt. Thresholds re-expressed in usable terms (MEDIUM_MIN_HEIGHT 16, FULL_MIN_HEIGHT 36) — full still engages at a ~44-row terminal; ≤~23 rows now → compact. Blocker 2 — the tests didn't prove the width gate (deleting `width < …` left them green). Rewrote to isolate each gate on one axis (e.g. `(FULL_MIN_WIDTH-1, tall) -> medium`), plus exact boundaries, the sidebar case, a short-terminal height case, and degenerate `(0,0)/(1,1)`. Also from review: - Rename `*_MAX_*` -> `MEDIUM_MIN_*` / `FULL_MIN_*` — floors matched with strict `<`. - `<Switch>/<Match>` instead of three memos + three `<Show>`. - Dedupe the CTA into a `CONNECT_CTA` constant. - Trim the full left column 65 -> 54 (logo is ~50 cols) so `full` engages sooner. - Shorten the medium description to one line. - Consistent "~13-row bordered box" framing in the comments. FULL_MIN_HEIGHT stays tuned so the wordmark shows only on large windows (product choice). Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
1 parent 8ae6c02 commit 03b9459

5 files changed

Lines changed: 242 additions & 57 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Pure breakpoint logic for WelcomePanel, split out (like upgrade-indicator-utils)
2+
// so it's unit-testable without the component's render/context dependencies.
3+
//
4+
// The full two-column boot box (block wordmark + description) is a ~13-row
5+
// bordered box, so on a typical terminal it eats ~40% of the screen with no way
6+
// to shrink it (issue #1067). We scale it down by the space the panel ACTUALLY
7+
// has on both axes:
8+
// - width: the terminal minus the caller's padding and any sibling sidebar.
9+
// - height: the terminal minus the fixed chrome that always shares the column
10+
// with the panel (top spacer + prompt + footer), so a big panel is
11+
// chosen only when it won't crowd the prompt off a short terminal.
12+
// `medium` (no wordmark) is the common case; `full` only when there's real room.
13+
//
14+
// Naming: these are the MINIMUMS a tier requires, matched with strict `<`
15+
// (`width < FULL_MIN_WIDTH` → not full). MEDIUM_MIN_* is the floor for medium
16+
// (below → compact); FULL_MIN_* is the floor for full (below → medium). All in
17+
// terms of AVAILABLE (usable) size, not the raw terminal.
18+
19+
export type WelcomePanelVariant = "full" | "medium" | "compact"
20+
21+
/**
22+
* Rows the panel must leave for the always-present chrome below/around it (the
23+
* prompt, the footer, and the home top spacer). Callers subtract this from the
24+
* terminal height to get the panel's usable height. An estimate — the prompt can
25+
* grow with multi-line input, but at rest this is the fixed cost.
26+
*/
27+
export const PANEL_VERTICAL_RESERVE = 8
28+
29+
/** Minimum usable size for the medium panel; below either → compact (one line). */
30+
export const MEDIUM_MIN_WIDTH = 60
31+
export const MEDIUM_MIN_HEIGHT = 16
32+
/** Minimum usable size for the full wordmark panel; below either → medium. */
33+
export const FULL_MIN_WIDTH = 110
34+
export const FULL_MIN_HEIGHT = 36
35+
36+
/**
37+
* Choose the WelcomePanel layout from the panel's AVAILABLE size — width already
38+
* minus padding/sidebar, height already minus PANEL_VERTICAL_RESERVE. Not the
39+
* raw terminal (that's the #1067 bug: a sidebar-narrowed column, or a short
40+
* terminal, would still pick `full`).
41+
*/
42+
export function welcomePanelVariant(width: number, height: number): WelcomePanelVariant {
43+
if (width < MEDIUM_MIN_WIDTH || height < MEDIUM_MIN_HEIGHT) return "compact"
44+
if (width < FULL_MIN_WIDTH || height < FULL_MIN_HEIGHT) return "medium"
45+
return "full"
46+
}
Lines changed: 116 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,139 @@
1-
import { Show } from "solid-js"
1+
import { Match, Show, Switch, createMemo } from "solid-js"
22
import { TextAttributes } from "@opentui/core"
3+
import { useTerminalDimensions } from "@opentui/solid"
34
import { useTheme } from "../context/theme"
45
import { Logo } from "./logo"
56
import { InstallationVersion } from "@opencode-ai/core/installation/version"
67
import { useReady } from "./altimate-onboarding"
8+
import { welcomePanelVariant } from "./welcome-panel-utils"
79

8-
// altimate_change — Claude-Code-style full-width boot box: big block wordmark on
9-
// the left and a single "What is Altimate Code" section on the right. Shared
10-
// between the home route and the session view so the header stays consistent
11-
// when a command (e.g. /discover) starts a session. zIndex keeps it above
12-
// transient top toasts (update/MCP) that would otherwise blank its top rows.
13-
export function WelcomePanel() {
10+
const CONNECT_CTA = "Connect your AI model to start."
11+
12+
// altimate_change — Claude-Code-style boot box: "What is Altimate Code" plus the
13+
// readiness-aware CTA. Shared between the home route and the session view so the
14+
// header stays consistent when a command (e.g. /discover) starts a session.
15+
// zIndex keeps it above transient top toasts (update/MCP) that would otherwise
16+
// blank its top rows.
17+
//
18+
// Responsive (issue #1067): the full two-column boot box is a ~13-row bordered
19+
// box that ate ~40% of the screen. It now scales down by AVAILABLE size,
20+
// following the repo's breakpoint idiom (createMemo over useTerminalDimensions,
21+
// cf. routes/session/permission.tsx:450, component/upgrade-indicator.tsx:14):
22+
// full — wordmark + full description (large windows only)
23+
// medium — title + one condensed line, no wordmark (the common case)
24+
// compact — a short line; the border title already carries the version
25+
//
26+
// `availableWidth` / `availableHeight` are the space the panel actually gets, not
27+
// the whole terminal — the caller subtracts its padding, any sibling sidebar
28+
// (session's contentWidth), and the fixed prompt/footer chrome
29+
// (PANEL_VERTICAL_RESERVE). Using the raw terminal would keep `full` selected in
30+
// a sidebar-narrowed column or a short window and swell the panel back up — the
31+
// bug #1067 is about. Both fall back to the terminal dimension when omitted.
32+
export function WelcomePanel(props: { availableWidth?: number; availableHeight?: number }) {
1433
const { theme } = useTheme()
1534
const ready = useReady()
35+
const dimensions = useTerminalDimensions()
36+
37+
const variant = createMemo(() =>
38+
welcomePanelVariant(props.availableWidth ?? dimensions().width, props.availableHeight ?? dimensions().height),
39+
)
40+
41+
const title = InstallationVersion === "local" ? " Altimate Code " : ` Altimate Code v${InstallationVersion} `
42+
1643
return (
1744
<box
1845
border
1946
borderStyle="rounded"
2047
borderColor={theme.border}
21-
title={InstallationVersion === "local" ? " Altimate Code " : ` Altimate Code v${InstallationVersion} `}
48+
title={title}
2249
titleAlignment="left"
2350
flexShrink={0}
2451
width="100%"
2552
zIndex={2000}
2653
backgroundColor={theme.background}
27-
flexDirection="row"
54+
flexDirection="column"
2855
>
29-
{/* left column — the block-letter wordmark (59 cols wide) */}
30-
<box
31-
width={65}
32-
flexShrink={0}
33-
alignItems="center"
34-
justifyContent="center"
35-
gap={1}
36-
paddingTop={1}
37-
paddingBottom={1}
38-
paddingLeft={1}
39-
>
40-
<text fg={theme.text} attributes={TextAttributes.BOLD}>
41-
Welcome to Altimate Code
42-
</text>
43-
<Logo />
44-
</box>
45-
{/* right column — tips + what-is sections */}
46-
<box
47-
flexGrow={1}
48-
border={["left"]}
49-
borderColor={theme.border}
50-
paddingLeft={2}
51-
paddingRight={2}
52-
paddingTop={1}
53-
paddingBottom={1}
54-
gap={1}
55-
>
56-
<box gap={0}>
57-
<text fg={theme.accent} attributes={TextAttributes.BOLD}>
58-
What is Altimate Code
59-
</text>
60-
<text fg={theme.text} wrapMode="word" width="100%">
61-
Altimate Code is a specialized data engineering harness that sits between any LLM and your entire data
62-
stack.
63-
</text>
64-
<text fg={theme.text} wrapMode="word" width="100%">
65-
It gives your AI real context — column-level lineage, SQL analysis, dbt, and live warehouse metadata — so it
66-
reasons about your data instead of guessing.
67-
</text>
68-
{/* CTA only until a model is connected — stale afterwards */}
69-
<Show when={!ready()}>
70-
<text fg={theme.primary} wrapMode="word" width="100%">
71-
Connect your AI model to start.
56+
<Switch>
57+
{/* compact — a short line; the border title already carries the version.
58+
wrapMode keeps it readable if the terminal is extremely narrow. */}
59+
<Match when={variant() === "compact"}>
60+
<box paddingLeft={2} paddingRight={2} width="100%">
61+
<text fg={ready() ? theme.text : theme.primary} wrapMode="word" width="100%">
62+
{ready() ? "Your data-aware AI harness." : CONNECT_CTA}
7263
</text>
73-
</Show>
74-
</box>
75-
</box>
64+
</box>
65+
</Match>
66+
67+
{/* medium — title + one condensed description + CTA, no block wordmark */}
68+
<Match when={variant() === "medium"}>
69+
<box paddingLeft={2} paddingRight={2} paddingTop={1} paddingBottom={1} gap={0} width="100%">
70+
<text fg={theme.text} attributes={TextAttributes.BOLD}>
71+
Welcome to Altimate Code
72+
</text>
73+
<text fg={theme.text} wrapMode="word" width="100%">
74+
Gives your AI real context on your data stack — lineage, SQL, dbt, and live warehouse metadata.
75+
</text>
76+
<Show when={!ready()}>
77+
<text fg={theme.primary} wrapMode="word" width="100%">
78+
{CONNECT_CTA}
79+
</text>
80+
</Show>
81+
</box>
82+
</Match>
83+
84+
{/* full — the original two-column boot box */}
85+
<Match when={variant() === "full"}>
86+
<box flexDirection="row" width="100%">
87+
{/* left column — the block-letter wordmark (logo is ~50 cols) */}
88+
<box
89+
width={54}
90+
flexShrink={0}
91+
alignItems="center"
92+
justifyContent="center"
93+
gap={1}
94+
paddingTop={1}
95+
paddingBottom={1}
96+
paddingLeft={1}
97+
>
98+
<text fg={theme.text} attributes={TextAttributes.BOLD}>
99+
Welcome to Altimate Code
100+
</text>
101+
<Logo />
102+
</box>
103+
{/* right column — what-is section */}
104+
<box
105+
flexGrow={1}
106+
border={["left"]}
107+
borderColor={theme.border}
108+
paddingLeft={2}
109+
paddingRight={2}
110+
paddingTop={1}
111+
paddingBottom={1}
112+
gap={1}
113+
>
114+
<box gap={0}>
115+
<text fg={theme.accent} attributes={TextAttributes.BOLD}>
116+
What is Altimate Code
117+
</text>
118+
<text fg={theme.text} wrapMode="word" width="100%">
119+
Altimate Code is a specialized data engineering harness that sits between any LLM and your entire data
120+
stack.
121+
</text>
122+
<text fg={theme.text} wrapMode="word" width="100%">
123+
It gives your AI real context — column-level lineage, SQL analysis, dbt, and live warehouse metadata —
124+
so it reasons about your data instead of guessing.
125+
</text>
126+
{/* CTA only until a model is connected — stale afterwards */}
127+
<Show when={!ready()}>
128+
<text fg={theme.primary} wrapMode="word" width="100%">
129+
{CONNECT_CTA}
130+
</text>
131+
</Show>
132+
</box>
133+
</box>
134+
</box>
135+
</Match>
136+
</Switch>
76137
</box>
77138
)
78139
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { useTheme } from "../context/theme"
1919
// one-line "Get started: /connect ... /discover ..." hint below, which duplicated the
2020
// same guidance the panel's "Tips for getting started" section now covers.
2121
import { WelcomePanel } from "../component/welcome-panel"
22+
import { PANEL_VERTICAL_RESERVE } from "../component/welcome-panel-utils"
2223
// altimate_change end
2324

2425
let once = false
@@ -108,7 +109,13 @@ export function Home() {
108109
<box height={2} flexShrink={0} />
109110
<box width="100%" flexShrink={0}>
110111
<pluginRuntime.Slot name="home_logo" mode="replace">
111-
<WelcomePanel />
112+
{/* Size to the panel's real space, not the whole terminal (#1067):
113+
-4 for this column's paddingLeft/Right; -PANEL_VERTICAL_RESERVE for
114+
the top spacer + prompt + footer that share the height. */}
115+
<WelcomePanel
116+
availableWidth={dimensions().width - 4}
117+
availableHeight={dimensions().height - PANEL_VERTICAL_RESERVE}
118+
/>
112119
</pluginRuntime.Slot>
113120
</box>
114121
<box flexGrow={1} minHeight={0} />

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { useTuiPaths, useTuiTerminalEnvironment } from "../../context/runtime"
2626
import { Spinner } from "../../component/spinner"
2727
// altimate_change — shared boot box at the top of the session scrollback
2828
import { WelcomePanel } from "../../component/welcome-panel"
29+
import { PANEL_VERTICAL_RESERVE } from "../../component/welcome-panel-utils"
2930
import { createSyntaxStyleMemo, generateSubtleSyntax, selectedForeground, useTheme } from "../../context/theme"
3031
import { BoxRenderable, ScrollBoxRenderable, addDefaultParsers, TextAttributes, RGBA } from "@opentui/core"
3132
import { Prompt, type PromptRef } from "../../component/prompt"
@@ -1186,7 +1187,13 @@ export function Session() {
11861187
/discover) starts a session. Outside the scrollbox: the bordered panel
11871188
does not paint reliably inside the scroll viewport. */}
11881189
<box flexShrink={0}>
1189-
<WelcomePanel />
1190+
{/* Size to the panel's real space, not the terminal (#1067):
1191+
contentWidth already subtracts the sidebar + padding;
1192+
-PANEL_VERTICAL_RESERVE leaves room for the prompt + footer. */}
1193+
<WelcomePanel
1194+
availableWidth={contentWidth()}
1195+
availableHeight={dimensions().height - PANEL_VERTICAL_RESERVE}
1196+
/>
11901197
</box>
11911198
{/* altimate_change end */}
11921199
<scrollbox
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { expect, test } from "bun:test"
2+
import {
3+
FULL_MIN_HEIGHT,
4+
FULL_MIN_WIDTH,
5+
MEDIUM_MIN_HEIGHT,
6+
MEDIUM_MIN_WIDTH,
7+
PANEL_VERTICAL_RESERVE,
8+
welcomePanelVariant,
9+
} from "../../src/component/welcome-panel-utils"
10+
11+
// Comfortably above the full floor on one axis, used to isolate the OTHER axis
12+
// so a single gate's removal is provable (each test below fails if its `<` check
13+
// is deleted from the source).
14+
const TALL = FULL_MIN_HEIGHT + 10
15+
const WIDE = FULL_MIN_WIDTH + 20
16+
17+
test("full requires BOTH width and height to clear the full floor", () => {
18+
expect(welcomePanelVariant(WIDE, TALL)).toBe("full")
19+
expect(welcomePanelVariant(FULL_MIN_WIDTH, FULL_MIN_HEIGHT)).toBe("full") // exactly at the floor
20+
})
21+
22+
test("full's width gate is real — width one below the floor drops to medium even when tall", () => {
23+
expect(welcomePanelVariant(FULL_MIN_WIDTH - 1, TALL)).toBe("medium")
24+
})
25+
26+
test("full's height gate is real — height one below the floor drops to medium even when wide", () => {
27+
expect(welcomePanelVariant(WIDE, FULL_MIN_HEIGHT - 1)).toBe("medium")
28+
})
29+
30+
test("compact's width gate is real — width one below the medium floor is compact even when tall", () => {
31+
expect(welcomePanelVariant(MEDIUM_MIN_WIDTH - 1, TALL)).toBe("compact")
32+
})
33+
34+
test("compact's height gate is real — height one below the medium floor is compact even when wide", () => {
35+
expect(welcomePanelVariant(WIDE, MEDIUM_MIN_HEIGHT - 1)).toBe("compact")
36+
})
37+
38+
test("compact→medium boundary is exact (at the floor is medium)", () => {
39+
expect(welcomePanelVariant(MEDIUM_MIN_WIDTH, MEDIUM_MIN_HEIGHT)).toBe("medium")
40+
expect(welcomePanelVariant(MEDIUM_MIN_WIDTH, TALL)).toBe("medium")
41+
expect(welcomePanelVariant(WIDE, MEDIUM_MIN_HEIGHT)).toBe("medium")
42+
})
43+
44+
test("everyday terminals get medium, not the oversized wordmark", () => {
45+
// Inputs are AVAILABLE size (terminal minus padding/sidebar on width, minus
46+
// PANEL_VERTICAL_RESERVE on height). A 106x31 terminal → ~(102, 23):
47+
expect(welcomePanelVariant(102, 23)).toBe("medium")
48+
// 80x24 terminal → ~(76, 16) — medium exactly at the height floor:
49+
expect(welcomePanelVariant(76, 16)).toBe("medium")
50+
// #1067 session case: a 130-col terminal with the 42-col sidebar leaves ~84
51+
// usable cols → medium (was wrongly full when it used the whole terminal width).
52+
expect(welcomePanelVariant(130 - 42 - 4, 50 - PANEL_VERTICAL_RESERVE)).toBe("medium")
53+
})
54+
55+
test("a short terminal drops to compact once prompt/footer chrome is reserved (#1067 height)", () => {
56+
// 120x22: wide, but only ~14 usable rows after the ~8-row chrome → compact,
57+
// where the raw terminal height (22) would have picked medium.
58+
expect(welcomePanelVariant(120 - 4, 22 - PANEL_VERTICAL_RESERVE)).toBe("compact")
59+
})
60+
61+
test("degenerate sizes collapse to compact", () => {
62+
expect(welcomePanelVariant(0, 0)).toBe("compact")
63+
expect(welcomePanelVariant(1, 1)).toBe("compact")
64+
})

0 commit comments

Comments
 (0)