feat: refactor by splitting up app and doing proper state

This commit is contained in:
Brooklyn Nicholson 2026-04-14 22:30:18 -05:00
parent 4cbf54fb33
commit 99d859ce4a
27 changed files with 4087 additions and 2939 deletions

41
ui-tui/src/app/uiStore.ts Normal file
View 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())
}