mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-01 01:51:44 +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/uiStore.ts
Normal file
41
ui-tui/src/app/uiStore.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { atom } from 'nanostores'
|
||||
|
||||
import { ZERO } from '../constants.js'
|
||||
import { DEFAULT_THEME } from '../theme.js'
|
||||
|
||||
import type { UiState } from './interfaces.js'
|
||||
|
||||
function buildUiState(): UiState {
|
||||
return {
|
||||
bgTasks: new Set(),
|
||||
busy: false,
|
||||
compact: false,
|
||||
detailsMode: 'collapsed',
|
||||
info: null,
|
||||
sid: null,
|
||||
status: 'summoning hermes…',
|
||||
statusBar: true,
|
||||
theme: DEFAULT_THEME,
|
||||
usage: ZERO
|
||||
}
|
||||
}
|
||||
|
||||
export const $uiState = atom<UiState>(buildUiState())
|
||||
|
||||
export function getUiState() {
|
||||
return $uiState.get()
|
||||
}
|
||||
|
||||
export function patchUiState(next: Partial<UiState> | ((state: UiState) => UiState)) {
|
||||
if (typeof next === 'function') {
|
||||
$uiState.set(next($uiState.get()))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
$uiState.set({ ...$uiState.get(), ...next })
|
||||
}
|
||||
|
||||
export function resetUiState() {
|
||||
$uiState.set(buildUiState())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue