Skip to content

refactor: simplify internals across the workspace - #1590

Open
aidenybai wants to merge 8 commits into
mainfrom
codex/extract-inspect-finalization
Open

refactor: simplify internals across the workspace#1590
aidenybai wants to merge 8 commits into
mainfrom
codex/extract-inspect-finalization

Conversation

@aidenybai

@aidenybai aidenybai commented Aug 6, 2026

Copy link
Copy Markdown
Member

Why

The runtime migration left correctness-sensitive work concentrated in oversized coordinators for scan planning, staged snapshots, baseline filtering, cache persistence, project detection, module linking, telemetry, and rendering. The workspace also accumulated duplicate graph walkers, repeated AST helpers, cast-heavy boundaries, pass-through wrappers, and internal exports with no consumers.

This refactor makes those responsibilities explicit and independently testable while preserving the CLI contract, JSON schema, package APIs, diagnostics, and release behavior.

What changed

  • decomposed CLI inspection into focused planning, staged-scan, finalization, cache, rendering, and telemetry boundaries
  • replaced nullable TUI state and concurrently mutated scan side channels with discriminated snapshots and explicit completed/skipped/omitted outcomes
  • made listener and abort registries reentrancy-safe by snapshotting before callbacks
  • separated pure final scan decisions from logging, metrics, report writes, and exit-code mutation
  • made NDJSON reporter ownership scoped and finalization idempotent, including early-exit coverage
  • split framework and React Compiler detection from the config evaluator; reduced the evaluator's largest function from 532 lines / cyclomatic 135 to 436 lines / 111 without fragmenting its recursive state model
  • lazy-loaded cold CLI command implementations while leaving Commander metadata and help eager
  • fixed built-output path containment in deslop with path.relative, including the sibling-prefix regression case
  • canonicalized repeated AST property-name detection and project-outcome partitioning
  • removed pass-through wrappers, stale detector barrels, duplicate source hashing, redundant aliases, unused imports, and analyzer-confirmed dead internals across the workspace
  • retained intentional compatibility surfaces such as InspectUiLayers and package-local atomic writers where combining them would break public or package boundaries
  • kept patch changesets for the affected published packages

The complete PR now changes 179 files with 5,275 insertions and 4,738 deletions. The final architecture pass was informed by React Grab's explicit state machines and snapshot-before-callback lifecycle handling, OpenCode's narrow runtime boundaries and lazy command loading, and OpenTUI's scoped ownership and pure outcome construction.

Fallow and deslop were used as evidence rather than mechanical deletion lists. The final Fallow pass reduced newly attributed duplicate groups from 9 to 3 and the maximum attributed cyclomatic complexity from 135 to 111. Its remaining new-only failures are known analysis limitations: an 89% file rename is counted as newly introduced complexity, the published CLI deliberately bundles effect, vite-plus is centrally managed workspace tooling, InspectUiLayers is a public compatibility export, and the two atomic writers sit across a private package boundary. The latest whole-repo deslop run exited successfully after analyzing 6,997 files and 9,268 exports; its large unused-file list is dominated by deliberate fuzz corpora and dead-code fixtures.

Test plan

  • nr test — 15/15 tasks; React Doctor 2,453 passed / 27 skipped
  • nr test:deslop — deslop-js 521 passed; deslop-cli 17 passed
  • focused current-head core suite — 1,862 passed
  • focused CLI architecture regressions — 24 passed
  • focused AST utility regressions — 70 passed
  • nr lint — passes; remaining warnings are intentional fuzz-corpus inputs
  • nr typecheck — 16/16 tasks across the workspace
  • nr format:check — 6,211 files
  • nr build — all workspace build tasks pass
  • nr smoke:json-report — schema v3 complete report
  • nr smoke:packed-cli-install — version 0.9.5, 180 diagnostics, zero forbidden packages
  • local React Doctor changed-scope scan for the final refactor commit — 16 files, zero diagnostics
  • npx --yes fallow@latest audit --base origin/main — completed and manually triaged as described above
  • npx --yes deslop-cli@latest analyze . — completed successfully across the full workspace

@pkg-pr-new

pkg-pr-new Bot commented Aug 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-react-doctor@1590
npm i https://pkg.pr.new/oxlint-plugin-react-doctor@1590
npm i https://pkg.pr.new/react-doctor@1590

commit: 257ed73

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 257ed73.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Interactive terminal E2E

React Doctor interactive terminal recording

Recorded from the built CLI at 257ed73 in a real terminal. The fixture holds Git busy for three seconds, so Scanning... must appear immediately after project selection, then exercises the compact interactive report.

Download the GIF and MP4 artifact

@aidenybai
aidenybai marked this pull request as ready for review August 6, 2026 08:19
@aidenybai aidenybai changed the title refactor(cli): extract inspect result finalization refactor: harden scan orchestration and cache boundaries Aug 6, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e20ce0a. Configure here.

Comment thread packages/react-doctor/src/cli/utils/open-workflow-pull-request.ts
@aidenybai aidenybai changed the title refactor: harden scan orchestration and cache boundaries refactor: consolidate scan, cache, and graph internals Aug 6, 2026
@aidenybai aidenybai changed the title refactor: consolidate scan, cache, and graph internals refactor: simplify internals across the workspace Aug 6, 2026
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