The Notification hook was unconditionally injecting "Resolve the pending
question..." whenever Claude Code sent a notification event — even if the
user was actively at the keyboard typing their own reply. This caused the
double-prompt problem independently of the Stop hook fix.
Two changes:
1. handle_notification now applies the same 60s idle gate as handle_stop.
If the user is active, the hook plays the attention sound only and exits —
the user responds themselves. Auto-inject only fires when they're away.
2. The "continue" prompt entry in agent-prompts.json had style "internal"
and slot null, making it invisible in the prompt library UI despite being
the SSOT for this behavior. Changed to style "more" / slot 14 so it
appears under the More button and can be read, used, and edited from the
same place as every other prompt.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Layer 1 (< 100ms): notify-choice.py shows a native KDE notification with
action buttons built from the first 3 prompt slots. Uses gi.repository.Notify
+ GLib event loop so actions are properly wired (plain notify-send --action
is not supported by the KDE notification server). When clicked:
- prints the slot number (choice)
- patches /tmp/cockpit-beacon/{id}.json so the browser beacon sees
choice != null and window.close()s itself within 500ms
Layer 2 (1-4s): beacon_python opens the full browser beacon in parallel.
Both layers write to a shared tempfile via atomic mv — first write wins.
The main loop polls every 200ms, kills both processes on first result.
If neither layer produces a choice (user is at keyboard, typing manually),
the hook exits cleanly without injecting anything.
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>
The XScreenSaver extension is unavailable on this machine's X11 display.
Add /dev/pts youngest-atime as a fallback: the most recently accessed
pseudo-terminal is a reliable proxy for 'user is active in a terminal'
and needs no extra packages or group membership.
Detection order: libXss (XScreenSaver) → /dev/pts atime → 9999 (show beacon).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three targeted fixes for the "prompt injection even when at keyboard" problem:
1. Remove the `choice="1"` fallback — when the beacon times out or Chrome fails
to open, the hook now exits cleanly instead of auto-injecting slot 1 on top of
whatever the user typed manually.
2. X11 idle gate — skip beacon entirely when the user has been active within the
last 60 s (uses xprintidle if installed, falls back to libXss via ctypes, falls
back to 9999 = always show beacon when neither is available). Install
xprintidle with `sudo apt install xprintidle` to enable on systems without the
MIT-SCREEN-SAVER X11 extension.
3. Instant notify-send notification fires before Chrome launches so the user gets
immediate visual feedback while the browser beacon popup loads (1–4 s on first
Chrome launch, near-instant when Chrome is already running).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
beacon.py now writes sessions to /tmp/cockpit-beacon/{uuid}.json
directly instead of POSTing to /api/beacon, and polls the file instead
of GET /api/beacon/{id}. No API auth is needed — the browser popup (which
has the user's session cookie) still calls the API to load the beacon UI
and write the choice. Works immediately without any dev server restart.
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>
Browser popup (Chrome --app= frameless window) is now the default when
Cockpit is running. PyQt native widget is used only when no browser is
found or Cockpit is not running. The confirm dialog still uses PyQt.
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>
Added /api/health (public), /api/control/agent, /api/control/commands,
/api/captures, and /api/beacon-settings to smoke coverage. All return
expected status codes (200 for public, 401 for auth-required routes).
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>
PAGE_ROUTES was missing /history, /thoughts, /settings (all in
NAV_ITEMS per the comment's own rule) and /whitepaper (public page).
Routes match navigation.ts NAV_ITEMS order for easier diffing.
AUTH_API_ROUTES grows from 5 to 10 — adds /api/me, /api/user-projects,
/api/invitations, /api/sessions, /api/prompts/agent. Each confirmed to
have a GET handler before adding. /api/subscriptions omitted (POST-only).
All 28 routes verified green against the running dev server.
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>
Runs npm run smoke before push when the local server is detected.
Silent skip when server is down so offline pushes are never blocked.
Supports COCKPIT_SESSION_TOKEN for fully authenticated smoke runs.
pre-commit now documents that authenticated smoke lives in pre-push.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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>
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>
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>
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>
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>
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>
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>
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>