Commit Graph

767 Commits

Author SHA1 Message Date
Lukas May
afdc1c7e00 fix: recover in_progress phases where all tasks are already completed on server restart 2026-03-06 20:41:26 +01:00
Lukas May
80dfe53bd1 Merge branch 'cw/review-tab-performance-phase-backend-server-side-diff-cache-with-ttl-and-commit-hash-invalidation' into cw-merge-1772826052715 2026-03-06 20:40:53 +01:00
Lukas May
54673a4399 fix: stop Vite refresh loop by ignoring routeTree.gen.ts from watcher 2026-03-06 20:38:38 +01:00
Lukas May
d4a28713f6 fix: conflict resolution tasks now get dispatched instead of permanently blocking initiative
- Remove original task blocking in handleConflict (task is already completed by handleAgentStopped)
- Return created conflict task from handleConflict so orchestrator can queue it for dispatch
- Add dedup check to prevent duplicate resolution tasks on crash retries
- Queue conflict resolution task via dispatchManager in mergeTaskIntoPhase
- Add recovery for erroneously blocked tasks in recoverDispatchQueues
- Update tests and docs
2026-03-06 20:37:29 +01:00
Lukas May
72f8b07b10 feat: wire phaseId + commit-view detail into DiffViewer; fix files prop
Merges task KGRrdWohwZ6YcWjOZ0KqF (ReviewTab rawDiff → metadata file list,
phaseId/commitMode wiring) into the viewport virtualization phase branch.

Key resolution decisions:
- Keep viewport virtualization IntersectionObserver logic from HEAD
- Use activeFiles (not undefined `files`) in ReviewTab DiffViewer render — bug fix from incoming
- Keep FileDiff/FileDiffDetail split from HEAD (not deprecated FileChangeType)
- Keep FileDiff['status'] in parse-diff (status lives on base type)
- Drop spurious `comments` prop the incoming branch added to DiffViewer (unused)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:36:46 +01:00
Lukas May
a41caa633b fix: break Vite refresh loop by ignoring __tests__ in route generation
TanStack Router plugin was picking up test files under routes/__tests__/,
causing routeTree.gen.ts to regenerate in a loop. Added routeFileIgnorePattern
and removed stale radar.test.tsx.
2026-03-06 20:34:35 +01:00
Lukas May
f1af9e5d7a chore: resolve merge conflicts for DiffCache test task
Resolves add/add conflict in diff-cache.ts (kept typed PhaseMetaResponse/
FileDiffResponse interfaces from HEAD over unknown-typed singletons from test
branch) and content conflict in phase.ts (kept both phaseMetaCache and
fileDiffCache imports; removed auto-merged duplicate firstClone/headHash/
cacheKey/cached declarations and unreachable empty-projects guard).

Also cleans auto-merged duplicate getHeadCommitHash in orchestrator.test.ts
and simple-git-branch-manager.ts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:33:41 +01:00
Lukas May
f63b1c5eec Merge branch 'cw/radar' into cw-merge-1772825408137 2026-03-06 20:30:08 +01:00
Lukas May
61c4e8c0e5 Merge branch 'cw/review-tab-performance-task-SP2g6-ypklu72GHVUBhty' into cw-merge-1772825187869 2026-03-06 20:26:28 +01:00
Lukas May
7215fb2753 test: add DiffViewer and FileCard viewport virtualization tests
Covers IntersectionObserver placeholder rendering for 300-file diffs,
single-file bypass, sidebar ref registration, expandAll batch fetching
(25 files → 3 batches of 10), and all FileCard lazy-load states:
default collapsed, loading, success with HunkRows, error+retry, binary,
no-hunks, detail-prop pre-expanded, and collapse/re-expand UX.

Cherry-picks viewport virtualization implementation commit (f804cb19)
onto this branch so the tests run against the actual new code.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:25:48 +01:00
Lukas May
cc4d4f6401 Merge branch 'cw/radar-task-JJ3yFeDd1HIKtqYWuF36n' into cw-merge-1772824727227 2026-03-06 20:18:47 +01:00
Lukas May
7c48c70d47 feat: Add SSE-driven real-time refresh and last-refreshed timestamp to drilldown dialogs
Add isAgentRunning prop to all four radar drilldown dialog components.
When true, subscribe to relevant SSE events and trigger refetch on
matching events for the current agentId. Show a "Last refreshed: just now"
timestamp that ticks to "Xs ago" in the dialog footer. Reset on close.

- CompactionEventsDialog, SubagentSpawnsDialog, QuestionsAskedDialog:
  subscribe to agent:waiting events
- InterAgentMessagesDialog: subscribe to conversation:created and
  conversation:answered events (matches on fromAgentId)
- Update DrilldownDialogProps type with isAgentRunning?: boolean
- Add test coverage for all new behavior across all four dialogs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:18:17 +01:00
Lukas May
5c5a4e9bab chore: remove stale hq.test.tsx route test file
The route-level test was replaced by component-level tests in ReviewTab.test.tsx.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:18:09 +01:00
Lukas May
92a95ffa02 feat: wire drilldown dialogs into RadarPage with isAgentRunning prop
- Add isAgentRunning? to DrilldownDialogProps interface
- Import and render all four dialog components in RadarPage
- Replace MetricCell helper with per-type td elements using data-testid
  attributes for reliable test targeting
- Add drilldown state (type/agentId/agentName) and isAgentRunning derivation
- Wire non-zero metric cell onClick handlers to open the correct dialog
- Zero cells retain no onClick handler
- Extend radar.test.tsx with 8 new dialog integration test cases covering
  open/close behavior and isAgentRunning prop passing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:14:06 +01:00
Lukas May
5a33155d2e chore: Fix package.json publish warnings (npm pkg fix) 2026-03-06 20:13:47 +01:00
Lukas May
f804cb197c feat: viewport virtualization for DiffViewer + lazy per-file hunk loading in FileCard
DiffViewer now uses IntersectionObserver to replace off-viewport FileCards with
48px placeholder divs, eliminating thousands of DOM nodes at initial render for
large diffs. Files within 1× viewport buffer are rendered as real FileCards.

FileCard defaults to collapsed state and only fires getFileDiff when expanded,
with staleTime: Infinity to avoid re-fetches. Handles loading/error/binary/
no-hunks states. Commit mode passes detail prop to skip lazy loading entirely.

DiffViewer batches expand-all in chunks of 10, prefetching via tRPC utils to
saturate the network without blocking the UI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:13:01 +01:00
Lukas May
425545d7c6 Merge branch 'cw/review-tab-performance-phase-frontend-virtualize-sidebar-file-list-for-50-items' into cw-merge-1772824315514 2026-03-06 20:11:55 +01:00
Lukas May
7995a5958e test: add ReviewSidebar FilesView virtualization tests
Writes Vitest + RTL tests covering the virtual list threshold (>50 rows),
fallback path (≤50), directory collapse/expand, tab-switch scroll
preservation, file-click callback, and root-level files.

Also aliases react/react-dom to the parent monorepo copies in
vitest.config.ts so all components share the same ReactSharedInternals
dispatcher — fixing the pre-existing null-dispatcher hook errors that
affected all web component tests in this git worktree.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:11:10 +01:00
Lukas May
9bd56ce4a1 Merge branch 'cw/radar-phase-drilldown-dialog-components' into cw-merge-1772824266700 2026-03-06 20:11:06 +01:00
Lukas May
b860bc100d feat: Add Radar page with nav item, filters, table, and tests
- Adds "Radar" nav item to AppLayout between Agents and Inbox
- Creates /radar route with validateSearch for timeRange/status/initiativeId/mode filters
- Summary stat cards for questions, messages, subagents, compactions aggregates
- Agent activity table with client-side sorting on all 10 columns (default: started desc)
- Real-time SSE updates via useLiveUpdates invalidating agent namespace
- Loading skeleton (5 rows) and empty state messaging
- Non-zero metric cells show cursor-pointer for future drilldown dialogs
- 12-test suite covering rendering, sorting, filtering, nav, and states

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:10:39 +01:00
Lukas May
20d591c51f feat: add QuestionsAskedDialog and InterAgentMessagesDialog with tests
Implements the remaining two Radar drilldown dialogs following the
established AddAccountDialog pattern. Both use tRPC lazy queries,
skeleton loading, and expandable rows via useState<number | null>.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:10:38 +01:00
Lukas May
16565ce42d feat: switch ReviewTab phase diff from rawDiff to metadata file list
- Split FileDiff into FileDiff (metadata-only) and FileDiffDetail (with hunks)
  so the phase branch diff no longer requires client-side diff parsing
- ReviewTab now reads diffQuery.data.files (FileStatEntry[]) and maps
  path → newPath for sidebar and DiffViewer; no parseUnifiedDiff call
  in the phase branch view path
- Commit view still parses rawDiff via parseUnifiedDiff → FileDiffDetail[]
- Pass phaseId, commitMode, comments, expandAll to DiffViewer
- Pass totalAdditions/totalDeletions from server to ReviewHeader stats bar
- Wire Expand all button in ReviewHeader to expandAll toggle state
- Update FileCard to use FileDiffDetail and status (replaces changeType)
- Update ReviewSidebar to use file.status instead of file.changeType

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:06:49 +01:00
Lukas May
cb4519439d feat: add CompactionEventsDialog and SubagentSpawnsDialog with tests
Implements two Radar drilldown dialog components following the
AddAccountDialog pattern (Radix UI Dialog + tRPC lazy query + skeleton
loading). CompactionEventsDialog shows a simple table of compaction
events; SubagentSpawnsDialog adds expandable rows that reveal the full
Agent tool prompt. Shared DrilldownDialogProps type in types.ts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:06:32 +01:00
Lukas May
a50ee01626 test: Add DiffCache unit tests and getPhaseReviewDiff cache integration tests
Creates diff-cache.ts module with generic DiffCache<T> class (TTL, prefix
invalidation, env-var configuration) and exports phaseMetaCache / fileDiffCache
singletons. Wires cache into getPhaseReviewDiff via getHeadCommitHash on
BranchManager. Adds 6 unit tests for DiffCache and 5 integration tests
verifying cache hit/miss behaviour, prefix invalidation, and NOT_FOUND guard.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:06:28 +01:00
Lukas May
5968a6ba88 feat: split FileDiff into metadata FileDiff + hunk-bearing FileDiffDetail
Prepares the review components for the backend phase that returns
metadata-only file lists from getPhaseReviewDiff. FileDiff now holds
only path/status/additions/deletions; FileDiffDetail extends it with
hunks. Renames changeType→status and adds 'binary' to the union.

Also fixes two pre-existing TypeScript errors: InitiativeReview was
passing an unknown `comments` prop to DiffViewer (should be
commentsByLine), and ConflictResolutionPanel destructured an unused
`agent` variable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 19:52:18 +01:00
Lukas May
9bdf89fc20 chore: update TypeScript build info after react-window addition 2026-03-06 19:51:46 +01:00
Lukas May
0996073deb feat: add in-memory diff cache with TTL and commit-hash invalidation
Adds DiffCache<T> module, extends BranchManager with getHeadCommitHash,
and wires phase-level caching into getPhaseReviewDiff and getFileDiff.
Cache is invalidated in ExecutionOrchestrator after each task merges into
the phase branch, ensuring stale diffs are never served after new commits.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 19:51:04 +01:00
Lukas May
0323b42667 feat: virtualize ReviewSidebar file list for >50 items with scroll preservation
Adds windowed rendering to FilesView in ReviewSidebar.tsx using
react-window 2.x (List component). File lists with more than 50 rows
render only visible items, keeping the DOM lean for large diffs.

- Install react-window 2.x and @types/react-window in apps/web
- Flatten directory-grouped file tree into a typed Row[] array via useMemo
- Use VariableSizeList-equivalent react-window 2.x List with rowHeight fn
  (32px for dir-headers, 40px for file rows); falls back to plain DOM
  render for ≤50 rows to avoid overhead on small diffs
- Directories are collapsible: clicking the dir-header toggles collapse,
  removing its file rows from the Row[] and from the virtual list
- Preserve sidebar scroll offset across Files ↔ Commits tab switches via
  filesScrollOffsetRef passed from ReviewSidebar into FilesView
- Clicking a file calls listRef.scrollToRow({ index, align: "smart" })
  to keep the clicked row visible in the virtual list
- Root-level files (directory === "") render without a dir-header,
  preserving existing behavior
- Add resolve.dedupe for react/react-dom in vitest.config.ts to prevent
  duplicate-React errors after local workspace package installation
- Add 6 Vitest + RTL tests covering: large-list DOM count, small-list
  fallback, collapse, re-expand, tab-switch smoke, root-level files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 19:50:53 +01:00
Lukas May
2c00ad902d Merge branch 'cw/review-tab-performance-phase-frontend-move-syntax-highlighting-off-main-thread' into cw-merge-1772822818316 2026-03-06 19:46:58 +01:00
Lukas May
eb09f1a5fe test: add missing fallback test scenarios for useHighlightedFile
Add single-chunk equivalence test (≤200 lines produces complete token
map with no missing line entries) and AbortController abort spy test
(unmount during chunked fallback triggers abort signal) to cover the
remaining spec scenarios not included by the implementation branch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 19:46:31 +01:00
Lukas May
90978d631a Merge branch 'cw/review-tab-performance-phase-backend-split-full-diff-into-metadata-per-file-procedures' into cw-merge-1772822786257 2026-03-06 19:46:26 +01:00
Lukas May
647f45c3bd Merge branch 'cw/review-tab-performance-task-7G4gkfUa2t87cIN6-rGVv' into cw-merge-1772822785439 2026-03-06 19:46:25 +01:00
Lukas May
4890721a92 feat: split getPhaseReviewDiff into metadata + add getFileDiff procedure
Rewrites getPhaseReviewDiff to return file-level metadata (path, status,
additions, deletions) instead of a raw diff string, eliminating 10MB+
payloads for large repos. Adds getFileDiff for on-demand per-file hunk
content with binary detection via numstat. Multi-project initiatives
prefix file paths with the project name to avoid collisions.

Adds integration tests that use real local git repos + in-memory SQLite
to verify both procedures end-to-end (binary files, deleted files,
spaces in paths, error cases).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 19:45:57 +01:00
Lukas May
c22a550bfc docs: document Web Worker syntax highlighting architecture in frontend.md
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 19:40:26 +01:00
Lukas May
0608900a53 feat: move syntax highlighting off main thread via Web Worker pool
Adds a 2-worker pool in use-syntax-highlight.ts so shiki tokenisation
runs off the main thread. Callers continue to receive null while the
worker is in flight and a LineTokenMap once it resolves — no caller
changes needed.

Fallback: if Worker construction is blocked (e.g. CSP), the hook falls
back to the existing createHighlighter singleton but processes 200 lines
at a time, yielding between chunks via scheduler.yield()/setTimeout(0)
to avoid long tasks.

Also adds worker.format:'es' to vite.config.ts (required when the app
uses code-splitting) and covers all paths with Vitest tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 19:39:31 +01:00
Lukas May
05eb160749 feat: add diffBranchesStat and diffFileSingle to BranchManager
Adds FileStatEntry type and two new primitives to the BranchManager
port and SimpleGitBranchManager adapter, enabling split diff
procedures in the tRPC layer without returning raw multi-megabyte diffs.

- FileStatEntry captures path, status, additions/deletions, oldPath
  (renames), and optional projectId for multi-project routing
- diffBranchesStat uses --name-status + --numstat, detects binary
  files (shown as - / - in numstat), handles spaces in filenames
- diffFileSingle returns raw unified diff for a single file path
2026-03-06 19:36:36 +01:00
Lukas May
9894cdd06f feat: add diffBranchesStat and diffFileSingle to BranchManager
Adds FileStatEntry type and two new primitives to the BranchManager
port and SimpleGitBranchManager adapter, enabling split diff
procedures in the tRPC layer without returning raw multi-megabyte diffs.

- FileStatEntry captures path, status, additions/deletions, oldPath
  (renames), and optional projectId for multi-project routing
- diffBranchesStat uses --name-status + --numstat, detects binary
  files (shown as - / - in numstat), handles spaces in filenames
- diffFileSingle returns raw unified diff for a single file path
2026-03-06 19:33:47 +01:00
Lukas May
ec86b62d8d perf: Pre-index review comments into Map to eliminate O(n) filtering
Build a Map<string, ReviewComment[]> once in ReviewTab and thread it
down through DiffViewer → FileCard → HunkRows, replacing O(n) filter
calls with O(1) map lookups. With 200 comments and 5000 diff lines,
this reduces ~1M iterations per render cycle to ~5K.

Key: "${filePath}:${lineNumber}:${lineType}" for line-level comments,
"${filePath}:file" for file-level (lineNumber === null) comments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 19:31:57 +01:00
Lukas May
2b7660f019 ci: Switch to OIDC trusted publishing for npm (no token needed) 2026-03-06 17:04:20 +01:00
Lukas May
c0096503b2 fix: Re-record cassettes and exclude workdir from test discovery
Re-recorded all 4 cassette files to reflect current prompt templates.
Added `workdir/**` to vitest exclude list to prevent test discovery
in agent worktree directories.
2026-03-06 17:00:46 +01:00
Lukas May
a30f98d532 ci: Alias NODE_AUTH_TOKEN to NPM_TOKEN for semantic-release verification 2026-03-06 16:53:14 +01:00
Lukas May
28521e1c20 chore: merge main into cw/small-change-flow
Integrates main branch changes (headquarters dashboard, task retry count,
agent prompt persistence, remote sync improvements) with the initiative's
errand agent feature. Both features coexist in the merged result.

Key resolutions:
- Schema: take main's errands table (nullable projectId, no conflictFiles,
  with errandsRelations); migrate to 0035_faulty_human_fly
- Router: keep both errandProcedures and headquartersProcedures
- Errand prompt: take main's simpler version (no question-asking flow)
- Manager: take main's status check (running|idle only, no waiting_for_input)
- Tests: update to match removed conflictFiles field and undefined vs null
2026-03-06 16:48:12 +01:00
Lukas May
91efbabee6 ci: Use NODE_AUTH_TOKEN and bump semantic-release to latest versions 2026-03-06 16:45:49 +01:00
Lukas May
5598e1c10f feat: implement Radar backend tRPC procedures with repository extensions
Add five new tRPC query procedures powering the Radar page's per-agent
behavioral metrics (questions asked, subagent spawns, compaction events,
inter-agent messages) plus the batch repository methods they require.

Repository changes:
- LogChunkRepository: add findByAgentIds() for batch fetching without N+1
- ConversationRepository: add countByFromAgentIds() and findByFromAgentId()
- Drizzle adapters: implement all three new methods using inArray()
- InMemoryConversationRepository (integration test): implement new methods

tRPC procedures added:
- agent.listForRadar: filtered agent list with per-agent metrics computed
  from log chunks (questionsCount, subagentsCount, compactionsCount) and
  conversation counts (messagesCount); supports timeRange/status/mode/initiative filters
- agent.getCompactionEvents: compact system init chunks for one agent (cap 200)
- agent.getSubagentSpawns: Agent tool_use entries with prompt preview (cap 200)
- agent.getQuestionsAsked: AskUserQuestion tool calls with questions array (cap 200)
- conversation.getByFromAgent: conversations by fromAgentId with toAgentName resolved

All 13 new unit tests pass; existing test suite unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 16:40:18 +01:00
Lukas May
1e16ad82e8 fix: Show conflict resolution agents in HQ dashboard
getHeadquartersDashboard had no section for active conflict agents,
so initiatives with a running conflict-* agent disappeared from all
HQ sections. Add resolvingConflicts array to surface them.
2026-03-06 16:39:48 +01:00
Lukas May
02ca1d568e fix: Disable EventEmitter maxListeners warning for SSE subscriptions
Each SSE client registers a listener per event type (30+ types), so a
few concurrent connections easily exceed the previous limit of 100.
Listeners are properly cleaned up on disconnect via eventBusIterable's
finally block, so this is not a real leak.
2026-03-06 16:39:36 +01:00
Lukas May
85f5f77927 ci: Switch from GitLab Package Registry to npmjs for publishing 2026-03-06 16:39:18 +01:00
Lukas May
cb95ac1c6e fix: Logo link navigates to HQ instead of Initiatives 2026-03-06 16:33:10 +01:00
Lukas May
da3218b530 Merge branch 'cw/small-change-flow-phase-cli-errand-commands' into cw-merge-1772810965256 2026-03-06 16:29:25 +01:00
Lukas May
0ec1022aba Merge branch 'cw/small-change-flow-task-3yaqNLqG3kk5ku6rH0exF' into cw-merge-1772810964768 2026-03-06 16:29:25 +01:00