Commit Graph
1304 Commits
Author SHA1 Message Date
g-but ef2ceffae8 fix(system): MemorySummaryCard catches its own getEntityStats failure
Sibling RecentFailuresCard already defended against query failure
with `.catch(() => [])`. MemorySummaryCard let getEntityStats throw
straight through Suspense — the most likely root cause of the
/system "Something went wrong" black-box screen that ee6df43 wrapped
with an error.tsx boundary.

Try/catch the query; render a small degraded card when the stats
can't be loaded, explaining the rest of System is unaffected and the
section will refresh on the next page load. Console.error keeps the
postmortem signal even when Vercel logs are unreliable
(pattern_vercel_log_fallback).

Now both server-component Suspense children on /system are isolated
— a failure in either renders a per-card degraded state instead of
falling through to the route-level error boundary. The page itself
stays functional.
2026-05-31 04:09:22 +02:00
g-but ee6df432b1 fix(system): defensive page render + route error boundary
Caught live on cockpitapp.vercel.app/system at 414px: the entire page
crashed into the global "Something went wrong" error with the generic
"Server Components render error" message — zero retry context, no
partial render. Per pattern_vercel_log_fallback the real cause is
opaque from outside (Vercel logs are unreliable on this stack).

Two-layer defense:
1. Wrap listCronJobsForUser (the only direct DB await on the page) in
   try/catch returning []. AutopilotCard handles empty initialJobs
   cleanly, so the rest of the route renders even when cron_jobs
   query fails (Neon blip, missing migration, etc.).
2. Add error.tsx for the /system route. Any server-component throw
   downstream (MemorySummaryCard, RecentFailuresCard) now renders a
   route-scoped error card with the digest + a Retry button instead
   of escalating to the generic global boundary. PageLayout shell and
   nav stay intact.

Doesn't fix the root-cause query (still unknown which DB call is
failing on cloud — needs a debug_logs row from prod), but the page is
no longer a black-box dead end for the user.
2026-05-31 04:02:05 +02:00
g-but 042972801d refactor: extract <ScrollAffordance> from four duplicate chevron sites
The mobile right-edge chevron pattern (relative wrapper + absolute
pointer-events-none ChevronRight + drop-shadow halo + sm:hidden) had
grown copy-pasted across four scroll surfaces in four sessions:
- Today SummaryBar (4cb018c)
- Settings tab strip (7ab36d6)
- Projects status filter chips (0523927)
- Prompts CategoryBar (a017df8)

Each call site had reinvented the same JSX with minor threshold
variations. Adding a fifth surface meant copy-pasting again — and
any tweak to the chevron icon, drop-shadow, or threshold semantics
would need touching four files.

Extract src/components/ui/scroll-affordance.tsx — a layout-only
wrapper that takes children + childCount + optional threshold (default 4).
Caller still owns the scroll container's overflow/fade classes; the
component only contributes the relative wrapper + conditional chevron.

Behavior is preserved at every site:
- Skeleton SummaryBar: childCount={0} (no chevron, matches old)
- Real SummaryBar: childCount={totalChipCount} threshold={3}
- Settings tabs: childCount={TABS.length} threshold={4}
- Projects status chips: childCount={statuses.length} threshold={4}
- Prompts categories: childCount={visibleCats.length+1} threshold={4}

Settings outer wrapper keeps its border-bottom so the underline spans
full width even when the inner scroll container is scrolled. No
imports lost; lucide-react ChevronRight now imported in exactly one
place (the new component).
2026-05-31 03:51:00 +02:00
g-but a017df89fa fix(prompts): mobile scroll affordance for CategoryBar chips
Fourth horizontal-scroll surface in the codebase to get the same
mobile chevron treatment as Today SummaryBar (4cb018c), Settings tab
strip (7ab36d6), and Projects status filter chips (0523927). Live
audit at 414px on cockpitapp.vercel.app/prompts caught "Engineering
(..." cut off at the right edge with neither a fade mask nor a
chevron — user has no cue the category bar is scrollable.

CategoryBar was also missing the ui-scroll-fade-right class entirely
(the other 3 surfaces had it for the opacity hint even if the chevron
was new). Adding both: the fade gives a subtle bg cue, the chevron
gives an explicit "more this way" affordance.

Threshold of visibleCats >= 3 matches the rough overflow point at
414px (1 "All" + 3 category chips ≈ first wrap-or-scroll boundary).
Pattern is now duplicated 4× — extracting <ScrollAffordance> is the
clear next refactor before a 5th surface appears.
2026-05-31 03:39:09 +02:00
g-but e0d71458c6 fix(projects): render dirPath + agentPref on every tile that has them
eae42d9 added the user_projects ⨝ entities join + render, but gated
on "no description AND no status AND no maturity AND no health signals
AND no next_step AND no extraAttrs." Live audit caught the problem:
almost every project tile DOES have a description (the few that didn't
were the bare ones I was looking at when picking the conditional), so
the dirPath + agentPref chips effectively never rendered in practice
— the join was paying for itself with zero user value.

Drop the gate. Render whenever either field is set. The chips are
already small and muted (text-[10px], text-text-tertiary, surface-
overlay bg) so they don't compete with description/status/maturity
above — they read as runtime metadata footer, which is what the user
actually wanted ("show me where this project lives and what agent
runs it, on every card").
2026-05-31 03:29:54 +02:00
g-but 60feb5332b fix(projects): StatusBadge truncates long status text with an ellipsis
ui-micro-badge applies display:inline-flex; truncate (Tailwind shortcut
for overflow:hidden + text-overflow:ellipsis + white-space:nowrap)
doesn't compose with inline-flex because flex layout doesn't apply
text-overflow to anonymous text children. Long status strings (e.g.
"Strategic planning only - no code, nothing yet") overflowed the
180px max-width and got cut mid-word with no ellipsis, so the chip
read as broken instead of "more text than fits."

Caught during a fresh Projects mobile audit at 414px: Bitbaum's
status chip showed "Strategic planning only - no code, n" with the
final char clipped against the chip border.

Wrap the text in an inner <span class="truncate"> so the ellipsis
has a block-like target. Outer keeps max-width + overflow:hidden so
the chip itself is bounded. Title attribute (already present) still
provides the full text on hover. No layout/color change.
2026-05-31 03:24:46 +02:00
g-but 05239273ee fix(projects): mobile scroll affordance for status filter chips
Third horizontal-scroll surface on mobile to get the same chevron
treatment as the Today SummaryBar (4cb018c) and Settings tab strip
(7ab36d6). Audit caught it live on Projects at 414px: the third
status chip ("Active") was cut off mid-word with no cue that the
filter row was scrollable — user would think they only had three
status filters when in reality they have eight.

Same pattern: wrap the scroll container in relative, add ChevronRight
pinned to the right edge inside the fade area on mobile (pointer-
events-none so chip taps fall through). Hidden on sm+ where chips
wrap. Conditional on statuses.length >= 4 — three chips fit at
414px without overflow, so the chevron would be misleading.
2026-05-31 03:17:10 +02:00
g-but c85d26272a fix(control): fleet-metric chips fade when daemon is offline/uncertain
ControlFleetStatus renders "X needs you / X working / X open" chips
from the last daemon-pushed snapshot. When the daemon is offline, the
numbers are cached state from the last sync — but the chips rendered
as live (full opacity, green dot, attention color), so the user reads
"1 working" as "an agent is making progress right now" when in
reality nothing has been observed for 2+ minutes.

Audit caught this live on mobile: header read "Daemon offline · sync
2m ago", chip row right below it showed "1 working" with a green dot.

When daemonOffline or daemonStateUnknown, apply opacity-60 + a title
tooltip explaining the chip is cached observation from the last sync
(with the sync age inlined when known). daemonNeverSeen path is
untouched — counts are zero in that state, no chip renders.

No layout change, no behavior change; pure visual honesty.
2026-05-31 03:10:35 +02:00
g-but 7ab36d6c91 fix(settings): mobile scroll affordance for tab strip
Settings tab strip (Profile / Account / Location / Agent / Projects /
Team / Billing) reliably overflows at 414px and the existing
ui-scroll-fade-right mask alone is too subtle on iOS where native
scrollbars hide at rest. Caught in a fresh mobile audit — landed on
Settings, "Team" was cut off mid-word with no visible cue that the
strip was scrollable. User would think the app only has 6 tabs.

Same fix pattern as the Today SummaryBar chevron (4cb018c): wrap the
scroll container in a relative div, add ChevronRight pinned to the
right edge inside the fade area, pointer-events-none so tab taps fall
through underneath. drop-shadow halo lifts the icon off the fade
background. Hidden on sm+ where the strip fits without overflow.
2026-05-31 03:06:43 +02:00
g-but 12a8667aa1 fix(today): templated dispatches render as intent badge, custom as body text
Today's "Recent Agent Work" card rendered every dispatch as
"projectKey [adapter] · timeago" + body=customPrompt || intent. For
templated dispatches (where customPrompt is null), the body became
the raw intent string — visible as "next_best" sitting on its own
line under the project name. Live mobile audit confirmed: two
back-to-back rows both showed "next_best" as body text, looking like
malformed prompts rather than templated intents.

4373e84 already shipped the right pattern on the Control panel
Activity feed: small uppercase pill badge inline with project name
when intent is templated, body row reserved for custom prompts. Same
class strings here so the two views match visually.

Body paragraph is only rendered when a custom prompt exists —
templated dispatches stay compact (one row instead of two).
2026-05-31 02:55:41 +02:00
g-but 4cb018c64c fix(today): mobile scroll affordance for SummaryBar chips
ui-scroll-fade-right alone is too subtle on iOS — native scrollbars
hide at rest, so a user landing on Today doesn't realize they can
swipe through more chips past the right edge. Caught during a live
mobile (414px) audit: chips visually fade off-screen with no
"there's more here" cue.

Wrap the scroll row in a relative container and add a ChevronRight
icon pinned to the right edge inside the fade area. pointer-events-
none so a chip tap underneath still lands. drop-shadow gives a
subtle halo that lifts the icon off the fading background.

Conditional on totalChipCount >= 3 — single-chip days don't need
the hint and 3+ is the rough threshold where overflow is likely on
a 414px viewport. sm:hidden ensures the chevron disappears once
chips wrap naturally on desktop.

Skeleton wrapper also gets the same relative div for consistent
layout while loading (no chevron — skeleton is fixed-width).
2026-05-31 02:49:57 +02:00
g-but 4373e845f8 fix(control): activity feed distinguishes templated dispatches from custom prompts
The Activity feed on each project card rendered every entry as a flat
"time + preview" row. A user scanning the feed couldn't tell at a glance
which entries were autopilot-fired Next best vs Test & fix vs a custom
prompt they typed by hand — the ledger threw the intent away and used
getIntentLabel as the body when customPrompt was null, so templated
dispatches just looked like short body text.

Carry intent through ProjectActivityEvent (null when customPrompt is
present) and render an uppercase pill badge before the preview when set.
Free-form prompts render unchanged. Existing copy + expand UX is
untouched.

Sample row reads "8m ago [NEXT BEST]" instead of "8m ago Next best" —
the badge is immediately visually distinct from the body text, so
scanning the feed shows the dispatch type at a glance.
2026-05-31 02:42:47 +02:00
g-but eae42d97d9 fix(projects): surface dirPath + agentPref on bare project cards
aec0ef8 dropped the dashed "Add context →" placeholder, leaving bare
tiles with just a title. Honest, but the user still had to click in
to see anything concrete. user_projects already stores the SSOT for
project runtime metadata (dirPath, agentPref) — surfacing it on the
card removes the need for that click.

DB: add fetchRuntimeMetaByEntityIds() that joins user_projects by
entityProjectId. Use in both getProjects and getOrgEntityProjects so
the returned ProjectRow gains dirPath + agentPref fields. Single
parallel query per page-load alongside fetchAttributesByEntityIds —
no N+1.

UI: extend the Project type with optional dirPath/agentPref. Render
them as small mono chips on truly bare tiles (no description, no
status, no maturity, no health signals, no next_step, no extra
attrs) — the same gap aec0ef8 left visually empty. dirPath is
truncated to the last two path segments (e.g. ".local/share/foo")
with the full path in title-tooltip. agentPref renders as a micro-
badge. Drops out cleanly when both fields are null.

No behavior change on tiles that already render status/maturity/etc.
2026-05-31 02:36:36 +02:00
g-but d77a8510dc fix(projects): make active health-filter chip visually distinct from base
2381a82 made the "1 security risk" and "X projects need attention"
counts toggleable filters. Active state was ring-1 ring-{color}/40 +
bg-{color}-subtle — the SAME hue as the base chip text. From the user
side at a glance, engaged vs disengaged states looked nearly identical;
caught during a live cloud audit at desktop width where the only
visible cue was a faint outline.

Three small bumps:
- ring-1 → ring-2 with /70 alpha (more presence)
- font-semibold on the active label so the text weight contrasts
- inline X icon next to the label as a universally-understood
  "click to clear" affordance (also doubles as the dismiss target)

Attention chip also gets the active-state text upgrade to
text-status-warning (was text-status-warning/80) so it brightens with
the rest of the engaged state.

Pure presentation; no filter logic change.
2026-05-31 02:29:31 +02:00
g-but aec0ef8467 fix(projects): drop "Add context →" placeholder on bare project cards
Bare projects (no description, no status, no maturity, no health
signals, no next_step, no extra attrs) rendered a dashed-bordered
"Add context →" box at the bottom of every tile. Caught during a
live cloud audit: in a 29-tile grid, every empty card had this
prompt dominating the visual — looked like a row of empty form
placeholders instead of a project portfolio.

The placeholder added zero data; the whole card is already clickable
via the wrapper's onClick, so the affordance to open and add context
is preserved. Bare tiles now show just the title (+ readonly badge,
action icons), which reads as "this project exists, click to learn
more" — same affordance, less visual noise.

extraAttrs path is untouched: when the user HAS set custom attrs
beyond the reserved set, those still render as micro-badges.

Smaller follow-up worth filing separately: surface dirPath + agentPref
from user_projects so even bare-attr tiles show concrete metadata.
That requires a query-level join (entities ⨝ user_projects) — not
in this commit.
2026-05-31 02:24:30 +02:00
g-but e88af3dc97 fix(control): explain ~25s daemon pickup when tab-switch results are queued
e62abe6 made /api/control/agent enqueue switch_agent commands on
cloud instead of silently doing nothing. The control panel's "Last
switch" line now renders "Cockpit queued, AOZ queued" — honest about
the state, but doesn't tell the user when the switch will actually
land. On Vercel the daemon long-polls /api/control/commands every
~25s (8s default + variability), so the gap between "I clicked
switch" and "agent actually swapped" is up to half a minute.

Append "· daemon picks up within ~25s" when any result has
status==="queued". No suffix when everything was "restarted" (local
mode) or fully "skipped" — those are immediate-outcome states. Keeps
the line compact when context-free.
2026-05-31 02:16:14 +02:00
g-but e62abe6f47 fix(control): cloud agent-switch queues switch_agent commands per project
/api/control/agent updated the user's stored agent/model preference,
then — in cloud mode — returned tabResults=[{status:"skipped", reason:
"Local runtime not available — cannot restart zellij tabs remotely."}]
and did nothing else. So a user clicking "switch to Cursor" in the
cloud Control UI silently failed to actually switch any open agent;
the pref was saved but no agent ever swapped.

Mirror the inject route's cloud-mode pattern: enqueue a switch_agent
command per registered project. The daemon's execute_switch_agent
(0ccb43d + 9a3bd61) handles tab-not-open as a no-op via its quit
signal path, so queueing for every registered project is safe — closed
tabs are skipped, open tabs get the switch. Also forwards model
explicitly; the daemon's _conf_model_for_tab fallback covers absent
model.

SwitchTabResult union gains "queued" so the response type is honest
about what happened on cloud. Local mode still uses the execSync
path with restarted/skipped/failed.
2026-05-31 02:11:45 +02:00
g-but 8ecddfc43b fix(orchestration): forward model into pending_commands payload
RunOrchestrationBody already accepts an optional `model` field
(z.string().max(160).optional()) and forwards it into orchestration_runs
.payload for trackable runs — but enqueueInjectCommand at the cloud-
mode branch dropped it. So autopilot next_best fires (the most common
caller of /api/orchestration/run on cloud) queued an inject without a
model, and the daemon launched the agent at its built-in default even
when the user had explicitly pinned a model in the request.

Add `model: request.model` to the enqueue payload. No new DB lookup —
the daemon's _conf_model_for_tab fallback (9a3bd61) already covers
the case where model is empty by reading from agent-projects.conf
(synced from user_projects.modelPref). This commit closes the
explicit-model path; the implicit-pref path already worked.
2026-05-31 02:03:31 +02:00
g-but 28dae157b8 fix(inject): carry modelPref through /api/inject payload to daemon launch
501a6e7 added modelPref to the conf-file path so the daemon's auto-
launch could read it. But /api/inject didn't write model into the
pending_commands payload at all, and execute_inject's dispatch case
didn't extract it — so cloud-side dispatches still launched with
empty model and fell back to each agent's built-in default. The
conf-file fallback worked, but a user who dispatched right after
changing modelPref (before the 5-minute conf-sync) would miss it.

Three-file change makes the explicit path land:
- InjectPayload: add model?: string. Mirrors the field shape already
  on LaunchAgentPayload + SwitchAgentPayload.
- /api/inject route: extract dbMatch.modelPref, include as
  `model: eventModel` in the executeInject payload.
- cockpit-daemon.sh: dispatch case reads payload.model; execute_inject
  accepts a 7th arg and prefers it over _conf_model_for_tab in the
  auto-launch branch. Empty payload model falls through to conf.

Precedence is now: payload_model > conf model > agent's built-in
default. tsc clean, daemon syntax OK.
2026-05-31 01:53:24 +02:00
g-but 7956ac6090 fix(settings): subdivide Beacon panel into Auto-inject / Popup / Voice
BeaconSettings was a single section with six unrelated fields stacked
vertically. From the user side it read as a long scroll where the
Voice (Whisper) options sat right after the Auto-inject mode picker
with no visual cue that they govern different things — easy to scroll
past or wonder why transcription is under "Beacon."

Group the six fields under three uppercase-kicker headings within the
same section so they share the one Save button at the bottom (no
state churn, no extra forms):
- Auto-inject: mode + idle gate + countdown (when/how the loop fires)
- Popup behavior: popup mode + advantage/trade-off callout
- Voice transcription: provider + Whisper model

Each subgroup is space-y-5 internally; subgroups separated by hr
dividers with space-y-8 between. Reorders fields slightly so related
controls live together (idle gate + countdown moved into Auto-inject).

Pure presentation; no behavior, API, or schema change.
2026-05-31 01:21:03 +02:00
g-but afdf2406d8 fix(settings): copy buttons for both install commands in Agent Tokens
The general install one-liner at the top of Agent Tokens settings was
inline <code> in a sentence — long URL, hard to select cleanly, no
copy button. The token reveal panel had a Copy button for the bare
token but only inline-code for the full pre-filled install command,
meaning users either copied the token then re-typed the curl line, or
hand-selected the long command in the paragraph.

Surface the install command as its own code block with a Copy button.
Inside the token reveal, also add a "one-shot install (token pre-
filled, no prompt)" block with its own Copy button — that's the path
most users actually want: one click → run on the new machine → done.

Refactor: single boolean `copied` becomes `copiedKey: string | null`
so multiple Copy buttons can each show their own check-mark without
stealing the others' state.
2026-05-31 01:14:36 +02:00
g-but 7a9fbe0d18 fix(settings): show token prefix + always-visible created date on agent tokens
Token rows in Settings → Agent Tokens listed only label + a single
"Last used X" or "Created X · never used" line. With three+ tokens
("dell", "local cockpit daemon", "local-cloud-daemon-2026-05-30") and
each daemon.env / .env.local holding a ck_… string, the user couldn't
tell which row mapped to which env file without a database query.

API GET now returns prefix = token.slice(0,12) + "…" alongside the
existing metadata. POST also returns prefix so the optimistic insert
in the client gets the same data without a refetch. Full token is still
stripped server-side (this only leaks the first 12 chars — same shape
GitHub uses for PATs, sufficient to identify, insufficient to forge).

Component renders the prefix as a mono code chip next to the label,
with a tooltip explaining the match-against-env use case. Created date
is now shown on every row (not just on never-used ones), with "last
used X" appended when available — so you can age-out unused tokens.
2026-05-31 01:09:21 +02:00
g-but 2381a826b6 fix(projects): banner counts are now click-through filters
"1 security risk" and "1 project needs attention" rendered as plain
text. User saw the count, wanted to jump to those projects, had to
scroll the grid by eye and read tile decorations to find them.

Turn both into toggleable buttons. Click "security risk" → grid filters
to projects with security_vulnerability set. Click "needs attention" →
grid filters to projects with any health signals. Click again or press
Escape to clear. Active state gets a subtle ring + filled bg so the
user knows the filter is engaged. Tooltip explains what the click will
do in both states.

Both counts compose with the existing query + status filter, so a user
can search "auth" + filter to "security risks" + a specific status all
at once.
2026-05-31 01:02:35 +02:00
g-but f814575a0d fix(projects): chip filter shows canonical short label, not truncated sentence
User-side audit caught the Projects status-filter chips rendering as
mid-sentence truncations: "Active — deployed as syst…", "Live — German-
language landi…", "150-line Prisma schema, no C…". Ugly and unhelpful —
the truncation cuts off exactly where the canonical label ends.

Add shortStatusLabel() that cuts at the first natural break (em/en
dash with spaces, comma, colon, " - ", open paren/bracket). Falls
back to hard truncation when no break exists or the head is too short
to be meaningful. CHIP_MAX_CHARS dropped 28 → 24 so tighter labels.

Filter value still uses the full original string; only the displayed
chip text changes. Full text remains in the title tooltip on hover.

Sample (verified):
  "Active — deployed as systemd service"        → "Active"
  "150-line Prisma schema, no CI yet, pre…"     → "150-line Prisma schema"
  "Pre-launch, Q2 2026 expected"                → "Pre-launch"
  "Strategic planning only - no execution yet"  → "Strategic planning only"
  "Active development"                          → unchanged
2026-05-31 00:56:33 +02:00
g-but 98de433f65 fix(today): group SummaryBar chips and visually separate Brief Ivy action
The top-of-Today chip row was 10+ chips in a single flat row with no
hierarchy. "0/2 habits" sat next to "1 urgent" — mixing units and
priorities, and "Brief Ivy" was styled identically to a status chip
even though it's the only actionable button. Reported as confusing
during a user-side audit.

Group into three semantic clusters: counters (what I have today —
goals, habits, contacts), alerts (what wants me — overdue, urgent,
due-soon, stalled, deadlines, drafts), fleet (what my agents are
doing — running, waiting, degraded). Thin vertical dividers (visible
on sm+, swallowed by horizontal-scroll on mobile) separate clusters
so the eye lands on each block as a unit.

Brief Ivy gets its own visual treatment — green border + subtle bg —
to read as an action rather than a status. Sits after the final
divider so it never feels like another count.

No data changes; pure presentation.
2026-05-31 00:50:10 +02:00
g-but 270a8dbf5d fix(empty-state): stop blaming the daemon for cloud-only feature gaps
CI/GitHub and Calendar cards both showed "X shows here once the local
daemon is connected" on Vercel. User saw this with the daemon CONNECTED
and pushing state successfully — naturally assumed Cockpit was broken
because the message implied daemon = the missing piece.

The actual constraint: github-status.sh and gog calendar shell out to
local CLIs (`gh`, `gog`) from the Cockpit *web server* process. Vercel
can't shell out to those. Daemon connectivity is irrelevant — even a
fully-paired daemon doesn't push CI / calendar snapshots upstream.

Replace both empty states with honest copy that names the real cause
(the gh/gog CLI lives on the web server's host) and the actual next
step (open the page on local Cockpit at http://localhost:3000).
Follow-up: have the daemon push a CI snapshot so cloud can render it
too — captured as audit punch list, not in this commit.
2026-05-31 00:40:48 +02:00
g-but 0e270e7e4e fix(today): show recent dispatches when no orchestration runs completed
"Recent Agent Work" said "No agent runs in the past 24 hours" even on
days with five active dispatches — the query only looked at
orchestration_runs, and manual injects via /api/inject (Send box,
prompt library, autopilot next_best) never land there. Spotted live
during a user-side audit: dispatched ~10 prompts this session, Today
card still read "No agent runs."

Add getRecentDispatches() reading from prompt_history with the same
24h window. When orchestration_runs is empty but dispatches exist,
render the dispatches with adapter chip + project + timestamp + the
prompt label, prefixed with "No completed orchestration runs yet —
showing recent dispatches." Truly quiet days still show the original
empty copy.
2026-05-31 00:34:26 +02:00
g-but 16d21c28e7 fix(inject): honor user_projects.agent_pref when caller omits adapter
POST /api/inject defaulted to "claude" whenever the body didn't pin an
adapter, so every project ran Claude regardless of agent_pref — a Gemini
project got Claude, a Cursor project got Claude. The per-row agent
preference is the SSOT exposed by /api/control and used everywhere in
the UI for the agent dropdown; the inject path was the one place
ignoring it.

After we resolve dbMatch (the user's project row), check agent_pref and
upgrade the provisional "claude" default only when the column is set
AND valid against ORCHESTRATION_ADAPTER_IDS. Caller-supplied adapter
still wins; agent_pref is just the fallback.

Daemon side already prefers payload_adapter (from d6215fe) before
defaulting to "claude" in execute_inject, so this commit closes the gap
end to end: web UI → /api/inject reads agent_pref → payload carries it
→ daemon launches the right agent in the right tab.
2026-05-31 00:27:24 +02:00
g-but d6215feda6 fix(dispatch): make local + cloud dispatch reliable end-to-end
Local-only daemon installs were silently broken: prompts queued from
localhost:3000 sat unclaimed because the daemon polled cloud, and "Not
running / Workspace tab open" contradicted itself on every project card
whose Zellij tab was open without an agent. This change wires both
sources, auto-launches the configured agent when its tab is empty, and
honestly labels tab-open-but-untracked state.

Daemon (scripts/cockpit-daemon.sh, _agents.sh, agent-hook-lib.sh):
- COCKPIT_BASE_URLS=local,cloud forks one child per extra URL so both
  cockpit-app instances drain to the same machine; per-URL flock so
  the children coexist.
- execute_inject auto-launches the chosen agent when none is running in
  the project dir, then polls 20s for the process before injecting —
  fixes prompts being typed into a bare bash shell.
- Wrap every `zellij action` call in `timeout 3` so one hung subprocess
  no longer freezes the single-threaded dispatch loop.
- Delete the obsolete _base_url local-probe / DAEMON_FORCE_REMOTE
  branch; each child now owns exactly one URL.

Auth (src/lib/session.ts):
- Legacy COCKPIT_DAEMON_TOKEN bearer was short-circuited by the `ck_`
  prefix check, returning 401 against local cockpit-app. Fall through to
  the legacy env-var path when the ck_ token isn't in the DB.

Control UI (ProjectCard, control-presenter, ZellijLivePanel,
project-intent-panel, ControlPanel):
- Idle + tab-open + !session-open → badge reads "Tab open" (was
  contradictory "Not running"); evidence line and intent-panel copy
  follow suit.
- Hide Launch CTA + saved-handoff block when the workspace tab is
  already open — they were inviting the user to "launch" something
  the daemon would have to refuse.
- Replace autonomy hint when tab is open but no agent is tracked.
- Surface "Last dispatch <age> · <prompt>" in the header evidence line
  so the cloud UI shows what was sent without scrolling to Activity.
2026-05-30 23:34:03 +02:00
g-butandCursor 92757c655b fix(push): return 503 on bad VAPID keys instead of silent 500
Malformed Vercel VAPID keys caused setVapidDetails to throw; wrap configure
and notify in try/catch. Use STALE_CLAIM_SECONDS in reclaim SQL.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-30 21:27:41 +02:00
g-butandCursor 60f0cff749 feat(push): web push subscriptions and stop-hook notifications
Adds VAPID-backed subscribe/notify API, service worker, top-bar pill,
and Stop hook push_notify_stop for ambient agent-done signals on mobile.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-30 21:05:35 +02:00
g-butandCursor 31b01ff44e fix(control): show Working state and mobile fleet summary
Runtime presenter no longer requires agentRunning for Working; handoff
status:working does not stale an active prompt; fleet status bar for mobile.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-30 21:03:34 +02:00
g-butandCursor ee5314a5b4 fix(autopilot): keep loop running after agent stop without hooks
Session-handoff watchdog fires when status:ready is fresh; Stop hook runs
autopilot first and queues inject via /api/inject with bearer fallback.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-30 21:01:38 +02:00
g-but e4cc0d9a8c Fix control runtime tabs and autopilot handoff 2026-05-30 15:39:00 +02:00
g-butandClaude Opus 4.7 142e21f271 feat(palette): voice input via /api/control/transcribe
Adds a mic button to the command palette that records a clip, posts to
/api/control/transcribe, and fills the search input with the transcript.
The user can then select a matching prompt with Enter — same flow as
typed search.

- New /api/control/transcribe route — re-exports POST from the existing
  /api/beacon/transcribe so Whisper/Groq routing stays a single source
  of truth during the beacon retirement. Implementation moves to this
  file in Stage 6 when the beacon route is removed.
- New use-voice-input hook — wraps MediaRecorder with state lifecycle
  (idle → recording → transcribing → idle / error), auto-stop at 60s,
  graceful cleanup on unmount. Greenfield extraction from the
  BeaconClient mic code so any surface can light up voice cheaply.
- CommandPalette: mic button between input and Esc kbd. Pulses while
  recording (oklch ring). Transcript fills the search input; errors
  surface in a one-line band beneath.

Voice-driven dispatch (palette → project picker → /api/inject) lands
later — Stage 5 wires push so the autopilot ↔ user loop closes first.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-29 17:27:39 +02:00
g-butandClaude Opus 4.7 f524134969 feat(shell): command palette, app top-bar, micro footer, x.ai polish
Folds the shell pass into Stage 3 of the autopilot rollout. Three new
surfaces and four restraint passes — designed to look closer to x.ai
(quiet chrome, type-driven hierarchy, soft separation) without breaking
the existing design-token contract.

New surfaces (all SSOT, all ui-* classes):
- CommandPalette — global ⌘K / Ctrl-K / `/` opens a searchable list of
  every agent prompt (~/.config/agent-prompts.json), every built-in
  PROMPT_TEMPLATE, and every active route. Recent selections survive
  in sessionStorage. Click → navigates to /control (agent), /prompts
  (template), or the route. Arrow keys + Enter; Esc closes.
- AppTopBar — slim sticky bar above <main>; only content is the
  palette trigger for now. Reserved on the right for Stage 5's push
  status pill and the eventual account chip.
- AppFooter — micro strip at the bottom of <main> on desktop. Env
  badge + commit SHA + link to /system. Counterweight to the sidebar.

Shell polish (from the x.ai-aligned review):
- ui-sidebar: hard 1px border → inset 0.04 opacity shadow; soft edge.
- ui-mobile-nav: backdrop-blur-xl → -md, less visual artifact.
- ui-nav-item-active: drop the full border, swap for a 2px left-edge
  accent. Reads as a marker, not a card.
- ui-sidebar-utility: tighten px-4 py-2.5 → px-3 py-2 so the footer
  utilities don't out-weigh the nav items above them.
- SidebarNavItem: nav descriptions go quiet at rest (opacity 0) and
  reveal on hover or active. Row height unchanged; calm at rest.

State management for the palette uses React Context (no new deps).
Hotkey listener lives in AppShell; trigger button is in AppTopBar.
Slot concept stays untouched in the data layer — the palette simply
doesn't surface it; Stage 6 removes the dead slot-driven code paths.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-29 17:12:48 +02:00
g-butandClaude Opus 4.7 997f1aa622 feat(autopilot): flip default auto_inject_mode to strategist
Cockpit's promise is autopilot — agents keep working when you're away.
The "queue_only" default introduced 2026-05-25 silenced the strategist on
day one, leaving new users in a non-autopilot product. Safety rails are
already in /api/control/dispatch (manual override, health gate, hard_stop,
queue priority) and the Stop hook respects them; the day-one risk that
prompted the flip no longer applies after /control became trustworthy in
6da8d7e + 7d7c40a.

Centralizes the default in DEFAULT_AUTO_INJECT_MODE (src/lib/constants/
control.ts) so the schema, queries, Settings UI, and Python/shell fallbacks
all source one constant. Adds an inline self-test (test:autopilot-defaults)
that pins every fallback to the autopilot value, wired into pre-push.

Existing users keep their explicit choice — only NEW rows get strategist.
The Drizzle migration is idempotent and reaffirms the column default.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-29 13:31:13 +02:00
g-but 6da8d7ea1e fix(control): clarify live agent runtime states 2026-05-28 14:37:07 +02:00
g-but 8be96443fc fix(control): sync daemon runtime source of truth 2026-05-28 07:38:21 +02:00
g-but 09f7bfb770 fix(control): make operations state race-safe 2026-05-27 21:52:33 +02:00
g-but 7c28ab15f8 refactor(control): create trustworthy agent operations workspace 2026-05-27 19:02:18 +02:00
g-but 4dd97e05b2 fix(control): label saved handoffs as historical 2026-05-27 10:56:28 +02:00
g-but b869bedd4c feat(control): make local agent runtime self-healing 2026-05-26 19:34:14 +02:00
g-but 31dd2690ef feat(control): Phase 0 polish - compact Live Zellij + Launch defaults with inline Install buttons, registry-driven models, functional New from picker, better offline language. Plus grok full parity in registry + daemon reflection paths.
This is the UI the user is asking to see live + the reflection fixes for direct terminal use (Cockpit tab showing correct agent).

Part of the approved zellij-control + terminal-reflection plan.
2026-05-26 18:03:41 +02:00
g-but 94d50da677 fix(agent): advertise hosted installer command 2026-05-26 13:26:21 +02:00
g-but f39b942148 fix(auth): allow OAuth accounts to set password 2026-05-26 13:11:03 +02:00
g-but 3e948b43e9 fix(control): report disconnected daemon truthfully 2026-05-26 12:38:50 +02:00
g-but 8f80b56b19 fix(orchestration): preserve LOOP v2 handoff signals 2026-05-26 10:38:51 +02:00
g-but f44016dfd2 feat(auth): hide Owner-key tab on cloud — ENABLE_OWNER_KEY=1 opt-in required
The /sign-in page has an "Owner key" tab driven by LOCAL_AUTH_PASSWORD.
That tab signs in via the "local" Credentials provider, which auths
against getDefaultUser() — meant for single-tenant installs (the
founder's local cockpit-app, where they're the default user). But
LOCAL_AUTH_PASSWORD is also set in Vercel prod for legacy reasons, so
the tab renders to every visitor on cockpitapp.vercel.app. Harmless
today (no is_default=true user on Neon prod, auth always rejects with
"user-not-found") but confusing for new customers and a brute-force
surface if someone later mistakenly marks a prod user is_default.

Add a structural ENABLE_OWNER_KEY=1 gate (defense in depth):

  • src/app/sign-in/page.tsx — UI tab only renders when both
    LOCAL_AUTH_PASSWORD set AND ENABLE_OWNER_KEY === "1". Cloud has
    the password but not the flag, so tab stays hidden.

  • src/auth.ts — "local" Credentials authorize() returns null with
    user-not-found if ENABLE_OWNER_KEY !== "1". UI gate alone wouldn't
    stop a direct POST to /api/auth/callback/credentials/local;
    runtime gate closes that path too.

  • .env.example — documents the new variable and the rationale
    (LOCAL_AUTH_PASSWORD alone no longer enables Owner-key tab).

Local cockpit-app's .env.local has been updated separately (not
committed; gitignored) to add ENABLE_OWNER_KEY=1, so the founder's
existing Owner-key login keeps working after the next rebuild.

Cloud impact: Owner-key tab disappears from /sign-in for every cloud
visitor. New customers see only Email and OAuth providers — cleaner
onboarding signal, no "what's an Owner key?" confusion.
2026-05-25 20:54:14 +02:00
g-but ae8a1a3cdf feat(agent): LOOP v2 handoff template — 9 fields, gravity signals first
Coordinated with the LOOP v2 deploy to ~/.config/agent-prompts.json
(out-of-git; backup at agent-prompts.json.bak-20260525-164621). The
prompt body and the handoff template ship atomically — buildPromptWith
Session() is the only emitter of the trailing handoff block per the
prompts-system.md SSOT rule "Never duplicate the handoff instruction in
the prompt body."

What changed in the 9-field template:

  • status: kept (functional — daemon dispatch gates on 'ready')
  • last-3-same-dir: NEW (gravity signal — LOOP v2 rule 5 fires on this)
  • wip-or-revert-in-last-5: NEW (thrashing signal)
  • tsc: NEW (replaces vague "health" composite)
  • lint: NEW (replaces vague "health" composite)
  • tests: kept (real signal, already worked)
  • todos: now explicitly auto-computed via `rg -c '(TODO|FIXME|HACK)' src/`
  • done: kept
  • next: changed — "state to resume from, NOT a verb. EMPTY if nothing
    mid-flight; empty > lie." Stops the agent writing "continue the
    sweep" when the sweep is done, which the previous session then
    obeyed as if real.
  • health: REMOVED — vanity field. "good" written reliably exactly when
    the loop was in trouble. Replaced by the six constituent signals
    above.

Gravity signals come FIRST in the template so the next session reads
them before any commit-summary narrative — can't be lulled by a tidy
story when the underlying state is repetitive.

Each new signal includes the exact shell command in a trailing comment
so the agent (any agent — Claude, Codex, Gemini) has the canonical
computation, no interpretation room.

This unlocks every LOOP v2 rule that references roadmap.md, blockers,
gravity, or recent-message scan — the prompt body deployed in the JSON
is now matched by a handoff that captures the data those rules need.
2026-05-25 16:49:01 +02:00