Skip to content

[standards][tracking] Split worst large files into testable modules #305

Description

@serge-ivo

Problem

VCQA reports standards D largely because several production files are still very large. This is valid PAGS technical debt, but it is not a single ready-to-pick implementation story unless it is treated as a tracking issue and split into smaller refactors.

Current line counts verified on 2026-08-07:

  • packages/sdk/src/voice/use-voice.ts — 1532 lines
  • workers/api/src/routes/coding.ts — 1738 lines
  • workers/api/src/routes/instances.ts — 1695 lines
  • workers/mcp/src/instance-tools/base.ts — 1778 lines
  • store/console/src/pages/InstanceDetail.tsx — 1230 lines
  • store/console/src/tabs/SettingsTab.tsx — 1148 lines
  • agents/coder/web/src/CodingTab.tsx — 1216 lines

Related narrower tickets already exist:

Fix direction

  • Treat this as a tracking issue unless a dev explicitly picks one file/module boundary.
  • Split by behavior boundary, not arbitrary line count.
  • Add or preserve tests before moving behavior.
  • Prefer small leaf modules for parsing, state derivation, route handlers, controller actions, and UI subpanels.
  • Avoid broad refactors that mix route behavior, UI styling, and public API changes in one PR.

Ready child work candidates

  • Extract voice audio/session/state-machine helpers from packages/sdk/src/voice/use-voice.ts.
  • Split workers/api/src/routes/instances.ts into route registration plus small handler/service modules.
  • Split workers/mcp/src/instance-tools/base.ts into tool groups with shared helpers.
  • Extract focused subpanels/hooks from store/console/src/pages/InstanceDetail.tsx.
  • Extract settings form sections from store/console/src/tabs/SettingsTab.tsx.
  • Extract Coder tab terminal/repo/session subpanels from agents/coder/web/src/CodingTab.tsx.

Acceptance

  • Each child PR names the boundary it is extracting and keeps behavior unchanged unless separately tested.
  • Typecheck and relevant tests pass for each child PR.
  • VCQA large-file/context findings improve over several focused PRs.
  • A ratchet or CI check prevents the same files from growing back past the agreed threshold.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendBackend / Worker / API workfrontendFrontend / UI work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions