feat(api): add GET /api/capabilities to expose myopencre feature flag#949
feat(api): add GET /api/capabilities to expose myopencre feature flag#949skypank-coder wants to merge 2 commits into
Conversation
MyOpenCRE was fully built but invisible because the frontend
useCapabilities hook calls /api/capabilities, which didn't exist —
the 404 resolved myopencre:false everywhere. Adds the route returning
{myopencre: <bool>} driven by the deployment flag, lighting up the
nav link and /myopencre route.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
Summary by CodeRabbit
WalkthroughAdds ChangesMyOpenCRE capabilities endpoint
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@application/tests/web_main_test.py`:
- Around line 1529-1555: The capabilities tests mutate the global
CRE_ENABLE_MYOPENCRE environment variable without restoring any preexisting
value, which can make them order-dependent. Update the three test methods in
web_main_test.py to use a scoped environment override (for example via
patch.dict) or save and restore the original value around each test, keeping the
existing assertions in test_capabilities_endpoint_returns_myopencre_key,
test_capabilities_myopencre_false_by_default, and
test_capabilities_myopencre_true_when_flag_set unchanged.
🪄 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.yml
Review profile: CHILL
Plan: Pro
Run ID: c1852a13-57d2-4cd5-84dd-933434ba1d81
📒 Files selected for processing (3)
application/feature_flags.pyapplication/tests/web_main_test.pyapplication/web/web_main.py
Use patch.dict for CRE_ENABLE_MYOPENCRE in tests so any preexisting value is restored and tests aren't order-dependent. Add docstrings to is_myopencre_enabled, get_capabilities, and the capabilities tests to satisfy docstring coverage.
Adds the missing
GET /api/capabilitiesendpoint that the frontenduseCapabilitieshook depends on. Without it the fetch 404s and the whole MyOpenCRE feature stays hidden in every environment.Changes
GET /api/capabilitiesinapplication/web/web_main.pyreturning{ "myopencre": <bool> }, mirroring the existing/rest/v1/configthin-handler style.is_myopencre_enabled()inapplication/feature_flags.py, readingCRE_ENABLE_MYOPENCREvia the existingTRUE_VALUESpattern. Defaults to off, so no existing deployment behavior changes.application/tests/web_main_test.py: key present + boolean, false-by-default, true-when-flag-set.Why a dedicated flag
MyOpenCRE download/preview is read-only and should be controllable independently of
CRE_ALLOW_IMPORT. The new flag decouples its visibility from the import feature.Verification
useCapabilities.ts→Header.tsx,routes.tsx); no FE change needed.200 {"myopencre": false}(clean 200, no more 404); flag on →200 {"myopencre": true}.Closes #948
cc @PRAteek-singHWY @Pa04rth @northdpole