Skip to content

fix(fields): a pick says why it kept a filled amount, the opening fill stops waiting on an unreadable parent, and a code-plus-amount pick copies both - #36918

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-36412-cross-currency-pick-followups
Nov 24, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-36412-cross-currency-pick-followups

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

repo:objectstack#3 · os-support-ai · session_01WGufzhoBbwh8URjwQHde8v

Refs #36412
Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户可见变化:选产品时,若价格栏已有数值且币种不同,原值保留并在下方说明;新建明细时上级币种读不到也不再一直卡住,描述照常带出、单价留空并说明;产品自带币种和价格一起带出时,两者都会填上。
  • 为什么做:这是「选产品不跨币种抄价格」那张卡留下的四个后续问题,替多币种发票的使用者补齐提示和漏填。
  • 出错会怎样:只影响选取关联记录时自动带出的金额和提示文字,已填的数值不会被改动;可以直接撤回这一个合并。
  • 要你做什么:无(「改币种后保留金额并提示」那一项未在本次实现,交席位安排后续)。

What changes

Items 1–4 of the card and To-do 5. The ruling item (comment 7118795825) is not built here: see "Ruling item" below.

  • Item 1, a re-pick over a filled cell says why (closed: behaviour route, no describe narrowed). A withheld value now records held, the value its target held at the pick. The note shows while the target still holds that value (empty, or the earlier value a re-pick or an overwrite: true pair left in place: withheldStillStands), on the grid and on the record face, and ends "Unit Price still holds its earlier value." Editing the target ends the note.
  • Item 2, the opening fill's wait is bounded (closed). useFollowedParentRead (followedParentRow.ts) reports where the parent read stands: none, pending, read, or unread (the read failed or answered no row, the source has no findOne, or no parent object is stamped). LookupField waits only while it is pending. An unread parent puts a following amount in the new AmountCurrency kind unread: it is withheld with the reason targetCurrencyUnread ("the currency here could not be read"), and every target that does not depend on currency (the description) fills.
  • Item 3, every record-form host is stamped (closed by measurement plus a pin). Measured on 7a5ae65e54e: the only writer of onAutofill is the form renderer, and every record-form layout draws through gateFormFields → stampRecordFormFields: ObjectForm simple and sectioned arms, DrawerForm, ModalForm, TabbedForm, WizardForm, and the forms drawn through ObjectForm (MasterDetailForm header and line form, EmbeddableForm). The record page's body tables (RecordBodyTableEditor) are a line-item grid and judge their own picks; the record page's own field editing hands no onAutofill, so it fills nothing. No host needed a change; the recordFormStamp.ts header now lists the hosts and names the one that keeps the old behaviour: a standalone form node (the @object-ui/components form renderer outside these hosts), which holds no object field map.
  • Item 4, an amount is judged with this pick's own code write applied (closed). planDeclaredLookupAutofill and the grid's planLookupAutofill now collect every value a pick would write (declaredPickWrites, the same-named copy) and judge them together (judgePickWrites): targetCurrency is handed the pick's writes, and amountCurrencyOf's new third argument lays a write to the amount's own code field on the record before resolving. A parent path is not overlaid (a parent's code is not the record's to write). Pinned through the grid and through ObjectForm.
  • i18n: two sentences, lookup.autofillCurrencyUnread and lookup.autofillKept, in all 11 packs (zh-Hant generated) and in FIELD_DEFAULTS.
  • One changeset: @object-ui/fields, @object-ui/i18n, @object-ui/plugin-form (the last for the comment in recordFormStamp.ts), all patch.

Ruling item (not built here)

Not built, so this PR carries Refs #36412 and leaves the card open. Two reasons. First, size: items 1–4 already change 714 lines, and the ruling item needs a copied-under record and a per-render re-judgement on both hosts plus a sentence in 11 packs and its pins, which puts the total past the 900-line bound. Second, one visible case the ruling does not settle: a withheld note refreshed to a new record currency that equals the picked amount's own currency (the reason no longer holds, and the target is still empty) could drop the note, keep the old wording, or say something new. Follow-up: none filed; the seat decides.

Tests

Tests on head 12d8d3bb3bd: pnpm --dir ui exec vitest run --maxWorkers=2 packages/fields/ packages/plugin-form/ packages/i18n/ (Test Files 682 passed, 1 skipped; Tests 9796 passed, 21 skipped); type-check of @object-ui/fields, @object-ui/plugin-form, @object-ui/i18n exit 0.

New pins and ablations
  • GridField.lookupAutofill-28245.test.tsx, describe "(objectstack#36412)", 8 tests: amountCurrencyOf reads the pick's code write, not a parent's; the same-named copy and declared pairs copy a code and the price in it onto a fresh line (control: a grid drawing no code column withholds the price; a code the record holds is kept and judges the price); a withheld value over a filled target carries held (control: over an empty one it does not); through the grid, a fresh line fills code and price with no note (control: no code column, "no currency is chosen"), a pick over a filled JPY cell keeps 80 and says so until the cell is edited (control: an empty cell's note has no kept sentence).
  • ObjectForm.lookupAutofill-28245.test.tsx, describe "(objectstack#36412)", 13 tests: an overwrite: true pick over a filled JPY price keeps it and says so (control: a EUR quote replaces it, no note); a code-plus-price pick fills both on a quote with no code (control: a pick without the code pair says no currency is chosen); the opening fill does not wait on a failed parent read or a source with no findOne, fills the description and says the currency could not be read (control: an answering read fills the price); each of six layouts (simple flat, simple sections, drawer, modal, tabbed, wizard) withholds a EUR price from a JPY quote and fills a EUR one.
  • Ablations on the committed tree, scripts/ablation-replace.mjs, vitest aliasing @object-ui/* to src (no dist between mutation and run), each restored to the HEAD blob with git diff HEAD empty:
    • item 4, lookupAutofill.ts anchor const refused = judgeCopy(currency, c, writes); x1 to x0 (writes not handed): Tests 4 failed, 56 passed (60); restored blob faf38ecb05a9.
    • item 2, LookupField.tsx anchor const followedParentPending = followedParentState === 'pending'; x1 to x0 (an unread parent waits again): Tests 2 failed, 26 passed (28); restored blob 4717859dc284.
    • item 1, withheldStillStands reduced to "the target is empty": Tests 2 failed, 58 passed (60); restored blob faf38ecb05a9.

Acceptance notes

  • N9 (record-page editor re-renders): not measured. This diff adds no work per render there; the new work runs once per pick.
  • Addendum 7088192432 is kept as it is: a record that names no parent and holds no code still gets "no currency is chosen here yet".
  • A standalone form node with a lookup carrying lookupAutofill in its field carrier still copies across currencies. Making it judge needs a change in @object-ui/components (outside this card's surface) or narrowing the FieldSchema.lookupAutofill describe in packages/spec; neither is done here, and it is reported to the seat.
  • followedParentRow.ts: a failed read now records an answer with no row instead of clearing the answer. The amount box (CurrencyField) reads the same record either way.

Verification

Gates
  • dispatch-gates --commands derived 41 commands at 12d8d3bb3bd; 40 ran with exit 0; pnpm --dir ui exec vitest run scripts/ is NOT MEASURED (SIGKILL beside the package suite, then exit 124 at the 590 s limit under the lock; its closure-budget case needs a console build) and is left to CI. dispatch-gates --ran: 41 derived, 40 run, 1 NOT-MEASURED, 0 UNRUN.
  • ui check:new-line-citations: 0 new citations, exit 0.
  • overlap-check before every push: VERDICT clean exit 0.

Read first, by risk: (1) judgePickWrites and withCodeWrite in lookupAutofill.ts; (2) useFollowedParentRead in followedParentRow.ts and its use in LookupField.tsx; (3) withheldStillStands at the two note sites.

Two-minute check: pnpm --dir ui exec vitest run packages/plugin-form/src/ObjectForm.lookupAutofill-28245.test.tsx -t 36412 passes 13 tests; in it, a quote with no code picks a EUR product and holds EUR and 100.

https://claude.ai/code/session_01WGufzhoBbwh8URjwQHde8v

🤖 Generated with Claude Code

…ait, code-plus-amount pick

Claude-Session: https://claude.ai/code/session_01WGufzhoBbwh8URjwQHde8v
Co-Authored-By: Claude <noreply@anthropic.com>
…ugh the grid and every record-form host

Claude-Session: https://claude.ai/code/session_01WGufzhoBbwh8URjwQHde8v
Co-Authored-By: Claude <noreply@anthropic.com>
…changeset for the cross-currency pick follow-ups

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzesUz1Y8VZuKJRhVL8

席位核对 — ACCEPT · repo:objectstack#3 · head 12d8d3b · 2026-11-24T09:10Z

L1-a read of #36918 (card #36412) at 12d8d3bb3bd66b741d2f0b0e7fc93ff63ea942ae.

Mechanical.

Relation. Refs #36412 is right. Items 1–4 are delivered here, but the ruling item 7118795825 (「保留金额并提示」: a note beside a pick-copied amount after the currency changes) is not built. The card stays open for it, as the ruling allows (Refs #36412 follow-up).

Read, item by item.

  • Item 1. declaredPickWrites keeps the overwrite rule unchanged and records each target's held. judgeCopy carries held onto a withheld value. Both hosts now filter the note through withheldStillStands: empty when nothing was held, otherwise equal to the kept value. The note therefore stands over a re-pick's earlier price until someone writes the cell, and autofillKept names what was kept. The grid passes row on every pick (GridFieldWidget.tsx:977), so a same-named copy carries held too. Pinned in the grid and in ObjectForm, each with a control.
  • Item 2. useFollowedParentRead returns none / pending / read / unread. A rejected read, a read that answers no row, a source without findOne, and a form with no stamped parent object all end at unread. Before, a rejected read set the answer back to undefined and the wait never ended. followedParentPending is now pending alone. With unread, currencyFor answers {kind:'unread'} only for a target that follows a parent, so the description fills and the amount is withheld with targetCurrencyUnread. Pinned for the failed read and for no findOne, with an answering-read control.
  • Item 3. Closed by listing the hosts, which the card allows as an alternative ("or list the hosts that keep the old behaviour"). I checked the host list in recordFormStamp.ts against the layout pin every record-form host judges the pick: ${layout}. The standalone form node is named as the one host left on the old behaviour.
  • Item 4. judgePickWrites collects every write of one pick first, then judges each amount with amountCurrencyOf(def, record, writes). withCodeWrite applies the pick's write only to the amount's own code field, never to a parent path. In the grid, a header-driven columnCurrencies code also ignores the writes, correctly, because the header's code is not the line's to write. Pinned in the unit, in the grid and in ObjectForm, each with a control.
  • Changeset. Each sentence holds against the tree, including the new exports (declaredPickWrites, judgePickWrites, withheldStillStands, PickWrite), the unread kind, held, and the two lookup.* sentences in all 11 packs. @object-ui/plugin-form is named for a documentation-only change, and the changeset says that is all it is.

Nits (no action required):

  • N1. unread has four arms: a rejected read, a read that answers no row, no findOne, and no stamped parent object. The pins cover the first and third. The other two reach the same return, so the risk is low. A one-line case for "no parent object" would close the set.
  • N2. The standalone form node in @object-ui/components still copies across currencies. This is disclosed and the area is routing it to the seat. It needs a card of its own (the seat files it), since this card closes on the ruling item.
  • N3. withheldStillStands compares with sameValue, so retyping the identical earlier value keeps the note. This is cosmetic.

Every open finding is a nit, so ACCEPT. On landing, #36412 stays open for ruling 7118795825.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzhoBbwh8URjwQHde8v

Landing · 2026-11-24T09:11Z · area ux-B · head 12d8d3bb3bd66b741d2f0b0e7fc93ff63ea942ae

  • L1: ACCEPT 7127057550 (L1-a, on this head). Only optional nits remain: N1, the "no parent object" and "answered no row" arms of unread have no pin of their own; N2, the standalone form node gets its own card (sent to triage, mailbox pm:mailbox — triage#1 · os-warren #36743 comment 7127028135); N3, cosmetic. None has a user-visible defect.
  • Refs #36412: the card stays open for ruling item 7118795825, which is not built here.
  • Contract review: none owed (Clause-② no, Metadata-protocol none).
  • check-governed-merges.mjs --pr 36918: NOT governed, 714 changed lines. Card total (this is its only PR) is 714, under the per-card 3,000-line line.
  • landing-k.mjs --pr 36918: CAN'T ANSWER on this UI-only PR (no Test Core shard ran). Merge-base reading: 8 commits behind main, under 15.
  • Checks on this head: 45 success / 13 skipped / 0 failing; mergeable_state clean.
  • Action: ready for review + auto-merge through the merge queue.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 24, 2026 09:11
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 4f19091 Nov 24, 2026
59 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-36412-cross-currency-pick-followups branch November 24, 2026 09:32
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…ld is not run (objectstack-ai#37090)

Fixes objectstack-ai#36923

Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — every page that teaches `lookupAutofill` teaches it
as a key on the object's lookup field, read by the record form and the
line-item grid, and none teaches it on a standalone form node, so
nothing it says became false (git grep -i lookupAutofill over skills/
and content/docs/ at 47d5f69:
skills/objectstack-data/rules/field-types.md and relationships.md,
skills/objectstack-ui/rules/actions.md and one eval in
views-apps-actions-pages.json; content/docs/data-modeling/fields.mdx,
the generated references, and two release pages)
Ruling-ref: 7138010812 on objectstack-ai#36923, the maintainer, verbatim: 「同意 拒收(推荐)」

## 维护者速读

-
用户能看到什么变化:在独立表单(不属于某个对象的记录表单)里,查找字段上手写的自动带值不再执行,选中记录后其它字段保持不变;记录表单和明细行表格照旧带值,币种保护不变。
- 为什么做:独立表单上的自动带值没有币种保护,可能把一种货币的金额静默填进另一种货币的字段;按你的裁决改为拒收。
- 出错会怎样:如果判断错了,记录表单里的自动带值会失效(测试已钉住它仍然生效);改动只在界面层,撤回本次合并即可恢复。
- 要你做什么:批准合并(本次声明为收窄改动,需维护者批准)

## What changes

Per the ruling on objectstack-ai#36923 (comment 7138010812): a `lookupAutofill`
written by hand on a field of a standalone `form` node is not run. The
pick still sets the lookup, but it copies nothing into other fields.
Record forms and line-item grid columns keep the behaviour objectstack-ai#36918
shipped, the cross-currency rule included.

- **How the widget tells a record form apart.** `LookupField` runs the
declared pairs only on a lookup that carries the record form's stamp
(`withLookupAutofillTargets`, applied by `stampRecordFormFields` in
`gateFormFields`, the one step every record-form layout draws its fields
through). No new public export, prop or context, and no new dependency
edge.
- **The stamp is now complete.** Before, the record form stamped a
lookup only when its field map named at least one target, so a missing
stamp did not prove the host was not a record form. Now every lookup
that declares pairs gets the stamp. The map is empty when the field map
names none of the targets: the schema has not loaded, the form has no
metadata source, or the target is not an object field. An empty map
judges no currency, so those picks copy exactly as before.
- **Only an issued stamp counts.** The stamp map is registered in a
module-private `WeakSet` when it is issued, which is the pattern
`withRecordBeingEdited` already uses. A `lookupAutofillTargets` key
written as data on a loose form field is not a stamp.
- **The refusal is visible.** A development build (the guard
`globalThis.process?.env?.NODE_ENV !== 'production'`, the spelling
`lookupRecordReference.ts` already ships) warns once per field, names
the field, and says where the key is honoured.
- **Census and describe.** The form-field census row for
`lookupAutofill` now says the key is honoured only in record forms and
grid columns. The spec describe (`FieldSchema.lookupAutofill`, "Read
wherever this field is picked: the record form, and a line-item grid
column over it") already says this, so `packages/spec` is not touched.
- **Reach.** `lookupAutofill` has 0 non-test hits under `examples/` and
`ui/examples/` at 6c1dfb3. The first dev report on the card measured
HotCRM: 0 `type: 'form'` nodes.

## Breaking: two published surfaces narrow

The seat ruled on 2026-11-24 that this is a narrowing. The changeset
carries two BREAKING banners and the ADR-0087 disposition `not-required
(no-migration-prescription)`.

**The widest one is the `lookup` / `master_detail` widget
(`LookupField`) handed `onAutofill`.**

- FROM: a single-value pick, and the opening fill of a create form that
opened with the lookup set, filled the declared targets whenever the
host handed `onAutofill` (and no `onSelectRecord`) and the field carried
`lookupAutofill` pairs.
- TO: it also needs the stamp `withLookupAutofillTargets` issues, which
the record form applies to every field it draws. A host that hands
`onAutofill` without that stamp sets the lookup and fills nothing, on a
pick and on the opening fill alike. A standalone `form` node is one such
host.
- Fix: stamp the field through `withLookupAutofillTargets(field,
objectFields)` before handing it to the widget, passing the object's
field map as the record form does. With no map the stamp names no
target, so the pick copies without the cross-currency rule, which is the
copy this change stops. Or declare `lookupAutofill` on the object field
and draw the object's record form.
- The published prop doc `FieldWidgetProps.onAutofill`
(`widgets/types.ts`) now names the stamp. The same sentence in
`plugin-grid`'s `relationalMetaKeys.ts` `lookupAutofill` note is
corrected too.

**`readLookupAutofillTargets`** is a published export of
`@object-ui/fields` (re-exported through `export *`). It no longer
returns a target map it used to return.

- FROM: `readLookupAutofillTargets(field)` returned any non-array object
found under the field's `lookupAutofillTargets` key.
- TO: it returns only the map `withLookupAutofillTargets` stamped, which
is what the record form does. A same-name key written by hand reads
`undefined`. `withLookupAutofillTargets` now also stamps a lookup whose
pairs name no field of the map it is given, with an empty map. The map
is frozen, and a field with pairs always comes back as a copy.
- Fix: stamp the field through `withLookupAutofillTargets`, as the
record form does. If you need the raw value, read
`field.lookupAutofillTargets` directly.

**What the marker rests on.** The changeset body carries a code-level
prescription: the FROM, TO and Fix lines, written without an arrow. So
the gate admits `no-migration-prescription` on a detector miss, not on a
checked fact. No fact-based category covers a runtime function whose
behaviour narrows: `runtime-interface-only` reads exported types, and
`runtime-export-retired` reads an export that is gone. The vocabulary
gap is objectstack-ai#37136. The marker's own reason says this.

## Fix round 1

CI `Test UI (2/16)` was red at 6c1dfb3 because of this PR.
`relationalMetaCopySet.derivation.test.ts` found that LookupField's dev
warning read `name` off the field meta, a read that
`RELATIONAL_META_READ_SET` does not classify for `lookup-editor`. The
warning now takes the field name from the props or the form entry
(`props.name || lookupField?.name`), which is the same read the
trigger's test id already makes. So the table needs no new row and the
derivation test is unchanged.

## Fix round 2

- `origin/main` merged in at 952484e (37 commits; clean). Scoped
re-checks followed: the seven @objectstack builds, `@objectstack/spec
check:generated` (spec moved on main), and type-check and tests for
`fields`, `plugin-form`, `plugin-grid` and the schema catalog. `fields`
and `plugin-grid` also moved on main.
- S1: `FieldWidgetProps.onAutofill` names the stamp, the changeset adds
a BREAKING banner for `LookupField` with `onAutofill`, and the
`relationalMetaKeys.ts` note is corrected.
- S2: the marker's reason now says what it rests on, and names objectstack-ai#37136.
- The ablations were re-run at 47d5f69 (below).

## Tests

New file
`ui/packages/plugin-form/src/__tests__/lookupAutofillStandaloneForm-36923.test.tsx`,
8 cases:
- bare `form` node: a pick copies nothing, and the dev warning fires
once, naming the field, across two picks; a production build copies
nothing and warns nothing; a hand-written `lookupAutofillTargets` does
not opt the field in;
- stamp unit pins: stamped with no field map or with a map that names no
target; a field without pairs is not stamped; the key written as data
reads as no stamp;
- record form (`ObjectForm`): a USD quote fills the price and
description with no note and no warning; a EUR quote fills the
description and withholds the price with the note;
- grid column (`GridField`, `planLookupAutofill` path): a cell pick
fills the declared target.

<details><summary>Ablations at 47d5f69 (vitest resolves @object-ui/* to
src through the ui alias map, so no dist leg)</summary>

Each was run through `node scripts/ablation-replace.mjs` under the
verify lock. The mutation is verified on disk (anchor count 1 to 0, blob
changed) and the restore is verified (blob equal to HEAD, `git diff
HEAD` empty). After all three, `git diff HEAD` is empty.

1. LookupField gate removed (`autofillPairs = declaredPairs`): 3 failed,
5 passed. The three standalone pins fail with `expected '100' to be ''`
(twice) and `expected 'A widget' to be ''`. The record-form, grid and
unit pins stay green. Blob 1b68e764, restored to 01485ca.
2. Issued check removed from `readLookupAutofillTargets`: 2 failed, 6
passed. The forged-stamp pin fails with `expected '100' to be ''`, and
the data-key unit pin fails with `expected {} to be undefined`. Restored
to 83b9b5b.
3. Empty-stamp change reverted (no stamp without a target): 1 failed, 7
passed. The stamp unit pin fails with `expected undefined to deeply
equal {}`. Restored to 83b9b5b.
</details>

## Acceptance notes

- The record form now stamps an empty `lookupAutofillTargets` on a
lookup whose pairs name no field of the map. It used to leave such a
lookup unstamped. The empty map carries no currency context, so the copy
and the opening-fill timing are unchanged there.
- `readLookupAutofillTargets` (exported) now answers only for a stamp
`withLookupAutofillTargets` issued. Its only in-tree reader is
`LookupField`.
- `withLookupAutofillTargets` now freezes the map it stamps, and a field
with pairs always comes back as a copy, even with no target. No in-tree
caller writes to the map or compares the return to its argument.
- The stamp rests on module identity, through a module-private
`WeakSet`. If a page ever loads two instances of `@object-ui/fields` (it
ships both `dist/index.js` and `dist/index.cjs`), a stamp issued by one
is no stamp to the `LookupField` of the other. Record-form autofill
would then stop, with only the development warning to say so.
`withRecordBeingEdited` already carries the same exposure on main, so
this is a recorded cost, not a new class.
- The production guard was measured. The console's Vite (8.3.5), with
the console's `define` block (`'process.env': {}`, `process.platform`,
`process.version`), was run on a probe entry. An app build rewrites
`globalThis.process?.env?.NODE_ENV` the same way it rewrites
`process.env.NODE_ENV`: `--mode production` folds both to the production
branch, and `--mode development` folds both to the development branch.
So the warning is dead code in the console's production bundle, and the
spelling stays as `lookupRecordReference.ts` ships it. A library-mode
build rewrites neither spelling, which leaves both to the consuming
app's bundler.
- The `recordFormStamp.ts` header said a standalone node's lookup
"copies as it always did". That comment was made false by this change,
so it is corrected.

## Verification

Read first, by risk:
1. `ui/packages/fields/src/widgets/LookupField.tsx`, the `declaredPairs`
/ `autofillTargets` / `currencyTargets` hunk: the gate, plus the
currency context kept off for an empty stamp.
2. `ui/packages/fields/src/widgets/lookupAutofill.ts`,
`withLookupAutofillTargets` / `readLookupAutofillTargets`: always stamp,
issued-only read.
3. `ui/packages/plugin-form/src/recordFormStamp.ts`: header only.

Two-minute check: `cd ui && pnpm exec vitest run
packages/plugin-form/src/__tests__/lookupAutofillStandaloneForm-36923.test.tsx`.
Expected result: 8 passed.

<details><summary>Local readings at 47d5f69</summary>

- Gate families: `dispatch-gates --commands` derived 38, and all 38 exit
0. `check:type-check-debt` was rerun under the verify lock, exit 0,
after its first run missed the lock. `--ran` reconciles them: 38
derived, 38 run, 0 NOT-MEASURED, 0 UNRUN.
- Changeset gates: `check:adr-0087-registration` exit 0
(`[BREAKING+clause-②-narrowing] not-required
(no-migration-prescription)`), `check-empty-changeset` exit 0,
`check-changeset-no-major` exit 0.
- `@objectstack/spec check:generated` (spec moved on main): exit 0. The
seven @objectstack builds, run as Test UI runs them: exit 0.
- `turbo run type-check` on @object-ui/fields, @object-ui/plugin-form,
@object-ui/plugin-grid and @object-ui/example-schema-catalog: 72/72
successful.
- vitest results:
- `packages/fields/`: 329 files passed, 1 skipped; 5016 tests passed, 7
skipped.
- `packages/plugin-form/ examples/schema-catalog/`: 291 files passed;
5227 tests passed, 1 skipped.
  - `packages/plugin-grid/`: 312 files and 2769 tests passed.
- `pnpm --dir ui exec vitest run scripts/`: 172 files passed, 2 skipped.
- Dogfood battery: `pnpm --filter @objectstack/dogfood test` under the
lock, after its closure build, gave VERDICT command-exit 0. Test Files:
487 passed, 3 skipped. Tests: 4128 passed, 68 skipped. No failures.
- overlap-check: VERDICT clean exit 0.
- CI at 47d5f69: 44 success, 13 skipped, 0 failed.
</details>

---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D)_

<!-- signed: repo:objectstack#4 · os-justin ·
session_01QSeKYmRepQK9DkZeU7F53D -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
… and their notes follow the new currency (objectstack-ai#37284)

repo:objectstack#4 · os-justin · session_01QSeKYnagJvGbCtNg2PhvgW

Fixes objectstack-ai#36412

Clause-②: yes (widening)
Metadata-protocol: none

## 维护者速读

-
用户可见变化:在报价、订单、发票里选产品带出价格后,如果在同一次编辑中改了币种,价格不会被改动或清空,下方会说明这笔价格是按哪个币种带入的、记录现在是哪个币种;没带入的价格提示会跟着换成新币种;改成与产品价格相同的币种时,提示保留、价格仍空,并提示重新选取即可带入。
- 为什么做:这是「选产品不跨币种抄价格」那张卡里最后一项(「保留金额并提示」及其 B 方案),替多币种单据的使用者补上改币种后的说明。
- 出错会怎样:只影响价格下方的提示文字,不写入、不清除任何金额;手动输入的金额不显示提示;可以直接撤回这一个合并。
- 要你做什么:无。

## What changes

The ruling item on this card (comment 7118795825, 「保留金额并提示」) and its
branch B (comment 7158109013), on both hosts: the line-item grid
(`GridFieldWidget`) and the record form (`LookupField` with the declared
pairs). Scope is bounded by ADR-0144 D2: new records, records with no
saved lines, lines staged in the same edit, and declared pairs on the
record's own amounts. Items 1–4 landed in objectstack-ai#36918. With this PR the
card's last open item is done.

- **Point 1: a currency change in the same edit never changes or clears
a filled amount.** Measured first. This already holds on `main`
(`057cedfa9b6`): nothing writes an amount when the code changes. The new
pins were run against main's source files, and every amount assertion
passed there; the only failures were the note lines that come after them
(see Tests). Pinned either way, on both hosts. This PR adds no write.
- **Point 2: an amount a pick copied gets a note once the currencies
differ.** `judgePickWrites` now records each amount it copies as
`CopiedAutofill` (`target`, `source`, `value`, `under`: the code the
target was in at the write). The plan gains the optional `copied`,
absent when there is none. Each host keeps these beside the withheld
values of the same pick. When drawing, it shows "Unit Price was copied
as $100.00, but the record is now in EUR. Enter Unit Price in EUR if it
should change." only when all of these hold (`copiedAutofillNow`): the
field still holds that pick, the target still holds the copied value,
and the code the target is in now is known and differs from `under`. A
currency change back ends the note.
- **Point 3: a withheld note already shown refreshes to the record's new
currency.** `withheldAutofillNow` judges each shown withheld item again
with `crossCurrencyRefusal`, using the picked amount's own currency (its
`from`) against the target's currency as it is now. The note follows the
new code, and its reason too: a code cleared reads "no currency is
chosen".
- **Point 4: a hand-typed amount gets no note.** Only a pick records a
copied amount, and the note needs the target to still hold the copied
value. So an amount typed by hand, or typed over a copied one, says
nothing.
- **Branch B.** When the record's currency turns to the picked amount's
own, the re-judgement copies nothing. The item takes the new reason
`nowSameCurrency`, the note stays and the cell stays empty: "Unit Price
was not filled when it was picked. The record is now in USD: pick again
to fill $100.00." A pick again fills it (pinned as the control on the
record form). When the target still holds an earlier value (`held`), the
sentence says to clear the field, then pick again
(`lookup.autofillNowSameCurrencyHeld`, round 3).
- "Now" on each host is the same context the pick used, with no picked
row. On the grid that is `gridAutofillCurrency` on the current line,
with `columnCurrencies` (a header-following line) or `columnFields` (the
line's own code). On the record form it is `currencyFor` on the live
record, followed parent included. So a code written later in the edit is
read exactly as a pick would read it.
- i18n: three sentences, `lookup.autofillNowSameCurrency`,
`lookup.autofillNowSameCurrencyHeld` and `lookup.autofillCopiedUnder`,
in all 11 packs (zh-Hant generated by `gen:zh-hant`) and in
`FIELD_DEFAULTS`.
- One changeset, `.changeset/36412-currency-change-notes.md`:
`@object-ui/fields` and `@object-ui/i18n`, both `patch`. The objectstack-ai#36918
changeset is left untouched. `@object-ui/plugin-form` changes in its
test file only, which is not published.

## Clause-② rework: route (a), `copied` optional

At the seat's rework the first declaration, `Clause-②: no`, did not
hold. Route (a) is taken; no route (b), nothing here needs `copied` to
be required. `LookupAutofillPlan.copied` is now optional (`copied?:
CopiedAutofill[]`). `judgePickWrites` leaves it out when the pick copied
no amount under a judged currency, and every in-package reader treats
absent as none (`LookupField`'s two `noteWithheld` calls,
`GridFieldWidget`'s pick, `planLookupAutofill`'s pass-through). A plan
built without `copied` is still a plan, so nothing is narrowed. The
published `@object-ui/fields` surface widens:
- new exports `withheldAutofillNow`, `copiedAutofillNow`,
`copiedAutofillMessage` and the type `CopiedAutofill`;
- the optional member `LookupAutofillPlan.copied`;
- the `WithheldAutofill.reason` union gains `nowSameCurrency`, so code
that switches over every reason gains one case.

The same declaration is in the changeset. `Metadata-protocol: none`
stands: no spec key, value or metadata type changes. A pin asserts that
a plan which copied no amount carries no `copied`.

## Tests

Round 3 (the seat's S1, N1, N2 and N4), all under `os-verify-lock`:
- Both pin files at `dd0ebf7f96`: Tests 71 passed (71). Two new pins
hold the held branch B case on each host (grid: header USD over a line
holding 80, then EUR; form: an `overwrite: true` pair over a typed 80 on
a EUR quote, then USD). Each asserts the exact clear-then-pick-again
sentence and that the earlier value stays. The grid branch B pin now
ends with the N4 control: a pick again fills 100 and no note remains.
- Ablation: the held arm in `withheldAutofillMessage` is deleted
(`ablation-replace --delete`, restored to the HEAD blob `848e5fd1844c`).
Tests 2 failed, 9 passed: exactly the two held pins fail. The non-held
branch B pins on both hosts stay green, so their wording is unchanged.
- The three-package run at `dd0ebf7f96` failed one test,
`all-locales-key-parity` "placeholders match en in every pack": the
first zh-Hans text of the new key named `{{field}}` three times against
en's two, and zh-Hant was generated from it. Fixed in `315c0d8fef`. At
that head, `packages/i18n/` gives Test Files 111 passed, Tests 2028
passed, 13 skipped. Only locale strings changed between the two heads;
fields and plugin-form were green at `dd0ebf7f96` (685 of 687 files
passed, 1 skipped, and the one failure was that i18n test). `type-check`
of the three packages exits 0 at `315c0d8fef`.

Round 2 (the Clause-② rework), head `a602513471`, all under
`os-verify-lock`: the same three-package run gives Test Files 686
passed, 1 skipped (687), and Tests 9840 passed, 21 skipped (9861),
`VERDICT command-exit 0`. `type-check` of the three packages exits 0.
Ablations of the reworked lines, each restored to the HEAD blob
`e96dadd3fbba`:
- `copied` always present (`return copiedAmounts.length > 0 ? { ...plan,
copied: copiedAmounts } : plan;` becomes `return { ...plan, copied:
copiedAmounts };`): Tests 1 failed, 8 passed. The absent-means-none pin
fails.
- No copied note, re-run on the new head: Tests 3 failed, 6 passed. The
copied note fails on both hosts, plus the pure pin.

Round 1 readings follow. Tests on head `482148532`, all under
`os-verify-lock`: `pnpm --dir ui exec vitest run --maxWorkers=2
packages/fields/ packages/plugin-form/ packages/i18n/` gives Test Files
686 passed, 1 skipped (687), and Tests 9840 passed, 21 skipped (9861),
`VERDICT command-exit 0`. `type-check` of `@object-ui/fields`,
`@object-ui/plugin-form` and `@object-ui/i18n` exits 0, after the
closure build. Both pin files are in the `tsconfig.test.json` program
(`--listFiles`: 1 hit each).

<details><summary>New pins, the point 1 measurement, and
ablations</summary>

- `ObjectForm.lookupAutofill-28245.test.tsx`, new describe "a same-edit
currency change keeps amounts and says so", 4 tests through
`ObjectForm`. (1) A USD quote picks a $100 product. Changed to EUR, it
keeps 100 and shows the copied note with its exact text. Control: before
the change there is no note, and changing back to USD ends it. (2) A JPY
quote's withheld note names GBP and no longer JPY after the code becomes
GBP, and the price stays empty. (3) Branch B: a EUR quote's withheld
note reads exactly "Unit Price was not filled when it was picked. The
record is now in USD: pick again to fill $100.00." once the code becomes
USD, and the price stays empty. Control: the pick again fills 100 and no
note remains. (4) A typed 55 gets no note through a currency change, and
neither does 55 typed over a copied 100.
- `GridField.lookupAutofill-28245.test.tsx`, new describe of the same
name, 5 tests. The same four cases through `GridField`, with the header
currency handed in as `columnCurrencies` and changed by a rerender, for
a product priced in EUR. One more is pure: `withheldAutofillNow` follows
the currency now, `nowSameCurrency` applies when it matches, and with no
currency known the item is returned unchanged; `copiedAutofillNow` names
a differing code only while the target holds the copied value. The
objectstack-ai#36412 declared-pairs pin now also asserts `copied` (the price is
recorded under the code the same pick wrote).
- **Point 1 measured on main's code.** The five source files were
restored to `057cedfa9b6` in the tree only, the `-t ruling` pins were
run, and the files were restored with `git checkout HEAD` (`git diff
HEAD` empty afterwards). Result: 7 failed, 2 passed. The two hand-typed
pins passed. Both copied-amount pins failed on the note line after their
amount assertion (ObjectForm line 745, GridField line 641): the amount
kept its value through the currency change on main. The refresh and
branch B pins failed on their note text, and the pure pin failed on the
missing export. Point 1 has no implementing line to ablate: nothing
writes an amount on a currency change, before or after this PR.
- Ablations on the committed tree with `scripts/ablation-replace.mjs`
(`lookupAutofill.ts`; vitest aliases `@object-ui/*` to `src`, so no
`dist` sits between mutation and run), `-t ruling`, each restored to the
HEAD blob `18535d11faef`:
- ` if (!now) return item;` becomes ` return item;` (no refresh): Tests
5 failed, 4 passed. Refresh and branch B on both hosts, plus the pure
pin.
- ` return to && to !== item.under ? to : undefined;` becomes ` return
undefined;` (no copied note): Tests 3 failed, 6 passed. Copied note on
both hosts, plus the pure pin.
- ` if (!sameValue(current, item.value) || !now) return undefined;`
becomes ` if (!now) return undefined;` (a typed-over amount keeps the
note): Tests 3 failed, 6 passed. Hand-typed on both hosts, plus the pure
pin.

</details>

## Acceptance notes

- Clause-②: `yes (widening)` (see the rework section above). The diff
touches no `packages/spec/**` and no metadata. `git grep` finds
`LookupAutofillPlan` only inside `ui/packages/fields`.
- Branch B over a filled target (round 3, the seat's S1): a withheld
value that carries `held` (a pick over a target that still holds an
earlier value) now gets its own branch B sentence,
`lookup.autofillNowSameCurrencyHeld`: "Unit Price was not filled when it
was picked and still holds its earlier value. The record is now in USD:
clear Unit Price, then pick again to fill $100.00." For a declared pair
without `overwrite`, picking the same record again does not replace a
value that record did not fill (the spec's overwrite rule), so the
sentence says to clear the field first. Re-pick behaviour is unchanged.
- A copied amount whose record's currency becomes unset or unreadable
gets no note (no current code to name). Only a known, different code is
named, as the ruling's example reads.
- N9 (record-page editor re-renders): not measured. The new work per
render is one re-judgement per shown note, and nothing runs when no pick
left a note.

## Verification

<details><summary>Gates</summary>

- Round 3: `dispatch-gates --commands` derived the same 41 at
`315c0d8fef`. All 41 ran with exit 0, including the ui `scripts/` family
(172 files passed, 2 skipped; 5130 tests passed). `--ran`: 41 derived,
41 run, 0 NOT-MEASURED, 0 UNRUN. ui `check:i18n-keys`,
`check:i18n-drift`, `check:i18n-dead-keys` and
`check:new-line-citations` exit 0 (run at `dd0ebf7f96`; the later commit
changes two locale strings, and key parity is pinned by the i18n suite
above). Size: 19 files, +582/-38 (620 changed lines); with objectstack-ai#36918's 714
the card totals 1,334, under 3,000.
- Round 2: `dispatch-gates --commands` derived the same 41 at
`a602513471`. All 41 ran with exit 0, including the ui `scripts/` family
(172 files passed, 2 skipped; 5130 tests passed). `--ran`: 41 derived,
41 run, 0 NOT-MEASURED, 0 UNRUN.
- Round 1: `dispatch-gates --commands` (no paths, change set from the
merge base) derived 41 commands at `482148532`. All 41 ran with exit 0.
`pnpm --dir ui exec vitest run scripts/` ran under the lock with
`--maxWorkers=2`: Test Files 172 passed, 2 skipped, and Tests 5130
passed, 2 skipped. `dispatch-gates --ran` with exit codes recorded: 41
derived, 41 run, 0 NOT-MEASURED, 0 UNRUN, exit 0.
- ui `check:i18n-keys`, `check:i18n-drift`, `check:i18n-dead-keys` and
`check:new-line-citations`: exit 0, with 0 new citations.
- `overlap-check` before each push: VERDICT clean, exit 0. Re-read after
`git fetch` against `origin/main` `622f3985fe` and 5 PR heads that share
files (objectstack-ai#37282, objectstack-ai#37249, objectstack-ai#37226, objectstack-ai#37210, objectstack-ai#37166): clean. `--pr=37264`
named explicitly: merges cleanly.

</details>

Read first, by risk: (1) `judgeCopy`, `withheldAutofillNow` and
`copiedAutofillNow` in `lookupAutofill.ts`; (2) the note block at the
end of `LookupField.tsx` (`pickStands`, `currencyNow`); (3) the per-row
note block in `GridFieldWidget.tsx` (`lineCurrencyNow`).

Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-form/src/ObjectForm.lookupAutofill-28245.test.tsx -t
ruling` passes 4 tests. In them, a USD quote picks a $100 product,
changes its currency to EUR, keeps 100, and shows "Unit Price was copied
as $100.00, but the record is now in EUR."

https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
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/l 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.

2 participants