Skip to content

clens-009-edits-highlight-mismatch: TUI Edits tab: the highlighted file is not the file Enter opens - #18

Merged
silouone merged 1 commit into
mainfrom
adw/clens-009-edits-highlight-mismatch
Jul 23, 2026
Merged

silouone merged 1 commit into
mainfrom
adw/clens-009-edits-highlight-mismatch

Conversation

@silouone

Copy link
Copy Markdown
Owner

clens-009-edits-highlight-mismatch

Ticket: tickets/clens-009-edits-highlight-mismatch.md

All gates are green and the diff is minimal — only tui-formatters.ts production code changed, plus the earlier test file (untouched in this turn).

Summary of the fix

Root cause: both groupFilesByDirectory and groupFilesByAgent recomputed a display position (fileIdx = baseIdx + i via cumulative offsets) after re-sorting/re-grouping the files, then compared that position to highlightIndex — silently assuming display order matched the flat selection order it doesn't.

Fix: resolve the highlighted file by identity instead. In each function, before any sorting/grouping, compute:

const highlightedPath = highlightIndex !== undefined ? files[highlightIndex]?.file_path : undefined;

using the original files array (the flat, selection-order array the caller passed in — the same one getEditsFileList/Enter uses). Then each rendered entry's isHighlighted becomes highlightedPath !== undefined && f.file_path === highlightedPath, which is invariant to how the entry gets re-sorted or bucketed by directory/agent for display.

Since the offset-tracking machinery (groupOffsets, baseIdx, fileIdx, agentGroupOffsets, groupBaseIdx, dirOffsets, dirBaseIdx) existed solely to feed that now-removed position comparison, it was dead code after the fix and was removed to keep lint clean (no orphaned unused vars) — no other behavior changed.

Gates

  • bun run lint → ✅ green
  • bun run typecheck → ✅ green
  • bun run test → ✅ 1866 pass, 0 fail (includes the 4 previously-red regression tests, now green)

Changes are left uncommitted in the working tree as instructed.

Gates

  • lint — pass

  • typecheck — pass

  • test — pass

  • Gate suite ran in: 19318ms

  • Repair rounds used: 0

  • Total duration: 668408ms

  • Run id: clens-009-edits-highlight-mismatch-1784800379163

Captured sessions

  • 0a678616-f695-44c7-a765-e5f283053bde — /Users/silouane/adw-factory/runs/clens-009-edits-highlight-mismatch-1784800379163/.clens/sessions/0a678616-f695-44c7-a765-e5f283053bde.jsonl
  • 1a37194b-92dd-4340-b9c4-4f92f379e784 — /Users/silouane/adw-factory/runs/clens-009-edits-highlight-mismatch-1784800379163/.clens/sessions/1a37194b-92dd-4340-b9c4-4f92f379e784.jsonl

Opened by adw-factory. A human reviews and merges — the factory never merges,
approves, or closes its own pull requests.

@silouone
silouone merged commit be19414 into main Jul 23, 2026
1 check passed
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