Skip to content

feat(theme-check-vscode): surface orphaned files on startup#1218

Open
ryandiginomad wants to merge 1 commit into
Shopify:mainfrom
ryandiginomad:feat/970-orphaned-files-on-boot
Open

feat(theme-check-vscode): surface orphaned files on startup#1218
ryandiginomad wants to merge 1 commit into
Shopify:mainfrom
ryandiginomad:feat/970-orphaned-files-on-boot

Conversation

@ryandiginomad
Copy link
Copy Markdown
Contributor

What

Closes #970.

theme-graph already knows which files are orphaned (dead code), and there's a Liquid Theme Check: Find dead code command to list them — but it's easy to miss because you have to know to run it. This surfaces it proactively: on activation, if the theme has orphaned files, the extension shows a single dismissable notification.

  • Review → opens the existing dead-code quick pick
  • Don't show again → flips the setting off
  • Gated by a new themeCheck.checkOrphanedFilesOnBoot setting (default true), mirroring the existing themeCheck.preloadOnBoot pattern

How

  • Reuses the whole-theme dead-code detection already exposed via ThemeGraphDeadCodeRequest (ThemeGraphManager.deadCode(rootUri)) — no server changes.
  • The startup check finds theme roots via workspace.findFiles('**/.theme-check.yml') (there's no active editor at boot), aggregates orphaned files across roots, and prompts once.
  • Refactored makeDeadCode to extract fetchDeadCode + showDeadCodePicker so the command and the startup check share logic — makeDeadCode's behavior is unchanged and covered by a characterization test.
  • Wired into both node and browser activation, fire-and-forget so it never blocks or fails activation.

Open questions (happy to adjust)

  • Setting default: went with true to match the issue's "prompt on start-up" intent, but happy to make it opt-in (false) if you'd prefer less startup noise.
  • Changeset bump: marked minor (new feature + setting); happy to drop to patch given the fixed version group.
  • Multi-root: aggregates the count across all theme roots and "Review" opens the first root with orphans. Open to per-root prompts instead.
  • Notification copy / action labels: easy to tweak to taste.

Testing

  • New unit tests for the startup check (orphanedFilesOnBoot.spec.ts): disabled setting, no orphans, orphans → notification, "Don't show again" → setting update, "Review" → picker.
  • Characterization tests for makeDeadCode to guard the refactor.
  • Full theme-check-vscode vitest suite green (23 tests), tsc --noEmit clean, prettier clean.

🤖 AI assistance

Drafted with Claude Code. I reviewed every change, ran the tests, and verified the approach against existing extension patterns. The orphaned-files detection this builds on is existing Shopify code; this PR adds the startup surfacing plus a shared refactor.

On activation, check the theme for orphaned (dead) files and show a single
dismissable notification with "Review" (opens the existing dead-code picker)
and "Don't show again" actions, instead of requiring the user to run the
dead-code command manually.

- Gated by a new `themeCheck.checkOrphanedFilesOnBoot` setting (default on),
  mirroring the existing `themeCheck.preloadOnBoot` pattern
- Reuses the whole-theme dead-code detection already exposed via
  ThemeGraphDeadCodeRequest
- Extract fetchDeadCode + showDeadCodePicker from makeDeadCode so the startup
  check and the command share logic (no behavior change; covered by tests)
- Wired into both node and browser activation, fire-and-forget so it never
  blocks or fails activation

Closes Shopify#970
@ryandiginomad ryandiginomad requested a review from a team as a code owner May 31, 2026 15:19
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.

VSCode prompt to remove dead code with an alert

1 participant