Skip to content

feat(ui): undo a business-record delete from its toast through the recycle bin - #31795

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/project-thread-vd60y0
Nov 9, 2026
Merged

objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/project-thread-vd60y0

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steedos · project thread
Part of #30239

Clause-②: yes (widening)
Metadata-protocol: none

维护者速读

  • 改了什么:删除一条业务对象记录后,“已删除”提示多了一个「撤销」按钮(控制台列表、插件列表、记录页三处)。撤销走回收站恢复接口 POST {data}/:object/recycle-bin/:entryId/restore,按原 id 恢复,不会重新创建记录;恢复被拒时按原因给出七句之一(唯一值被占、父记录已彻底删除、包已卸载、父记录也在回收站、条目不存在、无权限、本部署没有回收站)。业务对象的删除确认改成只问“确定要删除这条记录吗?”,不再说“此操作无法撤销”;平台对象(sys_、cloud_、ai_)保持原文。
  • 为什么改:ADR-0148 之后业务对象删除会进回收站,但控制台既拿不到 recycleBinEntryId(适配器丢了它),确认框还在说“无法撤销”,这和服务端的实际行为不一致。
  • 风险与回滚:撤销按钮只在同时满足两点时出现:服务端返回了条目 id,并且调用者在该对象上有 allowRestoreOwnDeleted(经 objectPermissionGrants 读取,manageRecycleBin、modifyAllRecords 也算)。缺任一项时提示与今天逐字相同;批量删除的提示不变。DataSource 只做加法(delete 仍返回 boolean)。回滚即撤销本 PR。
  • 先看:ui/packages/core/src/actions/recordDelete.ts 的 successToast 和 undo,再看 core/src/actions/recycleBinRestore.ts(拒绝码到语言包键的映射)和 app-shell/src/utils/recycleBinRestore.ts(权限判断)。
  • 两分钟验证:在 ui/ 下跑 pnpm exec vitest run packages/app-shell/src/hooks/__tests__/useObjectActions.deleteDialog-11695.test.tsx -t 30239,预期 8 个用例全绿(en、zh 各四个:往返、拒绝原因、无权限对照、无条目对照)。
  • 需要你做的:无,席位落地。管理端回收站页面在第二个 PR(Fixes #30239),它复用本 PR 的拒绝原因映射。

What changes

  • (A) @object-ui/types DataSource, additive only: delete(resource, id, opts?) options gain onRecycleBinEntry?: (entryId: string) => void, and DataSource gains an optional restoreRecycleBinEntry?(resource, entryId). delete still resolves to a boolean.
  • (A) @object-ui/data-objectstack: delete calls onRecycleBinEntry with the server's recycleBinEntryId, after the delete's mutation event, only when the delete succeeded and the answer carries a non-empty id. restoreRecycleBinEntry is the SDK's recycleBin.restore. It emits no mutation event (the vocabulary has no restore, and a restore is never a create), and a refusal is normalised as every write's is, so a 409 RESTORE_* keeps its code and details and is not a ConcurrentUpdateError.
  • @object-ui/core:
    • New recycleBinRestoreRefusalText(t, error, labels) with RECYCLE_BIN_RESTORE_REFUSAL_KEYS. It maps the door's seven codes (the spec's four RECYCLE_BIN_RESTORE_REFUSAL_CODES plus RECORD_NOT_FOUND, PERMISSION_DENIED, NOT_IMPLEMENTED) to one recycleBin.refusal.* sentence each, naming objects and fields by label with the machine name as fallback. An unknown code answers undefined, so the caller keeps its generic copy. The admin page in PR 2 reuses it.
    • recordDelete: the host passes an optional restore (and refusalLabels). With both an entry id and restore, the success toast carries an actions.undo action. Undo restores, refreshes, and toasts restoredNamed / restoreSuccess; a refusal toasts restoreFailed with the refusal sentence, or the server message for an unknown code. With neither, toast.success(message) is called with exactly one argument, as today. The entry id is asked for only when restore is present, so a host without it calls delete(object, id) exactly as before.
    • recordDelete.entersRecycleBin(name) is the engine's own predicate (!hasPlatformObjectPrefix). It picks the confirm copy: objectActions.deleteConfirmQuestion and console.objectView.bulkDeleteQuestion for a business object, today's keys for a platform object.
  • The hosts decide the grant; core reads no permission.
    • app-shell useObjectActions (console list) and RecordDetailView (record page) build restore through the new utils/recycleBinRestore.ts. That util reads usePermissions().effectiveObjects as MePermissionsProvider does (lowercase key, the key as given, then '*') and folds it with objectPermissionGrants(…, 'allowRestoreOwnDeleted'). On the record page, a successful Undo also navigates back to the record.
    • plugin-view ObjectView (the plugin list) does the same with a local reader, since it cannot import app-shell, and its fallback dictionary gains the new English keys.
    • plugin-detail DetailView: the confirm reads detail.deleteConfirmQuestion for a business object, per the amendment. Platform objects and a declared schema.deleteConfirmation are unchanged.
  • @object-ui/i18n, every pack: objectActions.deleteConfirmQuestion, restoredNamed, restoreSuccess, restoreFailed; detail.deleteConfirmQuestion; the console.objectView.bulkDeleteQuestion count family; and recycleBin.refusal.{uniqueValueTaken, parentPurged, packageUninstalled, parentInRecycleBin, notFound, permissionDenied, notAvailable}. zh-Hant is generated with gen:zh-hant. Each question is the platform sentence minus its permanence sentence.
  • Changeset: .changeset/30239-recycle-bin-undo-toast.md (seven @object-ui/* packages, patch).

Tests

New:

  • core/src/actions/__tests__/recycleBinRestore.test.ts: the key map covers the spec's RECYCLE_BIN_RESTORE_REFUSAL_CODES; an it.each over the seven codes checks the exact key and placeholders; the field label falls back to the machine name; CONTROL: an unknown code and a codeless error answer undefined.
  • core/src/actions/__tests__/recordDelete.test.ts, new describe "recordDelete and the recycle bin": business vs platform confirm copy; a round trip where Undo restores once with (object, entryId), never calls create, refreshes and names the record; a refusal toasts its sentence, not the server message; CONTROLs for an unknown code, no entry id, no restore, and a batch.
  • i18n/src/__tests__/recycle-bin-delete-copy-30239.test.ts: in every pack, each question equals its platform sentence minus the permanence sentence, the seven refusal sentences are distinct, none equals the generic failure, and each carries en's placeholders; the restore toasts' placeholders; exact en and zh-Hans sentences.
  • app-shell/src/hooks/__tests__/useObjectActions.deleteDialog-11695.test.tsx, new describe.each en/zh "console list Delete undo", through the real MePermissionsProvider: round trip; a refusal in the session language; CONTROL with no grant (delete called with two arguments and a one-argument toast); CONTROL with no entry id.
  • app-shell/src/utils/__tests__/recycleBinRestore-30239.test.ts: the grant fold (allowRestoreOwnDeleted, manageRecycleBin, '*' modifyAllRecords, case), plus CONTROLs: no read, no row, permissions not loaded, no restore on the data source.
  • data-objectstack/src/recycleBinEntry-30239.test.ts: the entry id is reported after the mutation event; no report without an id or for an unconfirmed delete; restore calls recycleBin.restore with no create and no event; a 409 refusal keeps code and details.

Edited pins. Each asserted the permanence sentence or key on a business object, which this card retires; nothing else in them changes and no assertion is removed:

  • app-shell/src/hooks/__tests__/useObjectActions.test.tsx: objectActions.deleteConfirm → objectActions.deleteConfirmQuestion, and console.objectView.bulkDeleteConfirm → console.objectView.bulkDeleteQuestion (crm_product).
  • app-shell/src/hooks/__tests__/useObjectActions.deleteCascade-28472.test.tsx: EN/ZH.objectActions.deleteConfirm → deleteConfirmQuestion, and bulkDeleteConfirm_other → bulkDeleteQuestion_other, as the base the cascade line is appended to.
  • app-shell/src/views/RecordDetailView.deleteCascade-28472.test.tsx: EN.objectActions.deleteConfirm → deleteConfirmQuestion, the same base.
  • app-shell/src/views/RecordDetailView.deleteConfirmDialog-11001.test.tsx: the body is found by deleteConfirmQuestion (en and zh). The Record delete: the confirm dialog never says the delete is permanent, and the toast says "Record deleted" without naming the record #27823 assertion "the body contains This cannot be undone." becomes "the dialog does not contain it" for this business record (crm_call). The platform-object side is still pinned, unedited, in i18n/src/__tests__/record-delete-permanent-27823.test.ts.
  • plugin-view/src/__tests__/ObjectView.gridDelete-10383.test.tsx: the two literal sentences lose This cannot be undone., and the docblock bullet says why.
  • core/src/actions/__tests__/recordDelete.test.ts (confirmCopy) and recordDelete.cascade-28472.test.ts: the business-object cases expect the Question keys.
  • i18n/src/__tests__/record-delete-permanent-27823.test.ts: docblock only, saying the sentence is now the platform keys'.

Acceptance notes

  • Before the delete, the console cannot know whether the server will write a recycle-bin entry, so the confirm promises neither permanence nor recovery. The toast tells the truth afterwards.
  • A batch delete keeps today's toast, as the amendment confirmed: each record writes its own entry, and one toast action would have to restore N entries, any of which can be refused on its own. The admin page in PR 2 is where several entries are restored.
  • member_default holds neither allowRestoreOwnDeleted nor manageRecycleBin, so a default member sees no Undo until an admin grants it. The restore door would refuse them anyway, and the toast never offers an action the runtime refuses.
  • Out of this PR: the admin recycle-bin page and its Setup nav item (PR 2), per-entry purge and "restore the parent first" (out of v1).

Verification

Head e6d5861b. Branch cut from c2bb879f, with origin/main merged at e253f3ab (five incoming commits; none touches this diff's files, and no parallel fix was found).

Tests (ui vitest from ui/, under the verify lock)
  • core and i18n, 8 files: Tests 155 passed (155).
  • app-shell, plugin-view and plugin-detail delete files (useObjectActions.deleteDialog-11695, useObjectActions, useObjectActions.deleteCascade-28472, RecordDetailView.deleteConfirmDialog-11001, RecordDetailView.deleteCascade-28472, ObjectView.gridDelete-10383, DetailView, DetailView.permissions): Test Files 8 passed (8), Tests 78 passed (78).
  • recycleBinRestore-30239, recycleBinEntry-30239, onMutation, bulkDelete: all passed (52 tests).
  • pnpm exec turbo run type-check on types, core, data-objectstack, app-shell, plugin-view, plugin-detail and i18n: Tasks: 75 successful, 75 total.
Ablation (scripts/ablation-replace.mjs, anchor x1 -> x0, restored blob == HEAD 1283125320a4 and git diff HEAD empty)

The undo attach line in recordDelete.ts, if (!entryId || !restore) {, replaced by if (true) {, so no toast ever carries Undo. recordDelete.test.ts with useObjectActions.deleteDialog-11695.test.tsx: Tests 7 failed | 29 passed (36). The 7 are the core round trip, the refusal and unknown-code cases, and the app-shell round trip and refusal in en and zh. The no-grant and no-entry CONTROLs stay green, as they should. The core module is imported from src, so there is no dist leg.

Gates

node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 40 derived commands, each run at e6d5861b with exit 0 (check:type-check-debt under the verify lock, check:query-options-erasure alone). --ran reconciliation: 40 derived, 40 run, 0 NOT-MEASURED, 0 UNRUN. --tier: no path-derived mandate. check-governed-merges --branch: 0 of 36 paths hit the register, not governed. Examples census (git grep of the touched copy, keys and members in ui/examples/** and ui/e2e/**): no hit that reads the changed copy. eslint on the touched sources and new tests: 0 errors. Changed lines 1432 (+1369 / -63): implementation about 420, tests about 690, locale packs about 235. The body gates (check-changeset-no-major, check-adr-0087-registration, check-closing-keyword-parity, check-partof-closing-keyword) were run on this body.


Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01QsR2jR7jBcj3r4Rii4HA82

…cycle bin

The data source tells the delete's recycleBinEntryId and can restore an
entry; the record-delete core offers Undo when the host passes a restore
(the caller holds allowRestoreOwnDeleted), and a business object's confirm
asks the question alone.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jR7jBcj3r4Rii4HA82
…ms, restore toasts

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jR7jBcj3r4Rii4HA82
… pin the adapter and grant reads

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jR7jBcj3r4Rii4HA82
@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 9, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#3 · zhuangjianguo · session_01QsR2jVEjiYrK7onirxUGyo

Contract review

Served-tier: TIER_DEFAULT
Head-sha: e6d5861b87166b9c5e3ba58d58031c6fd5fb13c7
Local-runs: none

This is the lane seat's own review of record. It is owed by the Clause-②: yes declaration alone (face declaration). No path of the diff is a published schema or a governed path: packages/spec/** and the server are untouched, and check-governed-merges --pr 31795 reads NOT governed (1432 lines).

① Derived judgments

  • @object-ui/types is published and only widens.
    • DataSource.delete's opts gains an optional onRecycleBinEntry?: (entryId) => void, and DataSource gains an optional restoreRecycleBinEntry?(resource, entryId).
    • delete still returns Promise<boolean>, so every existing implementer still satisfies the interface.
  • @object-ui/data-objectstack is published.
    • It implements both members. onRecycleBinEntry is called only after emitMutation, and only for a non-empty string recycleBinEntryId, which packages/client already declares on the delete answer.
    • restoreRecycleBinEntry calls the SDK's recycleBin.restore and emits no mutation event. It rethrows through normaliseClientError, which keeps code and details; pinned in recycleBinEntry-30239.test.ts, including that a 409 is not a concurrency conflict.
  • @object-ui/core is published and only widens.
    • It exports recycleBinRestoreRefusalText, RECYCLE_BIN_RESTORE_REFUSAL_KEYS and the type RecycleBinRefusalLabels.
    • recordDelete gains successToast, undo and entersRecycleBin.
    • confirmText takes an optional objectName.
    • RecordDeleteToastAction is also exported, by the existing export *. The changeset leaves it unnamed; that is a nit, below.
    • Existing callers are unchanged byte for byte: with no restore, run calls delete(resource, id) with two arguments and toast.success with one.
    • An absent objectName reads as a platform object, so the permanence sentence stays rather than dropping on a guess.
  • The refusal codes, read against packages/rest/src/recycle-bin-routes.ts on origin/main.
    • The four 409s are the spec's RECYCLE_BIN_RESTORE_REFUSAL_CODES.
    • RECORD_NOT_FOUND and NOT_IMPLEMENTED (the noBin 501) are the doors' own codes, and PERMISSION_DENIED is the classified 403.
    • details.object, field and parentObject are in REFUSAL_DETAIL_KEYS.
    • An unknown code answers undefined, and the toast keeps the server's message.
  • The Undo gate is objectPermissionGrants(perm, 'allowRestoreOwnDeleted'), the spec's own fold, read from the effective map the way MePermissionsProvider reads it (lowercase key, key as given, '*'). No map means no Undo, so the console never offers a restore the door would refuse.
  • @object-ui/i18n is published and only widens. These keys are added to all 11 packs:
    • objectActions.deleteConfirmQuestion, restoredNamed, restoreSuccess and restoreFailed;
    • detail.deleteConfirmQuestion;
    • the console.objectView.bulkDeleteQuestion plural family;
    • the seven recycleBin.refusal.* sentences.
      Plural rows follow each language's categories, which is why ar and ru carry more. actions.undo already existed. No key is removed or reworded.
  • The confirm copy is the card's ruling F of the amendment. A business object asks the question alone, and a platform object keeps "cannot be undone" (pinned unedited in record-delete-permanent-27823). The five edited pins move to the new keys, and none of their assertions is deleted.
  • Metadata-protocol: none is RIGHT. No author-written key, value or meaning changes.
  • Accept sets: none change.

② Semver level

  • .changeset/30239-recycle-bin-undo-toast.md marks @object-ui/types, data-objectstack, core, i18n, plugin-view and plugin-detail as patch; app-shell is private.
  • Both declaration lines are at line start, in the changeset and in the PR body.
  • That is RIGHT: a widening ships as patch.

③ Boundary flags

  • Nit N1: the changeset's surface paragraph does not name the newly exported RecordDeleteToastAction interface. It is prose only, so it is an accepted deviation; PR 2's changeset can name it.
  • Nit N2: plugin-view/src/ObjectView.tsx carries its own recycleBinRestoreFor, beside app-shell's recycleBinRestoreOf, because plugin-view cannot import app-shell. Both read the same spec fold, so the duplication is accepted. If a third host appears, the reader moves into @object-ui/core.
  • Nit N3: the plugin-list delete passes no refusalLabels, so its refusal sentences name objects and fields by their machine names. The console list and the record page pass labels. Accepted; PR 2's page uses the labelled path.
  • open_questions: none. The live dev:crm run moves to PR 2 with the page, as the step-1 plan says.

Implemented-by: claude/project-thread-vd60y0
Reviewed-by: session_01QsR2jVEjiYrK7onirxUGyo

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#3 · zhuangjianguo · session_01QsR2jVEjiYrK7onirxUGyo

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 006599d5d0f6bd30c83f78000392efa6bfc899e8
Local-runs: none

This is the delta review of record on the new head. The earlier record is 6732144296, PASS on e6d5861b. The head moved by one commit, and that commit touches one test file: ui/packages/i18n/src/__tests__/de-quote-pairing-3876.test.ts (+9/-3). git diff e6d5861b 006599d5 names no other path.

① Derived judgments

  • The de quote census goes from 110 to 111 in both places.
  • The extra pair is the one de key this PR adds that contains a „. It is correctly closed by “, so the bump records the new pair rather than masking a mis-quote. The durable assertion close === open + rdq is unedited.
  • No published surface changes on this commit. Every judgment of 6732144296 carries over unchanged.

② Semver level

  • No change. The changeset and the declaration lines are the ones 6732144296 judged RIGHT.

③ Boundary flags

Implemented-by: claude/project-thread-vd60y0
Reviewed-by: session_01QsR2jVEjiYrK7onirxUGyo

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#3 · zhuangjianguo · session_01QsR2jVEjiYrK7onirxUGyo

席位核对 · ACCEPT · 2026-11-09T04:54Z · head 006599d5d0f6bd30c83f78000392efa6bfc899e8

Seat domain:ui#3 reviewed the diff of its own dispatch for #30239 PR 1. The card thread is session_01QsR2jR7jBcj3r4Rii4HA82, and the os-dev-report is 6732117898. I checked against GitHub, not against the report.

  1. Shape: 36 files, +1378 / -66, draft on main, Part of #30239. This is PR 1 of 2. The page is PR 2.
    • Types and adapter: DataSource.delete options gain onRecycleBinEntry?, and DataSource gains an optional restoreRecycleBinEntry?. delete still returns a boolean. data-objectstack implements both. The entry id is told after the mutation event, and a restore emits no event.
    • Core: recordDelete gains successToast, undo and entersRecycleBin. recycleBinRestoreRefusalText maps the seven door codes to recycleBin.refusal.*. With no restore, a delete runs exactly as today.
    • Hosts: the console list, the plugin list and the record page offer Undo only when the caller's effective map grants allowRestoreOwnDeleted (objectPermissionGrants). On the record page, Undo returns to the record.
    • Confirm copy: a business object asks the question alone, on one record and on a selection, on the console list, the plugin list, the record page and the plugin DetailView. A platform object keeps "This cannot be undone."
    • Locales: the new keys are in all 11 packs.
  2. Premise: every door is on origin/main (PR feat(rest): the recycle bin has REST doors, and a delete answer names the entry to undo (#30237 PR 5) #31595). The console said a business delete "cannot be undone" and offered no undo. The step-1 report is 6731441670.
  3. Gates and check-runs:
    • 57 runs on this head: 44 success, 13 skipped, 0 red. mergeable_state is clean.
    • The first head e6d5861b was red on Test UI 3/16. That was this PR's own failure: the de quote census went 110 → 111 because of objectActions.restoredNamed. It was fixed on 006599d5, a single test-file commit.
    • Dev: 40/40 derived gates exit 0, with --ran reconciled. Type-check is 75/75. The ablation of the undo attach line turns 7 tests red and restores clean.
  4. Declaration review: TIER_DEFAULT PASS. The record is 6732144296 on e6d5861b, and the delta 6732342801 on this head carries it over.
  5. Tests read:
    • The Undo toast appears only with an entry id and the grant.
    • Undo restores, refreshes and toasts "restored". The record page navigates back.
    • Every refusal code gets its own sentence, with an it.each. CONTROL: an unknown code keeps the server message.
    • No grant, no entry id, or a batch delete gives today's toast.
    • The confirm-copy pins cover business vs platform objects. The record-delete-permanent-27823 platform pin is unedited.
    • The five edited pins each moved to the new keys, and no assertion was deleted. The seat approved this.
  6. Accepted deviations:
    • The line budget is 1,444 against about 800. Tests make up most of it.
    • The live dev:crm run moves to PR 2 with the page.
    • Review nits N1–N3: RecordDeleteToastAction is not named in the changeset; plugin-view has its own copy of the restore gate; the plugin list passes no refusal labels.
    • The record's "ruling F" wording was corrected in 6732342801.
  7. Landing:

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 9, 2026 04:56
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 9, 2026 04:56
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 56cac5e Nov 9, 2026
58 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-vd60y0 branch November 9, 2026 05:16
rajeev-kumar-se pushed a commit to rajeev-kumar-se/objectstack that referenced this pull request Nov 10, 2026
…n, or empty it (objectstack-ai#31835)

<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbPnyAMycuSU2XHXgpgorGJU)_
Fixes objectstack-ai#30239

Clause-②: yes (widening)
Metadata-protocol: none

## 维护者速读

- 改了什么:Setup → 配置 下新增「回收站」页面。左侧列出调用者有 `manageRecycleBin`
权限的业务对象(不发任何回收站读取),选中一个对象后读它的回收站,每页 50
条,可以「加载更多」。每行显示记录名、连带删除的相关记录数、删除人、删除时间和保留期限。「恢复」复用 objectstack-ai#31795 删除提示里的撤销逻辑:按原
id 恢复,被拒时按原因给出带对象和字段标签的句子。「清空回收站」会先确认并说明不可撤销,完成后报告移除了多少条。导航项由
`@objectstack/platform-objects` 的 Setup 导航贡献提供(`componentRef:
'data:recycle-bin'`),11 个翻译包都加了标签。
- 为什么改:ADR-0148 之后业务对象删除会进回收站,但管理员在控制台里看不到回收站,也没有办法恢复或清空。objectstack-ai#31795
只覆盖了删除者本人在提示里的撤销。
- 风险与回滚:新增页面和一个导航项,不改已有页面的行为。`CatalogAssignmentPage` 加了一个可选的 `select`
属性,`renderSection`
多传第二个参数,两个已有调用方不受影响。没有任何对象回收站管理权限的用户看到说明文字,不发读取。回滚即撤销本 PR。
-
先看:`ui/packages/app-shell/src/views/setup/RecycleBinPage.tsx`(`RecycleBinSection`
的读取、加载更多、恢复和清空),再看 `setup/recycleBin.ts`(`managesRecycleBin` 权限判断和 SDK
门的取法)。
- 两分钟验证:在 `ui/` 下跑 `pnpm exec vitest run
packages/app-shell/src/views/setup/RecycleBinPage.test.tsx`,预期 20
个用例全绿。实机截图见下方 Verification。
- 需要你做的:无,席位落地。

## What changes

- **`@object-ui/app-shell`, the page**
(`views/setup/RecycleBinPage.tsx`, registered as `data:recycle-bin` in
`builtinComponents.tsx`):
- **The object list costs no bin read.** It is the `object` catalog
narrowed to the business objects whose `manageRecycleBin` the caller
holds. The gate is `managesRecycleBin` in `setup/recycleBin.ts`: the
effective map from `/auth/me/permissions`, read as
`MePermissionsProvider` reads it (the lowercase key, the key as given,
then `'*'`), and folded by `objectPermissionGrants`, so
`modifyAllRecords` grants it. A platform object
(`hasPlatformObjectPrefix`) never enters the bin, so it is never listed.
- A caller who manages no object's bin is told so ("No recycle bin to
manage"), and no bin read is sent. The picked object rides the
page-scoped `?object=` param. A link to an object the caller does not
manage reads nothing.
- **One object:** one `recycleBin.list(object, { limit: 50, offset: 0
})`. "Load more" reads `offset` = the rows held, while the door answers
`hasMore`.
- Each row shows the record's name: `getRecordDisplayName` over the
served snapshot row, which the door masks to the fields the caller may
read.
- "and N related records" (`recordCount − 1`, a count family) shows when
the delete cascaded.
- Who deleted it is resolved by one batched `sys_user` read per page; a
refused read leaves the id.
- Also shown: when it was deleted, and the day it is kept until
(`purgeAfter`).
- **Restore** is `recordDelete.undo`, the same restore the delete
toast's Undo runs (objectstack-ai#31795). It restores under the original ids, never
creates, and drops the row. A refusal toasts `restoreFailed` with
`recycleBinRestoreRefusalText`, on the labelled path
(`recycleBinRefusalLabelsOf`): a field is named by its label, the object
by the page's label, and a parent object by its definition's label.
Review nit N2 asked for exactly this path.
- **Empty recycle bin** opens a destructive confirm that names the
object and says the removal is permanent. It then calls
`recycleBin.empty(object)` and toasts `emptied` (a count family) with
the door's `removed`. A failed list or empty shows the door code's
sentence (for example `NOT_IMPLEMENTED`), else the server message.
- The SDK doors come from the adapter's client
(`recycleBinDoorsOf(adapter)` → `getClient().recycleBin`), and restore
from the adapter's `restoreRecycleBinEntry` (objectstack-ai#31795). No `DataSource`
change.
- **`CatalogAssignmentPage`**: an optional `select(entries)` narrows the
catalog, and `renderSection(name, entry)` now also receives the picked
entry. Both existing callers (Position holders, Permission set
assignment) are unchanged.
- **`@objectstack/platform-objects`**: `nav_recycle_bin` (`type:
'component'`, `componentRef: 'data:recycle-bin'`, icon `trash-2`) in the
Setup app's `group_configuration`, after Data Lifecycle, beside the
`sys_recycle_bin` store this package registers. It has no
`requiredPermissions`, because the grant is per object. The label is
added in all 11 `apps/translations/*.ts`, with its source digest
recorded in the 10 `*.source-hashes.ts`.
- **`@object-ui/i18n`**: `recycleBin.page.*` in every pack (title,
subtitle, list and filter labels, the no-object state, pick, column
heads, Restore, Load more, the empty action, dialog and failure lines),
plus two count families, `related` and `emptied`. zh-Hant is generated
with `gen:zh-hant`. Shared wording reuses `setupAssignments.{noMatch,
notFound, retry, refresh}` and `common.cancel`.
- Changeset: `.changeset/30239-recycle-bin-setup-page.md`. It also names
`RecordDeleteToastAction`, the type objectstack-ai#31795 exported from
`@object-ui/core` (review nit N1).

## Tests

- `app-shell/src/views/setup/RecycleBinPage.test.tsx` (20 cases). It
runs through a real `I18nProvider` with the shipped packs and a real
`MePermissionsProvider`; the stand-ins are the adapter, the metadata
store and sonner.
- **The object list:** only the managed business objects are listed,
with no bin read. A member who manages none sees the no-object state,
with no bin read. CONTROL: `'*'` `modifyAllRecords` lists every business
object and no platform object. A link to an unmanaged object reads
nothing.
  - **One object:**
- One read at `{ limit: 50, offset: 0 }`, which names the record, the
related count and who deleted it, through one `sys_user` read.
- Load more reads at offset 50, appends, and stops when the door says
there is no more.
    - An empty bin says so, and Empty is disabled.
    - `NOT_IMPLEMENTED` reads its own sentence, and Retry reads again.
  - **Restore and empty, en and zh:**
- Restore calls `restoreRecycleBinEntry('crm_lead', 'rb_1')`, never
`create`, toasts `restoredNamed` and drops the row with no re-read.
- `RESTORE_UNIQUE_VALUE_TAKEN` names the field by label ("Email").
`RESTORE_PARENT_IN_RECYCLE_BIN` names the parent object by label
("Account"). In both, the row stays.
    - CONTROL: an unknown code keeps the server message.
- Empty asks with the title and body, then calls `empty('crm_lead')` and
toasts `emptied`. CONTROL: Cancel empties nothing.
- `app-shell/src/views/setup/RecycleBinPage.navContribution.test.tsx`:
the ref is registered by the production module, owned by app-shell,
addresses `component/data/recycle-bin`, and mounts through
`ComponentNavView`.
- **Two existing census files are edited**, both because the new entry
moved a count they keep. The seat approved both after CI found them.
- `packages/cli/test/connect-agent-both-halves-wire.pin.test.ts` counts
the Setup tree the platform admin is served. `nav_recycle_bin` makes it
33, where it said 32. Both `toHaveLength(32)` become 33, and the history
comment and the "24 entries `SETUP_NAV_CONTRIBUTIONS` carries" line move
by one. A new `toContain('nav_recycle_bin')` ties the bump to this
entry.
- `app-shell/src/console/__tests__/openPathObjectReaders-12811.test.ts`
gains one `OBJECTS_READERS` row. `RecycleBinPage.tsx` reads
`useMetadata().objects`, and it is classified `off` (Setup → Recycle
Bin, not mounted on an app object-list open).

## Acceptance notes

- **Out of v1, per the amendment:** per-entry purge, a "restore the
parent first" button, and a cross-object listing. Entries of an
uninstalled package's object are unreachable from this page until the
TTL reap.
- **A formula `nameField` reads its fallback in the list.** The bin's
snapshot holds stored columns, so a formula title is absent from the
served row. The row falls to the next name-ish field: in dev:crm, a
contact reads "Alan" rather than "Alan Turing". After a restore, the
record and its toasts read the full title.
- The live run was done as the organization admin. The member's
no-object state is pinned in the test above and was not run live.

## Verification

Head `701e095b`: the page `59cc82e1`, the tests, the changeset, the
collection-time linter import `test(ui)`, origin/main merged at
`4ed20928`, and two commits for reds that CI found after the PR opened.
`425681c5` renames the page's local served-entry type to
`RecycleBinListEntry`, because `@objectstack/spec/data` already exports
`RecycleBinEntry` (`check:spec-symbols`, a Type Check UI step outside
dispatch-gates). `701e095b` holds the two census edits named under
Tests. The merge of origin/main at `4ed20928` (11 incoming commits; none
touches this diff's files, and no parallel fix was found). Branch
restarted from `56cac5eb`, the landing of objectstack-ai#31795.

<details><summary>Tests (ui vitest from ui/, under the verify
lock)</summary>

- `packages/app-shell/src/views/setup/` (13 files): `Tests 159 passed
(159)`, including the 20 new page cases and the 3 nav cases.
- `packages/i18n/` plus every app-shell test importing
`builtinComponents`: `Test Files 120 passed (120)`, `Tests 1946 passed |
13 skipped`. This covers `de-quote-pairing-3876`,
`all-locales-key-parity`, `count-families-11445` and the census pins;
the new de keys carry no „…“ pair.
- `@objectstack/platform-objects`, whole package: `Test Files 120 passed
(120)`, `Tests 1932 passed (1932)`. `service-settings`
`settings-branding-posture.pin`: 15 passed.
- At `701e095b`, after the CI reds, each whole package was run:
- `@object-ui/app-shell` in 8 locked `--shard=k/8` runs: 2221 files
(2220 passed, 1 skipped), `Tests 20310 passed | 9 skipped`.
- `@objectstack/cli`: `Test Files 616 passed | 2 skipped (618)`, `Tests
7692 passed | 10 skipped`.
  - `@objectstack/platform-objects`: 1932 passed.
  - `service-settings` `setup-nav-hub-parity`: 23 passed.
  - `pnpm --dir ui run check:spec-symbols`: 0 untriaged collisions.
- `turbo run type-check --filter=@object-ui/app-shell
--filter=@object-ui/i18n`: `Tasks: 70 successful, 70 total`.
</details>

<details><summary>Ablation (scripts/ablation-replace.mjs, anchor x1 ->
x0, restored blob == HEAD f34b237 and git diff HEAD
empty)</summary>

The manage gate in `setup/recycleBin.ts`, `entries.filter((e) =>
managesRecycleBin(effectiveObjects, e.name))`, was replaced by
`entries.filter(() => true)`. `RecycleBinPage.test.tsx`: `Tests 4 failed
| 16 passed (20)`. The 4 are every object-list pin: the managed-only
list, the member's no-object state, the `'*'` CONTROL's platform
exclusion, and the unmanaged link. The restore, refusal, paging and
empty pins stay green, as they should.
</details>

<details><summary>Live run on dev:crm (en and zh, as the organization
admin; scripts and shots in the project folder
issue-30239/live-pr2/)</summary>

Workspace built (`pnpm build` 119/119, `pnpm console:build` 76/76),
`pnpm dev:crm`. Setup through the data door: an account, an opportunity
with two line items (a master-detail cascade), and three contacts. The
opportunity and two contacts were then deleted. Each answer carried
`recycleBinEntryId`, and the opportunity's entry has `recordCount: 3`.

- **Record page (objectstack-ai#31795):** Delete asks "Are you sure you want to delete
this record?" with no permanence sentence; zh: 确定要删除此记录吗?. The toast
reads `Contact "Ada Lovelace" deleted · Undo`; zh: 联系人“Ada Lovelace”已删除
· 撤销. Undo answers `POST …/crm_contact/recycle-bin/:entryId/restore`
200, toasts `Contact "Ada Lovelace" restored`, and returns to the
record's URL.
- **Setup → Recycle Bin:** the nav entry is present. The object list
sent no bin read (the only `/recycle-bin` requests before the pick were
the record-page restore and the page's own HTML). Picking Opportunity
sent `GET …/crm_opportunity/recycle-bin?limit=50&offset=0` once and
showed "Acme renewal · and 2 related records · Dev Admin · 11/9/2026,
6:17:40 AM · 12/9/2026".
- **Restore:** `POST …/restore` 200, toast `Opportunity "Acme renewal"
restored`, and the row left the list.
- **Empty:** Contact listed two entries. The dialog reads "Empty the
recycle bin of Contact? Every deleted Contact record in it is removed
for good. This cannot be undone." Confirming sent `DELETE
…/crm_contact/recycle-bin` 200, toasted "2 deleted records removed for
good", and the list read empty.
- **The same in zh:** 及 2 条相关记录; 商机“Acme renewal”已恢复; 清空联系人的回收站?; 已永久移除
2 条已删除的记录.
</details>

<details><summary>Gates</summary>

`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 67 derived commands, each exit 0
(`check:type-check-debt` under the verify lock,
`check:query-options-erasure` alone).
- `check-plugin-teardown-shape --self-test` needed its pinned fixture
fetched into the shallow clone, then passed.
- `check:test-source-alias` first flagged the new nav pin, which reaches
`celAuthoring.ts`'s dynamic `@objectstack/lint` import through
`builtinComponents`. The fix, a module-top `import '@objectstack/lint'`
in that pin, is commit `test(ui)`. That gate and
`check:undeclared-dep-imports` were re-run after it.
- `--ran` reconciliation: `67 derived, 67 run, 0 NOT-MEASURED, 0 UNRUN`.
`--tier`: no path-derived mandate.
- Changed lines 1278 (+1269 / -9): implementation about 517, tests about
399, locale packs about 326, platform-objects nav and translations 27.
- The body gates (`check-changeset-no-major`,
`check-adr-0087-registration`, `check-closing-keyword-parity`,
`check-partof-closing-keyword`) were run on this body.
</details>

---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jR7jBcj3r4Rii4HA82)_

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01QsR2jR7jBcj3r4Rii4HA82

<!-- signed: domain:ui#3 · zhuangjianguo ·
session_01QsR2jVEjiYrK7onirxUGyo -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant