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 e100a37
Browse filesBrowse the repository at this point in the historyBrowse files
fix(approvals): the approval e-mail link and the action page's inbox link open the Console under its mount (#36247)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X8UqWLrzTYpuat8L5eLdf2c)_Fixes#34862
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
-
审批人点开审批邮件里的「打开审批」链接,以前在默认部署上看到的是一个“找不到”的错误页,现在直接打开控制台里的这条审批请求;审批完成页上的「打开审批中心」链接也一样修好了。
- 属于审批与通知的整体工作:每位审批人收到的邮件唯一的链接是坏的,这次把它修好。
- 出错的话,审批人点邮件链接仍会落到错误页或错误路径,但不影响在控制台内直接审批;本改动可直接撤回。
- 无。
## What changes
The approval e-mail's link (`approvalUrl`, built in `notify()`) and the
action-link result page's "Open the Approvals Inbox" link now carry the
Console's mount. The mount is not written in plugin-approvals: it is
read from the auth service's Console page composer, `getConsoleUrl`
(`AuthManager.getConsolePageUrl`, which reads `AuthConfig.uiBasePath`,
default `/_console`). That is the composer the auth e-mails and the
mention e-mail (`plugin-audit`) already use, so the approval links now
follow the same one setting.
- `public-base-url.ts`: new `consolePageLink(publicBaseUrl, composer,
pagePath)`. The origin is `publicBaseUrl` (#30509's no-guess origin rule
is unchanged; the composer's own origin is dropped). Only the composer's
PATH is taken, minus any base path the two share, so a sub-path
deployment is not prefixed twice. No composer, a composer that throws,
or one that answers no URL gives no mount: the e-mail link is then the
one built before, and the inbox link is `BASE/system/approvals`.
- `approvals-plugin.ts`: reads `ctx.getService('auth').getConsoleUrl`
lazily at link time (the same reader `audit-plugin.ts` uses), and passes
it to the service. The raw-app action-page mount builds the inbox href
through the same function.
- `approval-service.ts`: `ApprovalServiceOptions.getConsoleUrl`
(optional, additive). `approvalUrl` = `consolePageLink(publicBaseUrl,
getConsoleUrl, actionUrl)`. The action page's inbox link moves from the
origin-relative `/system/approvals` to `BASE/_console/system/approvals`
(relative `/_console/system/approvals` when no base resolves;
`BASE/system/approvals` with no mount to read). `handleActionPage` and
the plugin's raw-app door build it through the same function, so the two
action-page doors still answer the same bytes.
- `action-link-pages.ts`: `renderResultPage` takes an optional
`inboxHref` (default: the bare route, as before). `APPROVALS_INBOX_PATH`
names the route.
- The in-app `actionUrl` (`/system/approvals?request=ID`) is unchanged:
the Console routes on it.
Files outside the claim's named surface, named before editing:
`approvals-plugin.ts` (the wiring), `public-base-url.ts` and
`public-base-url.test.ts` (the helper and its pins). The one source of
truth used is `AuthConfig.uiBasePath`, through the auth service's
`getConsoleUrl`. No `packages/spec/**` change and no new export; the one
public-surface change is the optional
`ApprovalServiceOptions.getConsoleUrl` member.
## Measured hops (real `os dev` boot, the showcase, which runs `serve
--dev`)
Boot: `objectstack dev --seed-admin --fresh -p 38617`,
`OS_BASE_URL=http://localhost:38617`, SMTP pointed at a local sink
(`OS_EMAIL_PROVIDER=smtp`, `OS_MAIL_SMTP_HOST=127.0.0.1`,
`OS_MAIL_SMTP_SECURE=false`), Console built (`pnpm console:build`, the
`console-static` plugin loaded). Trigger: sign in as the seeded admin
and retitle the "Q3 field-ops rollout" announcement, which opens
`showcase_dynamic_approval` (`approval.requested` to the admin). The URL
was read from the e-mail the sink received.
<details><summary>Before (origin/main a5a5312)</summary>
- E-mail: `Open the approval:
http://localhost:38617/system/approvals?request=areq_d3e65840-cc6b-43cf-877c-a2b5402aab42`
- `GET` that URL, anonymous: `404`, `application/json`,
`{"success":false,"error":{"code":"ENDPOINT_NOT_FOUND","message":"Not
found"}}`, no `Location`.
- Same URL signed in, following redirects: `404`, 0 redirects, the same
JSON. Chromium: one navigation, `404`, page text is that JSON.
- Action-link page inbox link `/system/approvals`: `404`.
- Control: the same path under the mount,
`/_console/system/approvals?request=...`: `200 text/html` with the base
href set to the mount; in Chromium it opens the request ("Q3 field-ops
rollout", Pending, Approve / Reject).
</details>
<details><summary>After (this branch, plugin-approvals
rebuilt)</summary>
- E-mail: `Open the approval:
http://localhost:38617/_console/system/approvals?request=areq_9dac833e-7dad-48d7-bb38-4c6c8b6b82cd`
- `GET` anonymous: `200 text/html`. Signed in, following redirects:
`200`, 0 redirects, the base href is the mount.
- Chromium: one navigation, `200`, then the Console routes to
`/_console/apps/com.objectstack.setup/sys_approval_request/record/areq_9dac833e-...`,
which shows the request (title, Pending, Lead Review, Approve / Reject).
- `GET /api/v1/approvals/act?token=not-a-token`: `200`, and the inbox
link is `http://localhost:38617/_console/system/approvals`, which
answers `200`.
</details>
Root mount: no boot on this tree serves the Console at `/`.
`createConsoleStaticPlugin` always mounts at `CONSOLE_PATH`
(`/_console`), and `os serve` passes no `uiBasePath` to `AuthPlugin`, so
it is always `/_console` there. A deployment that serves the Console at
`/` tells the platform through `AuthConfig.uiBasePath: '/'`. That case
is pinned at the service with the auth composer's exact composition: the
link stays `BASE/system/approvals?request=ID`. Not measured on a real
boot, because no boot here can produce it.
## Tests
- `approval-service.test.ts`, new top-level describe "Console page links
carry the Console mount": e-mail link under `/_console`, under `/`, the
action page's inbox href under both, and no auth service (the e-mail
link as before, the inbox link `BASE/system/approvals`).
- `public-base-url.test.ts`, `consolePageLink`: composer origin ignored,
root mount, shared sub-path, no base, and no composer / undefined /
throws / not a URL.
- `pnpm --filter @objectstack/plugin-approvals typecheck`: exit 0,
test-typecheck debt held. `pnpm --filter @objectstack/plugin-approvals
test`: 126 files, 1817 tests passed.
Ablations (src-imported suite, both legs through
`scripts/ablation-replace.mjs` with a disk-verified mutation and a
HEAD-blob restore):
- Mount dropped (`${publicBaseUrl}${pagePath}`): the `/_console` e-mail
pin and the action-page pin go red (2 failed / 2 passed). The root and
no-auth pins stay green.
- Mount hard-coded (`${publicBaseUrl}/_console${pagePath}`): the root
pin, the action-page pin and the no-auth pin go red (3 failed / 1
passed).
- Restored: `git diff HEAD` empty, blob `1e946f96f358` equal to HEAD.
## Acceptance notes
- With no auth service in the kernel (for example `os serve` in
production without `OS_AUTH_SECRET`, where `AuthPlugin` is skipped),
there is no mount to read: the e-mail link stays as before, and the
inbox link becomes `BASE/system/approvals` (it was the origin-relative
`/system/approvals`). Nobody can sign in to such a deployment's Console,
so its approvals inbox cannot be used anyway.
- With no `publicBaseUrl` the e-mail link is still relative, now under
the mount (`/_console/system/approvals?...`) when the auth service
answers; the inbox link is then the relative
`/_console/system/approvals`.
## Verification
First files to read, by risk:
1. `packages/plugins/plugin-approvals/src/public-base-url.ts`,
`consoleMountPath`: the base-path strip is the one subtle line.
2. `packages/plugins/plugin-approvals/src/approvals-plugin.ts`: the lazy
auth reader, and the raw-app mount's inbox href.
3. `packages/plugins/plugin-approvals/src/approval-service.ts`, the
`approvalUrl` hunk in `notify()`.
Two-minute check: `pnpm --filter @objectstack/plugin-approvals exec
vitest run src/approval-service.test.ts -t "Console page links carry the
Console mount"` shows 4 passed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01FEkQ5pb2t8Z8C64PkPyVt1
<!-- signed: repo:objectstack#4 · os-project-manager ·
session_01FEkQ5pb2t8Z8C64PkPyVt1 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(approvals): the approval e-mail's link and the action-link page's inbox link open the Console under its mount
6
+
7
+
Clause-②: yes (widening)
8
+
Metadata-protocol: none
9
+
10
+
The approval e-mail's "Open the approval" link was `BASE/system/approvals?request=ID`. `os serve` serves the Console at `/_console/` and nothing at `/system/*`, so the link answered `404 ENDPOINT_NOT_FOUND` and the request never opened. The "Open the Approvals Inbox" link on the action-link result page (`/api/v1/approvals/act`) had the same defect.
11
+
12
+
Both links now carry the Console's mount. The mount is read from the auth service's Console page composer (`getConsoleUrl`, which reads `AuthConfig.uiBasePath`, default `/_console`), the same composer the auth e-mails and the mention e-mail use.
13
+
14
+
- The e-mail link goes from `BASE/system/approvals?request=ID` to `BASE/_console/system/approvals?request=ID` on a default deployment. A deployment that sets `uiBasePath` to `/` keeps `BASE/system/approvals?request=ID`. Its base is still the approval links' own (`publicBaseUrl`, else `OS_AUTH_URL` / `OS_BASE_URL`). A kernel with no auth service has no mount to read, and the e-mail link stays as it was.
15
+
- The inbox link goes from the origin-relative `/system/approvals` to `BASE/_console/system/approvals`. It is now absolute under the approval links' base when one resolves, and relative (`/_console/system/approvals`) when none does. With no mount to read (no auth service, or `uiBasePath` set to `/`) it is `BASE/system/approvals`.
16
+
17
+
The widening: the exported `ApprovalServiceOptions` gains the optional `getConsoleUrl` that carries the composer; the in-app `actionUrl` is unchanged.
0 commit comments