Replace cold-open-per-session with a persistent /beacon/live tab that
stays open in the --app= frameless window. New SSE endpoint polls
/tmp/cockpit-beacon/ at 150ms and pushes fresh sessions to the tab,
so the popup appears in < 150ms with no browser cold start.
beacon.py now tracks the live-browser PID and focuses the existing
window instead of launching a new one. BeaconPageClient accepts onClose
so the live tab resets to standby instead of calling window.close().
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two fixes to make the beacon popup work without requiring the browser to
be logged into Cockpit:
1. Server-side initial session read — page.tsx is now a Server Component
that reads the beacon session directly from /tmp/cockpit-beacon/{id}.json
before sending HTML to the browser. The client receives a fully-populated
initialSession prop and shows session content immediately — no client-side
GET /api/beacon/{id} needed on page load. The PATCH (recording the user's
choice) and the cancel-detection poll still go through the API, which
works as long as the browser that opens the popup has a Cockpit session.
2. Prefer Brave browser for the popup — beacon.py now checks for brave-browser
before google-chrome in the candidate list. The user's Cockpit session
lives in Brave (the primary browser), so opening there means API calls
from the beacon page are authenticated automatically.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two bugs preventing the popup from working:
1. /api/beacon was matched by the auth middleware (401 for unauthenticated
beacon.py). Added api/beacon to the middleware exclusion list — sessions
are /tmp UUIDs with no sensitive data.
2. FocusCancelTextEdit(QPlainTextEdit) called setAcceptRichText which does
not exist on QPlainTextEdit (it's a QTextEdit method). Removed the
redundant call — QPlainTextEdit is plain-text-only by definition.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Header loading text becomes a pulse pill; sidepanel shows 4 skeleton
metric cards while useControlData fetches, matching the real 2×2 grid.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GitHubStatus showed 'Checking repos...' text; now shows 3 repo-row
skeletons (status icon circle + name bar / PR count + CI name bars).
PersonDetail drawer showed 'Loading...' text; now shows description
block, 2x2 attribute grid, and 3 interaction-row placeholders — matching
the actual drawer body layout.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both cards showed unstyled loading text while every other card on /today
used animate-pulse placeholder blocks. CalendarCard now shows 3 event-row
skeletons (time col + title/location); WeatherCard shows the icon + temp
+ condition block layout, keeping visual structure consistent during load.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- stripe/portal: remove copy-paste duplicate if (!userId) guard (dead code)
- money page: remove hardcoded Apr 2026 verification date that was already
stale and would keep rotting; label remains without the date
- smoke.sh: add /api/setup (public), /api/checkout/personal, and
/api/stripe/portal (accepts 401 + 503 when Stripe not configured);
extend check_route with extra_ok_code param for integration-gated routes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All four operations (frequency change, active toggle, done toggle, delete)
previously swallowed errors silently after reverting optimistic state.
Now flash a 3-second inline error message below the card on failure.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The owner key tab was always visible even when LOCAL_AUTH_PASSWORD is not
set, confusing users who don't use local auth. Now conditional on the env
var (passed server-side to avoid hydration mismatch).
Also moves the "No account?" link inside the email AuthCard instead of
using AuthFooterLink below, which visually associates it with the form.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PeopleGrid was rethrowing non-abort errors into a discarded promise, leaving
users looking at stale results or an empty list with no indication that the
search failed. Now sets fetchError state, shows an inline error banner with a
Retry button, and clears the error on the next successful fetch.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- SummaryBar: add SummaryBarSkeleton (5 animated pills) as Suspense fallback
instead of null — /today no longer shows blank space during DB queries
- ProfileSettings: show actual window.location.host instead of hardcoded
'cockpit.app' in the username prefix — correct on localhost and Vercel
- BeaconSettings: surface load failure with an error message instead of
silently rendering defaults when /api/beacon-settings is unreachable
- ProjectsSettings: reorder now reverts UI and shows error if any PATCH
fails — previously silent failure left UI and server out of sync
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
/api/health now returns { ok, runtime, version } — runtime signals whether this
is the local machine instance (RUNTIME_AVAILABLE=true) vs a cloud deployment,
enabling scripts and monitoring to distinguish the two without auth.
Beacon POST purges sessions older than 10 minutes from /tmp/cockpit-beacon/
on each new creation, preventing unbounded accumulation over time.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Renamed src/middleware.ts → src/proxy.ts (Next.js 16 convention)
- Removed stale src/middleware.ts that conflicted with proxy.ts
- authorized() callback now returns JSON 401 for /api/* routes instead
of redirecting to sign-in (clients expect JSON, not HTML redirect)
- Added api/crons and api/system to matcher exclusions — these are
intentionally public endpoints used by the daemon and monitoring
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both routes use fs.readFileSync without any Next.js dynamic API call, so
Next.js could statically pre-render them and bypass middleware. Added
`export const dynamic = "force-dynamic"` plus explicit getSessionUserId()
checks — /api/sessions also allows daemon bearer-token requests.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
auth.config.ts had a complete authorized() callback (unauthenticated →
/sign-in, not-onboarded → /onboarding, daemon bearer token pass-through)
but no middleware.ts to wire it up — it was dead code.
Uses NextAuth(authConfig).auth, an edge-safe instance with no DB adapter
or Node.js crypto. The matcher uses .+ (not .*) so the bare / path
(public landing page) is excluded without needing extra matcher logic.
Matcher explicitly excludes all public surfaces: landing (/), auth pages
(sign-in, sign-up, forgot-password, reset-password, setup, invite),
public content (whitepaper, thoughts, u/, beacon), NextAuth internals
(api/auth), and infrastructure endpoints (api/health, api/setup).
Verified: landing 200, /today unauthenticated → /sign-in?callbackUrl=%2Ftoday,
sign-in 200, whitepaper 200. All 28 smoke routes green.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a sliding-window in-memory rate limiter (lib/rate-limit.ts).
- /api/auth/register: 10 requests / IP / hour → 429 + Retry-After: 3600
- /api/auth/forgot-password: 5 requests / IP / 15 min → 429 + Retry-After: 900
Works correctly for the local-server deployment (single long-lived process).
On Vercel serverless, limits within a warm invocation — still raises the cost
of rapid-fire attacks without requiring Redis or external infrastructure.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Onboarding was inside (app) and rendered wrapped in the full AppShell
(sidebar visible). Moved to top-level app/onboarding/ so it uses
AuthShell → PublicSurface — same clean layout as sign-in/sign-up.
Sign-out no longer shows a confirmation page; it fires signOut()
immediately on mount and shows a spinner. The confirmation added
friction without protecting anything meaningful in a personal tool.
Sign-up description updated from generic filler to copy that matches
the landing page voice.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- PublicSurface now accepts navLinks prop; renders desktop link row
with a subtle border-bottom separating nav from content
- Landing page gets Features | Pricing | Whitepaper nav links with
scroll anchors; hero drops the badge, adds dual CTAs (Sign in +
Get started →) matching the x.ai pattern
- All auth pages inherit the same nav via AuthShell automatically
- Sign-in replaces the hidden "Use owner key" text link with a visible
Email / Owner key tab switcher — owner password is no longer buried
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
- 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>