Skip to content

fix(desktop): enforce "Only models you provide" from AI Gateway - #5433

Merged
benjaminshafii merged 7 commits into
devfrom
fix/enforce-managed-providers-policy
Sep 29, 2026
Merged

benjaminshafii merged 7 commits into
devfrom
fix/enforce-managed-providers-policy

Conversation

@reachjalil

@reachjalil reachjalil commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

What is this about?

On the AI Gateway page in Den, Who can use models lets an admin pick Only models you provide, so members cannot add their own provider keys. This PR makes the desktop and web app respect that choice.

What problem does it solve?

Den saves the choice, but the app ignores it. Members can still add, pick and use their own API keys.

What was the situation before?

The choice is stored as allowCustomProviders: false in the organization's default desktop policy. #5131 switched off every desktop policy check, because loading them could block startup and chat, and that switched this off too.

How is this implemented?

Only allowCustomProviders is enforced, as the AI Gateway's model access. The old desktop policies stay off, including allowZenModel, so OpenCode Zen is left as it is today.

Where What it does
App (desktop and web) The picker, command palette and Settings list only lpr_, ipr_ (AI Gateway) and openwork models. Adding a personal provider shows the existing notice.
OpenWork server Refuses sign-ins to personal providers and sends that use one.
Engine enabled_providers lists only the allowed providers.

It never blocks or slows anything:

  • The setting loads in the background.
  • If Den is down, the last known setting is used. If none is known, nothing is restricted. Signing out clears it.
  • Each send is checked locally, and the message is not read unless the setting is on.
  • Orgs without the setting see no change.

Known gap: a change reaches the desktop at its next start or sign-in.

What else changed?

  • Two session-model-catalog cases expected Zen to be hidden. They now expect it unchanged, and the file passes (it fails on dev).

Release note

When your organization chooses "Only models you provide" in AI Gateway, members can no longer add or use their own API keys in OpenWork.

Evidence

  • New e2e model-access-picker: on dev the member's own key shows, which fails. On this branch only the organization's model shows, which passes.
  • New e2e model-access-gateway: with the setting on, a member still picks the organization's AI Gateway model and gets an answer through the real Gateway (v1 on this commit, v2 on an earlier one).
  • Server (93) and app (17) policy tests pass. Server, app, electron and evals typechecks are clean.

Enforce allowCustomProviders and allowZenModel from the member's desktop
policy while every other desktop policy key stays suspended.

The server keeps the last verified policy per sign-in, reads it in the
background, and never waits on Den, so loading or failing to load the
policy never blocks startup, sign-in, or chat. With no known policy the
desktop stays open. Signing out clears it. Engine sign-ins and sends are
checked locally against the known policy, and the engine only lists the
organization's providers, plus Zen when allowed. Orgs without the policy
see no change.
@reachjalil
reachjalil requested a review from a team September 28, 2026 20:25
@vercel

vercel Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openwork-app Ready Ready Preview Sep 29, 2026 12:22am UTC
openwork-den Ready Ready Preview Sep 29, 2026 12:22am UTC
openwork-diagnostics Ready Ready Preview Sep 29, 2026 12:22am UTC
1 Skipped Deployment
Project Deployment Actions Updated
openwork-landing Ignored Ignored Preview Sep 29, 2026 12:22am UTC

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

OpenWork evidence

Status Commit Preview Updated
🟢 Ready · evidence passed 1bb6631 Open preview 2026-09-29 00:27:01 UTC

Run details · Open the preview to inspect evidence and sandbox options.

Sends are only read when the member's known policy limits providers, so
members without the policy never pay for the check.
@vercel
vercel Bot temporarily deployed to Preview – openwork-app September 28, 2026 20:37 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics September 28, 2026 20:37 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-landing September 28, 2026 20:37 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-den September 28, 2026 20:37 Inactive
@github-actions
github-actions Bot temporarily deployed to Evidence / PR 5433 September 28, 2026 20:44 Inactive
…roviders

With the organization allowing only managed providers and Zen off, a
member still sees the organization's Gateway model and gets an answer
through the real Gateway on both engines. On v1 the engine allow-list
holds only the Gateway provider.
@github-actions
github-actions Bot temporarily deployed to Evidence / PR 5433 September 28, 2026 22:05 Inactive
Den's "Free starter model (Auto)" switch is stored as allowZenModel. On
allows OpenWork's free Auto and OpenCode Zen, off blocks both, whether or
not members may add their own providers. The app, server and engine read
one shared list of those providers.

The AI Gateway dialog now saves the switch in both modes, and both Den
screens describe it the same way.
…cess

The AI Gateway's "Who can use models" setting is stored in the default
desktop policy. Name the enforcement after that setting so it stands on
its own while every other desktop policy stays off, and rename the e2e
specs to model-access-picker and model-access-gateway.
@reachjalil reachjalil changed the title fix(desktop): enforce only-managed-providers policy again fix(desktop): respect the AI Gateway "Who can use models" setting Sep 28, 2026
@github-actions
github-actions Bot temporarily deployed to Evidence / PR 5433 September 28, 2026 23:06 Inactive
Free Auto is not on dev, so the free starter model switch covers
OpenCode Zen only. Free Auto adds its provider to the same list in its
own change. The Den models page keeps its original switch label.
The PR now prevents custom models when the AI Gateway is set to
"Only models you provide" (allowCustomProviders: false) and nothing
else. allowZenModel stays off with the old desktop policies, so OpenCode
Zen is unchanged, and the Den screens are left as they are on dev.
@reachjalil reachjalil changed the title fix(desktop): respect the AI Gateway "Who can use models" setting fix(desktop): enforce "Only models you provide" from AI Gateway Sep 29, 2026
@benjaminshafii
benjaminshafii merged commit b00afe8 into dev Sep 29, 2026
32 checks passed
reachjalil added a commit that referenced this pull request Sep 29, 2026
…perience

Brings in dev through 6d956e0, including #5433 (enforce "Only models
you provide" from AI Gateway). The app-web runtime test imports dev's
moved preview-app-web world. openapi.json and the SDK are regenerated.
reachjalil added a commit that referenced this pull request Sep 30, 2026
…perience

Brings in dev through 6d956e0, including #5433 (enforce "Only models
you provide" from AI Gateway). The app-web runtime test imports dev's
moved preview-app-web world. openapi.json and the SDK are regenerated.
reachjalil added a commit that referenced this pull request Oct 2, 2026
…xture

Since #5433 installing an identity reads Den policy without waiting for it,
so checking for that read right after the 204 raced and failed at random.
reachjalil added a commit that referenced this pull request Oct 2, 2026
…xture

Since #5433 installing an identity reads Den policy without waiting for it,
so checking for that read right after the 204 raced and failed at random.
reachjalil added a commit that referenced this pull request Oct 3, 2026
…xture

Since #5433 installing an identity reads Den policy without waiting for it,
so checking for that read right after the 204 raced and failed at random.
benjaminshafii pushed a commit that referenced this pull request Oct 3, 2026
* fix(app): restore AI Providers row layout and footer after the Auto picker

Organization provider rows put the name and status at the far right because
the provider icon became a separate child of a justify-between row. Group the
icon with the text, move "Managed in Den" into the section title as a pill,
drop the duplicate "AI Providers" heading by putting Connect a provider on the
"On this device" header, keep the Connect a provider footer stacked so the
organization line stops wrapping, and share one Auto meta line between
Settings and the sheet.

* feat(app): redesign AI Providers and Connect a provider to match the design

Settings › AI Providers now follows the AI Providers design: the page header
carries Connect a provider, both sections use one bordered list of rows (tile,
name, status, monospace id and meta line), organization rows show who Den
grants them to and whether the key is shared or per member, the sync footer
sits inside the list, and signed-out members see a "No organization yet" card.

Connect a provider gets a visible description, sentence-case groups with
counts, one subtitle per provider that says how it connects, a single Connect
action, a footer with the organization and keyboard hints, wrapping instead
of truncated subtitles, and a capped height so long lists scroll inside it.

Built-in OpenCode Zen without a key of its own is offered under Available to
add instead of being listed as connected. The desktop now reads Den's
provider access and credential mode, which the usable-provider list already
returns.

* test(evals): align first-send spec with the current chat chrome and failed-send recovery

The mobile chrome probe looked for the sidebar toggle inside the session
pane, but it renders in the chat column beside it, so the count was always
zero and the overflow check could never fail. Scope both to the sidebar
inset.

Since #5167 a rejected first send stays in the conversation with Retry
instead of moving the prompt back into the composer. Assert that: one user
message, the inline error and Retry sending, no session and no model request.

* test(evals): bring the first-send spec up to date with the current app

The spec still described the app from before #5164, #5167 and #5196:

- First send: since #5167 the sent message shows at once in a provisional
  conversation and stays there until the session exists. The slow-creation
  and handoff steps now assert that (one user message, no flicker, one
  creation and no prompt before release) instead of an unchanged hero with
  no user row. The transition sampler records the provisional conversation.
- Mobile sidebar: Escape closes the Chat actions menu, then the sidebar; wait
  for each layer to finish closing instead of pressing twice at once.
- Model picker: since #5196 it opens straight onto its searchable list; the
  "Model" drill-in is gone. On v2, Connect more providers falls back to
  Settings › AI Providers, so the spec continues from Connect a provider there
  and returns with Back to app.
- While the first send is pending the dock is read-only, so the editor no
  longer keeps focus; its position is still checked.
- The New task heading is "What do you need done?" again (#5483).

* fix(chat): keep a new mobile turn at the top on OpenCode v2

On phones a sent message is pinned to the top of the transcript with space
reserved for its answer. The controller tracked the turn by the ID the
composer generated, but OpenCode v2 gives the message its own ID, so the
optimistic row is replaced (or never rendered) and the turn was dropped:
no space was reserved and the new turn sat below the top.

When the tracked ID is not on screen, follow the newest user turn that was
not already there when the message was sent.

* test(evals): wait for the background Den policy read in the outage fixture

Since #5433 installing an identity reads Den policy without waiting for it,
so checking for that read right after the 204 raced and failed at random.

* fix(app): drop status words from Connect a provider and capitalize its sections

Connected providers show how they connect and no action; only providers not yet
added offer Connect. OpenWork Models drops Included, Free, No account needed and
the weekly limit line, here and in Settings. Section labels read ON THIS DEVICE
and AVAILABLE TO ADD, as in the design.

Evidence: evals/specs/connect-provider-dialog.e2e.test.ts

* test(evals): record what the Connect a provider spec proves so the evidence report is complete

* fix(app): keep the design's provider filter placeholder in Connect a provider

The search field reads Filter providers by name or ID again (Model selector
B2, D2), so the live provider spec needs no change.

* test(evals): wait for the desktop header to return before checking it

After resizing from phone to desktop the spec only waited for the shell height,
then checked the header at once; the title can render a frame later.

* test(evals): describe the visible Retry text in the failed-send screenshot claim

The button reads 'Retry'; 'Retry sending' is its accessible label, which
the role assertion above already checks.

Signed-off-by: Benjamin Shafii <[email protected]>

---------

Signed-off-by: Benjamin Shafii <[email protected]>
Co-authored-by: ben <[email protected]>

This branch was successfully deployed

4 active and 1 inactive (outdated) deployments
Evidence / PR 5433 — 1bb6631a Deployed Sep 29, 2026 by github-actions[bot]
Preview – openwork-app — 1bb6631a Deployed Sep 29, 2026 by vercel[bot]
Preview – openwork-den — 1bb6631a Deployed Sep 29, 2026 by vercel[bot]
Preview – openwork-diagnostics — 1bb6631a Deployed Sep 29, 2026 by vercel[bot]
Preview – openwork-landing — c97c4db3 Deployed Sep 29, 2026 by vercel[bot]
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.

2 participants