@f5-sales-demo/xcsh 21.23.0 → 21.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@f5-sales-demo/xcsh",
4
- "version": "21.23.0",
4
+ "version": "21.24.0",
5
5
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
6
6
  "homepage": "https://github.com/f5-sales-demo/xcsh",
7
7
  "author": "Can Boluk",
@@ -62,13 +62,13 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "@agentclientprotocol/sdk": "1.3.0",
65
- "@f5-sales-demo/pi-agent-core": "21.23.0",
66
- "@f5-sales-demo/pi-ai": "21.23.0",
67
- "@f5-sales-demo/pi-natives": "21.23.0",
68
- "@f5-sales-demo/pi-resource-management": "21.23.0",
69
- "@f5-sales-demo/pi-tui": "21.23.0",
70
- "@f5-sales-demo/pi-utils": "21.23.0",
71
- "@f5-sales-demo/xcsh-stats": "21.23.0",
65
+ "@f5-sales-demo/pi-agent-core": "21.24.0",
66
+ "@f5-sales-demo/pi-ai": "21.24.0",
67
+ "@f5-sales-demo/pi-natives": "21.24.0",
68
+ "@f5-sales-demo/pi-resource-management": "21.24.0",
69
+ "@f5-sales-demo/pi-tui": "21.24.0",
70
+ "@f5-sales-demo/pi-utils": "21.24.0",
71
+ "@f5-sales-demo/xcsh-stats": "21.24.0",
72
72
  "@mozilla/readability": "^0.6",
73
73
  "@sinclair/typebox": "^0.34",
74
74
  "@xterm/headless": "^6.0",
@@ -17,17 +17,17 @@ export interface BuildInfo {
17
17
  }
18
18
 
19
19
  export const BUILD_INFO: BuildInfo = {
20
- "version": "21.23.0",
21
- "commit": "e6cb511dd988d7f63fb36a51801cea40a16d7872",
22
- "shortCommit": "e6cb511",
20
+ "version": "21.24.0",
21
+ "commit": "4e12e53d3f6e7085c345d9426f7252b03ac6dbfd",
22
+ "shortCommit": "4e12e53",
23
23
  "branch": "main",
24
- "tag": "v21.23.0",
25
- "commitDate": "2026-09-10T05:22:02+00:00",
26
- "buildDate": "2026-09-10T12:54:48.742Z",
24
+ "tag": "v21.24.0",
25
+ "commitDate": "2026-09-10T16:54:10+00:00",
26
+ "buildDate": "2026-09-10T17:36:28.538Z",
27
27
  "dirty": true,
28
28
  "prNumber": "",
29
29
  "repoUrl": "https://github.com/f5-sales-demo/xcsh",
30
30
  "repoSlug": "f5-sales-demo/xcsh",
31
- "commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/e6cb511dd988d7f63fb36a51801cea40a16d7872",
32
- "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.23.0"
31
+ "commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/4e12e53d3f6e7085c345d9426f7252b03ac6dbfd",
32
+ "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.24.0"
33
33
  };
@@ -28,8 +28,10 @@ import { getProviderDisplayName } from "../controllers/provider-presentation";
28
28
  import { getTabBarTheme } from "../shared";
29
29
  import {
30
30
  matchesSelectorKey,
31
+ type SelectorFrameLine,
31
32
  selectorCancelHint,
32
33
  selectorFrame,
34
+ selectorFrameContentWidth,
33
35
  selectorKeys,
34
36
  selectorNavigationHint,
35
37
  selectorRow,
@@ -417,7 +419,7 @@ export class ModelSelectorComponent extends Container {
417
419
  }
418
420
  override render(width: number): string[] {
419
421
  const height = this.#tui.terminal?.rows ?? 24;
420
- const inner = Math.min(100, width) - 6;
422
+ const inner = selectorFrameContentWidth(width);
421
423
  const selected = this.#menuItem ?? this.#getSelectedItem();
422
424
  const wide = width >= 80;
423
425
  const searching = Boolean(this.#searchInput.getValue().trim());
@@ -432,8 +434,11 @@ export class ModelSelectorComponent extends Container {
432
434
  : [],
433
435
  ),
434
436
  ].join(", ") || "Unassigned";
435
- let body: string[] = [];
436
- const details: string[] = selected ? [selected.selector] : [];
437
+ let body: SelectorFrameLine[] = [];
438
+ let selectedBodyIndex: number | undefined;
439
+ let stickyBodyRows = 0;
440
+ let minimumDetailRows = 0;
441
+ const details: string[] = selected ? wrapTextWithAnsi(selected.selector, inner) : [];
437
442
  let navigation: string[] = [];
438
443
  let title = "Choose a model";
439
444
  let purpose = "Choose a model, scope and reasoning.";
@@ -455,11 +460,8 @@ export class ModelSelectorComponent extends Container {
455
460
  : this.#menuStep === "scope"
456
461
  ? "Choose where this model applies."
457
462
  : "Choose a specialist role.";
458
- const budget = Math.max(1, height - 10);
459
- const start = Math.max(0, this.#menuSelectedIndex - budget + 1);
460
- body = labels
461
- .slice(start, start + budget)
462
- .map((label, i) => selectorRow([label], [inner], start + i === this.#menuSelectedIndex));
463
+ body = labels.map((label, i) => selectorRow([label], [inner - 2], i === this.#menuSelectedIndex));
464
+ selectedBodyIndex = this.#menuSelectedIndex;
463
465
  if (this.#menuStep === "scope")
464
466
  details.push(
465
467
  [
@@ -477,7 +479,7 @@ export class ModelSelectorComponent extends Container {
477
479
  ];
478
480
  } else {
479
481
  navigation = [
480
- ...(this.#tabBar?.render(Math.min(100, width) - 4) ?? []).slice(0, 2),
482
+ ...(this.#tabBar?.render(inner) ?? []).slice(0, 2),
481
483
  "Search all providers",
482
484
  ...this.#searchInput.render(inner),
483
485
  ];
@@ -488,27 +490,35 @@ export class ModelSelectorComponent extends Container {
488
490
  if (selected) {
489
491
  details.push(...wrapTextWithAnsi(assignments(selected.model, true), inner));
490
492
  if (this.#isItemDisabled(selected)) details.push("Unavailable · reconnect or refresh this provider.");
491
- else details.push(selected.model.description ?? "");
493
+ else if (selected.model.description) details.push(...wrapTextWithAnsi(selected.model.description, inner));
492
494
  }
495
+ // Two live-status rows are intentional reserved space; spinner/error updates must not shift the table.
496
+ minimumDetailRows = details.length + 2;
493
497
  const selectedStatus = selected
494
498
  ? this.#renderProviderStatus(inner).find(line =>
495
499
  line.includes(`${getProviderDisplayName(selected.model.provider)}:`),
496
500
  )
497
501
  : undefined;
498
- details.push(status[0] ?? "");
499
- details.push(selectedStatus && selectedStatus !== status[0] ? selectedStatus : "");
502
+ if (status[0]) details.push(status[0]);
503
+ if (selectedStatus && selectedStatus !== status[0]) details.push(selectedStatus);
500
504
  if (this.#errorMessage) details.push(String(this.#errorMessage));
501
- const budget = Math.max(1, height - navigation.length - details.length - footer.length - 5 - (wide ? 1 : 0));
502
- const start = Math.max(0, Math.min(this.#selectedIndex - budget + 1, this.#filteredModels.length - budget));
503
505
  const showProvider = searching;
504
- const widths = showProvider ? [inner - 40, 18, 18] : [inner - 22, 20];
505
- if (wide)
506
+ const widths = showProvider ? [inner - 42, 18, 18] : [inner - 24, 20];
507
+ if (wide) {
506
508
  body.push(
507
- selectorRow(showProvider ? ["Model", "Provider", "Assignment"] : ["Model", "Assignment"], widths),
509
+ selectorRow(
510
+ showProvider ? ["Model", "Provider", "Assignment"] : ["Model", "Assignment"],
511
+ widths,
512
+ false,
513
+ "muted",
514
+ ),
508
515
  );
509
- for (let i = start; i < Math.min(start + budget, this.#filteredModels.length); i++) {
516
+ stickyBodyRows = 1;
517
+ }
518
+ for (let i = 0; i < this.#filteredModels.length; i++) {
510
519
  const item = this.#filteredModels[i];
511
520
  const assignment = this.#isItemDisabled(item) ? "Unavailable" : assignments(item.model);
521
+ if (i === this.#selectedIndex) selectedBodyIndex = body.length;
512
522
  body.push(
513
523
  selectorRow(
514
524
  wide
@@ -516,14 +526,18 @@ export class ModelSelectorComponent extends Container {
516
526
  ? [getModelDisplayName(item.model), getProviderDisplayName(item.provider), assignment]
517
527
  : [getModelDisplayName(item.model), assignment]
518
528
  : [getModelDisplayName(item.model)],
519
- wide ? widths : [inner],
529
+ wide ? widths : [inner - 2],
520
530
  i === this.#selectedIndex,
521
531
  ),
522
532
  );
523
533
  }
524
534
  if (!this.#filteredModels.length) body.push(this.#getProviderEmptyStateMessage() ?? "No matching models");
525
535
  }
526
- return selectorFrame(width, height, title, purpose, navigation, body, details, footer);
536
+ return selectorFrame(width, height, title, purpose, navigation, body, details, footer, {
537
+ minimumDetailRows,
538
+ selectedBodyIndex,
539
+ stickyBodyRows,
540
+ });
527
541
  }
528
542
 
529
543
  #stopSpinner(): void {
@@ -7,8 +7,10 @@ import { getLoginOptions, type LoginOption } from "../controllers/login-options"
7
7
  import { providerPresentation } from "../controllers/provider-presentation";
8
8
  import {
9
9
  matchesSelectorKey,
10
+ type SelectorFrameLine,
10
11
  selectorCancelHint,
11
12
  selectorFrame,
13
+ selectorFrameContentWidth,
12
14
  selectorNavigationHint,
13
15
  selectorRow,
14
16
  } from "./selector-frame";
@@ -240,7 +242,7 @@ export class OAuthSelectorComponent extends Container {
240
242
  }
241
243
  const access = this.#getCombinedAccess(provider);
242
244
  if (state.includes("invalid") || access?.status === "reauth-required") {
243
- return access?.credentialSource === "stored-oauth" ? "Sign-in required" : "Sign-in required";
245
+ return "Sign-in required";
244
246
  }
245
247
  if (access?.status === "unreachable") return "Unreachable";
246
248
  if (
@@ -251,7 +253,7 @@ export class OAuthSelectorComponent extends Container {
251
253
  )
252
254
  return "No models returned";
253
255
  if (access?.status === "connected") {
254
- return access.credentialSource === "keyless" ? "Ready" : "Ready";
256
+ return "Ready";
255
257
  }
256
258
  if (state.includes("valid")) return "Ready";
257
259
  if (access?.status === "configured-unverified") return "Credentials saved";
@@ -274,7 +276,7 @@ export class OAuthSelectorComponent extends Container {
274
276
  }
275
277
  override render(width: number): string[] {
276
278
  const rows = this.#rows();
277
- const inner = Math.min(100, width) - 6;
279
+ const inner = selectorFrameContentWidth(width);
278
280
  const wide = width >= 80;
279
281
  const selected = this.#detailsProvider ?? this.#filteredProviders[this.#selectedIndex];
280
282
  const presentation = selected ? providerPresentation(selected.id) : undefined;
@@ -285,46 +287,47 @@ export class OAuthSelectorComponent extends Container {
285
287
  : this.#catalogMode
286
288
  ? "Connect a provider"
287
289
  : "Your providers";
288
- const details =
290
+ const details: string[] =
289
291
  selected?.action === "add-provider"
290
292
  ? [selected.description ?? "Search the full provider catalog"]
291
293
  : selected
292
294
  ? [
293
295
  `${selected.id} · ${presentation?.access}`,
294
296
  this.#getStatusText(selected),
295
- selected.description ?? presentation?.description ?? "",
296
- ]
297
+ selected.description ?? presentation?.description,
298
+ ].filter((value): value is string => Boolean(value))
297
299
  : [];
298
- let body: string[] = [];
300
+ let body: SelectorFrameLine[] = [];
301
+ let selectedBodyIndex: number | undefined;
302
+ let stickyBodyRows = 0;
299
303
  if (this.#detailsProvider) {
300
- body = this.#managementActions().map((label, i) => selectorRow([label], [inner], i === this.#actionIndex));
304
+ body = this.#managementActions().map((label, i) => selectorRow([label], [inner - 2], i === this.#actionIndex));
305
+ selectedBodyIndex = this.#actionIndex;
301
306
  const access = this.#getCombinedAccess(this.#detailsProvider);
302
- details.push(
307
+ const verification =
303
308
  access?.failureReason ??
304
- (access?.lastCheckedAt
309
+ (access?.status === "connected"
310
+ ? undefined
311
+ : access?.lastCheckedAt
305
312
  ? "Connection checked; refresh from model selection with Ctrl+R."
306
- : "Live availability has not been verified."),
307
- );
313
+ : "Live availability has not been verified.");
314
+ if (verification) details.push(verification);
308
315
  if (this.#providerIds(this.#detailsProvider).every(id => this.#isExcluded?.(id)))
309
316
  details.push("Models hidden by the configured provider filter.");
310
317
  } else {
311
- const maxVisible = Math.max(
312
- 1,
313
- Math.min(10, Math.floor((rows - 13) / (this.#catalogMode && !this.#searchInput.getValue() ? 2 : 1))),
314
- );
315
- const start = Math.max(
316
- 0,
317
- Math.min(this.#selectedIndex - maxVisible + 1, this.#filteredProviders.length - maxVisible),
318
- );
319
- if (wide) body.push(selectorRow(["Provider", "Access", "Status"], [inner - 40, 16, 20]));
318
+ if (wide) {
319
+ body.push(selectorRow(["Provider", "Access", "Status"], [inner - 42, 16, 20], false, "muted"));
320
+ stickyBodyRows = 1;
321
+ }
320
322
  let category = "";
321
- for (let i = start; i < Math.min(start + maxVisible, this.#filteredProviders.length); i++) {
323
+ for (let i = 0; i < this.#filteredProviders.length; i++) {
322
324
  const provider = this.#filteredProviders[i];
323
325
  const meta = providerPresentation(provider.id);
324
326
  if (this.#catalogMode && !this.#searchInput.getValue() && meta.category !== category) {
325
327
  category = meta.category;
326
328
  body.push(theme.fg("muted", category));
327
329
  }
330
+ if (i === this.#selectedIndex) selectedBodyIndex = body.length;
328
331
  body.push(
329
332
  selectorRow(
330
333
  wide
@@ -334,7 +337,7 @@ export class OAuthSelectorComponent extends Container {
334
337
  this.#getStatusText(provider),
335
338
  ]
336
339
  : [provider.name],
337
- wide ? [inner - 40, 16, 20] : [inner],
340
+ wide ? [inner - 42, 16, 20] : [inner - 2],
338
341
  i === this.#selectedIndex,
339
342
  ),
340
343
  );
@@ -358,6 +361,7 @@ export class OAuthSelectorComponent extends Container {
358
361
  body,
359
362
  details,
360
363
  [selectorNavigationHint(), selectorCancelHint(this.#searchInput.getValue() ? "clear search" : "back")],
364
+ { selectedBodyIndex, stickyBodyRows },
361
365
  );
362
366
  }
363
367
 
@@ -8,6 +8,68 @@ import {
8
8
  } from "@f5-sales-demo/pi-tui";
9
9
  import { theme } from "../theme/theme";
10
10
 
11
+ export interface SelectorFrameRow {
12
+ content: string;
13
+ selected: boolean;
14
+ }
15
+
16
+ export type SelectorFrameLine = string | SelectorFrameRow;
17
+
18
+ export interface SelectorFrameOptions {
19
+ /** Index of the selected row in `body`; used to retain it when the frame is height-constrained. */
20
+ selectedBodyIndex?: number;
21
+ /** Leading body rows, such as table headings, that remain visible while the choices scroll. */
22
+ stickyBodyRows?: number;
23
+ /** Optional upper bound for body rows in otherwise tall terminals. */
24
+ maxBodyRows?: number;
25
+ /** Intentional stable detail area for asynchronous status updates. Empty caller entries are still discarded. */
26
+ minimumDetailRows?: number;
27
+ }
28
+
29
+ function selectorFrameColumns(width: number): number {
30
+ return Math.max(4, Math.min(100, width));
31
+ }
32
+
33
+ export function selectorFramePadding(width: number): number {
34
+ return selectorFrameColumns(width) >= 80 ? 2 : 1;
35
+ }
36
+
37
+ /** Width available to aligned headings, rows, details and controls inside the shared gutters. */
38
+ export function selectorFrameContentWidth(width: number): number {
39
+ const columns = selectorFrameColumns(width);
40
+ return Math.max(1, columns - 2 - selectorFramePadding(columns) * 2);
41
+ }
42
+
43
+ function hasVisibleContent(value: string): boolean {
44
+ return visibleWidth(value.replace(/[\r\n]+/g, "").trim()) > 0;
45
+ }
46
+
47
+ function normalizeLine(value: string): string {
48
+ return value.replace(/[\r\n]+/g, " · ");
49
+ }
50
+
51
+ function wrapSection(values: string[], width: number): string[] {
52
+ return values.flatMap(value => {
53
+ if (!hasVisibleContent(value)) return [];
54
+ return wrapTextWithAnsi(normalizeLine(value), width).filter(hasVisibleContent);
55
+ });
56
+ }
57
+
58
+ function windowBody(
59
+ body: SelectorFrameLine[],
60
+ visibleRows: number,
61
+ selectedIndex: number | undefined,
62
+ stickyRows: number,
63
+ ): SelectorFrameLine[] {
64
+ if (visibleRows <= 0) return [];
65
+ if (body.length <= visibleRows) return body;
66
+ const stickyCount = Math.min(stickyRows, visibleRows - 1, body.length);
67
+ const capacity = visibleRows - stickyCount;
68
+ const selected = Math.max(stickyCount, Math.min(selectedIndex ?? stickyCount, body.length - 1));
69
+ const start = Math.max(stickyCount, Math.min(selected - capacity + 1, body.length - capacity));
70
+ return [...body.slice(0, stickyCount), ...body.slice(start, start + capacity)];
71
+ }
72
+
11
73
  /** A single bounded frame shared by provider, model and connection choices. */
12
74
  export function selectorFrame(
13
75
  width: number,
@@ -15,45 +77,118 @@ export function selectorFrame(
15
77
  title: string,
16
78
  purpose: string,
17
79
  navigation: string[],
18
- body: string[],
80
+ body: SelectorFrameLine[],
19
81
  details: string[],
20
82
  footer: string[],
83
+ options: SelectorFrameOptions = {},
21
84
  ): string[] {
22
- const columns = Math.max(4, Math.min(100, width));
23
- const inner = columns - 4;
24
- const box = theme.boxSharp;
25
- const edge = theme.fg("border", box.vertical);
26
- const horizontal = theme.fg("border", box.horizontal.repeat(columns));
27
- const line = (value: string) => {
28
- const fitted = truncateToWidth(value.replace(/[\r\n]+/g, " · "), inner);
29
- return `${edge} ${fitted}${" ".repeat(Math.max(0, inner - visibleWidth(fitted)))} ${edge}`;
85
+ const columns = selectorFrameColumns(width);
86
+ const padding = selectorFramePadding(columns);
87
+ const contentWidth = selectorFrameContentWidth(columns);
88
+ const box = theme.boxRound;
89
+ const sharp = theme.boxSharp;
90
+ const border = (value: string) => theme.fg("border", value);
91
+ const edge = border(box.vertical);
92
+ const top = border(`${box.topLeft}${box.horizontal.repeat(columns - 2)}${box.topRight}`);
93
+ const divider = border(`${sharp.teeRight}${box.horizontal.repeat(columns - 2)}${sharp.teeLeft}`);
94
+ const bottom = border(`${box.bottomLeft}${box.horizontal.repeat(columns - 2)}${box.bottomRight}`);
95
+ const line = (value: SelectorFrameLine) => {
96
+ const row = typeof value === "string" ? undefined : value;
97
+ const fitted = truncateToWidth(normalizeLine(typeof value === "string" ? value : value.content), contentWidth);
98
+ const content = `${" ".repeat(padding)}${fitted}${" ".repeat(
99
+ Math.max(0, contentWidth - visibleWidth(fitted)),
100
+ )}${" ".repeat(padding)}`;
101
+ return row?.selected
102
+ ? `${edge}${theme.bg("selectedBg", theme.fg("text", content))}${edge}`
103
+ : `${edge}${content}${edge}`;
30
104
  };
31
- const head = [theme.bold(title), ...(purpose ? [theme.fg("muted", purpose)] : []), ...navigation];
32
- const tail = [
33
- ...details.slice(0, Math.max(0, height - head.length - footer.length - 5)),
34
- ...footer.map(value => theme.fg("muted", value)),
35
- ];
36
- const budget = Math.max(0, height - head.length - tail.length - 3);
105
+
106
+ const heading = [theme.bold(normalizeLine(title))];
107
+ const purposeLines = wrapSection(purpose ? [purpose] : [], contentWidth)
108
+ .slice(0, 2)
109
+ .map(value => theme.fg("muted", value));
110
+ const navigationLines = navigation.filter(hasVisibleContent).map(normalizeLine);
111
+ const detailLines = wrapSection(details, contentWidth);
112
+ while (detailLines.length < (options.minimumDetailRows ?? 0)) detailLines.push("");
113
+ const footerLines = wrapSection(footer, contentWidth).map(value => theme.fg("muted", value));
114
+ const normalizedBody = body.filter(value => typeof value !== "string" || hasVisibleContent(value));
115
+
116
+ const gaps = {
117
+ headingToNavigation: navigationLines.length > 0,
118
+ bodyToDetails: normalizedBody.length > 0 && detailLines.length > 0,
119
+ detailsToFooter: detailLines.length > 0 && footerLines.length > 0,
120
+ };
121
+ const gapCount = () => Object.values(gaps).filter(Boolean).length;
122
+ const fixedRows = () =>
123
+ 2 +
124
+ heading.length +
125
+ purposeLines.length +
126
+ navigationLines.length +
127
+ 1 +
128
+ detailLines.length +
129
+ footerLines.length +
130
+ gapCount();
131
+ const preferredBodyRows = Math.min(normalizedBody.length, options.maxBodyRows ?? normalizedBody.length);
132
+
133
+ // Spacing is intentionally optional: preserve the information and controls before whitespace.
134
+ for (const gap of ["headingToNavigation", "bodyToDetails", "detailsToFooter"] as const) {
135
+ if (fixedRows() + preferredBodyRows <= height) break;
136
+ gaps[gap] = false;
137
+ }
138
+
139
+ let bodyRows = Math.min(preferredBodyRows, Math.max(0, height - fixedRows()));
140
+ let visibleBody = windowBody(
141
+ normalizedBody,
142
+ bodyRows,
143
+ options.selectedBodyIndex,
144
+ Math.max(0, options.stickyBodyRows ?? 0),
145
+ );
146
+
147
+ // Pathological tiny terminals still keep the enclosure intact. Normal supported sizes do not enter this branch.
148
+ const nonBodyRows = fixedRows();
149
+ if (nonBodyRows > height) {
150
+ const overflow = nonBodyRows - height;
151
+ detailLines.splice(Math.max(1, detailLines.length - overflow));
152
+ bodyRows = Math.min(preferredBodyRows, Math.max(0, height - fixedRows()));
153
+ visibleBody = windowBody(
154
+ normalizedBody,
155
+ bodyRows,
156
+ options.selectedBodyIndex,
157
+ Math.max(0, options.stickyBodyRows ?? 0),
158
+ );
159
+ }
160
+
37
161
  return [
38
- horizontal,
39
- ...head.map(line),
40
- horizontal,
41
- ...body.slice(0, budget).map(line),
42
- ...tail.map(line),
43
- horizontal,
162
+ top,
163
+ ...heading.map(line),
164
+ ...purposeLines.map(line),
165
+ ...(gaps.headingToNavigation ? [line("")] : []),
166
+ ...navigationLines.map(line),
167
+ divider,
168
+ ...visibleBody.map(line),
169
+ ...(gaps.bodyToDetails ? [line("")] : []),
170
+ ...detailLines.map(line),
171
+ ...(gaps.detailsToFooter ? [line("")] : []),
172
+ ...footerLines.map(line),
173
+ bottom,
44
174
  ];
45
175
  }
46
176
 
47
- export function selectorRow(cells: string[], widths: number[], selected = false): string {
177
+ export function selectorRow(
178
+ cells: string[],
179
+ widths: number[],
180
+ selected = false,
181
+ tone: "text" | "muted" = "text",
182
+ ): SelectorFrameRow {
48
183
  const row = cells
49
184
  .map((cell, index) => {
50
- const width = widths[index];
185
+ const width = Math.max(0, widths[index] ?? 0);
51
186
  const fitted = truncateToWidth(cell, width);
52
187
  return fitted + " ".repeat(Math.max(0, width - visibleWidth(fitted)));
53
188
  })
54
189
  .join(" ");
55
190
  const text = `${selected ? theme.nav.cursor : " "} ${row}`;
56
- return selected ? theme.bg("selectedBg", theme.fg("text", text)) : theme.fg("text", text);
191
+ return { content: theme.fg(tone, text), selected };
57
192
  }
58
193
 
59
194
  type SelectorAction = "up" | "down" | "confirm" | "cancel" | "pageUp" | "pageDown";
@@ -101,21 +236,17 @@ export class ConnectionChoiceComponent extends Container {
101
236
  super();
102
237
  }
103
238
  override render(width: number): string[] {
104
- const available = Math.max(1, this.rows() - 10);
105
- const start = Math.max(0, this.#selected - available + 1);
239
+ const contentWidth = selectorFrameContentWidth(width);
106
240
  return selectorFrame(
107
241
  width,
108
242
  this.rows(),
109
243
  this.title,
110
244
  this.purpose,
111
245
  [],
112
- this.choices
113
- .slice(start, start + available)
114
- .map((choice, index) =>
115
- selectorRow([choice.label], [Math.min(100, width) - 6], start + index === this.#selected),
116
- ),
246
+ this.choices.map((choice, index) => selectorRow([choice.label], [contentWidth - 2], index === this.#selected)),
117
247
  [this.choices[this.#selected]?.description ?? ""],
118
248
  [selectorNavigationHint(), selectorCancelHint()],
249
+ { selectedBodyIndex: this.#selected },
119
250
  );
120
251
  }
121
252
  handleInput(data: string): void {
@@ -139,7 +270,7 @@ export class ConnectionInputComponent extends Container {
139
270
  super();
140
271
  }
141
272
  override render(width: number): string[] {
142
- const inner = Math.max(1, Math.min(100, width) - 4);
273
+ const inner = selectorFrameContentWidth(width);
143
274
  return selectorFrame(
144
275
  width,
145
276
  this.rows(),