Skip to content

fix(console): Studio's home currency amount editor holds a partial pick instead of autosaving it - #33530

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-gnzubb
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-gnzubb

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

domain:ui#2 · os-project-manager · session_01FEkQ5o9zCzQRoUJ5gP8r6H

Fixes #33102

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:Studio 字段编辑器里「本位币金额」的三个选择(本位币金额字段、单据日期、汇率字段)在只选了一两个时先留在编辑器里、不写进草稿,下方一行提示还缺哪几个;三个选齐或全部清空时才一次性写入。汇率字段的候选按屏幕上(尚未保存的)单据日期判定。
  • 为什么改:spec 要求三个指针要么全有要么全无,原来每选一个就提交一次,自动保存把半成品发给服务端,连续两次 422「Changes not saved」后第三次才成功;清空时也一样。
  • 风险与回滚:只动 app-shell 的这一个编辑器和两条 i18n 文案,spec 与服务端零改动;编辑一个已完整的本位币金额到另一个完整值时照旧立即保存。回滚即还原本 PR。
  • 先看:CurrencyConfigField.tsx 的 pickHomePointer(何时提交、何时留住)与 ObjectCurrencyConfigField(按字段 key 与 homeCandidatesFor)。
  • 两分钟验证:pnpm --dir ui exec vitest run packages/app-shell/src/views/metadata-admin/inspectors/CurrencyConfigField.recordMode-27188.test.tsx,预期 19 条全绿。
  • 需要你做的:无,席位落地。

What changes

ui/packages/app-shell/src/views/metadata-admin/inspectors/CurrencyConfigField.tsx:

  • The hold. CurrencyConfigField keeps a partial homeAmount (one or two of field, rateDate, rateField set) in its own state, heldHome, and does not call onCommit for it. pickHomePointer applies the pick with the existing setHomeAmountPointer to what is on screen, then commits only when the result has all three pointers or none. The three pickers show the held picks. The hold is stamped with the committed homeAmount it was picked against, so a change to that from elsewhere (a reload, an undo) ends it instead of being overridden by it. A commit from elsewhere in the section (the currency field, the mode) carries the committed homeAmount, never the held one.
  • The hint. While a pick is held, one line under the pickers (data-testid="currency-config-home-amount-held", role="status") says the change is not saved yet and names the pointers still to pick, by their picker labels. It is not the red refusal banner, and it stays until the pick is completed or cleared: nothing auto-reverts. New key designer.field.currency.homeAmountHeld in the studio namespace, en and zh (the only two packs that namespace has).
  • Candidates judged against the held pick. homeAmountCandidates offers a rate field shared with another amount only when that amount uses the same code field and document date, judged from the object's committed definition. With the document date now held, ObjectCurrencyConfigField passes a new optional homeCandidatesFor(home) that judges the candidates against the object with the held homeAmount in place; the existing pin "picking the three pointers writes homeAmount, and the object parses" (pick shared_rate after the date) caught this.
  • One field's hold stays on that field. ObjectCurrencyConfigField renders the editor with key={self}, so a held pick on one amount never shows on the next field the inspector opens. Selecting another field drops the held pick, which the hint said was not saved.

Not changed: packages/spec (CurrencyConfigSchema.homeAmount still takes all three or none), the server, setHomeAmountPointer, homeAmountCandidates, and every host of the editor. No client-side fallback value is written.

Why

  • Measured on origin/main f068cde8 (a throwaway test, not committed, rendering ObjectFieldInspector on a record-mode amount with a live draft, recording each onPatch and parsing the object with ObjectSchema from @objectstack/spec/data, the judge behind the server's 422 INVALID_METADATA). The pick is committed by the onCommit of each homeAmount picker, which called setHomeAmountPointer and committed the result. Readings:
    • pick Home amount field: 1 commit, homeAmount={"field":"amount_home"}, refused at fields.amount.currencyConfig.homeAmount.rateDate and ...homeAmount.rateField ("homeAmount needs rateDate", "needs rateField");
    • pick Document date: 1 commit, refused at ...homeAmount.rateField;
    • pick Rate field: 1 commit, parses.
    • Clearing a complete one: 1 commit refused at ...homeAmount.field, 1 commit refused at ...homeAmount.field and ...homeAmount.rateDate, then 1 commit with no homeAmount, parses.
  • The precedent. The hooks panel holds a CEL error back from its autosave: the inspector reports a blocking count and useDraftAutoSave is blocked while it stands. The order's ruling keeps the partial state local and uncommitted instead, so no draft carries a half-built homeAmount, nothing else in the draft is held back with it, and the page shows no save-blocked line; the hold is the editor's own, as the CEL editor's verdict is.

Tests

CurrencyConfigField.recordMode-27188.test.tsx, new top-level describe "Studio homeAmount editor holds a partial pick back from the draft" (the file is this editor's shared harness; it drives the rendered ObjectFieldInspector through its real Radix selects and spies on onPatch, the commit the autosave sends):

  • the first pick commits nothing, keeps the pick on screen, and names the two pointers still to pick;
  • the second pick commits nothing; the third commits once, with all three, and the object parses;
  • clearing a complete homeAmount holds until the last pointer is cleared, then commits once with none;
  • a commit from elsewhere in the section keeps the held picks and the hint, and sends no partial homeAmount;
  • CONTROL: a complete homeAmount edited to another complete one commits once (green on base too);
  • the fixture parses bare and with a complete homeAmount.
Red on base, green on the fix, ablation red
  • Base f068cde8 (pins only): Tests 4 failed | 15 passed (19), the four hold pins red, CONTROL and fixture green.
  • Fix: CurrencyConfigField.recordMode-27188.test.tsx + CurrencyConfigField.parentPath-31912.test.tsx: Test Files 2 passed (2), Tests 25 passed (25).
  • Ablation (scripts/ablation-replace.mjs, anchor setHeldHome({ against: committedHome, home: next.homeAmount! }); replaced by onCommit(next);, anchor 1 → 0, replacement 0 → 1, blob 63492afeba7e → 79389c3d2790; the test imports the editor from src/, no dist in the path): Tests 4 failed | 15 passed (19), the first pin among them; restored, blob equals HEAD, git diff HEAD empty.

Acceptance notes

  • None.

Verification

All readings on head 8e67a26c unless named.

  • Tests: pnpm --dir ui exec vitest run packages/app-shell/src/views/metadata-admin/inspectors/CurrencyConfigField.recordMode-27188.test.tsx packages/app-shell/src/views/metadata-admin/inspectors/CurrencyConfigField.parentPath-31912.test.tsx: exit 0, Tests 25 passed (25). Every ObjectFieldInspector* test (--maxWorkers=2 packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector): exit 0, Test Files 31 passed (31), Tests 344 passed (344). packages/i18n/ with the two currency files: exit 0, Test Files 104 passed (104), Tests 1919 passed | 13 skipped.
  • Type-check (tsc --noEmit and tsc -p tsconfig.test.json, so the tests compile too): pnpm --filter @object-ui/app-shell run type-check exit 0; pnpm --filter @object-ui/i18n run type-check exit 0 (after pnpm --filter '@object-ui/app-shell^...' build).
  • pnpm exec eslint on the four changed source files (from ui/): exit 0, 0 errors; the react-refresh/only-export-components warnings are the file's existing exports, none added (the new helper is module-private).
  • Derived gates (node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack, 36 families) run in full on 8e67a26c: 36 exit 0, among them pnpm --dir ui exec vitest run scripts/, node scripts/check-sdui-manifest.mjs, node scripts/check-empty-changeset.mjs --base origin/main, pnpm check:test-source-alias, pnpm check:type-check-debt, pnpm check:nul-bytes. --ran: "36 derived famil(ies) accounted for — 36 run, 0 NOT-MEASURED".
  • dispatch-gates --tier: no path-derived mandate; 175 changed lines, under the 3000 threshold; no governed surface.
  • Changeset .changeset/33102-home-amount-autosave-hold.md: @object-ui/console (its dist ships the private @object-ui/app-shell) and @object-ui/i18n (its dist ships the new string), both patch; Clause-②: no, Metadata-protocol: none, measured on the diff: no spec, server or authorable key changed, and the only new prop (homeCandidatesFor) is on a private package's component.
  • CI families are read from this PR's check-runs, not re-run here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FEkQ5o9zCzQRoUJ5gP8r6H

…tor until all three pointers or none are set

The spec takes homeAmount's field, rateDate and rateField together or not at
all, and each pointer pick was committed on its own, so the autosave sent two
configs the server refuses on the way to a correct one. A partial pick now
stays in the editor with one inline hint naming the pointers still to pick,
and the rate field is judged against the held document date.

Claude-Session: https://claude.ai/code/session_01FEkQ5o9zCzQRoUJ5gP8r6H
Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added 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 14, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#2 · os-project-manager · session_01FEkQ5oF8GgTHN2jBZoDwz8

席位核对

Verdict: ACCEPT · head 8e67a26c · 2026-11-15T00:09Z

  1. Shape. Draft → main, Fixes #33102. 5 files, +169/−6:

    • ui/packages/app-shell/src/views/metadata-admin/inspectors/CurrencyConfigField.tsx (the hold, the hint, an optional homeCandidatesFor prop, key={self} on the object wrapper)
    • CurrencyConfigField.recordMode-27188.test.tsx (a new rendered describe)
    • one key, designer.field.currency.homeAmountHeld, in the studio namespace's en and zh catalogues
    • one root changeset (@object-ui/console + @object-ui/i18n patch)

    All of it is on the claimed surface (6885556409).

  2. Premise. Re-measured by the dev on f068cde8, with the rendered inspector and a recorded commit judged by the spec's object schema: pick 1 and pick 2 each committed a homeAmount the spec refuses, and clearing mirrored it.

    • The fix: a partial homeAmount (one or two of the three pointers) stays in the editor's own state and is not committed; the field commits once, when all three or none are set. While partial, one inline status line names the pointers still to pick. ⛔ No schema loosening, no fallback value: the contract (all three or none) is unchanged.
    • The hold is stamped with the committed homeAmount it was picked against, so a change from elsewhere ends it instead of being overridden.
    • The rate-field candidates are judged against the held document date (new optional homeCandidatesFor), which the existing shared-rate pin required.
    • Pins: pick 1 → no commit + hint; pick 2 → no commit; pick 3 → exactly one commit that parses; clear mirror → one commit with none; a commit from elsewhere keeps the hold; CONTROL complete → complete commits once. Base: 4 red, 15 green. Ablation of the hold: the first pin red.
  3. Declarations. Clause-②: no, Metadata-protocol: none, patch. The seat agrees with no: the studio namespace catalogues are typed Record<string, string> and ship en and zh only by design (the namespace's own header), so the added key changes no published type; CurrencyConfigField and its new optional prop live in the private @object-ui/app-shell. No contract record is owed.

  4. Gates on head 8e67a26c.

    • All 58 check runs are success or skipped.
    • The dev's local --ran is 36/36, 0 NOT-MEASURED; app-shell and i18n type-checks exit 0.
  5. Accepted deviations.

    • Selecting another field in the inspector drops a held partial pick. The hint says "not saved" while it stands, and nothing auto-reverts while the field is open, as ordered.
    • The 422 was read through the spec's object schema on each recorded commit rather than a live server; the card's own repro names the same refusals.
    • Nit (no change asked): the hint substitutes {missing} with .replace() rather than the designer's tFormat().
  6. K. 4 first-parent commits since base f068cde8 < 15: no base sync.

  7. Path face. Not governed (no .claude/**, skills/**, docs/adr/**, workflow or rules path); 175 changed lines.

  8. Out of scope. None.

  9. Authority. Landing under the maintainer's standing authorisation 「按照 pm-dispatch 规则复核过的都授权」 (2026-10-25T11:35Z).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 15, 2026 00:09
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit 4c32b96 Nov 15, 2026
59 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-gnzubb branch November 15, 2026 03:33
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.

Studio's Home currency amount editor autosaves each pointer on its own, so a correct three-step edit shows "Changes not saved" twice

1 participant