Skip to content

fix: count every file in a new directory, not the directory#96

Merged
omartelo merged 1 commit into
mainfrom
fix/untracked-dir-file-count
Jul 25, 2026
Merged

fix: count every file in a new directory, not the directory#96
omartelo merged 1 commit into
mainfrom
fix/untracked-dir-file-count

Conversation

@omartelo

@omartelo omartelo commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Problem

A session writing a whole new package showed 4 changed files in the footer and on its session card, while the Review tab listed 25.

Diff counted the lines of git status --porcelain. Git's default --untracked-files=normal collapses an untracked directory into one entry:

 M a.txt
?? src/          <- 2 new files in here, reported as 1

The +1175 -0 line totals were right the whole time — they come from ls-files --others --exclude-standard, which lists files, never directories.

Fix

Pass --untracked-files=all to the status call (internal/project/project.go). One flag; the untracked-line counting below it is unchanged.

worktree.go also runs status --porcelain, but only to decide dirty vs clean — the collapse cannot change that answer, so it stays as is.

Test plan

  • New case in TestDiff: two untracked files inside a fresh nested directory. Reports Files:4 without the flag (the exact symptom), Files:5 with it.
  • gofmt -l . clean, go vet ./... clean, go test ./... — 400 passed.
  • Frontend gate green even though it is untouched: biome check clean (12 pre-existing a11y warnings), vitest run 406 passed in 43 files, tsc --noEmit clean, vite build succeeds.

The changed-file count read `git status --porcelain`, whose default
`--untracked-files=normal` reports an untracked directory as a single
`?? pkg/` entry. An agent writing 25 files into fresh packages showed 4
changed files in the footer and on the session card while the Review tab
listed all of them.

Ask git for every untracked file instead. The added/deleted totals were
already right — they come from `ls-files --others`, which never collapsed.
@omartelo
omartelo merged commit 8f712e7 into main Jul 25, 2026
3 checks passed
@omartelo
omartelo deleted the fix/untracked-dir-file-count branch July 25, 2026 22:37
@omartelo omartelo mentioned this pull request Jul 25, 2026
6 tasks
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