mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-14 04:02:26 +00:00
fix(tui): preserve prompt separator width (#19340)
* fix(tui): preserve prompt separator width * fix(tui): align transcript height estimates with prompt width
This commit is contained in:
parent
d9c090fe36
commit
0ce1b9fe20
6 changed files with 85 additions and 7 deletions
|
|
@ -1,7 +1,13 @@
|
|||
import { renderSync } from '@hermes/ink'
|
||||
import React from 'react'
|
||||
import { PassThrough } from 'stream'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { MessageLine } from '../components/messageLine.js'
|
||||
import { toTranscriptMessages } from '../domain/messages.js'
|
||||
import { upsert } from '../lib/messages.js'
|
||||
import { stripAnsi } from '../lib/text.js'
|
||||
import { DEFAULT_THEME } from '../theme.js'
|
||||
|
||||
describe('toTranscriptMessages', () => {
|
||||
it('preserves assistant tool-call rows so resume does not drop prior turns', () => {
|
||||
|
|
@ -21,6 +27,50 @@ describe('toTranscriptMessages', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('MessageLine', () => {
|
||||
it('preserves a separator after compound user prompt glyphs in transcript rows', () => {
|
||||
const stdout = new PassThrough()
|
||||
const stdin = new PassThrough()
|
||||
const stderr = new PassThrough()
|
||||
let output = ''
|
||||
|
||||
Object.assign(stdout, { columns: 80, isTTY: false, rows: 24 })
|
||||
Object.assign(stdin, { isTTY: false })
|
||||
Object.assign(stderr, { isTTY: false })
|
||||
stdout.on('data', chunk => {
|
||||
output += chunk.toString()
|
||||
})
|
||||
|
||||
const t = {
|
||||
...DEFAULT_THEME,
|
||||
brand: { ...DEFAULT_THEME.brand, prompt: 'Ψ >' }
|
||||
}
|
||||
|
||||
const instance = renderSync(
|
||||
React.createElement(MessageLine, {
|
||||
cols: 80,
|
||||
msg: { role: 'user', text: 'Okay' },
|
||||
t
|
||||
}),
|
||||
{
|
||||
patchConsole: false,
|
||||
stderr: stderr as NodeJS.WriteStream,
|
||||
stdin: stdin as NodeJS.ReadStream,
|
||||
stdout: stdout as NodeJS.WriteStream
|
||||
}
|
||||
)
|
||||
|
||||
instance.unmount()
|
||||
instance.cleanup()
|
||||
|
||||
const renderedLine = stripAnsi(output)
|
||||
.split('\n')
|
||||
.find(line => line.includes('Okay'))
|
||||
|
||||
expect(renderedLine).toContain('Ψ > Okay')
|
||||
})
|
||||
})
|
||||
|
||||
describe('upsert', () => {
|
||||
it('appends when last role differs', () => {
|
||||
expect(upsert([{ role: 'user', text: 'hi' }], 'assistant', 'hello')).toHaveLength(2)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,13 @@ describe('virtual height estimates', () => {
|
|||
expect(estimatedMsgHeight(msg, 35, { compact: false, details: false })).toBeGreaterThan(5)
|
||||
})
|
||||
|
||||
it('uses compound user prompt width when estimating user message wrapping', () => {
|
||||
const msg: Msg = { role: 'user', text: 'x'.repeat(21) }
|
||||
|
||||
expect(estimatedMsgHeight(msg, 26, { compact: false, details: false, userPrompt: '❯' })).toBe(3)
|
||||
expect(estimatedMsgHeight(msg, 26, { compact: false, details: false, userPrompt: 'Ψ >' })).toBe(4)
|
||||
})
|
||||
|
||||
it('includes detail sections when visible', () => {
|
||||
const msg: Msg = { role: 'assistant', text: 'ok', thinking: 'line 1\nline 2', tools: ['Tool A', 'Tool B'] }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue