Skip to content

chore(dead-code): phase 2 trim pages shim cascade + packages/common monorepo#6

Merged
Agions merged 1 commit into
mainfrom
chore/dead-code-v2-cas-radical
Jun 4, 2026
Merged

chore(dead-code): phase 2 trim pages shim cascade + packages/common monorepo#6
Agions merged 1 commit into
mainfrom
chore/dead-code-v2-cas-radical

Conversation

@Agions
Copy link
Copy Markdown
Owner

@Agions Agions commented Jun 4, 2026

🐱 Dead Code Cleanup — Phase 2 (radical, ~30 files / -2,586 lines / ~190 KB)

Summary

Continues Phase 1 cleanup. Two unrelated workstreams bundled because they share the same root cause (left-over scaffolding from in-progress refactors that were never finished):

  1. 🅲️ Pages shim cascade — 5 shim-to-shim re-exports deleted, 2 routers migrated to canonical paths
  2. 🅳️ packages/common/ monorepo trim — 7 sub-directories with zero project references removed, package pruned to constants-only

🅲️ Pages shim cascade

The 4 capital-case pages/{AutoPipeline,ProjectEdit,ProjectEdit/ScriptDetail,ProjectDetail}/ directories were 2-line shims that re-exported the lowercase pages/{auto-pipeline,project-detail,project-edit}/ siblings. They existed only to give the router nice PascalCase import paths. Both routers (app/router/page-preload.ts + core/router/page-preload.ts) now use the lowercase canonical paths directly.

Deleted (5 files):

  • src/pages/AutoPipeline/AutoPipelinePage.tsx
  • src/pages/ProjectDetail/ProjectDetailPage.tsx
  • src/pages/ProjectEdit/ProjectEditPage.tsx
  • src/pages/ProjectEdit/ScriptDetailPage.tsx
  • src/pages/index.ts (also pointed at shims)

Modified:

  • src/app/router/page-preload.ts — 3 dynamic imports: @/pages/Project{Edit,Detail}/*@/pages/project-{edit,detail}/*, @/pages/AutoPipeline/*@/pages/auto-pipeline/*
  • src/core/router/page-preload.ts — same 3 + 1 scriptDetail path

🅳️ packages/common/ monorepo trim

Original design (per docs/adr/0002-frontend-monorepo-ddd.md) was to split the project into a publishable monorepo package with utils/formatters/motion/hooks/components/domain/validation sub-paths. Zero project files actually import any of these — only constants is referenced (4 sites in MusicTab/SfxTab/audio.entities/VideoExporter). The other 7 sub-directories sat at 192 KB of dead code.

Deleted (17 files + 3 empty dirs + 1 README):

  • packages/common/src/utils/ (16 KB)
  • packages/common/src/formatters/ (12 KB)
  • packages/common/src/motion/ (8 KB)
  • packages/common/src/hooks/ (20 KB)
  • packages/common/src/components/ui/{FileUploader,ProgressBar,Modal,ConfirmDialog}.{tsx,module.css} (44 KB)
  • packages/common/src/domain/{character,scene,script,shared,index}.ts (44 KB)
  • packages/common/src/validation/ (empty dir)
  • packages/common/eslint-rules/ (empty dir)
  • packages/common/tests/ (empty dir)
  • packages/common/README-before-after.md (transitional DRY-illustration doc)

Modified:

  • packages/common/src/index.ts — shrunk to export * from './constants' + comment explaining the trim and pointing at docs/adr/0002 for original design intent
  • packages/common/package.json — removed 5 dead exports entries (./* sub-paths), kept peerDependencies and devDependencies intact for future monorepo resurrection

🐛 Two latent bugs exposed (not fixed — out of scope)

Removing the broken @/pages/ProjectEditPage skip-listing surfaced two pre-existing issues that were hidden behind testPathIgnorePatterns entries in jest.config.cjs. Both are now re-skipped with a more accurate comment so a future "form refactor" PR can pick them up:

  1. ProjectEditPage.tsx useForm API mismatchconst [form] = useForm() as any (line 95) destructures the return value of useForm() as a tuple, but the actual export from @/components/ui/ui-components is useRhfForm (react-hook-form) which returns an object. Triggers TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator)) at first render. A NOTE comment in the source already flags this as "intentional until form refactor".
  2. __tests__/pages/project-{edit,detail}.test.tsx import paths — both used @/pages/ProjectEditPage / @/pages/ProjectDetailPage (no sub-dir, no extension) which never existed as a real module. Fixed to the canonical lowercase paths in this PR so the tests can run, then re-skipped under the new "form refactor" reason.

Files re-skipped with new reason in jest.config.cjs:

  • src/__tests__/pages/project-edit.test.tsx
  • src/__tests__/pages/project-detail.test.tsx

Verification

Check Result
npm run lint --quiet ✅ 0 errors
npx tsc --noEmit ✅ 0 errors
npm test --runInBand (90 suites) ✅ 1596 pass, 4 skip, 0 fail
npm run build ✅ OK (vite build + brotli compress)

Diff

 30 files changed, 23 insertions(+), 2586 deletions(-)

Phase summary

Phase Files deleted Lines deleted Volume
Phase 1 (PR #5) 26 2,774 ~72 KB
Phase 2 (this PR) 30 2,586 ~190 KB
Total 56 5,360 ~262 KB

Lesson reinforced

  1. Dynamic import('@/...') string literals are invisible to static import regex sweeps. Phase 1 missed 2 shims (components/business/CompositionStudio + RenderCenter); Phase 2 caught all 4 pages shims because the routers use the same pattern. The tsc --noEmit safety net caught the first batch immediately — always run it after every git rm cycle.
  2. testPathIgnorePatterns is a smell audit point — 2 tests in there were broken since v1.x and silently skipped. Dead-code sweeps are a good time to audit ignore lists for stale entries.
  3. "In-progress refactor" code is the biggest source of dead code — both phases' deletions (back-compat shims + monorepo scaffolding + page re-exports) were the residue of refactors that started but never finished. Either finish the refactor or strip the scaffolding; don't leave both.

@Agions Agions merged commit ef83d43 into main Jun 4, 2026
6 checks passed
@Agions Agions deleted the chore/dead-code-v2-cas-radical branch June 4, 2026 07:44
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