mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
feat: refactor by splitting up app and doing proper state
This commit is contained in:
parent
4cbf54fb33
commit
99d859ce4a
27 changed files with 4087 additions and 2939 deletions
41
ui-tui/src/app/overlayStore.ts
Normal file
41
ui-tui/src/app/overlayStore.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { atom, computed } from 'nanostores'
|
||||
|
||||
import type { OverlayState } from './interfaces.js'
|
||||
|
||||
function buildOverlayState(): OverlayState {
|
||||
return {
|
||||
approval: null,
|
||||
clarify: null,
|
||||
modelPicker: false,
|
||||
pager: null,
|
||||
picker: false,
|
||||
secret: null,
|
||||
sudo: null
|
||||
}
|
||||
}
|
||||
|
||||
export const $overlayState = atom<OverlayState>(buildOverlayState())
|
||||
|
||||
export const $isBlocked = computed($overlayState, state =>
|
||||
Boolean(
|
||||
state.approval || state.clarify || state.modelPicker || state.pager || state.picker || state.secret || state.sudo
|
||||
)
|
||||
)
|
||||
|
||||
export function getOverlayState() {
|
||||
return $overlayState.get()
|
||||
}
|
||||
|
||||
export function patchOverlayState(next: Partial<OverlayState> | ((state: OverlayState) => OverlayState)) {
|
||||
if (typeof next === 'function') {
|
||||
$overlayState.set(next($overlayState.get()))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
$overlayState.set({ ...$overlayState.get(), ...next })
|
||||
}
|
||||
|
||||
export function resetOverlayState() {
|
||||
$overlayState.set(buildOverlayState())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue