Hook changes:
- handle_notification now reads session health before picking which prompt
to auto-inject: health=needs attention|critical → unblock, else → next_best
- Log line and write_inject_state both carry the chosen key and health value
New prompts in agent-prompts.json:
- orient: context reload — reads git log, tsc, session; outputs brief;
no code changes. For resuming after breaks or context-limit compactions.
- unblock: stabilize before advancing — runs tsc + tests, fixes highest-
severity failure, stops when baseline is green. Never auto-injects on
healthy projects.
Thoughts article: "Prompts, Timing, and Orchestration: Where Agent Value
Actually Lives" — covers the decision tree, prompt taxonomy (auto-inject
candidates vs human-selected vs situational), queue-based injection
semantics, and what's still missing (velocity, time-of-day, multi-item
queue drain, inter-project coordination).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two structural gaps:
1. handle_notification didn't check the queue before injecting next_best.
If user dispatched a task from Control while Claude was running, the
notification path would ignore it and inject next_best instead. Now
mirrors handle_stop's slot-1 queue logic: dequeues and injects the
first item atomically, skipping next_best entirely when a task is waiting.
2. next_best prompt was underspecified for the "nothing urgent" case.
Added explicit priority order (type errors → uncommitted → session.next
→ discovery), expanded git log to -10, added tsc check as step 1, and
replaced the vague "highest-impact gap" directive with a concrete
discovery method: scan recent commits, find the adjacent broken thing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Articles had **bold**, *italic*, `code`, and [link](url) rendering as raw
markdown syntax. Added ri() inline-render helper that splits text on those
four patterns and maps each part to the appropriate React element. Applied
to paragraphs, list items, blockquote lines, and headings.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
continue prompt gave Claude zero context on what was in progress. next_best already
loads git state and prompts a context-aware resume; same rich session-file append
pattern as handle_stop. Also switches to emit_or_inject_prompt for AGENT_BRIDGE_EMIT_PROMPT
test compatibility and calls write_inject_state so Control panel reflects the injection.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The design refactor replaced className="flex flex-col max-h-[85vh]" with
className="ui-modal-scrollable". But ui-modal-scrollable included overflow-hidden,
which silently overrode the Modal panel's own overflow-y-auto — making all content
past the viewport clip with no scroll.
Fix:
- ui-modal-scrollable: drop flex-col + overflow-hidden; keep max-height + overflow-y-auto
so it is useful for simple whole-panel-scroll overrides
- RunModal, AskIvyModal: className="flex flex-col" — the panel's own max-h-[calc(100vh-2rem)]
already caps height; flex-col is all that's needed for sticky header/footer layout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Article covers model-agnostic dispatch vision: fallback chains, local models,
hardware layer, and why Cockpit sits above the model layer not inside any lab's
walled garden. 14 min read, tagged product/strategy/agents/dispatch/hardware.
Removes generateStaticParams + adds force-dynamic so new articles are live
immediately without a rebuild — page reads from the filesystem on each request.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- _beacon_config.py: add read_project_git_branch() (mirrors server-side parseProjectsConf logic)
- beacon.py: embed gitBranch in session JSON at write time so SSE/web consumers get it without a server-side lookup
- _beacon_popups.py: rewrite ContinuePopup header — green dot, project name, "Ready" badge, then chips row with agent chip + git branch chip; matches web beacon header exactly
- sse/route.ts: add git branch fallback enrichment for sessions written before this change
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- BeaconSession type: add optional gitBranch field
- beacon/[id]/page.tsx: server component enriches session with git branch
via parseProjectsConf() + execSync('git rev-parse --abbrev-ref HEAD')
so branch is available in the initial render with no client fetch
- BeaconClient.tsx: header now shows agent chip ("Claude ready") and
git branch chip with GitBranch icon, matching the Control panel card
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Kill the duplicate countdown / auto-fire / button rendering inside BeaconBody
and replace with the ReadyBanner component that the Control panel already uses.
Changes:
- ready-banner.tsx: widen prompts type to PromptItem (Pick of the display
fields) so both PromptMeta[] (card) and AgentPrompt[] (beacon) are accepted
without casting — export PromptItem for external use.
- BeaconClient.tsx: remove countdown useState + two useEffects + manual
primary/action/more button rendering; add ReadyBanner with onAutoInject
wired to the same choice-selection logic; add recentPrompts fetch + display;
update header subtitle to show agent name (was hardcoded "session complete").
- api/beacon/recent/route.ts: new GET ?project= endpoint that returns
RecentCustomPrompt[] via the same DB query the control panel uses —
lets the beacon popup show "Reuse recent prompts" identically.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The production standalone server runs outside Zellij (no ZELLIJ_SESSION_NAME),
so calling zellij action directly from the server process silently no-ops.
Two changes:
1. executor.ts: gate direct injection on both RUNTIME_AVAILABLE *and*
ZELLIJ_SESSION_NAME being present — falls through to queue otherwise.
2. inject/route.ts: run filesystem side-effects (beacon cancel, state files,
handshake clear) immediately in the route handler; they only need /tmp
access which the server always has. injectFn is now just the Zellij write.
Result: localhost production server always queues; daemon (which IS inside
Zellij) picks up and injects with correct session context. Dev server
launched from within a Zellij pane still injects directly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Four issues fixed:
- BeaconSession now carries countdownSeconds (read from settings file in both
the API route and beacon.py), so the web popup always shows the user-configured
value instead of a hardcoded fallback
- DEFAULT_BEACON_COUNTDOWN_S changed from 30 → 12 to match Python COUNTDOWN_SECONDS;
fallback is now consistent across all surfaces when no settings file exists
- BeaconClient uses session.countdownSeconds instead of AUTO_INJECT_S / URL param,
eliminating the split between readyAt-path (12s) and URL-param-path (30s)
- useAutoContinue default changed false → true so new tabs start with auto-continue
enabled, matching Python popup behaviour and isAutoContinueEnabledSync
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The injectFn closure uses dynamic imports (await import('@/lib/zellij')) but
executor called it without await — the Promise was discarded, imports never
resolved, and execSync never ran. Localhost injection silently returned ok:true
while doing nothing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Email/password users had no in-app way to change their password —
the only option was the forgot-password email flow. Adds:
- PATCH /api/me/password — verifies current password, rejects OAuth
accounts (no passwordHash), enforces 8-char minimum on new password
- updateUserPasswordHash() helper in users queries
- "Change password" subsection in ProfileSettings, shown only when
the account has a passwordHash; includes inline validation for
length and confirm-match before the request is sent
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All six components had try/finally without catch, so network errors
produced no user feedback and unhandled promise rejections. Each
mutation now catches and shows an inline error message or returns
false to its parent form. AddHabitButton and HabitsList.addHabit
now catch to return false instead of throwing into AddHabitForm.
HabitGoalLinks also handles !res.ok for link/unlink so API-level
failures surface instead of silently being ignored.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The edge runtime's regex engine doesn't reliably evaluate complex
lookahead patterns at compile time, causing /api/invitations/<token>
to return 401 instead of 404, blocking unauthenticated invitation
acceptance. Replace the regex test with pathname.startsWith which
is guaranteed to work in the edge runtime.
Smoke test /api/invitations/<token> now returns 404 (was 401).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CommitmentItem.save() had no catch so network errors propagated silently —
now surfaces "Network error — try again" in the form. FulfillCommitment,
AbandonGoal, and DismissAlert all called server actions with try/finally
but no catch, producing unhandled rejections; added silent catch since state
stays correct and the button correctly ungates for retry.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
commitTitle and commitDesc used ie.commit() but ignored the boolean return,
leaving users with no feedback when saves fail. Now shows a timed error below
the relevant field. toggleComplete, toggleAbandon, and all milestone operations
lacked catch blocks, creating unhandled promise rejections on API failures.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
onCancel() had no error handling — if the server action threw, setCancelling
stayed true forever with no recovery path. Added try/catch/finally, cancelError
state, Loader2 spinner on the Yes button, and error clearing on dialog re-open.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
commit() previously called setEditing(false) in finally, so any failed save
(network error or non-OK API response) silently closed the editor — user saw
the old value and couldn't tell whether the save succeeded or failed.
Now commit() closes only on success and returns a boolean. Callers stay in
edit mode on failure, preserving the draft so users can retry or cancel.
Updated HabitRow to check the boolean return instead of .catch().
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
If createCronJob threw (network error), setSaving was never called and the
button stayed in "Creating…" forever. If the API returned non-OK, the modal
still showed "Scheduled!" as if the job was created.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The toggle handler was optimistically setting streak ±1, but streak is
computed from consecutive history — it isn't simply current ± 1. More
critically, the error rollback only reset doneToday, leaving streak at
the wrong value permanently if the API call failed.
Removing the streak mutation fixes the rollback bug and eliminates the
inaccurate flash. The server-side value is already corrected immediately
by router.refresh() on success.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
agentRunning is derived independently from activeAgents (process CWD scan
vs. per-project agent ID array), so they can diverge when one agent stops
and another starts simultaneously. The control panel would show a stale
agent identity for the tick window until the next agentRunning transition.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PostgreSQL sorts booleans ascending (false < true), so the previous
orderBy(habits.active, ...) put inactive habits at the top. Inactive
habits are dimmed with opacity-50 — they should appear below active ones.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The money page fetched active subs and all subs separately — 2 DB
queries for data that's a strict subset. Now fetches getAllSubscriptions
once and filters active in memory. Removes getActiveSubscriptions from
the query layer entirely. Also drops dead getCurrentUserId() from
session.ts (deprecated, had zero callers).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Filesystem-based essays are site-wide content, not per-user writing.
On multi-user deployments, team member profiles incorrectly showed the
owner's essays as if they authored them. Gate on user.isDefault so
only the owner's profile renders the Writing section.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both functions fetched all habit_goals rows for the user, then filtered
in memory — wasting bandwidth proportional to total goal/habit count.
Now the WHERE clause includes an inArray on the relevant FK so only
matching rows travel the wire.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
generateMetadata and the page component both called getUserByUsername with
the same argument in the same request, firing two DB queries. Wrapping the
function with React cache() collapses them to one — no other changes.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
getOrgProjects and getOrgEntityProjects both ran the same two-step
sequential query to find org peer IDs: fetch the caller's orgIds, then
fetch peer userIds from those orgs. Extract this as getOrgPeerIds() in
utils.ts using a single self-join on org_memberships, and update both
callers. Reduces 3 sequential round-trips to 2 per call, and eliminates
the duplicated lookup logic.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Next.js 16 uses proxy.ts as the middleware file — creating middleware.ts caused
a startup conflict ("Both middleware file and proxy file detected"). Removed it.
The ^/...\$ regex anchor was also invalid for Next.js matchers (must start with /).
Reverted to original form. The authorized() belt-and-suspenders check added to
auth.config.ts in the prior commit is the definitive fix for invitation paths.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three related issues:
- proxy.ts rename broke production: Next.js requires middleware.ts; the build
manifest was empty meaning no middleware ran in production. New middleware.ts
re-exports from proxy.ts so logic stays in one place.
- Unanchored regex: /((?!...api/invitations/...).+) matched at substring
position 4 in /api/invitations/<token>, so Turbopack ran the middleware on
invitation routes despite the exclusion. Fixed with ^/...$ anchoring.
- Belt-and-suspenders: authorized() callback in auth.config.ts now explicitly
returns true for /api/invitations/<token> paths regardless of regex behavior.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
beacon-settings PATCH had no auth guard and the middleware regex (api/beacon) accidentally
excluded it as a prefix match. stripe/checkout had two identical auth checks (dead code).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
POST /api/agent/launch (starts AI agent processes in Zellij tabs) and
POST /api/orchestration/run/execute (runs OpenClaw against a project path)
were reachable by any valid bearer token without user verification,
completing the same bearer-passthrough gap fixed in the previous commit.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Six handlers that the middleware passes through for bearer-token
requests had no in-handler auth check, allowing any valid ck_* agent
token to call them regardless of the owning user:
POST /api/project/commit — commits to any git dir on the server
POST /api/ivy — calls OpenClaw on behalf of the server
POST /api/control/auto-continue — writes /tmp sentinel files
POST /api/control/focus-tab — switches Zellij tabs
POST /api/control/merge-prompts — calls Groq/OpenClaw
POST /api/control/dispatch — calls Groq
All now require getApiUserId() (accepts cookie session + daemon token
+ ck_* agent tokens), consistent with the rest of the fleet API.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
POST /api/crons, PATCH /api/crons, and POST /api/crons/run were
excluded from the auth middleware (so the daemon can GET job configs
without a session) but had no in-handler auth checks, leaving them
open to unauthenticated job creation, modification, and execution.
Uses getApiUserId() so daemon bearer tokens remain valid for these ops.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Org members see team-owner projects in the control fleet view but cannot
write to the owner's entity project or user-project rows (ownership-gated
APIs return 404). QuickProfileForm and RemoveSection were showing for
team projects with no profile, leading to confusing "Failed to save /
remove" errors when clicked.
Fix:
- Add readonly?: boolean to ProjectState type
- Set readonly: true for team-project entries in GET /api/control
- Gate QuickProfileForm behind !project.readonly
- Gate RemoveSection behind !project.readonly
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GET /api/projects/[id] is the most-called endpoint in the app — every
project drawer open hits it. The static smoke test had no coverage for
it because the ID is runtime-derived. Reuses the same jq+curl pattern
used for /api/people/<id>: fetches the first entity project ID from
/api/user-projects, then hits the detail route and verifies it returns
2xx (or 401 without a session).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a smoke route check for /api/invitations/<bogus-token> that must return
404, not 401. If it returns 401 it means the middleware exclusion (api/invitations/)
regressed and new users can no longer accept team invitations. The check fails
loudly on 401, passing only on the expected 404 for an invalid token.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Stripe's webhook POSTs carry no session cookie — the auth middleware was
returning 401 before the route handler's Stripe-Signature verification ran,
silently dropping all billing events (subscription created, cancelled, etc.).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
/api/invitations/[token] (validate) and /api/invitations/[token]/accept
were not excluded from the middleware, causing unauthenticated invitation
recipients to receive a 401 before the route handler ran. The trailing-slash
exclusion (api/invitations/) covers only token sub-routes; the root
GET/POST /api/invitations (list/create) stays protected.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extends the readonly gating from the previous commit to the Prompts tab:
org members can read linked autopilot jobs but cannot toggle them or create
new ones for a project they don't own.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Org members opening a team owner's project detail were silently getting 404
on every PATCH/DELETE because those routes are ownership-gated. Now the API
surfaces readonly=true when the viewer doesn't own the project, and every
edit control (name, description, status, maturity, attrs, add-attr, log-activity,
delete) is suppressed or rendered as non-interactive text for read-only views.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Previously, org project cards on /projects were non-clickable and "View Project"
in the prompts RunModal was suppressed because the detail API scoped by userId,
returning 404 for any project the viewer didn't own.
Added resolveProjectDetailWithOrgFallback() that verifies shared org membership
then fetches the detail under the owner's userId. The GET /api/projects/[id]
handler now falls back to this when the direct ownership check fails.
Cards and "View Project" are fully re-enabled. PATCH/DELETE still require
ownership and correctly return 404 for non-owned entities.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Team members saw an empty project dropdown in the RunModal when running
project-scoped prompt templates. Now fetches own + org entity projects in
parallel. Org projects are marked readonly so the 'View Project' button
(which would hang — detail API scopes by userId) is suppressed for them.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The applyToOpenTabs helper in /api/control/agent duplicated the raw
query-tab-names call that was fixed in getZellijTabs (9c6df29). Without
the fix, stale ZELLIJ_SESSION_NAME caused query-tab-names to emit session
list entries with ANSI codes, which never matched any project tab name —
silently marking all tabs as "skipped" when switching agent models.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Team members landing on /projects saw an empty page despite having org project
access in the control panel. Now fetches both own projects and org peers'
entity profiles in parallel. Org projects render with a 'team' kicker badge
and are read-only (no inline edit, no delete, no detail drawer).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>