Repository navigation
perf(plugin-view, app-shell): an object list loads the form package only when a form opens - #38486
Conversation
…nly when a form opens The object view drew its create / edit form from a static import of @object-ui/plugin-form, and the console drew a closed record-form dialog on every object page, so a list's first screen fetched the whole form package. The object view now loads ObjectForm lazily inside the drawer or modal that mounts it, and the console mounts the record-form dialog the first time it opens (useOpenedOnce, now shared with the view settings panel and the create-view dialog). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibxzGFPvShbd2qnkdEv
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5pH8MaBBP5T2dVcTHL
|
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5kjJ6Qm1z2mRox4ZbB 席位核对 — REWORK · L1-b · area o5-ux · Head-sha
|
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5kjJ6Qm1z2mRox4ZbB 席位核对 — ACCEPT · L1-b · area o5-ux · Head-sha
|
|
repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU |
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5pH8MaBBP5T2dVcTHL
|
Requested by Tesla · project thread
Part of #37444. This is the second cut, after #38429: the object list page stops loading the form package before its first screen. What this PR build measured (Verification below, 20 vs 20 against main
4d07ddbf): the list fetches about 45 KB gzip less form code before its first screen (225 → 224 scripts), and its LCP moved −46.5 ms at p 0.22, not a significant change and still above 2500 ms. So the card stays open after this PR, for candidate B.Clause-②: no
Metadata-protocol: none
维护者速读
What changes
An object list fetched the whole of
@object-ui/plugin-form(45.6 KB gzip, measured on1afd9c13) before its first screen, though it draws a form only when someone creates or edits a record. Two things did this:plugin-view'sObjectViewimportedObjectFormstatically. The form is drawn only inside the drawer or modal, whose content mounts when it opens.AppContentdrew a closedLazyModalFormon every object page:formObjectDefis set whenever an object is open, and a lazy component that is drawn fetches its chunk even closed. Making only the first import lazy left the chunk on the list route (seen in a probe; it was still fetched at about 2.0 s).Now:
plugin-view/src/ObjectView.tsx:ObjectFormisReact.lazy, and both form sites (drawer and modal) sit in aSuspensewith anullfallback.app-shell/src/console/AppContent.tsx: the record-form modal mounts the first render its open state is true (useOpenedOnce(recordFormShown)), and stays mounted after that, so it closes the way it did before. It is never drawn closed first.useOpenedOncemoves fromapp-shell/src/views/ObjectView.tsx(where perf(app-shell): an object list loads the package ask, the view settings panel and the create-view dialog only when opened #38429 added it) toapp-shell/src/hooks/useOpenedOnce.ts, package-internal, shared by both files. It is not exported from the package.No exported shape, prop or option changes; no spec or metadata change.
Tests
plugin-view/src/__tests__/ObjectView.formLoadsOnOpen-37444.test.tsx: a countedvi.mockfactory for@object-ui/plugin-form. Importing and drawing a drawer-layout list evaluates no form module; clicking New loads it once and draws the form increatemode.app-shell/src/console/__tests__/AppContent.recordFormMountsOnOpen-37444.test.tsx: an object page with no form open loads no form module and draws no modal;?form=newloads it once and its first render is open.ObjectView.tableEditable-10976,ObjectView.namedViewInlineEdit-10885andObjectView.test.tsx(navigation drawer default) read the form on the click's tick; they now wait for it, since it loads on first open.Pin ablation
Committed first, then
scripts/ablation-replace.mjs, one half at a time:AppContent.tsx: the anchor{formObjectDef && recordFormMounted && (replaced with{formObjectDef && (. Both AppContent cases red: case 1 drew a modal andloads.formwas 1 (expected 0); case 2 failed on its starting count. Restored: blob equals HEAD.plugin-view/src/ObjectView.tsx: the lazyObjectFormconst replaced with the staticimport { ObjectForm } from '@object-ui/plugin-form';. The plugin-view case red (expected 1 to be +0). Restored: blob equals HEAD,git diff HEADempty.Acceptance notes
AppContent.tsx(therecordFormMountedgate next touseRecordFormOpensOverDrawers), thenplugin-view/src/ObjectView.tsx(the lazy const and the twoSuspensesites).plugin-formchunk. Click New: the form opens after one chunk fetch. Close it and open it again: no new fetch.Verification
LCP reading on this PR's build (report on #37444, comment 7251766050), Lighthouse 13.6.0 desktop, 20 vs 20 per page against main at the merge base
4d07ddbf:The list fetches no
plugin-formchunk: 225 → 224 scripts, −45.4 KB gzip. It does not clear 2500 on this reading, so the card stays open. A same-session control read main1afd9c13at 2681.5. The same build read 2521.5 in the second-cut reading, so the box level moved about 160 ms between sessions. The record delta is unexplained: bytes, script count and theplugin-formrequest time match on both builds.Gates
Derived gates (
dispatch-gates.mjs --ran): 38 derived, 38 run, 38 exit 0, 0 NOT-MEASURED, on6a6dc4b9. Two needed a fix first, on the new AppContent pin:check:test-source-alias(a module-topimport '@objectstack/lint') andcheck-vi-mock-inherit(both countedplugin-formfactories now spreadimportOriginal); the pins and both ablations were re-run after it.vitest run scripts/: 172 files passed. Affected suite under the verify lock: 251 files / 2286 tests passed. eslint on the changed files: 0 errors. Overlap check againstorigin/main430bbbf1: merges cleanly. Changed lines: +290/−21 (311).Human Minimum
packages/specholds no runtime logic. (not touched)main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01L9qibxzGFPvShbd2qnkdEv