mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-27 01:11:40 +00:00
fix(tui): make /clear confirm window humane (3s → 30s, reset on other slash)
The 3s gate was too tight — users reading the prompt and retyping
consistently blow past it and get stuck in a loop ("press /clear
again within 3s" forever). Fixes:
- bump CONFIRM_WINDOW_MS 3_000 → 30_000
- drop the time number from the confirmation message to remove the
pressure vibe: "press /clear again to confirm — starts a new session"
- reset the gate from createSlashHandler whenever any non-destructive
slash command runs, so stale arming from 20s ago can't silently
turn the next /clear into an unintended confirm
- export the gate + isDestructiveCommand helper for that wiring
- add armed() introspection method
Follow-up to #4069 / 3366714b.
This commit is contained in:
parent
20eab355e7
commit
75377feb07
4 changed files with 33 additions and 5 deletions
|
|
@ -3,6 +3,10 @@ import { describe, expect, it } from 'vitest'
|
|||
import { CONFIRM_WINDOW_MS, createDestructiveGate } from '../domain/destructive.js'
|
||||
|
||||
describe('createDestructiveGate', () => {
|
||||
it('uses a generous default window so real humans can retype (#4069)', () => {
|
||||
expect(CONFIRM_WINDOW_MS).toBeGreaterThanOrEqual(15_000)
|
||||
})
|
||||
|
||||
it('first request is not confirmed — it arms the gate', () => {
|
||||
const g = createDestructiveGate()
|
||||
expect(g.request('clear', 0)).toBe(false)
|
||||
|
|
@ -11,7 +15,7 @@ describe('createDestructiveGate', () => {
|
|||
it('second request within window with same key is confirmed', () => {
|
||||
const g = createDestructiveGate()
|
||||
g.request('clear', 0)
|
||||
expect(g.request('clear', 2_500)).toBe(true)
|
||||
expect(g.request('clear', CONFIRM_WINDOW_MS - 1)).toBe(true)
|
||||
})
|
||||
|
||||
it('second request outside the window re-arms and is not confirmed', () => {
|
||||
|
|
@ -20,6 +24,15 @@ describe('createDestructiveGate', () => {
|
|||
expect(g.request('clear', CONFIRM_WINDOW_MS + 1)).toBe(false)
|
||||
})
|
||||
|
||||
it('armed() reports the pending key while fresh, null otherwise', () => {
|
||||
const g = createDestructiveGate(100)
|
||||
expect(g.armed()).toBe(null)
|
||||
g.request('clear')
|
||||
expect(g.armed()).toBe('clear')
|
||||
g.reset()
|
||||
expect(g.armed()).toBe(null)
|
||||
})
|
||||
|
||||
it('different key re-arms the gate, does not confirm', () => {
|
||||
const g = createDestructiveGate()
|
||||
g.request('clear', 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue