Old message implied codex had no orchestration support. All switchable
agents now dispatch tasks via prompt injection. The real distinction is
session lifecycle signals (stop/ready hooks), which only claude supports.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
agentRunning was scanning /proc only for the configured switchable agent's
process matchers. Switching to codex meant Claude sessions were invisible —
projects showed as idle while Claude was actively running in their tabs.
Fix: union all registered agents' processMatchers before scanning /proc.
A project is agentRunning if any known agent (claude, codex, openclaw…)
has a process in that directory.
Also hardcodes orchestration capability flags to true since the banners
now gate on readyAt signals rather than agent capability.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
readyAt/closedAt/closingAt signals are written by lifecycle hooks (stop.sh)
independently of which agent is set as the switchable default. Gating the
banners on autonomousPromptLoop suppressed them whenever the user switched
to codex — even when Claude sessions had genuinely finished.
Fix: remove the supportsAutonomousLoop gate from isClosed/isClosing/isReady.
The signals are sufficient evidence. agentRunning=false (no matching process
found) plus readyAt set is the correct ready condition regardless of agent.
Also removes the now-stale "This backend does not support autonomous loop"
message — intent buttons dispatch to any agent, so the disclaimer was wrong.
Drops the unused orchestration prop from ProjectCard.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
New /thoughts route renders markdown-based long-form content from
content/thoughts/. Seed content covers the autonomous loop philosophy
and the next-best-step prompt pattern. ThoughtMeta parsed from YAML
frontmatter; reading time auto-calculated from word count.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the Claude-only prompt loop with a neutral orchestration layer
that dispatches tasks to whichever agent is available. When one brain
runs out of tokens, switching to another requires one tap.
New infrastructure:
- src/lib/orchestration/ — contract, 10 task intents, adapter definitions,
prompt renderer, OpenClaw runner, summary parser
- src/lib/agent-registry.ts — detects claude/codex/openclaw/gemini from
PATH; reads configured model from dotfiles
- src/lib/agent-preferences.ts — persists selected brain to
~/.config/cockpit-agent.json; syncs model back to Claude settings
- src/lib/agent-catalog.ts, agent-runtime.ts, switch-agent.ts — catalog,
zellij tab restart logic, agent switching action
- src/db/schema/orchestration-runs.ts + queries — DB-tracked runs
New API routes:
- /api/control/agent — GET brain config, POST to switch + restart zellij tabs
- /api/orchestration/run — brain-agnostic dispatch: claude/codex → inject
rendered prompt into zellij tab; openclaw → fires detached worker
- /api/orchestration/run/execute — synchronous execute endpoint for worker
Control panel UX:
- Brain section collapsed to a single pill, expanding only when needed
- Intent buttons replace hardcoded "OpenClaw" buttons — Next best, Test & fix,
Quality, Commit, +5 under More; each shows "via {adapter}"
- agentRunning detection uses /proc scan against configured agent matchers
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add paused prop to ReadyBanner — countdown stops when paused=true
- ProjectCard passes paused={customFocused || custom.trim().length > 0}
- Custom input gains onFocus/onBlur to track focus state
- Countdown display shows ⏸ when paused instead of remaining seconds
Prevents the "Claude finished" banner from auto-firing while the user
is composing a custom prompt in the input below.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- lib/api/fetch.ts: getJson<T>(url, options?) — typed GET that throws on !ok
- hooks/use-fetch.ts: use getJson internally (DRY, typed error handling)
- PersonDetail, ProjectDetail, ClaudeSession: replace fetch+ok+json chain
- PeopleGrid, LogConversationButton: replace fetch+json with typed getJson
No logic changes — only the boilerplate layer is removed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
New src/components/ui/modal-form.tsx owns the shared skeleton that all
four "New X" buttons repeated: green trigger button, Modal wrapper,
header (title + X close), error block, and primary submit button.
Uses <form onSubmit> so Enter in any <input> submits natively — removes
the per-field onKeyDown handlers that were previously copy-pasted.
NewPersonButton / NewProjectButton / NewGoalButton / NewSubscriptionButton
now contain only their unique field state and field JSX. Combined line
count: 507 → 453 (−54 lines), and any future modal button costs ~35 lines
instead of ~100.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add stateFile.{ready,closing,closed,sentinel,prompt,lock}(tab) helpers
to claude-config.ts as the single TypeScript source for /tmp state file
paths. Update inject and control routes to use them — eliminates raw
string interpolation scattered across two files.
Add a STATE FILE CONTRACT comment block documenting what each sentinel
means and which actor owns reads/writes — the bash dotfiles (stop.sh,
notification.sh) duplicate these names as string literals, so the
comment is the only shared spec.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- New src/lib/claude-config.ts: SSOT for all Claude local-config paths
and file-reading helpers (parseProjectsConf, readProjectsMap,
readPromptMeta, readPrompts, buildPromptWithSession, PromptMeta type)
- control/route.ts + inject/route.ts: import from shared lib; removes
~50 lines of duplicated constants and functions
- route-helpers.ts: add handleDuplicateEntityNameError() helper
- people/route.ts + projects/route.ts: use the shared helper instead
of inline uq_entities_user_name_type string comparison
Also fixes notification.sh: skip auto-inject when close_session is in
flight (sentinel or closing marker present) — prevents a new prompt
firing immediately after a session closes.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Shows all open Zellij tabs as a strip at the top of the control panel
(project-matched tabs brighter, unknown tabs dimmer). Adds a Terminal
icon in each project card header when its tab is currently open.
Wires zellijTabs through the ControlData type to the GET response.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cache strategy:
- git state + DB profiles: 20s stale-while-revalidate (background refresh)
- Claude CWD detection: 3s TTL, reads /proc directly (no fork at all)
- Session files + tmp files: always fresh (cheap fs reads)
No more pgrep fork() on every request — replaced with direct /proc scan
(readdirSync + readFileSync per PID). Zero fork() calls on warm cache.
Result: cold=2s (first call or after 20s), warm=50–200ms (application-code).
Also: recent commits (last 4) shown per project card in the control panel.
Each row: "hash date: subject" from git log -5, joined with ~.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
API (/api/control):
- ProjectState gains closingAt, currentPrompt, profile fields
- profile pulled from DB entities (fuzzy tab→name match): description,
status, maturity, stack, mission, url + all attrs
- currentPrompt: reads /tmp/claude-current-prompt-<tab> set by inject
- closingAt: set when close_session injected; closedAt: set only after
Claude actually finishes (stop.sh writes it, not inject)
API (/api/inject):
- Writes claude-current-prompt-<tab> on every injection
- For close_session: writes closing file (not closed) — closed deferred to stop.sh
- Reads prompt meta to include icon+label in current prompt tracking
UI (ControlPanel):
- ClosingBanner: amber spinner "Closing session…" while prompt runs
- RunningBanner: indigo pill showing current prompt label + elapsed time
- ProfilePanel: collapsible — description, mission, maturity bar (10-dot),
stack, status, url, customers, architecture, owner
- MaturityBar: visual 10-dot progress indicator
- Status bar: running/waiting counts + total today's commits across all projects
- Sort: closed > ready > running > active (today commits) > idle
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fork() in the large Next.js process blocks the event loop for ~800ms each.
4 exec() calls × 19 repos = 76 sequential forks = 60s total.
Fix: one bash invocation with background jobs (&/wait) runs all repo git
queries in parallel. 2 total forks (bash + pgrep) instead of 76+.
Also fixes shell-injection bug: --format=%ar|%s was split by sh as a pipe,
making git log silently return null for all projects.
Result: /api/control drops from ~60s to ~2s application-code time.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add Page Visibility API + useRef in-flight guard to ControlPanel:
- Skips polls while the browser tab is in the background
- Skips a new poll if a request is already in progress
- Re-polls immediately when the tab becomes visible again
Prevents the server backlog that accumulated when the browser kept
sending new requests every 10s while the event loop was blocked.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace 76 sequential execSync calls (19 projects × 4 git commands)
with Promise.all — all projects and the pgrep check now run in parallel.
Event loop no longer blocks on each request; response time drops from
~40s to ~2s.
Also: add /control and /api/control to smoke.sh route lists; bump
reachability probe timeout from 5s to 20s for dev-mode compilation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- GET /api/control: reads claude-projects.conf, session files, git state,
claude process CWDs, ready/closed tmp files → returns ProjectState[]
- POST /api/inject: validates tab, builds prompt with session context,
shells to zellij; clears ready file; writes sentinel+closed when close_session
- /control page: polls every 10s, shows all projects with session state,
prompt buttons, custom input, ready-countdown banner, and close_session
celebration banner (no auto-countdown, shows shipped/next/tests)
- stop.sh: writes claude-ready-<TAB> on exit; writes sentinel+closed files
when close_session is chosen from popup (infrastructure-side, not LLM)
- close_session prompt simplified: infrastructure now handles sentinel
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Same pattern as PersonDetail: NameEditor now manages saving/error state
locally instead of delegating to useInlineEdit.commit (which always exits
edit mode in finally, swallowing API errors).
saveName in ProjectDetailHeader now throws on non-ok response so the
editor can catch and display the message (e.g. "A project with that name
already exists"). Also removes onBlur auto-save which prevented clicking
Cancel when an error was shown.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
useInlineEdit.commit always calls setEditing(false) in finally, so a 409
(duplicate name) or any other API error was silently swallowed — the drawer
closed edit mode and showed the old value with no feedback.
Replace nameEdit.commit / descEdit.commit with local saving+error state.
The hook still manages editing/draft/start/cancel; the async work now runs
directly so errors can be displayed inline and edit mode stays open until
the user either fixes the input or cancels.
Also removed onBlur=commitName which would re-submit on click-away, making
it impossible to click Cancel when an error was shown.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Bug fixes:
- events/[id] PATCH: return 404 when record not found instead of
{ ok: true, event: undefined } — EventCard uses json.event directly
so undefined would corrupt client state on stale IDs
- commitments/[id] PATCH: same guard for consistency
Feature:
- SubscriptionActions edit form now includes frequency (select) and
nextDue (date) fields; both are sent in the PATCH and the API+schema
already handled them — only the UI was missing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- AddHabitForm/AddCommitmentButton: lift trigger text from text-white/20-25
to text-white/35-40 so "Add habit" / "Add commitment" links are visible
without hover
- PersonCard Log button: sm:opacity-0 → sm:opacity-50 so the CRM's primary
action is dimly visible on desktop instead of completely hidden until hover
- CommitmentsCard: replace flat "No active commitments" text with centered
icon + sub-hint pointing to the add button below
- PeopleGrid: add proper empty state with Users icon; filtered-empty shows
a "Clear filters" inline link to restore results
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1. Typography: bump text-[9px]/text-[10px] category/date labels to
text-[11px] in EventsDueCard; lift "Open Events/Goals →" link opacity
from text-white/25 to text-white/40 so they're visible without hover.
2. Click targets: p-1 → p-1.5 on all icon-only action buttons
(EventCard, CommitmentItem, FulfillCommitmentButton, HabitRow pencil/X);
add p-1 + rounded to the bare habit-toggle button so tap target is ~26px.
3. Truncated text: add title= to truncated person name, profession/location,
and goal title so hover reveals the full string.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Events were previously immutable after creation — only archive and delete
were available. PatchEventBody now accepts all editable fields; the API
route spreads them into the DB update; EventCard gains an edit mode
(pencil icon → form → Save/Cancel) that optimistically updates local state.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Exports CreateProjectInput and CreatePersonInput (z.infer<>) from their
canonical query files and replaces the inline anonymous generics in each
button component. All useCreateMutation<T> calls now use named types.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
NewSubscriptionButton was missing the 'notes' field — users could set notes via
the inline edit (SubscriptionActions) but not at creation time.
Simultaneously cleans up the last inline body type definitions in components:
- AddCommitmentButton: import type CreateCommitmentInput from db/queries/today
- NewSubscriptionButton: import type CreateSubscriptionInput from db/queries/money
- lib/api/goals: use CreateGoalInput (import type from db/queries/goals)
All three query files export z.infer<> type aliases as the canonical types.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- pendingDrafts pill now links to /today (where ActionQueueCard lives)
- overdueCommitments pill now links to /today (where CommitmentsCard lives)
- urgentAlerts pill now links to /system
- Extract DEFAULT_TIMEZONE="Europe/Zurich" to lib/constants.ts; use it in
crons route instead of hardcoded string
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lib/api/crons.ts had CreateCronJobBody/PatchCronJobBody interfaces that were
missing model, timeoutSeconds, and tz fields present in the canonical Zod schemas.
Now exports z.infer<> types from lib/crons.ts via import type (erased at build
time, no risk of bundling fs code into client bundles).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces hardcoded "30+ days" string with the HEALTH_ACTIVE_DAYS constant
so the threshold stays consistent with the rest of the codebase.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The interface duplicated the Zod schema in db/queries/goals.ts.
Inline the type in createGoal's parameter; let TS infer the generic
in useCreateMutation from the request function signature.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Completes the schema sweep — all inline Zod schemas in route files that
have a corresponding db/queries/ file now live there instead.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Memory (knowledge graph telemetry) was occupying a sidebar nav slot but
isn't daily user content — it's infrastructure stats. Removed the Memory
nav item and embedded a compact MemorySummaryCard (entities, relations,
type breakdown) at the bottom of System, with a "View details →" link to
the full /memory page which is preserved for direct access.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
"Approve" and "Reject" implied a review workflow. The actual meaning is
"I did this / mark complete" and "skip this action". Done/Skip is clearer
especially for check-in prompts where users aren't approving a draft —
they're just logging whether they reached out. Compact tooltips updated too.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Goals, goal-due-soon, and events-deadline pills were static divs with no
navigation affordance. Wired them to /goals and /events respectively.
Drafts/overdue/alerts intentionally left static — they point to cards
already visible on the Today page, so linking would be a no-op reload.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The /habits page empty state said "Add habits from the Today page" with no
link and no form — a dead end. Added AddHabitButton (thin client wrapper
around AddHabitForm) and wired it into both the empty state and the bottom
of the habits list, so habits can be created from the dedicated page.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The button was text-white/25 — nearly invisible against the dark background.
This is the primary daily action that feeds the entire contact-health loop
(stale alerts, action queue, relationship scores). Made it a pill with
subtle bg/border at white/55 so it reads as clickable without competing
with the page header.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- CommitmentItem: truncate → line-clamp-2 so commitment text wraps instead
of being silently cut off mid-sentence
- ActionQueueCard: bump grouped check-in body preview from white/30 to
white/50 and switch to line-clamp-2 for multi-line visibility
- EventsDueCard: event.type label white/25 → white/40 to meet minimum
contrast for secondary labels
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Goals: CreateGoalBody added to db/queries/goals.ts alongside MilestoneSchema —
route now imports from there, removing the inline z.object.
Events: CreateEventBody + PatchEventBody (with EVENT_STATUSES cast) added to
db/queries/events.ts — both route files slimmed to just the import.
Also: session panel now renders the todos field (in amber) when non-zero, so open
TODOs are visible from the project overview drawer.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds GET /api/sessions?project=<name> which reads ~/.claude/sessions/<name>.md
(case-insensitive, dash-tolerant match) and parses done/next/tests/todos/health.
ClaudeSession component in ProjectOverviewTab fetches this on mount and renders a
compact status panel — visible for Cockpit, OrangeCat, kivvi, and any other project
that has an active session file. Projects without a session file render nothing.
Also fixes a DRY violation in SubscriptionActions where the delete-record handler
was duplicated verbatim as an inline arrow function in the permanent DeleteButton.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CURRENCIES_ENUM and FREQUENCIES_ENUM casts were byte-identical in both
/api/subscriptions/route.ts and /api/subscriptions/[id]/route.ts —
same pattern as habits FREQUENCIES fixed in 597c356.
CreateSubscriptionBody and PatchSubscriptionBody (which consume those
casts plus a SUB_STATUSES tuple) now export from db/queries/money.ts
next to cancelSubscription and calculateMonthlyBurn. Both route files
drop z import, both enum cast locals, and the full schema bodies.
money.ts gains one z import in exchange for being the single place
where subscription field validation lives.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three SSOT violations fixed:
1. habits routes: FREQUENCIES cast tuple was byte-identical in both
/api/habits/route.ts and /api/habits/[id]/route.ts.
CreateHabitBody + PatchHabitBody now export from db/queries/habits.ts
next to createHabit/updateHabit. Both routes drop z import + cast.
2. goals route: MilestoneSchema was inline in /api/goals/[id]/route.ts,
mirroring the Milestone TS type in db/schema/goals.ts.
MilestoneSchema now exports from db/queries/goals.ts where
GoalWithChildren already imports Milestone from the schema.
3. ProjectGrid: attr-key exclusion list ["production_url","url","repo",
"github_repo","owner","description"] was a partial duplicate of RESERVED
from project-detail-types.ts (which already covers all reserved keys).
Replaced inline array with the imported RESERVED constant.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Same shape as the just-shipped CreateInteractionBody extraction
(6472ee9). The attrs routes' runtime was deduped in 2e1859b
(upsertEntityAttribute / deleteEntityAttribute helpers) but the two
zod schemas — SetAttrBody (key+value) and DeleteAttrBody (key) — were
left inline and byte-identical across both /api/<entity>/[id]/attrs
routes.
Both schemas now export from db/queries/utils.ts next to the helpers
that consume them. Each route shrinks ~3 lines and drops the z import
entirely. Net: -3/+9 (only +9 because the new shared definitions are
counted once instead of twice).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>