Skip to content

feat(workbench): route editor state on effect-atom (#105 phase 2) - #263

Merged
ScriptedAlchemy merged 1 commit into
mainfrom
feat/workbench-atom-phase2
Sep 2, 2026
Merged

feat(workbench): route editor state on effect-atom (#105 phase 2)#263
ScriptedAlchemy merged 1 commit into
mainfrom
feat/workbench-atom-phase2

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Summary

Phase 2 of the #105 effect-atom migration (phase 1: #250). The routes-page route-input editor state — previously seven coordinated useState/derivation clusters per editor (draft, raw JSON, errors, rawError, attempted, arguments, argv) — moves onto an Atom.family keyed by manifest digest + compiled route id, in a new dedicated browser-state module per the docs/effect-conventions.md "Workbench browser state" convention.

  • packages/workbench/src/routes/route-editor-atoms.ts: writable Atom.family keyed digest\u0000routeId, initial value undefined (uninitialized sentinel). No effects, no streams (stream-backed derived atoms remain banned until the post-rc.112 re-pin), no Atom/AsyncResult in any public export.
  • packages/workbench/src/routes/routes-model.ts: stays pure — adds RouteEditorState + pure transitions (initialRouteEditorState, setRouteEditorDraftValue, setRouteEditorRaw, validateRouteEditor) that derive from the untouched validateRouteInput / validateRawRouteInput / cliCommandInvocation projections.
  • packages/workbench/src/routes/routes-page.tsx: RouteInputEditor consumes the atom via useAtom with functional updaters; markup unchanged; RoutesPage public props unchanged.

The undefined sentinel is what keeps provider-less static SSR rendering byte-identical initial markup (useAtomValue's getServerSnapshot returns the initial atom value), so the existing contract tests pass unmodified.

Preserved behavior contracts (#222/#224 fixes)

routes-model.test.ts, routes-page.test.ts, and examples-real.e2e.test.ts are untouched and green. Pinned explicitly by new unit tests: optional-boolean omitted/true/false three-state, stale-prefill fail-closed paths untouched (mcpToolPrefillFor gating on validated arguments preserved), variadic/repeated-option argv + usage projection, attempted-gated re-validation, and the raw-path asymmetry (raw edits after Validate update rawError/arguments but never argv).

Disposal regression (phase-1 pattern)

route-editor-atoms-disposal.test.ts (integration pool): rsbuild browser fixture mounting the real RoutesPage under a bare RegistryProvider; 5 mount → type → validate → unmount → remount cycles assert fresh initial state each remount, plus an A→B→A digest-switch cycle; zero page errors.

Verification (local, after rebasing over #259)

  • lint: 0 errors / 0 warnings (915 files)
  • typecheck: this diff is clean; pnpm typecheck currently fails on pristine origin/main (TS7016 in classify-docs-only.test.ts from ci: extract docs-only classifier tests and retry stale-diagnostic e2e flakes #259) — pre-existing, reproduced on a clean main worktree
  • scoped units (routes-model + routes-page + new routes-editor-state): 40/40
  • full integration + workbench browser e2e: 61 files / 629 tests — 625 passed, 3 skipped, 1 failed: public-api.test.ts :: keeps bundled config extension types in emitted root declarations, pre-existing (fails identically on a pristine origin/main worktree; unrelated to workbench)
  • new disposal regression: 1/1 pass

Bundle delta (workbench production build)

raw gzip
before (main) 2770.4 kB 595.3 kB
after 2770.7 kB 594.9 kB
delta +0.3 kB (+0.01%) −0.4 kB (−0.07%)

Near-zero as predicted — the effect core + atom runtime entered the shared chunk in phase 1.

Patch changeset included (agent-bundle ships the Workbench dist).

@changeset-bot

changeset-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 84b2ca7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agent-bundle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ScriptedAlchemy
ScriptedAlchemy merged commit c97a50f into main Sep 2, 2026
4 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T02:53:33.267063Z 84b2ca7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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