Commit Graph
1545 Commits
Author SHA1 Message Date
g-butandClaude Sonnet 4.6 7ab1d77556 fix(lint): remove unused secondsAgo and MaturityBar imports from ProjectCard
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 04:43:52 +02:00
g-butandClaude Sonnet 4.6 71cdcd0698 refactor(control): extract ProjectCard helper components to separate file
ProjectCard.tsx was 809 lines (god component per CLAUDE.md >300 rule).
The 8 self-contained presentational helpers — SessionBadge, MaturityBar,
ClosedBanner, ClosingBanner, RunningBanner, ReadyBanner,
LatestOrchestrationPanel, ProfilePanel — are moved to
project-card-helpers.tsx (298 lines). ProjectCard.tsx is now 524 lines
containing only the main interactive component logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 04:42:47 +02:00
g-butandClaude Sonnet 4.6 2ce5bd0999 fix(lint): remove unused ORCHESTRATION_INTENTS import from control-intents
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 04:31:07 +02:00
g-butandClaude Sonnet 4.6 b1618ca851 refactor(ssot): APP_LOCALE constant, delete dead thoughts config, trim dead export
- Add APP_LOCALE to lib/constants.ts (env: COCKPIT_LOCALE, default: de-CH)
- Replace 3 hardcoded locale strings ("de-CH"/"en-CH") with APP_LOCALE in
  CalendarCard, PersonInteractionsSection, and Greeting
- Delete config/thoughts.ts (95 lines, never imported — app uses
  lib/thoughts-content.ts which reads from content/thoughts/ markdown files)
- Remove unused getIntentLabel export from config/control-intents.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 04:30:05 +02:00
g-butandClaude Sonnet 4.6 ed0d54c619 fix(build): merge middleware into proxy.ts, delete duplicate middleware.ts
Next.js 16 renamed middleware.ts to proxy.ts. Having both files caused a
build error. Merged the complete auth logic (public paths, invite bypass,
API pass-through, onboarding redirect) into proxy.ts and deleted the
redundant middleware.ts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 04:22:09 +02:00
g-butandClaude Sonnet 4.6 d3c64e1a03 fix(multi-user): greeting name, project-states isolation, session type
- Greeting now shows the logged-in user's name (via getCurrentUserName())
  instead of the hardcoded DEFAULT_USER_NAME constant
- getAllProjectStates() replaced with getProjectStatesByUserId(userId) so
  the control panel only surfaces project states owned by the current user
  (or legacy rows with null userId for backward compat)
- auth.ts Session type uses explicit fields instead of Omit<DefaultSession>
  which was collapsing to {} under TypeScript's union distribution
- session.ts: add getCurrentUserName() helper

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 04:17:50 +02:00
g-butandClaude Sonnet 4.6 5be833f95b fix(best-practices): userId in inject upsert + readCurrentPrompt type guard
- /api/inject: pass userId to upsertProjectState so project-state rows are
  scoped to the authenticated user (matches the rest of the multi-user migration)
- control-fast-state: validate JSON shape in readCurrentPrompt() before casting
  to CurrentPrompt — malformed /tmp files no longer silently produce undefined fields

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 04:11:22 +02:00
g-butandClaude Sonnet 4.6 d5dd002949 fix(multi-user): complete DEFAULT_USER_ID migration across all query files
Every DB query now scopes data to the authenticated user via userId param
sourced from getCurrentUserId(). Invited team members no longer see the
owner's data. Affected: people, projects, memory, utils, orchestration-runs,
prompt-history, events, habits, money, alerts, actions, today.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 04:02:58 +02:00
g-butandClaude Sonnet 4.6 24a7bdc26a fix(ux+multi-user): nav copy SSOT + multi-tenancy read path + mission
Navigation:
- Add description field to NavItem type (navigation.ts is now SSOT)
- Write real per-item descriptions for all 12 nav items
  - Control: "Dispatch agents across projects" (was "Brain switching")
  - 9 generic items: specific descriptions (was "Tracked view" x9)
- Sidebar reads item.description instead of hardcoded ternary
- Control page subtitle: "Dispatch AI agents across your projects — pick an intent and fire"
  (was "Switch brains, models, and terminal sessions")

Multi-user read path fix:
- today.ts: all 5 functions now accept userId param (was DEFAULT_USER_ID)
- goals.ts: getGoals/getGoalStats now accept userId param
- goals/page.tsx, prompts/page.tsx: call getCurrentUserId()
- CommitmentsCard, GoalsDueCard, SubscriptionsCard, SummaryBar: call getCurrentUserId()
- actions.ts fulfillCommitment: call getCurrentUserId() in server action

CLAUDE.md:
- Add Mission section (2-sentence product definition)
- Add control/ to Architecture component list
- Add /control, /thoughts, /settings to Views table
- Update /control description to match actual fleet command feature

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 03:32:14 +02:00
g-butandClaude Sonnet 4.6 cc3b763d6d feat(cockpit): multi-dev invites, launch button, git sync guard, context clear
- Invitation system: token-based /invite/[token] registration page, TeamSettings
  component in /settings, DB schema + queries, full API (create/list/accept)
- Create & Launch: "New project" modal in ControlPanel, ensureTabExists() in
  agent-runtime so zellij tab is created if not open, Play button on idle tiles
- Git sync guard: behindRemote field in GitState (git rev-list HEAD..@{u}),
  "↓ N behind" warning badge + git pull button + /api/project/sync route
- Clear context: /api/project/clear-context sends /clear to Claude without
  writing prompt state; "Clear context" button in ProjectCard More section,
  only shown when currentAdapter === "claude"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 02:36:04 +02:00
g-butandClaude Sonnet 4.6 70d1d6def4 feat(packaging): self-hosted distribution foundation
First-run flow:
- /setup page + /api/setup: creates first user with hashed password
  (Node crypto scrypt, no new deps). POST rejects if users already exist.
- Landing page redirects to /setup when DB has no users
- middleware.ts: protects app routes, passes public pages through

Auth:
- passwordHash column added to users schema (drizzle-kit push applied)
- src/lib/password.ts: hashPassword/verifyPassword via Node scrypt
- auth.ts Credentials: env var takes priority, falls back to DB hash
  so packaged installs work without LOCAL_AUTH_PASSWORD

Multi-tenancy groundwork:
- Replaced DEFAULT_USER_ID with getCurrentUserId() across all 12 API
  route files (people, subscriptions, events, goals, projects, commitments)

Docker:
- Dockerfile: multi-stage Node 22 alpine, standalone output
- docker-compose.yml: postgres + migrate + app services
- .dockerignore, .env.example with documented required vars
- next.config.ts: output: standalone
- package.json: added migrate script (drizzle-kit push)
- tsconfig.json: scope to src/ only, exclude .next generated files

Install: clone → cp .env.example .env.local → docker-compose up
First visit → /setup → create account → sign in → done.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-03 13:46:07 +02:00
g-butandClaude Sonnet 4.6 3d315235a6 redesign(landing+signin): dramatic visual uplift + local auth
- Landing: 52–108px clamp headline, multi-layer glows, grid fade mask,
  3-col feature cards, stronger grid (0.055 opacity vs 0.035 before)
- Sign-in: matching dark bg, 36–48px headline, polished glass card,
  labeled inputs, focus border transitions
- globals.css: base font 15px→16px, headings font-weight 600→700,
  ui-page-title 3xl→4xl/5xl, ui-page-subtitle text-base→text-lg
- auth.ts: Credentials provider (local) for LOCAL_AUTH_PASSWORD,
  JWT strategy (required alongside DB adapter), jwt()+session() callbacks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-03 12:07:30 +02:00
g-butandClaude Sonnet 4.6 e0e9c7f538 redesign(landing): x.ai-inspired dark hero page
- Deep near-black background (#080808) with subtle 72px grid overlay
- Radial center glow adds depth without color
- 80px bold headline at lg, tight -3% tracking
- Reduced text/CTA to essentials — no feature card grid
- Proof line at bottom: "Built on Claude · Runs on your machine"
- Rounded-full CTAs: white primary, ghost outline secondary

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-03 10:58:19 +02:00
g-butandClaude Sonnet 4.6 5eb0c82451 feat(control): fleet grid view — idle projects collapse to compact tiles
Active projects (agent running, recent ready/closed/closing signal, or current
prompt) show as full ProjectCards. Idle projects compress to a 3-column tile
grid with name, health, git branch, and session.next preview.

- ProjectTile.tsx: new compact tile with spinner for running, health dot,
  branch, and session.next truncated to one line
- ControlPanel: isActiveProject() helper (5-min window), expandedTabs state
  to promote tiles back to full cards on click, collapsible idle section

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-03 09:52:39 +02:00
g-butandClaude Sonnet 4.6 04ac6fd9a9 refactor: design tokens, route group, orchestration SSOT cleanup
Design system:
- globals.css: add status color tokens (status-positive/warning/negative)
- constants/control.ts: replace hardcoded color classes with semantic tokens
- Components: replace hardcoded colors (emerald-400, amber-400, red-400) with
  status-positive/warning/negative tokens throughout

Route structure:
- Move all app pages into (app)/ route group alongside shared layout
- Remove flat src/app/ page files (moved to src/app/(app)/)

Orchestration SSOT:
- contract.ts: convert AdapterId and OrchestrationTaskIntentId from string union
  types to const arrays so z.enum() can use them as runtime values
- run/route.ts: remove hardcoded intent/adapter enum lists; import from contract
- run/route.ts: use getCurrentUserId() instead of DEFAULT_USER_ID

Misc:
- control/route.ts: remove unused fs import
- Sessions API: minor cleanup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-03 05:28:33 +02:00
g-butandClaude Sonnet 4.6 d9c1a875d8 feat(control): SSE real-time stream, activity log, UI polish, schema indexes
Control panel:
- Add SSE endpoint (/api/control/stream) pushing agent state diffs every 2s
- Extract shared fast-state reader to lib/control-fast-state.ts (DRY)
- ControlPanel: reduce polling from 10s to 30s; SSE handles fast path (2s latency)
- ControlPanel: add collapsible 24h activity log (was fetched but never rendered)
- ProjectCard: fix RunningBanner elapsed time bug ("154s" → "2m 34s")
- ProjectCard: add warning color to elapsed timer after 15 min (possible stall)
- ProjectCard: fix ClosingBanner elapsed time bug ("3ms running" → "3m running")
- ProjectCard: remove duplicate Pause icon from auto-continue toggle button
- ProjectCard: show session.tests and session.todos in status tab summary

Navigation:
- Move /control to mobile nav (remove /money from mobile); control is flagship view

DB schema:
- project_states: add user_id FK column + index (was only table missing user isolation)
- prompt_history: add idx_prompt_history_user_id index
- habits.habit_completions: add idx_habit_completions_user_id index
- goals: add composite idx_goals_user_status index on (userId, status)
- getRecentActivity query added to prompt-history queries

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-03 05:20:04 +02:00
g-butandClaude Sonnet 4.6 e84b6d4f0a feat: GitHub OAuth, design system rebuild, reliability fixes (M1-M7)
Auth & multi-user:
- GitHub OAuth via next-auth DrizzleAdapter; signIn callback absorbs first
  login into is_default=true user so all pre-auth data stays accessible
- getCurrentUserId() helper; onboarding + profile pages
- normalizeUsername() extracted to lib/username.ts (DRY fix)

Design system:
- All public pages (landing, sign-in, onboarding, settings) rebuilt to use
  ui-* classes and semantic tokens only — zero raw Tailwind color violations
- ui-input, ui-btn-*, ui-panel, bg-surface-*, text-text-* throughout

Reliability (M1–M7):
- M1: Stale claude-stop-active lock cleanup on stop hook entry
- M2: /api/inject validates tab exists in Zellij before writing /tmp
- M3: Prompt SSOT unified — claude-prompts.json single array format
- M4: DBUS UID hardcode removed (already in dotfiles)
- M5: auth.ts signIn callback + AdapterAccountType cast
- M6: project_states DB table — persists ready/closing/closed/session/prompt
  across reboots; stop.sh PATCHes on stop/close; control falls back to DB
  when /tmp is empty (24h window); inject writes currentPrompt to DB
- M7: scheduleOpenClawWorker now async; waits for spawn event (2s timeout);
  marks run as error in DB if worker fails to start

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-02 18:20:46 +02:00
g-but d62a442fba feat(control): add pause/play button for per-tab auto work 2026-05-01 13:46:15 +02:00
g-but 72a6393895 ux(control): rename auto-continue toggle to pause/resume wording 2026-05-01 13:31:45 +02:00
g-but 33b92a3be0 feat(control): persist auto-continue toggle per tab 2026-05-01 13:18:32 +02:00
g-but 4863989c9d feat(control): pause/disable auto-continue while typing 2026-05-01 13:17:02 +02:00
g-butandClaude Sonnet 4.6 a33027c651 feat(control): full project profile with dimension prompts + prompt history
- Add ProjectProfile tab to every project card: 7 dimensions (Engineering,
  Product, UX, Marketing, Content, Business, Deploy), each with 3 crafted
  prompts that interpolate project context (name, path, mission, stack, url)
- Per-project agent selector: override global brain per card; chosen agent
  used for all dimension prompt dispatches and auto-launches agent in tab
  if not running (via /api/agent/launch → restartTab)
- Add intent:"custom" to orchestration contract so dimension prompts dispatch
  as full free-form text, not a fixed intent enum
- Add prompt_history table (append-only log of every dispatch: adapter,
  intent, custom_prompt, dispatched_at) — foundation for reuse and learning
- Log every /api/orchestration/run dispatch to prompt_history regardless of adapter
- Return recentCustomPrompts per project in /api/control response (batch query)
- Show reusable chips below custom input: click to prefill, ×N for repeat use
- Show usage count on dimension prompt buttons in Profile tab
- Add /api/agent/launch route: wraps restartTab + launchAgentInTab
- Extract launchAgentInTab to agent-runtime.ts (shared, no duplication)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 13:10:39 +02:00
g-but 43bb66b17c fix(orchestration): enforce exact session handoff line format 2026-05-01 12:43:36 +02:00
g-butandClaude Sonnet 4.6 eed9a4147a fix(control): sort dirs before cache key comparison
Unsorted join caused cache misses whenever project list order changed
between polls (same set, different order = treated as different dirs).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 12:19:08 +02:00
g-butandClaude Sonnet 4.6 e2bfddc4c9 refactor(zellij): extract injectIntoTab to shared lib
Was duplicated verbatim in inject/route.ts and orchestration/run/route.ts —
any fix to the shell-escape logic needed double application. Now SSOT.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 12:18:02 +02:00
g-butandClaude Sonnet 4.6 10c42815a1 fix(orchestration): auto-cleanup stale running runs on control panel poll
Runs stuck in "running" beyond 60 min now auto-transition to error state
on every /api/control poll (every ~10s), preventing phantom active states.
Cleanup runs in parallel with the latestRuns query so it adds no latency.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 12:08:33 +02:00
g-butandClaude Sonnet 4.6 51d60852bb fix(control): update brain capability description to reflect actual dispatch model
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>
2026-05-01 12:00:36 +02:00
g-butandClaude Sonnet 4.6 96af615648 fix(control): detect any running agent, not just the configured default
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>
2026-05-01 11:58:32 +02:00
g-butandClaude Sonnet 4.6 8919fb30bd chore: remove unused ControlData import from ProjectCard
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 11:56:23 +02:00
g-butandClaude Sonnet 4.6 426c8be9e6 fix(control): show ready/closed/closing banners regardless of configured agent
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>
2026-05-01 11:55:41 +02:00
g-butandClaude Sonnet 4.6 3a56dbc748 chore: seed scripts, crons, sessions, docs, gitignore, package updates
- scripts/seed.ts + seed-goals.ts — updated entity/attribute seeding
- src/app/api/crons/route.ts — cron schedule updates
- src/app/api/sessions/route.ts — session handling fix
- docs/ — openclaw orchestration plan document
- .gitignore — added .next/logs to ignore list
- package.json/lock — dependency updates
- next-env.d.ts — auto-generated update

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 11:50:29 +02:00
g-butandClaude Sonnet 4.6 269b858b45 feat(thoughts): thoughts section — personal writing with tag filtering
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>
2026-05-01 11:50:05 +02:00
g-butandClaude Sonnet 4.6 0ad6a7095a feat(ux): semantic design token system + component polish across all views
Introduces a full semantic token layer (text-primary/secondary/tertiary/muted,
surface-page/base/raised/overlay, border-subtle/default/strong,
accent-primary/hover/muted/text) enabling consistent theming and light/dark
mode support. ThemeProvider + ThemeToggle added to shell.

Design system:
- globals.css — semantic token declarations; oklch color values tuned for
  dark-first readability; custom shadow, tracking, and radius tokens
- ThemeProvider wraps app root; ThemeToggle in sidebar for instant switching
- All UI primitives (Card, Modal, Form, PageLayout, EmptyState) migrated to
  semantic tokens

Component polish:
- Shell (AppShell, Sidebar, MobileNav, AskIvyModal, AskIvyButton) — semantic
  colors, tighter spacing, improved mobile layout
- People views — PeopleGrid, PersonCard, PersonDetail decomposed;
  PersonChannelsSection, PersonDetailAttrs, PersonDetailHelpers extracted;
  PersonInteractionsSection added
- Projects — GitHubStatus, ProjectGrid updated to semantic tokens
- Prompts — PromptRow, FeaturedCard, CategoryBar, RunModal, ScheduleModal
  migrated; PromptLibraryClient improved filter UX
- System — SystemStats migrated to semantic tokens
- Today — Greeting, SummaryBar updated
- Pages — Habits, Memory, Money pages migrated

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 11:49:40 +02:00
g-butandClaude Sonnet 4.6 449f4d77fd feat(brain): brain-agnostic orchestration framework + agent registry + control panel UX
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>
2026-05-01 11:49:08 +02:00
g-butandClaude Sonnet 4.6 9160fbefb3 fix(ux): freeze ReadyBanner countdown while typing custom prompt
- 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>
2026-04-27 23:25:48 +02:00
g-butandClaude Sonnet 4.6 0af18eabcb refactor(soc/dry/ssot): batch quality sweep
- lib/dates.ts: move advanceDueDate() out of SubscriptionActions (SoC)
- project-detail-types.ts: export precomputed SUGGESTED_ATTR_LABELS/PLACEHOLDERS (SSOT)
- ProjectOverviewTab: data-driven issue alerts via ISSUE_DISPLAY config — 3 identical
  JSX blocks → 1 .map(); use precomputed maps; consolidate duplicate form import
- form.tsx: add ADD_BUTTON_CLASS ("+ Add" ghost button) alongside INLINE_SAVE_CLASS
- Sweep: AddEventForm, PersonInteractionsSection, ProjectPromptsTab, ProjectGoalsTab

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 23:17:19 +02:00
g-butandClaude Sonnet 4.6 15c23afc9c refactor(dry): extract INLINE_SAVE_CLASS — 6 identical className strings → 1
Add INLINE_SAVE_CLASS to components/ui/form.tsx alongside PRIMARY_BUTTON_CLASS.
Sweep: PersonDetail, PersonInteractionsSection, ProjectInlineEditors,
ProjectOverviewTab, LogConversationButton, SubscriptionActions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 23:00:29 +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 Sonnet 4.6 427b94e830 refactor(kiss): split ControlPanel 708→179 lines, extract ProjectCard
- ProjectCard + all banner sub-components → src/components/control/ProjectCard.tsx
- Time-window constants + color maps → src/lib/constants/control.ts
- timeAgo / secondsAgo → src/lib/dates.ts (shared date helpers)
- ControlPanel now owns only polling, inject, status bar, Zellij strip

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 22:32:48 +02:00
g-butandClaude Sonnet 4.6 7638d54f61 refactor(dry): extract ModalForm — eliminate 4× duplicated modal shell
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>
2026-04-27 22:19:32 +02:00
g-butandClaude Sonnet 4.6 bc17563104 refactor(ssot): stateFile helpers + document state machine contract
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>
2026-04-27 22:07:54 +02:00
g-butandClaude Sonnet 4.6 32dd228723 refactor(ssot): extract claude-config.ts + deduplicate API helpers
- 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>
2026-04-27 21:32:21 +02:00
g-butandClaude Sonnet 4.6 397bd54047 feat(control): Zellij tab strip + per-card open indicators
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>
2026-04-27 20:54:02 +02:00
g-butandClaude Sonnet 4.6 7a69b2efc3 perf(control): warm-cache latency 2.3s → 50ms; add recent commits log
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>
2026-04-27 20:31:56 +02:00
g-butandClaude Sonnet 4.6 38a007a794 feat(control): project profiles, current prompt tracking, closing state
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>
2026-04-27 20:14:37 +02:00
g-butandClaude Sonnet 4.6 0e2e647de8 perf(api): 30× speedup — single bash+parallel-jobs replaces 76 fork()s
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>
2026-04-27 19:51:10 +02:00
g-butandClaude Sonnet 4.6 bd52a59d3a fix(control): stop polling when tab is hidden, deduplicate in-flight requests
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>
2026-04-27 19:12:52 +02:00
g-butandClaude Sonnet 4.6 d47cc7a8cd perf(api): make /api/control non-blocking with async git queries
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>
2026-04-27 18:51:54 +02:00
g-butandClaude Sonnet 4.6 c39d6577f9 feat(control): add remote control panel for Claude sessions
- 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>
2026-04-27 18:28:07 +02:00
g-butandClaude Sonnet 4.6 302b7a719b fix(ux): lift text-white/20 trigger buttons to text-white/35 across 4 components
Same fix applied to AddHabitForm/AddCommitmentButton in prior sessions:
interactive "Add X" / "Log activity" / "Collapse" trigger links were at
20% opacity, below readable contrast without hover.

- goal-card-helpers: "+ Add milestone" trigger
- ProjectOverviewTab: "Add [suggested fields]", "+ Add custom attribute",
  "+ Log activity", "Collapse" buttons; "No activity recorded yet" label
- EventsGrid: "No deadline" section divider label (text-white/20 → /30)
- CommitmentsCard: empty-state hint text (text-white/20 → /30)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 17:14:13 +02:00