mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-01 07:01:41 +00:00
fix(tui): reclaim status width when cwd is hidden
Make the cwd separator width conditional so the computed status layout matches the rendered row on ultra-narrow terminals.
This commit is contained in:
parent
11b0d9ed2f
commit
4d9791c551
2 changed files with 9 additions and 3 deletions
|
|
@ -20,6 +20,6 @@ describe('statusRuleWidths', () => {
|
|||
})
|
||||
|
||||
it('omits the cwd segment when there is no room for it', () => {
|
||||
expect(statusRuleWidths(2, 'abcdef')).toEqual({ leftWidth: 1, rightWidth: 0, separatorWidth: 1 })
|
||||
expect(statusRuleWidths(2, 'abcdef')).toEqual({ leftWidth: 2, rightWidth: 0, separatorWidth: 0 })
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -152,10 +152,16 @@ function ctxBar(pct: number | undefined, w = 10) {
|
|||
|
||||
export function statusRuleWidths(cols: number, cwdLabel: string) {
|
||||
const width = Math.max(1, Math.floor(cols || 1))
|
||||
const separatorWidth = width >= 24 ? 3 : 1
|
||||
const desiredSeparatorWidth = width >= 24 ? 3 : 1
|
||||
const minLeftWidth = width >= 24 ? 8 : 1
|
||||
const maxRightWidth = Math.max(0, width - separatorWidth - minLeftWidth)
|
||||
const maxRightWidth = Math.max(0, width - desiredSeparatorWidth - minLeftWidth)
|
||||
|
||||
if (!cwdLabel || maxRightWidth <= 0) {
|
||||
return { leftWidth: width, rightWidth: 0, separatorWidth: 0 }
|
||||
}
|
||||
|
||||
const rightWidth = Math.max(0, Math.min(cwdLabel.length, maxRightWidth))
|
||||
const separatorWidth = rightWidth > 0 ? desiredSeparatorWidth : 0
|
||||
const leftWidth = Math.max(1, width - separatorWidth - rightWidth)
|
||||
|
||||
return { leftWidth, rightWidth, separatorWidth }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue