Skip to content

fix(app-shell): the embedded item editor saves into the parent's draft (objectui#12027) - #12038

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-12027-embedded-draft-save
Oct 9, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-12027-embedded-draft-save

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #12027
Clause-②: no

The embedded item editor ("Save into object", opened from a metadata item's Related drawer) now saves into the parent's draft. Only EmbeddedItemEditor's doSave changes. No export, prop, type member or language-pack key is added.

Step 0: the live server's answer, measured

Measured on objectstack main 3054516e, from a separate objectstack worktree that has since been removed. examples/app-showcase was booted with objectstack dev --seed-admin --no-watch on its own port and its own SQLite file. Requests were sent two ways: directly over HTTP, and through the REAL editor with a real MetadataClient over HTTP. That second way was a one-off harness that rendered both main's editor and this branch's. It was never committed.

1. A draft-only parent, with the request the console sends today. The request is PUT /api/v1/meta/object/qa_sales_order with no query string and the body {"fields":{"amount":{"type":"number","label":"Order amount"}}}.

  • The server answers 422 INVALID_METADATA, with one issue at path name: "Invalid input: expected string, received undefined" (invalid_type).
  • Afterwards the published read and /layers still answer 404. The draft is unchanged and still in the drafts ledger. Nothing is published.
  • Through main's editor, the same request gets the same 422. The banner reads "Validation failed (1 issue)." The issue path name is not under fields.amount., so the editor maps it onto the sub-form unchanged. In the harness's field form, that path is the item's Name control, which then showed "Required text value". So the edit is not saved, the author is shown an error that is not about the item, and every retry sends the same stub.
  • A publish-mode write of an object with no sharingModel is also refused, by the author-time rule security-owd-unset (422). So the stub would be refused even if it carried a name.

2. A published parent with a pending draft, saved through main's editor.

  • The editor reads /layers (200), then sends a publish-mode PUT of the effective body with the item spliced in. The server answers 200: the edit goes live at once, without the author publishing.
  • The draft row is left as it was. Its own edits (a renamed label and an added channel field) are kept. It still holds the OLD amount label, so publishing that draft later puts the old label back.

This branch, measured live the same way:

  • Draft-only parent: the editor sends GET /_drafts, GET ?state=draft, then PUT ?mode=draft. The server answers 200 and the editor shows "Saved.". The stored draft row has the new amount label and keeps name, label, description and region. The published read and /layers still answer 404.
  • Published parent with a pending draft: PUT ?mode=draft answers 200. The draft keeps its renamed label and its channel field, and gets the new amount label. The published row is unchanged.
  • Published parent with no draft (control): GET /_drafts, then /layers (200), then a PUT with no query string (200). These are the same request and the same body as main's editor sends.
  • A parent with neither: GET /_drafts, then /layers (404), and no PUT. The banner reads "Failed to load object/qa_live_f: (not found)".
  • The rows were read straight from the SQLite file. A served draft carries the system columns, nameField and _diagnostics. The rows stored after these saves hold only the authored keys. The client strips the read decorations (extractDraftBody), and the server strips the served object columns.

What changed

doSave re-reads the parent when the author saves, as before. It now reads the parent's pending draft first, with the client's existing getDraft and extractDraftBody, both unchanged.

  • A draft exists: the item is spliced into the draft, and the parent is written back with { mode: 'draft' }.
  • No draft: the published body is read from /layers (effective, else code), and the save is sent exactly as before, in publish mode.
  • Neither is readable: the save is refused with an error state, using the existing strings engine.edit.loadFailed and engine.form.notFound. Nothing is sent and "Saved." is not shown. A missing published version never becomes {}.
  • A failed draft read is the save's error, and nothing is sent. Reading it as "no draft" would send a publish-mode write over a pending draft.

The one caller, MetadataDetailDrawer, holds no parent draft, so doSave reads it itself. MetadataDetailDrawer and RelatedPanel are untouched.

Pins

New file: EmbeddedItemEditor.draftSave-12027.test.tsx. It uses the real editor over a real MetadataClient, whose transport is an in-memory server shaped like the framework (drafts ledger, decorated ?state=draft, /layers 404, and a PUT that writes the draft row or the published row by mode). Six tests:

  • a draft-only parent: the edit lands in the draft, every other field is kept, and no publish-mode request is sent;
  • a published parent with a pending draft: the edit lands in the draft, the draft's own edits are kept, and the published row is untouched;
  • CONTROL: a published parent with no draft saves as before, with one publish-mode PUT of the effective body plus the item;
  • a parent with neither is refused with an error state: no PUT, and no "Saved.";
  • a draft-read failure (5xx) is the save's error, and nothing is PUT;
  • a 422 on the draft-mode save still lands its issue on the sub-form field.

Changed files, with their existing assertions unchanged:

  • EmbeddedItemEditor.refusalIssues-11379.test.tsx: its stub client gains getDraft: async () => null.
  • EmbeddedItemEditor.layersRead-11799.test.tsx: the header's "Not covered" paragraph now points at the new file. All three of its pins stay green. This card's write side supersedes nothing in them: both of its controls have no draft, so they still reach /layers.

Verification (head 3d2bcf0ab)

  • Pins, run under the shared verify lock: pnpm exec vitest run --maxWorkers=2 over the six EmbeddedItemEditor.* test files gave Test Files 6 passed (6) and Tests 35 passed (35).
  • app-shell, whole package: under the lock, pnpm exec vitest run --maxWorkers=2 packages/app-shell/ gave Test Files 1229 passed | 1 skipped (1230) and Tests 12031 passed | 9 skipped (12040), with the VERDICT line command-exit 0. The lock was held for 47 minutes on a shared box.
  • Type-check: turbo run build --filter='@object-ui/app-shell^...' --concurrency=2 (28 of 28 tasks), then pnpm --filter @object-ui/app-shell type-check (tsc --noEmit && tsc -p tsconfig.test.json), exited 0. tsc -p tsconfig.test.json --listFilesOnly lists the three touched test files.
  • ESLint, pnpm exec eslint --format json on the four touched files: 4 files, 0 errors, 7 warnings. The 7 warnings are exactly the 7 that main's copy of EmbeddedItemEditor.tsx already has, with the same rules at shifted lines, so none is new. This narrowed run is a measurement. The population is the four touched files (the JSON count is 4). eslint.config.js sets no parserOptions.project and no projectService, so linting is not type-aware. Nothing imports a test file, so no untouched file's verdict can move. pnpm lint is left to CI.
  • Gates, each exit 0: check:control-bytes, check:test-path-roots, check:changeset-claims, check:pending-changeset-literals, check:new-line-citations, check:vi-mock-specifiers, check:vi-mock-inherit, check:vi-mock-override-shape, check:metadata-write-doors, check:phantom-deps, check:unreferenced-sources, node scripts/check-changeset-presence.mjs, node scripts/check-changeset-no-major.mjs. No locale pack and no export changed, so the i18n gates and check:readme-exports do not apply.

Reverse verification (one-time, not committed)

Both runs used objectstack's scripts/ablation-replace.mjs in WRAP mode, under the lock, on the committed fix. The test resolves the editor from src, so no dist leg is needed.

  • R1: { mode: 'draft' } dropped from the draft-based save. The anchor count went from 1 to 0, and the blob from 062bbc87 to 82ebe33f. Result: 3 failed / 32 passed of 35, in the predicted direction. The draft-only pin, the pending-draft pin and the draft-mode 422 pin went red. The control, the refusal and the draft-read-failure pins stayed green.
  • R2: the ?? {} fallback put back after layered.effective ?? layered.code. The anchor count went from 1 to 0, and the blob from 062bbc87 to c68f7a78. Result: 1 failed / 34 passed: exactly the refusal pin ("Unable to find … Failed to load object/sales_order: (not found)").
  • Each restore was proven: the blob equals the HEAD blob 062bbc87, and git diff HEAD is empty.

Acceptance notes

  • Not ruled, kept as is: whether a published parent with no draft should also save as a draft. It saves in publish mode as before. That is the control pin, and it was measured live to send the same request as main's code.
  • A choice beyond the ruling's letter: a failed draft read refuses the save instead of falling back to publish mode. It is pinned.
  • The editor holds no package scope, so the draft read is unscoped, like the layered read it sits beside.
  • objectui#11773 (no draft save sends If-Match) is not addressed here and remains open.
  • An observation, not filed: the editor's 422 mapping places a parent-level issue path (one not under EMBEDDEDPATH.ITEM.) on the sub-form unchanged. On main, the stub's name issue therefore marked the item's own Name control. After this change the stub is never sent, and no other parent-level issue path was measured reaching that mapping.

Session: https://claude.ai/code/session_01CGZy1BGCjdN5cXqL9cnvB8 (domain:ui seat 3 dispatch, os-dev subagent).


Generated by Claude Code

claude added 2 commits October 9, 2026 06:28
…t (objectui#12027)

EmbeddedItemEditor's save based the parent on its published layers and
PUT it in publish mode. For a draft-only parent the layered read's 404
became an empty body, so the save sent a publish-mode stub of the one
item and said "Saved.".

The save now reads the parent's pending draft first and, when there is
one, splices the item into it and writes it back with mode draft. With
no draft it reads the published body as before and saves as before.
With neither, it refuses with an error state and sends nothing.

Claude-Session: https://claude.ai/code/session_01CGZy1BGCjdN5cXqL9cnvB8
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Eager closure (gzip, 289 chunks) 3162.5 KB 3204.6 KB
Main entry chunk (gzip) 71.6 KB 350 KB
Entry file index-BPNkNVPS.js —
Status PASS —

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

Package Size Gzipped
app-shell (consoleActionDispatch.js) 0.20KB 0.19KB
app-shell (index.js) 19.52KB 7.19KB
app-shell (runtime-config.js) 22.59KB 7.89KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 10.11KB 3.87KB
auth (ActiveOrganizationStorage.js) 27.95KB 10.04KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 2.07KB 1.00KB
auth (AuthProvider.js) 40.22KB 10.61KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.15KB 5.40KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.72KB 2.24KB
auth (SocialSignInButtons.js) 9.70KB 3.93KB
auth (UserMenu.js) 3.39KB 1.21KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 41.19KB 11.12KB
auth (createAuthenticatedFetch.js) 8.54KB 3.46KB
auth (index.js) 3.63KB 1.64KB
auth (invitation-status.js) 1.22KB 0.70KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 5.30KB 1.02KB
auth (useWorkspaceAdminStatus.js) 11.08KB 4.58KB
collaboration (CommentThread.js) 27.11KB 7.97KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 6.28KB 2.60KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.68KB 0.73KB
collaboration (useCollaborationTranslation.js) 6.50KB 2.52KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 587.83KB 141.44KB
core (index.js) 10.00KB 3.96KB
create-plugin (index.js) 27.94KB 9.51KB
data-objectstack (index.js) 240.39KB 67.09KB
fields (index.js) 268.74KB 68.04KB
i18n (LocalizationContext.js) 2.92KB 1.42KB
i18n (builtinAggregateLabels.js) 0.86KB 0.49KB
i18n (currency.js) 2.59KB 1.22KB
i18n (fallbackInterpolation.js) 6.25KB 2.77KB
i18n (i18n.js) 8.87KB 3.64KB
i18n (index.js) 5.52KB 2.39KB
i18n (pickLocalized.js) 9.86KB 3.95KB
i18n (provider.js) 39.35KB 12.88KB
i18n (translateFn.js) 0.20KB 0.18KB
i18n (useDisplayLocale.js) 3.52KB 1.76KB
i18n (useObjectLabel.js) 36.87KB 9.88KB
i18n (useSafeTranslation.js) 7.14KB 2.92KB
layout (index.js) 41.50KB 11.82KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.75KB
mobile (index.js) 1.99KB 0.87KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 6.62KB 2.45KB
mobile (useResponsive.js) 0.72KB 0.42KB
mobile (useSpecGesture.js) 5.52KB 2.10KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 13.86KB 5.00KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 6.52KB 2.26KB
permissions (discardProofCache.js) 1.04KB 0.55KB
permissions (evaluator.js) 8.33KB 3.07KB
permissions (index.js) 0.93KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.53KB
permissions (usePermissions.js) 4.83KB 2.27KB
plugin-ai (index.js) 16.04KB 3.92KB
plugin-calendar (index.js) 53.43KB 15.54KB
plugin-charts (index.js) 84.71KB 23.25KB
plugin-chatbot (index.js) 201.52KB 47.99KB
plugin-dashboard (index.js) 144.20KB 38.95KB
plugin-designer (index.js) 233.53KB 49.80KB
plugin-detail (index.js) 248.57KB 65.47KB
plugin-editor (index.js) 2.23KB 1.05KB
plugin-form (index.js) 177.11KB 45.88KB
plugin-gantt (index.js) 179.17KB 45.07KB
plugin-grid (index.js) 249.62KB 69.16KB
plugin-kanban (index.js) 52.77KB 16.56KB
plugin-list (index.js) 120.25KB 30.26KB
plugin-map (index.js) 27.24KB 9.03KB
plugin-markdown (index.js) 13.88KB 4.80KB
plugin-report (index.js) 44.12KB 12.29KB
plugin-timeline (index.js) 39.10KB 11.81KB
plugin-tree (index.js) 15.07KB 5.33KB
plugin-view (index.js) 91.20KB 23.04KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.81KB 3.58KB
providers (index.js) 0.45KB 0.23KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.62KB 2.34KB
react (LazyPluginLoader.js) 4.47KB 1.63KB
react (SchemaRenderer.js) 120.63KB 39.56KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 4.50KB 2.06KB
react (schema-input.js) 4.31KB 2.07KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (body-dialect.js) 4.50KB 1.99KB
sdui-parser (codegen.js) 9.45KB 3.76KB
sdui-parser (dashboard-widget-options.js) 3.07KB 1.30KB
sdui-parser (index.js) 7.30KB 3.12KB
sdui-parser (input-type.js) 2.84KB 1.40KB
sdui-parser (parse.js) 25.28KB 7.80KB
sdui-parser (provenance.js) 3.84KB 1.90KB
sdui-parser (types.js) 0.28KB 0.23KB
sdui-parser (validate.js) 23.87KB 7.83KB
types (ai.js) 4.39KB 2.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 4.12KB 1.61KB
types (authoring-nodes.js) 0.20KB 0.19KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (cloud.js) 0.20KB 0.18KB
types (complex.js) 4.44KB 2.07KB
types (crud.js) 0.20KB 0.18KB
types (dashboard-filter-alias.js) 6.23KB 2.74KB
types (dashboard-widget-layout.js) 2.06KB 0.96KB
types (data-display.js) 3.75KB 1.85KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.85KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (expression.js) 0.20KB 0.18KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 1.13KB 0.65KB
types (form.js) 0.20KB 0.18KB
types (http-inflight.js) 8.87KB 3.73KB
types (http-retry.js) 4.32KB 2.02KB
types (icon-key-migration.js) 4.26KB 1.63KB
types (index.js) 5.78KB 2.70KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 5.00KB 2.39KB
types (navigation.js) 0.20KB 0.18KB
types (node-slots.js) 7.18KB 2.34KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 2.52KB 1.31KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (select-option.js) 0.20KB 0.19KB
types (spec-report.js) 4.99KB 1.96KB
types (spec-ui-namespace.js) 0.20KB 0.19KB
types (strict-authoring-face.js) 19.93KB 7.25KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 6.28KB 2.87KB
types (ui-action.js) 8.11KB 3.32KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review October 9, 2026 07:54
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge October 9, 2026 07:54
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit ea79b77 Oct 9, 2026
45 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-12027-embedded-draft-save branch October 9, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants