Skip to content

fix(server): detect file changes inside untracked directories on refresh - #1739

Merged
chuks-qua merged 1 commit into
mainfrom
fix/1735-untracked-dir-refresh
Sep 22, 2026
Merged

chuks-qua merged 1 commit into
mainfrom
fix/1735-untracked-dir-refresh

Conversation

@chuks-qua

@chuks-qua chuks-qua commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What

file.refresh fingerprinted git status --porcelain, which collapses untracked directories into a single ?? dir/ line. Adding or removing a file inside an already-untracked directory never moved the dirty-set fingerprint, so files.changed never broadcast and cached @ file autocomplete stayed stale across attention refreshes.

The refresh now runs git status --porcelain --untracked-files=all, expanding untracked directories to per-file entries — the same granularity file.list already uses via git ls-files --others --exclude-standard. Ignore rules, the bounded single-status-call design, and per-scope baselines are unchanged.

Verified end to end on the live worktree runtime: public WS file.refresh baseline → external write of verify1735/alpha.ts inside a new untracked dir → files.changed{changedPaths:["verify1735/alpha.ts"]} push (removal too). In the real web app, reopening the @ picker after an external write shows the new file without a restart (screenshots attached).

Why

Closes #1735. Users directing agents hit stale file autocomplete when an agent or external tool creates files inside a new directory; the cached list silently missed them even after reopening the picker.

UI Changes

Behavioral fix with UI evidence attached: before, the @ picker lacks verify1735-ui/beta.ts; after an external write plus one attention refresh, the reopened picker lists it.

Review Notes

  • Regression suite (audit-untracked-file-refresh.test.ts) uses real git against temp repos: add, remove, nested dirs, unchanged set, ignored files, staging (?? f → A f intentionally stays silent, matching single-file staging), and status.showUntrackedFiles=no override. Red-before/green-after confirmed against the audit's pinned reproduction.
  • New ws-events tests pin the consumer side: files.changed clears the autocomplete cache and bumps the diff revision for both thread and workspace scopes.
  • Known pre-existing edge, slightly amplified: execFile's 1 MiB maxBuffer can make refresh return null on repos with huge unignored untracked trees. list() shares the exposure; not introduced here.

ui-02-picker-baseline

ui-03-picker-after-add


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

git status --porcelain collapses untracked directories into a single
"?? dir/" line, so adding or removing a file inside an already-untracked
directory never moved the dirty-set fingerprint. file.refresh returned
null, no files.changed broadcast fired, and cached file autocomplete
stayed stale across attention refreshes.

Fingerprint with --untracked-files=all so untracked directories expand
to per-file entries, matching the granularity list() already uses via
git ls-files --others --exclude-standard. Ignore rules are unchanged.

Adds real-git regression coverage for add, remove, nested dirs, staging,
unchanged sets, ignored files, and repo config overrides, plus a
consumer invalidation test for files.changed on the web client.

Closes #1735

Generated with [Devin](https://devin.ai)
@chuks-qua
chuks-qua merged commit c252f9c into main Sep 22, 2026
6 checks passed
@chuks-qua
chuks-qua deleted the fix/1735-untracked-dir-refresh branch September 22, 2026 08:56
chuks-qua added a commit that referenced this pull request Sep 22, 2026
Combines with #1739's --untracked-files=all status flag: refresh now
runs `status --porcelain --untracked-files=all -z` so untracked
directories expand per file and paths arrive unquoted.
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.

bug(files): attention refresh misses new files inside an already-untracked directory

1 participant