mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-26 11:12:03 +00:00
fix(tui): share composer prompt gap metric
Use one exported prompt gap constant for both composer width math and prompt prefix rendering.
This commit is contained in:
parent
10fcd620d2
commit
d3ab2b2e13
2 changed files with 11 additions and 6 deletions
|
|
@ -9,7 +9,12 @@ import { $uiState } from '../app/uiStore.js'
|
|||
import { INLINE_MODE, SHOW_FPS } from '../config/env.js'
|
||||
import { FULL_RENDER_TAIL_ITEMS } from '../config/limits.js'
|
||||
import { PLACEHOLDER } from '../content/placeholders.js'
|
||||
import { composerPromptWidth, inputVisualHeight, stableComposerColumns } from '../lib/inputMetrics.js'
|
||||
import {
|
||||
COMPOSER_PROMPT_GAP_WIDTH,
|
||||
composerPromptWidth,
|
||||
inputVisualHeight,
|
||||
stableComposerColumns
|
||||
} from '../lib/inputMetrics.js'
|
||||
import { PerfPane } from '../lib/perfPane.js'
|
||||
|
||||
import { AgentsOverlay } from './agentsOverlay.js'
|
||||
|
|
@ -22,8 +27,6 @@ import { QueuedMessages } from './queuedMessages.js'
|
|||
import { LiveTodoPanel, StreamingAssistant } from './streamingAssistant.js'
|
||||
import { TextInput, type TextInputMouseApi } from './textInput.js'
|
||||
|
||||
const PROMPT_GAP_WIDTH = 1
|
||||
|
||||
const PromptPrefix = memo(function PromptPrefix({
|
||||
bold = false,
|
||||
color,
|
||||
|
|
@ -35,7 +38,7 @@ const PromptPrefix = memo(function PromptPrefix({
|
|||
promptText: string
|
||||
width: number
|
||||
}) {
|
||||
const glyphWidth = Math.max(1, stringWidth(promptText))
|
||||
const glyphWidth = Math.max(1, width - COMPOSER_PROMPT_GAP_WIDTH)
|
||||
|
||||
return (
|
||||
<Box width={width}>
|
||||
|
|
@ -44,7 +47,7 @@ const PromptPrefix = memo(function PromptPrefix({
|
|||
{promptText}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box width={PROMPT_GAP_WIDTH} />
|
||||
<Box width={COMPOSER_PROMPT_GAP_WIDTH} />
|
||||
</Box>
|
||||
)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import { stringWidth } from '@hermes/ink'
|
||||
|
||||
export const COMPOSER_PROMPT_GAP_WIDTH = 1
|
||||
|
||||
let _seg: Intl.Segmenter | null = null
|
||||
const seg = () => (_seg ??= new Intl.Segmenter(undefined, { granularity: 'grapheme' }))
|
||||
|
||||
|
|
@ -54,7 +56,7 @@ export function inputVisualHeight(value: string, columns: number) {
|
|||
}
|
||||
|
||||
export function composerPromptWidth(promptText: string) {
|
||||
return Math.max(1, stringWidth(promptText)) + 1
|
||||
return Math.max(1, stringWidth(promptText)) + COMPOSER_PROMPT_GAP_WIDTH
|
||||
}
|
||||
|
||||
export function stableComposerColumns(totalCols: number, promptWidth: number) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue