Repository navigation
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Audit of the largest TypeScript source files (excluding node_modules, dist, and unit *.test.*). Purpose: identify refactor candidates — files that are too long and/or mix multiple responsibilities. No refactoring in this issue — just the list + rationale, to be split into follow-up tasks.
Command used:
find . -type f \( -name "*.tsx" -o -name "*.ts" \) ! -path "*/node_modules/*" \
! -path "*/.git/*" ! -path "*/dist/*" ! -name "*.test.ts" ! -name "*.test.tsx" \
-exec wc -l {} + | sort -rn | head
Top 15 by line count
| LOC | File | What it is / why it's a refactor candidate |
|---|---|---|
| 2029 | workers/mcp/src/instance-tools.ts |
Every instance-scoped MCP tool (schema + handler) in one file (~dozens of tools). Split by tool group (knowledge, coding, triggers, board, settings, …). |
| 1470 | workers/api/src/routes/coding.ts |
ALL coding routes — repos, sessions, deployments/builds, issues, overseer, engines, work-mode. Too many endpoints in one router; split by sub-domain. |
| 1317 | workers/api/src/routes/instances.ts |
Instance CRUD + voice-settings + typed settings + language sync + more. Mixed concerns; extract voice-settings and settings routers. |
| 1290 | workers/api/src/agent-do.ts |
The AgentDO Durable Object: chat loop, tool execution, storage wiring, repo ingest, alarm state machine. Classic god-object; split the ingest/alarm and chat loop out. |
| 1276 | store/console/src/tabs/SettingsTab.tsx |
One giant Settings component (voice, translation, board maintenance, runner info, danger zone, …). Split into per-section subcomponents. |
| 1251 | workers/api/src/agent-storage.ts |
Storage engine spanning collections, files, vectors, activity, summaries, memory — many domains in one class. Split per storage domain. |
| 1155 | packages/browser-runner/src/runner.ts |
Runner entry: Playwright + tmux + relay transport + task dispatch. Mixes transport and task handlers; extract the task registry. |
| 1064 | workers/mcp/src/index.ts |
MCP server bootstrap + account-tool registration + dispatch. Split registration from transport/dispatch. |
| 1064 | packages/sdk/src/voice/use-voice.ts |
The voice hook — STT/TTS/VAD/modes/commands/timers/echo-guard all in one useVoice. Very high complexity; extract sub-hooks (e.g. useStt, useTurnTimers, useCommands). |
| 986 | e2e/console.spec.ts |
Playwright e2e suite for the console (one big spec). Lower priority (tests), but could split by feature area for readability. |
| 788 | workers/api/src/routes/instances-runtime.ts |
Runtime/relay node routes (register/resolve/status). Cohesive but long; candidate to split node-management vs runtime-call. |
| 763 | agents/coder/web/src/CodingTab.tsx |
The Coder UI container: repos, sessions, terminal/co-pilot, header override, builds toggle, loop, engines. Many responsibilities in one component — prime split candidate (header, session view, landing view). |
| 748 | workers/api/src/lib/storage-tools.ts |
executeStorageTool — one big switch over all storage + coding tools. Split handlers per group. |
| 725 | packages/cli/src/commands/runner.ts |
CLI runner command (connect, relay, multiplex, reattach). Long single command; extract helpers. |
| 720 | store/console/src/pages/InstanceDetail.tsx |
Instance detail page: chat thread + tab routing + voice + loop + gloss. Mixed concerns; extract the chat thread component. |
Suggested next steps
- Prioritize the god-objects first:
agent-do.ts,agent-storage.ts,instance-tools.ts, anduse-voice.ts— highest complexity-per-file and most-touched. - UI:
SettingsTab.tsx,CodingTab.tsx,InstanceDetail.tsxsplit into subcomponents (they already have natural section boundaries). - Each split should be behavior-preserving with the existing tests kept green; file one follow-up issue per target.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Activity
serge-ivo commentedon Aug 2, 2026
Audit complete — this ticket was scoped as 'the list + rationale, split into follow-up tasks' (no refactoring in-issue), and the list is in the body.
Filed the prioritized god-object follow-ups (the issue's 'prioritize these first'):
workers/mcp/src/instance-tools.ts(2029 LOC) by tool groupAgentDOgod-objectworkers/api/src/agent-do.ts(1298 LOC)agent-storage.ts(1262 LOC) per storage domainpackages/sdk/src/voice/use-voice.ts(1127 LOC)The remaining audit candidates (routes/coding.ts, routes/instances.ts, SettingsTab/CodingTab/InstanceDetail UI splits, storage-tools.ts, runner.ts, cli runner.ts, etc.) stay documented in the table above as a backlog; file per-target issues as they're picked up. Each split must be behavior-preserving with existing tests kept green.
feat(github): a default-branch commit's closing keyword closes the is…