Skip to content

AI, fully local on your computer.

1.6 KB
Raw Blame
// The renderer's timing cadences, named once so a screen, a store and the tests that advance a fake
// clock all read the same value: polls, their failure budget, and the streamed-text flush window.

/**
 * Runtime-status poll cadence shared by HomeScreen and ChatScreen. Both screens poll
 * while no runtime is up (a large GGUF can take a while to auto-start) and must flip
 * to ready on their own — one constant keeps their cadences in lockstep.
 */
export const RUNTIME_POLL_MS = 2500

/**
 * Poll cadence for recovering an in-flight chat generation after the Chat screen was
 * unmounted (the user navigated away and back). Snappier than the runtime poll so the
 * recovered reply updates smoothly; only runs while a generation is actually in flight.
 */
export const STREAM_RECOVER_POLL_MS = 300

/**
 * CH-4 (frontend audit 2026-08-09, #148): consecutive getActiveStream failures tolerated by
 * the recovery poll before treating the stream as finished. A single transient IPC rejection
 * used to clear the live bubble, unlock the composer, and permanently detach — the SKA-40
 * bounded-failure-budget pattern keeps a live recovery over an IPC hiccup.
 */
export const STREAM_RECOVER_FAILURE_BUDGET = 3

/** How often ChatScreen's attach-import poll (`watchAttachJob`) reads the import job's status. */
export const ATTACH_POLL_MS = 400

/**
 * Streamed answer text is buffered and painted on this cadence instead of per token: one store
 * notify / re-render per window. Shared by ChatScreen and the Images screen's vision store
 * (PF-7c), both fast decodes; the Translate store stays per token (~4 tok/s, translateSession.ts).
 */
export const STREAM_FLUSH_MS = 40