Skip to content

fix: worktree branding not applied in vite dev mode - #1038

Merged
cryppadotta merged 1 commit into
masterfrom
paperclip-worktree-dynamics
Mar 16, 2026
Merged

cryppadotta merged 1 commit into
masterfrom
paperclip-worktree-dynamics

Conversation

@cryppadotta

Copy link
Copy Markdown
Contributor

Summary

  • Vite dev server was configured with appType: "spa", which adds its own SPA fallback middleware that serves index.html directly — bypassing the custom catch-all route that calls applyUiBranding()
  • Changed appType to "custom" so our route handles HTML serving and injects worktree-colored favicon + banner meta tags
  • No impact on non-worktree dev or production — branding is gated on PAPERCLIP_IN_WORKTREE env var which is only set by the CLI's worktree init commands

Test plan

  • Verified via curl that worktree meta tags and dynamic favicon are injected after fix
  • Visually confirm colored banner and favicon at http://127.0.0.1:<port> in a worktree instance
  • Confirm normal dev (no worktree) still serves default favicon and no banner
  • Confirm production/static mode is unaffected (different code path)

🤖 Generated with Claude Code

… applied

Vite's "spa" appType adds its own SPA fallback middleware that serves
index.html directly, bypassing the custom catch-all route that calls
applyUiBranding(). Changing to "custom" lets our route handle HTML
serving, which injects the worktree-colored favicon and banner meta tags.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a one-liner bug where appType: "spa" caused Vite's built-in SPA fallback middleware to intercept all unmatched GET requests and serve index.html directly — before the custom Express catch-all route (app.get(/.*/, ...)) ever ran, so applyUiBranding() was never called in vite-dev mode. Switching to appType: "custom" disables Vite's fallback and restores the intended code path where vite.transformIndexHtml() and applyUiBranding() are both applied.

  • The fix is minimal, correct, and scoped entirely to the vite-dev code path.
  • The app.use(vite.middlewares) line is retained, so Vite still serves /@vite/client, HMR WebSocket, and all static assets as before — only the SPA HTML fallback is removed and delegated to the existing Express catch-all.
  • Branding is gated on PAPERCLIP_IN_WORKTREE, so non-worktree dev sessions and production (static) mode are unaffected.
  • No functional regressions are introduced.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, targeted one-line fix with no functional side effects outside of the vite-dev worktree path.
  • The change is a single configuration value ("spa" → "custom") that removes Vite's built-in SPA fallback and defers HTML serving to the already-existing Express catch-all. vite.middlewares is still mounted so HMR, /@vite/client, and asset serving are unaffected. The custom catch-all already correctly calls vite.transformIndexHtml() and applyUiBranding(), so no new logic is needed — the fix simply stops Vite from short-circuiting it. The branding guard on PAPERCLIP_IN_WORKTREE ensures no impact on non-worktree dev or production paths.
  • No files require special attention.

Important Files Changed

Filename Overview
server/src/app.ts Single-line fix changing Vite's appType from "spa" to "custom" so the custom catch-all route (which calls applyUiBranding()) is no longer bypassed by Vite's built-in SPA fallback middleware. The rest of the vite-dev block is unchanged and correctly calls vite.transformIndexHtml() before applying branding.

Last reviewed commit: ccb6729

@cryppadotta
cryppadotta merged commit 7034ea5 into master Mar 16, 2026
3 checks passed
tr00x pushed a commit to tr00x/paperclip that referenced this pull request Mar 26, 2026
…ee-dynamics

fix: worktree branding not applied in vite dev mode
hhhhansel pushed a commit to hhhhansel/paperclip that referenced this pull request Mar 27, 2026
…ee-dynamics

fix: worktree branding not applied in vite dev mode
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