/** * Pure business logic for the TUI sidebar. * * All functions are deterministic, side-effect-free, and testable without * SolidJS, OpenTUI, or any UI framework. Only imports from type definition * modules and pure utility modules. * * @module */ import { EnginePhase } from "../constants"; import type { MonitorSnapshot, TaskSnapshot, ActiveFunction, LoopSnapshot, GraphSessionSnapshot, EngineGraphSnapshot } from "../cli/commands/monitor/monitor-reader-types"; export type HealthState = "ACTIVE" | "IDLE" | "NO_STATE" | "STALE" | "ERROR"; export interface HealthParams { phase: "loading" | "ready" | "error"; stateDirPresent: boolean; consecutiveFailures: number; snapshot: MonitorSnapshot | null; sessionScope: Set; currentSessionId: string; } export interface FilteredActivityData { fns: ActiveFunction[]; tasks: TaskSnapshot[]; graphs: GraphSessionSnapshot[]; loops: LoopSnapshot[]; /** Engine-graph (v2) execution snapshots, session-scoped. * Engine graphs carry no graph-level sessionId, so they are surfaced in the * current session's activity view (matching the monitor reader's unfiltered * projection); only the text filter applies. */ engineGraphs: EngineGraphSnapshot[]; } export interface FilterParams { snapshot: MonitorSnapshot | null; stateDirPresent: boolean; sessionScope: Set; currentSessionId: string; filterText: string; } /** * Compute the health state from raw inputs. * * Mirrors the health memo in state.tsx but as a pure function. * * Returns `null` only when phase is "loading" (no determination possible yet). */ export declare function computeHealth(params: HealthParams): HealthState | null; /** * Derive the effective engine lifecycle phase to display for a graph. * * A graph with any node in `running` status is never presented as idle: the * underlying session is actively executing (e.g. a node running a shell * command) even when the engine's persisted phase momentarily reads `idle` * (no node advancement is happening while work is in flight). Surface it as * `executing` instead of a stale `idle` to avoid false idle flicker. */ export declare function deriveEnginePhase(graph: { phase: EnginePhase; nodeStatusCounts: Record; }): EnginePhase; /** * Filter tasks to only active/pending/error/timeout ones within the session * scope, then sort by priority (errors first, then running, then pending). * * Within the same priority, sorts by startedAt (most recent first for errors, * earliest first for running/pending). */ export declare function getActiveTasks(snapshot: MonitorSnapshot | null, sessionScope: Set, currentSessionId: string): TaskSnapshot[]; /** * Compute the filtered activity data for the activity panel. * * Combines active functions, active tasks, graphs, and loops — all * scoped to the current session and optionally filtered by text. */ export declare function computeFilteredActivity(params: FilterParams): FilteredActivityData; //# sourceMappingURL=logic.d.ts.map