From e7f93f4aef80e580df5801f82d0458d46d24d2da Mon Sep 17 00:00:00 2001 From: Paulo Castellano Date: Fri, 17 Jul 2026 11:26:15 -0300 Subject: [PATCH] refactor(ai-create): clarify prompt-rule naming and label the counter - Rename AiPromptRules::promptRule() to wizardPromptRule() so the asymmetry is explicit: only the create wizard carries a minimum; the editor's generation reuses just the shared maximum. - Add aria-live and a data-testid to the prompt counter so the over-limit state is announced to assistive tech and reachable from browser tests. --- app/Http/Requests/App/Ai/StartPostCreationRequest.php | 2 +- app/Support/AiPromptRules.php | 6 ++++-- resources/js/components/posts/create/AiPostWizard.vue | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Http/Requests/App/Ai/StartPostCreationRequest.php b/app/Http/Requests/App/Ai/StartPostCreationRequest.php index 34ffb1bc..2b72365e 100644 --- a/app/Http/Requests/App/Ai/StartPostCreationRequest.php +++ b/app/Http/Requests/App/Ai/StartPostCreationRequest.php @@ -34,7 +34,7 @@ public function rules(): array ], 'social_account_id' => ['nullable', 'uuid'], 'image_count' => ['nullable', 'integer', 'min:0', 'max:10'], - 'prompt' => AiPromptRules::promptRule(), + 'prompt' => AiPromptRules::wizardPromptRule(), 'date' => ['nullable', 'date_format:Y-m-d'], 'template' => ['sometimes', 'string', Rule::enum(ContentStyle::class)], ]; diff --git a/app/Support/AiPromptRules.php b/app/Support/AiPromptRules.php index 9803cb90..c8b8ba6d 100644 --- a/app/Support/AiPromptRules.php +++ b/app/Support/AiPromptRules.php @@ -23,11 +23,13 @@ class AiPromptRules public const PROMPT_MAX_LENGTH = 2000; /** - * Validation rules for the create wizard's generation prompt. + * Validation rules for the create wizard's generation prompt. The editor's + * content generation reuses only PROMPT_MAX_LENGTH — it has no minimum, + * since it has no character counter to mirror one. * * @return array */ - public static function promptRule(): array + public static function wizardPromptRule(): array { return ['required', 'string', 'min:'.self::PROMPT_MIN_LENGTH, 'max:'.self::PROMPT_MAX_LENGTH]; } diff --git a/resources/js/components/posts/create/AiPostWizard.vue b/resources/js/components/posts/create/AiPostWizard.vue index 4e304921..49b277d5 100644 --- a/resources/js/components/posts/create/AiPostWizard.vue +++ b/resources/js/components/posts/create/AiPostWizard.vue @@ -364,6 +364,8 @@ const startGeneration = async () => { class="min-h-[140px] resize-none" />