Skip to content

fix: skip stack autodetect in file mode; remove CRIT_NO_AUTODETECT#423

Merged
tomasz-tomczyk merged 1 commit intomainfrom
fix/autodetect-file-mode
May 2, 2026
Merged

fix: skip stack autodetect in file mode; remove CRIT_NO_AUTODETECT#423
tomasz-tomczyk merged 1 commit intomainfrom
fix/autodetect-file-mode

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Summary

  • crit some-file.md on a stacked branch was being silently promoted into range mode, throwing away the file argument and rebuilding the file list from a SHA range.
  • Root cause: the autodetect guard in applySessionOverrides (added in feat: PR-scoped and commit-range review (#300) #391) didn't check for file mode — only for --working-tree and the CRIT_NO_AUTODETECT env var.
  • Fix: add len(sc.files) == 0 to the guard so file-mode invocations skip autodetect.
  • Also removes CRIT_NO_AUTODETECT — unused (no CI, no docs, no scripts referenced it) and redundant with --working-tree.

Review

  • Code review: passed (Go-only, no parity/security surface)
  • Tests: go test ./... clean; go vet/golangci-lint clean
  • Regression test added: TestAutoDetect_FileMode_Bypasses

Test plan

  • crit docs/some-spec.md from a stacked branch now opens the file (file mode), not the stack range
  • crit (no args) still autodetects the stack as before
  • crit --working-tree still bypasses autodetect

🤖 Generated with Claude Code

PR #391 introduced stacked-PR / local-stack autodetect but didn't gate
it on file mode. Running `crit some-file.md` while sitting on a stacked
branch silently promoted the session into range mode, throwing away the
file argument and rebuilding the file list from a SHA range.

Fix: add `len(sc.files) == 0` to the autodetect guard in
applySessionOverrides.

Also rip out the CRIT_NO_AUTODETECT escape hatch — it was unused (no CI,
no docs, no scripts referenced it) and redundant with --working-tree,
which is the discoverable, documented bypass.

Adds TestAutoDetect_FileMode_Bypasses regression test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tomasz-tomczyk tomasz-tomczyk merged commit 9a8811a into main May 2, 2026
6 checks passed
@tomasz-tomczyk tomasz-tomczyk deleted the fix/autodetect-file-mode branch May 2, 2026 10:14
@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.30%. Comparing base (3820908) to head (e3cf339).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #423      +/-   ##
==========================================
+ Coverage   67.28%   67.30%   +0.01%     
==========================================
  Files          26       26              
  Lines        9690     9689       -1     
==========================================
+ Hits         6520     6521       +1     
+ Misses       2658     2656       -2     
  Partials      512      512              
Flag Coverage Δ
e2e 34.06% <100.00%> (-0.04%) ⬇️
unit 63.52% <0.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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