mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 11:07:40 +01:00
Closes the queue-storage gap raised in last turn's evaluation. Before:
the per-project prompt queue lived in /tmp/agent-queue-<tab>, which is
ephemeral on Vercel (lost on cold start) and not user-scoped. After:
project_states.prompt_queue (text[] not null default '{}') is the
source of truth — persists across browsers, Vercel cold starts, and
backed by the same per-(user, project) PK as the rest of session
state.
Files touched:
• drizzle/0010_project_states_prompt_queue.sql — ADD COLUMN IF
NOT EXISTS text[] not null default '{}'. Applied to both Neon
prod and local Postgres via psql.
• src/db/schema/project-states.ts — promptQueue field added next
to sessionStatus (also new this week, similar shape).
• src/app/api/beacon/queue/[tab]/route.ts — rewritten to read/
write the DB row. Adds proper auth (was unauthenticated; closed
a real auth gap on the way through). Keeps a best-effort file
mirror so scripts/agent-hook-bridge.sh's two /tmp/agent-queue-*
readers don't break (user has denied prior edits to that file
3x — file mirror stays until that path is touched).
Auth note: the old route had NO auth check. Any unauthenticated
caller could read or overwrite any tab's queue. usePromptQueue is the
only consumer in the codebase and runs in an authed session, so the
new 401 doesn't break any production flow.
What's NOT in this commit (deliberate scope cut):
• The bash hook's two /tmp readers. Long-term they should query
the DB via authed API — that's a separate ticket since user has
repeatedly denied agent-hook-bridge.sh edits.
tsc clean, eslint clean, npm run test:home 85/85.
15 lines
688 B
SQL
15 lines
688 B
SQL
-- Move the per-project prompt queue from /tmp/agent-queue-<tab> to
|
|
-- project_states.prompt_queue so it persists across browsers and across
|
|
-- Vercel cold starts (the /tmp mirror is ephemeral on serverless and only
|
|
-- durable on local cockpit-app machines).
|
|
--
|
|
-- text[] (not jsonb) since the queue is always a flat list of prompt
|
|
-- strings — matches the existing activeAgents column shape, no JSON
|
|
-- parsing overhead, native Postgres array semantics.
|
|
--
|
|
-- Idempotent — ADD COLUMN IF NOT EXISTS lets the migration re-run on a
|
|
-- partially-migrated environment without erroring.
|
|
|
|
ALTER TABLE "project_states"
|
|
ADD COLUMN IF NOT EXISTS "prompt_queue" text[] NOT NULL DEFAULT '{}';
|