Skip to content

The open-source app everyone uses to manage agents at work

fix(server): ignore sibling worktrees in dev watch (#11074)

scotttong34fe57a0244f
diff --git a/server/src/__tests__/dev-watch-ignore.test.ts b/server/src/__tests__/dev-watch-ignore.test.ts
index 4f54e60988..42452310f5 100644
--- a/server/src/__tests__/dev-watch-ignore.test.ts
+++ b/server/src/__tests__/dev-watch-ignore.test.ts
@@ -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/**");
});
diff --git a/server/src/dev-watch-ignore.ts b/server/src/dev-watch-ignore.ts
index 4fe3769d16..20c97f33ef 100644
--- a/server/src/dev-watch-ignore.ts
+++ b/server/src/dev-watch-ignore.ts
@@ -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",