mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-07 02:51:50 +00:00
feat(tui): double-press confirm on /clear and /new
Prevents accidental session loss: the first press prints "press /clear again within 3s to confirm"; a second press inside the window actually starts a new session. Outside the window the gate re-arms. Opt out with HERMES_TUI_NO_CONFIRM=1 for scripted / muscle-memory workflows. Refs #4069.
This commit is contained in:
parent
52124384de
commit
3366714ba4
4 changed files with 88 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import { NO_CONFIRM_DESTRUCTIVE } from '../../../config/env.js'
|
||||
import { dailyFortune, randomFortune } from '../../../content/fortunes.js'
|
||||
import { HOTKEYS } from '../../../content/hotkeys.js'
|
||||
import { createDestructiveGate } from '../../../domain/destructive.js'
|
||||
import { nextDetailsMode, parseDetailsMode } from '../../../domain/details.js'
|
||||
import type {
|
||||
ConfigGetValueResponse,
|
||||
|
|
@ -13,6 +15,8 @@ import { patchOverlayState } from '../../overlayStore.js'
|
|||
import { patchUiState } from '../../uiStore.js'
|
||||
import type { SlashCommand } from '../types.js'
|
||||
|
||||
const destructiveGate = createDestructiveGate()
|
||||
|
||||
const flagFromArg = (arg: string, current: boolean): boolean | null => {
|
||||
if (!arg) {
|
||||
return !current
|
||||
|
|
@ -82,6 +86,12 @@ export const coreCommands: SlashCommand[] = [
|
|||
return
|
||||
}
|
||||
|
||||
const label = cmd.startsWith('/new') ? '/new' : '/clear'
|
||||
|
||||
if (!NO_CONFIRM_DESTRUCTIVE && !destructiveGate.request('clear')) {
|
||||
return ctx.transcript.sys(`press ${label} again within 3s to confirm (starts a new session)`)
|
||||
}
|
||||
|
||||
patchUiState({ status: 'forging session…' })
|
||||
ctx.session.newSession(cmd.startsWith('/new') ? 'new session started' : undefined)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue