Repository navigation
fix(console): Studio's home currency amount editor holds a partial pick instead of autosaving it - #33530
Conversation
…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>
Claude-Session: https://claude.ai/code/session_01FEkQ5o9zCzQRoUJ5gP8r6H Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5o9zCzQRoUJ5gP8r6H Co-Authored-By: Claude <noreply@anthropic.com>
|
domain:ui#2 · os-project-manager · session_01FEkQ5oF8GgTHN2jBZoDwz8 席位核对Verdict: ACCEPT · head
|
Requested by Leehom · project thread
domain:ui#2 · os-project-manager · session_01FEkQ5o9zCzQRoUJ5gP8r6H
Fixes #33102
Clause-②: no
Metadata-protocol: none
维护者速读
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:CurrencyConfigFieldkeeps a partialhomeAmount(one or two offield,rateDate,rateFieldset) in its own state,heldHome, and does not callonCommitfor it.pickHomePointerapplies the pick with the existingsetHomeAmountPointerto 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 committedhomeAmountit 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 committedhomeAmount, never the held one.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 keydesigner.field.currency.homeAmountHeldin the studio namespace,enandzh(the only two packs that namespace has).homeAmountCandidatesoffers 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,ObjectCurrencyConfigFieldpasses a new optionalhomeCandidatesFor(home)that judges the candidates against the object with the heldhomeAmountin place; the existing pin "picking the three pointers writes homeAmount, and the object parses" (pickshared_rateafter the date) caught this.ObjectCurrencyConfigFieldrenders the editor withkey={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.homeAmountstill takes all three or none), the server,setHomeAmountPointer,homeAmountCandidates, and every host of the editor. No client-side fallback value is written.Why
origin/mainf068cde8(a throwaway test, not committed, renderingObjectFieldInspectoron a record-modeamountwith a live draft, recording eachonPatchand parsing the object withObjectSchemafrom@objectstack/spec/data, the judge behind the server's422 INVALID_METADATA). The pick is committed by theonCommitof eachhomeAmountpicker, which calledsetHomeAmountPointerand committed the result. Readings:homeAmount={"field":"amount_home"}, refused atfields.amount.currencyConfig.homeAmount.rateDateand...homeAmount.rateField("homeAmountneedsrateDate", "needsrateField");...homeAmount.rateField;...homeAmount.field, 1 commit refused at...homeAmount.fieldand...homeAmount.rateDate, then 1 commit with nohomeAmount, parses.useDraftAutoSaveis blocked while it stands. The order's ruling keeps the partial state local and uncommitted instead, so no draft carries a half-builthomeAmount, 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-leveldescribe"Studio homeAmount editor holds a partial pick back from the draft" (the file is this editor's shared harness; it drives the renderedObjectFieldInspectorthrough its real Radix selects and spies ononPatch, the commit the autosave sends):homeAmountholds until the last pointer is cleared, then commits once with none;homeAmount;homeAmountedited to another complete one commits once (green on base too);homeAmount.Red on base, green on the fix, ablation red
f068cde8(pins only):Tests 4 failed | 15 passed (19), the four hold pins red, CONTROL and fixture green.CurrencyConfigField.recordMode-27188.test.tsx+CurrencyConfigField.parentPath-31912.test.tsx:Test Files 2 passed (2),Tests 25 passed (25).scripts/ablation-replace.mjs, anchorsetHeldHome({ against: committedHome, home: next.homeAmount! });replaced byonCommit(next);, anchor 1 → 0, replacement 0 → 1, blob63492afeba7e→79389c3d2790; the test imports the editor fromsrc/, no dist in the path):Tests 4 failed | 15 passed (19), the first pin among them; restored, blob equals HEAD,git diff HEADempty.Acceptance notes
Verification
All readings on head
8e67a26cunless named.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). EveryObjectFieldInspector*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.tsc --noEmitandtsc -p tsconfig.test.json, so the tests compile too):pnpm --filter @object-ui/app-shell run type-checkexit 0;pnpm --filter @object-ui/i18n run type-checkexit 0 (afterpnpm --filter '@object-ui/app-shell^...' build).pnpm exec eslinton the four changed source files (fromui/): exit 0, 0 errors; thereact-refresh/only-export-componentswarnings are the file's existing exports, none added (the new helper is module-private).node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack, 36 families) run in full on8e67a26c: 36 exit 0, among thempnpm --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/33102-home-amount-autosave-hold.md:@object-ui/console(its dist ships the private@object-ui/app-shell) and@object-ui/i18n(itsdistships the new string), bothpatch;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.🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5o9zCzQRoUJ5gP8r6H