fix(server): ignore sibling worktrees in dev watch (#11074)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Developers can run Paperclip from linked Git worktrees. > - The server development watcher scans paths near the active checkout. > - A main checkout can contain many complete sibling worktrees under `.paperclip/worktrees`. > - Scanning those sibling checkouts can stall the watcher before it starts the server. > - This pull request excludes the shared worktree directory from the development watcher. > - The benefit is that development startup stays responsive as the number of worktrees grows. ## Linked Issues or Issue Description **What happened?** The server development watcher traversed sibling checkouts under `.paperclip/worktrees`. Large worktree collections could make `pnpm dev` stall before the watcher started the server process. **Expected behavior** The watcher must observe only source paths that can reload the active checkout. It must ignore sibling worktrees in both a main checkout and a linked worktree. **Steps to reproduce** 1. Create several linked worktrees under `.paperclip/worktrees`. 2. Add normal dependency and build output trees to those worktrees. 3. Run `pnpm dev` from the main checkout or one linked worktree. 4. Observe the watcher scan sibling worktrees before it starts the server. **Paperclip version or commit** Reproduced on `master` before this change. **Deployment mode** Local development with `pnpm dev`. ## What Changed - Detect whether the active server root is inside the managed linked-worktree directory. - Ignore the shared `.paperclip/worktrees` root from both main and linked checkouts. - Add regression coverage for the resolved ignore path and its globstar form. ## Verification - `./node_modules/.bin/vitest run server/src/__tests__/dev-watch-ignore.test.ts --reporter=verbose` - `pnpm --filter @paperclipai/server typecheck` ## Risks - Low risk. The change affects only local development watch exclusions. - A non-standard checkout that copies the same `.paperclip/worktrees` directory layout will receive the same exclusion. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - OpenAI Codex, GPT-5, context window not disclosed, with reasoning, tool use, and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
1791979512
commit
34fe57a024
|
|
@ -36,6 +36,9 @@ describe("resolveServerDevWatchIgnorePaths", () => {
|
|||
expect(ignorePaths).toContain(fs.realpathSync(path.join(sharedUiRoot, ".vite")));
|
||||
expect(ignorePaths).toContain(path.join(worktreeUiRoot, "dist"));
|
||||
expect(ignorePaths).toContain(fs.realpathSync(path.join(sharedUiRoot, "dist")));
|
||||
const sharedWorktreesRoot = path.join(tempRoot, "repo", ".paperclip", "worktrees");
|
||||
expect(ignorePaths).toContain(sharedWorktreesRoot);
|
||||
expect(ignorePaths).toContain(`${sharedWorktreesRoot.replaceAll(path.sep, "/")}/**`);
|
||||
expect(ignorePaths).toContain("**/{node_modules,bower_components,vendor}/**");
|
||||
expect(ignorePaths).toContain("**/.vite-temp/**");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ function addIgnorePath(target: Set<string>, candidate: string): void {
|
|||
}
|
||||
|
||||
export function resolveServerDevWatchIgnorePaths(serverRoot: string): string[] {
|
||||
const checkoutRoot = path.dirname(serverRoot);
|
||||
const linkedWorktreesRoot = path.dirname(checkoutRoot);
|
||||
const isLinkedWorktree =
|
||||
path.basename(linkedWorktreesRoot) === "worktrees" &&
|
||||
path.basename(path.dirname(linkedWorktreesRoot)) === ".paperclip";
|
||||
const ignorePaths = new Set<string>([
|
||||
"**/{node_modules,bower_components,vendor}/**",
|
||||
"**/.vite-temp/**",
|
||||
|
|
@ -28,6 +33,14 @@ export function resolveServerDevWatchIgnorePaths(serverRoot: string): string[] {
|
|||
"../ui/node_modules/.vite-temp",
|
||||
"../ui/.vite",
|
||||
"../ui/dist",
|
||||
// Git worktrees live under <repo>/.paperclip/worktrees, each a full
|
||||
// checkout (source + its own .paperclip). Watching them can add hundreds
|
||||
// of thousands of files, stalling tsx watch before it ever spawns the
|
||||
// server. None of them are part of this checkout's reloadable source.
|
||||
// A linked checkout has serverRoot at
|
||||
// <repo>/.paperclip/worktrees/<branch>/server. In that case, the shared
|
||||
// worktree directory is the checkout's parent, not a nested path.
|
||||
isLinkedWorktree ? "../.." : "../.paperclip/worktrees",
|
||||
// npm install during reinstall would trigger a restart mid-request
|
||||
// if tsx watch sees the new files. Exclude the managed plugins dir.
|
||||
process.env.HOME + "/.paperclip/adapter-plugins",
|
||||
|
|
|
|||
Loading…
Reference in New Issue