Repository navigation
feat(ui): preview the home amount a record-mode amount will store, and say so when the rate cannot be read - #31724
Conversation
Claude-Session: https://claude.ai/code/session_01QsR2jQyTLkpKcX2UF8X3Ss Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jQyTLkpKcX2UF8X3Ss Co-authored-by: Claude <noreply@anthropic.com>
…-b809vx Claude-Session: https://claude.ai/code/session_01QsR2jQyTLkpKcX2UF8X3Ss Co-authored-by: Claude <noreply@anthropic.com>
|
domain:ui#3 · zhuangjianguo · session_01QsR2jVEjiYrK7onirxUGyo Contract reviewServed-tier: This is the lane seat's own review of record. It is owed by the ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:ui#3 · zhuangjianguo · session_01QsR2jVEjiYrK7onirxUGyo 席位核对 · ACCEPT · 2026-11-09T00:15Z · head
|
… and record-mode currency since 18.3.0 (objectstack-ai#32259) <!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBNP69gnL1YUb368kmLct4Bn)_ Fixes objectstack-ai#32020 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:给 18.4.0 发布测试台账补上 18.3.0 之后落地的三块能力的测试项:回收站(删除后撤销、恢复、清空、Setup 页面)、多币种记录模式金额(本币预览、Studio 本币字段编辑器、改指向货币字段时的 409 拒绝),以及 Redis 多副本部署的启动拒绝和运行期行为。共新增 16 条,并修正一条发票多币种条目。 - 为什么改:发布前的 `since:v18.4` 测试轮只能测台账里有的东西;这三块能力此前没有任何条目,测试员会漏测。 - 风险与回滚:只改 `docs/qa/platform-checklist/` 下的台账文件,没有产品代码、权限或数据语义变化,可直接 revert。 - 先看:`FOLLOW-UPS.md` 的 §17(范围、哪些条目被阻塞及原因),然后是 `areas/api-backend.json` 末尾两条回收站条目。 - 两分钟验证:`node scripts/check-platform-checklist.mjs`(exit 0);`node scripts/checklist-select.mjs since:v18.4` 应列出 34 条,其中 10 条来自本 PR(9 条新增、1 条修订),另有 6 条多副本条目因缺少多节点授权门而标为 blocked,加 `--include-blocked` 后为 40 条。 - 需要你做的:无,席位落地。 ## Premise The card's premise command at the base (`43a51b55`, history deepened to the 18.3.0 subject): ``` $ git -C . log --oneline 83d7e4a..origin/main | wc -l 1159 $ git -C . log --oneline 83d7e4a..origin/main | grep -iE 'replica|recycle|home amount|currency' | wc -l 51 ``` Before this PR, the 24 items carrying `since: "v18.4"` were all M1's (themes 1 and 3), so none covered themes 2, 4 or 5. FOLLOW-UPS §17 accounts for all 51 commits: 23 are covered by an item here, 10 are docs, ADR, skills or test commits with no surface, 17 are outside the card's named list, and one (objectstack-ai#31848) is a false match ("concurrency" contains "currency"). ## Theme 4: the recycle bin (4 items, all active) - `api-backend.recycle-bin-delete-entry-restore` (P1): the delete answer's `recycleBinEntryId`, the listing (cascade snapshot, deletedBy, 30-day retention, purgeAfter), the restore receipt under the original ids, the second restore's 404, and a `sys_` delete that keeps no entry. - `api-backend.recycle-bin-refusals-purge-empty` (P1): `RESTORE_PARENT_IN_RECYCLE_BIN` (naming the parent's entry, then restoring once it is restored), `RESTORE_PARENT_PURGED`, purge, empty, the declared paging and parameter refusals, and the non-manager 403s (via `search:qa-contributor-bound-member`) and the anonymous 401. - `records-forms.delete-toast-undo-restore` (P1): the confirm question without a permanence promise, the toast's Undo restoring through the bin, the list-row Undo, the bulk toast with no Undo, and a platform-object delete that still says it cannot be undone. - `records-forms.setup-recycle-bin-page` (P2): Setup → Recycle bin's object list, entries table, Restore and Empty with its confirm. - Not driven live, recorded in knownGaps and FOLLOW-UPS §17b/§17c: `RESTORE_UNIQUE_VALUE_TAKEN` (no showcase business object declares a unique field), `RESTORE_PACKAGE_UNINSTALLED` (destructive to the boot), and the own-entry half of the restore rule (no stock persona holds `allowRestoreOwnDeleted` without `manageRecycleBin`). All three are pinned by tests. ## Theme 5: record-mode currency (3 active, 1 planned, 1 revision) - `records-forms.home-amount-preview-states` (P2): the preview's converted, home-currency, awaiting-date and awaiting-rate states, and the unreadable-rate message for a member who may not read `sys_exchange_rate`. - `studio-authoring.currency-home-amount-editor` (P2): which fields each picker offers, the three saved pointers, a record stored through them, and clearing them. - `studio-authoring.currency-field-repointed-refusal` (P2): the 409 `DESTRUCTIVE_CHANGE` with the `currency_field_repointed` issue, its remedies, `?force=true`, and an identical pointer raising nothing. - Planned: `records-forms.master-detail-child-follows-parent-currency` (`since: null`). The spec admits the `PARENT_FIELD.CODE_FIELD` path (objectstack-ai#31956), but at the base the engine reads `currencyField` as a field of the same row, so a path reads no code. The engine half is objectstack-ai#31911 (open). FOLLOW-UPS §17a. - Revision: `records-forms.multi-currency-invoice` rev 2. `since` goes from `v18` to `v18.4`: the showcase invoice became the multi-currency example in objectstack-ai#31757, and the hint and preview that `acceptance[5]` reads landed in objectstack-ai#31638 and objectstack-ai#31724, all after 18.3.0. Its knownGaps[0] no longer says a child amount cannot take its parent's currency. No clause changed. ## Theme 2: multi-replica on Redis (8 items, all active, 6 blocked) - Runnable now (both refuse before any gate or Redis is needed): - `cli.serve-multi-replica-local-database-refusal` (P1): `os serve` refuses a SQLite or file database under declared replicas on redis, exit 1, naming a shared Postgres, before anything connects. - `cli.start-multi-replica-auth-secret-refusal` (P1): `os start` refuses without `OS_AUTH_SECRET` and writes no `auth-secret` file; a memory driver is not the declaration. - `blocked: { by: "fixture" }`, each stating its two-replica fixture: - `attachments-storage.multi-replica-local-root-refusal`; - `platform-core.multi-replica-package-change-refusal` (the seven `/packages` doors, install-local both ways, and the clone that would create a customization package); - `platform-core.ready-cluster-driver-health`; - `platform-core.cluster-membership-heartbeat`; - `platform-core.settings-change-reaches-every-replica`; - `platform-core.shared-redis-cache-across-replicas`. - Why they are blocked: the open tree registers no multi-node gate. `checkMultiNodeAllowed` fails closed with none registered, `os serve` falls back to the in-process driver, and the split-brain guard refuses the declared topology, so no declared multi-replica boot on Redis reaches `kernel:ready` on a stock tree. The open-tree route the CLI pin uses (an app whose own `@objectstack/service-cluster` calls `registerMultiNodeGate`, `writeApp` in `serve-multi-node-gate-declaration.integration.test.ts`) is unproven with the real redis driver. The first run that proves it should become an area recipe and lift `blocked` on all six. FOLLOW-UPS §17c. ## What changes - 16 new items across `api-backend`, `records-forms`, `studio-authoring`, `cli`, `attachments-storage` and `platform-core`, each with `source[]` anchors that resolve and a history row citing objectstack-ai#32020. One revision (`records-forms.multi-currency-invoice` rev 2). - `coverage.json`: the recycle-bin items are mapped to `crud_endpoints` (and the refusals item to `permission`); the currency items to `field`, and the re-point refusal to `object` and `metadata_endpoints`; the invoice item, never mapped before, to `field`. The six blocked theme-2 items are mapped nowhere: an item no run can drive does not carry a kind. - `FOLLOW-UPS.md` §17: scope and angles, the item list, 17a (planned, carded), 17b (notes for owners), 17c (fixtures worth adding), 17d (security note). ## Why The 18.4.0 release run selects `since:v18.4`. Before this PR it held nothing for the recycle bin, record-mode currency or multi-replica deployments, which landed after 18.3.0 (epic objectstack-ai#32022, M2). ## Tests No test code changed. Every clause is read from source at `43a51b55` (the merge of `origin/main` at `036a9fbf` was re-checked by the gates below), and each item's `automated.ref` names the pins that hold it today. No live checklist run was made; that is the QA seat's `since:v18.4` run on the release candidate. ## Acceptance notes - **Read from source, not from titles.** Each assertion was read in the code it cites (routes, refusal sentences, codes, constants). Two first drafts were corrected against the code before commit: a storage settings change to the local adapter under declared replicas is not refused at the settings door but logged and not applied by the subscriber (§17b records this as an owner note), and `/me/permissions` is served at `/api/v1/auth/me/permissions`. - **Blocked, not faked.** The order allows a multi-replica item without a fixture only as `blocked` with its reason. The six items state the fixture they need and the premise check (`[cluster] multi-node not authorized (` absent from both boot logs) that proves it was met. - **The doc-formula gate's first run exited 3** (nothing measured: `@objectstack/formula` and `@objectstack/lint` were not built in this fresh container). After `pnpm exec turbo run build --filter=@objectstack/formula --filter=@objectstack/lint` it exited 0, and that is the exit recorded below. - **Shared files with objectstack-ai#32233** (open): `api-backend.json`, `platform-core.json` and `records-forms.json`. This PR only appends items at the end of each items array and revises the last item of `records-forms.json`. The seat was told before the push; whichever lands second merges main. - No changeset: `docs/qa/` only, labelled `skip-changeset`. ## Verification On head `a4eaf691` (this branch with `origin/main` at `036a9fbf` merged in): - `node scripts/check-platform-checklist.mjs` → exit 0 (16 areas, 402 items; coverage 40 kinds mapped, 4 waived; 10/10 recipes referenced, 17 item references resolved; symbol anchors 1397/1407 resolved, the other 10 on the named objectstack-ai#16898 residual). - `node scripts/checklist-select.mjs since:v18.4 --json` → exit 0, 34 runnable items, 10 of them from this PR (9 new, plus the revised invoice item): theme 4 × 4, theme 5 × 4 (3 new and the invoice revision), theme 2 × 2. With `--include-blocked`: 40 (the 6 blocked theme-2 items). - `node scripts/pm/dispatch-gates.mjs --commands` → 16 commands, each run with its exit recorded: 16 × exit 0 (see the doc-formula note above). `--ran` on that record: `16 derived famil(ies) accounted for — 16 run, 0 NOT-MEASURED` (exit 0). - Diff: 8 files, +1335 / -8 (1,343 changed lines, under 3,000). ## Human Minimum Each item is one rule from [CONTRIBUTING.md › Human Minimum](https://github.com/objectstack-ai/objectstack/blob/main/CONTRIBUTING.md#human-minimum), which links the AGENTS.md text that states it. - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (`packages/**` is untouched.) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. (No lintable source changed: JSON and Markdown under `docs/qa/` only.) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. (Nothing publishes; labelled `skip-changeset`.) - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (Not touched.) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [ ] 8. Title, body and comments are in English. (All but the `## 维护者速读` block, which the order asks for in Chinese.) - [x] The *Before Submitting* list in CONTRIBUTING.md is done. --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzhw1tf6sUQgFxnzeJy)_ Co-authored-by: Claude <noreply@anthropic.com>
Requested by Steedos · project thread
Fixes #27196
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
record模式且声明了homeAmount)时,输入框下方实时显示保存后会写入的本位币金额,例如「≈ CN¥71,994.24 at 0.1389 on Mar 15, 2026」。汇率取自sys_exchange_rate中单据日期当天或之前最近的一条,同一币种和日期只读一次。换算函数直接引用@objectstack/formula(feat(formula): publish the home-amount conversion arithmetic #31631 从引擎提出来的同一份),所以预览数字与保存后的数字逐位一致。同币种显示「≈ 金额 (home currency)」,没有汇率时提示保存会被拒绝,没有单据日期时提示先填日期。无权读取汇率的成员(403)看到「保存时折算为本位币」,不会看到「没有汇率」,也不会看到估算金额。homeAmount的金额字段的编辑态:其他币种字段不读取任何数据、不渲染新行(有对照测试)。新增五个翻译键(widening)。@object-ui/fields新增依赖@objectstack/formula(@object-ui/core早已依赖,依赖图不变);fields 包体积 +3.6 KB(gzip +1.0 KB)。回滚即 revert 本 PR。ui/packages/fields/src/widgets/homeAmountPreview.tsx(readRateOn与useHomeAmountPreview),以及CurrencyField.tsx中挂载它的一行。cd ui && pnpm exec vitest run packages/fields/src/__tests__/homeAmountPreview-27196.test.tsx,预期 8 例全绿。其中一致性一例逐个比对引擎测试里的 JPY / CNY / KWD 和 71994.24 用例。What changes
The ui half of multi-currency M3-2, slice 2 of 2 (Task 2 of the card). Slice 1 was #31638. The arithmetic moved into
@objectstack/formulain #31631, which this PR imports. Nothing is copied.ui/packages/fields/src/widgets/homeAmountPreview.tsx(new, internal to the package, not exported).readRateOn(source, currency, date)issues the engine's ownrateOnquery:find('sys_exchange_rate', { $filter: { currency, effective_date: { $lte: date } }, $orderby: [{ field: 'effective_date', order: 'desc' }], $top: 1, $select: ['rate', 'effective_date'] }). Results are cached per adapter (aWeakMap), then by currency and date. A 403 (classifyLoadError(...) === 'forbidden') is cached asrefused. Any other failure is dropped from the cache so the next render asks again.useHomeAmountPreviewreplaysprojectHomeAmountsover the live form record: a blank amount or code gives no line; a code or home currency outside ISO 4217 gives no line. The same currency as home converts at 1 with no read, throughdivideToPlaces. A foreign currency with a blank date asks for the date.documentDateOf(value, localization.timezone)gives the day, and aYYYY-MM-DDvalue is its own day. No row, or a rate that is not positive, is awaiting-rate. Otherwise the line showsdivideToPlaces(amount, rate, CURRENCY_FRACTION_DIGITS[home]).dataSourceprop when a host passes one, else theSchemaRendererContextadapter, theLookupFieldorder. The form renderer's strip is unchanged:form.tsxhands registered widgets the context adapter anyway, so forwarding it again would add a line no test could tell apart. This differs from step-1 item 2, which listed the strip as surface.CurrencyField: mountsHomeAmountPreviewunder the edit box. The read face, and therefore the record page, is unchanged.gen:zh-hant) and inFIELD_DEFAULTS:fields.currencyHome.preview,previewSame,awaitingRate,awaitingDateandrateUnreadable.awaitingDatereads "Set the document date to see the home amount" instead of the step-1 "Pick FIELD …", because the amount widget does not hold its sibling field's label (step-0 6727854849).ui/packages/fields/package.jsongains"@objectstack/formula": "workspace:^", approved in the claim amendment.pnpm-lock.yamlmoves by one importer entry.Tests
ui/packages/fields/src/__tests__/homeAmountPreview-27196.test.tsx(new, 8 cases):home-amount-projection.test.ts: EUR 100 into JPY 15385, CNY 775.8, KWD 33.219. Fromengine-home-amount-projection.test.ts: USD 10,000 at 0.1389 into CNY 71994.24, and USD 150 on 2026-04-02 into 1000.data-state="refused").homeAmount, a blank amount or a blank code previews nothing and reads nothing, and the input stays.ui/packages/plugin-form/src/__tests__/sectionFormHomeAmount-27196.test.tsx, newdescribe: anObjectFormin edit mode under aSchemaRendererProvidershows the line under the amount. This proves the adapter reaches the widget through the form.form-field-channel-census-12130passes unchanged. The census records no new key on the channel, so the approved reader extension was not needed.Acceptance notes
pnpm dev:crmwith the built Console at/_console. The fixture is a scratch package with a record-mode amount declaringhomeAmount, home currency CNY, and USD rates 0.1389 (2026-01-01) and 0.15 (2026-04-01). The engine stored the invoice (USD 10,000, 2026-03-15) asamount_home71994.24 andamount_rate0.1389.sys_exchange_rateread answered 200 and picked the 2026-01-01 row, not the later one. Typing 20000 moved the line to "≈ CN¥143,988.48 …" with no second read.PERMISSION_DENIED. The adapter threwhttpStatus: 403,code: 'PERMISSION_DENIED', whichclassifyLoadErrorclasses asforbidden. The line reads "Converted to the home currency when you save". Typing did not read again./mnt/project-files/issue-27196/live-pr2/(setup.mjs,measure.mjs,shot.cjs,live-report.json,shots/).@object-ui/fieldsdist/index.jsgrows 349,245 → 352,872 bytes (+3,627), gzip 90,342 → 91,356 (+1,014). This was measured by building with and without the mount.@objectstack/formulais external to the fields build and already in the Console's graph through@object-ui/core.CURRENCY_FRACTION_DIGITS, the engine's table. It is drawn withformatCurrency, the same call that draws the stored home field, so the preview and the saved field read the same.datetimedocument date. The preview passeslocalization.timezonealways. Adatevalue in the form isYYYY-MM-DD, whichdocumentDateOfreturns as-is whatever zone it is given, so both agree for both types.Verification
Head
57993ba65a6d74dadc132374899bf4d3356da389. It mergesorigin/main(10 commits); none of them touches a file on this PR. The suites and gates below ran on78863476, the pre-merge head with the same PR files. 19 files, +447 / −2.node scripts/pm/dispatch-gates.mjs --ranreports 59 derived, 59 run, 0 NOT-MEASURED, 0 UNRUN, and every exit code is 0.check:query-options-erasuretimed out at 300 s in the loop. It was re-run alone: exit 0 in 5m22s.check:dual-build-cjs-loadsanswered exit 3 (unbuilt) until the platform packages were built. It was re-run: exit 0.turbo run type-checkfor fields, i18n and plugin-form, 55 tasks, green. eslint on the touched files: 0 errors.check-i18n-en-drift(fromui/): 0. The form-field census: 34/34.@object-ui/i18n+ui/examples/schema-catalog: 144 files, 4241 passed, 13 skipped.@object-ui/fields: 301 files passed, 1 skipped; 4556 tests passed, 7 skipped.@object-ui/plugin-form: 226 files; 2466 passed, 1 skipped.pnpm --dir ui exec vitest run scripts/: 170 files passed, 2 skipped; 5027 tests passed, 2 skipped.git grep -l PATH -- 'ui/examples/**/test/**' 'ui/e2e/**'for every touched path): onlycatalog-gallery-render.test.tsxnamesuseFieldTranslation.ts. It is inside the schema-catalog run above, green.ablation-replace.mjs; each restored to a blob equal to HEAD with an emptygit diff HEAD):if (held) return held;): 1 of 8 red, the once-per-currency-and-date pin.CURRENCY_FRACTION_DIGITS[home]: 1 of 8 red, the engine parity pin (JPY and KWD).HomeAmountPreviewmount removed fromCurrencyField: 7 of 14 red across the two files, the form pin included. The 7 that stay green are PR 1's five home-field pins, the parity case (it calls the hook directly) and the CONTROL.Gate list (59, exit codes as recorded)
🤖 Generated with Claude Code
https://claude.ai/code/session_01QsR2jQyTLkpKcX2UF8X3Ss