mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 11:07:40 +01:00
35adca22a8da170bc47ba6e4938bb9c5ffbcc2e3
1545
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b68b8bc5d1 |
fix(projects): createProject auto-creates user_projects link
Pre-fix: entity-creating routes (create-with-github, import-from-local, bulk-from-github, the bootstrap modal cloud path) inserted only into the entities table. /api/control reads from user_projects → a newly created project was visible on /projects but missing from /control. User dogfood surfaced this with truthseeker today. Fix: createProject now ALSO inserts a user_projects row linked to the new entity. dir_path stays null until the user clones locally and registers the path via /control/import-local; v0.7.1 will surface a "needs local clone" affordance for null-dir_path rows so /control shows them with the right call to action instead of silently hiding. Per-user org_id is auto-resolved from orgs.owner_id for consistency with the existing createUserProject path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
77218bd20c |
feat(observability): server-component errors auto-log digest to debug_logs
The (app)/error.tsx boundary catches server-component throws and shows
"Something went wrong" — but the error message + digest only live in
Vercel runtime logs, requiring DevTools spelunking to find. User asked
to diagnose /today crashes "without my involvement"; this gets the
digest + path + user-agent into the debug_logs table on every crash so
the next instance is queryable directly.
+ src/app/api/debug-log/route.ts — POST endpoint, schema-validated,
no auth needed (client errors before sign-in still useful)
~ src/app/(app)/error.tsx — useEffect posts {digest, message, path}
fire-and-forget on mount. Never blocks the error UI.
When the next /today crash fires, the row lands in debug_logs with
source='app-error-boundary'. The digest correlates 1:1 with the same
digest in Vercel runtime logs — so we can grep server logs by digest
instead of by timestamp guesswork.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
1c2826522a |
fix(deploy): cron daily-only for Hobby tier; hide noisy /control empty state
Two issues surfaced from production. (1) Production deploys stuck since Change 6. Every push from Change 5 onward failed Vercel build validation with: "Hobby accounts are limited to daily cron jobs. This cron expression (*/30 * * * *) would run more than once per day." The autonomous scheduler's */30 cadence exceeds Vercel Hobby's once-per-day cron limit. Fix: change to "0 4 * * *" (daily at 04:00 UTC). Documented in the route comment as plan-limited — drop back to */30 on a Pro upgrade. Daily run still picks up any project idle > IDLE_WINDOW_HOURS and nudges once; the cadence is the only regression vs the original design. The auto-deploy backlog means Changes 4, 5, 6 (Phase C, scheduler, beacon DB, typed boundary, per-project autopilot) all land in the same release once this commit unblocks the build. (2) /control empty-state visual noise. When the user has 0 projects, ControlFleetStatus still renders: "Setup needed · Autopilot Manual · 0 working · 0 ready · 0 open · All clear · Beacon — popup with smart choices ..." stacked under the empty-state welcome cards. The counters are meaningless at 0; the autopilot pill + beacon hint are decorative. User reported this as noise. Fix: gate ControlFleetStatus on `data.projects.length > 0`. The welcome cards already serve as the empty-state CTA; status panel returns the moment a project exists. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
963e97e426 |
feat(beacon): Change 4 — migrate /tmp file-based sessions to DB table
Pre-v0.7: /api/beacon wrote one JSON file per session to
/tmp/<APP_SLUG>-beacon/<id>.json. The SSE route polled the directory
every 150ms with fs.readdirSync(). That worked while traffic was
single-pod-single-user, but had three real drawbacks:
- /tmp isn't durable; a function instance restart loses pending
popups silently
- Cross-pod reads impossible — a popup written by pod A is invisible
to pod B (latent landmine that hasn't bitten yet)
- Filesystem polling on every SSE tick is exactly the work
NOTIFY/LISTEN was added to obsolete in v0.6
This change moves storage to a beacon_sessions DB table. Same product
behavior, durable + queryable + user-scoped. A NOTIFY trigger on the
table is the v2 step that obsoletes the poll loop entirely — the
bridge already has the LISTEN side. This commit keeps the SSE poll
cadence to keep the diff small.
The beacon product feature itself (L3 of the autopilot ladder — the
"popup with countdown" tier between Manual and Continuous) is
unchanged. This was the file-based hack INSIDE the L3 product, not
the product itself.
Files:
+ drizzle/0024_beacon_sessions.sql (applied to Hetzner prod)
+ src/db/schema/beacon-sessions.ts
+ src/db/queries/beacon-sessions.ts
~ src/app/api/beacon/route.ts — POST + helpers delegate to DB
~ src/app/api/beacon/[id]/route.ts — GET/PATCH via DB
~ src/app/api/beacon/cancel/route.ts — userId-scoped (was global)
~ src/app/api/beacon/sse/route.ts — polls DB instead of /tmp,
requires auth (was unauthenticated)
~ src/app/api/inject/route.ts — passes userId to cancel
~ src/app/api/orchestration/run/route.ts — passes userId to cancel
~ src/app/beacon/[id]/page.tsx — await readBeaconSession (now async)
~ src/app/beacon/live/page.tsx — userId-scoped + await
+ src/db/schema/index.ts — export beacon-sessions
Behavior changes worth flagging:
- SSE endpoint now requires auth (returns 401 unauthenticated).
Pre-Change-4 it served any /tmp content. The file version's lack
of auth was incidental, not intentional.
- cancelActiveBeaconSessions / readLatestPendingSession became
user-scoped. Callers updated to thread userId through.
- beaconPath export removed — meaningless for DB-backed storage,
no remaining callers after the migration.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
a090fed01f |
feat(api): Change 5 — autonomous scheduler nudges idle L4 projects
The "tool → system" lever the v0.6 essay called for: when you walk
away, the system keeps moving on the projects you've trusted to keep
moving. Pre-v0.7: nothing moved unless an agent finished a run +
agent-hook-bridge.sh fired. Now a cron tick checks for idle projects
and fires the next-best template for users on L4 (Continuous).
v1 scope (deliberately narrow):
- Fires ONLY for users on auto_inject_mode = 'next_best' (L4). Beacon
(L3) is reactive to agent-finish events, not idle-poll. Strategist
(L5) needs session-handoff context the cron doesn't have. Both v2.
- Respects per-project auto_inject_mode_override (the toggle shipped
earlier today). "Paused" projects are never nudged.
- Conservative gates:
* No orchestration_runs started in last 2 hours (IDLE_WINDOW_HOURS)
* No pending_commands with executed_at IS NULL (don't pile on)
* entities.metadata.lastNudgedAt is NULL or > 6 hours ago (cooldown)
- Capped at MAX_NUDGES_PER_TICK = 25 nudges per cron tick. Runaway
misconfig protection.
Schedule: every 30 minutes (vercel.json crons). Conservative — the
downside of over-firing is more obvious to a user than under-firing.
Tune up after observing real usage.
Implementation:
- src/app/api/crons/nudge-idle/route.ts — GET handler, requireCronAuth
- Drizzle builder API (no raw SQL except the JSONB key extraction +
IS NULL check that don't compose cleanly through the builder)
- Reads NEXT-BEST-STEP template from src/config/prompt-library.ts so
there's no template duplication; renders {{project_name}} per-project
- Inserts pending_commands of type='inject' with the rendered prompt
- Updates entities.metadata to track lastNudgedAt for cooldown gating
- logDebug per tick (info on success, error on failure) so production
has telemetry of the scheduler's behavior
vercel.json updated to register the new cron at */30 * * * *.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
e433334429 |
feat(desktop): Change 6 — typed command boundary at the IPC
Pre-v0.7 handleCommand cast command.payload as { tab?, prompt? } — an
unchecked cast that worked while the cloud was the only source and we
trusted its serialization. Change 5 (autonomous scheduler) is about to
start INSERT'ing pending_commands unattended via cron; an unchecked
cast at the boundary lets a typo'd cron payload through to
injectIntoTab() where the failure mode is less actionable.
New: desktop/src/main/command-validator.ts. Discriminated-union
ValidatedCommand + per-type validateCommand(raw) returning either
{ok:true,command} or {ok:false,error}. Hand-rolled guards (no zod) to
keep the main-process bundle lean — one validator function isn't
worth a runtime dep. Mirrors the cloud-side per-type payload contracts
in src/db/schema/pending-commands.ts; keep the two in sync by hand
until a second command type joins the desktop's executor.
Poller updated to validate before dispatch:
- inject: tab + prompt must be non-empty strings; optional fields
type-checked when present (not just when absent)
- unknown types: rejected with an actionable message naming the
file where to add the new type
- the catch around the executor remains for runtime injection errors
(zellij subprocess failures), distinct from validation errors
Defensive prerequisite for Change 5. Standalone safe.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
6402666152 |
feat(control): per-project autopilot pause/resume
Pre-v0.7: a single user-level beacon_settings.auto_inject_mode applied
to every project. User question while dogfooding: "how can I easily
pause and continue auto-inject for different projects?"
Now each project entity carries an optional auto_inject_mode_override.
NULL = inherit the user-level mode (today's behavior). Any
AUTO_INJECT_MODE_VALUES value (typically "off") = pin this specific
project to a different tier. /api/control/dispatch reads the override
before falling back to the user default.
End-to-end:
Schema (drizzle/0023_entities_auto_inject_mode_override.sql):
+ entities.auto_inject_mode_override TEXT (nullable, no CHECK —
validation is at the API boundary so future enum churn doesn't
orphan rows).
Query layer (src/db/queries/projects.ts):
+ getProjectAutopilotOverride(userId, projectKey) → AutoInjectMode|null,
defensively coerces unknown stored values to null
+ patchProject() accepts autoInjectModeOverride: AutoInjectMode|null
+ PatchProjectBody validator extended (zod enum + null)
Dispatch route (src/app/api/control/dispatch/route.ts):
+ Reads project override before user default. Both lookups fail-safe
to default mode so a transient DB hiccup doesn't kill dispatch.
/api/control snapshot (src/app/api/control/route.ts):
+ ProjectState.autoInjectModeOverride populated per-project via
resolveAutoInjectOverride() helper. Mirror of matchProfile's
fuzzy-match (id-first, then tab/dir basename).
UI (src/components/control/ProjectAutopilotToggle.tsx + ProjectCard):
+ Pause/Play button on each ProjectCard. "Active" = inheriting the
user-level mode. "Paused" = override is "off". Hover-tooltip
shows the user-level mode so "Inherit" isn't opaque.
+ Hidden when projectId is null (legacy paths-only projects with
no entity row can't be overridden — PATCH would 404).
+ Fires FLEETCROWN_REFRESH_EVENT on success so /control refetches.
Full per-tier control per-project (off/queue/beacon/continuous/mission
per project, not just binary pause) is the v2 follow-up; binary
pause/resume covers the dominant use case in scan-light shape.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fleet-runner-v0.7.0
|
||
|
|
28f775c715 |
feat(desktop): v0.7 Phase C — bundled local renderer is primary
The v0.6 essay called for local-first: cloud as the thin sync layer,
local as the source of truth for project state and dispatch. The
desktop's USE_WEB_SHELL default was the lever blocking that — set to
true, every launch loaded fleetcrown.vercel.app inside Electron and
the bundled renderer was a fallback for cloud failure.
v0.7 flips it. Initial-mode resolution:
- No saved ck_* token at ~/.config/fleetcrown/fleet-runner-token →
boot CLOUD (user needs to sign in; auto-mint drops the token).
Subsequent launches go local.
- FLEETCROWN_WEB_URL=https://... → boot cloud (preserves dev /
preview deploy workflows; also becomes the "Try cloud" target).
- FLEETCROWN_WEB_URL=cloud → boot cloud at APP_URL.
- FLEETCROWN_WEB_URL=local or unset, token present → boot LOCAL.
WEB_SHELL_URL is now always defined (defaults to APP_URL) so the
"Try cloud" button works regardless of initial mode. Pre-v0.7,
probe-cloud and switch-to-cloud both gated on USE_WEB_SHELL and
silently no-op'd when the user booted local — the button was broken
in exactly the mode that needed it most.
Factored the conflation: USE_WEB_SHELL now means "boot cloud?"
exclusively. WEB_SHELL_URL means "the cloud URL" exclusively. They
were one variable doing two jobs.
Bundled renderer (desktop/src/renderer/) already shows runtime
status, project list from agent-projects.conf, dispatch UI, token
management, and a "Try cloud" button. It is less feature-rich than
the cloud view today (no /control orchestration runs, no prompt
library) — those land via the cloud view click-through. Reaching
feature parity for the daily-driver flows is the Phase C follow-up.
desktop/package.json bumped 0.6.0 → 0.7.0.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
ecc98bf53d |
ux(shell): icon-only NotificationsPill; remove dark mode from sidebar
Two small UX fixes from a real user observation during dogfood today: 1. NotificationsPill — was "[bell icon] Notifications off" in a pill. Visually read as two elements (icon + text) for one button; users asked if there were two notification controls. Collapsed to a single bell-on/bell-off icon button matching the topbar's other icon-only buttons (mobile search, Sessions drawer). The hover-title carries the state explanation for users who need it. 2. SidebarFooter — dropped the full-width dark/light mode toggle. Theme is a set-once-and-forget preference; full-width sidebar slot was disproportionate. Settings → Appearance has the same toggle (AppearanceSettings.tsx) which is the right home for it. Sidebar slots now: collapse, Settings, Lock private zone (conditional), Sign out — all frequent navigation/presence actions. The third issue raised (prompt library showing prompts despite an empty Hetzner DB) is by design — src/config/prompt-library.ts ships ~30 FleetCrown defaults baked into the build, independent of DB state. User-defined / project-specific / personal prompts are a real feature gap noted for a future sprint (needs a user_prompts table + UI to manage; meaningful scope, separate change). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
a2db503c42 |
fix(auth): request GitHub 'repo' scope so create-with-github works
GitHub provider config requested only the Auth.js defaults (read:user + user:email). Those are enough for sign-in but not for POST /user/repos — GitHub returns 404 Not Found rather than 403 (security through obscurity) when the token lacks repo scope. Surfaced during dogfood today: clicked "Start a new project" with name truthseeker on /control/new-from-scratch, got "GitHub API rejected the create (404) — Not Found" with no further hint. The /api/projects/ create-with-github route comment even called out 403-or-401 as the expected failure modes; 404-because-of-missing-scope was the silent third case. Added 'repo' to the GitHub authorization scope params. New sign-ins will mint tokens with the right scope automatically; existing users must sign out + back in to upgrade their token's scope. Documented inline that repo is required by /api/projects/create-with- github AND /api/github/repos (the latter lists private repos too, which also needs repo or it falls back to public-only). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
9e5bfe6a6d |
fix(create-with-github): bump maxDuration to 60s
POST /api/projects/create-with-github runs a multi-call sequence (GitHub create-repo → seed template via branches/main, parallel blobs, tree, commit, patch ref → DB insert). Under normal latency that's 5-15s. Vercel's default 10s function ceiling tripped a 502 mid-flight during dogfood today — repo was never created on GitHub, client got a 502 from Vercel's edge with no JSON body, no error surfaced to the user. Match the pattern established by /api/project/ai-brief (maxDuration = 90) which faces similar third-party-API tail latency. 60s gives a comfortable margin without inviting hung functions. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
ec506cd774 |
fix(onboarding): infinite /api/onboarding loop from useSession update() in effect deps
The bootstrap effect on /onboarding had [router, update] as its dependency array. update() is the function returned by useSession() in next-auth's React adapter. Each time the effect called update() to sync the JWT from DB, the session state changed, useSession returned a new update() reference, the effect's deps changed, and React re-ran the effect — which called update() again. Result: hundreds of concurrent GET /api/onboarding requests, all stuck in "pending" state, page rendering only a spinner forever. Observed live during dogfood today (2026-06-05) driving fleetcrown .vercel.app in Chrome to create a new project. Network panel showed 217 fleetcrown.vercel.app requests in the first 4 seconds of the page load — all /api/onboarding GETs, all pending. Fix: hold update() in a ref so the bootstrap effect can call the latest version without depending on its identity. Effect deps drop to []. The auto-onboard heal path that POSTs /api/onboarding for returning users now actually completes — under the old behavior, the effect tore down before the POST resolved. Validates the broader pattern: next-auth's update() is not stable across renders. Any effect that calls it should ref it or call it exactly once on mount with empty deps. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
5eb04e2fe1 |
docs(thoughts): essay on the FleetCrown bootstrap loop, idea → first commit
Deep walk-through of how a user takes a fresh idea to a running agent dispatch today: signs in, lands on /control, uses /control/new-from- scratch (cloud path) or the Bootstrap modal (Fleet Runner path), gets a GitHub repo + FleetCrown project + first dispatch. Uses a concrete example throughout — a tool that writes first-principles rebuttals to articles with full source and author transparency (working title: truthseeker). This essay is itself a reference: it describes the loop the project will close in its own domain (article → response with sources) by analogy to the one FleetCrown closes for projects (idea → working code). Honest about gaps: cloud path doesn't clone for you (the Bootstrap modal does, locally); no autonomous scheduler firing next_best on idle projects yet; no voice-as-input. Calls these out explicitly as the work ahead, with the scheduler flagged as the single biggest unlock from "tool you initiate" to "system that operates." Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
c400cbdfd2 |
feat(bridge): desktop poller subscribes to SSE; delete /control polling baseline
Two paired architectural changes that move us off the surviving polling loops and onto the bridge for everything that should be push. Change 1 — Desktop poller subscribes to bridge SSE for fast command drain The desktop's long-poll to /api/control/commands?wait=25 stays as the safety net, but a new bridge-subscriber.ts opens an SSE connection to bridge.orangecat.ch and listens for `pending_commands` INSERT events. When one fires for our user, the subscriber aborts the in-flight wait=25 fetch; the loop's next iteration uses wait=0 and drains the queue immediately. Dispatch latency goes from "up to 25s" (long-poll cycle) to "<500ms" (NOTIFY → bridge fan-out → SSE frame → abort → re-poll → command). Old daemons in the wild keep working unchanged — they just don't have the SSE subscriber, so they pay the long-poll latency. Atomic claim (FOR UPDATE SKIP LOCKED) means commands still go to exactly one consumer when both paths race. The bridge already fans out pending_commands events: the trigger has been in drizzle/0022_notify_triggers.sql since v0.6 phase A, and bridge/src/subscriptions.ts:35 is table-agnostic. Only the consumer was missing. Change 3 — Delete /control polling setInterval useControlData's polling baseline (5min when bridge configured, 30s otherwise) is gone. Refresh triggers reduced to: 1. Mount (always) 2. visibilitychange (tab returns to foreground) 3. FLEETCROWN_REFRESH_EVENT (pull-to-refresh, manual button) 4. useEventStream onChange (any fc:state NOTIFY) 5. /api/control/stream EventSource projects-update patches (existing) If both push pipelines silently fail, visibility-change is the human- driven recovery. That's an acceptable failure mode for the egress savings — and per the v0.6 "From Polling to Listening" essay, the belt-and-braces was always meant to be temporary. Code quality SSOT: Bridge URL lives in src/config/brand.ts as BRIDGE_URL. Web and desktop both consume it; env override available for dev (NEXT_PUBLIC_ FLEETCROWN_BRIDGE_URL for the cloud build, FLEETCROWN_BRIDGE_URL for the desktop). Previously the web hardcoded the env-var-only path with no fallback. SSOT: ChangeEvent type lifted to src/lib/event-stream-types.ts, shared by web (src/lib/event-stream.ts) and desktop (bridge-subscriber.ts). Previously had three near-identical copies — one in bridge/, one in event-stream.ts as BridgeChangeEvent, and an implicit one about to appear in the desktop. The bridge package keeps its own copy at the IPC boundary (separate deployable). 3 copies → 2 at the wire format contract line. DRY/SoC: bridge-subscriber.ts has one job (detect pending_commands INSERT events and notify the poller). The poller decides what to do. No data-fetch logic in the subscriber; no SSE state machine in the poller. The two abort controllers (lifetimeCtrl for stop, inner currentFetchCtrl for bridge-wake) keep the lifecycle scopes explicit. YAGNI: No new dependency added. Built a ~150-line SSE client using Node's https module directly. EventSource polyfill not needed at our scale. Dead code cleanup: isBridgeConfigured() removed (always true now), EventStreamState "disabled" mode dropped, useEventStream "enabled" option removed (single caller, never used). Total -42 lines from event-stream.ts net of new code. Tests: 89/89 home self-tests pass. tsc clean. eslint clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
3fd068233e |
feat(control): hide "Install Fleet Runner" card when already in Fleet Runner
EmptyStateWelcome detects window.fleetRunner via the desktop preload IPC. When present, the "Install Fleet Runner" card is hidden (it makes no sense to pitch the app the user already has open) and the grid drops from lg:grid-cols-5 to lg:grid-cols-4 for clean wrapping. Outside Fleet Runner (cloud browser) — unchanged 5-card layout. The useEffect+setState pattern is explicitly documented in-line as necessary for the RSC-vs-hydration boundary (lazy useState initializers run on the SSR pass where window is undefined and are then locked in via the RSC payload — the post-hydration effect is the only way to read browser-only globals). Suppressed the eslint rule on the specific line with the rationale comment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
20526cf464 |
refactor(control): hide DaemonStatusBanner CLI grid inside Fleet Runner
MissingCLIsBanner (added in the v0.6.0 onboarding sprint) shows only the CLIs that are actually missing on the user's PATH, via the new window.fleetRunner.getInstalledCLIs IPC. The DaemonStatusBanner has a separate 5-button "Install Grok / Claude / Cursor / Gemini / Codex" grid that renders all five regardless of what's installed. Inside Fleet Runner, both render on the same page — noisy and contradictory (the smart banner says "claude is missing" while the dumb grid offers all 5 install buttons next to it). Suppress the DaemonStatusBanner grid when window.fleetRunner is present so MissingCLIsBanner is the sole source of truth there. Outside Fleet Runner (cloud install, daemon offline path), the grid stays — there's no IPC to read PATH from, so showing all 5 install buttons is the right blunt-but-honest fallback. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
c7580650c6 |
feat(onboarding): success feedback + clearer dispatch placeholder
Two small UX wins for the first-touch moment: 1. Suggesters now show a 1.5s success card after import succeeds — "Imported 5 GitHub repos. Welcome to your fleet." / "Imported 3 local repos. Your fleet is alive." Without this the user clicks "Import all 5", the suggester instantly unmounts, projects appear below, and there's no felt sense of having done something. The dwell gives the moment weight before the page transitions. Same pattern in both GitHubRepoSuggestions and LocalDevSuggestions, matching dwell constant. Kept inline (no toast library added) — YAGNI for one celebration moment. 2. Project intent panel placeholder: "Custom prompt…" → "What should the agent work on? e.g. summarize this repo". The old label described the INPUT, not what to put in it. New users had no model for the kind of thing to type; the example seeds a working first try. Power users see the placeholder vanish on focus, so it's first-touch-only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
209299c08f |
feat(onboarding): auto-onboard first-time users with a derivable username
Drops the "isReturning" gate in decideHealPatch so the heal fires on first sign-in too. When a user signs in with OAuth (GitHub / Google / Twitter) and we can derive a unique username from their display name or email local-part, we set it + onboardedAt right there in the JWT callback. They land authenticated with onboardingComplete=true and middleware sends them straight to /control instead of via /onboarding. User-visible effect: GitHub OAuth → /control in ONE page load instead of two. The /control empty state's GitHubRepoSuggestions / LocalDev- Suggestions / FleetRunnerAutoMint then take over from there. Fallback (still works): users whose suggested username collides with an existing one, or whose display name + email can't yield ≥2 chars of [a-z0-9-], get null patch → middleware sends them to /onboarding to pick manually. The page is no longer a forced gate — just a fallback for the edge cases. Side benefit: also skips the wasted "onboardedAt-only" write that the old logic would do for returning users without a valid username, since onboardedAt without a valid username is a no-op (isOnboardingComplete still gates on both). The /settings → Profile editor lets users change the auto-picked username later, so we're not stealing their choice — just defaulting it. Tests: 7/7 pass (npm run test:onboarding-heal). Updated existing brand-new-user assertion to reflect the new policy and added a collision-fallback test case. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
4a72eacaee |
chore(import-local): use APP_URL SSOT instead of hardcoded host
Two hardcoded https://fleetcrown.vercel.app/ strings in the local-import page replaced with APP_URL from src/config/brand.ts (already the documented SSOT for the canonical host). When the domain eventually moves off the .vercel.app placeholder, this page comes along for free. Scope limited to the page I touched in the preceding refactor — the remaining hardcoded URLs (DaemonStatusBanner copy, project-templates README footers, marketing-content install one-liner) are deliberately left alone so this commit stays minimal-blast-radius. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>fleet-runner-v0.6.0 |
||
|
|
511b6c8186 |
refactor(desktop/types): promote IPC return shapes to named SSOT types
MissingCLIsBanner and LocalDevSuggestions each had their own local copy of the type returned by the corresponding window.fleetRunner IPC method. Two consumers, same shape, copy-pasted — a small SSOT violation. Promoted both shapes to named exports in components/desktop/types.ts (InstalledCLIs, LocalDevProject) and switched consumers to import them. The FleetRunnerBridge function signatures now reference the named types too, so the contract is declared once and propagates everywhere. Note: desktop/src/main/index.ts still inlines its own copy. That's the implementation side of the IPC boundary, and the desktop package can't import from src/components/ without a cross-package alias. Living with that duplication for now — it's the IPC contract surface, not internal sharing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
0e5f8ddf5f |
refactor(control): trim empty-state duplication and DRY the welcome cards
Two fixes for the "minimum reading" goal: 1. EmptyStateWelcome — 5 near-identical card blocks reduced to a single WelcomeCard subcomponent + 5 prop-driven instances. Original code was the Rule of Three violated 5x: same icon/title/body/cta structure copy-pasted with one-prop variations (Link vs button, accent vs muted). Also tightened header copy: "Welcome to your fleet 🚀 / You don't have any projects yet. Pick how you want to add the first one:" became "Start your first project / Pick a path — every option is one click away from a working fleet." Two fewer lines to read. 2. ControlPanel — suppress DaemonStatusBanner during the zero-project daemon-never-seen state. That banner pitched "Start a new project" + "Install Fleet Runner" as cards, and EmptyStateWelcome (rendered just below) pitched the same two CTAs as cards. Same screen, same CTAs, twice. Banner still fires for has-projects-but-no-daemon (legit: they can't dispatch) and daemon-was-online-now-offline (legit: troubleshoot). No JSX palette colors, no arbitrary hex, no Tailwind palette utilities — all tokens flow through globals.css → ui-* classes per the four-layer design system. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
475283ed9c |
feat(onboarding): one-click bulk-import from GitHub + local ~/dev
Two parallel "we already know your work" suggesters that turn the empty /control state from "pick one of 5 cards and start typing" into "click one button and you're done": 1. GitHubRepoSuggestions (browser + Fleet Runner alike) When the user has a GitHub OAuth account linked AND no FleetCrown projects yet, lists their 5 most-recently-updated owner-affiliated repos and offers "Import all 5" via POST /api/projects/bulk-from-github. Sits above EmptyStateWelcome so the easy path is the first option seen. 2. LocalDevSuggestions (Fleet Runner only) New `getLocalDevProjects` IPC walks ~/dev, ~/code, ~/Code, ~/Projects (overridable via FLEETCROWN_DEV_ROOTS env on the desktop process side) to depth 3 for git repos. Returns the 50 most-recent. The web banner shows the top 5 with "Import all 5" — POSTs to /api/projects/import-from-local with the daemon's stored ck_* token. Skipped silently outside Fleet Runner (no IPC method). Also: 3. MissingCLIsBanner (Fleet Runner only) New `getInstalledCLIs` IPC scans PATH for zellij + each of claude/codex/grok/gemini/cursor. The banner renders ONLY when at least one is missing, with per-CLI "Install Claude" buttons that POST to /api/agent/install-cli (existing endpoint — daemon picks the install up and opens a zellij tab with the installer pre-typed). Replaces the silent-fail-on-dispatch problem. UX north-star (per user direction today): "minimum reading, minimum clicks, minimum page loads." Each banner is ≤4 lines of copy, single primary action, fully collapsible (no banner shown when there's no signal — e.g., no GitHub linked, no local repos, all CLIs installed). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
a4440fe7b1 |
feat(desktop): IPC for local CLI detection — surface zellij + agent prerequisites
Adds `window.fleetRunner.getInstalledCLIs()` so the web UI (when running inside Fleet Runner) can render a clear "Install Claude" CTA instead of silently dispatching to a missing binary — the prerequisite gap a new user would hit on first launch. Pieces: 1. desktop/src/main/index.ts: new `get-installed-clis` IPC handler. Shell-exec'd `command -v <name>` against each of zellij, claude, codex, grok, gemini, cursor. Result cached for the process lifetime (relaunch to re-scan; mid-session installs are uncommon and don't need to be reflected without a restart). Inherits PATH via shell -c so the scan matches what `injectIntoTab` would see at dispatch time. 2. desktop/src/preload/index.ts: exposes `getInstalledCLIs` on the `window.fleetRunner` bridge. 3. src/components/desktop/types.ts: adds the method to the canonical FleetRunnerBridge type (optional, since older shipped builds won't have it). Web-side consumer (badge / banner in /control) will land in a follow-up commit. Keeping the IPC change focused so the desktop release can ship the prerequisite-scan capability even if the web UI for it isn't deployed yet. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
0b77c876ac |
feat(desktop): v0.6.0 — version bump + tray quick-links
Two small but signalling changes: 1. desktop/package.json: 0.5.1 → 0.6.0 Aligns the version with the v0.6 platform series (Postgres LISTEN/NOTIFY bridge + SSE + Hetzner cutover + cloud bootstrap + Sessions/Decisions/ Brief surfaces). The auto-pair flow from this morning's commit lands under this version. The next `git tag fleet-runner-v0.6.0 && git push origin fleet-runner-v0.6.0` triggers .github/workflows/desktop-release.yml — releases are gated on the tag, not on this bump alone, so this commit is safe to merge before the user is ready to cut a build. 2. desktop/src/main/index.ts tray context menu Was: "Show Fleet Runner / Quit". Two items. Lacked any quick-navigation. Now: jumps directly to Control, /control/new-from-scratch, /decisions, or /settings via a single tray click. Replaces the BrowserWindow URL in web-shell mode (USE_WEB_SHELL); in bundled-renderer mode it just surfaces the window since the router state lives in the local React tree. The tray quick-links use a shared `surfaceAt(path)` helper that show()s + focus()es + loads the URL — minimal, fits the "tray = one-click bounce to a page" model. Order matters: Control first (most common entry), then create flow, then logs, then settings, then quit at the bottom where it can't be misclicked. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
7e4fefad02 |
feat(desktop): one-click in-app pair — skip the deep-link dance when already in Fleet Runner
Right now if you're INSIDE Fleet Runner (the desktop app's BrowserWindow) and need to pair the daemon, the flow was: go to /settings → mint a token → click "Open in Fleet Runner" deep-link → the protocol handler routes it back to … the same process you're already in. Three clicks of friction for no payload-vs-machine reason. Two surfaces now detect `window.fleetRunner` and short-circuit straight to IPC: 1. AgentTokenSettings (Settings → Agent tokens) When the user mints a token AND we're inside Fleet Runner, auto-call `window.fleetRunner.saveToken()` immediately and replace the deep-link button with a "Paired with this Fleet Runner ✓" confirmation chip. If the IPC fails (older desktop build missing the method, daemon refused the token), show a retry button + error. 2. DaemonStatusBanner (the daemonNeverSeen banner on /control) When inside Fleet Runner, the second CTA card transforms from "Install Fleet Runner desktop" (silly — they already have it) to "Pair this Fleet Runner" with a single "Pair now" button. The button mints a fresh ck_* token labelled "Fleet Runner · MMM DD" and hands it to the in-app daemon over IPC. Calls onRefresh() so the banner can self-hide once the daemon's first push lands. Solves the exact problem the user hit this week: after the Hetzner cutover, their existing Fleet Runner daemon's old Neon-side token didn't validate anymore, and the re-pair UX was opaque enough that they stayed broken. Now it's one click from /control. Defensive: window.fleetRunner methods are typed Optional in src/components/desktop/types.ts (older shipped builds may lack newer methods), so every call site checks for the method's presence before invoking and falls back to the manual deep-link path otherwise. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
be847f634c |
fix(agent-labels): split leaf file so client bundle stops importing fs/child_process
This was the bug behind 8 consecutive failed deploys today (every commit
since
|
||
|
|
cc0dc596ed |
feat(today): Fleet Brief card — Tier 1 thesis surface #3 (complete)
Closes 3 of 3 Tier-1 captain-mode surfaces from the 2026-06-04 thesis: ✓ Sessions drawer (cross-page inventory, live status) ✓ /decisions timeline (chronological feed of fleet activity) ✓ Fleet Brief card on /today (at-a-glance counts) Where the prior two answer "what's happening now" and "what happened in sequence", the brief answers "how busy was my week, at a glance" — prerequisite signal for a captain deciding what to attend to. Pieces: 1. components/today/FleetBriefCard.tsx Pure server component. One paragraph of SQL aggregation: - count(*) filter projects.createdAt >= today / week-start - same for orchestration_runs.startedAt - top 3 projects by run count this week - active token count Renders as a Today-page card alongside RecentRunsCard, CommitmentsCard, etc. Three stat tiles (Projects / Runs week / Tokens) + a "most active projects this week" list when populated. Empty-state branches: if no projects yet, point to /control/new-from- scratch. If projects exist but no activity, point to /control. "See timeline" link in the header navigates to /decisions for the full chronological feed. 2. /today page imports + Suspense-wraps the card above RecentRunsCard. Performance: single SQL round-trip (4 parallel queries through one pool), no daemon dependency, no shell-outs, no GitHub API calls. Cheap enough to land on Today without bloating SSR time. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
8b61a51f3c |
feat(decisions): /decisions timeline of fleet activity — Tier 1 thesis ship #2
Completes 2 of 3 Tier-1 surfaces from the 2026-06-04 auto-injection thesis:
✓ Sessions Panel (drawer in AppShell) — done earlier today
✓ Decision Log (this commit) — "what did my fleet do and decide?"
○ Daily Brief (defer) — derives from these two
Pieces:
1. GET /api/decisions/feed?limit=N&project=<name>
Pulls from 3 cloud-side sources in parallel and merges by timestamp:
- entities (type=project) created → "Created project X"
- orchestration_runs finished → "<adapter> · <intent> on <project> (outcome)"
- agent_tokens minted → "Issued agent token"
No daemon required. Future sources to layer in: GitHub commits per
project (via OAuth token), debug_logs filtered to auth.*, cross-project
inbox messages.
2. /decisions page
Reverse-chronological list grouped by calendar day ("Today",
"Yesterday", "Tuesday Jun 3"). Per-project filter. Per-event icon +
tone (Sparkles for creation, Bot for runs, KeyRound for tokens).
Empty-state explains the gap when nothing has happened yet.
3. Navigation
Added NAV.decisions (icon: ScrollText, mobile: false) to the Work
group right after History. Showing up in sidebar between History
and System.
End-to-end:
Create project via cloud bootstrap → land on /decisions →
see "Today · 14:32 · Created project catsitting-startup" → click
Sessions drawer → see same project listed with its phase.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
cb0385247f |
feat(shell): Sessions drawer — cross-page project inventory + status
The auto-injection thesis (2026-06-04) flagged that /control answers "what's happening on the focused project NOW" and /projects answers "what's my inventory and health", but neither was a quick-glance "all my agents at once" surface visible from any page. This is that surface. Pieces: 1. GET /api/sessions/snapshot Lightweight: joins entities + project_states + derives a coarse phase (working / ready / open_idle / closed / offline / unknown). No git shell-out, no zellij read, no agent process scan — pure DB query. Suitable for polling every 30s from every authenticated page. 2. components/shell/SessionsDrawer.tsx Slide-out right-side drawer, backdrop + Esc to close. Lists every project with a colored phase dot, last-activity timestamp, and an "Open repo" icon when entities.git_url is set. Clicking a project navigates to /control?focus=<name> and auto-closes the drawer. Empty state links to /control to create the first project. Polls /api/sessions/snapshot every 30s while open; stops while closed. 3. AppShell wires open/close state and renders <SessionsDrawer/> at the shell layer so the drawer is reachable from every authenticated page (today, control, projects, money, …). 4. AppTopBar gets a LayoutPanelLeft icon button next to the FleetRunner/Notifications pills. Optional `onOpenSessions` prop so the bar still renders cleanly in isolation. Deferred (not blocking): - Cmd+J global keyboard shortcut (next iteration) - SSE-driven updates instead of polling (the bridge already exists; drawer just needs to subscribe to fc:state events for project_states table changes) - Filter / search inside the drawer when project count gets large Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
d5ba3f3212 |
feat(control): rewrite daemon banner — action-first onboarding + re-pair path
The old banner promised "Generate a token below" but no token UI existed in
the banner. Three vague setup steps (install Zellij, pick an agent, run an
installer) without concrete commands. New users hit a dead end.
Rewrite of the daemon-never-seen branch:
- Lead with the two paths a builder actually chooses between:
A. "Start a new project" → /control/new-from-scratch (no install, works
today, GitHub repo + starter scaffold all from this website).
B. "Install Fleet Runner desktop" → /download (only required if you
specifically want to dispatch agents at LOCAL repos — clarified the
prerequisite).
- Collapsed advanced section for the terminal-only CLI installer path,
with the actual one-liner command pasted (curl … | node - init --token).
Rewrite of the daemon-offline branch (the situation a returning user is in
after the Hetzner cutover invalidated their old token):
- Surfaces a "Mint a fresh ck_* token" link to /settings so they can
re-pair Fleet Runner without hunting through the settings UI.
No new components — only DaemonStatusBanner JSX. The download page,
/control/new-from-scratch, /settings token-minting all already exist; this
just makes the paths to them discoverable from the first thing a new user
sees on /control.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
9c3abb01e6 |
feat(projects): first-class git_url column on entities + "Open repo" link
Right now the GitHub URL for a project lived as text in the description field (cloud bootstrap was concatenating it in) or as legacy attrs.repo. Adding a real schema column makes it queryable, indexable, and a predictable lookup path for the UI. Schema: - entities.git_url (text, nullable). Drizzle-kit push'd to Hetzner. - All non-project entities (people, commitments, etc.) leave it null. - Backward-compat: existing projects with attrs.repo still work — UI falls back to that when the column is null. Wired into: - createProject(): accepts optional gitUrl in CreateProjectBody, persists. - patchProject(): accepts optional gitUrl for inline edits. - /api/projects/create-with-github (cloud bootstrap) → passes repo.html_url. - /api/projects/bulk-from-github (multi-select import) → passes repo.html_url. - /api/projects/import-from-local (terminal one-liner) → passes folder.remote_url if the local repo has an origin remote configured. - Description field for cloud-bootstrap no longer carries the URL inline — it's now in the dedicated column, freeing description for actual prose. UI: - getProjectLinks() now takes an optional gitUrl as 2nd arg; entity column wins over attrs.repo when both are set. - ProjectGridCard's GitBranch quick-link icon (which was rendered behind attrs.repo) now also lights up for projects with entities.git_url. - ProjectDetailHeader same. - /control's ProjectState type intentionally NOT extended yet — that pipeline joins project_states + entities through a different code path; deferred to a separate change (probably worth a small refactor to surface gitUrl on ProjectState). End-to-end: create a project via /control/new-from-scratch → repo gets created with git_url populated → land on /projects → see the GitBranch icon as a clickable link to the repo. One click from project list to repo. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
08f518f826 |
feat(onboarding): 3 more starter templates — FastAPI, Hono Workers, plain HTML
Doubles the catsitting flow's surface to cover the common idea-shapes: 1. python-fastapi (Python + FastAPI + uv) Async API. uv-managed deps (pyproject.toml). Runs with `uv run uvicorn src.main:app --reload`. 4 files. Use case: AI/ML startups, data pipelines, anything Python-side. 2. hono-cloudflare (Hono on Cloudflare Workers) Edge-serverless TypeScript. 100k free requests/day, ~5ms cold starts. wrangler.toml + Hono routes. 6 files. Use case: lightweight APIs, webhooks, edge functions. 3. html-tailwind (Plain HTML + Tailwind CDN) No build step. Open index.html in a browser. Perfect for landing pages or quick demos. 4 files. Use case: marketing pages, MVPs that need to ship fast. Plus the existing two: - bare (just a README) - nextjs-tailwind (Next.js 15 + Tailwind v4) Total: 5 templates. The radio selector on /control/new-from-scratch auto-picks them up via `Object.values(TEMPLATES).map(...)` — no UI change needed. Endpoint's Zod schema updated to accept the new enum values. Why these four templates specifically (vs. more): - next.js+tailwind: covers full-stack TS / "build a real product" - python+fastapi: covers AI/ML and Python ecosystems - hono+cf: covers edge/serverless TS - html-tailwind: covers landing pages / no-build - bare: covers "I'll set it up myself" Anything else (Vite SPA, Express, Rails, Django) is one preference removed from one of these. Keep the list short until a user asks for more. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
d1edafe198 |
feat(onboarding): Next.js + Tailwind starter template for new-from-scratch
The cloud bootstrap created a bare repo with just a README. Useful but
not magic. Now users can pick a starter that ships with working code so
their "catsitting startup" is actually runnable from minute one.
Pieces:
1. src/lib/project-templates.ts — SSOT for available starters. Each entry
declares its files inline (no external template-repo to maintain).
Files support {{NAME}} / {{DESCRIPTION}} placeholders rendered server-side.
First starter: "Next.js 15 + Tailwind v4" (9 files: package.json,
tsconfig.json, next.config.ts, postcss.config.js, .gitignore, README.md,
src/app/{page,layout}.tsx, src/app/globals.css).
2. seedTemplate() in /api/projects/create-with-github
After the repo is auto-init'd with a README, we make 4 sequential
GitHub API calls (with N parallel blob creates):
- GET branches/main → get base commit + tree
- POST git/blobs (parallel for each template file)
- POST git/trees with base_tree (so README stays)
- POST git/commits with main as parent
- PATCH git/refs/heads/main → fast-forward
Failure is non-fatal: the repo still exists, user can clone the bare
version. Response carries `templateSeeded: false` so the UI can warn.
3. /control/new-from-scratch UI gains a radio selector for starter:
- Empty (just a README) [default]
- Next.js 15 + Tailwind v4
Both options shown with their human description.
4. Success view notes which starter was seeded.
End-to-end now:
/control empty → "Start a new project" → name "catsitting" → pick
"Next.js 15 + Tailwind v4" → submit → 1.5s later you have a real repo
with a runnable Next.js app + your name on the home page. `git clone`,
`npm install`, `npm run dev`, live at localhost:3000.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
c68b78108b |
refactor(agents)+feat(onboarding): consolidate label maps + editor deeplinks
Two small cleanups continuing from the 2026-06-05 code audit: 1. AGENT_LABELS SSOT in agent-registry.ts The 3 duplicate label maps in control-presenter.ts (lines 309, 334, 348 in the pre-refactor version) all named the same agents — slight drift waiting to happen. Now there's one canonical AGENT_LABELS map exported from the registry; control-presenter imports it. Plus ALL_AGENT_IDS for tab-name parsing. The "agent" → "Cursor" legacy alias is handled as a one-line PROCESS_NAME_ALIASES map (process basename ≠ UI id). 2. "Open in Cursor / VS Code" deeplinks on /control/new-from-scratch After creating a brand-new GitHub repo + project, the success page now surfaces collapsible deeplinks (cursor://file/, vscode://file/) so the user can launch their editor in one click after they clone. Assumes the default ~/dev/<name> clone path; surfaced as a hint in the disclosure. No behavior change to the existing flows. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
9d95b3ee42 |
feat(onboarding): cloud-side "start a new project" — GitHub repo + FleetCrown row
Closes the catsitting-startup loop for cloud-only users (no local runtime).
Before this commit, the only "scaffold from idea" path was BootstrapModal
which requires the Fleet Runner daemon to write to ~/dev and shell out to
`gh repo create`. Users without the daemon could only IMPORT existing
projects — they had no way to create a fresh one through the website.
What ships:
1. POST /api/projects/create-with-github
- Auth via session cookie (signed-in user)
- Reads user's GitHub OAuth access_token from the accounts table (saved
automatically on GitHub sign-in)
- Calls api.github.com/user/repos with the user's token to create a real
repo (name, description, visibility, auto-init README)
- Slugs the repo name (lowercase, hyphens); preserves original display
name as the FleetCrown project entity name
- Creates the FleetCrown project row pointing at the new repo URL
- Returns { gitUrl, sshUrl, cloneCmd, cloneHttpsCmd, project }
- Graceful failure modes: 400 if no GitHub linked (with hasGithub:false
and a hint to /control/import → Connect GitHub), 409 on duplicate repo
name, 502 on GitHub API errors with the original status surfaced
2. /control/new-from-scratch page
- Form: name (required), description (optional), visibility (private/public)
- Submit → endpoint above → success view with the clone command in a copy
button (SSH primary, HTTPS in a collapsed details)
- "Create another" loop without leaving the page
3. EmptyStateWelcome's first card becomes adaptive:
- With runtime (onBootstrap defined): button → BootstrapModal as before
- Without runtime: link to /control/new-from-scratch (cloud GitHub flow)
- Always visible — no more hidden Bootstrap
The grid is now always 5 columns on lg (5 onboarding paths total: start fresh,
import GitHub, import ~/dev, add manually, install Fleet Runner). 2-col on md.
End-to-end:
/control empty → click "Start a new project" → form → submit →
GitHub repo created with README → FleetCrown row created →
user copies `git clone git@github.com:you/catsitting-startup.git` →
clone wherever they want → start hacking.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
1f94978179 |
refactor(control): close 3 of 5 audit findings on /control empty state
Quick UX-visible cleanups from the 2026-06-05 code audit of /control + /projects:
1. Expose Bootstrap as 5th card in EmptyStateWelcome.
The "scaffold a new idea from scratch" flow (BootstrapModal → /api/project/
bootstrap → AI brief + GitHub repo + local folder + agent launch) was the
highest-leverage feature already built but invisible to new users — only
reachable via a small "New" link in the FleetStatus toolbar that requires
the daemon to be running.
The card is conditional on `runtimeAvailable` because /api/project/bootstrap
shells out to `gh repo create` and writes to ~/dev — both require the local
Fleet Runner daemon. Threading `onBootstrap` through ControlPanel maps the
card click to setBootstrapOpen(true).
2. Delete duplicate empty state in ProjectOperationsView.
When data.projects.length === 0, EmptyStateWelcome (5 CTAs) rendered above
AND ProjectOperationsView's inline empty state (3 buttons with different
copy) rendered below — two competing zero-states. The inline one is now
`return null` since the welcome above is canonical. Drops 4 imports.
3. Rename SOURCE_COCKPIT_UI → SOURCE_FLEETCROWN_UI across 8 call sites + the
constant definition. The value was already `${APP_SLUG}-ui` = "fleetcrown-ui"
so this is purely the variable name catching up to the brand SSOT.
Deferred from this commit:
- Cloud-side bootstrap (next: needs Octokit, a new endpoint that doesn't
require local runtime — the actual user-visible "catsitting from cloud" gap)
- Agent label map consolidation in control-presenter.ts (internal hygiene)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
4f7c952a6a |
fix(proxy): allow public access to /import-from-local.sh
The bash one-liner served from /import-from-local.sh (used by users to scan their ~/dev folder and import repos via curl|bash) was being caught by the auth-gate proxy matcher and 302-redirected to /sign-in, returning the signin HTML instead of the script body. Added the path to the matcher exclusion list so it serves the static file directly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
a764e464ba |
feat(onboarding): local ~/dev folder import via terminal one-liner
Closes the second-most-common project-source gap (after GitHub) caught
during dogfooding: builders' projects live in github repos AND on disk
in ~/dev. The GitHub side already had bulk-import via /control/import;
this adds the parallel for local folders.
Pieces:
1. POST /api/projects/import-from-local — accepts { folders: [...] },
creates one project per folder, dedupes by name. Auth via Bearer
ck_* agent token (validateAgentToken — reuses the existing token
surface, no new auth path).
2. scripts/import-from-local.sh (+ public/import-from-local.sh mirror) —
bash one-liner that walks $HOME/dev, $HOME/code, $HOME/Code,
$HOME/Projects (configurable via FC_ROOTS), finds .git directories
(max depth 3), extracts name + path + origin URL + last-commit ISO,
POSTs the batch. Safe to re-run; duplicates are reported, not errored.
3. /control/import-local — new page that walks the user through:
(a) mint a ck_* token at /settings (with link),
(b) paste the one-liner with their token,
(c) refresh /control to see imports.
4. EmptyStateWelcome on /control gets a fourth CTA card: "Import from
~/dev — paste one terminal line." Grid is now 2-col on md, 4-col
on lg so the four import paths fit cleanly.
5. CopyableCommand component (components/control/) for the one-line
bash block with a copy-to-clipboard button. Promotable to
components/ui/ if a second feature needs it.
UX flow:
/control empty → click "Import from ~/dev" → mint token at /settings
→ paste curl|bash in terminal → script scans local repos → refresh
/control → projects appear alongside GitHub imports.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
15e5159437 |
chore(brand): clean up user-visible Cockpit residue in comments
Non-functional. Three comment edits to reflect the FleetCrown rebrand where the legacy "Cockpit" name was still showing up in: - src/auth.config.ts: deployment-URL explanation (clarified that the internal Vercel project remains legacy-named "cockpit" pending dashboard rename, hence the cockpit-<hash>.vercel.app URLs) - src/components/control/ControlPanel.tsx: dogfood note - src/components/shared/RefreshOnFocus.tsx: refresh-event name doc NOT TOUCHED (deliberate — backward compat with running Fleet Runner daemons and existing user installs): - COCKPIT_* env var fallbacks (process.env.COCKPIT_DAEMON_TOKEN etc.) — paired with APP_* in code as `APP_X ?? COCKPIT_X`; ripping the fallback would break daemons in the field - /tmp/cockpit-* and ~/.config/cockpit/ paths — reflect user-side install state; renaming server-side would orphan local files - localStorage keys (cockpit-sidebar-sections-v1, cockpit.palette.recent) — already marked LEGACY for backward compat; renaming = users lose state - cockpit-daemon.service systemd unit — kept as fallback in UNIT_CANDIDATES alongside fleetcrown-daemon.service (preferred) - stripe metadata cockpitUserId — webhook contract; defer User-visible product is unaffected (APP_NAME = "FleetCrown" everywhere). The remaining cockpit references are technical debt to clean up in a deliberate later pass once running daemons are migrated. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
bda8681e5f |
feat(onboarding): in-place Connect GitHub button for email/password users
If you signed up via email+password, /control/import was a dead end — it
told you "no GitHub linked" with no way to fix it. Auth.js v5 supports
account linking via signIn("github") while already authenticated; this
adds a button that does exactly that.
After clicking, OAuth roundtrip → access_token saved to the existing
user_id → return to /control/import with hasGithub=true → repo list
appears. No sign-out, no second user account, no duplicate row.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
bff431799b |
fix(vercel): comprehensive .vercelignore — stop uploading .env.production.local
This was masking the Phase E Hetzner cutover for hours. .vercelignore was slimmer than it needed to be, so `vercel --prod --yes` was uploading the working directory's .env.production.local file. Next.js loads that at runtime with higher priority than platform env vars set via `vercel env add`, so every API call kept hitting Neon despite the platform env showing the new Hetzner DSN. Two patterns to internalize: 1. Local env override files (.env.*.local) MUST be in .vercelignore. .gitignore alone isn't enough because the Vercel CLI uploads from local context, not from git. 2. Patterns without a leading `/` match anywhere in the tree. `desktop` would wrongly exclude src/components/desktop/ (real source code). Root-level exclusions must be anchored with `/desktop`, `/bridge` etc. Diagnosis details + future-proofing pattern saved to memory/pattern_vercel_cli_env_local_override.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
6b974ce602 |
feat(onboarding): add "Import from GitHub" button to zero-state ProjectOperationsView
Companion to the new EmptyStateWelcome card. The ProjectOperationsView's own internal empty state (rendered below the welcome card, as a fallback for the project list area) now also surfaces the bulk-import affordance. Three buttons total: Bootstrap project (when runtime live), Register existing project (manual), Import from GitHub (the new path). This means a new user sees the bulk-import option in TWO places when they land empty — the welcome card AND the project list zero-state — closing the discoverability gap that prompted this change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
7019c41b08 |
feat(onboarding): bulk-import GitHub repos as projects + welcome empty-state
A new FleetCrown user with a GitHub account and 10+ repos shouldn't have to add projects one-by-one through a single-select picker, and a brand-new user shouldn't land on a blank /control with no guidance. Both gaps caught during dogfooding of the post-Hetzner cutover (fresh DB, zero projects). Changes: 1. `POST /api/projects/bulk-from-github` — takes an array of repo IDs, re-fetches the canonical repo list from GitHub via the user's stored OAuth token (so callers can't smuggle arbitrary names/descriptions), and creates N projects in one round-trip. Duplicates by name are silently skipped, not errored. 2. `RepoMultiPicker` component — checkbox-list version of the existing single-select `RepoPicker`. Includes a filter input, select-all/none buttons, and a selected-count display. Skipped repos surface their reason inline. 3. `/control/import` page — wires the multi-picker to the bulk endpoint with a search input and a primary "Import N projects" button. Auto-redirects to /control on a clean import; stays on the page if anything was skipped so the user can see why. 4. `EmptyStateWelcome` component — replaces the dead-end blank /control for users with zero projects. Three CTAs: import from GitHub (recommended, links to the new page), add manually (opens the existing NewProjectModal), install Fleet Runner. Disappears once any project exists. 5. Wired the empty-state into `ControlPanel` between the daemon banner and FleetStatus — exactly where the first-touch user would expect "what should I do?" guidance. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
5a37c3d990 |
fix(install): two production-validated bugs surfaced during Hetzner v0.6 cutover
Both fixes apply to scripts/oracle/install.sh based on the actual Hetzner deploy
on 2026-06-04. The install.sh path is now first-try-clean on Ubuntu 26.04.
1. Caddyfile `log { format filter ... query_replace }` removed. The
`caddy.logging.encoders.filter.query_replace` module isn't registered in
Caddy v2.11 — the service refused to start with "module not registered".
Default access logging goes to journalctl. If token-redaction matters
later, look at the `regexp` filter encoder or disable access logs.
2. pg_hba.conf gained host entries for 127.0.0.1/32 (fleetcrown +
orangecat roles, scram-sha-256). Without them, the Node bridge's
pg client couldn't connect to its own Postgres: pg requires explicit
`rejectUnauthorized: false` to accept Postgres's default self-signed
TLS cert, which isn't exposed via DSN. Bridge .env also switched to
`sslmode=disable` — loopback connection only, scram-sha-256 password
is the actual security boundary.
Verified end-to-end on 2026-06-04: SQL `pg_notify('fc:state', ...)` →
bridge `eventLogSize` increments → HTTPS endpoint at bridge.orangecat.ch
serves with valid Let's Encrypt cert.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
c14e61a531 |
docs(thoughts): two essays — the studio stack + who FleetCrown is for
Both synthesize today's strategic conversation about infrastructure
shape, the levelsio pattern, and FleetCrown's customer.
the-studio-stack-one-box-all-your-projects.md (~3000 words):
- The shape of indie-builder infrastructure: many small products,
few users each — the opposite of what cloud services price for.
- Why managed services multiply painfully at portfolio scale.
- The studio stack: one Hetzner box, one Postgres process, many
databases, Vercel for frontends, Caddy in front, R2/B2 for media.
- Concrete pricing math (€7/mo hosts a 15-project portfolio).
- The Postgres-one-process-many-databases technical model.
- Levelsio's public reference architecture.
- The "ten vendors" discipline.
- When to scale up (in-place rescale, second box, breakout product).
- Backups + Tailscale + Cloudflare Tunnel as the hardening trio.
- Closing: infrastructure ROI is attention back to product work.
the-levelsio-pattern-productized-who-fleetcrown-is-for.md (~2700 words):
- The May 11 tweet that names the customer.
- What the manual pattern has, what it's missing.
- The five thoughts every levelsio-pattern operator has had.
- What FleetCrown adds (dashboard, dispatch from anywhere, structured
history, autopilot policy, real-time notifications).
- Anti-positioning: FleetCrown is not Cursor / Copilot / Devin clones.
- Who actually buys this: solo founders / freelancers running 5+
projects with AI agents on remote infrastructure, indie tool prices.
- What this means for the roadmap (multi-machine fleet, anywhere
dispatch, history, policy, push). What we explicitly DON'T build
(team seats, RBAC, enterprise compliance, marketplace).
- Pricing strategy: flat monthly, not per-agent / per-seat.
- Marketing voice: "missing dashboard for the workflow you already run."
- Distribution: Twitter, HN, #buildinpublic — not SEO funnels.
- Default integrations: Tailscale + CF Tunnel ship as recommended.
- Closing: the customer was already in the wild, posting screenshots
of their Hetzner dashboards — read what they say as a job
description for the product you should be building.
Both are first-person essays from Mao, layered for technical and
non-technical readers per the established voice. Cross-reference the
kill-switch and polling-to-listening articles so the four-essay arc
reads as one coherent story:
1. The Database Kill Switch (May 22) — why we left Neon
2. From Polling to Listening (June 4) — the v0.6 rebuild
3. The Studio Stack (June 4) — the infrastructure pattern
4. The Levelsio Pattern, Productized (June 4) — the customer
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
c749f3f2d2 |
chore(oracle): one-shot Oracle Free → studio stack install script
Runs on the Ubuntu 24.04 ARM box, takes ~10 min, leaves you with:
- Postgres 17 + fleetcrown/orangecat roles + databases (per-role pg_hba)
- v0.6 NOTIFY triggers applied
- Bridge built and running as systemd fleetcrown-bridge.service
- Caddy reverse-proxy with auto letsencrypt TLS at BRIDGE_HOST
- UFW + iptables on 22/80/443/5432 only
- Daily pg_dump cron retaining 30d in /backups
Required env: FLEETCROWN_DB_PASSWORD, ORANGECAT_DB_PASSWORD, BRIDGE_HOST
Optional env: FLEETCROWN_DUMP_URL, ORANGECAT_DUMP_URL (restore from URL)
User flow:
1. Point bridge.fleetcrown.com (or whatever) A record at the Oracle IP
2. ssh ubuntu@<oracle-ip>
3. FLEETCROWN_DB_PASSWORD=... ORANGECAT_DB_PASSWORD=... BRIDGE_HOST=bridge.fleetcrown.com \
curl -fsSL https://raw.githubusercontent.com/maonakamoto/fleetcrown/main/scripts/oracle/install.sh | bash
4. Set the printed Vercel env vars, redeploy
5. /api/health returns 200 against the new DB, /control feels real-time
Idempotent — re-running won't error. Each step checks for the prior
state and skips if already done. Safe to re-run after a partial failure.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
e36beafafe |
feat(v0.6): Phase B + D — web SSE subscription, daemon event-driven push
Phase B (web client):
src/lib/event-stream.ts — useEventStream() hook that opens an
EventSource to the bridge for the component lifetime, mints a
per-session ck_* token via /api/event-stream-token, fires onChange
for every "change" frame. Auto-reconnect with Last-Event-ID replay.
No-op gracefully when NEXT_PUBLIC_FLEETCROWN_BRIDGE_URL is unset.
src/app/api/event-stream-token/route.ts — server-side endpoint that
mints a fresh ck_* labeled "event-stream" for the signed-in user.
no-store headers since the response contains a secret.
src/hooks/use-control-data.ts — when bridge is configured, poll
interval flips from 30s → 5min and SSE drives freshness. Bursts
coalesced into a single refetch via 200ms debounce.
Phase D (desktop daemon):
desktop/src/main/pusher.ts — heartbeat interval bumped from 60s to
5min (now a liveness signal only). New pushNow() helper coalesces
event-driven pushes so a burst of worker.idle events triggers one
POST, not N.
desktop/src/main/index.ts — notifyOnIdle now calls pushNow() so the
cloud learns about agent state changes within seconds instead of
waiting for the next heartbeat. Same code path that already shows
the local OS notification — both ride the same watcher event.
Combined egress reduction once bridge is deployed on Oracle:
/api/control polling: 9 GB → 0.4 GB/user/mo (22x)
Daemon runtime-state heartbeat: 300 MB → 60 MB/user/mo (5x)
+event-driven pushes on agent idle: ~10 MB/user/mo
Total: ~18 GB → ~470 MB/user/month (38x reduction)
Activates by setting NEXT_PUBLIC_FLEETCROWN_BRIDGE_URL on Vercel and
deploying the bridge on Oracle (Phase E).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
e3541e2374 |
feat(v0.6): Phase A — event bus foundation (Postgres NOTIFY → SSE bridge)
The end-to-end push pipeline that replaces /api/control polling. This
commit ships the foundation; phases B-E light it up across the web,
desktop, and daemon. Read the architectural narrative in
/thoughts/from-polling-to-listening-fleetcrown-v0-6.
drizzle/0022_notify_triggers.sql
- Generic fc_emit_change() plpgsql function: receives (user_col,
key_col) via TG_ARGV, emits NOTIFY 'fc:state' with a compact
{t, u, k, op, ts} JSON payload. IDs only — no row content — so
the bus stays under Postgres's 8 KB NOTIFY limit even on bursts.
- AFTER INSERT/UPDATE/DELETE triggers on the five UI-relevant
tables: project_states, runtime_snapshots, pending_commands,
orchestration_runs, beacon_settings.
- Adding more tables in the future is two lines: drop + create
trigger pointing at the same fc_emit_change function.
bridge/ (new ~300-line Node service)
- src/server.ts — HTTP server with /sse (SSE endpoint, ?token=ck_*
auth, Last-Event-ID replay) and /healthz. CORS open; the bridge
sits on a different origin than Vercel and the desktop app.
- src/listen.ts — single dedicated pg Client running LISTEN
"fc:state" forever, with exponential-backoff reconnect on
disconnect. Notifications fan out to subscriptions.
- src/subscriptions.ts — in-memory Map<userId, Set<connection>>.
Per-user routing; fanout writes SSE frames; idempotent remove
on disconnect.
- src/auth.ts — validates ck_* tokens against agent_tokens using
the same plaintext lookup the cloud API uses (mirrors src/db/
queries/agent-tokens.ts validateAgentToken).
- src/types.ts — ChangeEvent and Subscription shapes.
- In-memory ring buffer (1000 events) for Last-Event-ID replay so
a brief disconnect doesn't drop state.
- Heartbeat (SSE comment) every 25s to keep proxies happy.
- Graceful SIGINT/SIGTERM shutdown with 5s hard-fail timeout.
- .env.example, .gitignore, README with the Oracle systemd deploy
runbook.
next.config.ts
- Exclude ./bridge/** from output: standalone tracing. Same lesson
as ./desktop/** — bridge has its own node_modules and is
deployed separately. Don't let Vercel bundle it into every
serverless function.
Verified end-to-end locally:
- psql UPDATE on project_states → fc_emit_change fires →
pg_notify reaches the bridge's LISTEN client → fanout to the
subscribed curl SSE connection in ~milliseconds.
- Per-user routing: a token bound to user A only receives events
for user A's rows; tested by minting under two different users.
- Last-Event-ID replay: reconnect with header skips already-
delivered events, then live events arrive immediately.
Next: Phase B (web client subscribes to the bridge instead of polling
/api/control). Phases C-E follow.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
2b4bd01ef8 |
docs(thoughts): "From Polling to Listening" — v0.6 architectural rebuild story
Companion to the kill-switch article (which told the story of WHY we are
leaving Neon). This one is the architectural plan for WHAT we are
building in its place, and why moving the host alone solves the wrong
problem.
Structure (11 sections, ~3200 words, ~18 min read):
1. The Wrong Question, and the Right One — the reader who pushed back
with "should we not fix the architecture first?"
2. What "Chatty" Actually Means — transactional vs continuous-monitoring
shapes, polling as the easy/wrong default
3. Why Polling Made Sense, and Why It Stops
4. What Push Looks Like, Concretely — SSE vs WebSocket, the pizza
shop analogy carries through
5. The Event Bus, Explained Without Vocabulary — Slack channels for
code analogy, why Postgres LISTEN/NOTIFY is plenty at our scale
6. The Bridge Between Bus and Client — the ~300-line Node service
that fans NOTIFY out to SSE clients, why it can't live on Vercel
7. Local-First, the Deeper Half — desktop reads from local files
first, cloud is a sync layer, Linear/Cursor/Obsidian as references
8. The Studio Stack, On One Free Server — both products one Postgres,
Oracle Free as the chosen host with Hetzner as the calm alternative
9. What v0.6 Will Build, in Plain Language — 5 steps with parenthetical
technical notes for engineers
10. What This Changes, For You and For Me — user-visible end state +
studio-visible end state + the personal panic-then-wiser moment
11. The Broader Lesson, For Anyone Building — managed services price for
average shapes; chatty/stateful/background-process products should
own their infra AND fix their chattiness
Voice/audience per the brief: explicitly written for both Elon Musk
and the average reader. Technical concepts (egress, polling, push,
event bus, LISTEN/NOTIFY, SSE, local-first) are introduced via concrete
analogies first, then named formally. Engineers get the parenthetical
specifics; non-technical readers can skip them without losing the
argument.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
9b80cc9137 |
chore(db): extend migration toolkit to OrangeCat / Supabase + both-on-one-host
Same job, one more source. Now the toolkit handles:
- FleetCrown out of Neon (`dump-from-neon.sh`)
- OrangeCat out of Supabase (`dump-from-supabase.sh`)
- Both consolidated onto one self-hosted Postgres box
scripts/db/dump-from-supabase.sh
Mirrors dump-from-neon.sh's interface. Supabase-specific guards:
- Refuses pooler URLs (port 6543 / pooler.supabase.com) because
pg_dump fails midway through transaction-pooled connections.
- Defaults to --schema=public only. Supabase's auth/storage/realtime/
extensions schemas would create dangling-role FK errors on a vanilla
Postgres target. FULL_DUMP=1 dumps everything when self-hosting
gotrue too (bigger project for another day).
- Same .sql + .manifest.txt output shape as the Neon script;
restore-to-target.sh accepts either without modification.
scripts/db/BOTH_PRODUCTS_ONE_HOST.md
Layers two databases (`fleetcrown`, `orangecat`) on a single Postgres
instance with separate roles and per-role pg_hba.conf lines. Covers:
- role + database setup
- pg_hba rules: each role authenticates only to its own DB
- migration sequence: FleetCrown first (it's broken), OrangeCat
second (still functional on Supabase)
- auth-stays-on-Supabase recommendation for OrangeCat (cheap, no
gotrue self-host needed at this scale)
- shared backup cron with off-box rsync mirror
- PgBouncer add-on for when connection count balloons
- explicit "when to split the box" thresholds (sustained 70% CPU,
<95% cache hit ratio, p95 latency >50ms)
scripts/db/README.md
Updated header + file table to mention both products. Migration
cookbook now has separate Step 1 entries for Neon vs Supabase and
points at BOTH_PRODUCTS_ONE_HOST.md for the dual-product path.
Capacity sanity for the curious: a Hetzner CX22 (€4.51/mo, 2 vCPU, 4 GB
RAM, 40 GB SSD) is over-provisioned by ~3 orders of magnitude for both
products at today's scale (single-user each). Upgrade in-place to CX32
when sustained CPU exceeds 70% — that's many months out.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|