Skip to content

Add Knip config and initial dead-code cleanup - #4293

Merged
wojtekn merged 9 commits into
trunkfrom
remove-dead-code
Jul 23, 2026
Merged

Add Knip config and initial dead-code cleanup#4293
wojtekn merged 9 commits into
trunkfrom
remove-dead-code

Conversation

@wojtekn

@wojtekn wojtekn commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Related issues

  • N/A

How AI was used in this PR

Used Claude Code with Knip to detect dead code and unused dependencies across the monorepo, then manually verified each finding (checking for dynamic/string-based references, deeplink handlers, and Navigator wiring) before removing anything. Only high-confidence, independently-verified removals are included here.

Proposed Changes

Introduces Knip as a dead-code and unused-dependency analysis tool for the monorepo, and lands the first, highest-confidence cleanup it surfaced. This has no user-visible impact — it removes code that was already unreachable — but it reduces maintenance surface and gives us a repeatable way to catch dead code going forward.

  • Adds a knip.json tuned to this repo's non-standard entry points (Electron's main/preload builds, the CLI child-process daemons, the apps/ui hosted/local Vite targets, migrations, and the build scripts/), so runs produce a trustworthy signal rather than false positives.
  • Removes an orphaned duplicate migration (05-set-cli-user-uninstalled) that was byte-identical to the live 06-set-cli-user-uninstalled and referenced by nothing.
  • Removes a cluster of abandoned add-site "blueprint" components and a hook, none of which were imported anywhere; the live blueprint flow uses different components.

Further cleanups Knip surfaced will follow in separate, focused PRs.

Testing Instructions

  • npm run typecheck passes.
  • npm test -- apps/studio/src/lib/deeplink apps/studio/src/migrations passes (44 tests) — covers the migration and add-site/deeplink areas adjacent to the removed code.
  • Optionally, run npm run knip to see the current dead-code/dependency report.
  • Smoke-test the add-site flow (New site, import backup, blueprint deeplink) to confirm no regression from the removed components.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@wojtekn
wojtekn requested a review from a team July 22, 2026 07:53
@wpmobilebot

wpmobilebot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing c86dd49 vs trunk

app-size

Metric trunk c86dd49 Diff Change
App Size (Mac) 1362.03 MB 1362.03 MB 0.00 MB ⚪ 0.0%

site-editor

Metric trunk c86dd49 Diff Change
load 1084 ms 1085 ms +1 ms ⚪ 0.0%

site-startup

Metric trunk c86dd49 Diff Change
siteCreation 7033 ms 7018 ms 15 ms ⚪ 0.0%
siteStartup 2350 ms 2346 ms 4 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

wojtekn added 2 commits July 23, 2026 13:08
# Conflicts:
#	apps/studio/src/modules/add-site/components/blueprints.tsx
#	apps/studio/src/modules/add-site/components/import-backup.tsx

@epeicher epeicher 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.

Thanks for adding this @wojtekn! The CI passes as expected, and the knip report is generated fine. I have tested adding a site, importing from a backup, and adding a site using a blueprint and I have not found any issues. LGTM!

@wojtekn
wojtekn merged commit 41d3b5f into trunk Jul 23, 2026
13 checks passed
@wojtekn
wojtekn deleted the remove-dead-code branch July 23, 2026 14:39
wojtekn added a commit that referenced this pull request Jul 27, 2026
## Related issues

- N/A

## How AI was used in this PR

Follow-up to #4293. Used Claude Code with [Knip](https://knip.dev) to
identify unused UI code, then manually verified each finding had no
references (including dynamic/string references and test mocks) before
removing it. The Rive removal footprint (asset, test mock, dependency,
and Vite bundling) was traced by hand.

## Proposed Changes

Removes two pieces of dead UI code and their supporting infrastructure.
No user-visible impact — neither was rendered anywhere. This trims an
unused animation dependency and its WASM bundling, slightly reducing
install and build surface.

- Removes an unused SVG icon component that nothing referenced.
- Removes the unused animated AI icon hook along with its Rive animation
asset, its test mock, the `@rive-app/react-canvas` dependency, and the
Rive-specific WASM copying in the Electron Vite config.

## Testing Instructions

- `npm run typecheck` passes across all workspaces.
- `npm test -- apps/studio` passes (684 tests) — confirms removing the
`use-ai-icon` test mock had no fallout.
- `npx knip` no longer reports the two icons, and `@rive-app/*` is fully
gone from the dependency graph.
- Smoke-test the app (especially the AI/assistant surfaces) to confirm
no missing-icon regression

## Pre-merge Checklist

- [x] Have you checked for TypeScript, React or other console errors?
wojtekn added a commit that referenced this pull request Jul 31, 2026
## Related issues

- N/A

## How AI was used in this PR

Third follow-up in the Knip dead-code cleanup series (after #4293 and
#4313). Used Claude Code with [Knip](https://knip.dev) to surface unused
files, then manually verified each one had no live references —
carefully distinguishing genuinely-dead files from same-named symbols in
other modules (e.g. a CLI `wordpress.ts` with identical export names,
and a `SitesListContent` that lives in the non-classic selector). Only
files with zero real importers were removed.

## Proposed Changes

Removes the last batch of unused files Knip flagged. No user-visible
impact — none of these were reachable. This clears the dead-code backlog
so Knip now reports zero unused files.

- Removes a sync-sites re-export barrel that nothing imported (its
underlying hooks are imported directly and stay).
- Removes an unused chain of WordPress download/version/setup helpers in
the desktop app that only referenced each other; the CLI has its own
equivalent implementations that are unaffected.
- Removes a stale "classic" variant of the sync-sites modal selector
that was superseded by the current selector.
- Removes an unused Spinner component from the agentic UI.
- Cleans up the now-orphaned test mocks that referenced the removed
setup helper.

## Testing Instructions

- `npm run typecheck` passes for both `studio-app` and `@studio/ui`.
- `npm test -- apps/studio/src/tests/site-server.test.ts
apps/studio/src/tests/ipc-handlers.test.ts apps/studio/src/modules/sync`
passes (63 tests) — covers the areas whose test mocks were touched.
- `npx knip` now reports zero unused files.
- Smoke-test site creation and the sync "pull remote site" flow to
confirm no regression.

## Pre-merge Checklist

- [x] Have you checked for TypeScript, React or other console errors?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants