Skip to content

fix(plugin-form): drawer, tabbed and wizard edit forms for a record that does not exist show the not-found state, not an empty editable form - #29351

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/project-thread-w237hz
Nov 2, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/project-thread-w237hz

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steedos · project thread

Fixes #29247

Clause-②: no
Metadata-protocol: none

Declarations as set by the claim (card comment 6576081714), which fixes the file surface: DrawerForm.tsx, TabbedForm.tsx, WizardForm.tsx, loadFailure.ts (a module-private shared helper only), ModalForm.tsx only because its not-found drawing moved into that helper, their tests and a root changeset.

维护者速读

  • 改了什么:抽屉表单、分页签表单和向导表单在编辑一条不存在的记录时,现在显示「Record not found」未找到状态(与记录页和 ?form= 弹窗相同的文案),不再显示可编辑的空白表单,也没有「更新」按钮。四种记录表单共用 loadFailure.ts 里同一个私有组件来画这个状态。新建和编辑已存在的记录不变。
  • 为什么改:用户从已删除记录的旧链接进入这三种表单,会看到空白表单,填完点更新才被告知记录不存在;PR fix(plugin-form): the ?form overlay for a record that does not exist shows the not-found state, not an empty editable form #29246 只修了弹窗表单。
  • 风险与回滚:低。三处记录读取 effect 在 findOne 返回 null 时记一次 RecordNotFoundError 加载失败、不再把 {} 填进表单;原有的「加载失败时不画表单和底栏」路径接管其余。表单打开期间后台重读发现记录已删,也显示同一状态。ModalForm 只是改为调用共享组件,行为不变。回滚即还原本 PR。
  • 先看:ui/packages/plugin-form/src/loadFailure.ts 末尾的 RecordNotFoundState;DrawerForm.tsx 记录读取 effect 的 data == null 分支与 renderContent 开头的分支;WizardForm.tsx 同一处(它还设置 persistedRecord)。
  • 两分钟验证:pnpm --dir ui exec vitest run packages/plugin-form/src/recordNotFound-29247.test.tsx packages/plugin-form/src/ModalForm.recordNotFound-29157.test.tsx,预期 2 个文件、16 个测试全绿。
  • 需要你做的:无,席位落地。

What changes

  • A null edit read is a failure, not an empty record, in every record form. DataSource.findOne is typed T | null, and the ObjectStack adapter's readOne answers null when the server answers 404. DrawerForm, TabbedForm and WizardForm ran setFormData(data || {}) (the wizard also setPersistedRecord(data || {})) and committed, so an edit form for a deleted or unknown record drew a blank editable form with an enabled Update button. Each now fails the read with the package-private RecordNotFoundError, through the per-read failure run every other load failure uses, and the form is not seeded. This is the branch PR fix(plugin-form): the ?form overlay for a record that does not exist shows the not-found state, not an empty editable form #29246 gave ModalForm.
  • One drawing for the state. loadFailure.ts gains a module-private RecordNotFoundState: Empty with EmptyTitle and EmptyDescription, reading the existing pack keys empty.recordNotFound and empty.recordNotFoundDescription through its own createSafeTranslation table (the en values, so a provider-less host still reads English). Each of the four layouts draws it ahead of the generic "Error loading form" box when the shown failure is a RecordNotFoundError; the drawer keeps its footer off while a load failure is shown, as before, and the tabbed and wizard layouts return the state in place of the form. ModalForm's inline copy of the same drawing and its two table rows move into the helper; its test id is kept.
  • Also on a background re-read. A bus re-read (useRecordInvalidation) that finds the record deleted while the form is open shows the same state.
  • Unchanged. Create (or no id) never reads; an edit of a record that exists draws its form as before. No new string, no new export from the package entry, no prop or schema change.

Why

A user who opens an old link to a deleted record in a drawer, tabbed or wizard form saw a blank form, filled it in, and learned the record did not exist only on save.

Tests

  • New recordNotFound-29247.test.tsx, one describe.each over DrawerForm, TabbedForm and WizardForm (each an object-form in edit mode with one section, the real registered fields): a null read draws "Record not found", its description and the layout's test id, with no title input, no Update button and no "Error loading form"; a found record that a bus re-read then finds deleted switches to the same state; CONTROL a found record still draws its form and Update; CONTROL a create draws an empty form with Create and never calls findOne.
  • ModalForm.recordNotFound-29157.test.tsx (unchanged) holds ModalForm after its drawing moved into the helper.

Acceptance notes

  • Live console not measured. The chain is pinned in vitest from the findOne answer down; the adapter's 404 to null mapping is read from ObjectStackAdapter.readOne, not re-exercised.
  • The helper is built with createElement because loadFailure.ts stays a .ts module as the claim names it; the data-testid prop is typed onto Empty's props instead of cast.
  • setFormData(data) in the three layouts: after the null branch the || {} fallback could no longer fire, so it is dropped. ModalForm's own line is left as it is.
  • One lint warning in the new test (no-explicit-any on the parametrised layout type), the same documented shape and reason as recordSwapLoading.test.tsx: the four layouts share no props base.

Verification

New pin · 12/12 here, the 6 not-found cases red against main's three layouts

pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-form/src/recordNotFound-29247.test.tsx packages/plugin-form/src/ModalForm.recordNotFound-29157.test.tsx under os-verify-lock at c4c659f5: Test Files 2 passed (2), Tests 16 passed (16).

Reverse check at 35a69884: DrawerForm.tsx, TabbedForm.tsx and WizardForm.tsx restored from the base c347d22d with git restore --source (on disk: RecordNotFoundError count 0 in each; data || {} count 1, 1 and 2), loadFailure.ts kept at HEAD, new test file alone: Tests 6 failed, 6 passed (12). All six failures were the two not-found cases of each layout, each "Unable to find an element with the text: Record not found"; all six CONTROLs passed. Restored with git restore --source=HEAD --staged --worktree under an EXIT trap; git diff HEAD empty, git status --porcelain empty, and each file's git hash-object equal to its HEAD blob.

At the final head 56a7a05d (after the second merge of main): the two not-found files plus ModalForm.untypedRepeater.test.tsx (new on main) and recordSwapLoading.test.tsx: Test Files 4 passed (4), Tests 33 passed (33).

plugin-form package, type check and lint
  • pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-form/ (locked) at 903d4662: Test Files 220 passed (220), Tests 2435 passed, 1 skipped. Same counts at 35a69884 before the first merge.
  • turbo run type-check --filter=@object-ui/plugin-form (tsc --noEmit && tsc -p tsconfig.test.json): exit 0 at 903d4662 and again at 56a7a05d. The first run, at 35a69884, before 815181c6 typed the test id prop, was red with TS2769 on createElement(Empty, { 'data-testid' … }); fixed by naming the attribute in the props type, no cast.
  • eslint on the six changed .ts/.tsx files: 0 errors; the one warning in a changed hunk is the documented any in the new test.
  • pnpm --dir ui run check:new-line-citations: 0 new citations. node scripts/check-i18n-call-site-keys.mjs (from ui/, at 35a69884): exit 0, the new createSafeTranslation table repeats the en values.
Derived gates

node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 34 commands (the same 34 against merge bases c347d22d and d9885f5d). At 903d4662, the 33 non-vitest gates ran in one loop and all exited 0, check-sdui-manifest.mjs and its --self-test, check:nul-bytes, check:query-options-erasure, check:type-check-debt and check:test-source-alias among them; pnpm --dir ui exec vitest run scripts/: Test Files 169 passed, 2 skipped; Tests 4903 passed, 2 skipped. dispatch-gates --ran: 34 derived, 34 run, 0 NOT-MEASURED.

main then moved 21 commits, none touching the changed files (one new ModalForm test file and one en key in plugin-form and i18n). After merging it, at 56a7a05d: check-sdui-manifest, check-changeset-no-major, check-adr-0087-registration, check-empty-changeset, check:nul-bytes, check:type-check-debt, check:type-check-coverage, check:test-source-alias, check:cross-package-test-inputs, check:undeclared-dep-imports and check:published-files all exit 0. The other 23 derived gates were last measured at 903d4662.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (no spec change)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes. (eslint on the changed files: 0 errors)
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (not touched)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

…hat does not exist show the not-found state

A null findOne answer in edit mode is a RecordNotFoundError, as in
ModalForm, and every record form draws it through one shared
RecordNotFoundState in loadFailure.ts instead of seeding an empty
editable form.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jTeZsth6vzGnL4eoaN
@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 2, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#3 · zhuangjianguo · session_01QsR2jV4dWohojjbTJTQq5m

席位核对 · ACCEPT · 2026-11-02T12:57Z

Head-sha: 56a7a05d14aaba7dcf71f78aa7fd59d076a8b602

  • Shape: draft → main, Fixes #29247 in the body only. 7 files, +237 / −18 (255 lines ≤ 3000). No governed path: check-governed-merges --pr 29351 reports NOT governed (0 of 7 paths). Clause-②: no and Metadata-protocol: none are line-initial in the body and the changeset, as claimed (6576081714). The changeset is patch for @object-ui/plugin-form.
  • Contract review: none owed (Clause-②: no; RecordNotFoundError and the new RecordNotFoundState stay in the module-private loadFailure.ts, which src/index.tsx does not re-export; no new string, the two empty.* keys and defaults move unchanged from ModalForm).
  • File surface: inside the claim: DrawerForm.tsx, TabbedForm.tsx, WizardForm.tsx, loadFailure.ts (the shared drawing), ModalForm.tsx (its inline drawing moved into that helper, as the claim allowed), the new test, and the changeset.
  • Read in the diff: each of the three shells now fails a null edit read with RecordNotFoundError and returns before setFormData (the wizard before setPersistedRecord too), and draws RecordNotFoundState with its own test id: no form, no footer, no save. data || {} is gone, so a found record is passed as read. Create mode never reads, so it is unchanged.
  • Tests (dev): new recordNotFound-29247 12 / 12 (per shell: a null edit draws the not-found state with no save control; controls for create and a found record). Ablation (the three layouts restored from base) reds the 6 not-found cases with the 6 controls green, restored by hash. plugin-form 220 / 220 at 903d466; type-check at this head; derived gates 34 of 34 at 903d466, the fast ratchet and changeset gates re-run green here after a main merge that touched none of these files.
  • Gates (check-runs on this head): 44 success, 11 skipped, 0 failed or pending. mergeable_state is clean.
  • NOT MEASURED: a real Console run of each shell on a deleted record.
  • Follow-up filed: ObjectForm (default layout): editing a record that does not exist opens a blank, editable form #29354 (the default ObjectForm layout has the same defect; serial after this PR).
  • Landing: ordinary queue landing, pr_ready then automerge_enable. Fixes #29247 closes the card on merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 2, 2026 12:57
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 2, 2026 12:58
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit c92ae76 Nov 2, 2026
56 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-w237hz branch November 2, 2026 13:35
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

Development

Successfully merging this pull request may close these issues.

DrawerForm, TabbedForm and WizardForm: editing a record that does not exist opens a blank editable form

1 participant