Files
loki/drizzle
Mao NakamotoandClaude Opus 4.7 796f1f8290 fix(control): unblock prod queries + remove per-card polling
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>
2026-06-09 11:31:55 +02:00
..