mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
fix(tui): preserve composer width on narrow panes
This commit is contained in:
@@ -42,9 +42,9 @@ describe('input metrics helpers', () => {
|
||||
expect(inputVisualHeight('one\ntwo', 40)).toBe(2)
|
||||
})
|
||||
|
||||
it('reserves gutters without exceeding the physical terminal width', () => {
|
||||
it('reserves gutters on wide panes without starving narrow composer width', () => {
|
||||
expect(stableComposerColumns(100, 3)).toBe(93)
|
||||
expect(stableComposerColumns(10, 3)).toBe(3)
|
||||
expect(stableComposerColumns(10, 3)).toBe(5)
|
||||
expect(stableComposerColumns(6, 3)).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -54,9 +54,9 @@ export function inputVisualHeight(value: string, columns: number) {
|
||||
}
|
||||
|
||||
export function stableComposerColumns(totalCols: number, promptWidth: number) {
|
||||
// Physical render/wrap width. Reserve:
|
||||
// - outer composer paddingX={1}: 2 columns
|
||||
// - transcript scrollbar gutter + marginLeft: 2 columns
|
||||
// - prompt prefix width
|
||||
return Math.max(1, totalCols - promptWidth - 4)
|
||||
// Physical render/wrap width. Always reserve outer composer padding and
|
||||
// prompt prefix. Only reserve the transcript scrollbar gutter when the
|
||||
// terminal is wide enough; on narrow panes, preserving input columns beats
|
||||
// keeping gutters visually aligned.
|
||||
return Math.max(1, totalCols - promptWidth - 2 - (totalCols - promptWidth >= 24 ? 2 : 0))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user