Repository navigation
Commit cd7f785
fix(app-shell): offer the 变更 chip only when the reader's audit read answers (#30451)
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuXpPPZiBKyj1HzrdQ6La3ZH)_
domain:ui#6 · os-sales · session_01L6bhgUR8Nu4M7tbtgES7q2
Fixes #30344
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
改了什么:记录页「动态」的「变更」筛选,以及活动面板下拉里的「字段变更」选项,只在当前读者对审计日志的读取成功之后才出现;读取被拒(403)或失败时都不出现,与关闭字段历史时一样。
- 为什么改:没有审计日志读权限的销售打开开启了字段历史的线索,点「变更」永远是空的,会误以为「没人改过这条记录」或筛选坏了。
-
风险与回滚:只改前端两处判断(记录页一处、活动面板下拉一处,共用同一条规则),不加请求、不让页面等待;能读的用户在审计读取返回后才看到「变更」;没有宿主声明时下拉照旧四项。回滚即还原本
PR。
- 先看:`ui/packages/app-shell/src/views/RecordDetailView.tsx` 中
`fieldHistoryShown` 与审计读取
`.catch`;`ui/packages/plugin-detail/src/RecordActivityTimeline.tsx` 中
`getFilterOptions` 与 `activeFilter`;两个测试文件的新用例。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/RecordDetailView.recordPageTiers-26678.test.tsx
packages/plugin-detail/src/__tests__/recordTimelineStream-27055.test.tsx`,预期全过(未修复时
403 用例多出 `changes`,下拉用例多出 Field Changes)。
- 需要你做的:无,席位落地。
## What changes
`RecordDetailView` told the timeline stream whether the record shows its
field history (`RecordFieldHistoryContext`, which decides the 变更 chip)
from `historyEnabled` alone: `enable.trackHistory` plus whether
`sys_audit_log` is registered. It never asked whether this reader's
audit read answered. A member the server refuses that read to got a 变更
chip that always filtered to nothing.
Now the context carries `fieldHistoryShown = historyEnabled &&
historyEntries !== null`:
- The audit read's `.catch` (a refusal, or any other failure) now leaves
`historyEntries` at `null` instead of `[]`. `null` is what the code
already means by "no answer" (`timelineFieldChanges` documents it so),
and the stream merges `null` and `[]` the same way, so no row changes.
- So the chip is offered only once the read has answered, and a refused
read draws no chip, as history off does (ruling C on #30074 is
unchanged).
**The panel dropdown.** `RecordActivityTimeline`'s filter dropdown (the
panel face, `getFilterOptions`) now reads `RecordFieldHistoryContext`
and offers `changes_only` exactly when
`timelineStreamFilters(fieldHistory)` offers the stream's `changes`
chip. It reuses the stream's rule instead of adding a second one. The
context's default stays `true`, so a host with no provider keeps all
four options. A chosen or controlled `changes_only` that is no longer
offered reads as `all`, the way the stream's chips fall back.
**Why this shape (no wait).** Nothing waits on the audit read.
`historyEnabled` still gates the read itself (`historyPage` /
`historyWanted`, so the read still goes out only when the stream is on
screen) and still asks the page payload's `timeline.fieldChanges`. Only
the chip waits: on the 动态 tab it joins the other three chips when the
read answers. Two other shapes were considered and not taken:
- Hide the chip on a refusal only, and offer it while the read is
pending. A refused reader then sees the chip appear and disappear, and a
failed (5xx) read still offers an always-empty chip. The card asks for
"offered only when this reader's audit read succeeds".
- Hold the 动态 tab until the read lands. That makes the page wait, which
the code today avoids.
**The 动态 count.** No change is needed. With a payload, the server counts
each source as the caller does (`record-page-routes.ts`
`answerTimeline`: "a refused ledger count is no field change"), and with
zero field changes it keeps the `updated` activity rows. On the client,
`mergeTimelineStream` also keeps `updated` rows when there are no field
changes. Without a payload, the stream counts its own rows. Either way,
a refused read counts no field change.
## Tests
One new case in the shared harness
`RecordDetailView.recordPageTiers-26678.test.tsx`, in the existing
#30074 `describe` (the harness rule: a new pin goes into the component's
shared harness file):
- `a reader whose audit read is refused (403): no 变更 chip, as with
history off`. The `sys_audit_log` read rejects in the client's shape
(`httpStatus: 403`, `code: 'PERMISSION_DENIED'`). The case waits for the
read to go out and settle, then asserts the chips are exactly `all /
activity / discussion`.
- Positive control: the existing `trackHistory` case now asserts the
four chips after the read has answered (zero rows): history on and
readable keeps 变更.
- The existing history-off case is unchanged: no 变更, and no audit read.
- New top-level describe in the stream harness
`recordTimelineStream-27055.test.tsx`: "the panel's `changes_only` is
offered by the same rule as the 变更 chip". It covers four cases. History
shown offers four options. History not shown offers no Field Changes. No
provider offers four options (control). A `changes_only` that is not
offered reads as All Activity and every entry draws. A history-shown
`changes_only` control still filters to the field change only.
## Acceptance notes
- The panel dropdown was first left out because it was outside the
claimed surface. The seat's amendment 6657436301 widened the surface,
and this PR now carries the dropdown too.
- A failed (non-refusal) audit read now withholds the chip too, since it
also answers nothing. The read is not retried. This is unchanged from
before, when it showed an empty 变更.
## Verification
<details><summary>Red on the unfixed view, green with the fix</summary>
Unfixed: `RecordDetailView.tsx` restored from `a91409c4` in the tree
only (marker `fieldHistoryShown` count 0). Then restored with `git
checkout HEAD --`, hash-checked against the HEAD blob (RESTORED-OK), and
`git diff HEAD` was empty.
```
× a reader whose audit read is refused (403): no 变更 chip, as with history off
- Expected
+ Received
[ "all", "activity", "discussion", + "changes", ]
Tests 1 failed | 8 passed (9)
os-verify-lock: VERDICT command-exit 1
```
Fixed:
```
pnpm --dir ui exec vitest run --maxWorkers=2 (recordPageTiers-26678, timelineCount-28737, auditDisplayLocale-10442, auditTenantCurrency-27640, recordOpenWaves-13010)
Test Files 5 passed (5)
Tests 41 passed (41)
os-verify-lock: VERDICT command-exit 0
```
</details>
<details><summary>Panel dropdown: red without the plugin-detail change,
green with it</summary>
Unfixed: `RecordActivityTimeline.tsx` restored in the tree from the
merge commit `b4b0fb6157` (marker `changesOffered` count 0). Then
restored with `git checkout HEAD --`, hash-checked against the HEAD blob
(RESTORED-OK), and the status was clean.
```
× history not shown (history off, or a reader whose audit read did not answer): no `changes_only`
× a `changes_only` the dropdown does not offer reads as 全部: every entry draws
Tests 2 failed | 30 passed (32)
os-verify-lock: VERDICT command-exit 1
```
Fixed: `Tests 32 passed (32)`, VERDICT command-exit 0. The two CONTROL
cases pass on both legs.
</details>
<details><summary>Package and gates (head 6a04550, after merging
origin/main b4b0fb6)</summary>
All of the following were measured on head `6a045506`, in one lock hold.
- Tests, narrowed: every `RecordDetailView.*.test.tsx` file (102) plus
`packages/plugin-detail/src/`. Result: `Test Files 473 passed | 1
skipped (474)`, `Tests 3968 passed | 18 skipped (3986)`, exit 0. This
narrowing is declared. The full `app-shell/src/views/` suite (1,477
files) belongs to CI's `Test UI`.
- `pnpm --filter @object-ui/app-shell run type-check`: exit 0. `pnpm
--filter @object-ui/plugin-detail run type-check`: exit 0. Both ran
after `turbo run build --filter='@object-ui/app-shell^...'` (67/67
tasks).
- `eslint` on the four changed source and test files: 0 errors. The
warnings are all on lines already on main.
- `pnpm --dir ui run check:new-line-citations`: `0 new citation(s)`.
- `node scripts/pm/dispatch-gates.mjs --ran`: `35 derived famil(ies)
accounted for — 35 run, 0 NOT-MEASURED (a DERIVED zero)`. Each command
and its exit code:
```
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/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --dir ui exec vitest run scripts/ :: 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: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: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 check:changeset-fixed :: exit 0
```
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L6bhgUR8Nu4M7tbtgES7q2)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgUR8Nu4M7tbtgES7q2
<!-- signed: domain:ui#6 · os-sales · session_01L6bhgUR8Nu4M7tbtgES7q2
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e760204 commit cd7f785
5 files changed
Lines changed: 144 additions & 16 deletions
File tree
- .changeset
- ui/packages
- app-shell/src/views
- plugin-detail/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
144 | 151 | | |
145 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
146 | 155 | | |
147 | 156 | | |
148 | 157 | | |
| |||
161 | 170 | | |
162 | 171 | | |
163 | 172 | | |
164 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
165 | 183 | | |
166 | 184 | | |
167 | | - | |
| 185 | + | |
168 | 186 | | |
169 | 187 | | |
170 | 188 | | |
| |||
377 | 395 | | |
378 | 396 | | |
379 | 397 | | |
380 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
381 | 409 | | |
382 | | - | |
| 410 | + | |
383 | 411 | | |
384 | 412 | | |
385 | 413 | | |
| |||
388 | 416 | | |
389 | 417 | | |
390 | 418 | | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
391 | 431 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2906 | 2906 | | |
2907 | 2907 | | |
2908 | 2908 | | |
2909 | | - | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
2910 | 2913 | | |
2911 | 2914 | | |
2912 | 2915 | | |
| |||
4147 | 4150 | | |
4148 | 4151 | | |
4149 | 4152 | | |
| 4153 | + | |
| 4154 | + | |
| 4155 | + | |
| 4156 | + | |
| 4157 | + | |
| 4158 | + | |
| 4159 | + | |
| 4160 | + | |
4150 | 4161 | | |
4151 | 4162 | | |
4152 | | - | |
| 4163 | + | |
| 4164 | + | |
4153 | 4165 | | |
4154 | 4166 | | |
4155 | 4167 | | |
| |||
5069 | 5081 | | |
5070 | 5082 | | |
5071 | 5083 | | |
5072 | | - | |
| 5084 | + | |
| 5085 | + | |
5073 | 5086 | | |
5074 | | - | |
| 5087 | + | |
5075 | 5088 | | |
5076 | 5089 | | |
5077 | 5090 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| 57 | + | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| |||
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
222 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
223 | 235 | | |
224 | 236 | | |
225 | 237 | | |
226 | | - | |
| 238 | + | |
227 | 239 | | |
228 | 240 | | |
229 | 241 | | |
| |||
464 | 476 | | |
465 | 477 | | |
466 | 478 | | |
467 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
468 | 484 | | |
469 | 485 | | |
470 | 486 | | |
| |||
1069 | 1085 | | |
1070 | 1086 | | |
1071 | 1087 | | |
1072 | | - | |
| 1088 | + | |
1073 | 1089 | | |
1074 | 1090 | | |
1075 | 1091 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
197 | 243 | | |
198 | 244 | | |
199 | 245 | | |
| |||
0 commit comments