Repository navigation
Commit f91ab5a
feat(core): an action's param dialog description, helpText and outcomeMessages fill {{ }} template holes, and still fill ${…} (#28436)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoBCpS3vE7HS7cD6zZzsAPjZ)_
Part of #27948
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:控制台的动作文案里,参数对话框的 `description`、每个参数的 `helpText`、以及
`outcomeMessages` 现在也会填 `{{ record.x }}` / `{{ result.x }}` 这种模板洞(含 `{{
amount | currency:USD }}` 格式化),和 `confirmText` / `successMessage`
用同一个模板引擎;原来的 `${…}` 写法照旧能填。
- 为什么改:规范要求带参数的动作把确认问句从 `confirmText` 挪到 `description`,可挪过去后 `{{
record.x }}` 原样显示成花括号;裁决 A(「同意」)定五个文案键统一成 `{{ }}`,渲染端先行。这是第 1 步。
- 风险与回滚:只改 `@object-ui/core` 的动作运行器;一句话里有 `{{ }}` 就只走模板引擎(同句里的 `${…}`
当普通文字),没有就走旧的 `${…}`,现有文案行为不变;回滚即 revert 本 PR。
-
先看:ui/packages/core/src/actions/ActionRunner.ts(`dialogCopyFiller`、`composeSuccessMessage`
第一档)、ui/packages/core/src/actions/actionCopyTemplate.ts(`fillTransitionalCopy`)、ui/packages/core/src/actions/__tests__/ActionRunner.transitionalCopy-27948.test.ts。
- 两分钟验证:`cd ui && pnpm exec vitest run
packages/core/src/actions/__tests__/ActionRunner.transitionalCopy-27948.test.ts`,预期
15/15 通过。
- 需要你做的:无,席位落地。
## What changes
Step 1 of #27948, ruling 6545229148, letter A (renderer first). The five
action copy keys become one ADR-0032 `{{ }}` template slot.
`confirmText` and `successMessage` already read it; the param dialog's
`description`, each param's `helpText`, and `outcomeMessages` read only
`${…}`. So an author following the spec (move the confirm question of an
action with params from `confirmText` to `description`) saw `{{ record.x
}}` printed raw, from the record header and from a row.
- `ui/packages/core/src/actions/actionCopyTemplate.ts`:
`fillTransitionalCopy(text, fillTemplate, fillLegacy)`, one dialect per
sentence, the rule `confirmText` / `successMessage` kept through their
own transition (objectui#13367 until objectui#13476): a sentence with a
`{{ }}` hole is filled by the template engine alone, so a `${…}` token
in it stays text and a filled value is never read a second time; a
sentence with none keeps its `${…}` reading.
- `ui/packages/core/src/actions/ActionRunner.ts`:
- The `interpolate` handed to the param-collection handler is now
`dialogCopyFiller(action)`: `{{ }}` holes fill over `record` (the row on
a row dispatch, the page's record on the header) and the action's static
`params`, exactly the roots `confirmText` reads (factored out of
`confirmMessage` as `recordCopyRoots`); `${…}` still goes through
`templateEvaluatorFor` (objectui#12967). Both handlers
(`useConsoleActionRuntime`, `RecordDetailView`) already pass that
`interpolate` to the dialog for `description` and `helpText`, so no
app-shell code moves.
- `composeSuccessMessage` rung 1 (`outcomeMessages`): `{{ }}` holes fill
over `result` and `record`, the roots `successMessage` reads, with the
viewer's locale and tenant currency; `${result.*}` still goes through
`substituteScopeTokens`.
- Doc comments on `ActionDef.outcomeMessages`, `ParamCollectionHandler`,
`RUNNER_TEXT`, `templateEvaluatorFor` and `substituteScopeTokens` say
which spelling each reads.
- `.changeset/27948-action-copy-template-holes.md`: `@object-ui/core`
patch.
No `packages/spec/**` change: the describe text, the publish refusal of
`${…}` and the migration of existing `${…}` copy are step 2, after this
is on `main`.
## Tests
`ui/packages/core/src/actions/__tests__/ActionRunner.transitionalCopy-27948.test.ts`,
15 pins through the real runner and `@objectstack/formula`'s
`templateEngine`, reading what the host is handed (the dialog's
`interpolate` output and the toast handler's argument):
- `description` + `helpText`, on the header door and the row door
(`params._rowRecord`, as `ObjectGrid` dispatches): the card's case (the
`confirmText` sentence `Pause {{ record.display_name }}?` reads the same
moved to `description`), a `${record.x}` hole still fills, an unknown
`{{ x }}` hole reads exactly as `confirmText` reads it; a formatter
hole; a mixed sentence (`{{ }}` wins, `${…}` stays text); a filled value
is not re-read as `${…}`.
- `outcomeMessages`: `{{ result.x }}`, `{{ record.x }}` from the row, a
formatter hole, `${result.x}` still fills, an unknown `{{ x }}` reads as
`successMessage` reads it, a mixed sentence.
Reverse check against the unfixed runner (`ActionRunner.ts` and
`actionCopyTemplate.ts` restored from `5da3a8ce`, test file kept): 12
failed, 3 passed. The 3 that stay green are the `${…}` keepers, which
pin preservation and are meant to pass on both. Restore proven by an
empty `git diff HEAD`.
## Acceptance notes
- **Order inside one sentence.** One dialect per sentence, as the
ruling's "decide and pin the order" asks: a `{{ }}` hole makes the whole
sentence a template; `${…}` in it is text. This is the reading
`confirmText` / `successMessage` had during their transition, so step
2's refusal of `${…}` changes nothing for a sentence that already has a
`{{ }}` hole.
- **Roots.** The dialog copy reads `record` and static `params` (not the
collected values, which do not exist yet, the same as `confirmText`);
`outcomeMessages` reads `result` and `record`. The `${…}` path keeps its
wider scope (the whole runner context) until step 2 retires it; step 2's
migration should check producers for `${user.*}`-style holes, which have
no `{{ }}` root here.
- **Envelope.** These three keys are still read as strings:
`description` / `helpText` are localized in app-shell before
`interpolate`, and `outcomeMessages` entries are read only when they are
strings. If step 2 types them as template slots that parse to the `{
dialect, source }` envelope, the readers must accept the envelope first
(the trap objectui#13367 closed for `confirmText` / `successMessage`),
or a served entry silently falls back.
- Registered producers using `${result.*}` in `outcomeMessages` /
`successMessage` (platform-objects' invitation copy) are untouched;
`${…}` keeps filling.
## Verification
Readings at head `164cbe99` on objectstack-ai/objectstack (merge base
`5da3a8ce`).
<details><summary>Tests</summary>
- `cd ui && pnpm exec vitest run
packages/core/src/actions/__tests__/ActionRunner.transitionalCopy-27948.test.ts`:
Tests 15/15 passed.
- `cd ui && pnpm exec vitest run packages/core/`: Test Files 224/224,
Tests 4197 passed, 27 skipped.
- `cd ui && pnpm exec vitest run
packages/app-shell/src/views/ActionParamDialog
packages/app-shell/src/views/ObjectView.inviteOutcome-27797
packages/app-shell/src/hooks/`: Test Files 102/102, Tests 886/886.
- `pnpm --filter @object-ui/core type-check` (sources and
`tsconfig.test.json`): lock VERDICT command-exit 0.
</details>
<details><summary>Gates</summary>
- Build: `env -u OS_SKIP_DTS pnpm turbo run build
--filter='@object-ui/app-shell^...' --filter='!@object-ui/*'` (37/37
tasks) and `--filter='@object-ui/core^...'` (3/3), lock VERDICT
command-exit 0 both.
- `dispatch-gates --commands` at `164cbe99`: 34 families, each run with
stdin from `/dev/null`, exit codes recorded before any pipe; all 34 exit
0 (`pnpm --dir ui exec vitest run scripts/`: Test Files 169 passed, 2
skipped). `--ran`: 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN.
- `origin/main` moved to `630b4078` after branch-off; none of the
incoming files is this PR's and `git merge-tree` against it is clean.
- The full CI farm (`test:repo`, the UI lanes, lint) is CI's.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibwQ8tWwY7TiHQPMCHR)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 41df5eb commit f91ab5a
4 files changed
Lines changed: 276 additions & 34 deletions
File tree
- .changeset
- ui/packages/core/src/actions
- __tests__
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
519 | | - | |
520 | | - | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
521 | 524 | | |
522 | 525 | | |
523 | 526 | | |
| |||
644 | 647 | | |
645 | 648 | | |
646 | 649 | | |
647 | | - | |
| 650 | + | |
| 651 | + | |
648 | 652 | | |
649 | 653 | | |
650 | 654 | | |
| |||
686 | 690 | | |
687 | 691 | | |
688 | 692 | | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
693 | 700 | | |
694 | 701 | | |
695 | 702 | | |
| |||
1705 | 1712 | | |
1706 | 1713 | | |
1707 | 1714 | | |
1708 | | - | |
1709 | 1715 | | |
1710 | 1716 | | |
1711 | 1717 | | |
1712 | | - | |
| 1718 | + | |
1713 | 1719 | | |
1714 | 1720 | | |
1715 | 1721 | | |
| |||
1901 | 1907 | | |
1902 | 1908 | | |
1903 | 1909 | | |
1904 | | - | |
1905 | | - | |
| 1910 | + | |
| 1911 | + | |
1906 | 1912 | | |
1907 | 1913 | | |
1908 | 1914 | | |
| |||
1911 | 1917 | | |
1912 | 1918 | | |
1913 | 1919 | | |
1914 | | - | |
1915 | | - | |
1916 | | - | |
1917 | | - | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
1918 | 1928 | | |
1919 | 1929 | | |
1920 | 1930 | | |
| |||
1947 | 1957 | | |
1948 | 1958 | | |
1949 | 1959 | | |
| 1960 | + | |
1950 | 1961 | | |
1951 | | - | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
1952 | 1967 | | |
1953 | 1968 | | |
1954 | 1969 | | |
1955 | 1970 | | |
1956 | | - | |
1957 | | - | |
1958 | | - | |
1959 | | - | |
1960 | | - | |
1961 | | - | |
| 1971 | + | |
1962 | 1972 | | |
1963 | 1973 | | |
1964 | 1974 | | |
| |||
1989 | 1999 | | |
1990 | 2000 | | |
1991 | 2001 | | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
1992 | 2013 | | |
1993 | 2014 | | |
1994 | 2015 | | |
1995 | 2016 | | |
1996 | | - | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
1997 | 2034 | | |
1998 | | - | |
1999 | | - | |
2000 | | - | |
| 2035 | + | |
| 2036 | + | |
2001 | 2037 | | |
2002 | 2038 | | |
2003 | 2039 | | |
| |||
2996 | 3032 | | |
2997 | 3033 | | |
2998 | 3034 | | |
2999 | | - | |
3000 | | - | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
3001 | 3038 | | |
3002 | 3039 | | |
3003 | 3040 | | |
| |||
3047 | 3084 | | |
3048 | 3085 | | |
3049 | 3086 | | |
3050 | | - | |
3051 | | - | |
3052 | | - | |
3053 | | - | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
3054 | 3092 | | |
3055 | 3093 | | |
3056 | 3094 | | |
| |||
3199 | 3237 | | |
3200 | 3238 | | |
3201 | 3239 | | |
3202 | | - | |
| 3240 | + | |
| 3241 | + | |
3203 | 3242 | | |
3204 | 3243 | | |
3205 | 3244 | | |
| |||
0 commit comments