mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-29 01:31:41 +00:00
fix(tui): give inline_diff segments blank-line breathing room
Visual polish on top of the segment-anchor change: diff blocks were
butting up against the narration around them. Tag diff-only segments
with `kind: 'diff'` (extended on Msg) and give them `marginTop={1}` +
`marginBottom={1}` in MessageLine, matching the spacing we already
use for user messages. Also swaps the regex-based `diffSegmentBody`
check for an explicit `kind === 'diff'` guard so the dedupe path is
clearer.
This commit is contained in:
parent
11b2942f16
commit
2258a181f0
4 changed files with 25 additions and 19 deletions
|
|
@ -19,17 +19,16 @@ const INTERRUPT_COOLDOWN_MS = 1500
|
|||
const ACTIVITY_LIMIT = 8
|
||||
const TRAIL_LIMIT = 8
|
||||
|
||||
// Matches segments produced by pushInlineDiffSegment — a bare ```diff fence
|
||||
// wrapping the raw patch, no surrounding prose. Used at message.complete to
|
||||
// dedupe against final assistant text that narrates the same patch.
|
||||
const DIFF_SEGMENT_RE = /^```diff\n([\s\S]*?)\n```$/
|
||||
|
||||
// Extracts the raw patch from a diff-only segment produced by
|
||||
// pushInlineDiffSegment. Used at message.complete to dedupe against final
|
||||
// assistant text that narrates the same patch. Returns null for anything
|
||||
// else so real assistant narration never gets touched.
|
||||
const diffSegmentBody = (msg: Msg): null | string => {
|
||||
if (msg.role !== 'assistant' || msg.tools?.length) {
|
||||
if (msg.kind !== 'diff') {
|
||||
return null
|
||||
}
|
||||
|
||||
const m = msg.text.match(DIFF_SEGMENT_RE)
|
||||
const m = msg.text.match(/^```diff\n([\s\S]*?)\n```$/)
|
||||
|
||||
return m ? m[1]! : null
|
||||
}
|
||||
|
|
@ -226,7 +225,7 @@ class TurnController {
|
|||
return
|
||||
}
|
||||
|
||||
this.segmentMessages = [...this.segmentMessages, { role: 'assistant', text: block }]
|
||||
this.segmentMessages = [...this.segmentMessages, { kind: 'diff', role: 'assistant', text: block }]
|
||||
patchTurnState({ streamSegments: this.segmentMessages })
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue