- ControlPanel shows a 6s "Command queued — local daemon will execute it for <tab>"
notice when inject returns mode=queued (cloud dispatch flow)
- inject() in use-control-data now returns { mode } so callers can branch on it
- Sign-in page hides GitHub button unless GITHUB_CLIENT_ID + GITHUB_CLIENT_SECRET
are both set — prevents confusing OAuth error for unconfigured deployments
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
NotesSection and DevLogSection each called useFetch for the same endpoint.
Now fetched once in ProjectProfile and passed as props. Also extends useFetch
to accept null URL (skips fetch when no ID available).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Eliminates the duplicate type Agent = "codex" | "claude" that violated
the single-source-of-truth principle.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds throwApiError(res, fallback) to lib/api/fetch.ts and migrates 19
instances of the inline res.json().catch(() => ({})) pattern across 14
components and hooks. Four un-migratable instances remain where the
response body is needed on the success path or state is set rather than thrown.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Double-inject (control panel + web beacon firing at same second):
- Add 1s grace period to beacon auto-fire. /api/inject already calls
cancelActiveBeaconSessions synchronously; the 1s gap + 500ms close-poll
gives the cancel time to propagate and close the beacon before it fires.
- Reduce beacon close-poll from 2s to 500ms so cancels are detected
within 500ms rather than up to 2s.
Queue wipe on reboot (/tmp cleared, localStorage persists):
- Queue API GET now returns { queue, exists } so callers can distinguish
"file not found" (exists=false) from "file is empty array" (exists=true).
- Poll skips overwrite when exists=false, preventing empty file result
from wiping a non-empty localStorage queue after reboot.
- Mount effect bootstraps the file from localStorage when file is absent,
so PyQt sees the queue on its next poll cycle after a reboot.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add /api/beacon/queue/[tab] GET/PUT — file bridge for cross-process
queue sync between PyQt and web app
- stateFile.queue() centralises /tmp/agent-queue-{tab} path
- Normalize tab to lowercase in route + _beacon_popups._queue_file()
so all three consumers (web beacon, control panel, PyQt) share one file
- remove() now syncs to file immediately from localStorage rather than
waiting for the React render → effect cycle; fixes queue item
reappearing on next beacon because page closed before PUT completed
- isComposing includes listening||processing so countdown pauses during
mic recording and Whisper transcription, not just when text is present
- Auto-fire effect also guards on listening||processing as a safety net
for edge case where countdown initialises at 0
- Status line shows "Recording — auto-continue paused" / "Transcribing…"
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
React state updater closures run during the next render phase, not at setState
call time. The prior shift() captured item = q[0] inside setQueue(fn) and
returned it, but item was always null — the updater hadn't run yet. Every queue
drain silently fell through to next_best.
Fix: read from localStorage (the synchronous SSOT), write the sliced array back,
then call setQueue to sync React state. Atomically returns the correct item.
Also extracts useMicComposer hook (H3 audit) to eliminate the duplicated
pendingMicActionRef + appendTranscript + wrapSend/wrapEnqueue boilerplate
that was copy-pasted between IntentButtonPanel and BeaconBody.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- sendIntent("next_best") and send() legacy path now drain queue first before
calling the AI planner — queued items always take priority
- enableAutoContinue() called on each new ready cycle so persisted "off" state
doesn't leave the countdown permanently paused across sessions
- Beacon auto-fire guarded on prompts.length === 0 (prevents closing before
prompts load); fires remove(0) when using queue item so it's drained atomically
- PromptInput: items-end outer flex + fixed h-10 buttons so Queue/Send don't
stretch as the textarea grows; Pause/Play removed from action button row
- Pause/Play relocated to a labeled footer row ("Auto-continue on/off") in both
running and idle states, consistent with beacon popup pattern
- RunningBanner: custom prompts shown as line-clamp-3 instead of "Custom prompt"
header + truncated 2-line fallback
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ProjectCard had the same SSR bug as usePromptQueue: the lazy useState
initializer ran on the server (window absent), returned false, and the
first client-side write effect then stored "off" — silently disabling
auto-continue every time the control panel page loaded.
Fix: new useAutoContinue(tab) hook uses the same initialized-flag pattern
as usePromptQueue so the stored setting persists across page loads.
Side effects:
- Eliminates triple duplication of the control:auto-continue:${tab} key
- Removes the 2s polling loop from the beacon popup (storage event is
sufficient since popup and control panel are separate windows)
- Removes toggleAutoContinue local function from beacon page (hook owns it)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
usePromptQueue started with a lazy useState initializer that called
window.localStorage. On the server (SSR), window is absent so the
catch block returned [], and the first client-side write effect then
persisted [] to localStorage — silently wiping any items queued in
a previous session.
Fix: start with [], hydrate from localStorage in a mount useEffect
(client-only), and gate the write effect behind an `initialized`
flag so the pre-hydration empty state is never persisted.
Also move the beacon window auto-fit effect from BeaconPage into
BeaconBody so queue.length is in scope — the window now re-sizes
when items are loaded from localStorage or added via the + button.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
usePromptQueue gains reorder() and edit() operations.
QueueList in control panel: up/down chevron buttons to move items;
click item text to edit inline (Enter to save, Escape to cancel).
Beacon popup queue: same reorder/edit pattern — double-click text to
edit, ↑/↓ to reorder, X to remove without sending, click text to
send-and-remove. All writes go directly to localStorage so control
panel reacts via the storage event listener added earlier.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
usePromptQueue now listens for storage events so the control panel
reacts instantly when the beacon popup modifies the queue.
Beacon popup queue now matches control panel QueueList style (numbered,
first item highlighted, X to remove). Clicking a queue item removes it
from localStorage before submitting — prevents double-fire on next
auto-inject.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
**Pause bug fix:**
- /api/beacon/cancel endpoint cancels active beacon sessions for a project
- Clicking pause in the control panel now calls this endpoint so the beacon
popup's independent 30s countdown can't fire after the user pauses
**Prompt queue:**
- usePromptQueue hook (localStorage-backed) for per-project queued prompts
- Queue button (ListPlus) in the prompt input + Alt+Enter keyboard shortcut
- QueueList shows numbered items with × removal in running and idle states
- ReadyBanner auto-inject drains the queue first, falls back to next_best
- ReadyBanner shows "Queue N" tag when items are waiting
**Session summary restored:**
- SessionSummary (up next / done) is now visible while agent is running
- RunningBanner clearly labels the active task; session.next below it shows
what comes after — no more confusion between current and upcoming work
**SSOT / DRY:**
- lib/session-content.ts: shared parseSessionText() for session file parsing
- beacon popup page, beacon [id] API route both use the shared parser
- useWhisperMic extended: exposes waveformBars + recordingSeconds
- beacon popup replaced ~150 lines of custom mic code with useWhisperMic hook
- ReadyBanner uses stable refs for onSend/onAutoInject to prevent re-injection
from unstable parent function references on every SSE render
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
use-speech-recognition.ts is now unreferenced — AskIvyModal was the
last consumer and was migrated to useWhisperMic in the previous commit.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- beacon.py stop mode now opens localhost:3000/beacon/<id> (Chrome --app mode)
instead of a PyQt6 window; PyQt6 confirm popup stays for sync blocking
- /api/beacon + /api/beacon/[id] routes create/poll/submit sessions via /tmp files
- /beacon/[id] page uses the same ui-btn-primary, ui-panel, ui-kicker components as
the rest of Cockpit — fonts, tokens, and layout are literally the same code
- Per-project agent+model prefs: modelPref column added to user_projects (pushed);
ProjectState now carries id/agentPref/modelPref; launch modal pre-fills saved
prefs and saves choice back after every launch; ProjectProfile agent selector
persists to DB immediately
- Default agent changed from codex to claude in agent-preferences + hook fallback
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Move ProjectState, SessionState, GitState, ProjectProfile, CurrentPrompt, ControlData
from app/api/control/route.ts into lib/control-types.ts — fixes circular dep
(lib/control-fast-state was importing types from an API route)
- Update all 10 import sites (components, hooks, lib) to use lib/control-types
- Add ProjectRow named type to db/queries/projects.ts; replace ReturnType<typeof getProjects>
- Session summary text: remove line-clamp on done (full text visible), add select-text
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Merge claude-config.ts into agent-config.ts (single SSOT for all state file paths,
project conf, sessions dir, and prompt file resolution)
- Delete claude-config.ts; all importers updated to use agent-config
- Add Gemini to agent registry with availability detection; update agent-catalog to
buildSwitchableAgentCatalog; add agent-preferences persistence
- Expand orchestration: add lifecycle state derivation, event persistence, and
shouldPersistLifecycleEvent guard in orchestration/state.ts
- Add thoughts-content.ts (SSOT for article metadata read from content/thoughts/)
- Add MOBILE_NAV_ITEMS export to navigation.ts; integrate into MobileNav
- AppShell: use useState lazy initializer for sidebar collapse (fixes react-hooks/set-state-in-effect)
- Sidebar: collapse to icon rail on smaller screens; AppShell shows user avatar + name
- Control: SSE stream for real-time fast-state updates; ReadyBanner auto-inject countdown
- Shell, prompts, settings, today, goals, events, people: styling and UX consistency pass
- Update error/loading/not-found to use design system tokens
- Package.json dependency updates
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the remaining 10 raw fetch() calls across 6 files with getJson/postJson/patchJson.
No more repeated { method, headers, body: JSON.stringify } boilerplate outside the SSOT helper.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Moves all data fetching, SSE subscription, and API callbacks into
src/hooks/use-control-data.ts. ControlPanel drops from 488 → 278 lines,
staying under the 300-line god-component limit.
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>
Six inline-edit toggles across two files all hand-rolled the same
state machine: editing/draft/saving + start/cancel/setSaving wrap.
Pull that into hooks/use-inline-edit.ts.
Migrated:
- ProjectInlineEditors.tsx: NameEditor, DescriptionEditor, StatusEditor,
MaturityEditor (4 editors, 221 → 200 lines)
- PersonDetail.tsx: name and description toggles (-30 lines of plumbing)
Each call site keeps its own validation/equality/transform — the hook
only owns the lifecycle. Net: -32 lines across the two files, and
adding a new inline editor anywhere is now ~3 calls of useInlineEdit.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The four "New X" buttons (Person, Project, Goal, Subscription) all
hand-rolled the same flow: setSaving(true), POST, decode { ok, error },
router.refresh(), surface a fallback "Failed to create <thing>". Pull
that into hooks/use-create-mutation.ts.
Each consumer now declares only its body type, the request fn (or a
typed lib helper like createGoal), and an errorLabel. The reset-fields
+ close logic stays per-component since the field shape varies.
Net: -20 lines across the four call sites, and adding a fifth "New X"
button is now a one-page implementation.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
SSOT:
- Centralize DEFAULT_USER_ID and DEFAULT_USER_NAME in lib/constants
- Extract CHANNEL_CONFIG to config/channels.ts (was duplicated in PersonCard + PersonDetail)
- Use DEFAULT_USER_NAME in greeting instead of hardcoded "George"
DRY:
- Extract shared Card, CardHeader, CardSkeleton, StatCard to components/ui/card
- Extract PageLayout to components/ui/page-layout
- Extract useFetch hook to hooks/use-fetch
- Refactor all 6 pages + 5 components to use shared primitives
Security:
- Escape LIKE wildcards in people search (prevent pattern injection)
- Validate UUID format on /api/people/[id] (prevent Postgres errors)
- Add input length + range validation on /api/people search params
- Fail fast with clear error if DATABASE_URL is unset
Error handling:
- Add global error.tsx boundary with retry button
- Add loading.tsx skeleton for route transitions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>