Skip to content

fix: accept ENVIRONMENT=preview for pull request previews - #141

Merged
lewisjared merged 3 commits into
mainfrom
fix/preview-environment
Oct 19, 2026
Merged

lewisjared merged 3 commits into
mainfrom
fix/preview-environment

Conversation

@lewisjared

@lewisjared lewisjared commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Adds preview to the allowed ENVIRONMENT values. The pull request previews deploy with ENVIRONMENT=preview, which the settings model rejected, so a preview pod could not start.

The frontend treats preview like staging, showing the staging banner and the sparse results a production site withholds, because a preview serves unreleased code against the same data as staging. The /about response type gains the value, so the client is regenerated.

Summary by CodeRabbit

  • Bug Fixes
    • Pull request previews now behave like the staging site: they display the staging banner and sparse results.
    • Preview environments are now recognised consistently across the app, so staging-specific indicators and dashboard behaviour apply in previews as well.

Previews deploy with ENVIRONMENT=preview, which settings rejected at startup.
A preview serves unreleased code, so the frontend treats it as a staging site.
@lewisjared
lewisjared marked this pull request as ready for review October 19, 2026 22:58
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

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

Next included review available in 54 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b13affc2-d05b-46f5-a465-674222927653
📥 Commits

Reviewing files that changed from the base of the PR and between 3a0d62c and 27a34eb.

📒 Files selected for processing: 1
  • frontend/src/components/charts/mipEraSections.test.tsx
📝 Walkthrough

The backend and frontend environment types now accept preview. Frontend staging checks include preview, and tests cover the settings value and staging banner.

Changes: Preview environment support

Layer / File(s) Summary
Accept the preview environment
backend/src/ref_backend/core/config.py, backend/src/ref_backend/models/about.py, frontend/src/client/types.gen.ts, backend/tests/test_core/test_config.py
Backend settings, the About model and the generated frontend type accept preview. A backend test checks that settings retain the preview value.
Apply staging behaviour to previews
frontend/src/hooks/useStagingMode.ts, frontend/src/components/app/stagingBanner.test.tsx, changelog/141.fix.md
Both staging hooks treat preview as staging. A banner test checks that a preview displays “Staging site”. The changelog describes preview banner and sparse-results behaviour.

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 3a0d6

Preview environments are accepted and receive staging-style banner and sparse-results behavior. A preview-specific sparse-chart assertion would improve regression coverage, but no concrete runtime mismatch was found, so merge risk is minimal.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: accepting ENVIRONMENT=preview for pull request previews.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 6 files. (1 skipped: 1 …
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 6 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments: 1
frontend/src/hooks/useStagingMode.ts: 1

5-8: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover preview in the sparse-results chart test.

The banner test does not render SampleSizeGate. The chart test covers staging only, and its helper currently excludes "preview". A regression in the preview chart-gate path can therefore pass all existing tests.

Suggested fix
   const renderChart = (
     values: ReturnType<typeof model>[],
     mipEra?: "CMIP6" | "CMIP7",
-    environment: "production" | "staging" = "production",
+    environment: "production" | "staging" | "preview" = "production",
   ) => {
...
   it("plots a chart with too few models on a staging site", () => {
     renderChart([model("CMIP6", "A"), model("CMIP6", "B")], "CMIP6", "staging");
     expect(screen.getByTestId("chart")).toBeInTheDocument();
     expect(
       screen.queryByText("Not enough models to plot"),
     ).not.toBeInTheDocument();
   });
+
+  it("plots a chart with too few models on a preview site", () => {
+    renderChart([model("CMIP6", "A"), model("CMIP6", "B")], "CMIP6", "preview");
+    expect(screen.getByTestId("chart")).toBeInTheDocument();
+    expect(
+      screen.queryByText("Not enough models to plot"),
+    ).not.toBeInTheDocument();
+  });

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0296d71c-3e1b-4763-b095-2d944f58506b
📥 Commits

Reviewing files that changed from the base of the PR and between 834a91f and 3a0d62c.

📒 Files selected for processing: 7
  • backend/src/ref_backend/core/config.py
  • backend/src/ref_backend/models/about.py
  • backend/tests/test_core/test_config.py
  • changelog/141.fix.md
  • frontend/src/client/types.gen.ts
  • frontend/src/components/app/stagingBanner.test.tsx
  • frontend/src/hooks/useStagingMode.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@lewisjared

Copy link
Copy Markdown
Contributor Author

Added the preview case to the chart test in 27a34eb.

@lewisjared
lewisjared merged commit 15eb49f into main Oct 19, 2026
5 checks passed
@lewisjared
lewisjared deleted the fix/preview-environment branch October 19, 2026 23:13
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.

1 participant