Skip to content

Prevent nested worktree sync traversal#236

Merged
parsakhaz merged 1 commit into
mainfrom
tbrownio/run-pane-dev-mode
Jun 15, 2026
Merged

Prevent nested worktree sync traversal#236
parsakhaz merged 1 commit into
mainfrom
tbrownio/run-pane-dev-mode

Conversation

@tbrownio

@tbrownio tbrownio commented Jun 13, 2026

Copy link
Copy Markdown

Why this matters

  • Some agents keep their own native workspace/worktree state under agent config directories such as .claude/worktrees or .codex/worktrees.
  • Pane's worktree file sync copies gitignored config directories into new Pane worktrees. If that parent directory contains generated worktrees state, a single recursive copy or recursive scan can enter a 5-10 GB tree and saturate disk bandwidth.
  • The fix needs to be agent-agnostic: lightweight config should sync, but generated worktree forests should be treated as a boundary unless the user explicitly opts into that exact path.

Summary

  • skip direct worktrees children when syncing root config directories such as .claude, .codex, or custom .agent entries
  • prune any directory named worktrees during Unix recursive/glob discovery before traversal
  • tighten Windows glob ignores to exclude both worktrees directories and their contents
  • preserve explicit user opt-ins like .agent/worktrees or worktrees as exact sync entries
  • add regression coverage for Claude, Codex, custom agent roots, explicit opt-in, and recursive prune behavior

Visual Overview

worktrees is now a traversal boundary for default/parent sync. Pane can copy config beside it, but does not cross into generated workspace state unless the user explicitly syncs that exact path.

flowchart LR
  subgraph Before[Before: parent directory copy]
    A[Pane syncs .agent] --> B[recursive copy / recursive scan]
    B --> C[.agent/settings.json copied]
    B --> D[.agent/worktrees/... entered]
    D --> E[huge generated workspace
GBs + high file count
app or machine stalls]
  end

  subgraph After[After: generated workspace boundary]
    F[Pane syncs .agent] --> G[enumerate direct children]
    G --> H[copy .agent/settings.json]
    G --> I{child name is worktrees?}
    I -->|yes| J[skip before traversal]
    I -->|explicit exact entry| K[copy only when user opted in]
    L[recursive discovery] --> M[find/glob prunes worktrees dirs]
  end
Loading

Excalidraw source saved locally at /tmp/codex-pr-diagrams/pr-236/worktree-sync-no-traverse.excalidraw.

Verification

  • pnpm --filter main exec vitest run src/services/__tests__/worktreeFileSyncService.test.ts
  • pnpm --filter main typecheck
  • pnpm --filter main lint (passes with existing warnings)
  • pre-commit hook also ran workspace pnpm run -r typecheck and pnpm run -r lint

Note: this shell uses Node v20.19.3, so pnpm emitted the existing engine warning because the repo asks for Node >=22.14.0. The commands still exited successfully.

@tbrownio tbrownio force-pushed the tbrownio/run-pane-dev-mode branch from 005d4c6 to edda1a4 Compare June 13, 2026 17:39
@tbrownio tbrownio added the bug Something isn't working label Jun 13, 2026
@tbrownio tbrownio self-assigned this Jun 13, 2026
@parsakhaz parsakhaz force-pushed the tbrownio/run-pane-dev-mode branch from edda1a4 to 7db21fd Compare June 15, 2026 18:44
@parsakhaz parsakhaz changed the title Prevent heavy worktree sync stalls Prevent nested worktree sync traversal Jun 15, 2026
@parsakhaz parsakhaz merged commit a2b5f91 into main Jun 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants