feat: overhaul document viewer page (smart summary, badges, flattened evidence, flowing source text) - #492
Conversation
… evidence, flowing source text) - Add display-time smart summary formatter (document-summary-formatting.ts): strips glued PDF-header boilerplate, dedupes repeated passages, sections inline numbered headings, repairs mid-word truncated tails. Works on all stored summaries without re-indexing. - Add summary badge system (document-summary-badges.ts): safety-relevant labels + detected phrases render as tone-ordered ClinicalBadge cluster; new flags registered in the colour-coding catalogue; DocumentTagCloud colours unified with the canonical semantic-tone system app-wide. - Flatten pinned source evidence card: single quiet panel, no accent left borders/ring/solid header bar; excerpts flow via flowIndexedText. - Fix indexed source text: merge soft-wrap continuation blocks, recognise multi-level numbered headings, render as flowing typography instead of per-line bordered cards. - Remove meta-only Document details card: warnings become an InlineNotice at the sidebar top, index metadata demoted to a collapsed "Indexing details" disclosure, tables/diagrams count folded into that section. - Route the Overview hero through the formatter (was leaking boilerplate). - Extend demo data with labels/summary/indexHealth so the page is fully previewable in demo mode; add vitest suites for formatter + badges and a ui-smoke spec for the redesigned sidebar. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Warning Review limit reached
Next review available in: 12 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe document viewer now formats stored clinical summaries, derives semantic badges from labels and summary text, reflows indexed excerpts, exposes enriched demo metadata, and presents warnings and indexing details in updated viewer sections. ChangesDocument viewer enrichment
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant DemoPayload
participant DocumentViewer
participant SummaryFormatter
participant BadgeBuilder
DemoPayload->>DocumentViewer: labels, summary, indexHealth
DocumentViewer->>SummaryFormatter: stored summary text
SummaryFormatter-->>DocumentViewer: formatted sections
DocumentViewer->>BadgeBuilder: labels and summary text
BadgeBuilder-->>DocumentViewer: semantic badges
DocumentViewer-->>DocumentViewer: render viewer sections
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error)
✅ Passed checks (10 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)❌ Error creating Unit Test PR.
✨ Simplify code
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a17bc92059
ℹ️ 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: 3
🤖 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-badges.ts`:
- Line 59: Update the contraindication rule in the badge matching configuration
to ignore occurrences negated by phrases such as “not contraindicated” and “no
contraindications.” Make the matching logic inspect the surrounding occurrence
or sentence before assigning the danger badge, and add regression coverage for
both negated forms while preserving matches for actual contraindications.
In `@src/lib/indexed-source-formatting.ts`:
- Around line 193-203: Update flowIndexedText to normalize CRLF sequences
atomically before converting standalone carriage returns, ensuring each Windows
line ending becomes a single newline. Preserve the existing whitespace cleanup
and flow heuristic for the resulting normalized text.
- Around line 16-19: Update the heading detection logic in the visible predicate
to exclude decimal measurement/value lines such as “12.5 mg” and “2.5 mmol/L”
while continuing to recognize valid multi-level and top-level numbered headings.
Add a regression test covering these dose examples and preserving expected
heading matches.
🪄 Autofix (Beta)
❌ Autofix failed (check again to retry)
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: 8f38f074-a244-411b-8283-0394f0b954a1
📒 Files selected for processing (13)
src/components/DocumentTagCloud.tsxsrc/components/DocumentViewer.tsxsrc/lib/demo-data.tssrc/lib/document-summary-badges.tssrc/lib/document-summary-formatting.tssrc/lib/indexed-source-formatting.tssrc/lib/semantic-flags.tssrc/lib/source-text-sanitizer.tstests/demo-data.test.tstests/document-summary-badges.test.tstests/document-summary-formatting.test.tstests/indexed-source-formatting.test.tstests/ui-smoke.spec.ts
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. ❌ Cannot run autofix: This PR has merge conflicts. Please resolve the conflicts with the base branch and try again. Alternatively, use |
|
@codex fix all issues blocking merge including comments |
…esign Reconcile two redesigns of /documents/[id]. #489 restructured layout (document-first hero, sticky evidence rail, section anchors); this branch adds the content-quality fixes (#492): smart summary formatter, badge system, flattened pinned evidence, flowing indexed source text, and removal of the meta "Document details" card. Conflict resolution in DocumentViewer.tsx: - Keep #489's sticky-rail <aside> (grid + lg:sticky); nest my extraction- warnings InlineNotice inside it (md:col-span-2 lg:col-span-1). - Drop #489's trimmed "Document details" counts card (user feedback: meta content); my high-yield summary section already owns id="source-summary". - Re-add the indexHealth state + fetch wiring #489 removed, so extraction warnings stay visible and the demoted "Indexing details" disclosure works. - Span the high-yield summary and indexing-details full width on md now that their grid pair (the details card) is gone. Verified: tsc, eslint, prettier, 108 unit tests, no duplicate ids, zero horizontal overflow at 768/1440 light+dark. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 74f7a691ec
ℹ️ 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".
Summary
Testing
|
|
Note Unit test generation is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Generating unit tests... This may take up to 20 minutes. |
- 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>
|
Thanks — all review findings addressed in c2cfd57, with regression tests for each:
Verification: Note: this branch also merged current |
|
Request timed out after 900000ms (requestId=8a543201-4535-4d57-bc5c-094657fa153d) |
Summary
UX/UI overhaul of
/documents/[id]driven by direct user feedback on the live page:src/lib/document-summary-formatting.ts) — the storeddocument_summaries.summaryrenders through a display-time formatter that strips glued PDF-header boilerplate ("OFFICIAL … Reference #: … Scope Site Disciplines …"), deduplicates passages repeated 2–3×, converts inline numbered headings ("1. Introduction", "2.7. Dosage") into real sections with bullet items, and repairs mid-word truncated tails. Applies to all ~2,000 already-indexed documents with no re-indexing. Boilerplate stripping carries the same clinical-signal keep-bias as the sanitizer's H2 rules (threshold-bearing/action sentences are never dropped; strip reverts if it would consume everything).src/lib/document-summary-badges.ts) — safety-relevant labels (Risk / Medication / Clinical action) plus phrases detected in the summary text render as a tone-orderedBadgeCluster(danger reserved for contraindications; S8 → warning + lock, per the badge governance guide). New flags registered inSEMANTIC_FLAG_CATALOGUEso/reference/colour-codingstays complete.DocumentTagCloudchip colours now derive from the same canonical tone map (visual-only change on its 4 other call sites).flowIndexedText.parseIndexedSourceTextmerges soft-wrap continuation blocks (no more sentences split across cards), recognises multi-level numbered headings, and the renderer is flowing typography (real lists / plain paragraphs) instead of per-line bordered cards.InlineNoticeat the sidebar top (clinical safety: never hidden); extraction quality / index version / indexed date demoted to a collapsed "Indexing details" disclosure at the sidebar bottom; tables/diagrams count folded into that section's description.All load-bearing selectors/strings asserted by existing Playwright specs are preserved (
pinned-source-evidence,highlighted-source-passage, "Highlighted source passage",toggle-full-passage,#source-summaryexactly once, mobile ordering, composer hide-on-scroll).Verification
npm run verify:cheap— components run individually: check:runtime, check:github-actions, sitemap:check, lint, typecheck all pass; full vitest passes with--fileParallelism=false(parallel run hit 15s-timeout flakes from concurrent local sessions saturating the machine; same suites pass untouched on main)npm run verify:ui— 123 passed / 2 failed in 15.2m; both failures are off-page cold-compile timeouts (answer quick links, services mode toggle) and pass on immediate warm re-run. All 7 document-viewer specs green, including a new spec covering the summary card badges, boilerplate absence, and the collapsed indexing-details disclosurenpm run verify:release— not run (no release claim)npm run format:check— all changed files clean (pre-existing CLAUDE.md CRLF artifact unrelated)npm run eval:retrieval:quality— n/a: no retrieval, ranking, selection, chunking, or scoring behavior changed (display-time rendering only)npm run eval:rag— n/a: answer generation and post-processing untouchednpm run check:production-readiness— run; fails only on missing live secrets in this demo-mode worktree (NEXT_PUBLIC_SUPABASE_URL / SUPABASE_SERVICE_ROLE_KEY / OPENAI_API_KEY absent by design), which the repo docs classify as expected in demo modenpm run check:deployment-readiness— n/a: no deployment behavior changedVisual QA: Playwright screenshots at 375 / 768 / 1440 in light and dark; zero horizontal overflow at every width.
Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy) — no env/config changesassertDemoDataAlloweddemo gate)Notes
DocumentViewer.tsxregions (branchclaude/document-viewer-redesign-55b68b); reconcile before merging both.🤖 Generated with Claude Code