fix(tui): avoid collisions between generated heading anchors #4205
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 304 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.342
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4205"
general
weight: 0.35
openrig-review
What a user gets
The TUI file reader resolves heading anchors uniquely when repeated headings collide with headings that already contain numeric suffixes. For
# Target,# Target-1,# Target, opening#target-2previously reported “Heading not found”; it now opens the third heading.Track both each base slug's suffix counter and every emitted anchor, including generated ones, before allocating the next slug. This also handles an authored
Target-1following a generatedtarget-1.How you verified it
Tested commit
25844a931a4aaf6e7a9c0088834c5d74ef1de1d2on Windows, Node 24.14.1:f2fe3e529with “Heading not found.”npx vitest run packages/tui/test/reading-anchor-fences.test.ts packages/tui/test/reading-regressions.test.ts packages/tui/test/reading-journey.test.ts— 11 passed; 12 journey tests could not execute because their shared setup'ssymlinkSyncfails with EPERM on this Windows account.reading-journey.test.tson clean basef2fe3e529reproduces the same 12 setup failures. Running the two other files alone on this commit passes all 11 tests.npm run build— passed.npm run lint— passed.git diff origin/main...HEAD --check— passed.npm testwas not rerun on this branch. An earlier attempt on the sibling host-label branch hit failures in unchanged repository packaging/policy/POSIX-oriented checks on Windows and was interrupted after it stopped making progress; workspace suites were not reached.Anything you were unsure about
Verification exercises file-reader output with fixtures, including existing fenced-example and combining-mark cases; no native terminal session was exercised.
If this is security-related
N/A.
CHANGELOG.mdedit<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Bug Fixes
Improved heading-anchor matching when repeated headings would otherwise produce slugs that conflict with existing headings.
Tests
Added coverage for anchor resolution with repeated headings and conflicting generated slugs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->