- Clear handshake files unconditionally after every Claude adapter inject,
not only on hard_stop — prevents the beacon from firing a second inject
because the ready sentinel was never removed
- Skip Intent/Project header and execution rules in renderTaskForAdapter for
the Claude adapter — CLAUDE.md is always loaded in every Claude Code session
and already provides these; removes ~100 tokens of redundant context per inject
- Remove trailing "When done, update the session file:" epilogues from all
prompts in agent-prompts.json — buildPromptWithSession already appends the
exact session-file path; the vague duplicate in prompt bodies caused Claude
to receive two conflicting update instructions
- Rewrite next_best prompt body to reference the session context already
prepended by buildPromptWithSession instead of re-reading it via grep
- Fix continue prompt — remove stale update-block tail
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
agent-config.ts and orchestration/renderers.ts both generated
'todos: <count> TODOs' — the field name already communicates what
it is. Now generates 'todos: <count>'. DevLogList normalises legacy
DB entries (which stored 'N TODOs') so history renders cleanly too.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add agentRunning, activeAgents, lockAt columns to project_states schema
- New POST /api/control/runtime-state endpoint (daemon bearer auth)
accepts per-project runtime patches and upserts to DB
- control/route.ts: use DB agentRunning/activeAgents/currentPrompt
when isRuntimeAvailable()=false (Vercel sees live fleet state)
- stream/route.ts: DB polling path when !isRuntimeAvailable()
maps project_states rows → FastProjectState for SSE clients
- cockpit-daemon.sh: _push_loop runs in background every 2s,
reads /proc + /tmp sentinels + current-prompt files and pushes
all 7 tab states to the new endpoint
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Race 1 — async mic permission gap: setListening(true) was called only after
await getUserMedia(), leaving a window where isComposing=false even while
the browser was showing the permission dialog. Now setListening(true) fires
synchronously on mic button click, with a rollback to false on error.
Race 2 — cross-window blind spot: the control panel's ReadyBanner had no way
to know the beacon popup was mid-composition. It relied on display.isBeaconActive
which reads /tmp (unavailable on Vercel). Added beaconComposingKey to
control-storage so the popup writes a localStorage flag when isComposing;
ReadyBanner reads it synchronously before firing, blocking the inject.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both ProjectCard and ProjectCommanderCard were duplicating the same
postJson side-effects alongside the hook toggle. Moving them into
useAutoContinue means the beacon cancel and /tmp sentinel sync
happen wherever the toggle fires, including from beacon and
orchestration paths that bypass the card components.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cross-reference comments point bash defaults to AGENT_DEFAULT_MODELS in
agent-registry.ts so the coupling is visible without runtime import.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SWITCH_CHOICE_PREFIX="switch:" was defined locally in beacon/[id]/page.tsx
(TypeScript) and _beacon_popups.py (Python), while its sibling CUSTOM_CHOICE_PREFIX
already lived in src/lib/constants/control.ts and _beacon_config.py respectively.
- Add SWITCH_CHOICE_PREFIX to constants/control.ts alongside CUSTOM_CHOICE_PREFIX
- Remove local const from beacon/[id]/page.tsx; import from constants instead
- Move SWITCH_CHOICE_PREFIX from _beacon_popups.py into _beacon_config.py; import it
- Update shell script comment to cover both prefixes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The countdown bounds (min=5, max=300) were hardcoded in beacon/[id]/page.tsx,
BeaconSettings.tsx, and beacon-settings/route.ts. Centralised to control.ts so
changing the allowed range requires one edit instead of three.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- ControlPanel: use useLocalStorageState for viewMode so commander/full
preference survives page refreshes (critical for phone use)
- ProjectCommanderCard: show Continue + Talk buttons when isClosed — closed
projects were actionless in commander view; now match full card behaviour
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- control/route.ts: extract rowToProfile() helper — matchProfile and
matchProfileById both built the same 7-field object; now share one source
- control/stream/route.ts: extract scanProjects() — initial snapshot and
tick loop duplicated the confProjects.map + readFastState computation;
stream handler shrinks from 149 → 140 lines
- ControlPanel.tsx: call cardProps(project) once per commander card instead
of twice (separate .onInject and .onRunWithBrain destructures)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a compact mobile-first ProjectCommanderCard showing project state at a
glance with a single Continue button (fires next_best), a collapsible talk
panel for custom prompts, and a Let-it-roll auto-continue toggle. ControlPanel
gets a view-mode toggle (⊞/≡) to switch between full and commander views.
Also includes the session todos field in the Groq dispatch prompt so the
strategist has the full handoff picture when deciding queue vs next_best.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The 5-field summary shape was defined inline in ProjectState.latestOrchestrationRun,
duplicating the canonical OrchestrationTaskSummary from lib/orchestration. Import and
reuse the SSOT type.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Directory paths from userProjects.dirPath were embedded with bare single-quote
wrapping, breaking for paths that contain single quotes (e.g. user home dirs
with apostrophes). shellEscape handles the full single-quote escape sequence.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
drizzle-kit push emits drizzle/meta/_journal.json alongside the SQL files.
Committing so the directory structure is complete.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
prompt-history: extract DISPATCH_COLS + toHistoryItem/toActivityItem — remove
3 copy-pasted select shapes and row mappers; HistoryItem now derives from ActivityItem
via Omit+intersection so the type relationship is explicit.
user-projects: extract writeDevLog — remove duplicated append+cap+save logic from
appendProjectDevLog and appendProjectDevLogByEntityProjectId.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Module-level path.join(process.env.HOME, …) causes Turbopack's NFT tracer
to walk from HOME (parent of project root) and accidentally include
next.config.ts in /api/orchestration/run route bundle. Converting SESSIONS_DIR
and PROMPTS_FILE to lazy accessor functions defers evaluation to request time.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
process.env vars are undefined in "use client" components on the client,
so githubEnabled was always false after hydration — the GitHub button
flashed in SSR HTML then disappeared. Split into a server component page
that reads env vars and passes githubEnabled as a prop to the client form.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds cockpitapp.vercel.app to vercel.json alias list so Vercel
auto-updates it on each production push instead of staying pinned
to a specific deployment URL.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
NextAuth v5 middleware builds the redirect URL from request.url which
in the Edge Runtime is the deployment URL (cockpit-orangecat.vercel.app),
not the cockpitapp.vercel.app alias. Vercel sets x-forwarded-host to the
original alias, so we construct the redirect Response manually using it.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Ensures NextAuth redirects and OAuth callbacks use the stable alias URL
instead of the per-deployment cockpit-orangecat.vercel.app URL.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Shows a Lock icon + label in the sidebar footer only when the private
zone is unlocked. Clicking calls lock() which clears sessionStorage and
re-renders the PIN gate on the next private page visit.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET set for cockpitapp.vercel.app.
OAuth app registered at github.com/settings/applications/3599693.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Turbopack requires middleware to be a default export. The previous
`export const { auth: middleware }` destructured named export was not
recognized. Switch to `const { auth } = NextAuth(authConfig); export default auth`.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
proxy.ts and middleware.ts can't coexist in Next.js. Delete the old
Node.js-dependent proxy.ts and extend the edge-safe middleware matcher
to exclude beacon, thoughts, and invite paths (public routes).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Moves sensitive pages into an (app)/(private) route group with a shared
layout that renders PrivatePinGate before any content. The gate posts to
/api/auth/pin (scrypt verify, 5-attempt rate limit per IP), stores a
30-min sessionStorage token on success, and shows nothing until unlocked.
Uses useSyncExternalStore to read sessionStorage without an effect.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
auth.config.ts had '/auth/signin' but actual route is '/sign-in' — logged-out
users would hit a 404 instead of the sign-in page. Also excluded 'sign-in'
from the middleware matcher to prevent an infinite redirect loop when
NextAuth redirects unauthenticated users to the sign-in page.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Middleware runs in the Edge Runtime (no Node.js APIs). Created auth.config.ts
with a JWT-only, no-adapter config that is Edge-safe. middleware.ts now uses
NextAuth(authConfig) from auth.config.ts instead of importing the full auth.ts
(which uses Node crypto via password.ts and breaks the edge runtime).
Full auth with DrizzleAdapter + password hashing stays in auth.ts for server
components, which run in the Node.js runtime.
Fixes: "The edge runtime does not support Node.js 'crypto' module" on localhost.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Migrates all 15 user-data tables from local Postgres to Neon, rewriting
the default user_id (00000000-...) to the GitHub OAuth user_id. Uses
COPY format (binary-safe, no quoting issues) and imports in FK dependency
order. Re-runnable: skips already-populated tables unless --force is passed.
Result: 1324 entities, 2315 interactions, 20 projects, 638 orchestration
events, and all other data now live in Neon — deployed Cockpit now shows
the same data as localhost.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pass recentCommits (last 3, SHA stripped) from GitState to the dispatch
prompt so the model can reason about commit history when deciding QUEUE vs
NEXTBEST — e.g. if the last 3 commits and the next queue item all touch
the same subsystem, QUEUE is the stronger choice over an unrelated nextbest.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
handleAutoInject now pre-fetches /api/control/dispatch when the ready
banner appears — the Groq strategist decides QUEUE vs NEXTBEST based on
the session handoff + pending queue. The dispatch reason surfaces in the
ready banner as an "AI: <reason>" hint so the operator sees why a given
item was selected before the countdown fires.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
NextAuth v5 requires src/middleware.ts to re-export auth as default.
Without it, Next.js 16 Turbopack fails to parse the module tree locally.
Deployed Vercel builds were unaffected.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
POST /api/control/dispatch classifies whether auto-continue should drain
the queue or let the agent follow its own suggested next step, using
llama-3.3-70b-versatile via Groq. Falls back to queue-drain order when
GROQ_API_KEY is absent, preserving existing behavior. Includes defence-in-
depth health gate mirroring the client-side sessionHealthBlocksQueue check.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When handoff reports health:critical or tests:failing, auto-continue no longer
drains the queue. Both handleAutoInject and sendIntent("next_best") check the
session state before shifting a queue item — if blocked, next_best runs instead
so the agent stays focused on recovery rather than pivoting to an unrelated task.
The ready banner reflects this: shows "AI picks recovery task — health critical,
queue paused" instead of the queued item label, so the human knows why their
queued work was held back.
This is Step 1 of the dispatch intelligence path (rule-based, no AI call).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Switching agent now injects quit command into terminal then launches new agent
(e.g. Claude → Codex: injects /exit, waits 900ms, injects codex launch cmd)
- Agent chip shows Switching… spinner during injection
- Pending-changes chip expands to show Commit & push button
(stages all, commits as wip: checkpoint, pushes — shows sha on success)
- quitCommand added to each agent in registry (claude:/exit, codex/gemini: q)
- New API routes: POST /api/control/switch-agent, POST /api/project/commit
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers the distinction between dispatch selection (which to run) and prompt
quality (how to write prompts that compound), the handoff as a report card,
and a 7-step implementation path for embedded AI in Cockpit's dispatch layer.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deployment-specific URLs expire; the stable alias cockpit-orangecat.vercel.app always resolves to production.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Next.js/Vercel rejects having both middleware.ts and proxy.ts. The existing
proxy.ts already protected all app routes and handles the onboarding redirect.
Extended it with /sign-out and /thoughts as public paths.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- ControlPanel shows a 6s "Command queued — local daemon will execute it for <tab>"
notice when inject returns mode=queued (cloud dispatch flow)
- inject() in use-control-data now returns { mode } so callers can branch on it
- Sign-in page hides GitHub button unless GITHUB_CLIENT_ID + GITHUB_CLIENT_SECRET
are both set — prevents confusing OAuth error for unconfigured deployments
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without a middleware, anyone who knows the URL could access /control, /today,
/projects etc. on the public Vercel deployment. Now all app pages require a
session; API routes handle their own auth (some use bearer tokens for the daemon).
Public paths: /, /sign-in, /sign-out, /setup, /thoughts.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>