Skip to content

Fix folder-mode cold-start refs scan - #1306

Merged
backnotprop merged 1 commit into
mainfrom
codex-fix-folder-watch-cold-start
Aug 13, 2026
Merged

backnotprop merged 1 commit into
mainfrom
codex-fix-folder-watch-cold-start

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Summary

  • replace the recursive .git/refs watcher with five bounded exact Git metadata targets
  • preserve worktree content watching and Git-status refreshes through HEAD, index, logs/HEAD, packed-refs, and the current symbolic ref
  • enforce non-recursive Git metadata watching in both Bun and Pi runtimes
  • add deterministic regression coverage for large refs trees and packed current refs

Root cause

The live folder watcher added in #931 initialized chokidar against the entire Git common refs directory after the first file-tree snapshot. #935 delayed watcher setup, but first-file selection could still overlap that recursive initialization. On this checkout, .git/refs contains 1,714 files across 161 directories.

Measurement

A standalone chokidar-ready timer on the same checkout measured 23,102 ms and 25,631 ms before this change. With the five exact targets, the final measurement is 29.7 ms. The regression tests assert the target set directly and do not use timing thresholds.

Behavior tradeoff

Changes to unrelated branches and tags no longer trigger redundant file-tree status refreshes. Current worktree content, staging, commits, resets, branch movement, and packed-ref updates remain covered by exact targets.

Verification

  • bun test packages/shared/workspace-status.test.ts packages/server/reference-watch.test.ts apps/pi-extension/server/file-browser-watch.test.ts (31 pass)
  • bun run typecheck
  • bun run build:pi
  • bun build apps/hook/server/index.ts --target=bun --outfile <temp>/plannotator.js

@backnotprop
backnotprop merged commit 14e5c9e into main Aug 13, 2026
26 checks passed
dylanvanh pushed a commit to dylanvanh/plannotator that referenced this pull request Aug 25, 2026
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