mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 05:37:19 +01:00
Two related fixes that together restore the /control page to a working state.
1. Missing migration 0030_session_block_reason.sql
Commit 729237c added session_block_reason + session_no_op_count to the
project_states schema without generating a SQL migration. Production
Postgres lacked both columns, so every SELECT on project_states crashed
with 42703 (errorMissingColumn). Symptom: /api/beacon/queue/<tab>
returning 500/503 in a tight loop, /api/control/stream emitting empty
project state, every project rendering "Offline · Live status
unavailable" on /control.
The migration is additive and idempotent.
2. Per-card polling → SSE-piped state
usePromptQueue and useAutoContinue each opened a per-card HTTP read loop
(setInterval @ 2 s and an on-mount fetch) against /api/beacon/queue/<tab>
and /api/control/auto-continue?tab=<tab>. With 21 projects on the page
that meant an N+1 request storm for state that the /api/control/stream
SSE endpoint can deliver as a single push.
Stream the data instead:
- FastProjectState gains optional promptQueue / promptQueueRevision /
autoContinueEnabled
- /api/control/stream dbToFastState emits them from project_states
- /api/control populates the same fields so the first paint matches the
stream shape and no second mount-fetch is needed
- useControlData.mergeProjectPatches forwards the fields onto each
ProjectState
- usePromptQueue / useAutoContinue accept the values as props, drop
the polling loop, and only fall back to a one-shot HTTP load when
the props are absent (local /proc-backed runtime path that doesn't
project DB fields)
- ProjectCard threads project.promptQueue + project.autoContinueEnabled
into the hooks
Mutation paths (PUT /api/beacon/queue/<tab>, POST /api/control/auto-continue)
are unchanged. Optimistic local state + revision-based CAS retry still work
exactly as before; the stream just pushes the post-write revision back
instead of the hook polling for it.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8 lines
461 B
SQL
8 lines
461 B
SQL
-- Add structured loop-control columns referenced by src/db/schema/project-states.ts
|
|
-- (sessionBlockReason, sessionNoOpCount). Both were added to the schema in commit
|
|
-- 729237c without a generated SQL migration, so prod was missing them, causing
|
|
-- every SELECT on project_states to crash with 42703 (errorMissingColumn).
|
|
ALTER TABLE project_states
|
|
ADD COLUMN IF NOT EXISTS session_block_reason text,
|
|
ADD COLUMN IF NOT EXISTS session_no_op_count integer;
|