Skip to content

fix(plugin-detail): the record page hides a field whose own visibleWhen is false - #35421

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-35314-default-page-visiblewhen
Nov 19, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-35314-default-page-visiblewhen

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #35314

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:记录详情页(默认页与自建页的详情块)不再显示「显示条件」对当前记录为假的字段,与编辑表单一致;条件写错时照旧显示该字段并在控制台告警一次,也与表单一致。
  • 为什么改:默认记录页把只在特定状态才有意义的字段(如审批不需要时的「申请资格审批」)也画出来,读者看到空的或误导的字段,同一条记录的页面与表单说法不一。
  • 风险与回滚:若判错,会把本应显示的字段藏起来(数据仍在、接口仍返回,只是不画);整体回滚一个提交即可,无数据迁移。
  • 先看:ui/packages/plugin-detail/src/renderers/record-details.tsx 中新增的 fieldPredicateVisible 与 dropPredicateHidden 两处;其次同目录 __tests__/record-details.fieldVisibleWhen-35314.test.tsx 的对照矩阵。
  • 两分钟验证:pnpm --dir ui exec vitest run packages/plugin-detail/src/renderers/__tests__/record-details.fieldVisibleWhen-35314.test.tsx,预期 19 项全绿,其中每一行都同时断言表单与详情页的结论。
  • 需要你做的:无,席位落地。

What changes

record:details now honours a field's own object-level visibleWhen (Field.visibleWhen: "field is shown only when TRUE (else hidden)") on every field it draws. Before, it evaluated a field GROUP's visibleWhen (the { group } reference) and no field's, so the synthesized default record page drew a field whose predicate is false for the record, label and value.

  • Where it was missing. The section fold in record:details (fields: dropHidden(normaliseList(filterList(s.fields)))) and the flat-body fold (filteredFields) applied field security, the label ladder and the header dedupe, and never read the object's field visibleWhen; DetailSection draws whatever it is handed. The group derivation (deriveFieldGroupDetailEntries / toField) does not carry the field predicate either, so neither layer saw it.
  • The fix. One new fold, dropPredicateHidden, applied last to both lists. It reads the predicate off the object's field declaration by name and judges it with fieldPredicateVisible, which calls resolveFieldRuleState from @object-ui/core: the call the form renderer makes for a field's visibleWhen. So the fault direction is the field rule's (VISIBLE_WHEN_FAULTED, ADR-0137 D3): a predicate that cannot be evaluated SHOWS the field and warns once. That is the opposite of the group gate (fail-closed), on purpose; each slot keeps the direction the form gives it.
  • Record context. The same inputs the existing group gate passes: sectionPredicateRecord (every declared field seeded null, relations collapsed to their stored id) bound as record and previous, plus usePredicateScope(). The lazily assembled record is now shared by both gates (predicateRecord()), so a body with no predicate does no extra work.
  • Scope of the guard. It applies to every body record:details draws, because the renderer cannot tell the default page's enumerated sections from an authored page's: app-shell's running default page sends the ungrouped bucket, and the whole body of an object with no fieldGroups, as enumerated sections of the same shape an authored page writes. One guard closes the class instead of a default-page-only branch.

Tests

New ui/packages/plugin-detail/src/renderers/__tests__/record-details.fieldVisibleWhen-35314.test.tsx (19 tests):

  • Parity matrix (10). Each case renders the same row through record:details (the synthesized default page) AND through the entry form renderer with the field carrying the same predicate, and asserts { form, detail } against the expected verdict: envelope and bare-string spellings, no predicate, three fault shapes (unbound bare identifier, parse error, unknown field: drawn, fail-open), a declared-but-absent column (null seed), a relation bound as its id, previous, and the host current_user scope.
  • Every body (7). Synthesized default page (grouped field, ungrouped bucket); running default page shape app-shell writes (grouped, ungrouped bucket, object with no fieldGroups); authored enumerated sections; authored flat fields list.
  • Controls (2). A field whose predicate holds and a field with none are drawn; a section whose every member is hidden draws no heading (and draws it on the record where they show).

Harness guards: each render first finds an ungated anchor value and throws HARNESS DEAD otherwise, so an empty body cannot pass a hidden leg.

Reverse verification: the pin against the BASE renderer (red), then restored

record-details.tsx restored from the base commit with git restore --source=BASE, the pin run, the file restored with git checkout HEAD -- in an EXIT trap. Mutation proof: resolveFieldRuleState count in the file = 0.

× envelope `record.stage == closed_won` — the card reproduction
× bare-string `record.stage == closed_won` — the same verdict as the envelope
× a declared field the row does not carry compares as null — evaluated, not faulted
× a relation binds as its stored id, expanded or not
× `previous` binds the persisted row, as on the record's edit form
× the host `current_user` scope binds on both surfaces
× synthesized default page — a field in a declared group: hidden on LOST, drawn on WON
× synthesized default page — a field in the ungrouped bucket: hidden on LOST, drawn on WON
× running default page — a field in a declared group: hidden on LOST, drawn on WON
× running default page — a field in the ungrouped bucket: hidden on LOST, drawn on WON
× running default page of an object with no fieldGroups: hidden on LOST, drawn on WON
× authored page — enumerated sections of bare names: hidden on LOST, drawn on WON
× authored page — a flat fields list: hidden on LOST, drawn on WON
× a section every member of which the predicates hide draws no heading
 Test Files  1 failed (1)
      Tests  14 failed | 5 passed (19)
card reproduction diff: form [false, true], detail [true, true]

The 5 that stay green on the base are the controls that must: no predicate, the three fail-open fault cases (drawn on both rows, which is also what the base did), and the predicate-holds control. Restore proof: git diff HEAD empty, git status --porcelain empty, git hash-object of the file equals the HEAD blob.

Package suite and type-check at head 43ff1a5
pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-detail/
 Test Files  387 passed | 1 skipped (388)
      Tests  3511 passed | 18 skipped (3529)
pnpm --filter @object-ui/plugin-detail run type-check   (tsc --noEmit && tsc -p tsconfig.test.json; the second program includes src/**/*.test.tsx)
TC_EXIT=0
pnpm --dir ui exec vitest run --maxWorkers=2 scripts/
 Test Files  171 passed | 2 skipped (173)
      Tests  5092 passed | 2 skipped (5094)

The group-gate pin record-details.groupVisibleWhen-11630.test.tsx (13 tests) is in that suite and stays green: an authored or synthesized { group } section's own gate is unchanged.

Acceptance notes

  • Authored pages change too, deliberately. On the base, an authored record:details section (or flat fields list) naming a field whose visibleWhen is false also drew it (measured red above). The guard closes that in the same fold, under the bounded in-place rule: same defect class, mechanical, same file, no new gate surface. Nothing changes for a field with no predicate, a field whose predicate holds, or a { group } section's own gate.
  • Evaluated against the stored record, not the inline-edit draft, like the group gate: editing stage inline reveals a gated field after save, not while typing.
  • Display only. The record API still returns the field, as with a form-hidden field.
  • Not covered here: record:highlights (the header strip) and the detail-view node / record drawer do not read a field's visibleWhen either. Not measured as reachable defects in this run; noted, not filed.
  • Real app. showcase_invoice.paid_on (visibleWhen: record.status == 'paid', object with no fieldGroups) is the in-repo fixture of this shape; its body is the "object with no fieldGroups" leg above. A live browser run was not made (no built console bundle in this container).
  • The registry inputs text for record:details (and the generated reference page) says nothing false after this change, so it is not edited here.

Verification

Derived local gate families (node scripts/pm/dispatch-gates.mjs --commands, 38 commands) run, each with its exit code captured before any pipe; all 38 exit 0. Reconciliation with --ran: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN. Every other family is CI's; see this PR's check runs.


Generated by Claude Code

…n is false

The default record page drew a field whose object-level visibleWhen is false
for the record. record:details now judges each drawn field's visibleWhen with
the form's own call (resolveFieldRuleState: fail-open on a fault, ADR-0137 D3),
over the record, previous and host scope the group gate already uses.

Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
Co-authored-by: Claude <noreply@anthropic.com>
…le-dedupe ladder

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CZrgaiMgTJCnswR6jQ

Final head for review · area ux-2 · 2026-11-19T09:03Z
Head: 43ff1a5edf87ad0b5813ce6fca766f8159eb070d. All check runs on it concluded: 42 success, 13 skipped, 0 failed (the PR-side subset).
Fixes #35314 · Clause-②: no · Metadata-protocol: none · +455/−9 over 3 files. Not governed (0 of 3).
PM reading on the dev's open question: route A is kept, so every record details body honours a field's own visibleWhen, authored pages included. The renderer cannot tell the default page's enumerated sections from authored ones; the form already honours the predicate on authored sections; and the card expects the page to "honour a field's visibleWhen the same way the form does". One key keeps one meaning.
Review route: L1-a thread. The area lands it after L1-a's ACCEPT.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4

维护者速读

  • 用户能看到什么变化:字段设置了“只在某些条件下显示”时,记录详情页现在和编辑表单一样,条件不满足就不显示这个字段。一个分组里的字段全部隐藏时,连分组标题也不显示。
  • 为什么做:在销售套件里测到,详情页会显示表单已经隐藏的字段,同一条记录在两处显示不一致。
  • 出错会怎样:只影响页面显示,数据和接口不变。条件算不出来时照常显示,和表单一样。撤回即可。
  • 要你做什么:无。

席位核对 — ACCEPT (L1-a) · repo:objectstack#5 · head 43ff1a5edf · 2026-11-19T09:04Z

  • Shape: 3 files, +455/−9: record-details.tsx (+72/−9), one new test file and one changeset. Not governed (check-governed: NOT governed, 464 lines). K = 10 since base 35c63310, and it merges cleanly into current main.
  • Fixes vs card (console: the default record page draws a field whose object-level visibleWhen is false (the default form hides one whose visibleWhen holds; the two disagree) #35314, Expected: "the default record page honours a field's visibleWhen the same way the form does"):
    • The new dropPredicateHidden runs last on both the flat body (filteredFields) and each enumerated section's fields. It reads the object's own Field.visibleWhen by name, never a key on the section entry.
    • The verdict comes from resolveFieldRuleState in @object-ui/core, which is the same call form.tsx makes (lines 2180, 2258, 2354, 2501 and 3756). Its arguments are the record as record and as previous, plus the host predicate scope. So the fault direction is the field rule's: it fails open and warns once (ADR-0137 D3). That is the opposite of the group gate, which fails closed, and the code comment says so.
    • The lazy sectionRecord moved up and is shared by the group gate and the field gate through predicateRecord(). Group-gate behaviour is unchanged: groupVisibleWhen-11630 stays green.
  • Pins: record-details.fieldVisibleWhen-35314.test.tsx renders every predicate case through both record:details and the real entry form. Each leg asserts the form's verdict, the page's verdict and the expected verdict, so two surfaces that are wrong the same way still fail. A HARNESS DEAD guard stops an empty render from passing as "hidden".
    • It was red on base for 14 of 19. The 5 that stayed green are controls and fail-open cases.
    • It covers current_user scope, every body shape and the empty-section heading.
    • record-details has no shared harness file, only per-card files like this one (the latest added 11-18), so a new file is the norm (ruling record 6583487846 does not apply).
  • Changeset: @object-ui/plugin-detail patch, Clause-②: no, Metadata-protocol: none. I read it sentence by sentence and it matches the code, including that it is display-only and the record API still serves the field. I checked none against AGENTS.md: the key's declared meaning ("field is shown only when TRUE (else hidden)") does not change, and the page now does what it already says. So this is not semantic.
  • Gates: CI on 43ff1a5e is 42 success and 13 skipped, with 0 failed and 0 pending. PR-side CI is a subset, so ux-2 triages any queue red.
  • Behaviour note, judged: no maintainer question. Authored record:details bodies now hide a visibleWhen-false field too. Route A is the reading the spec text, the card's Expected (parity with the form) and ADR-0078 (no silently inert metadata) all give: the form already hides such a field on the same authored sections, and one key keeps one meaning. A page that showed the field was showing what its author declared hidden. This changes no product goal and can be undone by reverting. The changeset already says it reaches authored sections.
  • Deviations accepted:
    • The PR body's 维护者速读 runs to os-dev.md's six lines. This record carries the four-line form.
    • The real app is NOT MEASURED because the container has no console build. The parity matrix against the real form renderer is the measurement.
  • Out of scope, needs a card: record:highlights, the detail-view node and the drawer don't read a field's visibleWhen either. That is the same defect class on sibling surfaces, so ux-2 files one card nested under console: the default record page draws a field whose object-level visibleWhen is false (the default form hides one whose visibleWhen holds; the two disagree) #35314 (p2, same grade class as the source).
  • Landing clause: not governed, so ux-2 lands it. K < 15, so no main merge is required. A new push needs a fresh L1 only if it changes more than a main merge.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CZrgaiMgTJCnswR6jQ

Landing · area ux-2 · 2026-11-19T09:05Z

reading value
L1-a ACCEPT comment 7004621926 at head 43ff1a5edf87ad0b5813ce6fca766f8159eb070d (= current head); the authored-page behaviour judged in-route (no maintainer question)
check-governed-merges --pr 35421 NOT governed, 0 of 3 paths, 464 lines ≤ 3000; K = 10 from merge base 35c63310; the queue's full suite is the integration check

State: draft → ready + auto-merge (merge queue). #35314 closes on merge via Fixes.

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/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants