Skip to content

fix(opencode): hide Copilot models disabled by org/enterprise policy#1131

Merged
Astro-Han merged 1 commit into
devfrom
claude/copilot-policy-disabled-models
Jun 3, 2026
Merged

fix(opencode): hide Copilot models disabled by org/enterprise policy#1131
Astro-Han merged 1 commit into
devfrom
claude/copilot-policy-disabled-models

Conversation

@Astro-Han
Copy link
Copy Markdown
Owner

@Astro-Han Astro-Han commented Jun 3, 2026

Summary

Exclude GitHub Copilot models that the account's org/enterprise policy has disabled.

Two surgical edits in plugin/github-copilot/models.ts:

  • Schema: parse the optional policy: { state?: string } field on each model entry.
  • Filter: drop models whose policy.state === "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.

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: true but a policy.state of "disabled". PawWork only filtered on model_picker_enabled, so it listed models the account cannot actually use — picking one then fails at request time.

This re-implements upstream anomalyco/opencode PR #23176 (0068ccec35) against PawWork's diverged github-copilot/models.ts. dev and upstream/dev share no common ancestor, so this is a semantic port, not a cherry-pick. Thanks to the upstream author. (Upstream also dropped an unused Installation import in copilot.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": policy is optional, so policy?.state is undefined for 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

bun test test/plugin/github-copilot-models.test.ts → 8 pass / 0 fail (new "excludes models disabled by org/enterprise policy" included)
Red proof: reverted only the policy filter clause → new test fails (blocked-by-policy model still listed)
bun run typecheck (packages/opencode) → clean, no errors

Screenshots or Recordings

N/A — no visible UI change.

Checklist

  • Type label — this PR carries exactly one of 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.
  • Routing labels — this PR carries at least one of 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.
  • Priority label — this PR carries exactly one of P0, P1, P2, P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.
  • Human Review Status above is set to Pending, Approved by @<reviewer>, or Not required: <reason> (default is Pending; "not required" is restricted to bot-authored low-risk PRs).
  • I linked the related issue, or stated in Summary why there is no issue.
  • I described the review focus and any meaningful risks.
  • I replaced the example block in How To Verify with the real verification steps and the key result for each.
  • I did not introduce unrelated refactors, dependencies, generated files, or file changes beyond the stated scope.
  • (conditional) I manually checked visible UI or copy changes when needed, with screenshots or recordings. Leave unticked only if no visible UI or copy changed.
  • (conditional) I considered macOS and Windows impact for platform, packaging, updater, signing, paths, shell, or permissions changes. Leave unticked only if no platform/packaging surface was touched.
  • (conditional) I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file changes when relevant. Leave unticked only if none of those surfaces was touched.
  • I reviewed the final diff for unrelated changes and suspicious dependency changes.
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Warning

Review limit reached

@Astro-Han, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ca331d82-2b41-4947-8019-7836bf86b5a6

📥 Commits

Reviewing files that changed from the base of the PR and between 687865b and 06c23d1.

📒 Files selected for processing (2)
  • packages/opencode/src/plugin/github-copilot/models.ts
  • packages/opencode/test/plugin/github-copilot-models.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/copilot-policy-disabled-models

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 and usage tips.

@Astro-Han Astro-Han added the bug Something isn't working label Jun 3, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread packages/opencode/src/plugin/github-copilot/models.ts
@github-actions github-actions Bot added harness Model harness, prompts, tool descriptions, and session mechanics P2 Medium priority labels Jun 3, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Suggested priority: P2 (includes non-doc, non-test paths outside the low-risk bucket).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

@Astro-Han Astro-Han force-pushed the claude/copilot-policy-disabled-models branch 9 times, most recently from 5c30a35 to 5151950 Compare June 3, 2026 12:47
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.
@Astro-Han Astro-Han force-pushed the claude/copilot-policy-disabled-models branch from 5151950 to 06c23d1 Compare June 3, 2026 12:55
@Astro-Han Astro-Han merged commit 389df35 into dev Jun 3, 2026
33 checks passed
@Astro-Han Astro-Han deleted the claude/copilot-policy-disabled-models branch June 3, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working harness Model harness, prompts, tool descriptions, and session mechanics P2 Medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant