Commit Graph
1545 Commits
Author SHA1 Message Date
g-butandClaude Sonnet 4.6 e7d255b742 fix(today): hide first-run banner for team members with org project access
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>
2026-05-18 01:40:20 +02:00
g-butandClaude Sonnet 4.6 4424e4a9fa fix(onboarding): skip project step for team members who already have org access
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>
2026-05-18 01:34:25 +02:00
g-butandClaude Sonnet 4.6 0e68246d4f fix(control): remove dbProjects from shared git cache to prevent cross-user contamination
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>
2026-05-18 01:23:14 +02:00
g-butandClaude Sonnet 4.6 fcc2de3cba fix(control): fetch team owners' entity projects so members see profile data
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>
2026-05-18 01:10:23 +02:00
g-butandClaude Sonnet 4.6 9c6df290e3 fix(zellij): strip ANSI codes and session-list lines from getZellijTabs output
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>
2026-05-18 00:45:32 +02:00
g-butandClaude Sonnet 4.6 78d7d7b3a2 fix(control): always fetch on mount regardless of tab visibility
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>
2026-05-18 00:21:00 +02:00
g-butandClaude Sonnet 4.6 cf25ccee48 fix(stream): include team projects in SSE stream for members
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>
2026-05-17 23:20:01 +02:00
g-butandClaude Sonnet 4.6 ce78cf9ce4 fix(inject): allow members to dispatch to team projects
/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>
2026-05-17 23:16:53 +02:00
g-butandClaude Sonnet 4.6 44ded77127 feat(control): surface team projects for org members
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>
2026-05-17 23:10:16 +02:00
g-butandClaude Sonnet 4.6 fd4a39f17c feat(teams): surface org team projects in Settings for members
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>
2026-05-17 22:57:53 +02:00
g-butandClaude Sonnet 4.6 4af27c3157 fix(invite): collect email on open-link invites so users can sign back in
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>
2026-05-17 22:34:53 +02:00
g-butandClaude Sonnet 4.6 50d760f772 chore(deploy): postbuild hook copies static assets + restarts cockpit-app service
`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>
2026-05-17 22:14:33 +02:00
g-butandClaude Sonnet 4.6 b1033a5eb7 fix(beacon): remove ThemeToggle from popup; expand smoke to 39 routes
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>
2026-05-17 21:34:08 +02:00
g-butandClaude Sonnet 4.6 7f1d229ca6 fix(settings): load existing agent tokens on mount; fix unused params
- 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>
2026-05-17 21:16:31 +02:00
g-butandClaude Sonnet 4.6 1916b65e09 feat(agent): /api/agent/register endpoint + middleware bearer token passthrough
- /api/agent/register GET: validates ck_* token, returns user + org context for CLI init
- auth.config: pass Bearer ck_* requests through middleware without session (routes auth themselves)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 21:12:41 +02:00
g-butandClaude Sonnet 4.6 c9977e63a5 feat(agent-tokens): per-device DB tokens for CLI auth (ck_* bearer tokens)
- agent_tokens table: token, label, userId, orgId, lastUsedAt, expiresAt
- /api/agent-tokens GET/POST/DELETE: list/create/revoke tokens (plaintext shown once on creation)
- Settings > Agent Tokens: UI to generate tokens and paste into npx @cockpit/agent init
- daemon-auth.ts: getBearerUserId checks env token then ck_* DB tokens
- session.ts: getApiUserId() — unified auth for API routes (cookie session + bearer fallback)
- control/commands, control/commands/[id], control/runtime-state, sessions: migrated to getApiUserId

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 21:07:59 +02:00
g-butandClaude Sonnet 4.6 7fbf1d758f feat(multi-tenancy): org-scoped project visibility + team members UI
- /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>
2026-05-17 20:53:37 +02:00
g-butandClaude Sonnet 4.6 f0f1e3e455 chore: remove unused 'and' import in orgs queries
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 19:09:32 +02:00
g-butandClaude Sonnet 4.6 3d52e2dbf0 feat(multi-tenancy): add orgs + memberships; make auto-continue opt-in
- 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>
2026-05-17 19:06:21 +02:00
g-butandClaude Sonnet 4.6 29a1fee3e5 feat(onboarding): GitHub repo picker — replace manual form with one-click repo selection
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>
2026-05-17 18:46:14 +02:00
g-butandClaude Sonnet 4.6 fdd0fd82ca style(beacon): restyle popup to match Cockpit card/tile design language
- 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>
2026-05-17 18:38:56 +02:00
g-butandClaude Sonnet 4.6 97f65d1b7a feat(beacon): pre-warm live tab — web popup speed matches Python notify
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>
2026-05-17 18:05:30 +02:00
g-butandClaude Sonnet 4.6 bbf45c9a21 fix(hooks): guard Notification auto-inject behind idle check; surface continue prompt in UI
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>
2026-05-17 17:38:38 +02:00
g-butandClaude Sonnet 4.6 d966e906f1 feat(beacon): two-layer parallel popup — OS notification + browser beacon race
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>
2026-05-17 17:33:58 +02:00
g-butandClaude Sonnet 4.6 795f4b9974 fix(beacon): SSR initial session load + prefer Brave for popup
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>
2026-05-17 17:21:09 +02:00
g-butandClaude Sonnet 4.6 5978bcf0f8 fix(beacon): add /dev/pts fallback for idle detection without xprintidle
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>
2026-05-17 17:11:48 +02:00
g-butandClaude Sonnet 4.6 45835c9ee3 fix(beacon): stop auto-injecting on timeout; add idle gate + instant notify
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>
2026-05-17 17:05:09 +02:00
g-butandClaude Sonnet 4.6 604c84ed49 fix(beacon): bypass API auth — write/poll session files directly
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>
2026-05-17 16:45:32 +02:00
g-butandClaude Sonnet 4.6 77aec7eca5 fix(today): surface habit toggle errors in HabitsList instead of silent revert
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 16:38:34 +02:00
g-butandClaude Sonnet 4.6 5b35c8b6f3 fix(beacon): unblock /api/beacon from middleware + fix PyQt crash
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>
2026-05-17 16:32:50 +02:00
g-butandClaude Sonnet 4.6 b739b6f02f fix(people): replace bare 'Loading...' name in PersonDetail sticky header with skeleton pill
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 16:26:59 +02:00
g-butandClaude Sonnet 4.6 8b750d9666 fix(control): replace bare 'Loading…' with structural skeletons
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>
2026-05-17 16:24:47 +02:00
g-butandClaude Sonnet 4.6 fd70127e6e feat(beacon): make web beacon primary popup, PyQt fallback
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>
2026-05-17 16:21:22 +02:00
g-butandClaude Sonnet 4.6 bdf60a9086 fix(ui): replace bare loading text with structural skeletons in GitHubStatus and PersonDetail
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>
2026-05-17 16:12:35 +02:00
g-butandClaude Sonnet 4.6 ae77749c8a fix(today): replace bare 'Loading...' text with structural skeletons in CalendarCard and WeatherCard
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>
2026-05-17 16:08:33 +02:00
g-butandClaude Sonnet 4.6 f6cb0dc681 fix: remove duplicate auth check in stripe portal, drop stale date, expand smoke to 36
- 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>
2026-05-17 16:04:35 +02:00
g-butandClaude Sonnet 4.6 ad70f4f793 fix(habits): surface mutation errors in HabitCard instead of silent failure
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>
2026-05-17 15:59:40 +02:00
g-butandClaude Sonnet 4.6 e6c65d3778 fix(auth): gate owner-key tab on LOCAL_AUTH_PASSWORD, move sign-up link into form
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>
2026-05-17 15:58:50 +02:00
g-butandClaude Sonnet 4.6 260f33250d test(smoke): expand coverage from 28 to 33 routes
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>
2026-05-17 12:19:15 +02:00
g-butandClaude Sonnet 4.6 5a815ceaba fix(people): surface search fetch errors with retry instead of silent failure
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>
2026-05-17 12:10:09 +02:00
g-butandClaude Sonnet 4.6 dc791e5134 fix(ux): add SummaryBar loading skeleton, surface silent errors, fix reorder revert
- 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>
2026-05-17 12:00:24 +02:00
g-butandClaude Sonnet 4.6 632fcc16c8 feat(health): expose runtime and version in /api/health; purge stale beacon sessions
/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>
2026-05-17 11:47:12 +02:00
g-butandClaude Sonnet 4.6 c54858345a fix(middleware): rename to proxy.ts, return 401 for unauthenticated API requests, exclude public API routes
- 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>
2026-05-17 11:32:43 +02:00
g-butandClaude Sonnet 4.6 4e40609387 fix(security): guard /api/sessions and /api/prompts/agent against unauthenticated access
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>
2026-05-17 11:14:44 +02:00
g-butandClaude Sonnet 4.6 20b7a9dd49 feat(auth): add middleware.ts to activate global auth and onboarding gate
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>
2026-05-17 11:01:03 +02:00
g-butandClaude Sonnet 4.6 1416315bc9 fix(smoke): add missing nav routes and API endpoints to coverage
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>
2026-05-17 10:53:49 +02:00
g-butandClaude Sonnet 4.6 f33d8dbcd1 feat(security): rate-limit register and forgot-password endpoints
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>
2026-05-17 10:45:28 +02:00
g-butandClaude Sonnet 4.6 5c82f81d0c fix(auth): move onboarding to public surface, auto-fire sign-out, fix copy
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>
2026-05-17 10:41:32 +02:00
g-butandClaude Sonnet 4.6 daa264286d feat(public): x.ai-style nav, owner-key tab, redesigned landing
- 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>
2026-05-17 10:27:28 +02:00
g-butandClaude Sonnet 4.6 78ace3d904 chore(hooks): add pre-push smoke test gate
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>
2026-05-17 10:26:42 +02:00