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>
Both routes use child_process to run claude CLI and git pull respectively —
neither is available on Vercel. Returns 503 with descriptive message.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
spawn() and zellij inject are not available on Vercel.
The orchestration run endpoint now returns a clear 503 instead of crashing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three routes called child_process / zellij / ffmpeg without checking whether
the local runtime is present. On Vercel they would crash or return opaque 500s.
- agent route: skip applyToOpenTabs with an explanatory skipped result
- transcribe route: return 503 in cloud mode (ffmpeg/whisper not installed)
- bootstrap route: return 503 in cloud mode (local dir + git ops won't work)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
getCurrentUserId() falls back to a hardcoded ID when no session exists.
For the daemon bridge endpoints this would let any unauthenticated request
read/mutate the command queue. Use auth() directly: daemon bearer token
validates against DB is_default user, browser requests require a real session.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The daemon token authenticates the machine; the server finds the default
user automatically. Removes COCKPIT_DAEMON_USER_ID requirement so the
daemon works before the operator knows the Neon-assigned UUID.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds the missing link between cloud dispatch and local execution:
- GET /api/control/commands — claim next pending command (daemon auth via bearer token)
- PATCH /api/control/commands/[id] — mark command executed with result
- scripts/cockpit-daemon.sh — polls Vercel every 5s, executes inject/focus_tab via zellij
The daemon authenticates with COCKPIT_DAEMON_TOKEN. COCKPIT_DAEMON_USER_ID lets it
claim commands without a session cookie so it can run headlessly as a background service.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add pending_commands schema + queries: command queue table that the local
daemon polls when the cloud control plane is not co-located with zellij
- Add src/lib/runtime.ts: isRuntimeAvailable() reads RUNTIME_AVAILABLE env var
(set to "true" locally, absent on Vercel) — single source of truth for the
local/remote split
- Add src/lib/executor.ts: executeInject() routes to injectIntoTab() (direct)
or enqueueInjectCommand() (DB queue) based on runtime availability; callers
express intent once, the executor picks the mechanism
- Refactor /api/inject: use executeInject(); all DB side-effects (prompt history,
orchestration events, project state) run in both modes; file-system writes
(stateFile.prompt, sentinel, closing) guarded behind isRuntimeAvailable()
- Guard /api/control/focus-tab, /api/weather, /api/github, /api/calendar,
/api/system with early returns when runtime is unavailable — clean empty
responses instead of timeout errors on Vercel
- Add RUNTIME_AVAILABLE=true to .env.local; push pending_commands table to DB
- Add thoughts articles: portable creation cockpit vision + dispatch intelligence
problem (blind queue drain vs contextual AI triage)
- Control panel: agent switcher popover on runtime chip, cross-session
focus-tab, sticky left panel, Projects↔Control navigation bridge,
ClaudeSession uses runtimeState.tabName instead of entity name
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Writes sentinel + closing + closed files immediately so stop.sh never
re-opens the tab. Claude adapter skips session context to inject the
bare stop directive; codex adapter follows the same sentinel logic.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The abandoned goal flow added in 4e0de3e left a gap: getGoalStats only
counted active/completed, so the StatCard sub-text showed 'X completed'
while silently omitting any abandoned goals. Now counts all three states
and shows 'X completed · Y abandoned' (or just the non-zero ones).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The habit scheduling query hardcoded 'daily'/'weekdays'/'weekly' strings
directly in the SQL template instead of the HABIT_FREQUENCY constants
that are the canonical SSOT for these values. Now uses parameterized
template interpolation so a rename only requires changing statuses.ts.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The original page hardcoded 'en-US' locale for date formatting while
the rest of the codebase uses APP_LOCALE (COCKPIT_LOCALE env / 'de-CH').
HistoryFeed client component:
- Uses APP_LOCALE for all date/time formatting
- Project filter chips (hide project column when filtered — wider prompt
column makes the text readable at a glance)
- groupByDay / format helpers moved out of the server page
Server page is now thin: fetch + empty state + <HistoryFeed>.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Every agent dispatch (inject + orchestration) has been stored in
prompt_history since the table was created. This surfaces it:
- getPromptHistory() query fetches last 200 rows without the 24h cap
- /history page groups dispatches by calendar day, shows time /
project / prompt text / adapter badge
- History nav item added (non-mobile)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GOAL_STATUS.ABANDONED existed in the SSOT but nothing used it — abandoned
goals silently piled up in the active list. Now:
- GoalCard: Archive button marks goal abandoned; toggles back to active;
blocked when completed. Title/desc/progress editing guarded by isClosed.
- AbandonedGoals: collapsible section (mirrors CompletedGoals)
- GoalsGrid: renders AbandonedGoals, filtering respected
- Goals page: splits tree into active / completed / abandoned correctly
- patchGoal: clears completedAt when transitioning to ABANDONED
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30 dots in a flex-wrap row were hard to read for day-of-week patterns.
New layout: Mon-first 7-row × N-week grid (GitHub contributions style)
with M/W/F/S labels on the left so weekday vs weekend consistency is
immediately visible.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
scheduledDays is pure logic — no DB dependency — so it belongs alongside
isHabitScheduled in statuses.ts. HabitCard now imports from the constants
file instead of from the db/queries layer.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
isDue (HabitHeatmap) and isScheduled (habits query) contained identical logic.
Moved to lib/constants/statuses.ts alongside HABIT_FREQUENCY. HabitHeatmap
frequency prop strengthened from string to HabitFrequency.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
NotesSection and DevLogSection each called useFetch for the same endpoint.
Now fetched once in ProjectProfile and passed as props. Also extends useFetch
to accept null URL (skips fetch when no ID available).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The 4-line unlinkSync block for stale handshake files appeared identically in
inject/route.ts and orchestration/run/route.ts. Centralized in agent-config.ts.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three callsites passed identical GOAL_PROGRESS_THRESHOLDS to ProgressBar+getProgressTone.
GoalProgressBar bakes in those thresholds, reducing 3 imports to 1 per file.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Previously computeStreak broke on any day with no completion, so a
weekdays-only habit would show 0 streak on Saturday even with a full
week of completions. Also deduplicates isDueToday → isScheduled.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The 4-line Map<habitId, Set<completedDate>> construction appeared in both
listHabitsForToday and getHabitHeatmapData. Extracted to a shared helper.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The 7-line streak loop appeared twice — once using HABIT_HISTORY_DAYS
as the bound (listHabitsForToday) and once using a dynamic days param
(getHabitHeatmapData). Extracted to a private computeStreak(dates, maxDays)
function eliminating the duplication.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The repeating inline-edit input pattern (bg-surface-raised border rounded
outline-none transition-colors with focus:border-border-strong) appeared
14 times across 9 components with no shared class. Adds ui-input-inline
to globals.css as the single source of truth for click-to-edit inputs on
raised surfaces. Callers supply their own padding, text-size, width, and
border-strength overrides as needed.
Files updated: HabitCard, CommitmentItem, GoalCard, goal-card-helpers,
HabitRow, LogConversationButton, ProjectInlineEditors, ProjectPromptsTab,
project-overview-helpers.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Eliminates the duplicate type Agent = "codex" | "claude" that violated
the single-source-of-truth principle.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CreateEventInput, PatchEventInput, MilestoneSchema, SubscriptionRow,
PatchSubscriptionInput, LatestLifecycleEvents, PatchProjectInput,
PatchCommitmentInput — all referenced only within their own query file,
never imported by route handlers or components.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
WhisperModel (beacon), CHANNEL_ATTR_PREFIX + ChannelConfig (channels),
PromptScope (prompt-library), SubscriptionMeta (subscriptions) — all
had zero external callers and are only referenced within their own file.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
agent-registry: remove sanitizeAgentOption, getDefaultAgentId,
getAgentRegistryEntry, getDefaultAgentConfig, sanitizeAgentConfig,
listSwitchableAgentRegistry — all had zero external callers.
agent-config: make CLAUDE_HOME, PROJECTS_CONF, CLAUDE_PROJECTS_CONF,
CLAUDE_PROMPTS_FILE, PromptConfig, readPromptConfig private — only
used within the file.
agent-preferences: make AGENT_PREFERENCES_FILE private.
agent-catalog: make AgentCatalogEntry private.
constants: make OPENCLAW_DIR, WORKSPACE_DIR private.
utils: make UUID_RE private.
session-content: make ParsedSession private.
crons: make CronFileData private.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ProjectTab, SwitchTabResult, getConfiguredProjectTabs, getOpenZellijTabs,
restartTab, and restartOpenProjectTabs had zero external callers. The
internal helpers (getOpenZellijTabs, restartTab) are kept as private
functions since launchAgentInTab still depends on them.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The export was unused — both control routes import from control-fast-state.ts
which has the correct basename-only matching. The agent-runtime version used
a full cmdline scan that produced false positives on bash shell-snapshot scripts
and was superseded when control-fast-state.ts was introduced.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
isOrchestrationReady was not included in isActive, so projects where an
orchestration run just finished were buried in the collapsed idle grid
instead of appearing in the active section where the user can see the
result. The sort rank was already correct (rank 2, same as isReady) but
the active/idle split was wrong.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Removed three duplicates in agent-preferences.ts:
- local `type Agent` (same as registry export)
- local `sanitizeAgentId` (identical implementation)
- local `syncClaudeSettings` (same logic as registry's syncAgentSettings)
Now calls syncAgentSettings("claude", ...) directly instead of re-deriving the
~/.claude/settings.json path inline.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both maps cover the same health labels (good/excellent/needs-attention/degraded/critical)
so an agent writing "degraded" no longer silently falls through to neutral tag style
in DevLogList and the public profile page.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>