Repository navigation
Commit 561b764
fix(app-shell): a dynamic currency change in record History reads in the tenant currency (#27779)
domain:ui#2 · os-bill · session_01Utp6CY2n1JmZZKrHgtp9jC
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgP6XkfpjCfyzzG2KwQPUZfy)_
Fixes #27640
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:记录页 History
的格式化上下文现在带上租户默认币种(`useLocalization().currency`),`dynamic` 币种字段的变更显示为
`€1,500.00 → €2,500.00`,不再是裸数字。
- 为什么改:同一字段在记录页显示 `$4,321,000.00`,History 里却是 `4,321,000.00`,两处读数不一致;原因是
History 从没拿到租户币种。
- 风险与回滚:风险低,只是给已有的可选成员传值,`record` 模式不受影响;回滚即还原本 PR 一个提交。
- 先看:`ui/packages/app-shell/src/views/RecordDetailView.tsx`(`fmtCtx`
一行、hook 读取、effect 依赖),再看新测试
`RecordDetailView.auditTenantCurrency-27640.test.tsx`。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/RecordDetailView.auditTenantCurrency-27640.test.tsx`,预期
3 个测试全绿。
- 需要你做的:无,席位落地。
## What changes
`RecordDetailView`'s History effect built its format context as `{ t,
locale: displayLocale, lookupLabels }`, so `formatAuditValue` →
`resolveFieldCurrency` never reached its last step, the tenant default
currency (`AuditValueFormatContext.tenantCurrency`, ADR-0053). A
`dynamic`-mode currency change therefore read as a plain grouped number
next to the record's own currency face.
- The view reads `const { currency: tenantCurrency } =
useLocalization();` (from `@object-ui/i18n`), the same value the record
page's cells read: `DetailView` in `@object-ui/plugin-detail` takes its
`tenantCurrency` from `useLocalization()` the same way. The view held no
such value before, so this is the one hook read the triage allowed.
- `fmtCtx` becomes `{ t, locale: displayLocale, lookupLabels,
tenantCurrency }`.
- `tenantCurrency` joins the History effect's dependency list beside
`displayLocale`, so the stream re-formats when the tenant's localization
arrives or changes, the way it already does for a display-locale switch.
- `record`-mode fields are unchanged (out of scope per triage):
`resolveFieldCurrency` answers no code for them without the row, and the
tenant default is never their fallback.
Changeset: `.changeset/27640-history-dynamic-currency.md`,
`@object-ui/app-shell` patch.
## Tests
New:
`ui/packages/app-shell/src/views/RecordDetailView.auditTenantCurrency-27640.test.tsx`
renders the record page on its History stream (`?tab=timeline`) under a
real `I18nProvider` and a `LocalizationProvider`, with one audit entry
that moves a `dynamic` field and a `record`-mode field from 1500 to
2500:
- EUR tenant: the `dynamic` change reads `Amount €1,500.00 → €2,500.00`
(the pin);
- EUR tenant: the `record`-mode change stays `List price 1,500.00 →
2,500.00`;
- control, no tenant currency: the `dynamic` change reads `Amount
1,500.00 → 2,500.00`.
Ablation (fix committed first, mutation through
`scripts/ablation-replace.mjs`): replacing `lookupLabels, tenantCurrency
};` with `lookupLabels };` landed on disk (anchor 1 → 0, blob
`ab5f20a6e2c8` → `cb4dc3752561`); the pin went red (`got: Amount
1,500.00 → 2,500.00`), the record-mode case and the control stayed
green, and the restore matched the HEAD blob `ab5f20a6e2c8`.
## Acceptance notes
- The spec seat's draft PR #27713 also edits `RecordDetailView.tsx`; its
patch does not touch the hunks here (the import line, the
`displayLocale` hook area, `fmtCtx` and the History effect's dependency
list). Whichever lands second rebases.
- Local verification was narrowed: the `@object-ui/app-shell` package
holds about 1,900 test files, too many to run on the shared box under
the verification lock, so the local run covers every test file that
imports `RecordDetailView` plus the `auditHistoryDisplay` unit tests.
`Test UI` in CI runs the whole package.
## Verification
Local readings, on head `7be9046e` (after the one merge of
`origin/main`) unless named otherwise.
<details>
<summary>Targeted tests</summary>
- New test file: `Test Files 1 passed (1)`, `Tests 3 passed (3)`.
- History siblings (`RecordDetailView.auditDisplayLocale-10442`,
`auditHistoryDisplay.numericAmounts-27486`): green.
- Every test file importing `RecordDetailView` plus the
`auditHistoryDisplay` unit tests (157 files, the new one included):
`Test Files 156 passed | 1 skipped (157)`, `Tests 1079 passed | 8
skipped (1087)`, lock `VERDICT command-exit 0`.
</details>
<details>
<summary>Typecheck and lint</summary>
- `pnpm --filter @object-ui/app-shell run type-check` (both `tsc
--noEmit` and `tsconfig.test.json`), on `f804616f` (the merge brought no
change to this diff's files): lock `VERDICT command-exit 0`.
- `eslint` on the two touched source files: exit 0, 0 errors (warnings
only, the existing `no-explicit-any` ones and two `as any` test doubles
that mirror the sibling History test).
- `pnpm check:new-line-citations` (run by hand per `ui/AGENTS.md`): 0
new citations.
</details>
<details>
<summary>Derived gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 34 commands over the 3 changed
paths; all 34 exited 0 (`node scripts/check-sdui-manifest.mjs` among
them), and `--ran` reconciled 34 derived / 34 run / 0 NOT-MEASURED.
Re-run in full on `7be9046e`: 34/34 exit 0, `--ran` reconciled 34/34/0.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CY2n1JmZZKrHgtp9jC)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 2a0b37b commit 561b764
3 files changed
Lines changed: 238 additions & 3 deletions
File tree
- .changeset
- ui/packages/app-shell/src/views
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
762 | 762 | | |
763 | 763 | | |
764 | 764 | | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
765 | 768 | | |
766 | 769 | | |
767 | 770 | | |
| |||
2440 | 2443 | | |
2441 | 2444 | | |
2442 | 2445 | | |
2443 | | - | |
| 2446 | + | |
2444 | 2447 | | |
2445 | 2448 | | |
2446 | 2449 | | |
| |||
2485 | 2488 | | |
2486 | 2489 | | |
2487 | 2490 | | |
2488 | | - | |
| 2491 | + | |
2489 | 2492 | | |
2490 | 2493 | | |
2491 | 2494 | | |
| |||
0 commit comments