Team members who belong to an org already have projects accessible in the
control panel. The "Register your first project" prompt was incorrectly shown
to any user with no personal projects, including invited members. Now checks
both own projects and org projects before showing the banner.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Team members invited to an org already have projects shared with them.
Showing "Add your first project" was confusing — this detects org membership
after the username step and routes them directly to /today instead.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dbProjects (per-user entity projects) was stored in the module-level SlowCache
keyed by dirsKey. When a member user built the cache first (dbProjects=[]),
the owner's subsequent request hit the same dirsKey and got empty profiles
despite having their own entity projects. Now all user-specific project data
is fetched per-request in the existing Promise.all alongside teamOwnerIds,
so each user always resolves against their own + team owners' entity projects.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Members viewing team project cards always got profile:{description:'',status:''}
because dbProjects only contained the requesting user's own entity projects —
empty for org members. Now teamOwnerIds' projects are fetched in the same
Promise.all and merged, giving member users the same profile visibility as owners.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When called from the production server process, zellij action query-tab-names
emits session-list output with ANSI colour codes instead of bare tab names.
Strip escape sequences and drop "[Created ...]" lines so the tab-name check
passes correctly and inject reaches the target pane.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The initial poll() checked document.hidden before fetching, so the
control panel stayed stuck in skeleton state when a tab was backgrounded
(e.g. opened in background, browser automation). Now the first fetch
always fires; subsequent interval/visibility polls still skip when
hidden to avoid unnecessary background requests.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Members were only receiving live-state updates for own projects;
org-peer team projects were missing from the watched tab list.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
/api/inject was gating on own-projects only; a member dispatching to an
org-peer project got a 404 "Unknown tab". Now falls back to getOrgProjects
so team project tabs resolve correctly. DB events are still recorded under
the dispatching member's userId.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Include org-peer projects in the Control panel so members can dispatch
agents to the owner's projects. Own projects take precedence on tab-name
collision; DB session states are fetched from each team owner's userId so
progress is visible regardless of who last ran the agent.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
getOrgProjects previously queried by orgId on the project row, but no
projects had orgId set so it always returned empty. Fixed to query via
org membership user IDs instead — works with all existing data.
createUserProject now auto-sets orgId to the user's primary org so future
projects are org-linked at creation time.
Settings page fetches both own and team projects in parallel and renders
a read-only "Team projects" section below the user's own list. Members
can now see the fleet of projects they have access to dispatch agents on.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without an email on the invite, accepted users had email=null and no way
to authenticate after their initial session expired. Now open-link accept
forms require an email field; email-targeted invites keep the pre-filled
(disabled) display. Passed email flows through the API into acceptInvitation
which prefers invite.email and falls back to the user-supplied value.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
`npm run build` alone left .next/standalone/ with stale CSS/JS chunks,
causing the production server to serve 404s until `install-app` was run
manually. The new postbuild hook runs deploy-local.sh automatically after
every build: copies .next/static and public/ into standalone, then
conditionally restarts the cockpit-app systemd service if installed.
No-ops cleanly on CI (no standalone dir) and on machines without the
service (systemctl check skipped). install-app is preserved for first-time
setup.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Transient popup windows should not control app-wide theme — removing
ThemeToggle from the beacon header prevents the next session from
waking up in light mode when the user clicked the toggle there.
Smoke test gains /api/orgs, /api/agent-tokens, /api/agent/register
(all three new multi-tenancy + agent-token endpoints).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- AgentTokenSettings: fetch GET /api/agent-tokens on mount to populate list
- agent/register: remove unused NextRequest import/param
- agent-tokens/route: suppress intentional token omission lint warning
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- /api/orgs GET: returns all orgs the user belongs to with full member list
- TeamSettings: shows current members (avatar, name, role) before invite form
- getOrgProjects(): query for active projects shared via org (other members' projects)
- invitations.acceptInvitation: atomically adds new user to inviter's org on accept
- orgs.ts: getOwnerOrgId helper
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- New orgs and org_memberships tables (Drizzle schema + raw DDL applied)
- org_id FK added to user_projects and orchestration_runs for team scoping
- Org auto-create on sign-in: every new user gets a personal org; backfilled existing user
- db/queries/orgs.ts: getOrgMembershipCount, createPersonalOrg, getOrgsByUserId, addOrgMember
- Auto-continue now defaults to false (was true); beacon popup no longer force-enables it on mount — auto-inject is fully opt-in, preventing interference with in-progress multi-step plans
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds /api/github/repos that reads the stored OAuth access_token and
fetches the user's 50 most-recently-updated non-fork repos from GitHub.
Onboarding step 2 shows a scrollable visual picker with language badges,
star counts, and descriptions. Selecting a repo fills name + gitUrl
automatically. Manual entry is still available as a fallback ("Enter
details manually instead"). Users who signed up with email/password see
the original form unchanged (hasGithub: false path).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Root surface: bg-surface-page → bg-surface-base so the popup window
IS the card, not a page containing a card
- Header: rewritten using ui-card-header / ui-card-header-main /
ui-card-actions with the status-dot + project-name + tag pattern
from ProjectTile
- Primary prompt button: ui-btn-primary (white) → ui-btn-ready-primary
(accent) to match the control panel ready-banner style
- Section divider: border-t border-border-subtle separates header from
body, consistent with card section pattern
- Submitted state: same card surface + header, no separate full-page wrapper
- Dismiss button: ui-link-muted → ui-btn-ghost for system consistency
- Loading / standby states: bg-surface-page → bg-surface-base
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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>
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>