hermes-agent/apps/desktop/src/lib/yolo-session.ts
brooklyn! e003c53b06
chore(desktop): zero eslint/typecheck debt + prettier pass (#39100)
- eslint --fix across src/ and electron/ (unused imports, import/prop sort, padding)
- flatten empty catch blocks in electron CJS; drop unused applyUpdatesPosixInApp arg
- add setMutableRef helper for imperative ref writes (react-compiler clean)
- move sidebar cookie persistence into an effect; extract scrollElementToBottom helper
2026-06-04 14:10:38 +00:00

26 lines
772 B
TypeScript

import { setYoloActive } from '@/store/session'
export type GatewayRequester = <T = unknown>(method: string, params?: Record<string, unknown>) => Promise<T>
/**
* Toggle per-session YOLO (approval bypass) via gateway `config.set` — the same
* session-scoped flag as the TUI's Shift+Tab. It does NOT touch the global
* `approvals.mode` config, so CLI / TUI / cron behavior is unaffected.
*/
export async function setSessionYolo(
requestGateway: GatewayRequester,
sessionId: string,
enabled: boolean
): Promise<boolean> {
const result = await requestGateway<{ value?: string }>('config.set', {
key: 'yolo',
session_id: sessionId,
value: enabled ? '1' : '0'
})
const active = result?.value === '1'
setYoloActive(active)
return active
}