Skip to content

Split devCoder.ts into domain modules under src/dev/ (#1447 pass M) - #1466

Merged
currentbits merged 16 commits into
mainfrom
coder/refactor-m-split-devcoder-ts-ca13fb
Oct 5, 2026
Merged

currentbits merged 16 commits into
mainfrom
coder/refactor-m-split-devcoder-ts-ca13fb

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Round 5, pass M of #1447. src/devCoder.ts is the in-browser fake backend (npm run dev:browser, and the VITE_TRAILER=1 seed behind the site screenshots). It was one 6,696-line factory closure. It's now split into 16 domain modules under src/dev/, and devCoder.ts stays the entry point (512 lines) with the same exports.

Module Lines Module Lines
runs.ts 1,155 memory.ts 289
threads.ts 900 mcp.ts 287
git.ts 616 issues.ts 216
settings.ts 529 automations.ts 212
seed.ts 502 workflows.ts 138
usage.ts 496 context.ts 52
skills.ts 414 util.ts 25
workspace.ts 393 projects.ts 341

How the state moved. The closure's 8 reassigned variables (threads, projects, templates, mcpServers, memoryEntries, spendTodayUsd, dailyBudgetUsd, quotaWaitAutoResume) stay where they were. A ctx exposes them through getters and setters, so ctx.threads = … still writes the original variable. Maps and helpers go on ctx as-is, and each domain module is a create<Domain>(ctx) factory. State initialisation and timer start order are unchanged.

Checked

  • Only change is the ctx. rewrite: I stripped ctx. / ctx.api() from the added lines, then compared them with the removed lines (ignoring indentation). Everything left is wiring: the ctx construction, its getters and setters, and destructures.
  • No shadowing: on main, the only parameter that shares a name with ctx state is seedThreads(projects), a top-level function outside the closure. It still uses its own parameter, with no ctx references.
  • Demo screenshots against main: in the VITE_TRAILER=1 seed, the thread view after the seeded run completes, Insights › Usage and Kanban are byte-identical (cmp).
  • npm run typecheck and npx vite build are clean. Renderer suite: 2701/2701, 0 cancelled (TAP count).

🤖 Generated with Claude Code

Willem and others added 16 commits October 5, 2026 12:26
Pure move of the workflow/session tick helpers, usage bumps and RunState,
plus the shared now/id/capitalize/TRAILER helpers into src/dev/util.ts.
Bodies verbatim; only export prefixes and imports change. Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pure move of the seeded projects, threads, transcript, providers, crew
tasks, spec artifacts and fake diff. Bodies verbatim. Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds src/dev/context.ts: DevCtx carries the state buildDevCoder shares
with domain modules. Reassigned lets are get/set accessors over the
core's own variables, so the core's bodies stay verbatim and domains read
ctx.x at call time. createMemory(ctx) returns the memory namespace; the
seeded rows still initialise in the core at their original position.
Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
createMcp(ctx) owns the pending-import preview; the user server list is
shared with settings and pairing through ctx.mcpServers. redactDevMcp
is pure and hoisted to module scope. devCoder.ts re-exports the catalog
for test/support/fakeCoder.ts. Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
createSkills() owns the skill list, pending previews and the ponytail
plugin fixtures; nothing else reads them, so it takes no ctx. Bodies
verbatim. Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
createSettings(ctx) owns every settings variable and the budget/settle
patch parsers. dailyBudgetUsd and quotaWaitAutoResume stay core state
(the run budget guard and thread resume read them) and are reached via
ctx; shorthand properties for those become `x: ctx.x`. Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The template list stays core state (runs and git read it) behind
ctx.templates; the builtin template and normalisers move verbatim.
Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
createAutomations(ctx) owns the automation list; it starts runs through
ctx.api(), read lazily at call time. Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
createProjects(ctx) owns the space list; projects/threads/memory rows stay
core state behind ctx accessors. Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
createThreads(ctx) owns the trash map and its TTL; thread rows, details
and run maps stay core state. cloneDetail moves to src/dev/util.ts since
the core's emitDetail uses it too. Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…/runs.ts

createRunEngine(core) holds tickRun/startRunTimer/clearRunTimer and the
spend guards over the core state; ctx = Object.assign(core, engine). The
ctx block moves above the seeded-timer loop, which still runs at the same
point of buildDevCoder (after every seed, before the api object), so
timer start order is unchanged. createRuns(ctx) returns the namespace.
Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
createGit(ctx) owns the GC-reclaimed set and the synthetic PR counter;
the PR map (seeded at boot) and checkpoints stay core state. Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
createUsage(ctx) returns activity, usage, fleet, insights and digest; it
only reads core state. Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…/issues.ts

createSourceControl() and createIssues(ctx) are separate because the
namespaces are not adjacent in the api object and its key order is kept.
createIssues owns the Planboard label moves. Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
createPairing(ctx) owns the paired-device list (Settings > Remote). Part
of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
createWorkspace() owns the demo dev servers and terminal scrollback and
returns servers, simulator, preview, devserver, terminal, files, fs,
attachments and shell. Part of #1447.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@currentbits
currentbits merged commit fcc882b into main Oct 5, 2026
11 of 12 checks passed
@currentbits
currentbits deleted the coder/refactor-m-split-devcoder-ts-ca13fb branch October 5, 2026 11:18
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