Skip to content

Add condensed document reader view - #1380

Merged
BigSimmo merged 12 commits into
mainfrom
codex/document-reader-condensed-view
Jul 29, 2026
Merged

Add condensed document reader view#1380
BigSimmo merged 12 commits into
mainfrom
codex/document-reader-condensed-view

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds a persistent Condensed view / Full view toggle inside the existing document section navigator on desktop and phone.
  • Keeps section progress and navigation visible while condensing long indexed source text and clinical-priority detail by default.
  • Automatically reveals indexed text for section jumps, deep-linked evidence, in-document search, and printing.

Verification

  • npm run verify:pr-local

Verification not run: the repository's exclusive browser/build lease remained occupied by another active document-UI worktree. The dry-run plan was reviewed; hosted CI should run the complete gate.

  • npm run verify:ui when UI, routing, styling, browser behavior, reduced-motion, or forced-colors behavior changed

UI verification not run: the same coordinated browser lease was still active. Focused Playwright coverage was added for the density toggle, disclosure state, navigation, and print restoration.

  • npm run verify:release before release or handoff confidence claims
  • Focused Vitest: 5 files passed, 27 tests passed
  • Runtime check: Node 24.18.0 and npm 11.17.0
  • Installed-lock parity: Next 16.2.12, React 19.2.8, Playwright 1.62.0, TypeScript 6.0.3, Vitest 4.1.10
  • Maintainability budgets passed; DocumentViewer.tsx is 1615/1734 lines
  • git diff --check

Risk and rollout

  • Risk: Low-to-moderate document-reader UI state change. Existing section navigation, source text, citation jumps, and print output are preserved and covered by focused tests.
  • Rollback: Revert commit 6b36291.
  • Provider or production effects: None. No provider-backed, production, Supabase, OpenAI, or deployment workflow was run.

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy)
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative
  • Deployment classification/TGA SaMD impact was checked; no clinical decision-support behavior changed

Notes

  • Condensed view is the default and the reader's local preference persists in localStorage.
  • The original dirty checkout was not modified or included in this branch.

Summary by CodeRabbit

  • New Features

    • Added a compact document view toggle for desktop, tablet, and mobile layouts.
    • The selected view density is remembered across sessions and synchronized across open tabs.
    • Search results and deep links keep relevant source content visible in compact mode.
    • Document disclosures now expand appropriately when printing and restore afterward.
  • Bug Fixes

    • Improved disclosure and section navigation behavior when switching between compact and full views.
  • Tests

    • Expanded coverage for compact view, persistence, navigation, printing, and responsive interactions.

@supabase

supabase Bot commented Jul 29, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 24 minutes

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 34f9c211-42ce-4ed9-b7db-cdbbc5f286dd

📥 Commits

Reviewing files that changed from the base of the PR and between 3e96301 and 8cf5820.

📒 Files selected for processing (8)
  • docs/branch-review-ledger.md
  • src/components/DocumentViewer.tsx
  • src/components/document-viewer/document-rail-panels.tsx
  • src/components/document-viewer/source-panels.tsx
  • src/components/document-viewer/use-document-view-density.ts
  • tests/document-section-summary.dom.test.tsx
  • tests/document-view-density.dom.test.tsx
  • tests/ui-smoke.spec.ts
📝 Walkthrough

Walkthrough

Changes

The document viewer now supports a persisted compact/full density preference, density toggles across desktop and phone navigation, compact clinical-summary behavior, controlled indexed-text reveals, and extracted print disclosure handling.

Document viewer density and print integration

Layer / File(s) Summary
Density state and viewer wiring
src/components/DocumentViewer.tsx, src/components/document-viewer/use-*.ts, tests/document-view-density.dom.test.tsx, docs/branch-review-ledger.md
The viewer uses persisted density state and extracted print disclosure handling, then passes compact-mode state through its rendered sections and records validation results.
Density controls and summary propagation
src/components/document-viewer/document-*.tsx, src/components/document-viewer/section-*.tsx, tests/document-clinical-summary.dom.test.tsx, tests/document-section-*.test.ts*, tests/ui-smoke.spec.ts
Desktop and phone navigation expose the density toggle; compact state controls clinical priorities and marks indexed source text as collapsible, with DOM and UI smoke coverage.
Indexed text compact reveal behavior
src/components/document-viewer/source-panels.tsx, tests/document-section-summary.dom.test.tsx
Indexed source text uses controlled disclosure state to preserve selected or searched content, while forced reveals render inert summaries and remain open after accordion events.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Viewer
  participant DensityToggle
  participant DensityHook
  participant IndexedTextPanel
  Viewer->>DensityHook: read compact preference
  Viewer->>DensityToggle: render compact state and setter
  DensityToggle->>DensityHook: request full or compact mode
  DensityHook-->>Viewer: publish updated compact state
  Viewer->>IndexedTextPanel: pass compact state
  IndexedTextPanel->>IndexedTextPanel: preserve forced reveal for selected or searched content
Loading

Possibly related PRs

Suggested labels: codex

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding a condensed document reader view.
Description check ✅ Passed The description follows the required template and includes the main sections with useful verification, risk, and governance details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@BigSimmo

Copy link
Copy Markdown
Owner Author

@cursoragent Inspect the PR and repository state, identify the root cause of every failing CI check, unresolved review comment, merge conflict, and related defect. Apply the smallest robust fix using existing project patterns and best practices, without unrelated changes. Run Bugbot and all relevant lint, type-check, test, build, and CI-equivalent commands, fix any issues found, then resolve only the review comments that are fully addressed. Summarise the root causes, changes made, validation results, and any remaining blockers.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 29, 2026 04:20
@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

PR #1380 is green again. All required checks passed on the fix tip, including Production UI and CircleCI.

Root causes

  1. Lint / Static PR + CircleCI — three react-hooks/set-state-in-effect violations in density preference, clinical priorities, and indexed-text reveal.
  2. Format — Prettier drift in the follow-up files (CircleCI format:check).
  3. Codex P2 — full-view indexed-text <summary> looked collapsible but was inert.
  4. Production UI — condensed view + exclusive accordion could latch #source-text closed over a deep-linked chunk, so the highlighted passage stayed hidden.

Fixes (pushed on codex/document-reader-condensed-view)

  • Density → useSyncExternalStore (localStorage pattern)
  • Priorities / reveal → adjust-during-render
  • Full-view summary → non-interactive (aria-disabled, no chevron)
  • Deep-link reveal → forceReveal from chunk/search + restore after accordion closes
  • Ledger row appended for this babysit

Validation

Check Result
lint, format:check, typecheck, verify:cheap pass
Focused Vitest (document density/summary/nav) pass
Local Playwright condensed-view smoke (4 tests) 4 passed
Hosted Static / Build / Unit / Advisory / Production UI / PR required / CircleCI pass

Reviews

  • Codex P2 thread resolved after the inert-summary fix.
  • No unresolved cursor[bot] Bugbot threads (Bugbot agent run found the lint issues above; no separate Bot comments).

Remaining

  • None blocking merge on the fix tip. A docs-only ledger commit (3e96301f) may still be finishing CI; it should not reintroduce product failures.
  • Merge remains a human action.
Open in Web Open in Cursor 

@BigSimmo

Copy link
Copy Markdown
Owner Author

@codex review PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 88d27ab6ec

ℹ️ 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".

Comment thread src/components/document-viewer/source-panels.tsx Outdated
@BigSimmo

Copy link
Copy Markdown
Owner Author

@CodeRabbit review PR

@BigSimmo

Copy link
Copy Markdown
Owner Author

@codex resolve actionable Codex review findings for this pull request and current head using the repository instructions. This is the pull request's single automatic repair pass: do not perform a fresh review, create new standalone findings, or request another review. Work only the existing unresolved Codex threads on the current head. Always fix P0 and P1 findings. For P2 and lower findings, fix only clear, scoped, low-risk issues; otherwise disposition them with a concise reason. After fixing or dispositioning a thread, reply in that thread with as the first line, followed by a concise summary; that marker authorizes the workflow to close that exact thread. If human input or new authorization is required, do not use the marker and leave the thread open with the blocker. Finish only after every actionable thread is fixed or dispositioned and closed, or explicitly left open for a human decision. Do not update the branch from main, address unrelated reviews, broaden scope, or create more than one scoped fix commit. Do not use external APIs, paid services, credentials, dependency changes, or broad refactors unless explicitly authorized. Add targeted tests where behavior changes and run the narrowest relevant validation.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@BigSimmo I’ll review PR #1380, focusing on the condensed reader state, navigation/disclosure behavior, persistence, accessibility, and print restoration.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 88d27ab6ec

ℹ️ 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".

cursoragent and others added 2 commits July 29, 2026 04:34
Replace setState-in-effect density/disclosure sync with useSyncExternalStore
and adjust-during-render patterns so Static PR checks and CircleCI lint pass.
Make the full-view indexed-text summary non-interactive so it no longer
advertises a collapse control that cannot activate.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Keep format:check green for CircleCI and Static PR checks.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

CI triage

CI failed on this PR. Automated classification of the 2 failed job(s):

  • Production UIneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • PR requiredneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.

Compared with main CI run #6463 (success).

Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger.

cursoragent and others added 2 commits July 29, 2026 05:01
Condensed view was latching closed when exclusive-accordion toggles raced
deep-linked chunks, hiding highlighted passages in Production UI. Force
reveal from selectedChunkId/search, ignore collapse while forced, and
restore open after browser toggle settlement.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
tests/document-section-summary.dom.test.tsx (1)

41-86: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Consider covering the search-driven reveal and the plain compact-collapse path.

This test exercises only the selectedChunkId branch of forceReveal. The normalizedSearch branch and the ordinary compact behavior (no deep link, user collapses, stays collapsed) are the paths most likely to regress from the onToggle logic.

🤖 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 `@tests/document-section-summary.dom.test.tsx` around lines 41 - 86, Extend the
“IndexedTextPanel condensed reveal” tests to cover forceReveal via
normalizedSearch without selectedChunkId, verifying the matching content stays
revealed through summary and toggle interactions. Add a separate plain compact
case with no deep link or search, confirming the panel starts open, can be
collapsed by the user, and remains collapsed after the toggle settles.
src/components/document-viewer/source-panels.tsx (1)

455-476: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider distinct keys on the inert vs. interactive <summary>.

Both branches render <summary> in the same slot, so when interactive flips React reuses the same DOM node and swaps the handler in place rather than remounting. Impact here is benign (worst case one click toggles or no-ops), but distinct keys make the swap explicit and avoid stale-handler surprises if this header later gains stateful behavior.

Based on learnings: "when conditionally replacing a control ... ensure the two rendered controls do not reuse the same DOM node. Give the alternative controls distinct React keys (so React remounts instead of swapping handlers in-place)".

