Repository navigation
Commit b65488a
fix(plugin-detail): the highlights strip, the detail view and the record drawer hide a field whose own visibleWhen is false (#35545)
Fixes #35437
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:记录页顶部的要点条、详情视图(含页眉小标签)和列表等视图打开的侧边抽屉里,「显示条件」对当前记录不成立的字段不再显示,与编辑表单和详情正文一致。
- 为什么做:上一张卡只修好了详情正文,这三处是同一问题剩下的位置;同一条记录在不同位置显示不一,读者会看到空的或误导的字段。
- 出错会怎样:只影响显示,数据与接口不变;条件写错或算不出来时照常显示该字段;整体撤回一个提交即可。
- 要你做什么:无。
## What changes
A field's own object-level `visibleWhen` (`Field.visibleWhen`: "field is
shown only when TRUE (else hidden)") now hides it on every record
surface in `plugin-detail` that draws fields, not only on the
`record:details` body:
- **One implementation, three callers.** The details body's fold is
lifted into a new module-internal helper,
`ui/packages/plugin-detail/src/fieldPredicateVisibility.ts`
(`dropFieldPredicateHidden`, with `assemblePredicateRecord`,
`lazyPredicateRecord` and `fieldPredicateVisible` moved there
unchanged). It is not exported from the package barrel. Call sites:
1. `record:details` (`renderers/record-details.tsx`): its
`dropPredicateHidden` now delegates to the helper; the group gate keeps
its own fail-closed judge and reads the same lazily assembled record.
2. `HeaderHighlight`: drops a gated highlight before the read/edit face
split. This covers `record:highlights` and the strip a `detail-view`
draws from `highlightFields`.
3. `DetailView`: a render-only `drawn` memo filters `fields`,
`sections[].fields`, `sectionGroups[].sections[].fields` and the header
summary chips. This covers the `detail-view` node and the record drawer
(`RecordDetailDrawer` and the views' overlay both render
`RecordDetailPanel`, which renders `DetailView`).
- **The verdict is the form's (the ruling in the claim).**
`resolveFieldRuleState`, the record bound as `record` and `previous`,
the host predicate scope. A predicate that cannot be evaluated SHOWS the
field and warns once (ADR-0137 D3). A field with no predicate is
untouched.
- **Evaluated against the saved record**, as on the details body: on the
strip, an inline edit reveals a gated field after save, not while
typing.
- **`DetailView`'s record read is untouched.** The `$expand` read keeps
`schema`'s lists. A list derived from the verdict would refetch whenever
the verdict moved.
## Tests
New
`ui/packages/plugin-detail/src/__tests__/fieldVisibleWhen.surfaces-35437.test.tsx`
(11 tests). Each test renders the same row on four surface legs:
`record:highlights`, the `detail-view` node through `SchemaRenderer`,
the node's own `highlightFields` strip, and `RecordDetailDrawer`. It
also renders the row through the entry `form` renderer and asserts `{
form, highlights, node, nodeStrip, drawer }` against the expected
verdict in one assertion, so a red names the surface:
- **Parity matrix (8):** envelope and bare-string predicates, where the
WON row is the CONTROL for a predicate that holds. Also: no predicate
(CONTROL), a parse error and an unbound bare identifier (both fail-open
CONTROLs, drawn), the null seed, a relation bound as its stored id,
`previous`, and the host `current_user` scope.
- **Controls (1):** beside a hidden field, a field whose predicate holds
and a field with none stay drawn on every surface.
- **Summary chip (1):** the `detail-view` header draws no chip for a
gated field.
- Harness guards: each leg first finds an ungated anchor value, and the
`DetailView` legs wait for their own object-schema read to land.
Otherwise the leg throws `HARNESS DEAD`, so an empty render cannot pass
a hidden leg.
The details body's own pin,
`record-details.fieldVisibleWhen-35314.test.tsx` (19 tests), is
unchanged and green.
<details><summary>Reproduction on the base renderer: 8 red, the 3
fail-open/no-predicate controls green</summary>
`DetailView.tsx`, `HeaderHighlight.tsx` and `record-details.tsx` were
restored from the base commit 5756ae0 with `git restore --source`, and
the new pin was run. The sources were restored with `git checkout HEAD
--` in an EXIT trap. Mutation proof: helper references in the three
files = 0/0/0. Restore proof: `git diff HEAD` empty, `git status
--porcelain` empty, and the three `git hash-object` values equal the
HEAD blobs.
```
x envelope `record.stage == closed_won` — the card reproduction; CONTROL: drawn where it holds
x bare-string `record.stage == closed_won` — the same verdict as the envelope
x a declared field the row does not carry compares as null — evaluated, not faulted
x a relation binds as its stored id, expanded or not
x `previous` binds the persisted row, as on the record's edit form
x the host `current_user` scope binds on every surface
x CONTROL — beside a hidden field, a field whose predicate holds and a field with none stay drawn
x a `stage` chip is drawn on WON and not on LOST
Tests 8 failed | 3 passed (11)
card reproduction diff: form [false, true]; highlights, node, nodeStrip, drawer each [true, true]
```
All four surface legs reproduce red on the base (A1). None already
routed through the details body.
</details>
<details><summary>Ablation of the shared helper: both pins red</summary>
`node scripts/ablation-replace.mjs` replaced the helper's `if
(visibleWhen == null) return true;` with `return true;`: anchor 1 to 0,
blob 627ab41 to 0e66c463. The new pin and the details-body pin were
then run together:
```
Test Files 2 failed (2)
Tests 22 failed | 8 passed (30)
```
That is 8 red in the new pin and 14 in the `record:details` pin, the
same 14 that PR #35421 measured red against its base. So the details
body runs through the shared helper too. Restored with `git checkout
HEAD --` in an EXIT trap: `git diff HEAD` empty, hash equals the HEAD
blob, marker count 0.
</details>
<details><summary>Package suite and type-check</summary>
Taken at head 86c2830, after merging origin/main. The build closure was
rebuilt first, and the commands were chained with `&&` under the verify
lock, whose verdict was `command-exit 0`:
```
pnpm --workspace-concurrency=2 --filter '@object-ui/plugin-detail^...' build
pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-detail/
Test Files 388 passed | 1 skipped (389)
Tests 3536 passed | 18 skipped (3554)
pnpm --filter @object-ui/plugin-detail run type-check (tsc --noEmit && tsc -p tsconfig.test.json; the second program includes src/**/*.test.tsx, so the new pin is compiled)
exit 0
```
The group-gate pin `record-details.groupVisibleWhen-11630.test.tsx` and
the details-body pin `record-details.fieldVisibleWhen-35314.test.tsx`
are in that suite and unchanged.
</details>
## Acceptance notes
- **The drawer learns the predicate from `DetailView`'s own
object-schema read** (`dataSource.getObjectSchema`). That is the same
read that gives it option labels on the record page. `RecordDetailPanel`
hands `DetailView` typed field descriptors and no object schema. A host
that opens the panel with a data source lacking `getObjectSchema`
therefore still draws a gated field, as it also draws no option labels
from `DetailView`'s side. Every in-repo caller (grid, list, gallery,
kanban, calendar, gantt, map, tree, timeline) passes the view's data
source. `RecordDetailPanel.tsx` is outside this claim's file surface, so
this is noted here, not changed.
- **The header summary chips are included.** They are fields the
`detail-view` node draws, and they have the same defect. An auto-picked
chip that is hidden is dropped, not replaced by the next candidate.
- **`record:highlights` still registers every authored highlight name**
for the body's dedupe. A field the predicate hides is dropped by both
the strip and the body, so the registration changes nothing visible.
- **Display only.** The record API still returns the field, as with a
field the form hides.
- Line-addressed citations: none added.
## Verification
Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-detail/src/__tests__/fieldVisibleWhen.surfaces-35437.test.tsx`.
Expect 11 passed, each asserting the form and all four surface legs
together.
Files to read first:
1. `ui/packages/plugin-detail/src/DetailView.tsx`, the `drawn` memo and
the render sites that read it. Risk: a render path still reading
`schema.*` (the fetch effect deliberately does).
2. `ui/packages/plugin-detail/src/fieldPredicateVisibility.ts`, the
single implementation.
3. `ui/packages/plugin-detail/src/HeaderHighlight.tsx`, the gate before
the read/edit split.
<details><summary>Derived local gate families</summary>
At head 86c2830, `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 38 commands. Each was run with its
exit code captured before any pipe, the vitest and type-check families
under the verify lock. All 38 exited 0. `--ran` reconciliation: `38
derived, 38 run, 0 NOT-MEASURED, 0 UNRUN`. `pnpm --dir ui exec vitest
run scripts/` reported 171 passed and 2 skipped files (5092 passed
tests). `pnpm check:new-line-citations` (ui) reported 0 new citations.
Every other family belongs to CI; see this PR's check runs.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 93fa4f9 commit b65488a
6 files changed
Lines changed: 605 additions & 106 deletions
File tree
- .changeset
- ui/packages/plugin-detail/src
- __tests__
- renderers
| 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 | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
587 | 588 | | |
588 | 589 | | |
589 | 590 | | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
590 | 624 | | |
591 | 625 | | |
592 | 626 | | |
| |||
1168 | 1202 | | |
1169 | 1203 | | |
1170 | 1204 | | |
1171 | | - | |
| 1205 | + | |
1172 | 1206 | | |
1173 | | - | |
| 1207 | + | |
1174 | 1208 | | |
1175 | 1209 | | |
1176 | 1210 | | |
| |||
1230 | 1264 | | |
1231 | 1265 | | |
1232 | 1266 | | |
1233 | | - | |
| 1267 | + | |
1234 | 1268 | | |
1235 | 1269 | | |
1236 | 1270 | | |
| |||
1971 | 2005 | | |
1972 | 2006 | | |
1973 | 2007 | | |
1974 | | - | |
1975 | | - | |
| 2008 | + | |
| 2009 | + | |
1976 | 2010 | | |
1977 | 2011 | | |
1978 | 2012 | | |
| |||
1987 | 2021 | | |
1988 | 2022 | | |
1989 | 2023 | | |
1990 | | - | |
1991 | | - | |
| 2024 | + | |
| 2025 | + | |
1992 | 2026 | | |
1993 | 2027 | | |
1994 | 2028 | | |
| |||
2004 | 2038 | | |
2005 | 2039 | | |
2006 | 2040 | | |
2007 | | - | |
| 2041 | + | |
2008 | 2042 | | |
2009 | 2043 | | |
2010 | | - | |
| 2044 | + | |
2011 | 2045 | | |
2012 | 2046 | | |
2013 | 2047 | | |
| |||
2114 | 2148 | | |
2115 | 2149 | | |
2116 | 2150 | | |
2117 | | - | |
| 2151 | + | |
2118 | 2152 | | |
2119 | | - | |
| 2153 | + | |
2120 | 2154 | | |
2121 | 2155 | | |
2122 | 2156 | | |
| |||
2134 | 2168 | | |
2135 | 2169 | | |
2136 | 2170 | | |
2137 | | - | |
| 2171 | + | |
2138 | 2172 | | |
2139 | 2173 | | |
2140 | | - | |
| 2174 | + | |
2141 | 2175 | | |
2142 | 2176 | | |
2143 | 2177 | | |
| |||
2152 | 2186 | | |
2153 | 2187 | | |
2154 | 2188 | | |
2155 | | - | |
| 2189 | + | |
2156 | 2190 | | |
2157 | | - | |
| 2191 | + | |
2158 | 2192 | | |
2159 | 2193 | | |
2160 | 2194 | | |
2161 | 2195 | | |
2162 | 2196 | | |
2163 | | - | |
| 2197 | + | |
2164 | 2198 | | |
2165 | 2199 | | |
2166 | 2200 | | |
2167 | 2201 | | |
2168 | 2202 | | |
2169 | | - | |
| 2203 | + | |
2170 | 2204 | | |
2171 | 2205 | | |
2172 | | - | |
| 2206 | + | |
2173 | 2207 | | |
2174 | 2208 | | |
2175 | 2209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
103 | 116 | | |
104 | 117 | | |
105 | 118 | | |
106 | 119 | | |
107 | 120 | | |
108 | 121 | | |
109 | | - | |
| 122 | + | |
110 | 123 | | |
111 | 124 | | |
112 | 125 | | |
| |||
0 commit comments