mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
feat(tui): delete queued message while editing with ctrl-x / cancel with esc
Today there's no way to remove a queued message — ↑ loads it for edit, ctrl-K dispatches the head, but a draft you no longer want stays put forever. ctrl-C just clears the composer and exits edit mode without touching the queue. Two new bindings, both gated on queueEditIdx !== null so they're inert when the user isn't pointing at a queue item: - ctrl-X — delete the queue item being edited, clear composer, exit edit mode. "cut" matches the mental model and doesn't collide with any existing binding. - esc — cancel the edit (composer clears, item stays in queue). Mirrors ctrl-C's existing behavior so muscle memory has two paths. Header line now reads `queued (3) · editing 2 · ⌃X delete · esc cancel` when in edit mode, so the affordance is discoverable without /help. The /help hotkey table also gets a Ctrl+X entry. ctrl-C is intentionally unchanged: it should never destroy queued content. Cancel is non-destructive (esc / ctrl-C); only ctrl-X removes the item.
This commit is contained in:
parent
4a9ac5c355
commit
ea1012f59f
7 changed files with 79 additions and 3 deletions
|
|
@ -1,5 +1,15 @@
|
|||
import { useCallback, useRef, useState } from 'react'
|
||||
|
||||
export function removeAt<T>(arr: T[], i: number): T[] {
|
||||
if (i < 0 || i >= arr.length) {
|
||||
return arr
|
||||
}
|
||||
|
||||
arr.splice(i, 1)
|
||||
|
||||
return arr
|
||||
}
|
||||
|
||||
export function useQueue() {
|
||||
const queueRef = useRef<string[]>([])
|
||||
const [queuedDisplay, setQueuedDisplay] = useState<string[]>([])
|
||||
|
|
@ -36,6 +46,19 @@ export function useQueue() {
|
|||
[syncQueue]
|
||||
)
|
||||
|
||||
const removeQ = useCallback(
|
||||
(i: number) => {
|
||||
const before = queueRef.current.length
|
||||
|
||||
removeAt(queueRef.current, i)
|
||||
|
||||
if (queueRef.current.length !== before) {
|
||||
syncQueue()
|
||||
}
|
||||
},
|
||||
[syncQueue]
|
||||
)
|
||||
|
||||
return {
|
||||
dequeue,
|
||||
enqueue,
|
||||
|
|
@ -43,6 +66,7 @@ export function useQueue() {
|
|||
queueEditRef,
|
||||
queueRef,
|
||||
queuedDisplay,
|
||||
removeQ,
|
||||
replaceQ,
|
||||
setQueueEdit,
|
||||
syncQueue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue