Repository navigation
Commit 46ec2ec
fix(plugin-calendar): name the object by its label when a reschedule finds the record gone (#31528)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbWVeUdPTouw9owJWMAZ76p7)_
Fixes #31494
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- **改了什么:** 日历拖拽改期被服务端以 404 RECORD_NOT_FOUND 拒绝时,提示不再显示服务端原句(英文、带记录 id
和对象机器名),改为当前语言的一句话,用对象的显示名称指代对象;卡片照旧弹回原日期。
- **为什么改:** 中文会话下用户看到 `Record WB5z1sLAsWgE1tXL not found in
showcase_task` 这样的英文系统句,违反「显示名称优先于机器名」规范(QA #31486)。
- **风险与回滚:** 只在 404/RECORD_NOT_FOUND 分支生效;作者标注的
userMessage、外部数据源只读、权限拒绝三条分支仍排在前面不变。回滚即还原本 PR。
- **先看:** `ui/packages/plugin-calendar/src/ObjectCalendar.tsx`(新分支与
`isRecordNotFound`)、`ObjectCalendar.markedRefusalToast.test.tsx`(新
describe)、`ui/packages/i18n/src/locales/zh-Hans.ts`(新键译文)。
- **两分钟验证:** `cd ui && pnpm exec vitest run
packages/plugin-calendar/src/ObjectCalendar.markedRefusalToast.test.tsx`,预期
12 个用例全绿,其中 zh 用例读到「这条任务记录已不存在,或者您已无权访问它。」
- **需要你做的:** 无,席位落地。
## What changes
- **`@object-ui/plugin-calendar`:** `handleEventDropDefault`'s toast
chain gains one branch after the permission branch and before
`extractWriteErrorMessage`: a refusal whose code (on the error or its
`details`) is `RECORD_NOT_FOUND`, or whose status is 404, toasts
`calendar.rescheduleNotFound` with the object named by its label. The
label is the object schema's served `label` (already translated
server-side), else the app's convention-key translation via
`useSafeFieldLabel().objectLabel`, else no name at all: the toast then
says the existing `form.recordNotFoundOrHidden` sentence. The server's
sentence, the record id and the machine name never reach the toast. The
rollback of the optimistic move is unchanged. The classifier is a small
module-local `isRecordNotFound` built on `errorCodeIs` from
`@object-ui/types`: `is404Error` lives in `@object-ui/data-objectstack`,
which this package has only as a devDependency, so reusing it would have
meant a new runtime dependency edge.
- **`@object-ui/i18n`:** one new key, `calendar.rescheduleNotFound`, in
all eleven `locales/*.ts` packs; zh-Hant generated from zh-Hans with
`gen:zh-hant`. The sentence takes one placeholder, the object label.
- The shared `extractWriteErrorMessage` is not touched (no caller census
needed).
## Tests
New top-level describe in the existing harness
`ObjectCalendar.markedRefusalToast.test.tsx` (wire-shaped errors through
the real `normaliseClientError`, real MonthView drag):
- 404 RECORD_NOT_FOUND with a served label: the toast is the labelled en
sentence, contains no id, no machine name, no "not found in"; the event
is back on its own day and absent from the target day.
- The same under a zh `I18nProvider` with the label 任务: the toast is the
zh sentence.
- No label anywhere: the generic `form.recordNotFoundOrHidden` sentence,
no machine name.
- A 404 that carries a `userMessage` still renders the marking.
- The external-source refusal (EXTERNAL_WRITE_FORBIDDEN) keeps its
read-only sentence; an unmarked 403 keeps the permission substitution.
The test's drop-target lookup moved from the spoken cell label to the
day number of the current-month cell, so the zh render finds it too; the
previous `cellLabel` helper is removed.
## Acceptance notes
- The same raw-sentence shape likely exists on other write toasts that
end in `extractWriteErrorMessage` (11 non-test files under `ui/packages`
and `ui/apps` call it, `git grep` at d15c0ad). Not changed here; the
card scoped the fix to the calendar toast.
## Verification
<details><summary>Local runs at a934d10 (suites re-run at
d15c0ad)</summary>
- `vitest run
packages/plugin-calendar/src/ObjectCalendar.markedRefusalToast.test.tsx`:
12/12 passed.
- `vitest run packages/plugin-calendar/ packages/i18n/`: Test Files 167
passed, Tests 2312 passed, 108 skipped.
- `turbo run type-check --filter=@object-ui/plugin-calendar
--filter=@object-ui/i18n`: 53/53 tasks successful.
- `eslint` on the two calendar files: 0 errors (warnings all on
untouched lines).
- Ablation (`scripts/ablation-replace.mjs`, the `isRecordNotFound(err)`
condition replaced by `false`): 3 failed, 9 passed; the three new
not-found cases received `Record v1 not found in visit`; restore
verified blob == HEAD, `git diff HEAD` empty.
</details>
<details><summary>Derived gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 38 families; all 38 ran at a934d10
and exited 0; `--ran` reconciliation: 38 derived, 38 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/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: 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
pnpm --dir ui exec vitest run scripts/ :: exit 0
```
After merging main (head d15c0ad, the derived list unchanged), the
ratchet and suite families were re-run: all exit 0, and the calendar +
i18n suites again passed 167/167 files.
```text
node scripts/check-sdui-manifest.mjs :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:test-source-alias :: 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:published-files :: exit 0
pnpm check:nul-bytes :: exit 0
```
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jSxTNXbFBqyMe2bkhV)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 7d7af56 commit 46ec2ec
14 files changed
Lines changed: 172 additions & 23 deletions
File tree
- .changeset
- ui/packages
- i18n/src/locales
- plugin-calendar/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
| 867 | + | |
867 | 868 | | |
868 | 869 | | |
869 | 870 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
| 781 | + | |
781 | 782 | | |
782 | 783 | | |
783 | 784 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1046 | 1046 | | |
1047 | 1047 | | |
1048 | 1048 | | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
1049 | 1053 | | |
1050 | 1054 | | |
1051 | 1055 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
803 | 803 | | |
804 | 804 | | |
805 | 805 | | |
| 806 | + | |
806 | 807 | | |
807 | 808 | | |
808 | 809 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
798 | 798 | | |
799 | 799 | | |
800 | 800 | | |
| 801 | + | |
801 | 802 | | |
802 | 803 | | |
803 | 804 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
| 781 | + | |
781 | 782 | | |
782 | 783 | | |
783 | 784 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
| 781 | + | |
781 | 782 | | |
782 | 783 | | |
783 | 784 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
798 | 798 | | |
799 | 799 | | |
800 | 800 | | |
| 801 | + | |
801 | 802 | | |
802 | 803 | | |
803 | 804 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
| 824 | + | |
824 | 825 | | |
825 | 826 | | |
826 | 827 | | |
| |||
0 commit comments