config selector: scale maxVisible to terminal height

ResourceList hardcoded maxVisible=15, leaving most of the screen
empty on tall terminals. Pass terminalHeight through from
ProcessTerminal.rows and compute maxVisible dynamically, matching
the pattern tree-selector already uses.

Closes #4241
This commit is contained in:
Sam Jones
2026-05-06 14:45:13 -04:00
parent 88619669e2
commit fcd96df6f2
2 changed files with 14 additions and 3 deletions

View File

@@ -178,7 +178,7 @@ class ResourceList implements Component, Focusable {
private filteredItems: FlatEntry[] = [];
private selectedIndex = 0;
private searchInput: Input;
private maxVisible = 15;
private maxVisible: number;
private settingsManager: SettingsManager;
private cwd: string;
private agentDir: string;
@@ -196,12 +196,21 @@ class ResourceList implements Component, Focusable {
this.searchInput.focused = value;
}
constructor(groups: ResourceGroup[], settingsManager: SettingsManager, cwd: string, agentDir: string) {
constructor(
groups: ResourceGroup[],
settingsManager: SettingsManager,
cwd: string,
agentDir: string,
terminalHeight?: number,
) {
this.groups = groups;
this.settingsManager = settingsManager;
this.cwd = cwd;
this.agentDir = agentDir;
this.searchInput = new Input();
// 8 lines of chrome: top spacer + top border + spacer + header (2 lines) + spacer + bottom spacer + bottom border
const chrome = 8;
this.maxVisible = Math.max(5, (terminalHeight ?? 24) - chrome);
this.buildFlatList();
this.filteredItems = [...this.flatItems];
}
@@ -565,6 +574,7 @@ export class ConfigSelectorComponent extends Container implements Focusable {
onClose: () => void,
onExit: () => void,
requestRender: () => void,
terminalHeight?: number,
) {
super();
@@ -578,7 +588,7 @@ export class ConfigSelectorComponent extends Container implements Focusable {
this.addChild(new Spacer(1));
// Resource list
this.resourceList = new ResourceList(groups, settingsManager, cwd, agentDir);
this.resourceList = new ResourceList(groups, settingsManager, cwd, agentDir, terminalHeight);
this.resourceList.onCancel = onClose;
this.resourceList.onExit = onExit;
this.resourceList.onToggle = () => requestRender();