UNPKG

trellis

Version:

Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications

94 lines 4.67 kB
/** * Admin kanban — the operator console's issue board as a kanban-core * consumer (ADR 0034 wedge 13, spec §9). * * Replaces the static three-column TML view in `admin.html`: * * - one board over the issue snapshot, grouped by status through a * derived accessor that maps issue statuses onto the three canonical * ISSUE_COLUMNS keys (backlog / in-progress / done) — the same * visible columns as the static view, now dynamic; * - moving a card writes the issue's status through * `onCardMove` → `op('issueSetStatus', …)` — one EQL-S entity op * (the graph write-surface pattern); the SSE snapshot flows back * through `sync()` and diff-syncs the projection (`updateRow` / * `addRow` / `removeRow` — snapshot sync is not an edit, so no undo * steps and no write hooks); * - the board descriptor (column order / colors / collapse / hide / * sort) persists to localStorage via Save — app-layer persistence * of a pure JSON view (spec §2); * - undo stays in the transient layer (undo-history-core); durable * reversal stays in the op-log (spec §6.2). * * The core logic (`columnKeyOf` / `statusOf` / `syncRows` / * `createAdminBoardCore`) is DOM-free and unit-tested; `mountAdminKanban` * is the thin vanilla renderer the page mounts. * * @module trellis/ui */ import type { BoardDescriptor, KanbanGroupField, TableColumn, UseKanbanReturn } from '../kanban/core/index.js'; /** The issue shape the lanes snapshot supplies (IssueRow subset). */ export interface AdminIssueRow { id: string; title?: string; status?: string; priority?: string; labels?: string[]; createdAt?: string; laneIds?: string[]; } /** * Map a snapshot issue status onto the three canonical column keys. * Everything that is not in-progress/paused/closed is backlog — the same * fold the static TML query expressed as a negated OR. */ export declare function columnKeyOf(status: unknown): string; /** Inverse of `columnKeyOf` — the status value a move writes to the graph. */ export declare function statusOf(columnKey: string): string; export declare const ADMIN_BOARD_ID = "admin-issues"; export declare const BOARD_STORAGE_KEY = "trellis-admin-kanban-board"; /** The saved view — the ISSUE_COLUMNS collapse as a pure JSON descriptor. */ export declare const ADMIN_BOARD_DEFAULTS: BoardDescriptor; /** The group field: status, read through the ISSUE_COLUMNS accessor. */ export declare const ADMIN_GROUP_FIELDS: KanbanGroupField[]; /** Card-preview fields. */ export declare const ADMIN_COLUMNS: TableColumn<AdminIssueRow>[]; /** Storage surface — the browser's localStorage in the page, a Map in tests. */ export type BoardStorage = { getItem(key: string): string | null; setItem(key: string, value: string): void; }; /** Load the persisted view, merged over the ISSUE_COLUMNS defaults. */ export declare function loadBoardDescriptor(storage: BoardStorage | null, defaults?: BoardDescriptor): BoardDescriptor; export declare function saveBoardDescriptor(board: BoardDescriptor, storage: BoardStorage | null): void; /** * Diff-sync the board's row set from a fresh snapshot. New rows are * added, removed rows dropped, changed rows patched (`updateRow` — no * undo step, no write hook: snapshot sync is not an edit). A * `lastSeen` map (rowId → signature) suppresses no-op updates. */ export declare function syncRows(core: UseKanbanReturn<AdminIssueRow>, issues: AdminIssueRow[], lastSeen?: Map<string, string> | null): void; export interface AdminKanbanHooks { /** POST a graph mutation (e.g. issueSetStatus) — the durable write. */ op(action: string, args: Record<string, unknown>): Promise<unknown> | unknown; board?: BoardDescriptor; storage?: BoardStorage | null; } export interface AdminKanbanMount { readonly core: UseKanbanReturn<AdminIssueRow>; /** Apply a lanes snapshot to the board (initial seed + every SSE frame). */ sync(snapshot: unknown): void; /** Commit the current view state into storage. */ saveBoard(): void; /** Unsubscribe listeners and detach the renderer. */ destroy(): void; } /** DOM-free board core: column mapping, write hook, undo composition. */ export declare function createAdminBoardCore(opts: AdminKanbanHooks): UseKanbanReturn<AdminIssueRow>; /** * Mount the board renderer into `host`. The renderer is adapter-tier DOM * glue over core state: DnD input writes `dragState`, every other * behavior is a core action. */ export declare function mountAdminKanban(host: HTMLElement, opts: AdminKanbanHooks): AdminKanbanMount; //# sourceMappingURL=admin-kanban.d.ts.map