Skip to content

Commit 3dce4e9

Browse files
committed
feat(spec): submitText sits beside params, the key it depends on; test types the overlay
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2fi9zfJhUTubyJYb6V
1 parent df2d216 commit 3dce4e9

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

‎packages/spec/src/ui/action-submit-text.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import { describe, it, expect } from 'vitest';
1414
import { ActionSchema, InlineActionSchema } from './action.zod';
1515
import { ObjectTranslationDataSchema, TranslationDataSchema, type TranslationBundle } from '../system/translation.zod';
16-
import { translateAction } from '../system/i18n-resolver';
16+
import { translateAction, type ActionLike } from '../system/i18n-resolver';
1717

1818
/** Minimum legal registered action that collects params (HotCRM's `send_email` shape). */
1919
const base = {
@@ -183,7 +183,8 @@ describe('the translation slot and its overlay', () => {
183183

184184
it('resolves the translated label for an action that collects params but authors none', () => {
185185
const { submitText: _authored, ...unlabelled } = action;
186-
expect(translateAction(unlabelled, bundle, { locale: 'zh-CN' }).submitText).toBe('发送');
186+
const translated: ActionLike = translateAction<ActionLike>(unlabelled, bundle, { locale: 'zh-CN' });
187+
expect(translated.submitText).toBe('发送');
187188
});
188189

189190
it('gives no button to an action without params, whatever the bundle carries', () => {

‎packages/spec/src/ui/action.zod.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,12 +1099,6 @@ const actionObject = () => strictObject({
10991099
*/
11001100
description: I18nLabelSchema.optional().describe('Explanatory line shown under the title in the action\'s param dialog. Carries the confirm question for an action that collects params (one dialog, not two). Not the LLM-facing `ai.description`.'),
11011101

1102-
/**
1103-
* The param dialog's submit button label — the contract is on
1104-
* {@link actionSubmitText}.
1105-
*/
1106-
submitText: actionSubmitText().optional().describe('Label of the submit button in the action\'s param dialog, the verb the button performs (e.g. "Send", "Log Call"), in place of the default "Confirm" (declared ahead of its console reader: no renderer shows it yet) — the default-language string, or an inline locale map; translated at `objects.OBJECT._actions.ACTION.submitText` (`globalActions.ACTION.submitText` for an object-less action). Only on an action with a non-empty `params`: without one no param dialog opens, so it is refused. Not `confirmText`, which is the message of a param-less action\'s confirm dialog. A blank label is refused.'),
1107-
11081102
/** Target object this action belongs to (optional, snake_case) */
11091103
objectName: z.string().regex(/^[a-z_][a-z0-9_]*$/).optional().describe('Target object this action belongs to. When set, the action is auto-merged into the object\'s actions array by defineStack().'),
11101104

@@ -1417,6 +1411,12 @@ const actionObject = () => strictObject({
14171411
: undefined
14181412
),
14191413
}).optional().describe('Input parameters required from user — an ActionParam[] DEFINITION array, never a payload map (a static request body goes in `bodyExtra`).'),
1414+
1415+
/**
1416+
* The submit button label of the dialog `params` opens — the contract is
1417+
* on {@link actionSubmitText}.
1418+
*/
1419+
submitText: actionSubmitText().optional().describe('Label of the submit button in the action\'s param dialog, the verb the button performs (e.g. "Send", "Log Call"), in place of the default "Confirm" (declared ahead of its console reader: no renderer shows it yet) — the default-language string, or an inline locale map; translated at `objects.OBJECT._actions.ACTION.submitText` (`globalActions.ACTION.submitText` for an object-less action). Only on an action with a non-empty `params`: without one no param dialog opens, so it is refused. Not `confirmText`, which is the message of a param-less action\'s confirm dialog. A blank label is refused.'),
14201420

14211421
/** Visual Style */
14221422
variant: z.enum(['primary', 'secondary', 'danger', 'ghost', 'link']).optional().describe('Button visual variant for styling (primary = highlighted, danger = destructive, ghost = transparent)'),

0 commit comments

Comments
 (0)