Commit Graph
28 Commits
Author SHA1 Message Date
g-butandClaude Sonnet 4.6 564bf05d45 feat(ux): queued-mode feedback + hide GitHub button when OAuth not configured
- 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>
2026-05-14 15:46:36 +02:00
g-butandClaude Sonnet 4.6 0795e3d851 chore: commit accumulated session work across control, orchestration, and schema
- Control panel: ProjectTile, control-presenter, project-card-helpers,
  project-composer, project-intent-panel, control-panel-helpers updates
- Orchestration: run route hardening, adapters, contract, state refinements
- Schema: orchestration-events, orchestration-runs, project-states,
  prompt-history, user-projects additive field updates
- Queries: orchestration-runs, project-states, prompt-history, user-projects
  extended query support
- Agents: agent-catalog, agent-config, agent-preferences, agent-registry
  updates including Gemini runner script
- Beacon: route and PyQt popup/bridge script updates
- System: AutopilotCard and JobDetail minor updates
- Shared: DevLogList, SessionHandoff, project-activity-ledger
- Hooks: use-control-data, use-project-lifecycle-sync
- Config: prompt-library additions, session-handoff-copy
- Lib: control-fast-state, control-types, crons, crons-shared,
  orchestration state refinements

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 14:09:48 +02:00
g-butandClaude Sonnet 4.6 8515bc28ca fix(perf): lift UserProject fetch in ProjectProfile — eliminate duplicate HTTP request
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>
2026-05-11 16:00:33 +02:00
g-butandClaude Sonnet 4.6 df8e2b2a40 fix(ssot): import Agent type from agent-registry instead of redefining
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>
2026-05-11 15:06:17 +02:00
g-butandClaude Sonnet 4.6 91374b42cf fix(dead-code): remove unused LaunchAgentOption from use-control-data
Zero external callers; the type was never imported by any component.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 15:03:11 +02:00
g-butandClaude Sonnet 4.6 f11d4b7a44 refactor(api): extract throwApiError to eliminate duplicated error-extraction pattern
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>
2026-05-09 21:12:43 +02:00
g-butandClaude Sonnet 4.6 c7abed75a5 fix(beacon): eliminate double-inject race + queue wipe on reboot
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>
2026-05-09 11:38:25 +02:00
g-butandClaude Sonnet 4.6 09a1f29e57 fix(queue): file-bridge API, casing SSOT, remove() race, mic pause
- 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>
2026-05-09 11:27:50 +02:00
g-butandClaude Sonnet 4.6 a80a4ef12d fix(queue): shiftQueue always returned null — read from localStorage synchronously
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>
2026-05-09 08:32:50 +02:00
g-butandClaude Sonnet 4.6 cb576d6b42 fix(control): queue-aware next_best, better prompt UI, and auto-continue UX fixes
- 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>
2026-05-09 08:17:41 +02:00
g-butandClaude Sonnet 4.6 e389067016 refactor(control+beacon): SSOT fixes, hydration fix, queue UX, x.ai design
- Extract useLocalStorageState generic hook (SSR-safe, ping-pong fix)
- Extract control-storage.ts: localStorage key construction + sync read
- Add CUSTOM_CHOICE_PREFIX constant shared across TS, Python, bash
- Add DEFAULT_BEACON_COUNTDOWN_S constant (was hardcoded 30/12)
- Add splitSessionItems export; parseSessionText uses it (M3)
- Import BeaconSession+AgentPrompt from API routes, drop local defs (H2)
- Fix AppShell hydration mismatch: defer localStorage read to useEffect
- ReadyBanner: pipeline preview line + countdown reset on queue arrival
- QueueList: flat terminal-style dividers; drag-to-reorder; click-to-edit
- "Agent's plan" label replaces "Up Next" across all surfaces (H7)
- x.ai design: reduced border radii, monospace timers, tighter layout
- Add AI queue merge via /api/control/merge-prompts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-09 00:34:46 +02:00
g-butandClaude Sonnet 4.6 767241b2bb refactor(control): extract useAutoContinue hook + fix SSR wipe
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>
2026-05-08 22:17:39 +02:00
g-butandClaude Sonnet 4.6 bbfdab4757 fix(queue): prevent SSR from clearing localStorage on page load
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>
2026-05-08 22:04:26 +02:00
g-butandClaude Sonnet 4.6 616c7ed360 feat(queue): reorder (↑/↓) and inline edit in both control panel and beacon popup
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>
2026-05-08 20:46:08 +02:00
g-butandClaude Sonnet 4.6 34fe0e3e47 fix(queue): cross-window sync + beacon remove button + send-removes-item
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>
2026-05-08 20:34:58 +02:00
g-butandClaude Sonnet 4.6 f98eacfde4 fix(control): pause cancels beacon popup; add prompt queue; restore session summary; SSOT
**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>
2026-05-08 19:02:04 +02:00
g-butandClaude Sonnet 4.6 0ec334859e chore: delete dead Web Speech API hook
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>
2026-05-08 18:12:06 +02:00
g-butandClaude Sonnet 4.6 78780e7414 feat(mic): replace Web Speech API with Whisper in control panel; harden beacon popup mic
- Add useWhisperMic hook — MediaRecorder → /api/beacon/transcribe (local Whisper)
  replaces useSpeechRecognition in project-card-sections; always available, no Google
- PromptInput: processing spinner, error display below input, waveform placeholder text
- beacon.py WhisperThread: emit failed() on silence/empty/no-frames instead of silently
  resetting; add level pyqtSignal for real-time peak tracking; rec_tick shows ▮▯ meter
- beacon page: peakRef tracks amplitude via AnalyserNode; flat-waveform warning after 2s;
  amplitude guard before sending to Whisper; actionable permission-denied messages
- Thoughts post: anatomy of broken injection pipeline (18-min deep-dive)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 17:33:00 +02:00
g-butandClaude Sonnet 4.6 50025a1cbd feat(beacon): replace PyQt6 popup with Cockpit web page for true design SSOT
- 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>
2026-05-08 08:21:24 +02:00
g-butandClaude Sonnet 4.6 43357a14b5 refactor(arch): extract control domain types to lib/control-types, add ProjectRow/select-text fixes
- 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>
2026-05-07 19:23:43 +02:00
g-butandClaude Sonnet 4.6 e90b5e323f refactor(core): consolidate agent-config SSOT, add Gemini/multi-agent support, expand shell
- 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>
2026-05-07 16:21:10 +02:00
g-butandClaude Sonnet 4.6 e9f5d8d24b refactor: eliminate all raw fetch() calls — route everything through lib/api/fetch helpers
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>
2026-05-04 06:34:49 +02:00
g-butandClaude Sonnet 4.6 43dc962d28 refactor: split ProjectOverviewTab and AskIvyModal below 300-line limit
- Move ClaudeSession into project-overview-helpers (ProjectOverviewTab: 322 → 258)
- Extract useSpeechRecognition into src/hooks/use-speech-recognition.ts
- Extract useElapsedTimer + QUICK_PROMPTS into ask-ivy-helpers.ts
  (AskIvyModal: 317 → 226)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 05:25:08 +02:00
g-butandClaude Sonnet 4.6 096fd6e3c8 refactor(control): extract useControlData hook from ControlPanel
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>
2026-05-04 05:21:04 +02:00
g-butandClaude Sonnet 4.6 f70e8fa716 refactor(soc): add getJson<T> — eliminate raw fetch() in components
- 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>
2026-04-27 22:45:59 +02:00
g-butandClaude Opus 4.7 41fa885ce6 refactor(hooks): extract useInlineEdit, collapse 6 inline editors
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>
2026-04-25 17:31:37 +02:00
g-butandClaude Opus 4.7 f78be4de0f refactor(hooks): extract useCreateMutation, drop the four-fold copy
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>
2026-04-25 17:19:14 +02:00
g-butandClaude Opus 4.6 7d123e9e37 refactor: fix SSOT, DRY, security, and error handling
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>
2026-04-04 23:56:00 +02:00