Skip to content

Commit f755457

Browse files
committed
feat(console): an action's confirm and param dialogs draw its cancelText on the dismiss button
Claude-Session: https://claude.ai/code/session_01QsR2jQtTxhjJ5tQUg79qSg Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9a9823d commit f755457

39 files changed

Lines changed: 1110 additions & 40 deletions

File tree

‎content/docs/protocol/objectui/actions.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ params:
538538
- It is not `confirmText`. `confirmText` is the message of the confirm dialog a param-less action opens; `submitText` is the button of the param dialog an action with params opens instead.
539539
- A blank string (`''` or whitespace only) is refused at parse. Omit the key to keep **Confirm**.
540540
- `submitLabel` and `confirmLabel` (the button's spelling on a view's `bulkActionDefs`) are refused with a rename to `submitText`.
541-
- The console does not draw it yet: until its param dialog reads the key, the button says **Confirm**, and `os validate` warns an author who declares it.
541+
- The console draws it on the param dialog's submit button. Without it, the button says **Confirm**, and while a file param uploads it says **Uploading…** either way.
542542

543543
### Naming the dismiss button: `cancelText`
544544

@@ -558,7 +558,7 @@ cancelText: Keep invitation
558558
- **Either pre-run dialog.** It labels the dismiss button of the confirm dialog a param-less action with `confirmText` opens, and of the param dialog an action with a non-empty `params` opens (beside that dialog's `submitText`). An action that declares neither opens no dialog, so `cancelText` there is refused at parse, and a translation of it under such an action is reported by `os validate` (`translation-target-unknown`).
559559
- A blank string (`''` or whitespace only) is refused at parse. Omit the key to keep **Cancel**.
560560
- `cancelLabel` (the button's spelling on the console's `form` and `alert-dialog` renderers) is refused with a rename to `cancelText`.
561-
- The console does not draw it yet: until its confirm and param dialogs read the key, the button says **Cancel**, and `os validate` warns an author who declares it.
561+
- The console draws it on the dismiss button of both dialogs, from the translation bundle first and then the authored text. Without it, the button says **Cancel**. `sys_invitation`'s **Cancel Invitation** action declares **Keep invitation**.
562562

563563
## AI Tool Exposure (ADR-0011)
564564

‎packages/cli/src/utils/i18n-extract.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,15 @@
8888
* objects.<name>._actions.<action>.successMessage
8989
* objects.<name>._actions.<action>.disabledReason
9090
* objects.<name>._actions.<action>.submitText (only beside a non-empty `params`)
91+
* objects.<name>._actions.<action>.cancelText (only beside `confirmText` or a non-empty `params`)
9192
* objects.<name>._actions.<action>.outcomeMessages.<outcome>
9293
* objects.<name>._actions.<action>.params.<param>.label / .helpText / .placeholder
9394
* objects.<name>._actions.<action>.params.<param>.options.<value>
9495
* objects.<name>._actions.<action>.resultDialog.title / .description / .acknowledge
9596
* objects.<name>._actions.<action>.resultDialog.fields.<path>
9697
* globalActions.<action>.label / .description / .confirmText / .successMessage
9798
* / .disabledReason / .submitText (beside a non-empty `params`)
99+
* / .cancelText (beside `confirmText` or a non-empty `params`)
98100
* globalActions.<action>.outcomeMessages.<outcome>
99101
* globalActions.<action>.params.<param>.* / .resultDialog.* (same shape as object actions)
100102
* apps.<app>.label / .description
@@ -771,6 +773,29 @@ function pushActionSubmitText(
771773
pushOptional(out, [...actionRoot, 'submitText'], action.submitText, source, { objectName });
772774
}
773775

776+
/**
777+
* Emit `cancelText`, the dismiss button label of the dialog an action opens
778+
* before it runs, under the action's translation root — OPTIONAL-not-derived
779+
* like `submitText` (an action that names no label shows the console's own
780+
* "Cancel"), and only for an action that opens one of the two dialogs carrying
781+
* that button: the confirm dialog of a declared `confirmText`, or the param
782+
* dialog of a non-empty `params`. Those are the actions `translateAction`
783+
* overlays the key onto; any other action gets no slot, so a translation filed
784+
* there stays dangling.
785+
*/
786+
function pushActionCancelText(
787+
out: ExpectedEntry[],
788+
actionRoot: string[],
789+
action: any,
790+
source: ExpectedEntry['source'],
791+
objectName: string | undefined,
792+
): void {
793+
const opensDialog = action?.confirmText != null
794+
|| (Array.isArray(action?.params) && action.params.length > 0);
795+
if (!opensDialog) return;
796+
pushOptional(out, [...actionRoot, 'cancelText'], action.cancelText, source, { objectName });
797+
}
798+
774799
/**
775800
* Emit `params.<param>.{label,helpText,placeholder}` and
776801
* `params.<param>.options.<value>` entries under an action's translation root.
@@ -1530,6 +1555,7 @@ export function collectExpectedEntries(
15301555
pushOptional(out, [...aroot, 'successMessage'], actionCopy(action.successMessage), 'action', { objectName });
15311556
pushOptional(out, [...aroot, 'disabledReason'], action.disabledReason, 'action', { objectName });
15321557
pushActionSubmitText(out, aroot, action, 'action', objectName);
1558+
pushActionCancelText(out, aroot, action, 'action', objectName);
15331559
pushActionOutcomeMessages(out, aroot, action, 'action', objectName);
15341560
pushActionParams(out, ['objects', objectName, '_actions', aname], action, 'action', objectName);
15351561
pushActionResultDialog(out, ['objects', objectName, '_actions', aname], action, 'action', objectName);
@@ -1628,6 +1654,7 @@ export function collectExpectedEntries(
16281654
// seed for it.
16291655
pushOptional(out, [...root, 'disabledReason'], action.disabledReason, kind, { objectName });
16301656
pushActionSubmitText(out, root, action, kind, objectName);
1657+
pushActionCancelText(out, root, action, kind, objectName);
16311658
pushActionOutcomeMessages(out, root, action, kind, objectName);
16321659
pushActionParams(out, root, action, kind, objectName);
16331660
pushActionResultDialog(out, root, action, kind, objectName);
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
// Copyright (c) 2026 ObjectStack contributors. Apache-2.0 license.
2+
//
3+
// The extractor half of `action.cancelText`, the label of the dismiss button on
4+
// the dialog an action opens before it runs.
5+
//
6+
// `translateAction` overlays `objects.OBJECT._actions.ACTION.cancelText`
7+
// (`globalActions.ACTION.cancelText` for an object-less action) only onto an
8+
// action that opens one of the two dialogs carrying that button: the confirm
9+
// dialog of a declared `confirmText`, or the param dialog of a non-empty
10+
// `params`. `os i18n extract` scaffolds the slot on exactly that population:
11+
// there it is an optional slot like `submitText`, and anywhere else there is no
12+
// slot at all. The last test walks ONE fixture action through all three
13+
// surfaces — `ActionSchema` accepts it, the extractor emits its key, the
14+
// translation schema accepts the bundle written at that key — because each half
15+
// passing alone does not prove the addresses agree.
16+
17+
import { describe, it, expect } from 'vitest';
18+
import { collectExpectedEntries, extractTranslations } from '../src/utils/i18n-extract';
19+
import { computeI18nCoverage } from '../src/utils/i18n-coverage';
20+
import { ActionSchema } from '@objectstack/spec/ui';
21+
import { ObjectTranslationDataSchema } from '@objectstack/spec/system';
22+
23+
const paths = (config: any) => collectExpectedEntries(config).map((e) => e.path.join('.'));
24+
25+
const PARAMS = [{ name: 'reason', label: 'Reason', type: 'text' }];
26+
27+
describe('the extractor emits action-level `cancelText` beside `confirmText` or a non-empty `params`', () => {
28+
it('emits it for a TOP-LEVEL object action with a confirm dialog', () => {
29+
const keys = paths({
30+
actions: [{
31+
name: 'cancel_invitation', objectName: 'sys_invitation', label: 'Cancel Invitation',
32+
confirmText: 'Cancel this invitation?', cancelText: 'Keep invitation',
33+
}],
34+
});
35+
36+
expect(keys).toContain('objects.sys_invitation._actions.cancel_invitation.cancelText');
37+
});
38+
39+
it('emits it for a GLOBAL action with a param dialog', () => {
40+
const keys = paths({
41+
actions: [{ name: 'close_period', label: 'Close Period', params: PARAMS, cancelText: 'Keep open' }],
42+
});
43+
44+
expect(keys).toContain('globalActions.close_period.cancelText');
45+
});
46+
47+
it('emits it for an action declared INLINE on the object', () => {
48+
const keys = paths({
49+
objects: [
50+
{
51+
name: 'sys_invitation',
52+
label: 'Invitation',
53+
actions: [{ name: 'cancel_invitation', label: 'Cancel Invitation', confirmText: 'Sure?', cancelText: 'Keep invitation' }],
54+
},
55+
],
56+
});
57+
58+
expect(keys).toContain('objects.sys_invitation._actions.cancel_invitation.cancelText');
59+
});
60+
61+
it('records a seed-less slot for a dialog action that names no label — the dialog keeps "Cancel"', () => {
62+
const config = {
63+
objects: [{ name: 'sys_invitation', label: 'Invitation', actions: [{ name: 'resend', label: 'Resend', confirmText: 'Resend it?' }] }],
64+
};
65+
const key = 'objects.sys_invitation._actions.resend.cancelText';
66+
const entry = collectExpectedEntries(config).find((e) => e.path.join('.') === key);
67+
68+
expect(entry).toBeDefined();
69+
expect(entry?.inline).toBeUndefined();
70+
expect(entry?.sourceValue).toBeUndefined();
71+
72+
const { bundles } = extractTranslations(config, { defaultLocale: 'en', fill: 'default' });
73+
expect(bundles.en.objects?.sys_invitation?._actions?.resend).not.toHaveProperty('cancelText');
74+
expect(computeI18nCoverage({ ...config, translations: [{ 'zh-CN': {} }] }).issues.map((i) => i.key))
75+
.not.toContain(key);
76+
});
77+
78+
it('emits NO slot for an action that opens no dialog — neither `confirmText` nor a non-empty `params`', () => {
79+
for (const params of [undefined, []]) {
80+
const keys = paths({
81+
objects: [
82+
{
83+
name: 'sys_invitation',
84+
label: 'Invitation',
85+
actions: [{ name: 'archive', label: 'Archive', ...(params ? { params } : {}) }],
86+
},
87+
],
88+
actions: [{ name: 'refresh_all', label: 'Refresh', ...(params ? { params } : {}) }],
89+
});
90+
91+
expect(keys).toContain('objects.sys_invitation._actions.archive.label');
92+
expect(keys).not.toContain('objects.sys_invitation._actions.archive.cancelText');
93+
expect(keys).toContain('globalActions.refresh_all.label');
94+
expect(keys).not.toContain('globalActions.refresh_all.cancelText');
95+
}
96+
});
97+
98+
it('carries the declared label into the bundle, and gates it until it is translated', () => {
99+
const config: any = {
100+
objects: [
101+
{
102+
name: 'sys_invitation',
103+
label: 'Invitation',
104+
actions: [{ name: 'cancel_invitation', label: 'Cancel Invitation', confirmText: 'Sure?', cancelText: 'Keep invitation' }],
105+
},
106+
],
107+
translations: [
108+
{ 'zh-CN': { objects: { sys_invitation: { label: '邀请', _actions: { cancel_invitation: { label: '取消邀请', confirmText: '确定?' } } } } } },
109+
],
110+
};
111+
const key = 'objects.sys_invitation._actions.cancel_invitation.cancelText';
112+
113+
const entry = collectExpectedEntries(config).find((e) => e.path.join('.') === key);
114+
expect(entry?.source).toBe('action');
115+
expect(entry?.inline).toBe('Keep invitation');
116+
117+
const { bundles } = extractTranslations(config, { defaultLocale: 'en', fill: 'default' });
118+
expect(bundles.en.objects?.sys_invitation?._actions?.cancel_invitation.cancelText).toBe('Keep invitation');
119+
120+
expect(computeI18nCoverage(config).issues.map((i) => i.key)).toContain(key);
121+
config.translations[0]['zh-CN'].objects.sys_invitation._actions.cancel_invitation.cancelText = '保留邀请';
122+
expect(computeI18nCoverage(config).issues.map((i) => i.key)).not.toContain(key);
123+
});
124+
});
125+
126+
describe('one fixture action, all three surfaces (cancelText end-to-end)', () => {
127+
const authored = {
128+
name: 'cancel_invitation',
129+
objectName: 'sys_invitation',
130+
label: 'Cancel Invitation',
131+
type: 'script',
132+
target: 'cancelInvitation',
133+
confirmText: 'Cancel this invitation?',
134+
cancelText: 'Keep invitation',
135+
};
136+
137+
it('parses as metadata, extracts to a key, and that key round-trips a bundle', () => {
138+
const parsed = ActionSchema.safeParse(authored);
139+
expect(parsed.success).toBe(true);
140+
expect(parsed.success && parsed.data.cancelText).toBe('Keep invitation');
141+
142+
const { bundles } = extractTranslations({ actions: [authored] }, {
143+
defaultLocale: 'en',
144+
locales: ['zh-CN'],
145+
fill: 'empty',
146+
});
147+
const bundle: any = bundles['zh-CN'];
148+
expect(bundle.objects.sys_invitation._actions.cancel_invitation).toHaveProperty('cancelText');
149+
150+
bundle.objects.sys_invitation._actions.cancel_invitation.cancelText = '保留邀请';
151+
const translated = ObjectTranslationDataSchema.safeParse(bundle.objects.sys_invitation);
152+
expect(translated.success).toBe(true);
153+
expect(translated.success && translated.data._actions?.cancel_invitation?.cancelText).toBe('保留邀请');
154+
});
155+
});

‎packages/platform-objects/src/identity/sys-invitation.object.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ export const SysInvitation = ObjectSchema.create({
126126
requiresFeature: 'organization',
127127
requiresMembershipReach: 'cancel_invitation',
128128
confirmText: 'Cancel this invitation? The recipient will no longer be able to accept it.',
129+
// The dismiss button names what dismissing keeps: beside a "Cancel
130+
// Invitation" confirm button, a bare "Cancel" reads as the same verb.
131+
cancelText: 'Keep invitation',
129132
successMessage: 'Invitation canceled',
130133
refreshAfter: true,
131134
// ADR-0011 identity-actions note, bucket C: exposed, and the

‎packages/spec/liveness/action.json‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@
2424
"note": "LIVE since #28158 (the console half of #27944). An action that collects `params` names its own submit verb (\"Send\", \"Log Call\"): the param dialog's submit button draws the translated or authored `submitText` and falls back to \"Confirm\" when the action declares none. While a file param uploads, the button says \"Uploading…\" either way. The Studio action form offers the key (`action.form.ts`). `authorWarn` / `authorHint` were dropped in the same edit (a warned `live` row reds this gate)."
2525
},
2626
"cancelText": {
27-
"status": "planned",
27+
"status": "live",
2828
"verifiedAt": "2026-11-02",
29-
"authorWarn": true,
30-
"authorHint": "Keep it, but nothing reads it yet: no console draws an action's `cancelText`, so the dismiss button of its confirm or param dialog still says \"Cancel\" until the console's two action dialogs read the key.",
31-
"evidence": "packages/spec/src/ui/action.zod.ts#cancelText (the parse: an I18nLabel, never blank, only on an action that declares `confirmText` or a non-empty `params`); packages/spec/src/system/i18n-resolver.ts#translateAction overlays the translated `objects.{o}._actions.{a}.cancelText` (or `globalActions.{a}.cancelText`) onto the served action when it opens either dialog; packages/spec/src/system/translation.zod.ts declares the translation slot; packages/lint/src/validate-translation-references.ts#checkActionCancelText refuses a translation under an action that opens neither dialog.",
32-
"note": "PLANNED until the console half of #28519 lands (spec PR first, console card second, the #27944 split). The framework half is live, but no renderer reads the key yet. The confirm dialog: ui/packages/app-shell/src/views/ActionConfirmDialog.tsx already draws `options.cancelText` over `actionConfirm.cancel`, but ui/packages/core/src/actions/ActionRunner.ts#confirmOptions hands it only `title` / `confirmText` / `destructive`, never the action's `cancelText`, and `ActionDef` does not declare the key. The param dialog: ui/packages/app-shell/src/views/ActionParamDialog.tsx draws `actionDialog.cancel` unconditionally, fed by the two param-collection handlers (ui/packages/app-shell/src/hooks/useConsoleActionRuntime.tsx#paramCollectionHandler, ui/packages/app-shell/src/views/RecordDetailView.tsx#paramCollectionHandler). `authorWarn` is set because an author who writes the key today sees \"Cancel\", not their label. The console PR flips this row to `live` with those read points, and drops `authorWarn` / `authorHint` in that same edit (a warned `live` row reds this gate)."
29+
"evidenceScope": "in-repo",
30+
"evidence": "ui/packages/react/src/hooks/useActionTextLocalizer.ts (the confirm path: the bundle's `objects.{o}._actions.{a}.cancelText`, or `globalActions.{a}.cancelText` for an object-less action, through `actionCancelText`, then the authored `I18nLabel` collapsed to the active language, only when the action declares one); ui/packages/core/src/actions/ActionRunner.ts#confirmOptions (hands the resolved string to the confirm handler as `options.cancelText`) and ui/packages/core/src/actions/ActionRunner.ts#ActionDef (the key derived from the spec); ui/packages/app-shell/src/views/ActionConfirmDialog.tsx (draws `options.cancelText` over `actionConfirm.cancel`); ui/packages/app-shell/src/hooks/useConsoleActionRuntime.tsx#paramCollectionHandler and ui/packages/app-shell/src/views/RecordDetailView.tsx#paramCollectionHandler (the param path, resolved the same way); ui/packages/app-shell/src/views/ActionParamDialog.tsx (draws it on the dismiss button, `actionDialog.cancel` when absent); ui/packages/components/src/renderers/action/action-button.tsx, ui/packages/components/src/renderers/action/action-icon.tsx, ui/packages/components/src/renderers/action/action-group.tsx, ui/packages/components/src/renderers/action/action-menu.tsx (the four action renderers forward it to the runner); packages/spec/src/system/i18n-resolver.ts#translateAction (the served overlay); packages/lint/src/validate-translation-references.ts#checkActionCancelText (a translation under an action that opens neither dialog is refused)",
31+
"note": "LIVE since #28879 (the console half of #28519). An action that asks first or collects `params` names its dialog's dismiss button (\"Keep invitation\" beside \"Cancel Invitation\"): the confirm dialog and the param dialog draw the translated or authored `cancelText` and fall back to \"Cancel\" when the action declares none. `sys_invitation`'s `cancel_invitation` is the first consumer. The Studio action form offers the key (`action.form.ts`). `authorWarn` / `authorHint` were dropped in the same edit (a warned `live` row reds this gate)."
3332
},
3433
"objectName": {
3534
"status": "live",

‎packages/spec/src/system/metadata-form-zod-reconciliation.test.ts‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -396,18 +396,7 @@ const LEDGER: ReadonlyArray<OmitEntry | SubsetEntry> = [
396396
key: 'pressed',
397397
why: "planned, not yet rendered — the reader's pressed-state predicate is validated at parse (CEL only, no boolean literal) and judged at the authoring doors in the `record` scope, but no action surface draws the pressed face until the console's header buttons read it. A form control offered today would let an author write a predicate nothing shows",
398398
},
399-
// #28519 — the dismiss label of an action's confirm and param dialogs lands
400-
// spec-first the way `submitText` did: `planned` in the liveness ledger,
401-
// drawn by neither dialog until the console reads it. The console change
402-
// that flips the ledger row deletes this row and offers the key in
403-
// `action.form.ts`, beside `submitText`.
404-
{
405-
kind: 'omit',
406-
type: 'action',
407-
path: ROOT_PATH,
408-
key: 'cancelText',
409-
why: "planned, not yet rendered — the dialogs' dismiss button label is validated at parse (an I18nLabel, never blank, only on an action that declares `confirmText` or a non-empty `params`) and translated by `translateAction`, but the console's confirm and param dialogs still draw their default \"Cancel\" until they read the key. A form control offered today would let an author set a button label nothing shows",
410-
},
399+
411400
// #27945 — a lookup's pick autofill lands spec-first the same way: `planned`
412401
// in the liveness ledger, read by no form or grid until the ui card's lookup
413402
// widget writes the declared targets on pick.

0 commit comments

Comments
 (0)