You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a8e794f
Browse filesBrowse the repository at this point in the historyBrowse files
fix(console): keep the OAuth consent page finished after a decision, with an outcome card for app-scheme redirects (#34369)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9STQV6FBnGhfrvF3mZr4ymB)_Fixes#34349
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:OAuth 同意页一旦提交了授权/拒绝并拿到跳转地址,就进入终态,按钮不再恢复可点;跳转是 App 协议(如
`workbuddy://`)时,页面换成结果卡:已授权/已拒绝、「返回该应用,可关闭此标签页」,外加一个再次打开该应用的链接。
- **为什么改**:WorkBuddy
等桌面客户端用自定义协议回调,浏览器把地址交给系统后标签页不离开,同意卡原样回来、按钮又可点;用户以为没成功,再点一次就用已作废的请求重提,弹出「Consent
failed」。
- **风险与回滚**:只改 Console 同意页与语言包,无服务端/契约改动;`http(s)` 回调(含
loopback)照旧整页跳走,服务端拒绝时照旧提示并恢复按钮。回滚即 revert 本 PR。
- **先看**:`ui/apps/console/src/pages/auth/OAuthConsentPage.tsx` 的
`handleDecision`(`terminal` 与 `setHandedOff`)和新增的结果卡分支;其次同目录
`__tests__/OAuthConsentPage.public-client-12301.test.tsx` 末尾的 `after a
decision` 一组。
- **两分钟验证**:`pnpm --dir ui exec vitest run
apps/console/src/pages/auth/__tests__/OAuthConsentPage.public-client-12301.test.tsx`,预期
28 个测试全过。
- **需要你做的**:无,席位落地。
## What changes
- `OAuthConsentPage.handleDecision`: once the server answers a decision
with a redirect, the signed query is spent, so the page is terminal for
every redirect kind. The `finally` no longer re-enables Authorize and
Deny after a redirect (`terminal` flag); a decision the server refuses
(no redirect, non-2xx) still toasts and re-enables them as before.
- A redirect that is not `http(s)` (a native app's custom scheme) is
still handed to the browser (`window.location.assign`), and the page
replaces the consent card with an outcome card
(`data-testid="oauth-consent-handed-off"`): "Access granted" / "Access
denied" (the existing `granted` / `denied` keys), "Return to APP to
continue. You can close this tab.", and an "Open APP" link whose `href`
is the same redirect, in case the browser's open-the-app prompt was
dismissed. With no identified client name, the unnamed forms are used.
- The http(s)-or-not test is the one `redirectDestination` already used,
extracted as `webRedirectHost` beside it; `redirectDestination` now
calls it, so there is one copy of the test.
- The tab navigation is now spelled `window.location.assign(redirect)`
instead of assigning `window.location.href` (same navigation; it makes
the location write observable to the pins).
- `window.close()` is not attempted.
- i18n: four new keys under `oauth.consent` (`returnToApp`,
`returnToUnnamedApp`, `openApp`, `openUnnamedApp`) in all eleven Console
packs; zh-Hant generated with `pnpm --filter @object-ui/i18n
gen:zh-hant`.
- Changeset: `.changeset/34349-oauth-consent-app-scheme-terminal.md`
(`@object-ui/console`, `@object-ui/i18n`: patch).
## Tests
New top-level `describe('OAuthConsentPage — after a decision')` in the
existing shared harness file
`OAuthConsentPage.public-client-12301.test.tsx` (its `stubLookup` gained
an optional decision answer):
- Authorize, and Deny, with a `workbuddy://` redirect: the outcome card
shows the outcome and the app name, the "Open" link carries the
redirect, `location.assign` was called once with it, no button is left
on the page, and exactly one decision POST was sent with `{ accept,
oauth_query }`.
- An unidentified client: the outcome card uses the unnamed forms.
- CONTROL, an `https://` redirect and a loopback `http://127.0.0.1`
redirect: `location.assign` is called with the redirect, no outcome
card, and Authorize / Deny stay disabled after the decision settles.
- CONTROL, a refused decision (400): buttons are disabled while in
flight, enabled again after, consent card kept, no navigation.
No forced edits to existing tests.
## Acceptance notes
- None filed. The other two consent test files (`agent-scopes-12853`,
`mcp-scopes-26587`) were not touched.
## Verification
<details><summary>Tests (head after the last code commit)</summary>
- `pnpm --dir ui exec vitest run
apps/console/src/pages/auth/__tests__/OAuthConsentPage.public-client-12301.test.tsx`
→ Test Files 1 passed, Tests 28 passed.
- `pnpm --dir ui exec vitest run apps/console/src/pages/auth/__tests__/
packages/i18n/` → 137 files, run before the label fix: only the three
new pins that looked up the in-flight "Authorizing…" label failed; fixed
in the next commit and the file re-run green (above).
- `pnpm --filter @object-ui/console --filter @object-ui/i18n run
type-check` → both Done, lock VERDICT command-exit 0.
- `pnpm --dir ui exec eslint` on the two changed console files → exit 0.
`pnpm --dir ui run check:new-line-citations` → 0 new citations.
</details>
<details><summary>Ablations (scripts/ablation-replace.mjs, mutation
proven on disk, restored to HEAD blob 51a03ea)</summary>
- A: `if (!terminal) setSubmitting(false);` → `setSubmitting(false);`
(buttons re-armed after a redirect): the two http(s) CONTROL pins go red
(2 failed / 26 passed).
- B: delete `if (webRedirectHost(redirect) === null) setHandedOff({
accept, redirect });` (no outcome card): the Authorize, Deny and unnamed
custom-scheme pins go red (3 failed / 25 passed).
</details>
<details><summary>Derived gate families</summary>
Head `6b6a0a53`, `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` (same list re-derived on this head): 40
commands, all exit 0. `--ran` reconciliation: 40 derived, 40 run, 0
NOT-MEASURED, 0 UNRUN.
```text
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-sdui-manifest.mjs :: exit 0
node scripts/check-sdui-manifest.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --dir ui exec vitest run scripts/ :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:adr-anchors :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:merge-driver :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:role-word :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
```
Every family CI runs is read from this PR's check-runs, not re-run here.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmRAAikoiFeHPhvRdyB)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(console): the OAuth consent page stays finished after Authorize or Deny when the client's redirect is an app scheme
7
+
8
+
Clause-②: no
9
+
Metadata-protocol: none
10
+
11
+
Desktop and native MCP clients (such as WorkBuddy) register a redirect with their own scheme (`workbuddy://…`). After Authorize, the browser hands that address to the app but keeps the tab where it is. The consent page then put its card back with Authorize and Deny enabled again. A person could not tell that the connection had worked, and a second click sent the already-used request again and showed "Consent failed".
12
+
13
+
Once the server answers a decision with a redirect, the page now treats the request as finished and never enables the buttons again. For an app-scheme redirect it replaces the consent card with the outcome ("Access granted" or "Access denied"). It tells the person to return to the application and that they can close the tab. It also shows an "Open" link to the same redirect, in case the browser's prompt to open the app was dismissed. An `http(s)` redirect, including a loopback one, still navigates the tab away as before. A decision the server refuses still shows the error and enables the buttons again. The new sentences are in every Console language pack.
0 commit comments