Repository navigation
Commit b631573
feat(console): revoke an authorized AI assistant from Connect an Agent, and an admin widget for a person's assistants (#31084)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao5pkwaKihk9gPVY4NVju7YY)_
Part of #30894 (part 2: the assistants' Revoke, plus the ui half of the
administrator view. The card stays open for the server half: one "AI
Assistants" tab on the `sys_user` record page that names the widget
added here, filed by the seat.)
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- 改了什么:「连接 AI 助手」页里已授权的每个 AI
助手旁新增「撤销」按钮,确认后立即收回该助手的访问权限并刷新列表;删掉「暂不支持在此页面撤销」那行提示。另新增一个管理员组件
`mcp:authorized-assistants`,放在用户记录页上即可查看并撤销此人授权的助手(目前还没有页面引用它)。
- 为什么改:OAuth 授权页承诺「可以随时在账户设置中撤销访问权限」,第一部分只做了列表;服务端撤销接口 #31048
已合并,这一步把承诺补完整,并为管理员替员工撤销准备好界面。
- 风险与回滚:只调用已上线的两个撤销接口(本人 / 平台管理员),每次撤销前都要确认;管理员组件在页面引用前不会出现。回滚即还原本
PR,无数据迁移。
-
先看:ui/packages/app-shell/src/console/connect/AuthorizedAccessList.tsx(撤销流程与撤销后重读)、ManagedPersonAssistants.tsx(只从记录上下文取用户
id)、ui/packages/i18n/src/locales/en.ts(新增 5 个、删除 1 个
connectAgent.access.* 键)。
- 两分钟验证:pnpm dev 后以授权过助手的用户登录,打开 账户 → 连接 AI
助手,在某个助手上点「撤销」并确认,该行消失,该助手下一次 MCP 调用被拒绝(401)。
- 需要你做的:无,席位落地。
## What changes
- **Assistant Revoke** (`AuthorizedAccessList.tsx`). The assistants half
is now its own `AuthorizedAssistantsSection`. Every assistant row
carries a Revoke. It asks first, naming the assistant ("Revoke access
for Claude Desktop?", the unnamed fallback for a nameless client), then
calls `oauth.authorizedClients.withdraw(id)` with the row's consent id.
The list is read again after every withdraw, answered or refused: a
refusal is most often a grant already withdrawn elsewhere (the server
answers 404 for it), so its message is shown and the stale row leaves.
Revoke buttons wait while a withdraw is in flight. The
`connectAgent.access.withdrawLater` line is removed. The API-key half is
unchanged.
- **Administrator view, ui half** (`ManagedPersonAssistants.tsx`, new).
SDUI widget registered ONCE as `mcp:authorized-assistants` (`namespace:
'mcp'`, `skipFallback: true`, so no bare `authorized-assistants` and no
`app-shell:` spelling). It reads `className` from the node and one thing
from the page: the bound record from `useRecordContext()`, which must be
a `sys_user` record with an id. It takes no props. It renders
`AuthorizedAssistantsSection` with `forUserId` = that id, which lists
through `oauth.authorizedClients.listForUser(userId)` and revokes
through `withdrawForUser(userId, id)`, with the same rows and confirm.
Off a `sys_user` record (Studio palette, any other object's page, no id)
it renders nothing. Those doors are platform-admin only; anyone else
gets the server's 403 shown as a failed read, never as an empty list. No
page names the widget yet, so nothing changes on screen until the server
card (#31085) adds the tab.
- **Its `@object-ui/types` arm** (`zod/mcp-authorized-assistants.zod.ts`
`McpAuthorizedAssistantsSchema`, TS twin
`mcp-authorized-assistants.ts`), a member of `AnyComponentSchema` /
`AnySchema`, so `objectui validate` claims the type instead of refusing
it at `type` (the registered-types ratchet's namespaced pin stays 306).
Read from the widget's read points: `properties` may only be `{}`;
`body` / `children` are refused by name with the family clause. Pinned
by `mcp-authorized-assistants-arm.test.ts`; the mirror-parity pair count
moves 197 → 198 and the emit-headroom table gains the arm.
- `ui/packages/app-shell/src/index.ts` imports the widget for its
registration, and `package.json` `sideEffects` lists it (dist and src),
as for `ConnectAgentWidget`.
- `ui/packages/cli/src/utils/known-schema-types.ts` regenerated (`node
scripts/regenerate-known-schema-types.mjs`): one line,
`mcp:authorized-assistants`. The 10859 ratchet gains a row pinning that
it registered with its arm.
- **Language packs**, all eleven: added
`connectAgent.access.withdrawTitle`, `withdrawBody`, `managedBody`,
`managedEmpty`, `managedTruncated`; removed `withdrawLater`. Net +4 keys
per pack; no existing key reworded. `zh-Hant` regenerated from `zh-Hans`
with `gen:zh-hant`.
- Changeset `.changeset/30894-assistant-revoke.md`
(`@object-ui/app-shell`, `@object-ui/i18n`, `@object-ui/types`,
`@object-ui/cli`: patch).
## Tests
`AuthorizedAccessList.test.tsx`, 21 cases (12 before). New: every
assistant row has a Revoke; Revoke asks first naming the assistant,
Cancel withdraws nothing; a nameless assistant is named by the fallback;
confirm calls `withdraw('consent_2')`, re-reads the list, the row
leaves, keys are not re-read and `withdrawForUser` is not called; a
refused withdraw (grant gone) names the refusal and still re-reads. §5,
the admin widget: registered as `mcp:authorized-assistants`; on a
`sys_user` record it lists through `listForUser('user_mia')` (never
`list`) and revokes through `withdrawForUser('user_mia', 'consent_1')`,
then re-reads; empty and truncated lines speak of "this person"; a
refused read (not an admin) is named, not shown empty; off a `sys_user`
record or without an id it renders and reads nothing. The old "no
Revoke, withdrawLater shown" case is replaced by the Revoke cases.
Ablation (one-off, on committed head 5087922): replacing the admin
branch's `withdrawForUser(forUserId, client.id)` with
`withdraw(client.id)` turned §5's revoke case red (1 failed, 20 passed);
restored and verified `git diff HEAD` empty by
`scripts/ablation-replace.mjs`.
## Acceptance notes
- **Where the administrator view lands.** Setup shows one user only on
the `sys_user` record page, which is server metadata
(`packages/platform-objects/src/pages/sys-user.page.ts`, `kind: 'full'`,
its own tab strip). The console has no ui-side way to add a tab there,
so this PR ships the widget and the server card adds the tab: a
`page:tabs` item whose body is `{ type: 'mcp:authorized-assistants',
properties: {} }`. The widget needs nothing from the page but the bound
record. Gating the tab to platform administrators is the server card's
call; without it, a non-admin sees the 403 named.
- **Shared files with #30898**: `ConnectAgentWidget.tsx` is not touched.
In the packs, keys are only added and one removed; no existing string is
reworded.
- **Refusal text**: a refused withdraw shows the server's message ("No
authorized assistant you may withdraw matches the supplied id.") under
the list, and the list is re-read.
- Follow-up #31076 (refresh-family delete not scoped to the
organization) is server-side and does not change what the console calls.
## Verification
<details><summary>Both withdraw doors, live on origin/main cb8f520
(showcase, fresh; admin + two members)</summary>
- Own door `POST /auth/authorized-clients/withdraw`: the member's own
grant 200 `{id}`, and the assistant's next MCP call 401 (200 before).
Another member naming that id: 404 RESOURCE_NOT_FOUND, and the
assistant's MCP call still 200. Unknown id 404; the same id a second
time 404; missing `id` 400 VALIDATION_ERROR. The admin naming the
member's id on the own door: 404.
- Admin door `POST /auth/admin/authorized-clients/withdraw`: member
caller 403 PERMISSION_DENIED; admin with the wrong `userId` 404; admin
with the member's `userId` 200 `{id}`, the assistant's next MCP call
401, and `listForUser` then answers `[]`.
- A user created through `admin/create-user` answers 403
PASSWORD_RESET_REQUIRED on these doors until they change their password
(the server's existing rule, not new here).
</details>
<details><summary>Console, live (Vite dev against that backend), head
2583f17's code</summary>
As a member with two grants (Claude Desktop, Cursor), on Account →
Connect an Agent: both rows show a Revoke and the not-available-yet line
is gone. Revoke on Claude Desktop opened "Revoke access for Claude
Desktop? The assistant loses access at once. To use it again, it has to
be authorized again."; confirming removed the row (Cursor stays). Claude
Desktop's token then answered 401 on MCP while Cursor's still answered
200. The admin widget is not reachable live yet: no page names it
(unit-tested, §5).
</details>
<details><summary>Local gates and tests</summary>
- `pnpm --dir ui exec vitest run
packages/app-shell/src/console/connect/`: 2 files, 37 tests passed. With
`packages/i18n/`, the plugin-form `affordanceGrantMap-12082` write
census and the product-neutral ratchet: 102 files, 1859 passed, 13
skipped. After merging `origin/main` (2583f17): connect +
affordanceGrantMap + `check-side-effects-array`: 4 files, 138 passed.
- `pnpm --filter @object-ui/app-shell type-check` and `@object-ui/i18n`
type-check: exit 0. eslint on `console/connect/` and `index.ts`: 0
errors (3 existing warnings in `ConnectAgentWidget.tsx`, untouched).
- `node scripts/pm/dispatch-gates.mjs --commands` derived 51 commands on
the final change set; all 51 exit 0; `--ran` reconciliation: 51 derived,
51 run, 0 NOT-MEASURED. That includes `node
scripts/check-sdui-manifest.mjs` exit 0 and `pnpm --dir ui exec vitest
run scripts/` (170 files passed, 2 skipped) on fec0386, which first
caught the missing `sideEffects` entry (fixed in fec0386).
`check:type-check-debt` exit 0 on 5087922 (the package.json change
after it touches no `typecheck` script).
- `pnpm check:new-line-citations` (ui): 0 new citations.
- NOT MEASURED locally: the `i18n-locale-en` eager-closure ceiling
(needs the Console production build; CI's `Build & E2E UI`
`check:eager-closure` is the verdict). The ceiling is not changed.
</details>
<details><summary>CI fix round, head 5044eb2</summary>
- Cause of the red Test UI (6/16):
`registered-types-validate-ratchet-10859.test.ts` counted 308 refused
namespaced keys against the pin 306 — `mcp:authorized-assistants` and
`app-shell:mcp:authorized-assistants` had no arm. Fixed by arming the
type and registering it under one key; the pin is unchanged.
- `pnpm --dir ui exec vitest run packages/cli/ packages/types/
packages/app-shell/src/console/connect/
packages/app-shell/src/__tests__/product-neutral-renderer.ratchet.test.ts
scripts/`: 592 files passed, 2 skipped (15956 tests passed).
- `@object-ui/types`, `@object-ui/app-shell`, `@object-ui/cli`
type-check: exit 0. eslint on the new files: exit 0. ui
`check:new-line-citations`: 0 new.
- `dispatch-gates --commands`: 51 derived, all 51 exit 0, `--ran` 0
NOT-MEASURED (record: project files
ui-seat-3/r2026-11-06/30894/gates-ran-p2-510c6e36.list); changeset gates
re-run on 5044eb2 exit 0.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(No spec change.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; eslint on the touched files passes (the
repo-wide `pnpm lint` is CI's).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L9qiby1cruv4PSfF5pFmit
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qiby1cruv4PSfF5pFmit)_
<!-- signed: domain:ui#3 · os-tesla · session_01L9qibxW6qraU2Z3mwupUGp
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ddd646d commit b631573
27 files changed
Lines changed: 749 additions & 98 deletions
File tree
- .changeset
- ui/packages
- app-shell
- src
- console/connect
- cli/src
- __tests__
- utils
- i18n/src/locales
- types/src
- __tests__
- zod
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
18 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
19 | 27 | | |
20 | 28 | | |
21 | 29 | | |
| |||
55 | 63 | | |
56 | 64 | | |
57 | 65 | | |
58 | | - | |
| 66 | + | |
| 67 | + | |
59 | 68 | | |
| 69 | + | |
60 | 70 | | |
61 | 71 | | |
62 | 72 | | |
| |||
93 | 103 | | |
94 | 104 | | |
95 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
96 | 110 | | |
97 | 111 | | |
98 | 112 | | |
| |||
104 | 118 | | |
105 | 119 | | |
106 | 120 | | |
107 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
108 | 133 | | |
109 | 134 | | |
110 | 135 | | |
| |||
113 | 138 | | |
114 | 139 | | |
115 | 140 | | |
116 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
117 | 151 | | |
118 | 152 | | |
119 | 153 | | |
| |||
173 | 207 | | |
174 | 208 | | |
175 | 209 | | |
176 | | - | |
| 210 | + | |
177 | 211 | | |
178 | 212 | | |
179 | | - | |
| 213 | + | |
180 | 214 | | |
181 | | - | |
182 | 215 | | |
183 | 216 | | |
184 | 217 | | |
| |||
189 | 222 | | |
190 | 223 | | |
191 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
192 | 273 | | |
193 | 274 | | |
194 | 275 | | |
| |||
275 | 356 | | |
276 | 357 | | |
277 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
0 commit comments