Skip to content

chore(dead-code): remove 26 verified orphan files (~72KB / -2,774 lines)#5

Merged
Agions merged 1 commit into
mainfrom
chore/dead-code-cleanup-v2.2
Jun 4, 2026
Merged

chore(dead-code): remove 26 verified orphan files (~72KB / -2,774 lines)#5
Agions merged 1 commit into
mainfrom
chore/dead-code-cleanup-v2.2

Conversation

@Agions
Copy link
Copy Markdown
Owner

@Agions Agions commented Jun 4, 2026

🐱 Dead Code Cleanup — Phase 1 (conservative, ~72 KB / 26 files)

Summary

Removes 26 verified orphan source files totaling ~72 KB / -2,774 lines identified through:

  • ts-prune static export analysis
  • Recursive reverse import graph traversal
  • Dynamic import('@/...') string-literal sweep (caught 2 false positives)

What's removed

A. 12 back-compat shim files (commented "21+ files import" but verified 0 actual references post v2.x refactor):

  • src/components/{index.ts, ui/confirm-dialog.tsx}
  • src/context/SettingsContext.tsx
  • src/hooks/index.ts
  • src/providers/AppProvider.tsx
  • src/core/pipeline/step-chain.ts
  • src/core/services/{base-ai-service, novel-helpers, scene-analyzer.service, script-analyzer.service, video-composition.types}.ts
  • src/core/stores/middlewares/persistWithDebounce.ts (had @deprecated tag)

B. 14 real orphan source files (zero references anywhere in repo):

  • src/pages/project-edit/hooks/useProjectEdit.ts (569 lines, Container hook left orphaned after page split refactor)
  • src/styles/{design-tokens, motion}.ts (only theme.ts is imported; motion.ts keyframes duplicated in globals.css)
  • src/shared/hooks/use-animation-frame.ts (10.5 KB RAF hook library, unused)
  • src/shared/components/ui/{accordion, async-boundary, breadcrumb, drawer, form, use-form}.tsx
  • src/core/validation/schemas.ts (270-line Zod)
  • src/core/domains/novel/services/emotion-detector.service.ts
  • src/core/services/video/ffmpeg-wasm/ffmpeg-wasm.types.ts
  • src/features/editor/components/timeline.types.ts

Preserved (verified needed)

  • src/shared/types/cssmodule.d.ts — ambient *.less/*.css declarations, used by 60+ less imports
  • src/components/business/CompositionStudio.tsx + RenderCenter.tsx — used by 3 import() sites in ProjectDetailPage + StepComposition + StepRender

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

Diff

 26 files changed, 2774 deletions(-)

Out of scope (Phase 2 candidates, ~443 KB remaining)

  • 🅲️ 4 orphan pages/ directories (auto-pipeline/project-detail/project-edit/video-editor, ~256 KB) — needs test import path migration
  • 🅳️ packages/common/ half (utils/formatters/motion/hooks/domain/components/validation, ~192 KB) — only constants is used; effectively aborts the monorepo refactor

Lesson learned (patched into this PR's analysis method)

Dynamic import('@/components/business/xxx') string-literal calls are invisible to static import regex sweeps. Initial candidate list had 2 false positives (CompositionStudio + RenderCenter shims); tsc --noEmit caught them immediately after git rm, files were restored via git restore --staged --worktree. Always run tsc --noEmit after the first batch of deletions before committing.

Static analysis (ts-prune + recursive reverse import graph + dynamic import
sweep) identified 28 candidates with zero importers. Two back-compat shims
(components/business/CompositionStudio.tsx + RenderCenter.tsx) are kept
because they are referenced via dynamic import() in 3 page files
(ProjectDetailPage + StepComposition + StepRender).

Deleted categories:
  A. 12 back-compat shim files (declared '21+ files import' but 0 actual
     references after 8-phase refactor):
     - src/components/{index.ts,ui/confirm-dialog.tsx}
     - src/context/SettingsContext.tsx
     - src/hooks/index.ts
     - src/providers/AppProvider.tsx
     - src/core/pipeline/step-chain.ts
     - src/core/services/{base-ai-service,novel-helpers,
       scene-analyzer.service,script-analyzer.service,
       video-composition.types}.ts
     - src/core/stores/middlewares/persistWithDebounce.ts

  B. 14 real orphan source files (0 references anywhere):
     - src/core/domains/novel/services/emotion-detector.service.ts
     - src/core/validation/schemas.ts
     - src/core/services/video/ffmpeg-wasm/ffmpeg-wasm.types.ts
     - src/features/editor/components/timeline.types.ts
     - src/pages/project-edit/hooks/useProjectEdit.ts (HUGE 569 lines,
       Container hook left orphaned after page refactor split)
     - src/shared/components/ui/{accordion,async-boundary,breadcrumb,
       drawer,form,use-form}.tsx
     - src/shared/hooks/use-animation-frame.ts (10.5KB RAF hook lib)
     - src/styles/{design-tokens,motion}.ts (only theme.ts is imported)

Verification:
  - npm run lint --quiet  → 0 errors
  - npx tsc --noEmit       → 0 errors
  - npm test (90 suites)   → 1596 pass, 4 skip, 0 fail
  - npm run build          → OK

Preserved (verified needed):
  - src/shared/types/cssmodule.d.ts (ambient *.less/*.css declarations)
  - components/business/CompositionStudio.tsx + RenderCenter.tsx
    (re-export shims, used by 3 dynamic import() sites)
@Agions Agions merged commit 8b2c970 into main Jun 4, 2026
6 checks passed
@Agions Agions deleted the chore/dead-code-cleanup-v2.2 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