Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Create-form does not resolve the current_user defaultValue token — spec-correct "default applicant = me" renders as an empty field until save #5683

Closed

Description

@os-zhuang

What

The spec's defaultValue runtime token current_user (@objectstack/spec/data DEFAULT_VALUE_TOKENS, #7127 family — legal on user fields and lookup with reference: 'sys_user') is resolved only by the engine at INSERT time (objectql/engine.ts — isCurrentUserDefaultToken → out[f.name] = execCtx.userId). ObjectForm resolves neither this token nor any dynamic default client-side: a new-record form renders the field empty, and the value appears only after save.

Why it matters (live prod repro, 2026-08-22)

Env os-6vp51e.objectos.ai, app app.v4b4 (报销流程): the owner asked the build agent 「报销单申请人默认不应该就是自己吗?」. The agent authored the spec-correct metadata —

"applicant": { "type": "lookup", "reference": "sys_user", "defaultValue": "current_user" }

— and the engine WILL stamp the actor on save (verified: an untouched lookup is omitted from ObjectForm's insert payload — server error text "insert … did not supply 'project'" proves absence, not '' — so the omitted-or-null default path fires). But the user opened the new-record form, saw 申请人 empty, and reasonably concluded the change did not work. Two sessions of back-and-forth followed. The "default = current user" a user asks for IS form pre-fill; engine-on-save alone reads as broken.

Ask

When building the initial values for a create form, resolve defaultValue: 'current_user' on user / lookup→sys_user fields to the session user (id + display), the same way static schema defaults are seeded today (the objectui-form-defaults-and-falsy seam). The token spelling must come from @objectstack/spec (DEFAULT_VALUE_TOKEN_CURRENT_USER), not a local literal — that drift is exactly how #4560 happened engine-side. NOW() on date/datetime deserves the same treatment while in there. Engine-side resolution stays as the authority for non-form writers; the form seed is a UX mirror, and an untouched pre-filled value submits the same id the engine would have chosen, so no behavior fork.

Cross-refs: engine token application packages/objectql/src/engine.ts (#4560/#4597 comments); agent-side narration fix tracked in cloud#1584 (D2 addendum).

Activity

  1. os-zhuang commented on Aug 22, 2026

    @os-zhuang
    ContributorAuthor

    Claim — session 30b1d4ba (cloud epic #1521 PM seat), branch fix/current-user-default-prefill, surface: ObjectForm create-mode initial-value seeding (+ shared default resolution helper). Maintainer directive 2026-08-22: 「相关问题你都直接处理」.

  2. added a commit that references this issue on Aug 22, 2026
  3. os-zhuang commented on Aug 22, 2026

    @os-zhuang
    ContributorAuthor

    Verified end-to-end on staging (env os-1cvf2x.objectos.app, 2026-08-22, console @ 3c9fca3d via cloud#1588): asked the build agent for a 「审核人」 user field defaulting to 当前登录用户 → metadata landed with the token → the create form now renders the field pre-filled with the session user (ME · Magic Flow E2E chip, clearable/replaceable). Bonus: with cloud#1587's skill rules live, the agent unprompted narrated the save-time semantics correctly (「默认值是保存时由系统解析填入的…表单里可能显示为空,留空提交即可」) — both halves of the fix confirmed in one round.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions