fix(tui): preserve footer truncation after merge

This commit is contained in:
Tianyi Cui
2026-07-21 23:47:14 +08:00
parent 53615c91e7
commit f8008b571d
3 changed files with 4 additions and 6 deletions

View File

@@ -777,10 +777,7 @@ class FooterComponent implements Component {
return [`${' '.repeat(Math.max(0, width - visibleWidth(compact)))}${this.palette.dim(compact)}`]
}
const rightAvailable = width - visibleWidth(counters) - 1
const fullWidth = visibleWidth(formattedCwd) + visibleWidth(counters) + visibleWidth(fullRight) + 3
const right = this.cwdFormatter === undefined
? (visibleWidth(fullRight) <= rightAvailable ? fullRight : compactRight)
: (fullWidth <= width ? fullRight : compactRight)
const right = visibleWidth(fullRight) <= rightAvailable ? fullRight : compactRight
const rightClipped = truncateToWidth(right, rightAvailable, '')
const cwdAvailable = Math.max(0, width - visibleWidth(counters) - visibleWidth(rightClipped) - 3)
const cwd = truncateToWidth(formattedCwd, cwdAvailable, '')

View File

@@ -511,10 +511,10 @@ describe('pi-tui chat lifecycle and transcript', () => {
await dispose(outsideResult)
const logicalResult = await setup({
cwd: '/host/worktree',
cwd: '/w',
formatCwd: cwd => `logical:${cwd}\x1b`,
})
expect(logicalResult.terminal.output).toContain('logical:/host/worktree\\x1b')
expect(logicalResult.terminal.output).toContain('logical:/w\\x1b')
await dispose(logicalResult)
})