Bring apps/desktop and ui-tui to a clean state for typecheck, eslint,
and prettier:
- Run prettier across both trees (printWidth/wrap drift; prettier is not
CI-enforced for these JS projects, so main had accumulated drift).
- Apply eslint --fix for padding-line-between-statements and perfectionist
import/export sorting.
- Manual fixes for non-auto-fixable rules:
- remove unused node:net import in electron/main.cjs (uses Electron net)
- replace inline `typeof import(...)` annotations with top-level
`import type * as EnvModule` in two ui-tui test files
- scoped eslint-disable no-control-regex on intentional sentinel/ANSI
regexes (mathUnicode.ts, text.ts)
- resolve react-hooks/exhaustive-deps per-case: correct swapped/missing
deps, collapse redundant session.* members, and justified disables on
settings mount-only data-load effects to preserve run-once behavior
No behavior changes; test pass/fail counts are unchanged from the main
baseline.
84 lines
2.2 KiB
TypeScript
84 lines
2.2 KiB
TypeScript
import { atom, computed } from 'nanostores'
|
|
|
|
import type { OverlayState } from './interfaces.js'
|
|
|
|
const buildOverlayState = (): OverlayState => ({
|
|
agents: false,
|
|
agentsInitialHistoryIndex: 0,
|
|
approval: null,
|
|
billing: null,
|
|
clarify: null,
|
|
confirm: null,
|
|
modelPicker: false,
|
|
pager: null,
|
|
petPicker: false,
|
|
pluginsHub: false,
|
|
secret: null,
|
|
sessions: false,
|
|
skillsHub: false,
|
|
sudo: null
|
|
})
|
|
|
|
export const $overlayState = atom<OverlayState>(buildOverlayState())
|
|
|
|
export const $isBlocked = computed(
|
|
$overlayState,
|
|
({
|
|
agents,
|
|
approval,
|
|
billing,
|
|
clarify,
|
|
confirm,
|
|
modelPicker,
|
|
pager,
|
|
petPicker,
|
|
pluginsHub,
|
|
secret,
|
|
sessions,
|
|
skillsHub,
|
|
sudo
|
|
}) =>
|
|
Boolean(
|
|
agents ||
|
|
approval ||
|
|
billing ||
|
|
clarify ||
|
|
confirm ||
|
|
modelPicker ||
|
|
pager ||
|
|
petPicker ||
|
|
pluginsHub ||
|
|
secret ||
|
|
sessions ||
|
|
skillsHub ||
|
|
sudo
|
|
)
|
|
)
|
|
|
|
export const getOverlayState = () => $overlayState.get()
|
|
|
|
export const patchOverlayState = (next: Partial<OverlayState> | ((state: OverlayState) => OverlayState)) =>
|
|
$overlayState.set(typeof next === 'function' ? next($overlayState.get()) : { ...$overlayState.get(), ...next })
|
|
|
|
/** Full reset — used by session/turn teardown and tests. */
|
|
export const resetOverlayState = () => $overlayState.set(buildOverlayState())
|
|
|
|
/**
|
|
* Soft reset: drop FLOW-scoped overlays (approval / clarify / confirm / sudo
|
|
* / secret / pager) but PRESERVE user-toggled ones — agents dashboard, model
|
|
* picker, skills hub, sessions overlay. Those are opened deliberately and
|
|
* shouldn't vanish when a turn ends. Called from turnController.idle() on
|
|
* every turn completion / interrupt; the old "reset everything" behaviour
|
|
* silently closed /agents the moment delegation finished.
|
|
*/
|
|
export const resetFlowOverlays = () =>
|
|
$overlayState.set({
|
|
...buildOverlayState(),
|
|
agents: $overlayState.get().agents,
|
|
agentsInitialHistoryIndex: $overlayState.get().agentsInitialHistoryIndex,
|
|
modelPicker: $overlayState.get().modelPicker,
|
|
petPicker: $overlayState.get().petPicker,
|
|
pluginsHub: $overlayState.get().pluginsHub,
|
|
sessions: $overlayState.get().sessions,
|
|
skillsHub: $overlayState.get().skillsHub
|
|
})
|