fix(opencode): hide Copilot models disabled by org/enterprise policy#1131
Conversation
|
Warning Review limit reached
More reviews will be available in 39 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ 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.
Code Review
This pull request introduces filtering of GitHub Copilot models based on organization or enterprise policies, specifically excluding models where the policy state is "disabled". It also adds a corresponding test suite to verify this behavior. The review feedback suggests using .nullish() instead of .optional() in the Zod schema for the policy object and state field to prevent validation failures if the API returns null instead of undefined.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
5c30a35 to
5151950
Compare
GitHub Copilot Business/Enterprise can disable specific models via org or enterprise policy. The model-list endpoint still returns those entries with model_picker_enabled true but a policy.state of "disabled", so PawWork listed models the account is not actually allowed to use — selecting one then fails at request time. Parse the optional policy.state field and exclude models whose policy.state is "disabled" from the remote model map, in addition to the existing model_picker_enabled filter. Models with no policy or any non-"disabled" state are unaffected. Re-implements upstream anomalyco/opencode PR #23176 (0068ccec35) against PawWork's diverged github-copilot/models.ts (no common ancestor; semantic port, not a cherry-pick). Thanks to the upstream author.
5151950 to
06c23d1
Compare
Summary
Exclude GitHub Copilot models that the account's org/enterprise policy has disabled.
Two surgical edits in
plugin/github-copilot/models.ts:policy: { state?: string }field on each model entry.policy.state === "disabled"from the remote model map, in addition to the existingmodel_picker_enabledfilter.Models with no
policyor any non-"disabled"state are unaffected.Why
GitHub Copilot Business/Enterprise lets an org or enterprise admin disable specific models. The model-list endpoint still returns those entries with
model_picker_enabled: truebut apolicy.stateof"disabled". PawWork only filtered onmodel_picker_enabled, so it listed models the account cannot actually use — picking one then fails at request time.This re-implements upstream
anomalyco/opencodePR #23176 (0068ccec35) against PawWork's divergedgithub-copilot/models.ts.devandupstream/devshare no common ancestor, so this is a semantic port, not a cherry-pick. Thanks to the upstream author. (Upstream also dropped an unusedInstallationimport incopilot.ts; that is unrelated to this fix and intentionally not included here.)Related Issue
No local issue; ported from upstream PR #23176.
Human Review Status
Pending
Review Focus
The filter predicate
m.model_picker_enabled && m.policy?.state !== "disabled":policyis optional, sopolicy?.stateisundefinedfor models without it and!== "disabled"keeps them. Only an explicit"disabled"state is excluded.Risk Notes
Low. Additive optional schema field plus one filter clause; no public API change. Strictly narrows the listed set — only models explicitly marked
policy.state === "disabled"are removed. No platform/packaging/UI surface touched.How To Verify
Screenshots or Recordings
N/A — no visible UI change.
Checklist
bug,enhancement,task,documentation. Type labels are author-added; the labeler bot does NOT assign them. Add the label in the GitHub UI, then tick this.app,ui,platform,harness,ci. The labeler bot assigns these on PR open based on changed paths. Confirm the bot's choice (or override if wrong), then tick this.P0,P1,P2,P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.Pending,Approved by @<reviewer>, orNot required: <reason>(default isPending; "not required" is restricted to bot-authored low-risk PRs).dev, and my PR title and commit messages use Conventional Commits in English.