Extends ConfigDisplayConfig and UiState so the four new display flags
flow from `config.get {key:"full"}` into the nanostore. applyDisplay is
exported to keep the fan-out testable without an Ink harness.
Defaults mirror v1 parity: streaming + inline_diffs default true
(opt-out via `=== false`), show_cost + show_reasoning default false
(opt-in via plain truthy check).
32 lines
850 B
TypeScript
32 lines
850 B
TypeScript
import { atom } from 'nanostores'
|
|
|
|
import { ZERO } from '../domain/usage.js'
|
|
import { DEFAULT_THEME } from '../theme.js'
|
|
|
|
import type { UiState } from './interfaces.js'
|
|
|
|
const buildUiState = (): UiState => ({
|
|
bgTasks: new Set(),
|
|
busy: false,
|
|
compact: false,
|
|
detailsMode: 'collapsed',
|
|
info: null,
|
|
inlineDiffs: true,
|
|
showCost: false,
|
|
showReasoning: false,
|
|
sid: null,
|
|
status: 'summoning hermes…',
|
|
statusBar: true,
|
|
streaming: true,
|
|
theme: DEFAULT_THEME,
|
|
usage: ZERO
|
|
})
|
|
|
|
export const $uiState = atom<UiState>(buildUiState())
|
|
|
|
export const getUiState = () => $uiState.get()
|
|
|
|
export const patchUiState = (next: Partial<UiState> | ((state: UiState) => UiState)) =>
|
|
$uiState.set(typeof next === 'function' ? next($uiState.get()) : { ...$uiState.get(), ...next })
|
|
|
|
export const resetUiState = () => $uiState.set(buildUiState())
|