♻️ Proposed keys
   if (!interactive) {
     return (
       <summary
+        key="static"
         aria-disabled="true"
         tabIndex={-1}
   return (
     <summary
+      key="interactive"
       onClick={onClick}
       className="flex min-h-[72px] cursor-pointer list-none items-center justify-between gap-3 px-4 py-3"
     >
🤖 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/components/document-viewer/source-panels.tsx` around lines 455 - 476, Add
distinct React keys to the inert and interactive `<summary>` elements in the
conditional rendering branch, using stable, branch-specific values so React
remounts the element when `interactive` changes instead of reusing its DOM node
and swapping handlers.

Source: Learnings

🤖 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/components/document-viewer/use-document-view-density.ts`:
- Around line 28-35: Update setCompact in the document view density hook to
always retain the new density in an in-memory fallback when localStorage.setItem
fails, then dispatch documentViewDensityEvent regardless of persistence success.
Preserve localStorage persistence when available and ensure subscribers receive
the updated value in both paths.

---

Nitpick comments:
In `@src/components/document-viewer/source-panels.tsx`:
- Around line 455-476: Add distinct React keys to the inert and interactive
`<summary>` elements in the conditional rendering branch, using stable,
branch-specific values so React remounts the element when `interactive` changes
instead of reusing its DOM node and swapping handlers.

In `@tests/document-section-summary.dom.test.tsx`:
- Around line 41-86: Extend the “IndexedTextPanel condensed reveal” tests to
cover forceReveal via normalizedSearch without selectedChunkId, verifying the
matching content stays revealed through summary and toggle interactions. Add a
separate plain compact case with no deep link or search, confirming the panel
starts open, can be collapsed by the user, and remains collapsed after the
toggle settles.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0a51f7a2-3f49-48dd-a7b3-f56d73a362de

📥 Commits

Reviewing files that changed from the base of the PR and between 7695b36 and 3e96301.

📒 Files selected for processing (16)
  • docs/branch-review-ledger.md
  • src/components/DocumentViewer.tsx
  • src/components/document-viewer/document-clinical-summary.tsx
  • src/components/document-viewer/document-overview-landing.tsx
  • src/components/document-viewer/document-rail-panels.tsx
  • src/components/document-viewer/section-index.ts
  • src/components/document-viewer/section-nav.tsx
  • src/components/document-viewer/source-panels.tsx
  • src/components/document-viewer/use-document-view-density.ts
  • src/components/document-viewer/use-printable-disclosures.ts
  • tests/document-clinical-summary.dom.test.tsx
  • tests/document-section-index.test.ts
  • tests/document-section-nav.dom.test.tsx
  • tests/document-section-summary.dom.test.tsx
  • tests/document-view-density.dom.test.tsx
  • tests/ui-smoke.spec.ts

Comment thread src/components/document-viewer/use-document-view-density.ts
@BigSimmo

Copy link
Copy Markdown
Owner Author

@cursoragent Inspect the PR and repository state, identify the root cause of every failing CI check, unresolved review comment, merge conflict, and related defect. Apply the smallest robust fix using existing project patterns and best practices, without unrelated changes. Run Bugbot and all relevant lint, type-check, test, build, and CI-equivalent commands, fix any issues found, then resolve only the review comments that are fully addressed. Summarise the root causes, changes made, validation results, and any remaining blockers.

@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

PR #1380 is merged (855aa291 on main). Required CI was green on the merge tip (8cf58207).

Root causes

  1. Merge conflict / DIRTYmain kept moving; real content conflict once in source-panels.tsx (condensed <details> vs main’s plain section + tracking-eyebrow). Later DIRTY states were staleness (merge-tree clean).
  2. CodeRabbit (actionable) — density toggle early-returned on localStorage.setItem failure, so the control did nothing when storage was blocked.
  3. CodeRabbit nitpicks — missing distinct summary keys; incomplete forceReveal/collapse tests.
  4. Earlier CI (already fixed before this turn)set-state-in-effect, prettier drift, inert full-view summary, deep-link chunk hidden under exclusive accordion.

Changes made

  • In-memory transientCompactPreference + always dispatch density event (use-document-view-density.ts)
  • Distinct static/interactive summary keys; search forceReveal + plain compact collapse tests
  • Repeated origin/main merges (kept condensed details + tracking-eyebrow)
  • CodeRabbit density thread resolved; Bugbot: no open P0/P1
  • Ledger rows appended for the babysit

Validation

Check Result
Hosted Static / Build / Unit / Advisory / Production UI / PR required / CircleCI pass on 8cf58207 (merged)
Local Vitest document suites 24/24
Full unit suite via verify:cheap 4379 passed
lint / typecheck / format:check pass
Unresolved review threads none

Remaining

  • None blocking — PR is merged; density fallback is on main.
  • Cleanup candidate only: post-merge push recreated codex/document-reader-condensed-view at b5cdbf30 (empty resync after merge). Safe to delete remotely if you want; I did not delete it.
Open in Web Open in Cursor 

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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 @coderabbitai resolve merge conflict to automatically resolve the conflicts.

cursoragent and others added 6 commits July 29, 2026 11:26
Resolve source-panels conflict by keeping condensed details/forceReveal
behavior and adopting main's tracking-eyebrow token. Also keep the density
toggle usable when localStorage is blocked (in-memory fallback) and extend
condensed reveal coverage for search and plain collapse paths.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Append the merge/conflict-resolution and CodeRabbit density-fallback outcome for tip 7cefb24.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Resync after main advanced with ledger closeout #1382.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Resync after main landed #1383; merge-tree was already clean.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Keep PR tip current after CI green; main advanced by one commit.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Note hosted Production UI / PR required success and post-CI main resync.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo
BigSimmo merged commit 855aa29 into main Jul 29, 2026
19 checks passed
@BigSimmo
BigSimmo deleted the codex/document-reader-condensed-view branch July 29, 2026 12:16
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.

2 participants