Skip to content

🤖 fix: fall back to an allowed model when admin policy excludes the VS Code webview's selection - #4811

Merged
ThomasK33 merged 4 commits into
mainfrom
fix/vscode-webview-policy-model-fallback
Sep 27, 2026
Merged

ThomasK33 merged 4 commits into
mainfrom
fix/vscode-webview-policy-model-fallback

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Summary

When the enforced admin policy excludes the VS Code webview's selected model, the composer now uses the first allowed model from its list for display and send, and a status line says which model the policy rejected and which one is used. The stored choice is never overwritten. If no listed model is allowed, the composer keeps the stored model and the status line asks the user to choose an allowed one. Before, every send failed with policy_denied with no hint until the user picked another model.

Background

The selected model can be one the policy disallows: persisted earlier, seeded from the workspace (#4778), or revoked by a policy refresh. Since #4807 the dropdown hides disallowed models, but the composer still showed and sent the stored one. Found in review of #4807. The desktop composer has no such reconciliation to reuse (it only filters the model lists), so this is webview-local.

Implementation

vscode/src/webview/ChatComposer.tsx (webview only):

  • Checks the stored model with the route-aware isAllowedByPolicyOnActiveRoute from the shared useModelsFromSettings hook, the same predicate the model list uses, because the backend enforces policy after routing. The check uses the gateway-preserving identity (normalizeSelectedModel), so an explicitly pinned gateway model is checked on that gateway.
  • If excluded, picks the first entry of the (already policy-filtered) models list that passes the same check. That model drives the selector, the thinking control, model cycling, and the send's model option. The send overrides model only in this case, so the normal send keeps the stored model string as before.
  • Nothing is written: no localStorage change and no updateAgentAISettings call, because webview persistence is off (🤖 fix: VS Code webview first send overwrites workspace AI settings with webview defaults #4755/🤖 feat: persist explicit AI-setting changes from the VS Code webview #4781). If the policy later allows the stored model again, it comes back by itself.
  • No allowed listed model (for example, the policy only allows an unlisted custom model): nothing else changes; the status line says so and the backend decides, as before.
  • The status line is a role="status" text line above the model selector, using the text-content-secondary token.

Review history: round 1 asked for the route-aware check and for /vim to keep working in a "Send disabled" state; round 2 found the check dropped explicit gateway IDs and the disabled button still blocked /vim by mouse. Both rounds clustered on the blocking state, so it was removed (scope reduction) instead of adding more special cases.

Validation

  • Test-first in App.test.tsx (TestBridge now has an answer(path, value) helper that plays the host's orpcResponse), with policy.get answered with an enforced policy and the stored model anthropic:claude-opus-5-5:
    1. Policy allows only openai:gpt-5.6-terra: the status line names the rejected model, the send carries model: "openai:gpt-5.6-terra", the stored model is unchanged, and no updateAgentAISettings is posted. On main: no status line, and the send carries anthropic:claude-opus-5-5.
    2. Policy allows only an unlisted model: status line shown and the send carries the stored model. On main: no status line.
    3. Policy allows the stored model: no status line and the send is unchanged (guards the normal path).
  • A gateway-pinned regression test is not possible in the webview yet: it resolves routes without the providers config until 🤖 fix: VS Code webview does not load app/providers config (thinking floors, model list) #4766 connects it (PR in flight), so an explicit gateway currently falls back to the direct route there.
  • Served-bundle dogfood (🤖 fix: render and send in the VS Code webview after workspace selection #4740 harness, policy.get answered with an enforced policy allowing openai:gpt-5.6-terra and gpt-5.6-sol, stored model Opus 5.5):
    • The composer showed "Admin policy does not allow anthropic:claude-opus-5-5; using openai:gpt-5.6-terra." with GPT-5.6 Terra selected.
    • Send posted workspace.sendMessage with model: "openai:gpt-5.6-terra" and skipAiSettingsPersistence: true; no updateAgentAISettings post; localStorage["model:ws-demo"] stayed "anthropic:claude-opus-5-5". 0 console errors.
    • With a policy that allows only an unlisted model: "Admin policy does not allow anthropic:claude-opus-5-5. Choose an allowed model." and Send stays enabled.

Fallback, 800px:

Policy fallback status line, 800px

Fallback, 390px:

Policy fallback status line, 390px

No allowed listed model, 800px:

No allowed listed model, 800px

Risks

Low, webview only. The webview does not load routing preferences or the providers config until #4766, so today the active route is the default one and "first allowed model" means the first allowed built-in model.

Fixes #4808


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $4.48

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T02:53:17.671295Z cab8bac New commits
🔒 Security Review ✅ Completed 2026-09-27T02:53:33.735550Z cab8bac New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: c080dcf990

ℹ️ 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 thread vscode/src/webview/ChatComposer.tsx Outdated
Comment thread vscode/src/webview/ChatComposer.tsx

@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: e0a2f6f3b2

ℹ️ 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 thread vscode/src/webview/ChatComposer.tsx
Comment thread vscode/src/webview/ChatComposer.tsx Outdated
@ThomasK33
ThomasK33 force-pushed the fix/vscode-webview-policy-model-fallback branch from e0a2f6f to 1cc93ee Compare September 27, 2026 02:36

@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: 1cc93ee31f

ℹ️ 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 thread vscode/src/webview/ChatComposer.tsx Outdated
@ThomasK33
ThomasK33 force-pushed the fix/vscode-webview-policy-model-fallback branch from 1cc93ee to cab8bac Compare September 27, 2026 02:49

@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: cab8bac8ed

ℹ️ 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 thread vscode/src/webview/ChatComposer.tsx
@ThomasK33
ThomasK33 added this pull request to the merge queue Sep 27, 2026
Merged via the queue into main with commit f31ed52 Sep 27, 2026
57 of 60 checks passed
@ThomasK33
ThomasK33 deleted the fix/vscode-webview-policy-model-fallback branch September 27, 2026 03: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.

🤖 fix: VS Code webview keeps a policy-revoked model selected

1 participant