Uh oh!
There was an error while loading. Please reload this page.
feat(plugin-form): pre-fill the current_user defaultValue token on create forms - #5686
Merged
Conversation
…eate forms (#5683) The engine resolves defaultValue: 'current_user' to the acting user's id at INSERT (ObjectQL.applyFieldDefaults -> execCtx.userId), but no client code resolved it, so a spec-legal "default applicant = me" opened as an empty control and read as a broken change — the live prod shape on 报销流程's applicant lookup. This is the "surface what the server WILL supply" follow-up the #4069 notes promised. - permissions: PermissionContextValue.userId (from /me/permissions; null = unknown), threaded by MePermissionsProvider; the role-based provider and the no-provider fallback report null. - schemaDefaults: schemaDefaultValues/seedCreateValues accept an optional SeedContext{currentUserId}. current_user seeds the known user id on the token's two legal field shapes only (type 'user', or 'lookup' with reference/reference_to 'sys_user' — mirroring the field.zod #7127 authoring rule). NOW() and CEL envelopes stay server-owned: form-open time is not insert time. - All seven create seeding sites (ObjectForm + Modal/Drawer/Tabbed/ Split/Wizard) thread usePermissions().userId. Unknown user seeds nothing — empty control, key omitted, engine resolves: the exact pre-#5683 contract, which is why every #4047/#4068/#4069 test passes unchanged. Closes#5683 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
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 freeto 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.
What
defaultValue: 'current_user'is a spec-legal runtime token (DEFAULT_VALUE_TOKENS, legal onuserandlookup→sys_userperfield.zod#7127) that the engine resolves to the acting user's id at INSERT. No client code resolved it, so a create form rendered the field empty and the value appeared only after save.Live shape that motivated this (prod, 2026-08-22): 报销流程's
applicant: { type:'lookup', reference:'sys_user', defaultValue:'current_user' }— engine-honoured, yet the owner opened 新建报销单, saw 申请人 empty, and reasonably concluded the change didn't work (#5683; agent-side narration half tracked in cloud#1584).How
PermissionContextValue.userId(/me/permissionsuserId;null= unknown).MePermissionsProviderthreads it; the role-based provider and no-provider fallback reportnull.SeedContext{ currentUserId }onschemaDefaultValues/seedCreateValues.current_userseeds the known id on the token's two legal field shapes only (type:'user'", orlookupwithreference/reference_to=sys_user). The seeded id equals the engine's own resolution **by construction** — no second default contract, a preview of the same one.NOW()`/CEL stay server-owned (form-open time ≠ insert time; client can't evaluate CEL).usePermissions().userId.defaultValue— a required select with a default renders empty and forces a manual choice #4047/fix(plugin-form): seed create forms from the object schema's declared defaults #4068/A required field whosedefaultValueis a runtime token (NOW()/current_user) cannot be submitted from a create form #4069 pin passes unchanged.Tests
New
currentUserDefault.test.tsx(5): legal-shapes-only unit matrix (both reference spellings, illegal type left alone, NOW() untouched, caller initial outranks), plus two ObjectForm component pins — seeded id is SUBMITTED with a provider, and the key is OMITTED without one. Fullplugin-form+permissionssuites: 671 passed. Root build green.Closes#5683
🤖 Generated with Claude Code