Commit Graph

349 Commits

Author SHA1 Message Date
Lukas May
342b490fe7 feat: Task decomposition for Tailwind/Radix/shadcn foundation setup
Decomposed "Foundation Setup - Install Dependencies & Configure Tailwind"
phase into 6 executable tasks:

1. Install Tailwind CSS, PostCSS & Autoprefixer
2. Map MUI theme to Tailwind design tokens
3. Setup CSS variables for dynamic theming
4. Install Radix UI primitives
5. Initialize shadcn/ui and setup component directory
6. Move MUI to devDependencies and verify setup

Tasks follow logical dependency chain with final human verification
checkpoint before proceeding with component migration.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-10 09:48:51 +01:00
Lukas May
da4152264c feat(web): Pipeline visualization, phase content editing, and review tab
Pipeline view groups phases by dependency depth with DAG visualization.
Phase detail panel with Tiptap rich content editor and auto-save.
Code review tab with diff viewer and comment threads (dummy data).
Centralized live updates hook replaces scattered subscription boilerplate.
Extract agent output parsing into shared utility. Inbox detail panel,
account cards, and agent action components.
2026-02-09 22:33:40 +01:00
Lukas May
47c3162581 feat(shared): Add topological sort and pipeline column grouping for phases
Kahn's algorithm for topological phase sorting by dependency edges with
createdAt tiebreaker. groupPhasesByDependencyLevel computes pipeline
visualization columns. Handles cycles gracefully.
2026-02-09 22:33:34 +01:00
Lukas May
fab7706f5c feat: Phase schema refactor, agent lifecycle module, and log chunks
Phase model changes:
- Drop `number` column (ordering now by createdAt + dependency DAG)
- Replace `description` (plain text) with `content` (Tiptap JSON)
- Add `approved` status as dispatch gate
- Add phase dependency management (list, remove, dependents)
- Approval gate in PhaseDispatchManager.queuePhase()

Agent log chunks:
- New `agent_log_chunks` table for DB-first output persistence
- LogChunkRepository port + DrizzleLogChunkRepository adapter
- FileTailer onRawContent callback streams chunks to DB
- getAgentOutput reads from DB first, falls back to file

Agent lifecycle module (src/agent/lifecycle/):
- SignalManager: atomic signal.json read/write/wait operations
- RetryPolicy: exponential backoff with error-specific strategies
- ErrorAnalyzer: pattern-based error classification
- CleanupStrategy: debug archival vs production cleanup
- AgentLifecycleController: orchestrates retry/recovery flow
- Missing signal recovery with instruction injection

Completion detection fixes:
- Read signal.json file instead of parsing stdout as JSON
- Cancellable pollForCompletion with { cancel } handle
- Centralized state cleanup via cleanupAgentState()
- Credential handler consolidation (prepareProcessEnv)

Prompts refactor:
- Split monolithic prompts.ts into per-mode modules
- Add workspace layout section to agent prompts
- Fix markdown-to-tiptap double-serialization

Server/tRPC:
- Subscription heartbeat (30s) and bounded queue (1000 max)
- Phase CRUD: approvePhase, deletePhase, dependency queries
- Page: findByIds, getPageUpdatedAtMap
- Wire new repositories through container and context
2026-02-09 22:33:28 +01:00
Lukas May
43e2c8b0ba fix(agent): Eliminate race condition in completion handling
PROBLEM:
- Agents completing with questions were incorrectly marked as "crashed"
- Race condition: polling handler AND crash handler both called handleCompletion()
- Caused database corruption and lost pending questions

SOLUTION:
- Add completion mutex in OutputHandler to prevent concurrent processing
- Remove duplicate completion call from crash handler
- Only one handler executes completion logic per agent

TESTING:
- Added mutex-completion.test.ts with 4 test cases
- Verified mutex prevents concurrent access
- Verified lock cleanup on exceptions
- Verified different agents can process concurrently

FIXES: residential-cuckoo and 12+ other agents stuck in crashed state
2026-02-08 15:51:32 +01:00
Lukas May
6f5fd3a0af fix(agent): Implement incremental JSONL parsing to eliminate race conditions
Replaces file completion detection with a superior approach that reads only
complete JSONL lines and tracks file position. This eliminates race conditions
without any delays or polling.

Key improvements:
- Read up to last complete line, avoiding partial lines during writes
- Track file position per agent for incremental reading
- Process only valid, complete JSON lines
- Clean up position tracking on completion/crash
- No hardcoded delays or polling required

This approach is more robust, responsive, and elegant than timing-based solutions.
The race condition where agents were marked as crashed is now completely resolved.
2026-02-08 14:10:02 +01:00
Lukas May
604da7cd0d fix(agent): Replace hardcoded 500ms delay with robust file completion detection
Fixes race condition where agents were incorrectly marked as crashed when
output files took longer than 500ms to complete writing.

Changes:
- Replace hardcoded 500ms delay with polling-based file completion detection
- Add signal file validation to ensure JSON is complete before processing
- Make status updates atomic to prevent race conditions
- Update cleanup manager to pass outputFilePath for proper timing

This resolves the issue where successful agents like "abundant-wolverine"
were marked as crashed despite producing valid output.
2026-02-08 14:03:47 +01:00
Lukas May
2877484012 Add userDismissedAt field to agents schema 2026-02-07 00:33:12 +01:00
Lukas May
111ed0962f docs(21-06): complete integration smoke test plan
Tasks completed: 2/2
- Run full build verification (TypeScript, Vite, tests)
- Full integration smoke test (human-verified, approved)

SUMMARY: .planning/phases/21-polish-integration/21-06-SUMMARY.md
2026-02-05 09:16:31 +01:00
Lukas May
51c26d6d19 docs(21-05): create summary and update state for code splitting & performance
Add 21-05-SUMMARY.md documenting route-based code splitting results
(582 KB -> 454 KB main chunk + route-level chunks) and PlanTasksFetcher
useEffect fix. Update STATE.md to plan 5/6 with new decisions.
2026-02-05 09:06:13 +01:00
Lukas May
c1744b306c docs(21-04): complete subscription error handling plan
Tasks completed: 2/2
- Add subscription error handling with toast feedback on all pages
- Verify SpawnArchitectDropdown error toast coverage (no-op)

SUMMARY: .planning/phases/21-polish-integration/21-04-SUMMARY.md
2026-02-05 09:05:49 +01:00
Lukas May
c66d7ecfb2 fix(21-05): move PlanTasksFetcher onTasks callback to useEffect
Replace the setState-during-render pattern in PlanTasksFetcher with a
useEffect hook. The onTasks callback was being called directly in the
render body when tasksQuery.isSuccess was true, which could cause
infinite re-render loops when the parent state update triggered a
re-render. Now data flows through useEffect with proper dependencies.
2026-02-05 09:05:07 +01:00
Lukas May
1530d7ab15 feat(21-05): enable route-based code splitting via TanStack Router autoCodeSplitting
Enable autoCodeSplitting in TanStackRouterVite plugin to split the monolithic
582 KB bundle into route-level chunks. Main vendor chunk drops to 454 KB with
initiative detail (~13 KB), inbox (~13 KB), and dashboard (~65 KB) as separate
lazy-loaded chunks. Eliminates the Vite 500 KB chunk size warning.
2026-02-05 09:04:25 +01:00
Lukas May
4ae85da3f6 feat(21-04): add subscription error handling with toast feedback on all pages
- Replace silent onError: () => {} with sticky toast notification
- Toast uses fixed ID 'sub-error' to prevent duplicate notifications
- duration: Infinity keeps toast visible until dismissed
- Applied to initiatives/index.tsx, initiatives/$id.tsx, inbox.tsx
2026-02-05 09:04:17 +01:00
Lukas May
3d492d86a1 docs(21-01): create summary and update state for error boundary + toasts 2026-02-05 09:02:31 +01:00
Lukas May
c95ef6e98c docs(21-02): create summary and update state for skeleton loading states 2026-02-05 09:02:02 +01:00
Lukas May
5efb4d4e8b feat(21-01): wire toast notifications into all mutation flows
- SpawnArchitectDropdown: toast.success on spawn, toast.error on failure
- ActionMenu: toast.success on archive, toast.error on failure
- CreateInitiativeDialog: toast.success on creation
- Inbox: toast.success/error for resumeAgent and respondToMessage mutations
- Replace all console.error-only mutation error handling with user-visible toasts
2026-02-05 09:01:45 +01:00
Lukas May
7e82ac561b docs(21-03): complete cross-screen navigation & mobile responsive plan
Tasks completed: 2/2
- Add cross-screen navigation links
- Fix mobile responsive layout for detail panels

SUMMARY: .planning/phases/21-polish-integration/21-03-SUMMARY.md
2026-02-05 09:01:34 +01:00
Lukas May
a6c2864b74 feat(21-02): add skeleton loading states to initiative detail page
Replace plain "Loading initiative..." and "Loading phases..." text with
structured skeleton placeholders matching the page layout: header with
back arrow/title/badge, two-column grid with phase accordions and
sidebar panels.
2026-02-05 09:01:22 +01:00
Lukas May
1e1aadaece feat(21-03): fix mobile responsive layout for inbox detail panel
- Hide inbox list on mobile when agent selected (drill-down pattern)
- Add "Back to list" button visible only on mobile (lg:hidden)
- Clicking back clears selection and returns to list view
2026-02-05 08:59:39 +01:00
Lukas May
d323e1ea8e feat(21-01): add ErrorBoundary, Sonner toast provider, and 404 navigation
- Create ErrorBoundary class component with recovery UI (reload button)
- Create Sonner Toaster wrapper (bottom-right, richColors)
- Wire ErrorBoundary around Outlet in root route to catch render errors
- Add Toaster as sibling to AppLayout in root route
- Update notFoundComponent with Back to Dashboard link button
2026-02-05 08:57:30 +01:00
Lukas May
c52c6f170f feat(21-03): add cross-screen navigation links
- Remove disabled nav stubs (Agents, Tasks, Settings) from AppLayout
- Make TaskRow agent names clickable links to inbox page
- Add task ID link and "View in context" link in inbox detail panel
2026-02-05 08:57:07 +01:00
Lukas May
11fa5f4be9 feat(21-02): add Skeleton component and skeleton loading states for dashboard + inbox
Create reusable Skeleton component with animate-pulse styling. Replace
plain "Loading..." text with structured skeleton placeholders matching
card layouts in InitiativeList and inbox page.
2026-02-05 08:56:35 +01:00
Lukas May
81814ac213 docs(21): create phase plan for Polish & Integration
Phase 21: Polish & Integration
- 6 plans in 3 waves
- 3 parallel (Wave 1), 2 parallel (Wave 2), 1 sequential (Wave 3)
- Ready for execution
2026-02-05 07:46:36 +01:00
Lukas May
e2c84f0577 docs(20): complete real-time-subscriptions phase 2026-02-04 22:23:31 +01:00
Lukas May
48c81f70a8 docs(20-02): create summary and update state for frontend subscriptions
Phase 20 (Real-Time Subscriptions) is now complete. Both plans delivered:
- 20-01: SSE backend with subscription procedures
- 20-02: Frontend splitLink + subscription hooks on all 3 UI pages
2026-02-04 22:22:53 +01:00
Lukas May
170ac55afd feat(20-02): wire SSE subscription hooks into dashboard, detail, and inbox pages
Add useSubscription hooks to all three UI pages that invalidate React
Query caches on domain events:
- Dashboard: onTaskUpdate invalidates listInitiatives + listPhases
- Detail: onTaskUpdate invalidates phases/tasks/plans, onAgentUpdate
  invalidates listAgents
- Inbox: onAgentUpdate invalidates listWaitingAgents + listMessages

Subscription failures are silent (onError: () => {}) so pages degrade
gracefully to manual refresh when the backend is not running.
2026-02-04 22:21:44 +01:00
Lukas May
eaf3f10722 feat(20-02): add splitLink to route subscriptions to SSE httpSubscriptionLink
Replace single httpBatchLink with splitLink that routes subscription
operations to httpSubscriptionLink (SSE) while keeping queries/mutations
on httpBatchLink. No new packages needed — both exports are part of
@trpc/client v11.
2026-02-04 22:20:16 +01:00
Lukas May
8cfdfe987b docs(20): complete plan 20-01 SSE streaming summary and state update 2026-02-04 22:18:11 +01:00
Lukas May
42154d60d4 feat(20): export SubscriptionEvent type from shared package
Add SubscriptionEvent interface for frontend consumption of SSE
subscription data in onData callbacks. Vite proxy confirmed compatible
with SSE streaming (http-proxy passes chunked responses by default).
2026-02-04 22:16:57 +01:00
Lukas May
e5d8dbb583 feat(20): add SSE streaming support and subscription procedures
Fix tRPC HTTP adapter to stream ReadableStream responses instead of
buffering (required for SSE). Create subscriptions module that bridges
EventBus domain events into tRPC async generator subscriptions using a
queue-based pattern. Add three subscription procedures: onEvent (all
events), onAgentUpdate (agent lifecycle), onTaskUpdate (task/phase).
2026-02-04 22:16:14 +01:00
Lukas May
4b25ba0ab2 docs(20): create phase plan
Phase 20: Real-time Subscriptions
- 2 plans in 2 waves
- 1 parallel (Wave 1: backend SSE), 1 sequential (Wave 2: frontend hooks)
- SSE via tRPC httpSubscriptionLink (no WebSocket dependency)
- Ready for execution
2026-02-04 22:10:54 +01:00
Lukas May
9d7002d2bd fix(19): wire AgentManager into server tRPC context
AgentManager was never instantiated or passed to the CoordinationServer,
causing all agent-related tRPC procedures to throw "Agent manager not
available". Creates DrizzleAgentRepository, SimpleGitWorktreeManager,
and ClaudeAgentManager in startServer() and passes agentManager into
the server context deps.
2026-02-04 22:03:09 +01:00
Lukas May
049810ffae fix(19): gracefully handle missing agentManager in read-only agent procedures
listWaitingAgents, listAgents, and getAgentQuestions now return empty
results instead of throwing when agentManager is not wired into the
tRPC context. Mutation procedures (spawn, stop, resume) still throw.
2026-02-04 22:00:34 +01:00
Lukas May
c93b3aaa4c docs(19): complete agent-inbox phase 2026-02-04 21:57:46 +01:00
Lukas May
b4d6f9c070 docs(19-04): create inbox page assembly summary and update state
Phase 19 (Agent Inbox) complete. All 4 plans executed: backend API
procedures, InboxList/MessageCard components, QuestionForm/input
components, and inbox page assembly with tRPC wiring.
2026-02-04 21:57:00 +01:00
Lukas May
3cac453364 feat(19-04): wire inbox page with data fetching, detail panel, and answer submission
Replaces stub inbox page with full implementation connecting InboxList
and QuestionForm components to tRPC backend. Two-column layout with
agent list on left and detail panel on right. Handles answer submission
via resumeAgent mutation, notification dismissal via respondToMessage,
and loading/error states following patterns from initiative detail page.
2026-02-04 21:55:42 +01:00
Lukas May
d6cf309091 docs(19-03): create QuestionForm & Input Components summary and update state
Tasks completed: 2/2
- OptionGroup and FreeTextInput components
- QuestionForm component

SUMMARY: .planning/phases/19-agent-inbox/19-03-SUMMARY.md
2026-02-04 21:53:45 +01:00
Lukas May
ce46cfc663 docs(19-01): complete backend API for agent questions plan
Tasks completed: 2/2
- Add getAgentQuestions and listWaitingAgents tRPC procedures
- Export PendingQuestions and QuestionItem types from shared package

SUMMARY: .planning/phases/19-agent-inbox/19-01-SUMMARY.md
2026-02-04 21:53:21 +01:00
Lukas May
aa93efaf65 docs(19-02): create InboxList/MessageCard plan summary and update state 2026-02-04 21:52:55 +01:00
Lukas May
648f9db230 feat(19-03): create QuestionForm component
- Renders mixed question types from questions array
- Submit disabled until all questions answered
- onSubmit called with Record<string, string> mapping questionId to answer
2026-02-04 21:52:08 +01:00
Lukas May
bf3521e3dd feat(19-02): create InboxList component with filter/sort controls
InboxList joins agents with their latest messages, provides filter
(all/waiting/completed) and sort (newest/oldest) controls, renders
MessageCard instances, and shows empty state when no messages match.
2026-02-04 21:52:01 +01:00
Lukas May
47a2bb38bf feat(19-01): export PendingQuestions and QuestionItem from shared package
- Re-export PendingQuestions and QuestionItem types from agent/types
- Available via @codewalk-district/shared for frontend consumption
2026-02-04 21:51:51 +01:00
Lukas May
f73b85062d feat(19-03): create OptionGroup and FreeTextInput components
- OptionGroup renders radio or checkbox based on multiSelect prop
- "Other" field auto-selects when user types into it
- FreeTextInput renders Input or Textarea based on multiline prop
2026-02-04 21:51:40 +01:00
Lukas May
004140ea83 feat(19-01): add getAgentQuestions and listWaitingAgents tRPC procedures
- getAgentQuestions returns structured PendingQuestions from AgentManager
- listWaitingAgents filters agents to waiting_for_input status
- Updated JSDoc procedure list with both new procedures
2026-02-04 21:51:25 +01:00
Lukas May
6450e4072a feat(19-02): create MessageCard component for agent inbox
MessageCard displays agent name with status, message preview (truncated
to 80 chars), relative timestamp, and response indicator (filled/empty
circle). Uses shadcn Card base with selected state highlighting.
2026-02-04 21:51:24 +01:00
Lukas May
d9b6ce4748 docs(19): create agent inbox phase plan
Phase 19: Agent Inbox
- 4 plans in 2 waves
- 3 parallel (Wave 1), 1 sequential (Wave 2)
- Ready for execution
2026-02-04 21:47:58 +01:00
Lukas May
9586e379bc docs(18): complete initiative detail phase 2026-02-04 21:39:48 +01:00
Lukas May
572b7e3806 docs(18-04): create initiative detail page assembly summary and update state
Phase 18 (Initiative Detail) complete — all 4 plans finished.
2026-02-04 21:39:02 +01:00
Lukas May
1e26bfadbd feat(18-04): wire Initiative Detail page with data fetching and all components
Replace placeholder with full initiative detail page: tRPC data fetching
(getInitiative, listPhases, listPlans, listTasks), PhaseWithTasks helper
component pattern for stable hooks, two-column layout with phases on left
and progress/decisions on right, TaskDetailModal with selectedTask state,
queue actions for phases and tasks, loading/error states.
2026-02-04 21:37:41 +01:00