fix: land document-viewer review fixes missed by #492 squash-merge - #505
Conversation
- badges: contraindication danger badge is now negation-aware — "no
contraindications" / "not contraindicated" no longer emit a false red
clinical stop signal (hasPositiveContraindication guard).
- indexed-source: isNumberedHeading no longer classifies decimal dose/value
lines ("12.5 mg", "2.5 mmol/L") as section headings (require a non-lowercase
token after the numeric prefix).
- indexed-source: flowIndexedText + parseIndexedSourceText normalize CRLF/CR
atomically (\r\n? -> \n) so Windows line endings don't become blank lines.
- summary formatter: only repair/flag a truncated tail when the RAW stored
summary actually ended with an ellipsis; a complete final sentence lacking
punctuation is left intact (no fabricated ellipsis, no false "trimmed"
notice). Demo fixture updated to a realistic "…narro..." truncation.
- Regression tests added for all four.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe changes refine document-summary badge matching, truncation-tail handling, numbered-heading detection, and newline normalization. Tests cover negated contraindications, truncated and complete endings, decimal values, and CRLF input. ChangesSummary processing behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 10 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (10 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b68c45a48
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/document-summary-formatting.ts`:
- Around line 337-356: Update the tail-repair logic around orderedSections and
repairTruncatedCompactTail to normalize any existing terminal Unicode ellipsis
before appending the repair marker. Ensure the helper receives a single trailing
ellipsis rather than duplicated “…” markers, while preserving the existing
repaired-tail replacement and drop behavior.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 87b4db36-bf70-4bb9-89fc-d7674ffffd30
📒 Files selected for processing (7)
src/lib/demo-data.tssrc/lib/document-summary-badges.tssrc/lib/document-summary-formatting.tssrc/lib/indexed-source-formatting.tstests/document-summary-badges.test.tstests/document-summary-formatting.test.tstests/indexed-source-formatting.test.ts
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 1 file(s) based on 1 unresolved review comment. Files modified:
Commit: The changes have been pushed to the Time taken: |
Fixed 1 file(s) based on 1 unresolved review comment. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
- Handle no-ellipsis truncated tails again (Codex): a final fragment that is a
prefix of another kept sentence ("Lithium is a narro" vs the full
"…narrow therapeutic index drug") is a cut-off repeat — drop + flag it, while
still leaving a complete, unique unpunctuated sentence intact.
- Strip a terminal Unicode "…" as well as ASCII dots before re-marking, so
repairTruncatedCompactTail never receives a doubled "… …" (CodeRabbit).
- Tests: no-ellipsis prefix-duplicate drop, explicit ellipsis repair, and the
complete-unpunctuated-sentence keep case; demo fixture reverted to a
no-ellipsis truncated repeat.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…xes' into claude/document-viewer-review-fixes # Conflicts: # src/lib/document-summary-formatting.ts
|
Both follow-up findings on the tail-truncation logic are resolved in e765b38 (which also incorporates the CodeRabbit auto-fix commit):
Verification: tsc / eslint / prettier clean; formatter, badges, indexed-source, and demo-data suites pass (41 focused + full suites green locally). |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/document-summary-formatting.ts`:
- Around line 337-372: Update the tail-repair loop around rawEndedTruncated and
repairTruncatedCompactTail so rawEndedTruncated only enables repair when the
exact raw-derived truncated sentence remains as the final item after
keepNewSentences deduplication. Track that sentence before deduplication or
compare its identity/content with last, and otherwise rely on
isTruncatedDuplicate without rewriting the surviving valid sentence.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ec4216d3-0899-42af-a720-39270865a29a
📒 Files selected for processing (3)
src/lib/demo-data.tssrc/lib/document-summary-formatting.tstests/document-summary-formatting.test.ts
✅ Files skipped from review due to trivial changes (1)
- src/lib/demo-data.ts
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/document-summary-formatting.ts`:
- Around line 337-372: Update the tail-repair loop around rawEndedTruncated and
repairTruncatedCompactTail so rawEndedTruncated only enables repair when the
exact raw-derived truncated sentence remains as the final item after
keepNewSentences deduplication. Track that sentence before deduplication or
compare its identity/content with last, and otherwise rely on
isTruncatedDuplicate without rewriting the surviving valid sentence.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ec4216d3-0899-42af-a720-39270865a29a
📒 Files selected for processing (3)
src/lib/demo-data.tssrc/lib/document-summary-formatting.tstests/document-summary-formatting.test.ts
✅ Files skipped from review due to trivial changes (1)
- src/lib/demo-data.ts
🛑 Comments failed to post (1)
src/lib/document-summary-formatting.ts (1)
337-372: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
sed -n '250,390p' src/lib/document-summary-formatting.tsRepository: BigSimmo/Database
Length of output: 6321
🏁 Script executed:
rg -n "keepNewSentences|rawEndedTruncated|messyLithiumSummary|repairTruncatedCompactTail|normalizeSentenceKey" src test tests fixturesRepository: BigSimmo/Database
Length of output: 3269
🏁 Script executed:
sed -n '145,220p' src/lib/document-summary-formatting.tsRepository: BigSimmo/Database
Length of output: 3213
🏁 Script executed:
sed -n '500,575p' src/lib/source-text-sanitizer.tsRepository: BigSimmo/Database
Length of output: 4661
🏁 Script executed:
sed -n '1,140p' tests/document-summary-formatting.test.tsRepository: BigSimmo/Database
Length of output: 7443
🏁 Script executed:
rg -n "unsafeTruncationTailPattern" src/lib/source-text-sanitizer.ts src/lib/document-summary-formatting.tsRepository: BigSimmo/Database
Length of output: 331
🏁 Script executed:
sed -n '1,120p' src/lib/source-text-sanitizer.tsRepository: BigSimmo/Database
Length of output: 8542
Gate tail repair on the surviving raw tail sentence
rawEndedTruncatedcan still triggerrepairTruncatedCompactTailafterkeepNewSentencesdrops the true truncated fragment as a long containment repeat, so the branch may rewrite the new last sentence and strip valid clinical text. Track the final raw-derived sentence before dedupe, or only repair when that exact item survives as the last item.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/document-summary-formatting.ts` around lines 337 - 372, Update the tail-repair loop around rawEndedTruncated and repairTruncatedCompactTail so rawEndedTruncated only enables repair when the exact raw-derived truncated sentence remains as the final item after keepNewSentences deduplication. Track that sentence before deduplication or compare its identity/content with last, and otherwise rely on isTruncatedDuplicate without rewriting the surviving valid sentence.
Summary
Follow-up to #492. That PR was squash-merged while its head was still the reconciliation commit, so the four review fixes I pushed afterward (in response to CodeRabbit/Codex) did not make it into
main. This PR lands exactly those fixes on top of currentmain(cherry-pick of the original review-fix commit; the three lib files are untouched onmainsince #492, so it applied cleanly). Each fix has a regression test.Negated contraindications → false danger badge (
document-summary-badges.ts, was CodeRabbit Major + Codex P2): theContraindicationsdanger badge now runs through ahasPositiveContraindicationguard that checks for a negation cue (no,not,non,without,nil,no known, …) before eachcontraindicat*match. "no contraindications" / "not contraindicated" no longer emit a red clinical-stop badge; a genuine contraindication still does. Clinical-safety relevant — an inverted danger badge is the highest-urgency signal in the summary cluster.Decimal doses classified as headings (
indexed-source-formatting.ts, CodeRabbit Major):isNumberedHeadingnow requires a non-lowercase token after the numeric prefix (\s+(?![a-z])\S), so "12.5 mg" / "2.5 mmol/L" stay paragraphs while Title-Case and digit-led headings still resolve.CRLF handling (
indexed-source-formatting.ts, CodeRabbit):flowIndexedTextandparseIndexedSourceTextnormalize\r\n?→\natomically, so a Windows line ending is one newline, not a spurious blank line.Complete unpunctuated final sentence truncated (
document-summary-formatting.ts, Codex P2): tail repair now only fires when the raw stored summary ended with a truncation ellipsis (captured before the sanitizer normalizes it away), so a complete final sentence lacking a period is left intact — no fabricated ellipsis, no false "trimmed" notice.Verification
tsc --noEmit,eslint,prettier --check— cleanverify:ui— n/a: these are display-time formatting/lib changes with existing UI coverage from feat: overhaul document viewer page (smart summary, badges, flattened evidence, flowing source text) #492; no new UI surfaceClinical Governance Preflight
Clinical KB Databasesjrfecxgysukkwxsowpy)🤖 Generated with Claude Code