Skip to content

perf: keep document administration UI off the initial dashboard bundle - #1562

Merged
BigSimmo merged 11 commits into
mainfrom
codex/review-latency-and-lazy-loading-optimizations
Aug 1, 2026
Merged

perf: keep document administration UI off the initial dashboard bundle#1562
BigSimmo merged 11 commits into
mainfrom
codex/review-latency-and-lazy-loading-optimizations

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Reduce initial client bundle weight and visible-latency by preventing the full document administration UI from being pulled into the dashboard entry chunk.
  • Preserve lazy-loading boundaries and keep always-visible, small status UI in a minimal client chunk to improve perceived load and LCP.
  • Make the document-admin surface remain behind existing dynamic imports so administration code only loads on demand.

Description

  • Extracted a dependency-free contract module with types and small fallback state: src/components/clinical-dashboard/document-manager-contracts.ts to avoid importing heavy admin code from the dashboard.
  • Moved the compact library health summary into a focused client component: src/components/clinical-dashboard/library-health-strip.tsx which preserves loading skeleton and content-visibility optimizations.
  • Updated the dashboard to import only the contracts and the new lightweight health-strip instead of the full admin panel: changes in src/components/ClinicalDashboard.tsx.
  • Kept compatibility exports in DocumentManagerPanel while re-exporting lightweight types from the contract file so the full admin surfaces remain behind existing dynamic imports: changes in src/components/clinical-dashboard/DocumentManagerPanel.tsx.
  • Added a static regression assertion to guard the import boundary: tests/client-performance-boundaries.test.ts (asserts dashboard no longer statically imports the administration module).

Testing

  • Ran typecheck with npm run typecheck and it passed with no errors.
  • Ran lint with npm run lint -- --no-cache and it passed (no blocking warnings).
  • Ran the full unit test suite with npm run test and the results were: 463 test files, 4,811 tests passed and 1 skipped.
  • Built production with npm run build and the Next.js production build completed successfully and the client-bundle secret scan passed.
  • Measured client bundle with npm run check:bundle-budget -- --json: current gzip total 1,434,092 bytes across 293 chunks, verdict within tolerance (≈+9.53% vs baseline; enforcement enabled).
  • Ran the repository ledger/verification and npm run verify:pr-local -- --dry-run --files ... (dry-run) to produce the PR-local verification plan; plan was generated successfully.
  • Note: an attempt to run a focused test run was rejected by repo policy because the test file changed; the full suite was executed instead.

Files changed/added (key):

  • Added src/components/clinical-dashboard/document-manager-contracts.ts (types & fallback checks).
  • Added src/components/clinical-dashboard/library-health-strip.tsx (small client component).
  • Modified src/components/ClinicalDashboard.tsx (now imports contracts + health strip instead of admin module).
  • Modified src/components/clinical-dashboard/DocumentManagerPanel.tsx (kept exports, removed types to contracts).
  • Modified tests/client-performance-boundaries.test.ts (assert import boundary).

All automated checks listed above completed successfully and the bundle-budget check is within the enforced budget.


Codex Task

Summary by CodeRabbit

  • New Features

    • Added a library health summary showing document, setup, indexing, and failure statuses.
    • Added accessible actions for navigating to relevant dashboard areas.
    • Improved loading-state presentation with clear skeleton indicators.
  • Bug Fixes

    • Improved phone overlay behavior during scrolling and viewport resizing.
    • Prevented temporary measurements from causing incorrect spacing or hidden interface elements.
  • Tests

    • Expanded coverage for dashboard loading boundaries, responsive overlays, and viewport-resize stabilization.

@supabase

supabase Bot commented Aug 1, 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 Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a5a2842a-4800-4b02-90a5-acc0005f861e

📥 Commits

Reviewing files that changed from the base of the PR and between 7f555b7 and 26a3c4a.

📒 Files selected for processing (2)
  • docs/branch-review-ledger.md
  • src/components/clinical-dashboard/library-health-strip.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/clinical-dashboard/library-health-strip.tsx
  • docs/branch-review-ledger.md

📝 Walkthrough

Walkthrough

The dashboard separates administration contracts and library health rendering into dedicated modules. Phone overlay reserve measurement uses fallback heights and preserves valid CSS state during transient zero-height measurements. Tests cover import boundaries, measurement behavior, and viewport settling.

Changes

Clinical dashboard boundary extraction

Layer / File(s) Summary
Extract dashboard contracts
src/components/clinical-dashboard/document-manager-contracts.ts, src/components/clinical-dashboard/DocumentManagerPanel.tsx
Shared setup and ingestion contracts, fallback checks, readiness helpers, and re-exports are defined in a dependency-free module.
Extract and wire health summary
src/components/clinical-dashboard/library-health-strip.tsx, src/components/ClinicalDashboard.tsx
LibraryHealthStrip derives library status values and renders the health strip. ClinicalDashboard imports the dedicated health and contract modules.
Validate import boundaries
tests/client-performance-boundaries.test.ts, docs/branch-review-ledger.md
The boundary test verifies that DocumentManagerPanel is not eagerly imported. The review ledger records review results.

Phone overlay reserve stabilization

Layer / File(s) Summary
Centralize reserve measurement
src/components/clinical-dashboard/use-phone-overlay-chrome-reserve.ts
readPhoneOverlayChromeReservePx selects a measurable overlay stack or collapse row. The hook preserves the existing CSS reserve when measurements are non-positive.
Validate reserve stabilization
tests/header-scroll-hide-contract.test.ts, tests/phone-overlay-chrome-reserve.dom.test.ts, tests/ui-phone-scroll-page-owned.spec.ts
Tests cover zero-height fallbacks, measurement precedence, and reserve restoration during viewport resizing.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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 summarizes the primary performance change: keeping document administration UI out of the initial dashboard bundle.
Description check ✅ Passed The description explains the motivation, implementation, changed files, and verification results, although it does not follow every template heading.
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.

@ecc-tools

ecc-tools Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@BigSimmo
BigSimmo marked this pull request as ready for review August 1, 2026 15:56
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@ecc-tools

ecc-tools Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@BigSimmo
BigSimmo enabled auto-merge (squash) August 1, 2026 16:00
@ecc-tools

ecc-tools Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@ecc-tools

ecc-tools Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

CI triage

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

  • Production UI (1)needs 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 #7731 (cancelled).

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

@BigSimmo

BigSimmo commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@cursoragent fix failing CI and any other issues

@cursor

cursor Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Fixed the Production UI failure and pushed to PR #1562.

Cause: Services results keep a continuous browser viewport… failed under CI. Trace showed chrome stayed hidden and scrollTop stayed at 504, but the result anchor jumped -138 → -7 (+131px). That matches --phone-overlay-chrome-h briefly publishing 0px (via ?? on a zero-height stack), then restoring the full stack height.

Fix: In use-phone-overlay-chrome-reserve.ts, fall through zero-height stacks with ||, refuse to publish 0px on phone, and keep the CSS seed / last good reserve. Tightened the Playwright poll to require a stable positive reserve, and added a DOM unit + contract guard.

Verified: focused unit/contract tests 32 passed; the failing Playwright journey 1 passed locally. CI is re-running on 7f555b78.

Open in Web Open in Cursor 

BigSimmo and others added 3 commits August 2, 2026 00:57
Production UI failed when Services results kept chrome hidden after a
viewport shrink but the result anchor jumped +131px with scrollTop
unchanged. A zero-height stack measurement used `??`, so offsetHeight 0
published 0px over the CSS seed and the next successful measure restored
the full stack height. Refuse zero phone measurements and fall through
with `||`; tighten the Playwright poll to require a stable positive
reserve.

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

ecc-tools Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

1 similar comment
@ecc-tools

ecc-tools Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@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 (1)
tests/client-performance-boundaries.test.ts (1)

50-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Tighten the negative import assertion.

Line 50 matches one exact specifier string. It does not catch a relative specifier such as ./clinical-dashboard/DocumentManagerPanel, so a future eager import can reappear and this test still passes. Match the static import ... from form with a regex, and keep lazy import() allowed.

♻️ Proposed tighter assertion
-    expect(dashboard).not.toContain('from "`@/components/clinical-dashboard/DocumentManagerPanel`"');
+    expect(dashboard).not.toMatch(/^import\s[^;]*?\sfrom\s+["'][^"']*clinical-dashboard\/DocumentManagerPanel["']/m);
     expect(dashboard).toContain('from "`@/components/clinical-dashboard/document-manager-contracts`"');
     expect(dashboard).toContain('from "`@/components/clinical-dashboard/library-health-strip`"');
🤖 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/client-performance-boundaries.test.ts` around lines 50 - 52, Update the
negative assertion in the dashboard import test to use a regex matching the
static `import ... from` form for the DocumentManagerPanel module, including
relative and aliased specifiers, while continuing to allow dynamic import()
usage. Keep the existing positive assertions unchanged.
🤖 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/clinical-dashboard/library-health-strip.tsx`:
- Around line 78-89: Update the button class list in the health strip button
rendering to include min-h-12, ensuring every production tap target has a 48px
minimum height while preserving the existing sizing and styling classes.

---

Nitpick comments:
In `@tests/client-performance-boundaries.test.ts`:
- Around line 50-52: Update the negative assertion in the dashboard import test
to use a regex matching the static `import ... from` form for the
DocumentManagerPanel module, including relative and aliased specifiers, while
continuing to allow dynamic import() usage. Keep the existing positive
assertions unchanged.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 900da4f8-7bbe-4183-9b3c-bf5c1b25eacd

📥 Commits

Reviewing files that changed from the base of the PR and between 93ab1e0 and 7f555b7.

📒 Files selected for processing (10)
  • docs/branch-review-ledger.md
  • src/components/ClinicalDashboard.tsx
  • src/components/clinical-dashboard/DocumentManagerPanel.tsx
  • src/components/clinical-dashboard/document-manager-contracts.ts
  • src/components/clinical-dashboard/library-health-strip.tsx
  • src/components/clinical-dashboard/use-phone-overlay-chrome-reserve.ts
  • tests/client-performance-boundaries.test.ts
  • tests/header-scroll-hide-contract.test.ts
  • tests/phone-overlay-chrome-reserve.dom.test.ts
  • tests/ui-phone-scroll-page-owned.spec.ts

Comment thread src/components/clinical-dashboard/library-health-strip.tsx
@ecc-tools

ecc-tools Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@coderabbitai

coderabbitai Bot commented Aug 1, 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.

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

Files modified:

  • src/components/clinical-dashboard/library-health-strip.tsx

Commit: 5fe0a55463ecd6094aa7aa0c7b83d30daee3c3db

The changes have been pushed to the codex/review-latency-and-lazy-loading-optimizations branch.

Time taken: 2m 24s

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@ecc-tools

ecc-tools Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@BigSimmo
BigSimmo disabled auto-merge August 1, 2026 18:07
@BigSimmo

BigSimmo commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

@cursoragent Unblock the current open PR. Confirm the PR number and GitHub head first from context. If more than one open PR could apply, stop and say which one you would use and why.

Fetch and start from the remote tip that matches that GitHub head. If the named branch ref is missing or stale, use the PR head ref. Preserve unrelated local WIP; do not discard dirty work; do not treat a local-ahead commit as the reviewed tip. Do not merge the PR, force-push, rebase, or arm auto-merge. No provider-backed gates without approval. If you cannot push or resolve threads, diagnose and comment only; if inline replies fail, resolve when possible and put blocker dispositions in the summary comment. If auto-merge is already armed, push only for a real blocker and avoid cancelling in-flight required CI unless the push clears that blocker.

If the PR is already merged or closed: confirm outcome, post one summary, and stop.

Primary job: clear mergeability and required-CI blockers on this tip. Do a full product review only if needed to explain or fix a blocker. Stay light otherwise—no broad verification suites or Playwright unless needed to prove one concrete unblock fix.

Snapshot the GitHub head: tip, behind/ahead, mergeable state, merge-tree versus origin/main (real conflict versus behind-but-clean), required checks on that tip including Production UI when selected, and unresolved threads that block merge or required CI. Missing checks while dirty are not green. Tip moved → re-snapshot.

Ledger-lookup against that GitHub head under an unblock/fix scope for this PR. If already handled at this head for unblock work, merge-tree clean, required checks green, and no blocking threads: summarize, comment, stop.

Unblock once: real conflict → merge origin/main with the smallest correct resolution (prefer main’s shared queues; keep this PR’s notes); behind-but-clean → one sync, late if required CI is in flight; clean → leave. skip-branch-sync and similar labels do not block a manual sync needed to clear a real blocker. No sync thrash. After any sync or push, re-snapshot tip, merge-tree, and required checks before declaring done. Dedupe the ledger if a merge touched it.

Fix only what blocks required checks or mergeability on this tip. Ignore advisory red unless it reveals a real required failure. Prefer the smallest safe fix; if a bot/autofix commit caused the break, prefer revert. Prove with the smallest targeted check only. Format and commit before push.

Push only blocker-fix commits. Append ledger for the final GitHub head under the unblock scope. Never push a ledger-only tip.

One PR comment: tip, sync/merge-tree, what blocked and what you fixed or dispositioned, required CI status, residual risks; merge left to me.

Stop when merge-tree is clean on the current GitHub tip, no blocking threads remain for merge/required CI, and required checks are green or clearly in progress.

@cursor

cursor Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

PR #1562 unblocked at tip 26a3c4a7.

GitHub had reported DIRTY/CONFLICTING, but merge-tree vs origin/main was clean (behind-by-4 staleness). Synced origin/main (clean auto-merge), pushed with the ledger row.

Now: mergeable: MERGEABLE, behind 0 / ahead 11, merge-tree clean, no unresolved threads, auto-merge off. Required CI is re-running on the new tip (PR mergeability + PR policy already green). Merge left to you.

Open in Web Open in Cursor 

cursoragent and others added 2 commits August 1, 2026 19:18
…zations

Unblock PR #1562: GitHub reported DIRTY/CONFLICTING while merge-tree was clean
(behind-by-4 staleness). Sync main so refs/pull/1562/merge can build again.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Ledger the behind-but-clean sync that cleared GitHub DIRTY mergeability
on the document-admin lazy-load PR tip.

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

ecc-tools Bot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@cursor

cursor Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Unblock summary — PR #1562

Tip: 26a3c4a76a419e7cffd9f583e63b20d713b553b0 on codex/review-latency-and-lazy-loading-optimizations
Prior GitHub head: 5fe0a554 (CodeRabbit autofix min-h-12 on library health strip)

Sync / merge-tree

  • GitHub reported CONFLICTING / DIRTY while git merge-tree --write-tree origin/main <tip> was clean (behind-by-4 staleness, not a content conflict).
  • Merged origin/main → push. Now behind 0 / ahead 11, merge-tree still clean.
  • Re-snapshot: mergeable: MERGEABLE, mergeStateStatus: BLOCKED (waiting on required CI), auto-merge off.

What blocked / what I did

Blocker Action
Dirty mergeability (missing refs/pull/1562/merge) Synced origin/main (clean auto-merge)
Unresolved review threads None open
Required CI on prior tip Already green on 5fe0a554 (Production UI 1–3, PR required, Static/Build/Unit). Re-running on new tip after sync.

No product code changes in this unblock push beyond the main sync + ledger row. CodeRabbit’s min-h-12 autofix on library-health-strip.tsx was already on the prior tip and left intact.

Required CI (current tip)

  • PR mergeability: SUCCESS
  • PR policy: SUCCESS
  • Static PR / Unit / Build / Production UI: in progress or queued after the sync push

Residual risks

  • Hosted CI on 26a3c4a7 must finish green (Production UI selected by change scope).
  • Merge left to you — auto-merge not armed.

@BigSimmo
BigSimmo merged commit a5c75c7 into main Aug 1, 2026
29 checks passed
@BigSimmo
BigSimmo deleted the codex/review-latency-and-lazy-loading-optimizations branch August 1, 2026 19:39
@coderabbitai coderabbitai Bot mentioned this pull request Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants