mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix(tui): address latest review feedback
This commit is contained in:
parent
2be5e181a9
commit
a8bfe72d35
5 changed files with 17 additions and 87 deletions
|
|
@ -1,52 +0,0 @@
|
|||
import { SCROLLING_IDLE_MS, TYPING_IDLE_MS } from '../config/timing.js'
|
||||
|
||||
export type InteractionMode = 'idle' | 'scrolling' | 'typing'
|
||||
|
||||
type Timer = null | ReturnType<typeof setTimeout>
|
||||
|
||||
let mode: InteractionMode = 'idle'
|
||||
let scrollingTimer: Timer = null
|
||||
let typingTimer: Timer = null
|
||||
|
||||
const clear = (t: Timer): null => {
|
||||
if (t) {
|
||||
clearTimeout(t)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export function getInteractionMode(): InteractionMode {
|
||||
return mode
|
||||
}
|
||||
|
||||
export function markTyping(): void {
|
||||
mode = 'typing'
|
||||
typingTimer = clear(typingTimer)
|
||||
scrollingTimer = clear(scrollingTimer)
|
||||
typingTimer = setTimeout(() => {
|
||||
typingTimer = null
|
||||
mode = 'idle'
|
||||
}, TYPING_IDLE_MS)
|
||||
}
|
||||
|
||||
export function markScrolling(): void {
|
||||
if (mode === 'typing') {
|
||||
return
|
||||
}
|
||||
|
||||
mode = 'scrolling'
|
||||
scrollingTimer = clear(scrollingTimer)
|
||||
scrollingTimer = setTimeout(() => {
|
||||
scrollingTimer = null
|
||||
if (mode === 'scrolling') {
|
||||
mode = 'idle'
|
||||
}
|
||||
}, SCROLLING_IDLE_MS)
|
||||
}
|
||||
|
||||
export function resetInteractionMode(): void {
|
||||
scrollingTimer = clear(scrollingTimer)
|
||||
typingTimer = clear(typingTimer)
|
||||
mode = 'idle'
|
||||
}
|
||||
|
|
@ -101,10 +101,10 @@ export function useSubmission(opts: UseSubmissionOptions) {
|
|||
|
||||
gw.request<PromptSubmitResponse>('prompt.submit', { session_id: sid, text: submitText }).catch((e: Error) => {
|
||||
if (isSessionBusyError(e)) {
|
||||
composerActions.enqueue(text)
|
||||
composerActions.enqueue(submitText)
|
||||
patchUiState({ busy: true, status: 'queued for next turn' })
|
||||
|
||||
return sys(`queued: "${text.slice(0, 50)}${text.length > 50 ? '…' : ''}"`)
|
||||
return sys(`queued: "${submitText.slice(0, 50)}${submitText.length > 50 ? '…' : ''}"`)
|
||||
}
|
||||
|
||||
sys(`error: ${e.message}`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue