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 c1c86a3
Browse filesBrowse the repository at this point in the historyBrowse files
fix(app-shell): a deleted record leaves the recently-accessed list (#34108)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi97evQ69Yx3njz2MqoYASHxL)_Fixes#33826
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:删除记录成功后,该记录立刻从「最近访问」里移除(⌘K 命令面板、环境首页、本地缓存与服务端 `ui.recent` 偏好同步)。
- 为什么改:删掉的记录还挂在最近访问第一条,点进去落到一条不存在的记录,最近访问越用越不可信。
- 风险与回滚:只加了一个订阅数据源删除事件的监听,只删 `record:对象:ID` 这一条;回滚即 revert 本 PR,无数据迁移。
-
先看:`ui/packages/app-shell/src/context/RecentItemsProvider.tsx`(`useDropDeletedRecordsFromRecents`)→
`ui/packages/app-shell/src/console/ConsoleShell.tsx`(唯一挂载点)。
- 两分钟验证:打开一条客户记录 → 更多 → 删除 → 确认,然后按 ⌘K:「最近访问」里不再有它;点 Toast 上的撤销回到该记录后再按
⌘K,它重新出现在第一条。
- 需要你做的:无,席位落地。
## What changes
- `useDropDeletedRecordsFromRecents(dataSource)` (new, module-internal
to `@object-ui/app-shell`, not exported from the package index):
subscribes to the data source's `onMutation` and, on a `delete` event
that names its record (`resource` + `id`), calls the provider's existing
`removeRecentItem` with the record entry's id, `record:OBJECT:RECORD_ID`
(the id the record page writes). `removeRecentItem` already writes the
list, localStorage and the debounced `ui.recent` save, and writes
nothing when the entry is absent.
- `ConnectedShellInner` mounts it once (`DeletedRecordsLeaveRecents`,
beside `UserStateBridge`), on the connected adapter. The console's
`ConsoleShell` holds `RecentItemsProvider` above every `ConnectedShell`,
so the palette (`CommandPalette`), Home and the sidebar read the trimmed
list. One subscriber covers every delete door that reports its record
(record header, list row, action) with no call at each door, and
`RecordDetailView.tsx` is untouched.
- Undo: the record page's Undo restores the record and navigates back to
it; that visit records it again through the record page's existing
`addRecentItem` effect. A restore emits no mutation event by design
(`restoreRecycleBinEntry`: "a restore is never a create"), so nothing
re-inserts the entry before the visit.
- No public surface changes: the `useRecentItems()` value and the
package exports are unchanged, so `Clause-②: no` holds.
## Tests
-
`ui/packages/app-shell/src/context/__tests__/RecentItemsProvider.test.tsx`
gains one top-level `describe` (the shared harness file): the deleted
record leaves the list, localStorage and the saved row; CONTROL another
record's delete (same object, other object) leaves it listed and saves
nothing; CONTROL an `update` event and an id-less `delete` (bulk) drop
nothing; after an undo the revisit lists it again at the head; the
listener unsubscribes on unmount.
-
`ui/packages/app-shell/src/console/__tests__/ConnectedShell.deletedRecordLeavesRecents-33826.test.tsx`
(new): the real `ConnectedShell` under the real recents provider; a
delete reported by the adapter drops that record only; the subscription
goes away with the shell.
- No forced test edits.
<details><summary>Test runs (head a6cbed1)</summary>
- `pnpm --dir ui exec vitest run
packages/app-shell/src/context/__tests__/RecentItemsProvider.test.tsx
packages/app-shell/src/console/__tests__/ConnectedShell.deletedRecordLeavesRecents-33826.test.tsx`:
Test Files 2 passed (2), Tests 28 passed (28), lock VERDICT command-exit
0.
- Ablation 1 (`scripts/ablation-replace.mjs`, mutation landed anchor 1
to 0, restored blob == HEAD): `DeletedRecordsLeaveRecents` mount deleted
from `ConsoleShell.tsx` turns the shell pin red, Tests 2 failed (2).
- Ablation 2: the `removeRecentItem(recordRecentItemId(...))` call in
the hook replaced by a no-op turns 3 pins red (deleted record gone; undo
revisit; shell drop), Tests 3 failed / 25 passed (28); restored, `git
diff HEAD` empty.
- No build between legs: ui vitest resolves `@object-ui/*` to `src/`
through `ui/vitest.config.mts` aliases.
</details>
## Acceptance notes
- A bulk delete (`bulkDelete`, `bulk('delete')`) emits one
resource-level `delete` with no `id`, so its records stay in the recents
until opened. Closing it needs the mutation event to carry the deleted
ids (`DataSourceMutationEvent` in `@object-ui/types`), a public-type
widening outside this card's surface. carrier: seat (named in the
report's open_questions).
- A record deleted elsewhere (another session or user) is not reported
to this tab's data source, so it stays listed until opened. The card's
optional route ("opening a recent whose record answers 404 drops it")
lives in the record page's load path (`RecordDetailView.tsx`), which
this card's claim fenced off; not done here. carrier: seat.
## Verification
<details><summary>Local gates (head a6cbed1)</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 37 commands, each run, all exit 0
(including `pnpm --dir ui exec vitest run scripts/` under the lock,
`pnpm check:test-source-alias`, `pnpm check:cross-package-test-inputs`,
`pnpm check:nul-bytes`, `pnpm check:published-files`).
- `--ran` reconciliation: 37 derived, 37 run, 0 NOT-MEASURED, 0 UNRUN.
- `pnpm --filter @object-ui/app-shell type-check` (after `turbo run
build --filter='@object-ui/app-shell^...'`): both `tsc --noEmit` and
`tsc -p tsconfig.test.json`, lock VERDICT command-exit 0.
- `pnpm --dir ui run check:new-line-citations`: 0 new citations.
- Every other family (lint, Test UI shards, Build and E2E UI, the
required set): this PR's CI check-runs.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmTS7jKcrSq1mgNofuy)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(app-shell): a deleted record leaves the recently-accessed list that the command palette and Home show
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
Deleting a record left its entry in the recents, so the ⌘K palette's "Recent" group and Home's "recently accessed" still offered it, and opening it landed on a record that no longer exists. The connected shell now listens to the data source's delete events once and drops the deleted record's entry from the list, from localStorage and from the saved `ui.recent` preference. One listener covers every delete that reports its record: the record page's header, a list row, an action. Undoing the delete brings the record back, and the visit that follows lists it again. A bulk delete reports only its object, not its records, so it drops nothing.
0 commit comments