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:
@@ -43,6 +43,7 @@ export async function selectConfig(options: ConfigSelectorOptions): Promise<void
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
},
|
},
|
||||||
() => ui.requestRender(),
|
() => ui.requestRender(),
|
||||||
|
ui.terminal.rows,
|
||||||
);
|
);
|
||||||
|
|
||||||
ui.addChild(selector);
|
ui.addChild(selector);
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ class ResourceList implements Component, Focusable {
|
|||||||
private filteredItems: FlatEntry[] = [];
|
private filteredItems: FlatEntry[] = [];
|
||||||
private selectedIndex = 0;
|
private selectedIndex = 0;
|
||||||
private searchInput: Input;
|
private searchInput: Input;
|
||||||
private maxVisible = 15;
|
private maxVisible: number;
|
||||||
private settingsManager: SettingsManager;
|
private settingsManager: SettingsManager;
|
||||||
private cwd: string;
|
private cwd: string;
|
||||||
private agentDir: string;
|
private agentDir: string;
|
||||||
@@ -196,12 +196,21 @@ class ResourceList implements Component, Focusable {
|
|||||||
this.searchInput.focused = value;
|
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.groups = groups;
|
||||||
this.settingsManager = settingsManager;
|
this.settingsManager = settingsManager;
|
||||||
this.cwd = cwd;
|
this.cwd = cwd;
|
||||||
this.agentDir = agentDir;
|
this.agentDir = agentDir;
|
||||||
this.searchInput = new Input();
|
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.buildFlatList();
|
||||||
this.filteredItems = [...this.flatItems];
|
this.filteredItems = [...this.flatItems];
|
||||||
}
|
}
|
||||||
@@ -565,6 +574,7 @@ export class ConfigSelectorComponent extends Container implements Focusable {
|
|||||||
onClose: () => void,
|
onClose: () => void,
|
||||||
onExit: () => void,
|
onExit: () => void,
|
||||||
requestRender: () => void,
|
requestRender: () => void,
|
||||||
|
terminalHeight?: number,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@@ -578,7 +588,7 @@ export class ConfigSelectorComponent extends Container implements Focusable {
|
|||||||
this.addChild(new Spacer(1));
|
this.addChild(new Spacer(1));
|
||||||
|
|
||||||
// Resource list
|
// 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.onCancel = onClose;
|
||||||
this.resourceList.onExit = onExit;
|
this.resourceList.onExit = onExit;
|
||||||
this.resourceList.onToggle = () => requestRender();
|
this.resourceList.onToggle = () => requestRender();
|
||||||
|
|||||||
Reference in New Issue
Block a user