fix(tui): yolo toggle only reports on/off for strict '0'/'1' values

Copilot on #14145 flagged that the shift+tab yolo handler treated any
non-null RPC result as valid, so a response shape like {value: undefined}
or {value: 'weird'} would incorrectly echo 'yolo off'. Now only '1' and
'0' map to on/off; anything else (including missing value) surfaces as
'failed to toggle yolo', matching the null/catch branches.
This commit is contained in:
Brooklyn Nicholson 2026-04-22 15:51:11 -05:00
parent b641639e42
commit e0d698cfb3

View file

@ -386,7 +386,11 @@ export function useInputHandlers(ctx: InputHandlerContext): InputHandlerResult {
return void gateway
.rpc<ConfigSetResponse>('config.set', { key: 'yolo', session_id: live.sid })
.then(r => actions.sys(r ? `yolo ${r.value === '1' ? 'on' : 'off'}` : 'failed to toggle yolo'))
.then(r =>
actions.sys(
r?.value === '1' ? 'yolo on' : r?.value === '0' ? 'yolo off' : 'failed to toggle yolo'
)
)
.catch(() => actions.sys('failed to toggle yolo'))
}