Skip to content

P2: Background git reads take index.lock and read every untracked file on the main process #1520

Closed

Description

@currentbits

There are two problems in the background git polling.

  1. Lock contention with the agent. Read-only git status calls refresh the index and take index.lock, so they can make the agent's own git commit/git add fail mid-run. GIT_OPTIONAL_LOCKS is not set anywhere in electron/; the gitTryAsync env (electron/worktrees-git.js:372-376) only sets GIT_TERMINAL_PROMPT. Fix: set GIT_OPTIONAL_LOCKS=0 on every read-only git call (status, diff, log, rev-parse).

  2. Unbounded untracked scan. The Changes scan runs status --porcelain -uall (electron/worktrees-changes.js:206). For each untracked file it then calls fs.readFileSync on the main process, only to count lines (:274-291). There is no count or size cap. A build output dir with no ignore rule (thousands of files, or large binaries) stalls the UI. Fix: cap the count (e.g. the first 500 untracked entries get line counts, the rest report 0 with a "+N more" note) and skip files over ~1 MB. Or move the counting to async reads with a budget.

Size: S each.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions