Commit Graph
1545 Commits
Author SHA1 Message Date
g-butandClaude Sonnet 4.6 6c32560377 fix(smoke): accept 401 for auth-protected API routes, add COCKPIT_SESSION_TOKEN support
smoke.sh was always exiting 1 because auth-required API routes correctly
return 401 without a session — but the script treated anything ≥400 as a
failure. Splits routes into PUBLIC_API_ROUTES (must 2xx) and AUTH_API_ROUTES
(200 or 401 both pass), so the check meaningfully detects 500s without
requiring a live session. When COCKPIT_SESSION_TOKEN is set, all requests
are authenticated and the full DB/query layer is exercised (20/20 routes).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 22:26:55 +02:00
g-butandClaude Sonnet 4.6 07f0c20cf0 fix(scripts): remove dead should_skip_native_popup and fix cp -r nesting
Removes the should_skip_native_popup() function and its call site from
agent-hook-bridge.sh — prefer_browser_ready_ui was removed from the UI
and API, leaving this code checking a setting that no longer exists.

Fixes a repeated-install bug in install-cockpit-app.sh where cp -r into
an existing directory nests the source as a subdirectory instead of
overwriting. Now removes target dirs before copying.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 22:01:18 +02:00
g-butandClaude Sonnet 4.6 b8fa8b89e9 fix(auth): trust localhost in production standalone server
Auth.js v5 in production rejects unrecognized hosts by default, causing
every session check at localhost:3000 to throw UntrustedHost and spam
the journal. The error prevented sign-in from working at all on the local
production server.

Fix: set trustHost from AUTH_TRUST_HOST env var (sourced from .env.local
by cockpit-app.sh at startup). Vercel keeps working via the existing
VERCEL=1 auto-trust. Local .env.local has AUTH_TRUST_HOST=true added.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 21:50:53 +02:00
g-butandClaude Sonnet 4.6 837ecb6f1d feat(daemon): auto-detect local server, prefer it over Vercel
When the local Next.js app (cockpit-app.service) is running, the daemon
now routes all runtime-state pushes and command polls to localhost:3000
instead of cockpitapp.vercel.app. This makes the Control panel on the
local machine show live agent state (via local PostgreSQL) rather than
always showing idle.

Detection logic:
- At startup: probe localhost:3000/api/health up to 8 times (1 s apart)
  so the daemon doesn't race past the app during boot.
- During operation: re-check every 30 s via a shared tmpfile cache so
  both the poll loop and the background push loop agree on the URL.
- Falls back to COCKPIT_BASE_URL (Vercel) when localhost is unreachable.

Updated cockpit-daemon.service to soft-depend on cockpit-app.service
(Wants= / After=) so systemd starts the app before the daemon.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 21:35:05 +02:00
g-butandClaude Sonnet 4.6 d973ad63a8 feat(local): add production server installer and systemd user service
Adds two scripts to run Cockpit locally as a production-grade service
instead of relying on `npm run dev`:

- scripts/cockpit-app.sh: wrapper that sources .env.local and launches
  the Next.js standalone server at localhost:3000. Unsets the bash
  HOSTNAME builtin so the server binds to 0.0.0.0 (not the machine's
  hostname which resolves to 127.0.1.1).

- scripts/install-cockpit-app.sh: one-shot installer that builds the
  production bundle, copies static assets into .next/standalone, writes
  ~/.config/systemd/user/cockpit-app.service, and enables + starts it.
  Accepts --skip-build to reinstall without rebuilding.

Run: npm run install-app  (or npm run build && npm run install-app --skip-build)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 21:27:56 +02:00
g-butandClaude Sonnet 4.6 c8a0d6b7c4 fix(build): remove duplicate middleware.ts that conflicts with proxy.ts
Next.js 16 renamed middleware.ts → proxy.ts. The old file was never
deleted, causing the build to fail with "both middleware and proxy file
detected." Merged the missing public-route exclusions (sign-up,
forgot-password, reset-password) into proxy.ts and deleted middleware.ts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 21:04:11 +02:00
g-butandClaude Sonnet 4.6 b7c2bea591 fix(commands): drain queue for all user IDs, not just isDefault user
The daemon was calling claimNextPendingCommand(getDaemonUserId()), which
only claimed commands stored under the isDefault user's row. Commands
enqueued by a session authenticated via GitHub OAuth (a different DB row
for the same person) were silently ignored and never executed.

Fix: daemon now fetches all distinct userIds from user_projects and
claims commands for any of them. Also makes the claim atomic via a
transaction with FOR UPDATE SKIP LOCKED, preventing a theoretical
double-claim race if two pollers hit the endpoint simultaneously.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 20:52:40 +02:00
g-butandClaude Sonnet 4.6 793957a824 fix(beacon): add missing input_bg token to dark and light palettes
ContinuePopup._build_summary used C['input_bg'] but neither palette
defined it, causing a KeyError crash on every stop hook — popup fell
back to slot-1 auto-continue silently instead of showing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 20:46:01 +02:00
g-butandClaude Sonnet 4.6 2eda5b77cd fix: harden runtime-state lookup + remove dead prefer_browser_ready_ui setting
getUserIdsByProjectNames: replace case-sensitive inArray with lower()-based
equality so conf-file tab names with different casing still resolve the
right user. Also fixes potential LIKE-wildcard injection via ilike.

prefer_browser_ready_ui: the old "open browser window" beacon mode was
replaced by PyQt-primary months ago. The toggle has been a no-op ever
since — remove it from BeaconSettings and the API to stop misleading users.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 20:36:52 +02:00
g-butandClaude Sonnet 4.6 6291bc609b fix(control): resolve actual project owner in runtime-state push
getDaemonUserId() returns the isDefault user's ID, but the owner may be
logged in as a different user (e.g. GitHub OAuth creates a separate row
when the setup user has no email). This caused project_states to be stored
under user A while the SSE read for user B — showing all 20 projects idle
even with Claude running in multiple zellij tabs.

Fix: look up which user actually owns each project via user_projects, fall
back to daemonUserId only for unregistered projects.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 20:24:09 +02:00
g-butandClaude Sonnet 4.6 618a6cde1f fix(control): remove readProjectsMap fallback from clear-context route
Resolves canonical tab name from the user's own DB projects only,
consistent with the same fix applied to agent and inject routes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 20:16:53 +02:00
g-butandClaude Sonnet 4.6 f80cdccf33 fix(control): remove parseProjectsConf leaks from agent and inject routes
applyToOpenTabs in /api/control/agent was merging the owner's conf-file
projects with the current user's DB projects, allowing any authenticated
user to force-restart the owner's Claude sessions.

/api/inject was resolving canonical tab names and project paths from the
owner's conf file before falling back to DB — now DB-only for both.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 20:00:49 +02:00
g-butandClaude Sonnet 4.6 bd7929786b fix(middleware): exclude beacon and health routes from auth
beacon.py calls /api/health (to detect if Cockpit is up) and /api/beacon
(to create/poll/patch sessions) without a session cookie. With these
routes protected the calls were silently redirected to /sign-in, causing
_create_web_session() to always return None and breaking two-way sync
between the PyQt popup and the Control panel ReadyBanner.

/api/beacon writes only ephemeral /tmp data — no user-sensitive state.
/api/health is a no-op check. Both are safe to expose publicly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 19:53:18 +02:00
g-butandClaude Sonnet 4.6 bd0dfe4ddf chore: remove dead DEFAULT_USER_ID constant
No longer referenced in any application code after the data isolation
audit replaced all user-resolution paths with getSessionUserId().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 19:43:21 +02:00
g-butandClaude Sonnet 4.6 ce74277d1d fix(control): remove conf-file fallback that leaked owner projects to all users
Both /api/control and /api/control/stream fell back to parseProjectsConf()
when the authenticated user had no DB projects yet. The conf file contains
the owner's personal project list, so any signed-in user with no projects
of their own would see all of the owner's projects in their control panel.

Fix: drop the fallback entirely. Each user now sees only the projects in
their own user_projects rows. The owner already has their projects there,
so backward compatibility is unaffected. New users who skip onboarding
or haven't added projects yet see an empty control panel — correct.

Also removes the now-dead parseProjectsConf import from both routes and
collapses the usingUserProjects conditional into a single filter+map.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 19:35:52 +02:00
g-butandClaude Sonnet 4.6 fc6282e1fb feat(auth): enforce onboarding flow for new self-registered users
Three-part fix:

1. auth.config.ts — add session callback to propagate onboardedAt from
   the JWT payload so the middleware can check it without a DB lookup;
   add authorized() gate that redirects authenticated-but-not-onboarded
   users to /onboarding for all page routes (API routes pass through so
   the /api/me and /api/user-projects calls from the onboarding page work).

2. sign-up/page.tsx — redirect to /onboarding after registration instead
   of /today, so new users immediately enter the username + first-project
   setup flow.

3. db/queries/users.ts — remove the premature onboardedAt: new Date()
   from createUser(). New self-registered users now have onboardedAt=null
   until they complete /onboarding. createInitialUser() (owner account)
   and the invite flow keep their immediate onboardedAt, since those users
   don't need guided setup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 19:25:21 +02:00
g-butandClaude Sonnet 4.6 4d17f2a928 fix(control): don't label projects idle when daemon state is unknown
When accessing the control panel from Vercel (or any remote browser)
and the local daemon is offline or has never connected, the DB shows
agentRunning=false for every project — not because they're idle, but
because there's no live signal. This caused the Cockpit project itself
(with an active Claude session) to appear in the "Idle projects" section.

Fix: when daemon is offline/never-seen, collapse the active/idle split
entirely and show all projects in the main list. The DaemonStatusBanner
already explains why state is stale; the fleet view no longer claims
projects are idle when it simply doesn't know.

Also made ControlMetricCard.note optional so the "N idle" note can be
suppressed in the stat card when daemon state is unknown.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 19:16:19 +02:00
g-butandClaude Sonnet 4.6 fe282bf761 fix(auth): GitHub OAuth creates separate accounts per user
Replaced the hard-coded default-user link in the signIn callback.
Previously, every new GitHub login was linked to the default user.
Now allowDangerousEmailAccountLinking lets the DrizzleAdapter link
GitHub accounts to existing Cockpit users by email match (safe: GitHub
verifies email addresses). New users get their own account; returning
users continue via existing account lookup. signIn callback reduced to
profile field updates only.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 18:59:23 +02:00
g-butandClaude Sonnet 4.6 689a315ca7 fix(auth): complete data isolation — remove DEFAULT_USER_ID fallback, add daemon bypass
Security fixes:
- auth.config.ts: middleware now allows COCKPIT_DAEMON_TOKEN bearer requests through,
  so the local daemon works correctly after middleware was added in the previous commit.
  Individual daemon routes still enforce their own auth; middleware is the first gate.
- lib/session.ts: removed DEFAULT_USER_ID fallback that silently returned the owner's
  data for unauthenticated requests. Replaced with:
    requirePageUserId()  — server components/actions: redirects to /sign-in if no session
    getSessionUserId()   — API routes: returns null for explicit 401 handling
  getCurrentUserId() is now a deprecated alias for requirePageUserId().

Call-site migrations:
- 22 server component files (pages + today/* + system/*): getCurrentUserId → requirePageUserId
- 35 API route files: getCurrentUserId → getSessionUserId + explicit 401 guard
  (one exception: beacon appendDevLog helper silently skips on no session to avoid
  breaking the beacon response for an internal logging side-effect)
- project-states/[key]: fixed concurrent Promise.all that mixed data fetch with auth

Result: every data-access path now explicitly enforces authentication. Unauthenticated
requests to server components redirect to /sign-in; API calls return 401 JSON. No path
silently falls back to owner data.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 18:47:51 +02:00
g-butandClaude Sonnet 4.6 9650985d97 fix(auth): remove unused imports in sign-up and reset-password pages
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 18:31:05 +02:00
g-butandClaude Sonnet 4.6 bbe92fae7a feat(auth): multi-user registration, email sign-in, forgot/reset password
Self-service registration flow:
- POST /api/auth/register — creates account (email+name+password)
- /sign-up — registration form; auto-signs-in after creation

Email+password sign-in:
- New 'email-password' Credentials provider in auth.ts
- SignInForm updated: email+password primary, 'forgot password?' link,
  'Create account →' footer; owner key accessible via collapsible fallback

Forgot/reset password flow:
- password_reset_tokens table (2-hr expiry, single-use, auto-invalidates)
- POST /api/auth/forgot-password — creates token, sends via Resend REST API
  (falls back to console log when RESEND_API_KEY is unset)
- POST /api/auth/reset-password — validates + consumes token, hashes new password
- /forgot-password — email input; always shows 'check your email' (no user enumeration)
- /reset-password/[token] — new password form, redirects to sign-in on success

Infrastructure:
- src/middleware.ts — NextAuth edge middleware protecting all app routes;
  excludes sign-in, sign-up, forgot-password, reset-password, invite, API auth
- src/lib/email.ts — thin Resend REST wrapper (no package dep)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 18:25:20 +02:00
g-butandClaude Sonnet 4.6 e9e85447cf feat(settings): transcription provider selector — local / groq / auto
Adds a per-setting choice between local Whisper and Groq cloud so the
operator can force local when Groq rate-limits hit, or force Groq when
the runtime isn't active. 'auto' preserves the old behavior.
Stored in ~/.config/agent-dashboard-settings.json alongside whisper_model.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 18:03:22 +02:00
g-butandClaude Sonnet 4.6 c1ca3909a6 fix(transcribe): strip codec suffix from Groq audio filename
MediaRecorder uses 'audio/webm;codecs=opus' as MIME type; splitting on '/'
gave 'webm;codecs=opus' as the extension, which Groq could not recognize.
Now strip everything after ';' so Groq receives 'audio.webm'.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 17:55:57 +02:00
g-butandClaude Sonnet 4.6 56e3e84360 feat(prompts): fleet control + security categories, comprehensive library
Add 'fleet' and 'security' as first-class categories, each with its own
color token (amber and red). Fleet Control leads with 'Next Best Step' as
the flagship prompt — the autonomous agent execution entry point — plus
Continue Task, Test & Fix, Commit & Push, Review & Clean, Full Health Check.

Security gets six prompts covering the full threat surface: Security Audit,
Auth & Session Audit (IDOR, CSRF, session fixation), Data Exposure & Privacy
Audit (PII mapping, GDPR), API Security Review, Dependency CVE Scan, and
OWASP Top 10 Check. All six are detailed, actionable, and tuned for the
multi-user / private-data context of the platform.

All fleet prompts are featured so they appear in Quick Access. The two new
categories are ordered first so they're the most discoverable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 17:43:34 +02:00
g-butandClaude Sonnet 4.6 f114a76696 fix(queue): wire onMergeItems to non-running QueueList
Multi-select merge was silently broken when the agent was waiting/idle
— the most common state for queue editing. The running-state branch
already passed the prop; the non-running branch was missing it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 17:31:57 +02:00
g-butandClaude Sonnet 4.6 e05f5a7056 feat(control): full-screen focus mode with project tab switcher
When a project is focused, the brain panel and metrics grid collapse
so the ProjectCard expands to fill the full page width. A compact
horizontal tab bar replaces the old banner — each active project
appears as a pill with a live status dot, clicking switches focus
without returning to the fleet view first.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 17:22:36 +02:00
g-butandClaude Sonnet 4.6 efe70bccec fix(queue): pure remove() updater + commander view consumes queue
Two behavioral fixes:

1. remove() side effects were inside the setQueue updater — React Strict Mode
   and concurrent mode can invoke updaters multiple times, causing double file
   writes and duplicate PUT requests to /api/beacon/queue. Moved localStorage
   write and writeToFile() call outside the updater; updater is now a pure
   filter. This matches the pre-existing pattern used by shift().

2. ProjectCommanderCard.advance() bypassed the queue entirely — it went straight
   to onRunWithBrain("next_best") even when items were queued. Switching to
   commander view silently broke queue dispatch. Fixed: now calls shiftQueue()
   first, injects the queued item if present, falls back to next_best otherwise.
   Also surfaces queue state in the card: context line shows queue[0] when ready,
   button shows "Send (N)" with a count tooltip instead of plain "Continue".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 17:10:42 +02:00
g-butandClaude Sonnet 4.6 d851185c26 feat(beacon): install-beacon.sh — standalone installer for any machine
Cockpit Beacon can now be installed independently of the Next.js web app.
The popup (PyQt6 session-stop overlay + queue + prompt dispatch) works
without a running Cockpit server — web sync is an optional enhancement.

Changes:
- scripts/install-beacon.sh  — new installer
  Copies beacon scripts to ~/.local/share/cockpit-beacon/
  Wires ~/.claude/hooks/stop.sh and notification.sh (backs up existing)
  Creates ~/.config/agent-prompts.json with a working default prompt set
  Creates ~/.config/agent-projects.conf with format instructions
  Checks for PyQt6, jq, zellij, xrandr and prints targeted install hints

- scripts/agent-hook-bridge.sh  — PyQt6 detection order fixed
  beacon_python() now prefers system PyQt6 (pip install PyQt6 or
  apt install python3-pyqt6) and falls back to the .python-vendor
  bundle only when system install is absent — making standalone use
  work without the Cockpit repo on disk

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 16:56:13 +02:00
g-butandClaude Sonnet 4.6 048a66b8c7 fix(queue): clear selection on reorder, atomic remove() via setQueue updater
- After drag-to-reorder, selected Set still held old indices — item X selected
  could now refer to a different item at that position. Clear on drop instead.
- remove() was reading from localStorage which may lag behind React state when
  called immediately after enqueue(). Switch to setQueue updater form so next
  is derived from the authoritative React state, then write localStorage and
  file synchronously inside the updater before returning.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 16:43:59 +02:00
g-butandClaude Sonnet 4.6 b21a6d933a refactor(queue): smooth dnd-kit drag, content-based sync guard, multi-select merge
Queue was the most important interface — the bridge between the human's intent
and agent execution — and it had three reliability failures:
  1. Items "came back": time-based poll skip window raced with async writes
  2. Double-write on remove(): direct file write + effect-triggered write
  3. Janky drag: native HTML5 DnD with only a background flicker on hover

Fixes:
- content-based sync guard (lastWrittenRef): poll only applies updates when file
  content ≠ last write — our own echoes are silently skipped regardless of timing
- single write per action: remove()/shift() set lastWrittenRef before setQueue so
  the sync effect sees a no-op and returns early
- @dnd-kit/sortable: smooth animated displacement during drag, DragOverlay for the
  floating ghost, PointerSensor with distance:5 constraint prevents accidental drags
- multi-select: checkboxes on each item, "Merge (N)" concatenates selected items
  with double-newline at the first selected position, clears selection after

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 16:33:49 +02:00
g-butandClaude Sonnet 4.6 80f3313f9b feat(control): launch agent with initial task from web app
LaunchTabModal now has an optional "Initial task" textarea. When filled:
- Server writes the prompt to /tmp/agent-queue-{tab} immediately (queue
  file fallback — beacon auto-continue picks it up on first stop).
- Server polls /proc every 3s for the agent process to appear in the
  project dir, then injects directly via injectIntoTab (up to 30s / 10
  attempts). Queue file is cleared on successful direct inject.
- Button label changes from "Launch" → "Launch & run" when a task is set.

No changes to the no-prompt launch path — fully backwards compatible.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 16:08:13 +02:00
g-butandClaude Sonnet 4.6 d244ffa668 feat(beacon): PyQt-primary popup with queue always visible + recent prompts
- beacon.py: PyQt opens immediately; web session only created when Cockpit
  is already running (2s check). Eliminates 1-3s startup delay. Web poll
  runs in daemon thread every 3s to sync control-panel choice back to popup.

- _beacon_popups.py: queue section always visible with hint text when
  empty ("Alt+Enter to add · runs automatically when session ends").
  Adds collapsible "Recent" section showing last 5 dispatched custom prompts,
  stored in ~/.local/share/cockpit/prompt-history.json. Clicking a recent
  item fills the custom input for editing before send.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 15:48:00 +02:00
g-butandClaude Sonnet 4.6 6d39347e28 fix(system): error state + retry + 30s auto-refresh on SystemStats
Applies the same FetchErrorState pattern used by Weather/Calendar/GitHub
cards — shows a friendly message with a Retry button instead of bare static
text on fetch failure. Also adds intervalMs:30s so RAM/disk numbers stay
live without a manual page reload.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 15:30:50 +02:00
g-butandClaude Sonnet 4.6 a98541ce60 feat(live-cards): auto-refresh live data without loading flash
useFetch gains an optional intervalMs parameter that silently re-fetches
in the background. Uses setRevision (stable useState setter) directly in
the interval — no ref pattern needed.

Applied intervals: calendar 5 min, weather 10 min, GitHub CI 2 min —
so the Today page stays current for users who leave it open all day.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 15:19:41 +02:00
g-butandClaude Sonnet 4.6 3c0e029678 fix(daemon): resolve promptKey to full prompt text on inject
Cloud mode queues inject commands with prompt=promptKey (the raw key string)
because the full text isn't available server-side. The daemon now reads
promptKey from the payload and calls _resolve_prompt(), which looks up the
prompt text via get_prompt() from agent-prompts.json and wraps it with
session context (mirroring buildPromptWithSession in TypeScript), so the
correct expanded prompt is injected into the Zellij tab instead of the
literal key name.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 15:02:55 +02:00
g-butandClaude Sonnet 4.6 640eb76e45 fix(ux): friendly error states with retry across Weather, Calendar, GitHub cards
All three cards were showing raw error strings ({error ?? data?.error})
to users with no recovery path. Fixed across the board:

- useFetch: add refetch() function (revision counter) + reset loading/error
  on re-fetch so stale state doesn't persist between attempts
- FetchErrorState: new shared component — friendly message + Retry button
- WeatherCard: add error/data.error branch → FetchErrorState; "Unavailable"
  now only shows when runtime is offline (not when tool actually fails)
- CalendarCard: replace raw error div with FetchErrorState + refetch
- GitHubStatus: same fix

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 14:54:36 +02:00
g-butandClaude Sonnet 4.6 b8504a2c63 feat(control): DaemonStatusBanner — actionable offline state instead of hidden tooltip
The daemon offline/never-connected state was surfaced only as a
hidden sm:inline span with a title tooltip — invisible on mobile,
cryptic on desktop. Replace with a full DaemonStatusBanner that:

- Renders below the main grid when daemonNeverSeen or daemonOffline
- Shows two states: "not connected" (first time) vs "offline" (went away)
- Displays the exact shell command to start/restart the daemon
- Notes where to find the COCKPIT_DAEMON_TOKEN
- Is dismissible per-session via local state
- Header retains a small amber dot indicator pointing to the banner

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 14:44:54 +02:00
g-butandClaude Sonnet 4.6 409930eb36 feat(billing): plan-based project limit gating
- src/lib/plan.ts: PLAN_LIMITS config (free=3, personal=5, pro/team=∞)
  with getProjectLimit() and isUnlimitedProjects() helpers
- db/queries/user-projects: add countActiveProjects() for efficient count
- POST /api/user-projects: enforces limit for non-default users; owners
  (isDefault=true) and unlimited-plan users are always allowed through
- ProjectsSettings: shows "N / limit projects" counter and "limit reached"
  badge when at cap; Add button disabled with upgrade tooltip; upgrade
  nudge banner links to /settings#billing
- Settings page: passes projectLimit=null for owner and unlimited plans,
  or the finite limit for free/personal users

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 14:35:44 +02:00
g-butandClaude Sonnet 4.6 830f90341f feat(billing): wire pricing CTA → sign-in → Stripe checkout
- GET /api/checkout/[plan]: auth-protected redirect route that creates a
  Stripe checkout session (or bounces back to sign-in with callbackUrl
  preserved if unauthenticated)
- Landing pricing CTAs now link to /sign-in?callbackUrl=/api/checkout/<plan>
  when Stripe is ready, so the full funnel is connected end-to-end
- BillingSettings reads ?billing= query param on mount and shows a status
  notice (success / canceled / error / not-configured / already-active),
  then strips the param from the URL so it doesn't persist on refresh
- Suspense wrapper added around BillingSettings in settings page

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 14:23:46 +02:00
g-butandClaude Sonnet 4.6 c47a22eb5f feat(billing): Stripe subscription infrastructure — schema, routes, BillingSettings UI
Adds complete ready-to-activate payment infrastructure:
- DB: plan/planStatus/stripeCustomerId/stripeSubscriptionId on users table
- src/lib/stripe.ts: Stripe client + price ID config (returns null until keys added)
- /api/stripe/checkout: creates checkout session for personal/pro/team plans
- /api/stripe/portal: redirects to Stripe billing portal for subscription management
- /api/stripe/webhook: handles subscription lifecycle (activated, updated, canceled)
- BillingSettings component: shows current plan, monthly/annual toggle, upgrade cards
- Settings page: BillingSettings wired in above ProjectsSettings
- Landing: pricing CTAs pass ?plan= param when Stripe is ready

Activate by adding to .env.local:
  STRIPE_SECRET_KEY=sk_live_...
  STRIPE_WEBHOOK_SECRET=whsec_...
  STRIPE_PRICE_PERSONAL_MONTHLY=price_...
  STRIPE_PRICE_PERSONAL_ANNUAL=price_...
  STRIPE_PRICE_PRO_MONTHLY=price_...
  STRIPE_PRICE_PRO_ANNUAL=price_...
  STRIPE_PRICE_TEAM_MONTHLY=price_...
  STRIPE_PRICE_TEAM_ANNUAL=price_...

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 14:08:06 +02:00
g-butandClaude Sonnet 4.6 e2d2d07741 fix(invite): auto sign-in after invite acceptance now works
The local credentials provider signs in only the default (owner) user, so
the post-acceptance signIn("local") call was always authenticating as the
wrong account. Added a user-password credentials provider that looks up
any user by ID and verifies their password hash, then wired the invite
page to use it with the userId returned by the accept API.

Also distinguishes expired vs already-used invite states so the error
message is specific rather than generic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 13:52:52 +02:00
g-butandClaude Sonnet 4.6 3d956e2356 feat(control): agent switching in cloud mode via daemon queue
switch-agent route returned 503 in cloud mode. Now enqueues a
switch_agent pending command instead, which the local daemon claims
within its 5s poll cycle and executes:
  1. injects the quit command for the current agent (e.g. /exit for claude)
  2. waits 1s for exit, then injects the launch command for the new agent

Schema: adds SwitchAgentPayload type and "switch_agent" to the type comment.
Queries: adds enqueueSwitchAgentCommand.
Daemon: adds execute_switch_agent + _agent_quit_cmd + _agent_launch_cmd
  helpers; adds switch_agent case to the main dispatch loop.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 13:37:43 +02:00
g-butandClaude Sonnet 4.6 ac941900a2 fix(auth): clarify sign-in page copy — Local password → Password, owner password divider
"Local password" read as localhost-specific jargon. Renamed to "Password".
Divider now says "or owner password" to distinguish the admin bypass from
the GitHub OAuth path for regular users.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 13:24:59 +02:00
g-butandClaude Sonnet 4.6 252eabb80c refactor(goals): extract GoalCard state/handlers into use-goal-card hook
GoalCard was 319 lines (component limit: 300). State declarations and five
async handlers moved to use-goal-card.ts — business logic separated from
rendering. Component is now 239 lines, hook is 111 lines.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 13:18:06 +02:00
g-butandClaude Sonnet 4.6 1b1e6e910e fix(control): remove git-dirty from attention bar; compact idle tile launch label
Attention bar was filled with routine "N uncommitted" noise from git dirty
state, crowding out real health signals (critical, failing tests). Git state
is already visible in per-project header chips and idle tiles.

Idle tile launch button showed "codex · gpt-5.4" which wrapped onto three
lines in the compact grid. Model is already in the title tooltip; showing
only the agent name keeps the chip single-line.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 13:07:26 +02:00
g-butandClaude Sonnet 4.6 e331b586e7 feat(control): live tab state via SSE + daemon sync indicator
tabOpen propagation:
- Add tabOpen to FastProjectState; local path derives it from zellijTabCache,
  cloud path reads it from DB (daemon-pushed).
- SSE change detection now fires when tabOpen changes so projects move
  between active/idle immediately, not after the next 30s poll.
- mergeProjectPatches updates zellijTabs from incoming tabOpen patches
  so the client's tab list stays live without a full page refresh.

Daemon status indicator (cloud mode only):
- daemonLastPushedAt computed from MAX(project_states.updatedAt) —
  no extra query, derived from the already-fetched dbStatesArr.
- ControlPanel header shows "daemon Xs ago" when connected,
  "daemon offline" when >90s stale, "daemon not connected" when never seen.
- Gives cloud users clear feedback when their local daemon is down.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 12:50:38 +02:00
g-butandClaude Sonnet 4.6 3de153031d fix(control): cloud-mode next-best-step + disable redundant auto-inject
Three improvements for web (Vercel) users:

1. orchestration/run: for claude adapter in cloud mode, render the intent
   prompt and enqueue via pending_commands instead of returning 503.
   The local daemon picks it up and injects. Other adapters still 503
   (they require local workers).

2. runtimeAvailable flag: exposed in ControlData API response and
   threaded down to ProjectCard so cloud mode is detectable client-side.

3. ReadyBanner auto-inject: disabled when runtimeAvailable=false
   (no onAutoInject prop passed). The local stop hook already handles
   auto-continuation the moment Claude finishes — the cloud countdown
   firing 12s later would double-inject on top of running work.
   Manual dispatch buttons still work in cloud mode.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 12:28:48 +02:00
g-butandClaude Sonnet 4.6 0b1585a9da fix(control): surface launch errors in modal + fix Zellij session discovery
Three-layer fix for silent launch failure on web:
- agent-runtime: discover ZELLIJ_SESSION_NAME via env or full session scan
  so zellij action calls work when running outside a Zellij pane
- api/agent/launch: guard with isRuntimeAvailable() — returns 503 with
  helpful message instead of hanging when launched from cloud/Vercel
- use-control-data: launchProject now checks res.ok and throws so the
  error propagates to LaunchTabModal's error prop instead of silently
  closing the modal

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 12:11:26 +02:00
g-butandClaude Sonnet 4.6 f625c48478 feat(nav): add More drawer to mobile nav — all 14 views now reachable
Previously 9 of 14 views (Habits, Events, Money, History, Prompts, System,
Memory, Thoughts, Settings) were completely inaccessible from mobile — the
bottom bar only showed the 5 mobile:true items with no overflow path.

Add a 6th "More" button that opens a bottom sheet with the 9 overflow items
in a 3×3 grid. Sheet closes on tap-outside, on link navigation, or on the
X button. "More" button highlights as active when the current path is an
overflow item, giving correct active-state feedback.

No config changes — NAV_ITEMS is still the SSOT; OVERFLOW_ITEMS is derived
by filtering mobile:false at runtime.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 11:57:34 +02:00
g-butandClaude Sonnet 4.6 0bf662ac10 fix(transcribe): Groq Whisper cloud fallback + extract AgentSwitcherPopover
Transcribe route: replace daemon-relay remote path with direct Groq Whisper
API call (whisper-large-v3-turbo). Cuts remote transcription from 8-15s to
2-4s and removes the polling/result-TTL complexity entirely. GROQ_API_KEY
must be set in Vercel env vars. Local path (Whisper via Python) unchanged.

Add callGroqTranscribe() to lib/groq.ts alongside the existing callGroqText()
so both text and audio inference share the same API client module.

Extract AgentSwitcherPopover from ProjectStatusChips (306→253 lines) into
its own focused file — removes the circular useRef/useEffect block from the
parent component.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 11:48:26 +02:00