Repository navigation
Commit f4b1f9e
fix(console): register the push device without an origin the spec refuses (#31513)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9Ubb6etUG8W3NiG1863Cn9e1Ry)_
Fixes #31472
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:Console 注册移动端推送设备时,只有当发布的 `RegisterDeviceRequestSchema` 的
`origin` 成员接受 `window.location.origin` 才带上它;否则不带 `origin` 照常注册。
- **为什么改**:主机名带下划线(内网/compose 服务名)或末尾带点的自托管 Console,原来发出的 origin
被服务端整体拒收(400),这台设备收不到任何推送;spec 文档块写的是「此时生产者不带 origin」。
- **风险与回滚**:风险低,只影响这两类主机,其余主机照旧带 origin;回滚即还原
`nativePushRegistration.ts` 一个函数。
- **先看**:`ui/apps/console/src/nativePushRegistration.ts` 的
`registrationOrigin()`;其次是测试文件末尾新增的 describe。
- **两分钟验证**:`cd ui && pnpm exec vitest run
apps/console/src/__tests__/nativePushRegistration-29042.test.tsx`,预期 20
个用例全绿。
- **需要你做的**:无,席位落地。
## What changes
- `registrationOrigin()` in
`ui/apps/console/src/nativePushRegistration.ts` keeps the page origin
only when
`RegisterDeviceRequestSchema.shape.origin.safeParse(location.origin).success`,
with the schema imported from `@objectstack/spec/api`. That is the
schema the runtime door parses the whole registration body with, so the
producer and the door cannot disagree. No regex is copied and no spec
export is added: `PUSH_SERVER_ORIGIN_PATTERN` is internal to
`@objectstack/spec` (route recorded in claim amendment 6720762259).
- A host with an underscore (`http://my_svc:3000`) or a trailing dot
(`https://crm.example.com.`) now registers its device without `origin`,
as the `push-server-origin.ts` docblock says; its pushes carry no
origin. Every other http or https host still sends its origin, and a
non-http(s) page still sends none.
- One root changeset, `.changeset/31472-push-origin-underscore-host.md`
(`@object-ui/console` patch).
## Tests
- New top-level describe in the shared harness
`ui/apps/console/src/__tests__/nativePushRegistration-29042.test.tsx`:
an underscore host and a trailing-dot host answer no origin, a normal
host with a port and a dotted IPv4 host keep theirs; and, with the page
URL moved to each refused host, the full registration flow sends a body
with no `origin` that `RegisterDeviceRequestSchema` accepts, while the
same body naming the page origin is refused.
- CONTROL: the existing registration and unregister tests in that file
and `App.nativeShellMode-29039.test.tsx` stay green (2 files, 37 tests).
- Ablation (`scripts/ablation-replace.mjs`, guard line replaced by
`return location.origin;`): the 3 new cases go red, the other 17 in the
file stay green; restore verified blob == HEAD and `git diff HEAD`
empty.
## Acceptance notes
- `registrationOrigin()` keeps its explicit http/https check ahead of
the schema judge; the schema alone would also refuse `"null"`, so the
check is documentation of intent rather than a second rule.
## Verification
All readings on objectstack `claude/project-thread-4wp8tl`; the derived
gates at `075c3ef6`, the re-runs at merged head `16fff1a7` (main
`2ae3e301` plus 4 commits, none touching these files).
<details><summary>Derived gates: 36 of 36 exit 0 (dispatch-gates --ran:
0 NOT-MEASURED, 0 UNRUN)</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 36 families for the 3 changed paths
(65 changed lines). Every one exited 0, including `node
scripts/check-sdui-manifest.mjs` (+ `--self-test`),
`check-changeset-no-major --base origin/main`,
`check-adr-0087-registration --base origin/main`,
`check-closing-keyword-parity` (on this body), `check:type-check-debt`
(under the verify lock), `check:nul-bytes`,
`check:cross-package-test-inputs`, `check:test-source-alias` and `pnpm
--dir ui exec vitest run scripts/` (170 files passed, 2 skipped; 4997
tests). `--ran` reconciliation: 36 derived, 36 run.
</details>
<details><summary>Console type-check and tests</summary>
- `pnpm exec turbo run type-check --filter=@object-ui/console` (console
task a cache miss, `tsc --noEmit` covers test files): exit 0 at
`075c3ef6` and again at `16fff1a7`.
- `nativePushRegistration-29042.test.tsx` +
`App.nativeShellMode-29039.test.tsx`: 2 files, 37 tests passed.
- Every console test file importing `App` or `nativePushRegistration`
(11 files, 68 tests): passed at `075c3ef6` and at `16fff1a7`. `App.tsx`
already imports `@objectstack/spec/api` at runtime through
`components/FormPage.tsx`, so the new import adds no entry to the
Console's module graph.
- Ablation at `075c3ef6`: anchor 1 to 0, blob `79894a6a` to `acf23d1c`;
3 failed, 17 passed; restored blob equals HEAD, `git diff HEAD` empty.
</details>
Dogfood battery: n/a, no `!` in the title and no (narrowing) arm.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jS8ohBnEAnxBKpZcag)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 0c0ede0 commit f4b1f9e
3 files changed
Lines changed: 61 additions & 4 deletions
File tree
- .changeset
- ui/apps/console/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
366 | 367 | | |
367 | 368 | | |
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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
137 | | - | |
138 | | - | |
139 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
140 | 146 | | |
141 | 147 | | |
142 | | - | |
| 148 | + | |
| 149 | + | |
143 | 150 | | |
144 | 151 | | |
145 | 152 | | |
| |||
0 commit comments