Skip to content

Apply CORS only to /api, lazy-init map transition audio, and tighten sidebar smoke checks - #212

Merged
Occumed79 merged 2 commits into
mainfrom
codex/fix-cors-issue-causing-500-errors-i65g51
Aug 10, 2026
Merged

Apply CORS only to /api, lazy-init map transition audio, and tighten sidebar smoke checks#212
Occumed79 merged 2 commits into
mainfrom
codex/fix-cors-issue-causing-500-errors-i65g51

Conversation

@Occumed79

@Occumed79 Occumed79 commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent CORS middleware from blocking static frontend assets while keeping a strict API-only CORS policy.
  • Avoid renderer startup hangs by deferring creation of the large embedded transition audio until a user gesture.
  • Simplify and harden sidebar ownership checks to ensure React declaratively owns the sidebar UX and retire legacy imperative runtimes.

Description

  • Restrict CORS to API routes by mounting the CORS middleware at app.use("/api", ...) and add assertions in api-security-smoke.ts to enforce the API-only policy.
  • Add CI integration assertions to fetch a static asset (/favicon.svg) from a disallowed origin to ensure frontend assets remain servable and retain their content type in ci-api-integration.mjs.
  • Change the dual-map transition to lazy-create and reuse an HTMLAudioElement instead of constructing it at module load, move audio graph creation to ensureAudioGraph(audio), and export switchMapModeWithTransition from dualMapTransitionRuntime.ts.
  • Wire the app to call switchMapModeWithTransition from main.tsx and replace the previous direct engine-switching handler with a transition-aware handler in installMapModeSwitching.
  • Update startup hardening smoke to assert the cinematic transition remains wired but that audio is created lazily and not initialized during startup.
  • Simplify sidebar hardening smoke (sidebar-workspace-hardening-smoke.ts) to assert the native React sidebar is rendered and that legacy imperative sidebar runtimes/CSS imports have been removed.
  • Adjust runtime ownership and other smoke scripts to reflect removal of the legacy sidebar controller runtime and related imports.

Testing

  • Ran the API smoke checks (api-security-smoke.ts) which validate CORS placement and route policy assertions; assertions were updated and verified to pass.
  • Executed the CI API integration checks (ci-api-integration.mjs) including the new static asset fetch and CORS assertions; the integration checks passed.
  • Ran the frontend smoke scripts (startup-hardening-smoke.ts, sidebar-workspace-hardening-smoke.ts, runtime-ownership-smoke.ts) to confirm lazy audio behavior, React sidebar ownership, and runtime registrations; all smoke assertions passed.

Codex Task

Summary by CodeRabbit

  • Bug Fixes
    • Restricted cross-origin request handling to API routes, ensuring frontend assets remain accessible with the correct content type.
    • Improved map-mode transitions by preventing audio initialization during startup and creating transition audio only when needed.
  • Refactor
    • Simplified sidebar rendering and runtime checks while preserving key workspace tools and controls.
    • Streamlined map transition event handling and startup loading behavior.
  • Tests
    • Updated smoke tests to validate API security, asset access, sidebar behavior, and map transition startup safeguards.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 10, 2026

Copy link
Copy Markdown

Deploying network-map with  Cloudflare Pages  Cloudflare Pages

Latest commit: a7a0697
Status: ✅  Deploy successful!
Preview URL: https://94cac801.network-map-dew.pages.dev
Branch Preview URL: https://codex-fix-cors-issue-causing-x21v.network-map-dew.pages.dev

View logs

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Occumed79, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 41 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2492e26e-64dd-41f3-81b5-6847a77fd1d7

📥 Commits

Reviewing files that changed from the base of the PR and between 82f170a and a7a0697.

📒 Files selected for processing (2)
  • occu-med-map/scripts/ui-style-ownership-smoke.ts
  • occu-med-map/src/main.tsx
📝 Walkthrough

Walkthrough

The PR scopes CORS to API routes and preserves static asset access. It also changes map transition wiring, makes transition audio lazy, removes retired sidebar runtimes, and updates related smoke tests.

Changes

API CORS scoping

Layer / File(s) Summary
API CORS route scope
api-server/src/app.ts, api-server/scripts/api-security-smoke.ts, api-server/scripts/ci-api-integration.mjs
CORS now applies only to /api routes. Smoke and integration checks verify that unauthorized-origin SVG assets remain accessible with the expected content type.

Map runtime hardening

Layer / File(s) Summary
Sidebar runtime checks
occu-med-map/src/main.tsx, occu-med-map/scripts/sidebar-workspace-hardening-smoke.ts, occu-med-map/scripts/runtime-ownership-smoke.ts
Sidebar runtime imports and retired CSS are removed. Smoke checks verify React rendering, retained controls, React-driven Finder visibility, and runtime ownership expectations.
Map transition runtime
occu-med-map/src/dualMapTransitionRuntime.ts
switchMapModeWithTransition is exported. Transition audio is created during activation, and the document-level click interceptor is removed.
Main startup and transition wiring
occu-med-map/src/main.tsx, occu-med-map/scripts/startup-hardening-smoke.ts
main.tsx delegates map switching to the transition runtime and removes optional loading. Startup checks verify static import, click-driven invocation, lazy audio creation, and no startup-time audio initialization.

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

Sequence Diagram(s)

sequenceDiagram
  participant main.tsx
  participant dualMapTransitionRuntime
  participant WebAudioGraph
  main.tsx->>dualMapTransitionRuntime: switchMapModeWithTransition(targetMode, control)
  dualMapTransitionRuntime->>WebAudioGraph: create and connect transition audio on activation
  dualMapTransitionRuntime-->>main.tsx: complete map-mode transition
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring 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 name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title concisely and accurately summarizes the PR's three main changes: API-only CORS, lazy map transition audio, and revised sidebar smoke checks.
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 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-cors-issue-causing-500-errors-i65g51

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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: 82f170ac65

ℹ️ 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 on lines +16 to +18
assert.doesNotMatch(main, /sidebarWorkspaceControllerRuntime/, "an imperative runtime must not mutate the React sidebar");
assert.doesNotMatch(main, /sidebarWorkspacePanelGuardRuntime/, "a second runtime must not manage Finder visibility");
assert.doesNotMatch(main, /sidebar-workspace-final-fixes\.css/, "workspace CSS must not hide native sidebar content");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Migrate browser acceptance before retiring workspace tabs

When this removal reaches any pull-request browser workflow, the mandatory acceptance suites still wait for and exercise .occumed-sidebar-workspace-tab elements created only by the retired controller: production-ui-smoke.mjs waits for the tab strip, ci-ui-acceptance.mjs requires exactly one selected tab, and ci-cross-browser-acceptance.mjs switches those tabs. Because the new React sidebar does not render those selectors, the UI smoke, UI acceptance, and hardening browser jobs will time out or fail on every run; update those suites to exercise the native controls as part of this migration.

Useful? React with 👍 / 👎.

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@Occumed79
Occumed79 merged commit be8f0c4 into main Aug 10, 2026
14 checks passed
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.

1 participant