Skip to content

Commit 9e27ac3

Browse files
committed
Derive the list-view chrome budget instead of guessing it
listHeight() used a flat constant for the rows above and below the pick-list, re-guessed by hand whenever a row was added or removed. Compute it from the same building blocks the tree is made of instead: the seven always-visible single-line rows, root and listBox padding, the summary box's per-step rows, and the telemetry notice when shown.
1 parent dd66dad commit 9e27ac3

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/tui-opentui/provider-setup.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -645,13 +645,20 @@ export async function runProviderSetup(
645645
})
646646

647647
function listHeight(): number {
648-
// Fixed chrome above the list: root padding, header, intro, step,
649-
// instruction, one populated summary row, and the list box's own
650-
// padding — plus the footer below it, and slack for a long label
651-
// wrapping onto a second terminal row. A tighter budget than the old
652-
// flat -14 so the list actually uses the room a short terminal leaves it
653-
// instead of reserving rows nothing else needs and sitting short.
654-
const chromeRows = 12
648+
// Every row root carries besides listBox itself, during the steps where
649+
// the list is shown (provider pick, or model pick for preset/oauth):
650+
// loginBox and inputFrame are hidden then, so they cost nothing.
651+
const singleLineRows = 7 // header, intro, step, instruction, statusLine, guidance, footer
652+
const rootPadding = 1
653+
const listBoxPadding = 1
654+
// summary always renders one row per step in the active flow (values
655+
// filled in as "done", the rest as "—"); PRESET_STEPS and OAUTH_STEPS
656+
// are the only flows whose model/provider steps show the list, and both
657+
// are the same length today, so take the max in case that changes.
658+
const summaryRows = 1 + Math.max(PRESET_STEPS.length, OAUTH_STEPS.length)
659+
const telemetryRows = config.showTelemetryNotice ? 1 + TELEMETRY_ROWS : 0
660+
const chromeRows =
661+
rootPadding + singleLineRows + summaryRows + listBoxPadding + telemetryRows
655662
const rows = renderer.height || 24
656663
return Math.max(LIST_ROWS_MIN, Math.min(LIST_ROWS_MAX, rows - chromeRows))
657664
}

0 commit comments

Comments
 (0)