Repository navigation
fix(components): header-action predicates wait for the record instead of reporting "No such key" - #34035
Merged
Conversation
…rd arrives While the record page's read is in flight the header bound an empty record, so every record.<field> predicate faulted with "No such key" and the warn-once report told the author to check field names the object has. A bound record id with no row is now its own pending state: each predicate answers its key's fallback and reports nothing until the row arrives. Claude-Session: https://claude.ai/code/session_01ADHkmQj66qNAyERYxzoNgw Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmQj66qNAyERYxzoNgw Co-authored-by: Claude <noreply@anthropic.com>
Contributor
Author
|
domain:ui#2 · os-steve · session_01ADHkmSzhXR4yUAgwq1bQRi 维护者速读
席位意见:ACCEPT。根因在调用方把“记录未到”当成“空记录”,修在调用方而非求值器,正确;加载中的 席位核对 — ACCEPT · domain:ui#2 · head
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Steve · project thread
Fixes #33987
Clause-②: no
Metadata-protocol: none
维护者速读
visible/hidden/disabled/pressed条件,在记录还没加载完时不再求值,也不再往控制台报错;记录到了再正常求值。record.status这类条件都报 “No such key… check the field names and CEL”,让作者去改其实没错的元数据。page:header一个组件;加载中各条件取各自的安全默认值(隐藏 / 不隐藏 / 禁用 / 未按下),与之前出错时的取值一致,记录到了以后行为不变。回滚即还原这一个提交。ui/packages/components/src/renderers/layout/containers.tsx的headerRecordPending与evalHeaderPredicate;再看page-header-predicate-dialect.test.tsx末尾新增的一组测试。cd ui && pnpm exec vitest run packages/components/src/__tests__/page-header-predicate-dialect.test.tsx,预期 33 条全绿。What changes
A record page binds its record id at once and its row only when the read answers (
RecordDetailViewhandsdata: nulluntil then;RecordContextValue.datais documented as "undefined while loading").page:headerevaluated its action predicates againstctx?.data ?? {}, so during that window everyrecord.FIELDpredicate faulted with "No such key", and the warn-once fault report (keyed by label and predicate) told the author to check the field names of a field the object has, on every page load.headerRecordPendingnames the state: a record context is present, it carries a record id, and its row isnull/undefined.evalHeaderPredicateanswers each key's own fallback while pending and evaluates nothing, so nothing is reported. All four call sites (visible,hidden,disabled,pressed) go through it.disabledReasonForgives no "Not available for this record" reason while pending: the closeddisabledfallback is not a fact about a record that has not arrived. Same defect class (a pending record reported as a fact about the record), same file, same gate families.record.*predicate there still faults and says so; a loaded record that really lacks the key still warns once.No change in
ui/packages/core/src/evaluator/**: the evaluator is right to fault on an empty record; the root cause is the caller spelling an absent record as an empty one.Tests
One new top-level
describein the existing shared harnesspage-header-predicate-dialect.test.tsx(no new file):visibleanswers hidden; record arrives → predicate honoured (shown), still no report;hidden/disabled/pressed→ rendered, disabled,aria-pressed="false", noaria-describedbyreason, no report; after load → enabled, pressed, no report;f_status→ hidden and exactly one fault namingf_status;No existing test was edited.
Acceptance notes
[false,false]with 2 fault reports; after load[true,false], which is the predicates' own verdict. So only the pre-load pass was wrong; the authored rule was already honoured once the record arrived. With the fix: pending[false,false], 0 reports; loaded[true,false], 0 reports.ctx.user.isPlatformAdmin == true) also waits for the record, where it used to evaluate at once. The header shows its record-gated and user-gated actions together, once the row arrives.Verification
Ablations (fix committed first; restored blob == HEAD each time)
headerRecordPendingforced tofalse: 3 of the 5 new tests red (expected [ Array(1) ] to have a length of +0 but got 1on both pending fault-count pins; the legs test red onaria-describedby); both CONTROL tests stay green.disabledReasonForpending line deleted: 1 red (the legs test,aria-describedby).Local runs at a1d4af3
cd ui && pnpm exec vitest run packages/components/src/__tests__/page-header-predicate-dialect.test.tsx: 33/33 passed.pnpm --filter @object-ui/components test --maxWorkers=2(under the verify lock): Test Files 479 passed, 1 skipped (480); Tests 4595 passed, 24 skipped.pnpm --filter @object-ui/components type-check(after building the dependency closure): exit 0.node scripts/pm/dispatch-gates.mjs --commands: 37 derived families, each run, all exit 0;--ranreconciliation: 37 run, 0 NOT-MEASURED, 0 UNRUN.pnpm --dir ui exec vitest run scripts/first exited 1 only because@objectstack/clienthad no build in this container (unresolved-entry list); after the build it passed 171 files / 5065 tests.Generated by Claude Code