Skip to content

perf: reduce Therapy startup and sidebar layout work - #1489

Merged
BigSimmo merged 39 commits into
mainfrom
codex/address-performance-issues-in-package
Jul 31, 2026
Merged

perf: reduce Therapy startup and sidebar layout work#1489
BigSimmo merged 39 commits into
mainfrom
codex/address-performance-issues-in-package

Conversation

@BigSimmo

@BigSimmoBigSimmo commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add opt-in, privacy-first server-side Sentry error tracking that is inert without SENTRY_DSN and scrubs request, user, body, breadcrumb, and clinical content before export.
  • Surface conservative, normalized source-governance metadata in the RAG prompt so generation can see provenance state without inventing adverse unverified status for empty, index-only, or partial-sibling documents.metadata.
  • Document the privacy envelope, operator approval checklist, and rollback path in docs/error-tracking.md.

RAG impact: no retrieval behaviour change — prompt presentation only adds conservative normalized source-governance metadata; retrieval, ranking, and source selection are unchanged.

Verification

  • npm run verify:pr-local
  • Focused Vitest for tests/error-tracking.test.ts, tests/rag-source-governance-prompt.test.ts, and tests/source-metadata.test.ts
  • npm run eval:rag:offline — 36/36 golden retrieval cases
  • npm run check:production-readiness:ci returned READY (offline; expected missing-env warnings)
  • npm run build succeeded for production instrumentation wiring
  • Merged origin/main and resolved Codex Cloud git-remote helper conflicts; git merge-tree vs origin/main is clean
  • UI verification not run: no UI, routing, styling, or browser-behavior changes
  • Live answer-generation quality evaluation not run — OpenAI/provider interaction requires explicit owner approval

Risk and rollout

  • Risk: medium; optional Sentry path is disabled unless configured, but prompt wording changes answer-generation context and should land only with owner acceptance of offline evidence or an approved live answer-quality check.
  • Rollback: revert the squash-merge commit on main, remove SENTRY_DSN and restart services if observability was enabled, and confirm prompts no longer emit the Source governance line.
  • Provider or production effects: None unless an operator explicitly sets SENTRY_DSN; no browser DSN, tracing, or source-map upload is configured.

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 when clinical decision-support behavior changed

Notes

  • Empty/{}/index-only governance metadata remains unrecorded in prompts; partial sibling fields use neutral unknown rather than inventing adverse unverified; explicit stored clinical_validation_status: "unverified" from upload is preserved.
  • Optional Sentry init failures are swallowed so observability cannot block production boot.
  • Merge remains gated on approved live answer-quality verification or an explicit owner decision to accept the offline-only evidence.

@coderabbitai

coderabbitaiBot commented Jul 30, 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:39 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: e7dea63b-ba13-47cc-8d50-becf952f4964

📥 Commits

Reviewing files that changed from the base of the PR and between 2cdb950 and 67d5cb9.

📒 Files selected for processing (19)
  • .github/workflows/ci.yml
  • docs/branch-review-ledger.md
  • docs/outstanding-issues.md
  • docs/scripts-index.md
  • public/therapy-compass-data/therapies-home.211dab554c4ec62d.json
  • public/therapy-compass-data/therapies-home.json
  • public/therapy-compass-data/therapies-index.4b4ee988e0ff84e2.json
  • public/therapy-compass-data/therapies-index.json
  • scripts/build-therapies-index.mjs
  • scripts/check-bundle-budget.mjs
  • scripts/lib/escape-false-openai-key-signatures.mjs
  • src/components/clinical-dashboard/use-hide-on-scroll.ts
  • src/components/therapy-compass/data/generated-assets.ts
  • src/data/therapies-index.json
  • tests/escape-false-openai-key-signatures.test.ts
  • tests/header-scroll-hide-contract.test.ts
  • tests/therapy-compass-mode-wiring.test.ts
  • tests/ui-phone-scroll-page-owned.spec.ts
  • tests/use-hide-on-scroll.test.ts
📝 Walkthrough

Walkthrough

This PR splits the Therapy Compass dataset into content-addressed home, index, and full catalogue assets with legacy aliases, updates the build script, bindings, and data hook to select the correct catalogue per route, and adds caching rules. It also hardens the bundle-budget script and CI/Docker install steps, removes sidebar transition logic, adds viewport-resize handling to scroll-hide behavior, and updates review documentation.

Changes

Therapy catalogue assets

Layer / File(s)Summary
Catalogue generation and asset validation
scripts/build-therapies-index.mjs, public/therapy-compass-data/therapies-home.json, public/therapy-compass-data/therapies-home.f68f0bb9623bc42a.json, public/therapy-compass-data/therapies-index.7cd59ff6765d15f8.json, src/components/therapy-compass/data/generated-assets.ts, next.config.ts
The build script resolves the source dataset via manifest fallback, generates a compact home projection, produces content-addressed full/index/home assets plus legacy aliases, writes generated-assets.ts, and validates hashes and aliases in check mode. Caching rules add immutable caching for hashed filenames and revalidation for aliases.
Route-specific catalogue loading
src/components/therapy-compass/bindings.tsx, src/components/therapy-compass/data/use-therapy-data.ts
TcProvider selects "home", "index", or "full" per screen; the data hook resolves catalogue files through THERAPY_CATALOGUE_ASSETS instead of hardcoded filenames.
Catalogue wiring and route validation
tests/therapy-compass-data-recovery.dom.test.tsx, tests/therapy-compass-pathways.test.ts, tests/therapy-compass-mode-wiring.test.ts, tests/ui-route-coverage.spec.ts, tests/ui-therapy-nav-scroll.spec.ts
Tests use generated asset constants, verify legacy alias byte-equality, check immutable/revalidation caching, and update fixture filename allowlists to accept hashed therapy filenames.

Build and CI hardening

Layer / File(s)Summary
Bundle budget script refactor and tests
scripts/check-bundle-budget.mjs, tests/bundle-budget.test.ts
Adds BUNDLE_BUDGET_ROOT override, EXIT_FAILSAFE_MS, measureChunkPaths, exitProcess, and runBundleBudgetCheck, returning status codes instead of exiting directly; tests cover streaming measurement, exit behavior, and an end-to-end CLI run.
CI timeout and Docker install retries
.github/workflows/ci.yml, Dockerfile, Dockerfile.worker
CI invokes the checker script directly with a three-minute step timeout. Both Dockerfiles retry npm ci up to three attempts with fetch retries and backoff delays.

Sidebar transition removal

Layer / File(s)Summary
Remove sidebar transition wiring
src/components/ClinicalDashboard.tsx, src/components/clinical-dashboard/global-search-shell.tsx, src/components/clinical-dashboard/use-sidebar-column-transition.ts
Removes useSidebarColumnTransitionReady and its usages, deleting the hook file and conditional grid-transition classes; sidebar sizing remains static.

Viewport-resize scroll-hide handling

Layer / File(s)Summary
Viewport-height detection and rebasing
src/components/clinical-dashboard/use-hide-on-scroll.ts, tests/use-hide-on-scroll.test.ts, tests/ui-phone-scroll-page-owned.spec.ts
computeScrollHideUpdate accepts a viewport-height-changed flag and preserves hidden state on geometry changes. The hook tracks previous viewport height, resets it on deactivation, and registers resize listeners for both reporters. Tests cover viewport-shrink/grow scenarios and a "settled" status assertion.

Review documentation

Layer / File(s)Summary
Record review and issue status
docs/branch-review-ledger.md, docs/outstanding-issues.md
Adds branch-review ledger records for reopen prep, reconciliation, and PR #1489 outcomes. Issue #117 documentation records the home/pathways/search payload split.

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

Sequence Diagram(s)

sequenceDiagram
participant TcProvider
participant useTherapyData
participant THERAPY_CATALOGUE_ASSETS
participant TherapyCatalogueJSON
TcProvider->>useTherapyData: Select home, index, or full catalogue
useTherapyData->>THERAPY_CATALOGUE_ASSETS: Resolve hashed asset filename
useTherapyData->>TherapyCatalogueJSON: Request selected JSON asset
Loading
sequenceDiagram
participant CI
participant CheckBundleBudgetScript
participant runBundleBudgetCheck
participant exitProcess
CI->>CheckBundleBudgetScript: Run script directly with timeout
CheckBundleBudgetScript->>runBundleBudgetCheck: Measure chunks and validate budget
runBundleBudgetCheck->>exitProcess: Return status code
exitProcess->>CI: Terminate process with code
Loading

Possibly related PRs

  • BigSimmo/Database#912: Directly extends the same Therapy Compass catalogue generation, bindings, and hashed-asset selection logic.
  • BigSimmo/Database#608: Introduces the bundle-budget script this PR refactors with runBundleBudgetCheck, exitProcess, and measureChunkPaths.
  • BigSimmo/Database#1270: Modifies the same use-hide-on-scroll.ts geometry-rebase and phone scroll-hide logic extended here for viewport resize.

Suggested reviewers:claude

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.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 nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly summarizes the main performance changes to Therapy startup and sidebar layout work.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck 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
BigSimmo enabled auto-merge (squash) July 30, 2026 19:33
@BigSimmo
BigSimmo disabled auto-merge July 30, 2026 19:36

@chatgpt-codex-connectorchatgpt-codex-connectorBot 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:835a66af0e

ℹ️ 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 threadscripts/build-therapies-index.mjs Outdated
@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

@codex review PR

@BigSimmoBigSimmo added the skip-branch-sync Opt out of hosted pr-branch-sync / update-branch on this PR label Jul 30, 2026
@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

@cursoragent run bugbot review for PR and resolve merge conflict

@cursor

cursorBot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Merge conflict cleared and Bugbot triage finished on PR #1489. Tip is f7f24dbf (mergeable; CI still settling).

Merge conflict

Only conflict was docs/outstanding-issues.md vs origin/main.

  • Kept main’s open queue (HEAD-only open rows were already archived on main).
  • Preserved this PR’s #117 hashed catalogue filename note.
  • git merge-tree vs origin/main is clean; check:outstanding-issues passed.

Bugbot review

No unresolved cursor[bot] Bugbot threads on the PR. Ran a Bugbot-style pass on the product delta:

SeverityLocationFindingDispositionEvidence
PR product tipNo P0–P2 product defects in payload split, loader wiring, cache headers, or sidebar transition removalno issueVitest therapy suites 20/20; build-therapies-index.mjs --check current (205 records)
P2 (prior Codex)scripts/build-therapies-index.mjsUnversioned catalogue URLs 404 for deployment-straddling clientsalready fixed (ff270e957)Aliases present and byte-identical; --check fails on alias drift
ResidualFuture hashed-asset regenPrior content-hashed files need retention for open tabs after later data bumpsleave openProcess risk only; aliases cover pre-PR clients

Checks

  • Ran: conflict resolution, check:outstanding-issues, build-therapies-index --check, therapy Vitest 20/20, merge-tree clean, push.
  • Not run: full verify:cheap / Playwright / Lighthouse (provider/production).
Open in WebOpen in Cursor

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit:ff270e9576

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

CopilotAI 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.

Pull request overview

This PR optimizes Therapy Compass startup and sidebar layout work by introducing content-addressed (hashed) therapy catalogue assets with a generated manifest, loading smaller route-appropriate payloads (home vs search vs detail), and removing a costly grid-template-columns transition during sidebar toggles.

Changes:

  • Generate and consume a manifest-driven set of hashed Therapy Compass catalogue JSON assets (plus a compact home projection) to reduce client parse/work and enable immutable caching.
  • Route-select the appropriate therapy dataset (home / index / full) via useTherapyData + Therapy Compass bindings, and update tests/fixtures accordingly.
  • Remove the sidebar grid-column transition wiring from the main shell owners to avoid layout animation jank.

Reviewed changes

Copilot reviewed 13 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
tests/ui-therapy-nav-scroll.spec.tsUpdates offline fixture allowlist to accept hashed therapy catalogue asset filenames.
tests/ui-route-coverage.spec.tsSame fixture allowlist update for route-coverage Playwright runs.
tests/therapy-compass-pathways.test.tsSwitches pathway integrity test to read the manifest-provided full catalogue asset.
tests/therapy-compass-mode-wiring.test.tsAsserts hashed assets exist, verifies legacy aliases match, and updates loader expectations to manifest usage.
tests/therapy-compass-data-recovery.dom.test.tsxUpdates fetch mocks/assertions to use manifest-driven asset names (home/full).
src/components/therapy-compass/data/use-therapy-data.tsAdds home catalogue option and loads catalogue JSON via THERAPY_CATALOGUE_ASSETS[...] (manifest).
src/components/therapy-compass/data/generated-assets.tsNew generated manifest exporting hashed therapy asset filenames.
src/components/therapy-compass/bindings.tsxSelects home vs index vs full catalogue based on Therapy Compass route/screen.
src/components/ClinicalDashboard.tsxRemoves sidebar grid-column transition gating (drops useSidebarColumnTransitionReady).
src/components/clinical-dashboard/global-search-shell.tsxSame: removes grid-column transition gating for the standalone search shell.
scripts/build-therapies-index.mjsGenerates compact home projection, writes hashed assets + TS manifest, and validates assets via --check.
public/therapy-compass-data/therapies-home.jsonAdds the compact home projection dataset.
next.config.tsAdds immutable caching headers for content-addressed therapy catalogue assets.
docs/outstanding-issues.mdUpdates the Therapy Compass perf tracking entry to reference the hashed asset name.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadsrc/components/therapy-compass/data/use-therapy-data.ts
Comment threaddocs/outstanding-issues.md Outdated
cursoragentand others added 2 commits July 30, 2026 21:30
Resolve docs/outstanding-issues.md by keeping main's open queue (HEAD-only
rows already archived on main) and preserving this PR's #117 hashed catalogue
filename note.
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

Temporarily paused during the owner-authorized ordered merge sweep so main cannot move between exact-head review and merge. The branch and all commits are preserved; this PR will be reopened at its verified place in the queue.

@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

@cursoragent this PR will be re-opened soon. Please resolve any failing CI, run bugbot and resolve any bugbot comments against current repo and fix any merge conflicts and also fix any errors and address and fix all comments or suggestions that are likely to improve the PR and Codebase. Please implement smallest required fix according to best code practices. Check your work. Leave this PR closed for now but still make all these changes and run the review. I want it ready to go for when I re-open it.

@cursor

cursorBot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

PR #1489 is ready to reopen and still closed. Branch tip is 5c85e6ff on codex/address-performance-issues-in-package.

Done

  • Merge conflict cleared against current origin/main (docs/outstanding-issues.md only). Kept main’s open queue; kept this PR’s #117 home/index note. git merge-tree is clean (0 behind / 8 ahead).
  • Bugbot / review threads: none unresolved. Fresh product pass found no P0–P2 defects.
  • Small fixes landed:
    • Deleted dead use-sidebar-column-transition.ts (imports were already gone)
    • Added must-revalidate cache headers for unversioned therapy aliases
    • Added a wiring test for hashed-immutable vs alias-revalidate headers

Checks

  • Therapy Vitest 21/21, build-therapies-index --check (205), check:outstanding-issues, format:check, typecheck
  • Not run: full verify:cheap / Playwright / Lighthouse

Note

GitHub may still show the closed PR head as b4e0b60d until you reopen; the branch itself is already at 5c85e6ff. After reopen, mergeability/CI should evaluate the synced tip.

Open in WebOpen in Cursor

cursoragentand others added 4 commits July 31, 2026 00:15
Resolve docs/outstanding-issues.md by keeping main's open queue
(HEAD-only open rows already archived on main) and preserving this
PR's #117 home/index catalogue split note.
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Serve unversioned therapy catalogue aliases with must-revalidate so
deployment-straddling clients pick up regenerated bytes, and delete the
unused sidebar column-transition hook left after import removal.
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Guard the immutable hashed catalogue headers and the must-revalidate
compatibility-alias policy so a future next.config change cannot silently
collapse them.
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@cursor

cursorBot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

PR #1489 reopen prep is done on codex/address-performance-issues-in-package tip 5c85e6ff. Left closed as requested.

Merge conflict

  • Synced origin/main (was 9 behind / CONFLICTING on docs/outstanding-issues.md).
  • Kept main’s open queue; preserved this PR’s #117 home/index split note.
  • git merge-tree --write-tree origin/main HEAD is clean; branch is 0 behind / 8 ahead.

Bugbot / review threads

  • No unresolved review threads (Codex P2 aliases + Copilot comment/docs notes already fixed earlier).
  • Fresh Bugbot-style product pass: no P0–P2 product defects.
SeverityLocationFindingDisposition
Product tipPayload split, loader wiring, aliases, cache headers, sidebar transition removalclear
P3 cleanupuse-sidebar-column-transition.tsDead helper left after import removaldeleted
Hardeningnext.config.tsUnversioned aliases lacked explicit revalidationmust-revalidate headers added + wiring test

Checks run

  • check:outstanding-issues passed
  • build-therapies-index.mjs --check current (205 records)
  • Therapy Vitest 21/21 (incl. new cache-header contract)
  • format:check clean; typecheck clean
  • Not run: full verify:cheap / Playwright / Lighthouse (provider/production)

On reopen

GitHub’s closed-PR head may still show b4e0b60d until reopen; the branch tip is already 5c85e6ff. After reopen, mergeability/CI should evaluate the synced tip.

@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

@CodeRabbit please review PR

@coderabbitai

coderabbitaiBot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@BigSimmo: I’ll review the changes in #1489, focusing on the Therapy asset generation/loading contract, cache headers, route-mode behavior, and sidebar transition removal.

✅ 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.

@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

@coderabbitai please run a new review of this closed PR for me

@coderabbitai

coderabbitaiBot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@BigSimmo: Starting a new full review of #1489, including the previously reviewed changes.

✅ Action performed

Full review finished.


Your included review limit is currently reached under our Fair Usage Limits Policy. Your recent PR review activity is in the 95th percentile or higher among CodeRabbit users, so adaptive limits apply. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 41 minutes.

@cursor

cursorBot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Deep fix: Build bundle-budget hang (why “re-run” kept failing)

Root cause:Build was not failing tests. npm run build succeeded, then check:bundle-budget printed success (within tolerance / fixture assertion passed) and never exited. The job hit timeout-minutes: 25 → Build = cancelled (orphan MainThread), and PR required stayed red.

Why re-run kept failing: “Re-run failed jobs” skips cancelled jobs. Only PR required re-ran, saw Build still cancelled, and failed again (attempt 3 on the same tip).

Durable fix (caced05a):

  1. Script: stream chunk measurement (no retained multi‑MiB buffers); every exit path uses exitProcess (stdout drain + 1s hard failsafe); print [bundle-budget] done.
  2. CI: run node scripts/check-bundle-budget.mjs directly with timeout-minutes: 3 on the step — a stuck exit fails the step as failure (re-runnable), instead of cancelling the whole Build job
  3. Tests: exitProcess unit coverage + CLI subprocess must exit 0 with done. within 5s

Verified locally: vitest bundle-budget 14/14; check:bundle-budgetdone.; check:github-actions passed.

Tip will move with ledger append. Let the new CI run finish — do not push again mid-run. Merge left to you.

cursoragentand others added 3 commits July 31, 2026 07:57
Behind-but-clean (merge-tree clean); GitHub DIRTY blocked pull_request CI.
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Review follow-up: always route unexpected throws through exitProcess, and
only drop fixture buffers after the violation check so failure reporting
cannot race a cleared buffer.
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@cursor

cursorBot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review + stress test — bundle-budget hang fix

Verdict: Fix is sound. No P0–P2 remaining in this delta. Tip 2cdb950c (product 7ecc4e18 + ledger).

What was wrong (confirmed)

Build printed bundle-budget success, then never exited → 25m job timeout → cancelled. “Re-run failed jobs” skipped cancelled Build → PR required loop.

Fix review

LayerAssessment
Streamed measureChunkPathsCorrect; avoids retaining all chunk buffers
exitProcess drain + 1s failsafeCorrect; covers stuck stdio drain
CI timeout-minutes: 3 on step + direct nodeCorrect; stuck exit becomes failure (re-runnable), not job cancelled
[bundle-budget] done. markerGood observability
Review follow-up (7ecc4e18)Unexpected throws now always hit exitProcess; buffer clear only after fixture check

Stress evidence (local)

  • Vitest bundle-budget 14/14
  • Real .next CLI ×40: p95 ~113ms, max ~118ms, all printed done. and exited 0
  • Concurrent ×10: max ~338ms, all exit 0
  • Failsafe ×100 stuck-drain: 0 misses
  • Blocked/paused stdout, npm run, over-budget (exit 1), 800-file synthetic tree: all OK
  • check:github-actions passed; merge-tree clean vs main after sync

Residual risk

If console.log itself blocked on a full pipe beforeexitProcess runs, the 1s failsafe would not start — the 3m step timeout is the backstop for that case. Observed CI hang was after logs flushed, which this fix targets.

Synced origin/main (behind-but-clean / GitHub DIRTY). Let the new required CI finish; don’t push mid-run. Merge left to you.

@coderabbitaicoderabbitaiBot 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: 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 `@public/therapy-compass-data/therapies-home.f68f0bb9623bc42a.json`:
- Around line 3928-3929: Update the upstream therapy catalogue record that
generates the task-centred-practice entry so its slug and name use plain “k”
rather than the \u006b escape; ensure the generated therapies-home asset emits
task-centred-practice and Task-centred practice, and verify existing hard-coded
routes, tests, or links continue resolving that slug.
In `@public/therapy-compass-data/therapies-index.7cd59ff6765d15f8.json`:
- Around line 720-724: Stop deriving modality from tags in the therapy index
generator, and inspect all route, filter, and facet consumers before choosing
removal versus curated values. Update the generator and affected records so
clinically unsupported modality values are omitted or replaced only with
source-backed values, including the ECT, rTMS, cognitive stimulation, MBT, TFP,
psychoanalysis, and psychodynamic entries; preserve conservative behavior when
no curated value exists.
In `@tests/bundle-budget.test.ts`:
- Around line 50-84: Update both exitProcess calls in the exitProcess tests to
cast their mock exitImpl and stdout objects to the inferred option types,
matching the existing setTimer cast where needed. Keep the test behavior and
mock implementations unchanged while ensuring both strict TypeScript call sites
compile.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e0e1ffd9-2289-4342-b08b-7ec6f34a4baf

📥 Commits

Reviewing files that changed from the base of the PR and between fe0d7e0 and 2cdb950.

📒 Files selected for processing (20)
  • .github/workflows/ci.yml
  • Dockerfile
  • Dockerfile.worker
  • docs/branch-review-ledger.md
  • docs/outstanding-issues.md
  • public/therapy-compass-data/therapies-home.f68f0bb9623bc42a.json
  • public/therapy-compass-data/therapies-home.json
  • public/therapy-compass-data/therapies-index.7cd59ff6765d15f8.json
  • scripts/build-therapies-index.mjs
  • scripts/check-bundle-budget.mjs
  • src/components/clinical-dashboard/global-search-shell.tsx
  • src/components/clinical-dashboard/use-hide-on-scroll.ts
  • src/components/therapy-compass/bindings.tsx
  • src/components/therapy-compass/data/generated-assets.ts
  • src/components/therapy-compass/data/use-therapy-data.ts
  • tests/bundle-budget.test.ts
  • tests/therapy-compass-data-recovery.dom.test.tsx
  • tests/therapy-compass-mode-wiring.test.ts
  • tests/ui-phone-scroll-page-owned.spec.ts
  • tests/use-hide-on-scroll.test.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/components/therapy-compass/data/generated-assets.ts
  • src/components/clinical-dashboard/global-search-shell.tsx
  • tests/therapy-compass-mode-wiring.test.ts
  • src/components/therapy-compass/bindings.tsx
  • src/components/therapy-compass/data/use-therapy-data.ts
  • scripts/build-therapies-index.mjs
  • tests/therapy-compass-data-recovery.dom.test.tsx

Comment threadpublic/therapy-compass-data/therapies-home.f68f0bb9623bc42a.json Outdated
Comment threadtests/bundle-budget.test.ts
Resolve conflicts in use-hide-on-scroll and the Services phone-scroll poll
by keeping main's range-change hold and this branch's viewportHeightChanged
rebase (plus visualViewport resize listeners). Update the header contract
test to pin the merged resize wiring.
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

@cursoragent please thoroughly review these failing CI so they don't occur again and address all comments logically

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

cursorBot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Fixed the CI-blocking issue and cleared the open review threads on PR #1489 (tip ac2d0ec5; product fix 3e56dd91).

CI failure (won’t recur)

Static PR typecheck failed on tests/bundle-budget.test.ts: exitProcess defaults made TS infer exitImpl as (value) => never and stdout as WriteStream, so Vitest mocks failed.

Fix:ExitProcessOptions JSDoc + options = {} in scripts/check-bundle-budget.mjs.
Proof:npm run typecheck clean; vitest 34/34.

Comments addressed

CommentAction
Critical: exitProcess mocksFixed (above)
Minor: \u006b in task-centredFixed — generator was rewriting every mid-word sk- (including task-); now only key-shaped \bsk-[A-Za-z0-9]{16,}; home/index regenerated
Major: modality from tagsNo change — pre-existing on main; out of scope for this perf PR

All three threads resolved (inline replies 403; dispositions in the PR summary comment).

Left alone

Clinical catalogue modality/settings cleanup, auto-merge, merge to main. Hosted CI is re-running on the new tip.

Open in WebOpen in Cursor

exitProcess now declares injectable mock options via JSDoc so Vitest mocks
typecheck under strict tsc (the Static PR failure on bundle-budget tests).
The therapies generator no longer mid-word-rewrites every sk- sequence into
s\u006b-; only OpenAI-key-shaped tokens are escaped, so task-centred stays
plain in pretty-printed home/index assets. Regenerated hashed catalogues and
added regression coverage.
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@cursor

cursorBot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

CI + review-comment pass (3e56dd91)

Failing CI root cause (will not recur)

Static PR / typecheck was red on tests/bundle-budget.test.ts because exitProcess defaults inferred exitImpl as (value) => never and stdout as WriteStream, so Vitest mocks failed strict tsc.

Fix:ExitProcessOptions JSDoc + options = {} in scripts/check-bundle-budget.mjs. Local proof: npm run typecheck clean; vitest bundle-budget + escape + therapy wiring/pathways 34/34.

Open CodeRabbit threads

ThreadDisposition
exitProcess mocks (Critical)Fixed in 3e56dd91
\u006b in task-centredFixed — generator mid-word sk- rewrite mangled task-centred; now only key-shaped \bsk-[A-Za-z0-9]{16,} is escaped; home/index regenerated (211dab55 / 4b4ee988)
modality derived from tags (Major)No change — pre-existing on main catalogue source; out of scope for this perf PR

Inline replies are 403 for the agent token; threads were resolved via GraphQL. Dispositions recorded here.

Not changed

  • Clinical modality/settings/tag cleanup (catalogue-data PR)
  • Provider-backed gates / auto-merge / merge to main

Merge left to you once required CI on 3e56dd91 is green.

cursoragentand others added 2 commits July 31, 2026 08:51
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

@cursoragent this keeps failing... please do a thorough deep dive to ensure no more failures with CI

@cursor

cursorBot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Taking a look!

Open in WebOpen in Cursor

cursoragentand others added 3 commits July 31, 2026 08:54
GitHub reported DIRTY/CONFLICTING while merge-tree was clean; branch was
one commit behind main. Sync so pull_request CI can build refs/pull/1489/merge.
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Merge origin/main (#1478) so GitHub can build the PR merge ref again
(DIRTY was behind-but-clean). Refresh scripts inventory for the new
escape helper, and retarget #117 asset path refs away from deleted
hashed catalogue filenames so docs:check-links stays green.
@cursor

cursorBot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

CI deep-dive unblock (f5e57e64)

Why CI kept “failing”

GitHub PR mergeability reported a real conflict, which prevents refs/pull/1489/merge from building — so CI / Gitleaks / Semgrep look missing or red even when the branch tip itself is fine.

Local git merge-tree --write-tree origin/main <tip> was clean. The branch was only 1 commit behindmain (#1478 Sentry + source-governance). That is the repo’s behind-but-clean false-conflict case, not a content fight.

What I fixed this pass

  1. Merged origin/main (ef0feef3) so the PR merge ref can build again.
  2. docs:check-inventory — refreshed docs/scripts-index.md for the new escape helper (would have failed Static PR after the last push).
  3. docs:check-links#117 still pointed at deleted hashed assets (…7cd59ff… / …f68f0bb…); retargeted to durable/current paths.
  4. Prior tip fixes already on the branch: exitProcess JSDoc typing (Static PR typecheck), task-centred sk-escape mangling, #146 hide-on-scroll, bundle-budget hang exit.

Local proof (decisive lines)

  • verify:cheap: 448 files / 4683 passed
  • verify:pr-local: Client bundle secret surface check passed + Offline RAG fixture validation passed (36 golden cases)
  • check:bundle-budget: within tolerance + done (process exits; no hang)
  • format:check: All matched files use Prettier code style!
  • merge-tree origin/main: clean

Threads / scope

  • No new product defects found in this pass.
  • Clinical modality catalogue debt remains out of scope (pre-existing on main).
  • Did not merge the PR, force-push, rebase, or arm auto-merge.

Hosted required CI should now be able to run on tip f5e57e64. Merge left to you once pr-required is green.

Real conflict in docs/scripts-index.md after main added the
outstanding-issues writer. Regenerated inventory (198 scripts / 212 npm
scripts) so PR mergeability can build refs/pull/1489/merge again.
@cursor

cursorBot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

CI deep-dive — unblocked (67036ed0)

Root cause of the “keeps failing” loop

  1. PR mergeability DIRTY blocked refs/pull/1489/merge, so required CI never ran (or looked missing).
  2. First sync of main was clean; main then moved again (#1524) and created a real conflict in docs/scripts-index.md.
  3. Earlier Static PR reds (already fixed on this branch): exitProcess mock typing; docs inventory / stale hashed #117 paths; task-centred sk-escape; bundle-budget hang; Services hide-on-scroll.

What I did

  • Merged origin/main through #1478 and #1524
  • Regenerated docs/scripts-index.md (198 scripts / 212 npm scripts) to resolve the content conflict
  • Kept prior typecheck / asset / chrome / bundle-budget fixes

State now

  • GitHub: MERGEABLE / BLOCKED only while checks run
  • Local: merge-treeCLEAN, 0 behind
  • Tip pushed for CI: 67036ed0
  • Ledger append kept local-only for the moment so this push does not cancel the in-flight required run

Local proof

Merge left to you once pr-required is green on 67036ed0.

@BigSimmo
BigSimmo merged commit 9451482 into mainJul 31, 2026
26 checks passed
@BigSimmo
BigSimmo deleted the codex/address-performance-issues-in-package branch July 31, 2026 09:37
BigSimmo pushed a commit that referenced this pull request Aug 9, 2026
Resolves the duplicate #286 that made the PR un-mergeable. Main's
in-page-nav series claims #286-#288; this branch independently created
its own #286 for the authorizationHeader casing trap. Kept both sides and
renumbered the branch's row to #289, bumping issues:next-id to 290.
The auto-merge silently dropped the branch's #286 detail row rather than
conflicting on it -- only the recommended-queue hunk raised a marker. That
row is restored as #289. This is the silent row-loss mode archive row #112
describes: the guard catches duplicate ids but not a vanished one.
Also addresses review findings on the handover brief:
- Require the Clinical Governance Preflight for Phase 3 regardless of what
scripts/pr-policy.mjs classifies. AGENTS.md:257 keys the requirement to
behaviour -- source rendering and document access -- and Phase 3 changes
both. The classifier not matching src/components/** is the PR #1489 gap
recorded at pr-policy.mjs:62, not an exemption.
- Resolve the scope contradiction: the brief claimed everything stays in
src/components/document-viewer/** while Task 3 authorised wiring
src/app/api/images/signed-urls/route.ts, which is clinical-risk. That is
now an explicit, discouraged scope exception.
- Correct the signed-URL warning. Both identity bugs are already fixed on
main (authorizationIdentity() helper, identity in the dedupe key, cache
write outside the shared promise, tests/auth-signed-url-cache.dom.test.tsx).
The brief now says so and requires that coverage stay green, rather than
reading as an open disclosure with a "consider" remedy.
- Drop a literal NUL byte that had landed in the prose, and remove the
trailing-space code span (MD038).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ER2xPFzPzoS8fAxkgHC8yo
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codexskip-branch-syncOpt out of hosted pr-branch-sync / update-branch on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@BigSimmo@cursoragent