mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-30 01:41:43 +00:00
fix(ui-tui): hide stale sticky prompt when newer prompt is visible
Sticky prompt selection only considered the top edge of the viewport, so it could keep showing an older user prompt even when a newer one was already visible lower down. Suppress sticky output whenever a user message is visible in the viewport and cover it with a regression test.
This commit is contained in:
parent
aa47812edf
commit
9a885fba31
3 changed files with 41 additions and 2 deletions
|
|
@ -18,6 +18,7 @@ const upperBound = (offsets: ArrayLike<number>, target: number) => {
|
|||
export const stickyPromptFromViewport = (
|
||||
messages: readonly Msg[],
|
||||
offsets: ArrayLike<number>,
|
||||
bottom: number,
|
||||
top: number,
|
||||
sticky: boolean
|
||||
) => {
|
||||
|
|
@ -26,8 +27,15 @@ export const stickyPromptFromViewport = (
|
|||
}
|
||||
|
||||
const first = Math.max(0, Math.min(messages.length - 1, upperBound(offsets, top) - 1))
|
||||
const last = Math.max(first, Math.min(messages.length - 1, upperBound(offsets, bottom) - 1))
|
||||
|
||||
for (let i = first; i >= 0; i--) {
|
||||
for (let i = first; i <= last; i++) {
|
||||
if (messages[i]?.role === 'user') {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = first - 1; i >= 0; i--) {
|
||||
if (messages[i]?.role !== 'user') {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue