Skip to content

Split routes/activity.ts into feature-owned modules#792

Merged
selfcontained merged 1 commit into
mainfrom
tech-debt/split-activity-routes
Jul 17, 2026
Merged

Split routes/activity.ts into feature-owned modules#792
selfcontained merged 1 commit into
mainfrom
tech-debt/split-activity-routes

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

What

Splits the 779-line apps/server/src/routes/activity.ts into feature-owned modules under apps/server/src/routes/activity/, mirroring the existing routes/agents/ layout:

  • shared.ts — the ActivityRouteDeps type
  • metrics-routes.ts — heatmap, stats, daily-status, active-hours, agents-created, working-time-by-project
  • token-routes.ts — token-stats, token-daily, token-by-project, token-by-model, harvest-tokens
  • history-routes.ts — history projects, agent list, agent detail
  • index.ts — thin composition (registerActivityRoutes)

Handler bodies are moved verbatim — no behavior change. The only edit outside the new directory is the import path in server.ts.

Why it's tech debt

activity.ts bundled three unrelated features (activity metrics, token reporting, agent history) in one file. PR #773 extracted the handlers into named functions; this completes the follow-up queued in the tech-debt backlog by giving each feature its own module.

Validation

  • pnpm run check — clean
  • pnpm run test — 2,562 passing
  • pnpm run test:e2e — 168 passed, 13 skipped (pre-existing terminal-live skips)

Queued next

Reduce agents-view.tsx (1006 lines) or use-terminal.ts (916 lines) — coordinating with the componentizer job which owns large-component extraction.

🤖 Generated with Claude Code

The 779-line activity.ts held 14 handlers spanning three distinct
features. Move them into routes/activity/ mirroring the existing
routes/agents/ layout: metrics-routes.ts (heatmap, stats, daily
status, active hours, agents created, working time), token-routes.ts
(token stats/daily/by-project/by-model, harvest), history-routes.ts
(projects, agent list, agent detail), with shared.ts holding the deps
type and index.ts composing registration. Handler bodies are moved
verbatim; no behavior change.

Co-Authored-By: Claude Fable 5 <[email protected]>
@selfcontained
selfcontained merged commit 36872f4 into main Jul 17, 2026
1 check passed
@selfcontained
selfcontained deleted the tech-debt/split-activity-routes branch July 17, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant