Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

Structure brand voice and make generated copy platform-aware

Paulo Castellanoa09b1f45c27a
diff --git a/app/Actions/Automation/Node/RunGenerateNode.php b/app/Actions/Automation/Node/RunGenerateNode.php
index 286c66c86..ed6766662 100644
--- a/app/Actions/Automation/Node/RunGenerateNode.php
+++ b/app/Actions/Automation/Node/RunGenerateNode.php
@@ -54,10 +54,19 @@ class RunGenerateNode
]);
}
+ // Per-automation toggle: when off, the brand persona/voice is NOT
+ // injected, so the post stays faithful to a third-party source (news /
+ // RSS curation) instead of being rewritten in the brand's voice.
+ $applyBrandVoice = (bool) data_get($config, 'use_brand_voice', true);
+
+ $platformContext = $this->resolvePlatformContext($accountsConfig);
+
$agent = new PostContentGenerator(
workspace: $workspace,
format: $format,
slideCount: $slideCount,
+ platformContext: $platformContext,
+ applyBrandVoice: $applyBrandVoice,
);
$generatorResponse = $agent->prompt($prompt);
@@ -73,7 +82,7 @@ class RunGenerateNode
$structured = $generatorResponse->structured ?? [];
- $structured = $this->humanize($workspace, $structured, $format);
+ $structured = $this->humanize($workspace, $structured, $format, $applyBrandVoice, $platformContext);
$content = $format === 'carousel'
? (string) data_get($structured, 'caption', '')
@@ -102,7 +111,10 @@ class RunGenerateNode
];
}
- $includeImage = (bool) data_get($config, 'include_image', true);
+ // A single source of truth for image count: 0 = text-only (no image),
+ // 1 = single image, 2+ = carousel. For the single-image branch we only
+ // care whether at least one image was requested.
+ $wantsImage = (int) data_get($config, 'target_slide_count', 1) >= 1;
$brandAccount = $platforms !== []
? $activeAccounts->get(data_get($platforms[0], 'social_account_id'))
@@ -112,7 +124,7 @@ class RunGenerateNode
? ContentType::tryFrom((string) data_get($platforms[0], 'content_type'))
: null;
- $imageCount = $this->intendedImageCount($format, $slideCount, $includeImage, $structured, $brandAccount);
+ $imageCount = $this->intendedImageCount($format, $slideCount, $wantsImage, $structured, $brandAccount);
// Dry runs do the AI work (so the user sees a real generation) but
// never persist a Post. Downstream nodes (Publish) read `is_dry_run`
@@ -130,11 +142,13 @@ class RunGenerateNode
$media = [];
+ $applyBrandVisuals = (bool) data_get($config, 'use_brand_visuals', true);
+
if ($brandAccount) {
if ($format === 'carousel') {
- $media = app(PostImagePipeline::class)->forCarousel($workspace, $brandAccount, $structured, $contentType);
- } elseif ($includeImage) {
- $media = app(PostImagePipeline::class)->forSingle($workspace, $brandAccount, $structured, $contentType);
+ $media = app(PostImagePipeline::class)->forCarousel($workspace, $brandAccount, $structured, $contentType, $applyBrandVisuals);
+ } elseif ($wantsImage) {
+ $media = app(PostImagePipeline::class)->forSingle($workspace, $brandAccount, $structured, $contentType, $applyBrandVisuals);
}
}
@@ -159,7 +173,7 @@ class RunGenerateNode
* @param array<string, mixed> $structured
* @return array<string, mixed>
*/
- private function humanize(Workspace $workspace, array $structured, string $format): array
+ private function humanize(Workspace $workspace, array $structured, string $format, bool $applyBrandVoice = true, ?string $platformContext = null): array
{
try {
$input = $format === 'carousel'
@@ -179,7 +193,7 @@ class RunGenerateNode
'image_body' => data_get($structured, 'image_body', ''),
];
- $humanizer = new PostContentHumanizer($workspace, $format);
+ $humanizer = new PostContentHumanizer($workspace, $format, platformContext: $platformContext, applyBrandVoice: $applyBrandVoice);
$response = $humanizer->prompt(json_encode($input, JSON_UNESCAPED_UNICODE));
$humanized = $response->structured ?? [];
@@ -263,6 +277,25 @@ class RunGenerateNode
return ['format' => 'single', 'slide_count' => 1];
}
+ /**
+ * Pick the content type the generator should write for so the copy fits
+ * every selected network. A Generate node can target one or many accounts,
+ * each with its own content type, so we feed the generator the MOST
+ * RESTRICTIVE platform (smallest character cap) — content that fits X (280)
+ * also fits LinkedIn (3000). Returns null when no account carries a known
+ * content type, leaving the generator platform-agnostic.
+ *
+ * @param array<int, array{social_account_id: string, content_type: ?string, meta: array<string, mixed>}> $accountsConfig
+ */
+ private function resolvePlatformContext(array $accountsConfig): ?string
+ {
+ return collect($accountsConfig)
+ ->map(fn ($entry) => ContentType::tryFrom((string) data_get($entry, 'content_type')))
+ ->filter()
+ ->sortBy(fn (ContentType $contentType) => $contentType->platform()->maxContentLength())
+ ->first()?->value;
+ }
+
/**
* Number of images that would be attached for the resolved format. Used as
* the dry-run indicator and mirrors the non-dry image generation branches:
@@ -270,7 +303,7 @@ class RunGenerateNode
*
* @param array<string, mixed> $structured
*/
- private function intendedImageCount(string $format, int $slideCount, bool $includeImage, array $structured, ?SocialAccount $brandAccount): int
+ private function intendedImageCount(string $format, int $slideCount, bool $wantsImage, array $structured, ?SocialAccount $brandAccount): int
{
if (! $brandAccount) {
return 0;
@@ -282,7 +315,7 @@ class RunGenerateNode
return is_array($slides) ? count($slides) : $slideCount;
}
- return $includeImage ? 1 : 0;
+ return $wantsImage ? 1 : 0;
}
private function resolveUser(AutomationRun $run): User
diff --git a/app/Actions/Workspace/CreateWorkspace.php b/app/Actions/Workspace/CreateWorkspace.php
index f23e6da79..e6dd18a9a 100644
--- a/app/Actions/Workspace/CreateWorkspace.php
+++ b/app/Actions/Workspace/CreateWorkspace.php
@@ -19,8 +19,7 @@ class CreateWorkspace
'name' => data_get($data, 'name'),
'brand_website' => data_get($data, 'brand_website'),
'brand_description' => data_get($data, 'brand_description'),
- 'brand_tone' => data_get($data, 'brand_tone'),
- 'brand_voice_notes' => data_get($data, 'brand_voice_notes'),
+ 'brand_voice_traits' => data_get($data, 'brand_voice_traits'),
'brand_color' => data_get($data, 'brand_color'),
'background_color' => data_get($data, 'background_color'),
'text_color' => data_get($data, 'text_color'),
diff --git a/app/Ai/Agents/BrandAnalyzer.php b/app/Ai/Agents/BrandAnalyzer.php
index e7dfd531f..124b1f798 100644
--- a/app/Ai/Agents/BrandAnalyzer.php
+++ b/app/Ai/Agents/BrandAnalyzer.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Ai\Agents;
+use App\Enums\Workspace\BrandVoiceTrait;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Ai\Contracts\Agent;
use Laravel\Ai\Contracts\HasStructuredOutput;
@@ -16,7 +17,10 @@ class BrandAnalyzer implements Agent, HasStructuredOutput
public function instructions(): string
{
- return view('prompts.brand_analyzer')->render();
+ return view('prompts.brand_analyzer', [
+ 'voice_groups' => BrandVoiceTrait::grouped(),
+ 'single_select_groups' => BrandVoiceTrait::singleSelectGroups(),
+ ])->render();
}
public function provider(): Lab
@@ -42,17 +46,10 @@ class BrandAnalyzer implements Agent, HasStructuredOutput
'description' => $schema->string()
->description('A concise 2-3 sentence brand description summarizing what the company does, who they serve, and what makes them unique. Written in the detected content language.')
->required(),
- 'tone' => $schema->string()
- ->enum(['professional', 'casual', 'friendly', 'bold', 'inspirational', 'humorous', 'educational'])
- ->description('The tone of voice the brand uses in their content.')
- ->required(),
'language' => $schema->string()
->enum(['en', 'pt-BR', 'es'])
->description('The primary language of the content.')
->required(),
- 'voice_notes' => $schema->string()
- ->description('2-3 sentences of concrete writing guidelines inferred from the site style (e.g. "Use technical but approachable language", "Avoid marketing buzzwords"). Written in the detected content language.')
- ->required(),
'brand_color' => $schema->string()
->description('The primary brand color as a hex string starting with # (e.g. "#0ea5e9"). Pick the most prominent accent color used in CTAs, links, or logos. Return empty string if not confidently identifiable.')
->required(),
@@ -62,6 +59,10 @@ class BrandAnalyzer implements Agent, HasStructuredOutput
'text_color' => $schema->string()
->description('The dominant body text color as a hex string starting with # (e.g. "#0f172a"). Return empty string if not confidently identifiable.')
->required(),
+ 'voice_traits' => $schema->array()
+ ->items($schema->string()->enum(BrandVoiceTrait::values()))
+ ->description('Brand voice traits inferred from the site, using only the allowed values. Pick AT MOST ONE per single-select dimension (point of view, formality, energy, humor, attitude, warmth, confidence) and any number of style traits. See the instructions for the groups and what each value means.')
+ ->required(),
];
}
}
diff --git a/app/Ai/Agents/Concerns/ResolvesPlatformCopyBudget.php b/app/Ai/Agents/Concerns/ResolvesPlatformCopyBudget.php
new file mode 100644
index 000000000..c22797ec9
--- /dev/null
+++ b/app/Ai/Agents/Concerns/ResolvesPlatformCopyBudget.php
@@ -0,0 +1,35 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Ai\Agents\Concerns;
+
+use App\Enums\PostPlatform\ContentType;
+
+trait ResolvesPlatformCopyBudget
+{
+ /**
+ * Resolve the per-platform copy budget for a content-type string so every
+ * agent that writes OR rewrites post text honours the same character caps.
+ * Returns nulls when the platform is unknown, leaving the prompt
+ * platform-agnostic.
+ *
+ * @return array{hard_max_chars: ?int, target_chars: ?int, platform_label: ?string}
+ */
+ protected function platformCopyBudget(?string $platformContext): array
+ {
+ $contentType = $platformContext !== null ? ContentType::tryFrom($platformContext) : null;
+
+ if (! $contentType instanceof ContentType) {
+ return ['hard_max_chars' => null, 'target_chars' => null, 'platform_label' => null];
+ }
+
+ $platform = $contentType->platform();
+
+ return [
+ 'hard_max_chars' => $platform->maxContentLength(),
+ 'target_chars' => $platform->recommendedAiContentLength(),
+ 'platform_label' => $platform->label(),
+ ];
+ }
+}
diff --git a/app/Ai/Agents/PostContentGenerator.php b/app/Ai/Agents/PostContentGenerator.php
index 2c86e3bc1..cb9c09b23 100644
--- a/app/Ai/Agents/PostContentGenerator.php
+++ b/app/Ai/Agents/PostContentGenerator.php
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace App\Ai\Agents;
-use App\Enums\PostPlatform\ContentType;
+use App\Ai\Agents\Concerns\ResolvesPlatformCopyBudget;
use App\Models\Workspace;
use App\Services\Ai\TemplateContextResolver;
use Illuminate\Contracts\JsonSchema\JsonSchema;
@@ -18,6 +18,7 @@ use Laravel\Ai\Promptable;
class PostContentGenerator implements Agent, HasStructuredOutput
{
use Promptable;
+ use ResolvesPlatformCopyBudget;
public function __construct(
public Workspace $workspace,
@@ -25,6 +26,7 @@ class PostContentGenerator implements Agent, HasStructuredOutput
public string $format = 'single',
public int $slideCount = 1,
public ?string $platformContext = null,
+ public bool $applyBrandVoice = true,
) {}
public function instructions(): string
@@ -46,30 +48,20 @@ class PostContentGenerator implements Agent, HasStructuredOutput
// Two budgets: the platform's HARD cap (must never exceed — would break
// publishing) and the recommended SWEET SPOT length (what well-performing
// posts actually look like, way below the hard cap on most platforms).
- $hardMaxChars = null;
- $targetChars = null;
- $platformLabel = null;
- $contentType = $this->platformContext ? ContentType::tryFrom($this->platformContext) : null;
- if ($contentType) {
- $platform = $contentType->platform();
- $hardMaxChars = $platform->maxContentLength();
- $targetChars = $platform->recommendedAiContentLength();
- $platformLabel = $platform->label();
- }
+ $budget = $this->platformCopyBudget($this->platformContext);
return view('prompts.post_content.generator', [
'brand_name' => $this->workspace->name ?? '',
- 'brand_description' => $this->workspace->brand_description ?? '',
- 'brand_tone' => $this->workspace->brand_tone ?? '',
- 'brand_voice_notes' => $this->workspace->brand_voice_notes ?? '',
+ 'brand_description' => $this->applyBrandVoice ? ($this->workspace->brand_description ?? '') : '',
+ 'brand_voice_traits' => $this->applyBrandVoice ? ($this->workspace->brand_voice_traits ?? []) : [],
'content_language' => $this->workspace->content_language,
'current_content' => $this->currentContent,
'format' => $this->format,
'slide_count' => $this->slideCount,
'examples' => $examples,
- 'hard_max_chars' => $hardMaxChars,
- 'target_chars' => $targetChars,
- 'platform_label' => $platformLabel,
+ 'hard_max_chars' => $budget['hard_max_chars'],
+ 'target_chars' => $budget['target_chars'],
+ 'platform_label' => $budget['platform_label'],
])->render();
}
diff --git a/app/Ai/Agents/PostContentHumanizer.php b/app/Ai/Agents/PostContentHumanizer.php
index d0dfd7a23..4eba6f5c6 100644
--- a/app/Ai/Agents/PostContentHumanizer.php
+++ b/app/Ai/Agents/PostContentHumanizer.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Ai\Agents;
+use App\Ai\Agents\Concerns\ResolvesPlatformCopyBudget;
use App\Models\Workspace;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Ai\Attributes\Temperature;
@@ -22,20 +23,30 @@ use Laravel\Ai\Promptable;
class PostContentHumanizer implements Agent, HasStructuredOutput
{
use Promptable;
+ use ResolvesPlatformCopyBudget;
public function __construct(
public Workspace $workspace,
public string $format = 'single',
+ public ?string $platformContext = null,
+ public bool $applyBrandVoice = true,
) {}
public function instructions(): string
{
+ // The generator already wrote within the platform's character cap; the
+ // humanizer must preserve it, so it gets the same budget — otherwise the
+ // rewrite can drift past the limit the generator respected.
+ $budget = $this->platformCopyBudget($this->platformContext);
+
return view('prompts.post_content.humanizer', [
'brand_name' => $this->workspace->name ?? '',
- 'brand_tone' => $this->workspace->brand_tone ?? '',
- 'brand_voice_notes' => $this->workspace->brand_voice_notes ?? '',
+ 'brand_voice_traits' => $this->applyBrandVoice ? ($this->workspace->brand_voice_traits ?? []) : [],
'content_language' => $this->workspace->content_language,
'format' => $this->format,
+ 'hard_max_chars' => $budget['hard_max_chars'],
+ 'target_chars' => $budget['target_chars'],
+ 'platform_label' => $budget['platform_label'],
])->render();
}
diff --git a/app/Ai/Agents/PostContentReviewer.php b/app/Ai/Agents/PostContentReviewer.php
index 07a398555..6bf6252c0 100644
--- a/app/Ai/Agents/PostContentReviewer.php
+++ b/app/Ai/Agents/PostContentReviewer.php
@@ -25,8 +25,7 @@ class PostContentReviewer implements Agent, HasStructuredOutput
{
return view('prompts.post_content.reviewer', [
'brand_name' => $this->workspace->name ?? '',
- 'brand_tone' => $this->workspace->brand_tone ?? '',
- 'brand_voice_notes' => $this->workspace->brand_voice_notes ?? '',
+ 'brand_voice_traits' => $this->workspace->brand_voice_traits ?? [],
'content_language' => $this->workspace->content_language,
])->render();
}
diff --git a/app/Ai/Agents/PostContentStreamer.php b/app/Ai/Agents/PostContentStreamer.php
index 091fb0b76..545c8af62 100644
--- a/app/Ai/Agents/PostContentStreamer.php
+++ b/app/Ai/Agents/PostContentStreamer.php
@@ -33,8 +33,7 @@ class PostContentStreamer implements Agent
return view('prompts.post_content.generator', [
'brand_name' => $this->workspace->name ?? '',
'brand_description' => $this->workspace->brand_description ?? '',
- 'brand_tone' => $this->workspace->brand_tone ?? '',
- 'brand_voice_notes' => $this->workspace->brand_voice_notes ?? '',
+ 'brand_voice_traits' => $this->workspace->brand_voice_traits ?? [],
'content_language' => $this->workspace->content_language,
'current_content' => $this->currentContent,
'format' => 'single',
diff --git a/app/Enums/Workspace/BrandVoiceTrait.php b/app/Enums/Workspace/BrandVoiceTrait.php
new file mode 100644
index 000000000..adc8be4d2
--- /dev/null
+++ b/app/Enums/Workspace/BrandVoiceTrait.php
@@ -0,0 +1,158 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Enums\Workspace;
+
+/**
+ * Discrete brand-voice traits a workspace can toggle, replacing the old
+ * free-text `brand_voice_notes` AND the single `brand_tone` column. Stored as a
+ * JSON array of these string values (e.g. ["third_person", "balanced", "no_hype"]).
+ *
+ * Traits are organized into groups so any selection composes coherently:
+ * - the spectrum groups (pov, formality, energy, humor, attitude, warmth,
+ * confidence) are SINGLE-SELECT in the UI — mutually exclusive opposites,
+ * - the `style` group stacks freely (additive traits with no opposite).
+ *
+ * The instruction each trait maps to lives in the prompt Blade
+ * (`prompts/post_content/_voice`), never here — see the project AI conventions.
+ */
+enum BrandVoiceTrait: string
+{
+ // Point of view.
+ case FirstPerson = 'first_person';
+ case SecondPerson = 'second_person';
+ case ThirdPerson = 'third_person';
+
+ // Formality.
+ case Formal = 'formal';
+ case Balanced = 'balanced';
+ case Casual = 'casual';
+
+ // Energy.
+ case Calm = 'calm';
+ case Moderate = 'moderate';
+ case Enthusiastic = 'enthusiastic';
+ case Vibrant = 'vibrant';
+
+ // Humor.
+ case Serious = 'serious';
+ case Dry = 'dry';
+ case Witty = 'witty';
+ case Playful = 'playful';
+
+ // Attitude.
+ case Respectful = 'respectful';
+ case EvenHanded = 'even_handed';
+ case Bold = 'bold';
+ case Provocative = 'provocative';
+
+ // Warmth.
+ case Neutral = 'neutral';
+ case Friendly = 'friendly';
+ case Empathetic = 'empathetic';
+
+ // Confidence.
+ case Humble = 'humble';
+ case Confident = 'confident';
+ case Assertive = 'assertive';
+
+ // Additive style traits (stack freely).
+ case Direct = 'direct';
+ case Concise = 'concise';
+ case Transparent = 'transparent';
+ case NoHype = 'no_hype';
+ case Practical = 'practical';
+ case DataDriven = 'data_driven';
+ case Storytelling = 'storytelling';
+ case Inspirational = 'inspirational';
+ case Educational = 'educational';
+ case Technical = 'technical';
+ case Minimalist = 'minimalist';
+
+ /**
+ * UI grouping. Every group except `style` is single-select (mutually
+ * exclusive opposites); `style` traits stack.
+ */
+ public function group(): string
+ {
+ return match ($this) {
+ self::FirstPerson, self::SecondPerson, self::ThirdPerson => 'pov',
+ self::Formal, self::Balanced, self::Casual => 'formality',
+ self::Calm, self::Moderate, self::Enthusiastic, self::Vibrant => 'energy',
+ self::Serious, self::Dry, self::Witty, self::Playful => 'humor',
+ self::Respectful, self::EvenHanded, self::Bold, self::Provocative => 'attitude',
+ self::Neutral, self::Friendly, self::Empathetic => 'warmth',
+ self::Humble, self::Confident, self::Assertive => 'confidence',
+ default => 'style',
+ };
+ }
+
+ /**
+ * Groups whose options are mutually exclusive (rendered single-select).
+ *
+ * @return array<int, string>
+ */
+ public static function singleSelectGroups(): array
+ {
+ return ['pov', 'formality', 'energy', 'humor', 'attitude', 'warmth', 'confidence'];
+ }
+
+ /**
+ * @return array<int, string>
+ */
+ public static function values(): array
+ {
+ return array_map(fn (self $t) => $t->value, self::cases());
+ }
+
+ /**
+ * Reduces arbitrary values (e.g. an LLM's guess) to a coherent selection:
+ * only valid traits, and at most one per single-select dimension. Style
+ * traits stack. Order is preserved.
+ *
+ * @param array<int, mixed> $values
+ * @return array<int, string>
+ */
+ public static function coerce(array $values): array
+ {
+ $single = self::singleSelectGroups();
+ $usedGroups = [];
+ $result = [];
+
+ foreach ($values as $value) {
+ $trait = is_string($value) ? self::tryFrom($value) : null;
+ if ($trait === null) {
+ continue;
+ }
+
+ $group = $trait->group();
+ if (in_array($group, $single, true)) {
+ if (isset($usedGroups[$group])) {
+ continue;
+ }
+ $usedGroups[$group] = true;
+ }
+
+ $result[] = $trait->value;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Trait values keyed by group, in declaration order — drives the brand
+ * form's grouped pill picker.
+ *
+ * @return array<string, array<int, string>>
+ */
+ public static function grouped(): array
+ {
+ $grouped = [];
+ foreach (self::cases() as $trait) {
+ $grouped[$trait->group()][] = $trait->value;
+ }
+
+ return $grouped;
+ }
+}
diff --git a/app/Http/Controllers/App/WorkspaceController.php b/app/Http/Controllers/App/WorkspaceController.php
index 2721de9a6..d670c8e02 100644
--- a/app/Http/Controllers/App/WorkspaceController.php
+++ b/app/Http/Controllers/App/WorkspaceController.php
@@ -8,6 +8,7 @@ use App\Actions\Ai\AutofillBrand;
use App\Actions\Workspace\CreateWorkspace;
use App\Actions\Workspace\DeleteWorkspace;
use App\Enums\Workspace\BrandFont;
+use App\Enums\Workspace\BrandVoiceTrait;
use App\Enums\Workspace\ImageStyle;
use App\Http\Requests\App\Workspace\StoreWorkspaceRequest;
use App\Http\Requests\App\Workspace\UpdateWorkspaceRequest;
@@ -81,6 +82,7 @@ class WorkspaceController extends Controller
return Inertia::render('workspaces/Create', [
'availableFonts' => BrandFont::values(),
'availableImageStyles' => ImageStyle::values(),
+ 'availableVoiceTraits' => BrandVoiceTrait::grouped(),
]);
}
@@ -178,6 +180,7 @@ class WorkspaceController extends Controller
'workspace' => $workspace,
'availableFonts' => BrandFont::values(),
'availableImageStyles' => ImageStyle::values(),
+ 'availableVoiceTraits' => BrandVoiceTrait::grouped(),
]);
}
diff --git a/app/Http/Requests/App/Automations/UpdateAutomationRequest.php b/app/Http/Requests/App/Automations/UpdateAutomationRequest.php
index 689c85dc9..2257fd242 100644
--- a/app/Http/Requests/App/Automations/UpdateAutomationRequest.php
+++ b/app/Http/Requests/App/Automations/UpdateAutomationRequest.php
@@ -121,6 +121,17 @@ class UpdateAutomationRequest extends FormRequest
NodeType::Trigger->value => [
'trigger_type' => ['required', Rule::in(array_column(TriggerType::cases(), 'value'))],
'cron' => ['required_if:nodes.*.data.trigger_type,'.TriggerType::Schedule->value, 'string'],
+ 'schedule_field' => ['sometimes', Rule::in(['minutes', 'hours', 'days', 'weeks', 'months', 'custom'])],
+ 'schedule_minutes_interval' => ['sometimes', 'integer', 'min:1', 'max:59'],
+ 'schedule_hours_interval' => ['sometimes', 'integer', 'min:1', 'max:23'],
+ 'schedule_days_interval' => ['sometimes', 'integer', 'min:1', 'max:31'],
+ 'schedule_hour' => ['sometimes', 'integer', 'min:0', 'max:23'],
+ 'schedule_minute' => ['sometimes', 'integer', 'min:0', 'max:59'],
+ 'schedule_weekdays' => ['sometimes', 'array'],
+ 'schedule_weekdays.*' => ['integer', 'min:0', 'max:6'],
+ 'schedule_day_of_month' => ['sometimes', 'integer', 'min:1', 'max:31'],
+ 'schedule_custom_cron' => ['sometimes', 'nullable', 'string'],
+ 'schedule_timezone' => ['sometimes', 'string', 'timezone'],
],
NodeType::FetchRss->value => [
'feed_url' => ['required', 'url'],
@@ -143,7 +154,9 @@ class UpdateAutomationRequest extends FormRequest
NodeType::Generate->value => [
'accounts' => ['required', 'array', 'min:1'],
'prompt_template' => ['required', 'string'],
- 'target_slide_count' => ['nullable', 'integer', 'min:1', 'max:'.GenerateNodeValidator::MAX_GENERATED_IMAGES],
+ 'target_slide_count' => ['nullable', 'integer', 'min:0', 'max:'.GenerateNodeValidator::MAX_GENERATED_IMAGES],
+ 'use_brand_voice' => ['sometimes', 'boolean'],
+ 'use_brand_visuals' => ['sometimes', 'boolean'],
],
NodeType::Delay->value => [
'duration' => ['required', 'integer', 'min:1'],
diff --git a/app/Http/Requests/App/Workspace/StoreWorkspaceRequest.php b/app/Http/Requests/App/Workspace/StoreWorkspaceRequest.php
index 74beb136c..2a6711a80 100644
--- a/app/Http/Requests/App/Workspace/StoreWorkspaceRequest.php
+++ b/app/Http/Requests/App/Workspace/StoreWorkspaceRequest.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Http\Requests\App\Workspace;
use App\Enums\Workspace\BrandFont;
+use App\Enums\Workspace\BrandVoiceTrait;
use App\Enums\Workspace\ImageStyle;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
@@ -24,8 +25,8 @@ class StoreWorkspaceRequest extends FormRequest
'name' => ['required', 'string', 'max:255'],
'brand_website' => ['nullable', 'url', 'max:255'],
'brand_description' => ['nullable', 'string', 'max:2000'],
- 'brand_tone' => ['nullable', 'string', 'in:professional,casual,friendly,bold,inspirational,humorous,educational'],
- 'brand_voice_notes' => ['nullable', 'string', 'max:2000'],
+ 'brand_voice_traits' => ['nullable', 'array'],
+ 'brand_voice_traits.*' => ['string', Rule::enum(BrandVoiceTrait::class)],
'brand_color' => $hex,
'background_color' => $hex,
'text_color' => $hex,
diff --git a/app/Http/Requests/App/Workspace/UpdateWorkspaceRequest.php b/app/Http/Requests/App/Workspace/UpdateWorkspaceRequest.php
index 405149429..f2b6cc777 100644
--- a/app/Http/Requests/App/Workspace/UpdateWorkspaceRequest.php
+++ b/app/Http/Requests/App/Workspace/UpdateWorkspaceRequest.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Http\Requests\App\Workspace;
use App\Enums\Workspace\BrandFont;
+use App\Enums\Workspace\BrandVoiceTrait;
use App\Enums\Workspace\ImageStyle;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
@@ -24,8 +25,8 @@ class UpdateWorkspaceRequest extends FormRequest
'name' => ['required', 'string', 'max:255'],
'brand_website' => ['nullable', 'url', 'max:255'],
'brand_description' => ['nullable', 'string', 'max:2000'],
- 'brand_tone' => ['nullable', 'string', 'in:professional,casual,friendly,bold,inspirational,humorous,educational'],
- 'brand_voice_notes' => ['nullable', 'string', 'max:2000'],
+ 'brand_voice_traits' => ['nullable', 'array'],
+ 'brand_voice_traits.*' => ['string', Rule::enum(BrandVoiceTrait::class)],
'brand_color' => $hex,
'background_color' => $hex,
'text_color' => $hex,
diff --git a/app/Jobs/Ai/StreamPostCreation.php b/app/Jobs/Ai/StreamPostCreation.php
index 2ea08d988..7d45f776c 100644
--- a/app/Jobs/Ai/StreamPostCreation.php
+++ b/app/Jobs/Ai/StreamPostCreation.php
@@ -139,7 +139,7 @@ class StreamPostCreation implements ShouldQueue
'image_body' => data_get($structured, 'image_body', ''),
];
- $humanizer = new PostContentHumanizer($workspace, $format);
+ $humanizer = new PostContentHumanizer($workspace, $format, platformContext: $this->format);
$response = $humanizer->prompt(json_encode($input, JSON_UNESCAPED_UNICODE));
$humanized = $response->structured ?? [];
diff --git a/app/Models/Workspace.php b/app/Models/Workspace.php
index 470bea53a..13981bc70 100644
--- a/app/Models/Workspace.php
+++ b/app/Models/Workspace.php
@@ -26,8 +26,7 @@ class Workspace extends Model
'name',
'brand_website',
'brand_description',
- 'brand_tone',
- 'brand_voice_notes',
+ 'brand_voice_traits',
'brand_color',
'background_color',
'text_color',
@@ -40,6 +39,7 @@ class Workspace extends Model
{
return [
'image_style' => ImageStyle::class,
+ 'brand_voice_traits' => 'array',
];
}
diff --git a/app/Services/Automation/GenerateNodeValidator.php b/app/Services/Automation/GenerateNodeValidator.php
index 750dbf92f..e04991b2e 100644
--- a/app/Services/Automation/GenerateNodeValidator.php
+++ b/app/Services/Automation/GenerateNodeValidator.php
@@ -32,7 +32,8 @@ final class GenerateNodeValidator
return null;
}
- $imageCount = $this->intendedImageCount($config, $accounts);
+ // Single source of truth: 0 = text-only, 1 = single image, 2+ = carousel.
+ $imageCount = (int) data_get($config, 'target_slide_count', 1);
foreach ($accounts as $entry) {
$contentType = ContentType::tryFrom((string) data_get($entry, 'content_type'));
@@ -51,26 +52,6 @@ final class GenerateNodeValidator
return null;
}
- /**
- * Mirrors the frontend: the carousel slide count when any selected account
- * supports multiple images, otherwise a single image when enabled.
- *
- * @param array<string, mixed> $config
- * @param array<int, mixed> $accounts
- */
- private function intendedImageCount(array $config, array $accounts): int
- {
- foreach ($accounts as $entry) {
- $contentType = ContentType::tryFrom((string) data_get($entry, 'content_type'));
-
- if ($contentType instanceof ContentType && $contentType->supportsImage() && $contentType->maxMediaCount() > 1) {
- return (int) data_get($config, 'target_slide_count', 2);
- }
- }
-
- return (bool) data_get($config, 'include_image', true) ? 1 : 0;
- }
-
private function issueForAccount(ContentType $contentType, int $imageCount): ?string
{
if ($contentType->requiresMedia() && $imageCount === 0) {
diff --git a/app/Services/Brand/BrandMetadata.php b/app/Services/Brand/BrandMetadata.php
index 112f09077..93d4f33bf 100644
--- a/app/Services/Brand/BrandMetadata.php
+++ b/app/Services/Brand/BrandMetadata.php
@@ -6,16 +6,18 @@ namespace App\Services\Brand;
final readonly class BrandMetadata
{
+ /**
+ * @param array<int, string> $voiceTraits
+ */
public function __construct(
public ?string $name = null,
public ?string $description = null,
public ?string $language = null,
- public ?string $tone = null,
- public ?string $voiceNotes = null,
public ?string $logoUrl = null,
public ?string $brandColor = null,
public ?string $backgroundColor = null,
public ?string $textColor = null,
+ public array $voiceTraits = [],
) {}
public function mergeLlm(LlmBrandAnalysis $llm): self
@@ -24,8 +26,6 @@ final readonly class BrandMetadata
name: $llm->name ?: $this->name,
description: $llm->description ?: $this->description,
language: $llm->language ?: $this->language,
- tone: $llm->tone ?: null,
- voiceNotes: $llm->voiceNotes ?: null,
logoUrl: $this->logoUrl,
// Prefer deterministically-extracted colors (theme-color meta, CSS
// custom properties, body rules) — the LLM only sees stripped
@@ -33,6 +33,7 @@ final readonly class BrandMetadata
brandColor: $this->brandColor ?: ($llm->brandColor ?: null),
backgroundColor: $this->backgroundColor ?: ($llm->backgroundColor ?: null),
textColor: $this->textColor ?: ($llm->textColor ?: null),
+ voiceTraits: $llm->voiceTraits ?: $this->voiceTraits,
);
}
@@ -42,12 +43,11 @@ final readonly class BrandMetadata
name: $this->name,
description: $this->description,
language: $this->language,
- tone: $this->tone,
- voiceNotes: $this->voiceNotes,
logoUrl: $logoUrl,
brandColor: $this->brandColor,
backgroundColor: $this->backgroundColor,
textColor: $this->textColor,
+ voiceTraits: $this->voiceTraits,
);
}
@@ -57,12 +57,11 @@ final readonly class BrandMetadata
name: $this->name,
description: $this->description,
language: $this->language,
- tone: $this->tone,
- voiceNotes: $this->voiceNotes,
logoUrl: $this->logoUrl,
brandColor: $brandColor,
backgroundColor: $this->backgroundColor,
textColor: $this->textColor,
+ voiceTraits: $this->voiceTraits,
);
}
@@ -73,7 +72,7 @@ final readonly class BrandMetadata
* For AI image generation we swap them: page text (usually dark) becomes
* image background, and page background (usually light) becomes in-image text.
*
- * @return array{name: ?string, brand_description: ?string, content_language: ?string, brand_tone: ?string, brand_voice_notes: ?string, brand_color: ?string, background_color: ?string, text_color: ?string, logo_url: ?string}
+ * @return array{name: ?string, brand_description: ?string, content_language: ?string, brand_color: ?string, background_color: ?string, text_color: ?string, logo_url: ?string, brand_voice_traits: array<int, string>}
*/
public function toArray(): array
{
@@ -81,12 +80,11 @@ final readonly class BrandMetadata
'name' => $this->name,
'brand_description' => $this->description,
'content_language' => $this->language,
- 'brand_tone' => $this->tone,
- 'brand_voice_notes' => $this->voiceNotes,
'brand_color' => $this->brandColor,
'background_color' => $this->textColor,
'text_color' => $this->backgroundColor,
'logo_url' => $this->logoUrl,
+ 'brand_voice_traits' => $this->voiceTraits,
];
}
}
diff --git a/app/Services/Brand/LlmBrandAnalysis.php b/app/Services/Brand/LlmBrandAnalysis.php
index 5fa5b1a27..33dc7aa07 100644
--- a/app/Services/Brand/LlmBrandAnalysis.php
+++ b/app/Services/Brand/LlmBrandAnalysis.php
@@ -4,32 +4,36 @@ declare(strict_types=1);
namespace App\Services\Brand;
+use App\Enums\Workspace\BrandVoiceTrait;
use ArrayAccess;
final readonly class LlmBrandAnalysis
{
+ /**
+ * @param array<int, string> $voiceTraits
+ */
public function __construct(
public string $name = '',
public string $description = '',
- public string $tone = '',
public string $language = '',
- public string $voiceNotes = '',
public string $brandColor = '',
public string $backgroundColor = '',
public string $textColor = '',
+ public array $voiceTraits = [],
) {}
public static function fromResponse(ArrayAccess|array $response): self
{
+ $traits = data_get($response, 'voice_traits', []);
+
return new self(
name: trim((string) data_get($response, 'name', '')),
description: trim((string) data_get($response, 'description', '')),
- tone: trim((string) data_get($response, 'tone', '')),
language: trim((string) data_get($response, 'language', '')),
- voiceNotes: trim((string) data_get($response, 'voice_notes', '')),
brandColor: self::normalizeHex((string) data_get($response, 'brand_color', '')),
backgroundColor: self::normalizeHex((string) data_get($response, 'background_color', '')),
textColor: self::normalizeHex((string) data_get($response, 'text_color', '')),
+ voiceTraits: BrandVoiceTrait::coerce(is_array($traits) ? $traits : []),
);
}
diff --git a/app/Services/Image/PostImagePipeline.php b/app/Services/Image/PostImagePipeline.php
index d09d18154..eb5b43365 100644
--- a/app/Services/Image/PostImagePipeline.php
+++ b/app/Services/Image/PostImagePipeline.php
@@ -25,7 +25,7 @@ class PostImagePipeline
* @param array<string, mixed> $structured
* @return array<int, array<string, mixed>>
*/
- public function forSingle(Workspace $workspace, SocialAccount $account, array $structured, ?ContentType $contentType): array
+ public function forSingle(Workspace $workspace, SocialAccount $account, array $structured, ?ContentType $contentType, bool $applyBrandVisuals = true): array
{
['width' => $width, 'height' => $height] = $this->dimensionsForContentType($contentType);
@@ -37,6 +37,7 @@ class PostImagePipeline
imageKeywords: data_get($structured, 'image_keywords', []),
width: $width,
height: $height,
+ applyBrandVisuals: $applyBrandVisuals,
);
if (! $rendered) {
@@ -53,7 +54,7 @@ class PostImagePipeline
* @param array<string, mixed> $structured
* @return array<int, array<string, mixed>>
*/
- public function forCarousel(Workspace $workspace, SocialAccount $account, array $structured, ?ContentType $contentType): array
+ public function forCarousel(Workspace $workspace, SocialAccount $account, array $structured, ?ContentType $contentType, bool $applyBrandVisuals = true): array
{
['width' => $width, 'height' => $height] = $this->dimensionsForContentType($contentType);
@@ -68,6 +69,7 @@ class PostImagePipeline
imageKeywords: data_get($slide, 'image_keywords', []),
width: $width,
height: $height,
+ applyBrandVisuals: $applyBrandVisuals,
);
if ($rendered) {
diff --git a/app/Services/Image/TemplateImageGenerator.php b/app/Services/Image/TemplateImageGenerator.php
index a33a424ef..4f5d0fbdf 100644
--- a/app/Services/Image/TemplateImageGenerator.php
+++ b/app/Services/Image/TemplateImageGenerator.php
@@ -51,6 +51,7 @@ class TemplateImageGenerator
int $width = self::DEFAULT_WIDTH,
int $height = self::DEFAULT_HEIGHT,
?string $backgroundPath = null,
+ bool $applyBrandVisuals = true,
): ?array {
$this->width = $width;
$this->height = $height;
@@ -64,6 +65,14 @@ class TemplateImageGenerator
};
$language = $workspace->content_language;
+ // When brand visuals are off (e.g. faithful curation), the AI background
+ // is generated without brand colours or identity — neutral imagery driven
+ // only by the post's own keywords.
+ $brandColor = $applyBrandVisuals ? $workspace->brand_color : null;
+ $backgroundColor = $applyBrandVisuals ? $workspace->background_color : null;
+ $textColor = $applyBrandVisuals ? $workspace->text_color : null;
+ $brandDescription = $applyBrandVisuals ? $workspace->brand_description : null;
+
$generatedNewBackground = false;
$resolvedBackgroundPath = null;
$imageData = null;
@@ -79,10 +88,10 @@ class TemplateImageGenerator
style: $imageStyle,
orientation: $orientation,
language: $language,
- brandColor: $workspace->brand_color,
- backgroundColor: $workspace->background_color,
- textColor: $workspace->text_color,
- brandDescription: $workspace->brand_description,
+ brandColor: $brandColor,
+ backgroundColor: $backgroundColor,
+ textColor: $textColor,
+ brandDescription: $brandDescription,
);
if ($imageData === null) {
@@ -134,9 +143,9 @@ class TemplateImageGenerator
'body' => $body,
'width' => $this->width,
'height' => $this->height,
- 'brand_color' => $workspace->brand_color,
- 'background_color' => $workspace->background_color,
- 'text_color' => $workspace->text_color,
+ 'brand_color' => $brandColor,
+ 'background_color' => $backgroundColor,
+ 'text_color' => $textColor,
'background_path' => $resolvedBackgroundPath,
],
];
diff --git a/database/factories/WorkspaceFactory.php b/database/factories/WorkspaceFactory.php
index 3e9de50fa..5c4615bd3 100644
--- a/database/factories/WorkspaceFactory.php
+++ b/database/factories/WorkspaceFactory.php
@@ -25,7 +25,7 @@ class WorkspaceFactory extends Factory
'user_id' => User::factory(),
'name' => fake()->company(),
'content_language' => 'en',
- 'brand_tone' => 'professional',
+ 'brand_voice_traits' => ['balanced', 'direct'],
'brand_font' => 'Inter',
'image_style' => 'cinematic',
];
diff --git a/database/migrations/2026_06_12_155847_replace_brand_voice_notes_with_traits_on_workspaces.php b/database/migrations/2026_06_12_155847_replace_brand_voice_notes_with_traits_on_workspaces.php
new file mode 100644
index 000000000..b057669e8
--- /dev/null
+++ b/database/migrations/2026_06_12_155847_replace_brand_voice_notes_with_traits_on_workspaces.php
@@ -0,0 +1,30 @@
+<?php
+
+declare(strict_types=1);
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ public function up(): void
+ {
+ Schema::table('workspaces', function (Blueprint $table) {
+ // Structured brand voice — a JSON array of BrandVoiceTrait values
+ // (e.g. ["third_person", "balanced", "no_hype"]), replacing BOTH the
+ // free-text `brand_voice_notes` and the single `brand_tone` column.
+ $table->json('brand_voice_traits')->nullable()->after('brand_description');
+ $table->dropColumn(['brand_voice_notes', 'brand_tone']);
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('workspaces', function (Blueprint $table) {
+ $table->dropColumn('brand_voice_traits');
+ $table->string('brand_tone')->default('professional')->after('brand_description');
+ $table->text('brand_voice_notes')->nullable()->after('brand_tone');
+ });
+ }
+};
diff --git a/lang/en/automations.php b/lang/en/automations.php
index 1d3001678..7ef2f79d4 100644
--- a/lang/en/automations.php
+++ b/lang/en/automations.php
@@ -162,7 +162,6 @@ return [
'invalid_json' => 'This isn’t valid JSON yet.',
'expand_editor' => 'Expand editor',
'minimize_editor' => 'Minimize',
- 'editing_in_panel' => 'Editing in the side panel',
'trigger' => [
'type' => 'Trigger type',
@@ -218,8 +217,12 @@ return [
'target_slide_count' => 'Slides to generate',
'prompt_template' => 'Prompt template',
'prompt_template_hint' => 'Type {{ to insert data from earlier steps.',
- 'include_image' => 'Include image',
- 'include_image_hint' => 'Generate an AI image for this post',
+ 'image_count' => 'Images to generate',
+ 'image_count_hint' => '0 = text-only post (no image). 1 = single image. 2+ = carousel.',
+ 'use_brand_voice' => 'Use brand voice',
+ 'use_brand_voice_hint' => 'Apply your brand description and voice. Turn off for faithful curation of third-party sources (news, RSS).',
+ 'use_brand_visuals' => 'Use brand visuals',
+ 'use_brand_visuals_hint' => 'Steer AI images with your brand colors and identity. Turn off for neutral imagery driven only by the post topic.',
],
'delay' => [
'duration' => 'Duration',
diff --git a/lang/en/settings.php b/lang/en/settings.php
index dae4a7a35..cb0b29ea5 100644
--- a/lang/en/settings.php
+++ b/lang/en/settings.php
@@ -151,16 +151,55 @@ return [
'website_placeholder' => 'https://yourbrand.com',
'brand_description' => 'Description',
'brand_description_placeholder' => 'Tell us about your brand, what you do, and who your audience is...',
- 'tone' => 'Tone of voice',
- 'tone_professional' => 'Professional',
- 'tone_casual' => 'Casual',
- 'tone_friendly' => 'Friendly',
- 'tone_bold' => 'Bold',
- 'tone_inspirational' => 'Inspirational',
- 'tone_humorous' => 'Humorous',
- 'tone_educational' => 'Educational',
- 'voice_notes' => 'Voice notes',
- 'voice_notes_placeholder' => 'Additional writing guidelines, words to avoid, style preferences...',
+ 'voice' => 'Brand voice',
+ 'voice_description' => 'Pick the traits that define how your content sounds.',
+ 'voice_group' => [
+ 'pov' => 'Point of view',
+ 'formality' => 'Formality',
+ 'energy' => 'Energy',
+ 'humor' => 'Humor',
+ 'attitude' => 'Attitude',
+ 'warmth' => 'Warmth',
+ 'confidence' => 'Confidence',
+ 'style' => 'Style',
+ ],
+ 'voice_trait' => [
+ 'first_person' => 'First person',
+ 'second_person' => 'Second person (you)',
+ 'third_person' => 'Third person',
+ 'formal' => 'Formal',
+ 'balanced' => 'Balanced',
+ 'casual' => 'Casual',
+ 'calm' => 'Calm',
+ 'moderate' => 'Moderate',
+ 'enthusiastic' => 'Enthusiastic',
+ 'vibrant' => 'Vibrant',
+ 'serious' => 'Serious',
+ 'dry' => 'Dry / subtle',
+ 'witty' => 'Witty',
+ 'playful' => 'Playful',
+ 'respectful' => 'Respectful',
+ 'even_handed' => 'Even-handed',
+ 'bold' => 'Bold',
+ 'provocative' => 'Provocative',
+ 'neutral' => 'Neutral',
+ 'friendly' => 'Friendly',
+ 'empathetic' => 'Empathetic',
+ 'humble' => 'Humble',
+ 'confident' => 'Confident',
+ 'assertive' => 'Assertive',
+ 'direct' => 'Direct',
+ 'concise' => 'Concise',
+ 'transparent' => 'Transparent',
+ 'no_hype' => 'No hype',
+ 'practical' => 'Practical',
+ 'data_driven' => 'Data-driven',
+ 'storytelling' => 'Storytelling',
+ 'inspirational' => 'Inspirational',
+ 'educational' => 'Educational',
+ 'technical' => 'Technical',
+ 'minimalist' => 'Few emojis',
+ ],
'brand_color' => 'Brand color',
'background_color' => 'Background color',
'text_color' => 'Text color',
diff --git a/lang/en/workspaces.php b/lang/en/workspaces.php
index 61fa5b9fd..4b0232713 100644
--- a/lang/en/workspaces.php
+++ b/lang/en/workspaces.php
@@ -33,18 +33,8 @@ return [
'name_placeholder' => 'e.g. Acme Inc',
'brand_description' => 'Brand description',
'brand_description_placeholder' => 'What does your brand do?',
- 'tone' => 'Brand tone',
- 'tone_professional' => 'Professional',
- 'tone_casual' => 'Casual',
- 'tone_friendly' => 'Friendly',
- 'tone_bold' => 'Bold',
- 'tone_inspirational' => 'Inspirational',
- 'tone_humorous' => 'Humorous',
- 'tone_educational' => 'Educational',
'content_language' => 'Content language',
'content_language_description' => 'AI-generated captions will be written in this language.',
- 'voice_notes' => 'Voice notes (optional)',
- 'voice_notes_placeholder' => 'e.g. short, punchy sentences. avoid jargon.',
'brand_color' => 'Brand color',
'background_color' => 'Background color',
'text_color' => 'Text color',
diff --git a/lang/es/automations.php b/lang/es/automations.php
index f7614eab6..66e5d7124 100644
--- a/lang/es/automations.php
+++ b/lang/es/automations.php
@@ -162,7 +162,6 @@ return [
'invalid_json' => 'Esto aún no es un JSON válido.',
'expand_editor' => 'Expandir editor',
'minimize_editor' => 'Minimizar',
- 'editing_in_panel' => 'Editando en el panel lateral',
'trigger' => [
'type' => 'Tipo de disparador',
@@ -218,8 +217,12 @@ return [
'target_slide_count' => 'Diapositivas a generar',
'prompt_template' => 'Plantilla de prompt',
'prompt_template_hint' => 'Escribe {{ para insertar datos de pasos anteriores.',
- 'include_image' => 'Incluir imagen',
- 'include_image_hint' => 'Generar una imagen con IA para esta publicación',
+ 'image_count' => 'Imágenes a generar',
+ 'image_count_hint' => '0 = post solo texto (sin imagen). 1 = imagen única. 2+ = carrusel.',
+ 'use_brand_voice' => 'Usar voz de marca',
+ 'use_brand_voice_hint' => 'Aplica la descripción y la voz de tu marca. Desactiva para curaduría fiel de fuentes de terceros (noticias, RSS).',
+ 'use_brand_visuals' => 'Usar visual de marca',
+ 'use_brand_visuals_hint' => 'Guía las imágenes de IA con los colores e identidad de tu marca. Desactiva para imágenes neutrales, guiadas solo por el tema del post.',
],
'delay' => [
'duration' => 'Duración',
diff --git a/lang/es/settings.php b/lang/es/settings.php
index 5a622b476..a93de88b9 100644
--- a/lang/es/settings.php
+++ b/lang/es/settings.php
@@ -151,16 +151,55 @@ return [
'website_placeholder' => 'https://tumarca.com',
'brand_description' => 'Descripción',
'brand_description_placeholder' => 'Cuéntanos sobre tu marca, lo que haces y quién es tu audiencia...',
- 'tone' => 'Tono de voz',
- 'tone_professional' => 'Profesional',
- 'tone_casual' => 'Casual',
- 'tone_friendly' => 'Amigable',
- 'tone_bold' => 'Audaz',
- 'tone_inspirational' => 'Inspirador',
- 'tone_humorous' => 'Humorístico',
- 'tone_educational' => 'Educativo',
- 'voice_notes' => 'Notas de voz',
- 'voice_notes_placeholder' => 'Directrices adicionales de escritura, palabras a evitar, preferencias de estilo...',
+ 'voice' => 'Voz de marca',
+ 'voice_description' => 'Elige los rasgos que definen cómo suena tu contenido.',
+ 'voice_group' => [
+ 'pov' => 'Punto de vista',
+ 'formality' => 'Formalidad',
+ 'energy' => 'Energía',
+ 'humor' => 'Humor',
+ 'attitude' => 'Actitud',
+ 'warmth' => 'Calidez',
+ 'confidence' => 'Confianza',
+ 'style' => 'Estilo',
+ ],
+ 'voice_trait' => [
+ 'first_person' => 'Primera persona',
+ 'second_person' => 'Segunda persona (tú)',
+ 'third_person' => 'Tercera persona',
+ 'formal' => 'Formal',
+ 'balanced' => 'Equilibrado',
+ 'casual' => 'Casual',
+ 'calm' => 'Calmo',
+ 'moderate' => 'Moderado',
+ 'enthusiastic' => 'Entusiasta',
+ 'vibrant' => 'Vibrante',
+ 'serious' => 'Serio',
+ 'dry' => 'Sutil / seco',
+ 'witty' => 'Ingenioso',
+ 'playful' => 'Juguetón',
+ 'respectful' => 'Respetuoso',
+ 'even_handed' => 'Equilibrado',
+ 'bold' => 'Audaz',
+ 'provocative' => 'Provocador',
+ 'neutral' => 'Neutro',
+ 'friendly' => 'Amigable',
+ 'empathetic' => 'Empático',
+ 'humble' => 'Humilde',
+ 'confident' => 'Seguro',
+ 'assertive' => 'Asertivo',
+ 'direct' => 'Directo',
+ 'concise' => 'Conciso',
+ 'transparent' => 'Transparente',
+ 'no_hype' => 'Sin hype',
+ 'practical' => 'Práctico',
+ 'data_driven' => 'Basado en datos',
+ 'storytelling' => 'Narrativo',
+ 'inspirational' => 'Inspiracional',
+ 'educational' => 'Educativo',
+ 'technical' => 'Técnico',
+ 'minimalist' => 'Pocos emojis',
+ ],
'brand_color' => 'Color de marca',
'background_color' => 'Color de fondo',
'text_color' => 'Color de texto',
diff --git a/lang/es/workspaces.php b/lang/es/workspaces.php
index b4e904e38..41b1d0872 100644
--- a/lang/es/workspaces.php
+++ b/lang/es/workspaces.php
@@ -33,18 +33,8 @@ return [
'name_placeholder' => 'ej. Acme Inc',
'brand_description' => 'Descripción de la marca',
'brand_description_placeholder' => '¿Qué hace tu marca?',
- 'tone' => 'Tono de la marca',
- 'tone_professional' => 'Profesional',
- 'tone_casual' => 'Casual',
- 'tone_friendly' => 'Amigable',
- 'tone_bold' => 'Audaz',
- 'tone_inspirational' => 'Inspirador',
- 'tone_humorous' => 'Humorístico',
- 'tone_educational' => 'Educativo',
'content_language' => 'Idioma del contenido',
'content_language_description' => 'Las descripciones generadas por IA se escribirán en este idioma.',
- 'voice_notes' => 'Notas de voz (opcional)',
- 'voice_notes_placeholder' => 'ej. frases cortas y directas. evita jerga.',
'brand_color' => 'Color de marca',
'background_color' => 'Color de fondo',
'text_color' => 'Color de texto',
diff --git a/lang/pt-BR/automations.php b/lang/pt-BR/automations.php
index 2d6f9ec47..f44b07ceb 100644
--- a/lang/pt-BR/automations.php
+++ b/lang/pt-BR/automations.php
@@ -162,7 +162,6 @@ return [
'invalid_json' => 'Isto ainda não é um JSON válido.',
'expand_editor' => 'Expandir editor',
'minimize_editor' => 'Minimizar',
- 'editing_in_panel' => 'Editando no painel ao lado',
'trigger' => [
'type' => 'Tipo de trigger',
@@ -218,8 +217,12 @@ return [
'target_slide_count' => 'Slides a gerar',
'prompt_template' => 'Template do prompt',
'prompt_template_hint' => 'Digite {{ para inserir dados das etapas anteriores.',
- 'include_image' => 'Incluir imagem',
- 'include_image_hint' => 'Gerar uma imagem com IA para esta publicação',
+ 'image_count' => 'Imagens a gerar',
+ 'image_count_hint' => '0 = post só texto (sem imagem). 1 = imagem única. 2+ = carrossel.',
+ 'use_brand_voice' => 'Usar voz da marca',
+ 'use_brand_voice_hint' => 'Aplica a descrição e a voz da sua marca. Desligue para curadoria fiel de fontes de terceiros (notícias, RSS).',
+ 'use_brand_visuals' => 'Usar visual da marca',
+ 'use_brand_visuals_hint' => 'Guia as imagens de IA com as cores e identidade da sua marca. Desligue para imagens neutras, guiadas só pelo tema do post.',
],
'delay' => [
'duration' => 'Duração',
diff --git a/lang/pt-BR/settings.php b/lang/pt-BR/settings.php
index a4da14a71..5a483f1bc 100644
--- a/lang/pt-BR/settings.php
+++ b/lang/pt-BR/settings.php
@@ -151,16 +151,55 @@ return [
'website_placeholder' => 'https://suamarca.com',
'brand_description' => 'Descrição',
'brand_description_placeholder' => 'Conte sobre sua marca, o que você faz e quem é seu público...',
- 'tone' => 'Tom de voz',
- 'tone_professional' => 'Profissional',
- 'tone_casual' => 'Casual',
- 'tone_friendly' => 'Amigável',
- 'tone_bold' => 'Ousado',
- 'tone_inspirational' => 'Inspirador',
- 'tone_humorous' => 'Bem-humorado',
- 'tone_educational' => 'Educacional',
- 'voice_notes' => 'Notas de voz',
- 'voice_notes_placeholder' => 'Diretrizes adicionais de escrita, palavras a evitar, preferências de estilo...',
+ 'voice' => 'Voz da marca',
+ 'voice_description' => 'Escolha os traços que definem como seu conteúdo soa.',
+ 'voice_group' => [
+ 'pov' => 'Ponto de vista',
+ 'formality' => 'Formalidade',
+ 'energy' => 'Energia',
+ 'humor' => 'Humor',
+ 'attitude' => 'Atitude',
+ 'warmth' => 'Calor',
+ 'confidence' => 'Confiança',
+ 'style' => 'Estilo',
+ ],
+ 'voice_trait' => [
+ 'first_person' => 'Primeira pessoa',
+ 'second_person' => 'Segunda pessoa (você)',
+ 'third_person' => 'Terceira pessoa',
+ 'formal' => 'Formal',
+ 'balanced' => 'Equilibrado',
+ 'casual' => 'Casual',
+ 'calm' => 'Calmo',
+ 'moderate' => 'Moderado',
+ 'enthusiastic' => 'Entusiasmado',
+ 'vibrant' => 'Vibrante',
+ 'serious' => 'Sério',
+ 'dry' => 'Sutil / seco',
+ 'witty' => 'Bem-humorado',
+ 'playful' => 'Brincalhão',
+ 'respectful' => 'Respeitoso',
+ 'even_handed' => 'Equilibrado',
+ 'bold' => 'Ousado',
+ 'provocative' => 'Provocador',
+ 'neutral' => 'Neutro',
+ 'friendly' => 'Amigável',
+ 'empathetic' => 'Empático',
+ 'humble' => 'Humilde',
+ 'confident' => 'Confiante',
+ 'assertive' => 'Assertivo',
+ 'direct' => 'Direto',
+ 'concise' => 'Conciso',
+ 'transparent' => 'Transparente',
+ 'no_hype' => 'Sem hype',
+ 'practical' => 'Prático',
+ 'data_driven' => 'Baseado em dados',
+ 'storytelling' => 'Narrativo',
+ 'inspirational' => 'Inspiracional',
+ 'educational' => 'Educativo',
+ 'technical' => 'Técnico',
+ 'minimalist' => 'Poucos emojis',
+ ],
'brand_color' => 'Cor da marca',
'background_color' => 'Cor de fundo',
'text_color' => 'Cor do texto',
diff --git a/lang/pt-BR/workspaces.php b/lang/pt-BR/workspaces.php
index 28fe4a936..caeabd6f8 100644
--- a/lang/pt-BR/workspaces.php
+++ b/lang/pt-BR/workspaces.php
@@ -33,18 +33,8 @@ return [
'name_placeholder' => 'ex. Acme Inc',
'brand_description' => 'Descrição da marca',
'brand_description_placeholder' => 'O que sua marca faz?',
- 'tone' => 'Tom da marca',
- 'tone_professional' => 'Profissional',
- 'tone_casual' => 'Casual',
- 'tone_friendly' => 'Amigável',
- 'tone_bold' => 'Ousado',
- 'tone_inspirational' => 'Inspirador',
- 'tone_humorous' => 'Bem-humorado',
- 'tone_educational' => 'Educacional',
'content_language' => 'Idioma do conteúdo',
'content_language_description' => 'Legendas geradas por IA serão escritas neste idioma.',
- 'voice_notes' => 'Notas de voz (opcional)',
- 'voice_notes_placeholder' => 'ex. frases curtas e diretas. sem jargão.',
'brand_color' => 'Cor da marca',
'background_color' => 'Cor de fundo',
'text_color' => 'Cor do texto',
diff --git a/package-lock.json b/package-lock.json
index 58bfa129a..6914f9d01 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -28,7 +28,7 @@
"laravel-vue-i18n": "^2.8.0",
"maska": "^3.2.0",
"posthog-js": "^1.364.2",
- "reka-ui": "^2.7.0",
+ "reka-ui": "^2.9.10",
"tailwind-merge": "^3.2.0",
"tailwindcss": "^4.1.1",
"tw-animate-css": "^1.2.5",
@@ -8663,9 +8663,9 @@
}
},
"node_modules/reka-ui": {
- "version": "2.7.0",
- "resolved": "https://registry.npmjs.org/reka-ui/-/reka-ui-2.7.0.tgz",
- "integrity": "sha512-m+XmxQN2xtFzBP3OAdIafKq7C8OETo2fqfxcIIxYmNN2Ch3r5oAf6yEYCIJg5tL/yJU2mHqF70dCCekUkrAnXA==",
+ "version": "2.9.10",
+ "resolved": "https://registry.npmjs.org/reka-ui/-/reka-ui-2.9.10.tgz",
+ "integrity": "sha512-yuvZVTp4fWH2G3qk+ze/x6YYlyc2Xl1d+eMUlIYrKqzTowBKteoDoN17fitURmqSUck3mc7JbcYgp49DnGu2EQ==",
"license": "MIT",
"dependencies": {
"@floating-ui/dom": "^1.6.13",
@@ -8673,14 +8673,56 @@
"@internationalized/date": "^3.5.0",
"@internationalized/number": "^3.5.0",
"@tanstack/vue-virtual": "^3.12.0",
- "@vueuse/core": "^12.5.0",
- "@vueuse/shared": "^12.5.0",
+ "@vueuse/core": "^14.1.0",
+ "@vueuse/shared": "^14.1.0",
"aria-hidden": "^1.2.4",
- "defu": "^6.1.4",
+ "defu": "^6.1.5",
"ohash": "^2.0.11"
},
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/zernonia"
+ },
+ "peerDependencies": {
+ "vue": ">= 3.4.0"
+ }
+ },
+ "node_modules/reka-ui/node_modules/@vueuse/core": {
+ "version": "14.3.0",
+ "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-14.3.0.tgz",
+ "integrity": "sha512-aHfz47g0ZhMtTVHmIzMVpJy8ePhhOy68GY5bv110+5DVtZ+W7BsOx+m61UNQqfrWyPztIHIanWa3E2tib3NFIw==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/web-bluetooth": "^0.0.21",
+ "@vueuse/metadata": "14.3.0",
+ "@vueuse/shared": "14.3.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/antfu"
+ },
+ "peerDependencies": {
+ "vue": "^3.5.0"
+ }
+ },
+ "node_modules/reka-ui/node_modules/@vueuse/metadata": {
+ "version": "14.3.0",
+ "resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-14.3.0.tgz",
+ "integrity": "sha512-BwxmbAzwAVF50+MW57GXOUEV61nFBGnlBvrTqj49PqWJu3uw7hdu72ztXeZ33RdZtDY6kO+bfCAE1PCn88Tktw==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/antfu"
+ }
+ },
+ "node_modules/reka-ui/node_modules/@vueuse/shared": {
+ "version": "14.3.0",
+ "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-14.3.0.tgz",
+ "integrity": "sha512-bZpge9eSXwa4ToSiqJ7j6KRwhAsneMFoSz3LMWKQDkqimm3D/tbFlrklrs/IOqC8tEcYmXQZJ6N0UrjhBirVCg==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/antfu"
+ },
"peerDependencies": {
- "vue": ">= 3.2.0"
+ "vue": "^3.5.0"
}
},
"node_modules/require-directory": {
diff --git a/package.json b/package.json
index 8486bf4f1..d8a51ec29 100644
--- a/package.json
+++ b/package.json
@@ -61,7 +61,7 @@
"laravel-vue-i18n": "^2.8.0",
"maska": "^3.2.0",
"posthog-js": "^1.364.2",
- "reka-ui": "^2.7.0",
+ "reka-ui": "^2.9.10",
"tailwind-merge": "^3.2.0",
"tailwindcss": "^4.1.1",
"tw-animate-css": "^1.2.5",
diff --git a/resources/js/components/BrandForm.vue b/resources/js/components/BrandForm.vue
index 541839d41..0b82368ff 100644
--- a/resources/js/components/BrandForm.vue
+++ b/resources/js/components/BrandForm.vue
@@ -10,6 +10,13 @@ import FontPicker from '@/components/FontPicker.vue';
import HexColorInput from '@/components/HexColorInput.vue';
import InputError from '@/components/InputError.vue';
import { Button } from '@/components/ui/button';
+import { Checkbox } from '@/components/ui/checkbox';
+import {
+ Field,
+ FieldGroup,
+ FieldLabel,
+ FieldTitle,
+} from '@/components/ui/field';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import {
@@ -26,8 +33,7 @@ interface BrandFields {
name?: string;
brand_website: string;
brand_description: string;
- brand_tone: string;
- brand_voice_notes: string;
+ brand_voice_traits: string[];
brand_color: string | null;
background_color: string | null;
text_color: string | null;
@@ -41,12 +47,11 @@ interface AutofillResponse {
name: string | null;
brand_description: string | null;
content_language: string | null;
- brand_tone: string | null;
- brand_voice_notes: string | null;
brand_color: string | null;
background_color: string | null;
text_color: string | null;
logo_url: string | null;
+ brand_voice_traits: string[] | null;
}
const props = withDefaults(
@@ -55,6 +60,7 @@ const props = withDefaults(
errors: Partial<Record<keyof BrandFields, string>>;
availableFonts: string[];
availableImageStyles: string[];
+ availableVoiceTraits: Record<string, string[]>;
autofill?: boolean;
showName?: boolean;
}>(),
@@ -68,9 +74,26 @@ const autofillHttp = useHttp<{ url: string }, AutofillResponse>({ url: '' });
const isAutofilling = ref(false);
const logoPreview = ref<string | null>(null);
-const toneLabel = computed(() =>
- props.fields.brand_tone ? trans(`settings.brand.tone_${props.fields.brand_tone}`) : '',
-);
+// Only the `style` group stacks; every spectrum group (pov, formality, …) is
+// single-select, so picking an option clears the others in that group.
+const isTraitSelected = (value: string): boolean => (props.fields.brand_voice_traits ?? []).includes(value);
+
+const toggleTrait = (group: string, value: string): void => {
+ const current = props.fields.brand_voice_traits ?? [];
+
+ if (current.includes(value)) {
+ props.fields.brand_voice_traits = current.filter((v) => v !== value);
+ return;
+ }
+
+ if (group === 'style') {
+ props.fields.brand_voice_traits = [...current, value];
+ return;
+ }
+
+ const groupValues = props.availableVoiceTraits[group] ?? [];
+ props.fields.brand_voice_traits = [...current.filter((v) => !groupValues.includes(v)), value];
+};
const languageLabel = computed(() => {
const map: Record<string, string> = {
@@ -96,8 +119,9 @@ const runAutofill = async () => {
if (data?.name && props.showName && !props.fields.name) props.fields.name = data.name;
if (data?.brand_description) props.fields.brand_description = data.brand_description;
if (data?.content_language) props.fields.content_language = data.content_language;
- if (data?.brand_tone) props.fields.brand_tone = data.brand_tone;
- if (data?.brand_voice_notes) props.fields.brand_voice_notes = data.brand_voice_notes;
+ if (data?.brand_voice_traits?.length) {
+ props.fields.brand_voice_traits = data.brand_voice_traits;
+ }
if (data?.brand_color) props.fields.brand_color = data.brand_color;
if (data?.background_color) props.fields.background_color = data.background_color;
if (data?.text_color) props.fields.text_color = data.text_color;
@@ -164,59 +188,52 @@ const runAutofill = async () => {
<InputError :message="errors.brand_description" />
</div>
- <div class="grid gap-4 sm:grid-cols-2">
- <div class="grid gap-2">
- <Label for="brand_tone">{{ $t('settings.brand.tone') }}</Label>
- <Select v-model="fields.brand_tone">
- <SelectTrigger id="brand_tone" class="w-full">
- <SelectValue :placeholder="$t('settings.brand.tone')">
- {{ toneLabel }}
- </SelectValue>
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="professional">{{ $t('settings.brand.tone_professional') }}</SelectItem>
- <SelectItem value="casual">{{ $t('settings.brand.tone_casual') }}</SelectItem>
- <SelectItem value="friendly">{{ $t('settings.brand.tone_friendly') }}</SelectItem>
- <SelectItem value="bold">{{ $t('settings.brand.tone_bold') }}</SelectItem>
- <SelectItem value="inspirational">{{ $t('settings.brand.tone_inspirational') }}</SelectItem>
- <SelectItem value="humorous">{{ $t('settings.brand.tone_humorous') }}</SelectItem>
- <SelectItem value="educational">{{ $t('settings.brand.tone_educational') }}</SelectItem>
- </SelectContent>
- </Select>
- <InputError :message="errors.brand_tone" />
- </div>
-
- <div class="grid gap-2">
- <Label for="content_language">{{ $t('settings.brand.content_language') }}</Label>
- <Select v-model="fields.content_language">
- <SelectTrigger id="content_language" class="w-full">
- <SelectValue :placeholder="$t('settings.brand.content_language')">
- {{ languageLabel }}
- </SelectValue>
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="en">English</SelectItem>
- <SelectItem value="pt-BR">Português (Brasil)</SelectItem>
- <SelectItem value="es">Español</SelectItem>
- </SelectContent>
- </Select>
- <InputError :message="errors.content_language" />
- </div>
+ <div class="grid gap-2">
+ <Label for="content_language">{{ $t('settings.brand.content_language') }}</Label>
+ <Select v-model="fields.content_language">
+ <SelectTrigger id="content_language" class="w-full">
+ <SelectValue :placeholder="$t('settings.brand.content_language')">
+ {{ languageLabel }}
+ </SelectValue>
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="en">English</SelectItem>
+ <SelectItem value="pt-BR">Português (Brasil)</SelectItem>
+ <SelectItem value="es">Español</SelectItem>
+ </SelectContent>
+ </Select>
+ <p class="text-xs font-medium text-foreground/60">
+ {{ $t('settings.brand.content_language_description') }}
+ </p>
+ <InputError :message="errors.content_language" />
</div>
- <p class="-mt-4 text-xs font-medium text-foreground/60">
- {{ $t('settings.brand.content_language_description') }}
- </p>
+ <div class="grid gap-5">
+ <div class="grid gap-1">
+ <Label>{{ $t('settings.brand.voice') }}</Label>
+ <p class="text-xs font-medium text-foreground/60">{{ $t('settings.brand.voice_description') }}</p>
+ </div>
- <div class="grid gap-2">
- <Label for="brand_voice_notes">{{ $t('settings.brand.voice_notes') }}</Label>
- <Textarea
- id="brand_voice_notes"
- v-model="fields.brand_voice_notes"
- :placeholder="$t('settings.brand.voice_notes_placeholder')"
- rows="3"
- />
- <InputError :message="errors.brand_voice_notes" />
+ <div v-for="(values, group) in availableVoiceTraits" :key="group" class="grid gap-2">
+ <Label>{{ $t(`settings.brand.voice_group.${group}`) }}</Label>
+ <FieldGroup class="flex flex-row flex-wrap gap-2 [--radius:9999rem]">
+ <FieldLabel v-for="value in values" :key="value" :for="`voice-${value}`" class="!w-fit">
+ <Field
+ orientation="horizontal"
+ class="gap-1.5 overflow-hidden !px-3 !py-1.5 transition-all duration-100 ease-linear group-has-data-[state=checked]/field-label:!px-2"
+ >
+ <Checkbox
+ :id="`voice-${value}`"
+ :model-value="isTraitSelected(value)"
+ class="-ml-6 -translate-x-1 rounded-full opacity-0 transition-all duration-100 ease-linear data-[state=checked]:ml-0 data-[state=checked]:translate-x-0 data-[state=checked]:opacity-100"
+ @update:model-value="toggleTrait(group, value)"
+ />
+ <FieldTitle>{{ $t(`settings.brand.voice_trait.${value}`) }}</FieldTitle>
+ </Field>
+ </FieldLabel>
+ </FieldGroup>
+ </div>
+ <InputError :message="errors.brand_voice_traits" />
</div>
<div class="grid gap-4 sm:grid-cols-3">
diff --git a/resources/js/components/CodeEditor.vue b/resources/js/components/CodeEditor.vue
index 486c18246..57a225f9d 100644
--- a/resources/js/components/CodeEditor.vue
+++ b/resources/js/components/CodeEditor.vue
@@ -3,7 +3,16 @@ import { autocompletion } from '@codemirror/autocomplete';
import { indentWithTab } from '@codemirror/commands';
import { json } from '@codemirror/lang-json';
import { type Extension, EditorState } from '@codemirror/state';
-import { EditorView, keymap, placeholder as placeholderExt } from '@codemirror/view';
+import {
+ Decoration,
+ type DecorationSet,
+ EditorView,
+ keymap,
+ MatchDecorator,
+ placeholder as placeholderExt,
+ ViewPlugin,
+ type ViewUpdate,
+} from '@codemirror/view';
import { IconArrowsMaximize, IconArrowsMinimize, IconCopy } from '@tabler/icons-vue';
import { basicSetup } from 'codemirror';
import { computed, inject, onBeforeUnmount, onMounted, type Ref, ref, watch } from 'vue';
@@ -18,6 +27,7 @@ import {
import {
type ExpressionSuggestion,
expressionCompletionSource,
+ isKnownExpression,
} from '@/composables/useExpressionCompletions';
import debounce from '@/debounce';
import { copyToClipboard } from '@/lib/utils';
@@ -72,6 +82,44 @@ const onKeydown = (event: KeyboardEvent): void => {
}
};
+// Paints `{{ ... }}` expressions as pills — primary-tinted when the path is
+// resolvable for this node, amber/wavy when it isn't — so they read as
+// variables and a wrong reference is obvious. Styles are inline on the mark so
+// they win over the editor theme and JSON string-token colors.
+const KNOWN_EXPR_STYLE =
+ 'background-color:color-mix(in srgb,var(--primary) 16%,transparent);color:var(--primary);border-radius:4px;padding:1px 3px;font-weight:600;';
+const UNKNOWN_EXPR_STYLE =
+ 'background-color:color-mix(in srgb,#f59e0b 18%,transparent);color:#b45309;border-radius:4px;padding:1px 3px;font-weight:600;text-decoration:underline wavy #f59e0b;';
+
+const expressionHighlighter = (() => {
+ const matcher = new MatchDecorator({
+ regexp: /\{\{\s*([\w.]+)\s*\}\}/g,
+ decoration: (match) =>
+ Decoration.mark({
+ attributes: {
+ style: isKnownExpression(match[1], expressionCompletions.value)
+ ? KNOWN_EXPR_STYLE
+ : UNKNOWN_EXPR_STYLE,
+ },
+ }),
+ });
+
+ return ViewPlugin.fromClass(
+ class {
+ decorations: DecorationSet;
+
+ constructor(view: EditorView) {
+ this.decorations = matcher.createDeco(view);
+ }
+
+ update(update: ViewUpdate) {
+ this.decorations = matcher.updateDeco(update, this.decorations);
+ }
+ },
+ { decorations: (plugin) => plugin.decorations },
+ );
+})();
+
const editorContainer = ref<HTMLElement>();
let view: EditorView | null = null;
@@ -157,6 +205,7 @@ onMounted(() => {
activateOnTyping: true,
icons: false,
}),
+ expressionHighlighter,
lightTheme,
updateListener,
];
@@ -219,19 +268,7 @@ onBeforeUnmount(() => {
<template>
<div class="group relative h-full w-full">
- <div v-show="!isExpanded" ref="editorContainer" class="code-editor h-full w-full" />
-
- <!-- While the side panel is open, the inline field collapses to a hint
- (clicking it closes the panel) instead of duplicating the editor. -->
- <button
- v-if="isExpanded"
- type="button"
- class="flex h-full w-full flex-col items-center justify-center gap-1.5 rounded-md border-2 border-dashed border-foreground/25 bg-card/40 px-3 text-center text-xs font-medium text-foreground/60 transition hover:border-foreground/40 hover:text-foreground/80"
- @click="isExpanded = false"
- >
- <IconArrowsMaximize class="size-4" stroke-width="2.5" />
- {{ $t('automations.config.editing_in_panel') }}
- </button>
+ <div ref="editorContainer" class="code-editor h-full w-full" />
<TooltipProvider :delay-duration="200">
<div
diff --git a/resources/js/components/automations/config/GenerateNodeConfig.vue b/resources/js/components/automations/config/GenerateNodeConfig.vue
index 7f7abe955..1f28b8faf 100644
--- a/resources/js/components/automations/config/GenerateNodeConfig.vue
+++ b/resources/js/components/automations/config/GenerateNodeConfig.vue
@@ -5,6 +5,7 @@ import { computed, ref, watch } from 'vue';
import ChannelConfigurator from '@/components/ChannelConfigurator.vue';
import CodeEditor from '@/components/CodeEditor.vue';
import InputError from '@/components/InputError.vue';
+import { useExpandedEditor } from '@/composables/useExpandedEditor';
import { Button } from '@/components/ui/button';
import { Label } from '@/components/ui/label';
import { Switch } from '@/components/ui/switch';
@@ -45,7 +46,8 @@ interface GenerateConfig {
accounts: GenerateAccount[];
target_slide_count: number;
prompt_template: string;
- include_image: boolean;
+ use_brand_voice: boolean;
+ use_brand_visuals: boolean;
}
const props = defineProps<{
@@ -54,6 +56,8 @@ const props = defineProps<{
}>();
const emit = defineEmits<{ update: [Record<string, unknown>] }>();
+const editorExpanded = useExpandedEditor();
+
const page = usePage();
const socialAccounts = computed<SocialAccount[]>(() => {
@@ -135,9 +139,10 @@ const normalizeAccountsFromData = (): GenerateAccount[] => {
const local = ref<GenerateConfig>({
accounts: normalizeAccountsFromData(),
- target_slide_count: (props.data.target_slide_count as number | undefined) ?? 5,
+ target_slide_count: (props.data.target_slide_count as number | undefined) ?? 1,
prompt_template: (props.data.prompt_template as string) ?? '',
- include_image: (props.data.include_image as boolean | undefined) ?? true,
+ use_brand_voice: (props.data.use_brand_voice as boolean | undefined) ?? true,
+ use_brand_visuals: (props.data.use_brand_visuals as boolean | undefined) ?? true,
});
watch(local, (val) => emit('update', val), { deep: true });
@@ -191,34 +196,24 @@ const getBoards = (account: SocialAccount): PinterestBoard[] =>
// at MAX_GENERATED_IMAGES regardless of how many a platform technically allows.
const MAX_GENERATED_IMAGES = 10;
-const multiImageAccounts = computed(() =>
- local.value.accounts.filter((a) => {
- const rules = getMediaRulesForContentType(a.content_type);
- return rules.acceptImages && rules.maxFiles > 1;
- }),
+// Highest image count any selected account accepts (0 when none accept images,
+// e.g. text-only platforms), capped at MAX_GENERATED_IMAGES.
+const imageCountCap = computed(() =>
+ Math.min(
+ MAX_GENERATED_IMAGES,
+ local.value.accounts.reduce((max, a) => {
+ const rules = getMediaRulesForContentType(a.content_type);
+ return rules.acceptImages ? Math.max(max, rules.maxFiles) : max;
+ }, 0),
+ ),
);
-const supportsMultiImage = computed(() => multiImageAccounts.value.length > 0);
-
-const imageCountCap = computed(() => {
- if (!supportsMultiImage.value) return 1;
- const maxAcrossAccounts = Math.max(
- ...multiImageAccounts.value.map((a) => getMediaRulesForContentType(a.content_type).maxFiles),
- );
- return Math.min(MAX_GENERATED_IMAGES, maxAcrossAccounts);
-});
-
+// Single picker: 0 = no image (text-only), 1 = single image, 2+ = carousel.
const imageCountOptions = computed(() =>
- Array.from({ length: Math.max(0, imageCountCap.value - 1) }, (_, i) => i + 2),
+ Array.from({ length: imageCountCap.value + 1 }, (_, i) => i),
);
-// How many images each selected account will receive — the carousel slide count
-// when any account supports multiple, otherwise a single image when enabled.
-const intendedImageCount = computed(() =>
- supportsMultiImage.value
- ? local.value.target_slide_count
- : (local.value.include_image ? 1 : 0),
-);
+const intendedImageCount = computed(() => local.value.target_slide_count);
const syntheticImages = (count: number): MediaItem[] =>
Array.from({ length: Math.max(0, count) }, () => ({ type: 'image' }) as MediaItem);
@@ -235,14 +230,17 @@ const accountIssue = (accountId: string): string | null => {
return account ? getPlatformMetaIssue(account.platform, entry.meta) : null;
};
-watch(imageCountCap, (cap) => {
- if (local.value.target_slide_count > cap) {
- local.value.target_slide_count = cap;
- }
- if (local.value.target_slide_count < 2) {
- local.value.target_slide_count = Math.min(2, cap);
- }
-});
+// Clamp the chosen count to what the selected accounts actually allow — runs on
+// mount too so legacy/over-cap values (or text-only accounts → 0) self-correct.
+watch(
+ imageCountCap,
+ (cap) => {
+ if (local.value.target_slide_count > cap) {
+ local.value.target_slide_count = cap;
+ }
+ },
+ { immediate: true },
+);
const channels = computed<Channel[]>(() =>
socialAccounts.value.map((account) => {
@@ -284,8 +282,9 @@ const channels = computed<Channel[]>(() =>
/>
</div>
- <div v-if="supportsMultiImage" class="space-y-2">
- <Label class="text-sm font-bold">{{ $t('automations.config.generate.target_slide_count') }}</Label>
+ <div v-if="imageCountCap >= 1" class="space-y-2">
+ <Label class="text-sm font-bold">{{ $t('automations.config.generate.image_count') }}</Label>
+ <p class="text-xs text-foreground/60">{{ $t('automations.config.generate.image_count_hint') }}</p>
<div class="flex flex-wrap gap-2">
<Button
v-for="n in imageCountOptions"
@@ -300,15 +299,23 @@ const channels = computed<Channel[]>(() =>
</div>
</div>
- <div v-else class="flex items-start justify-between gap-3">
+ <div v-show="!editorExpanded" class="flex items-start justify-between gap-3">
+ <div class="space-y-0.5">
+ <Label class="text-sm font-bold">{{ $t('automations.config.generate.use_brand_voice') }}</Label>
+ <p class="text-xs text-foreground/60">{{ $t('automations.config.generate.use_brand_voice_hint') }}</p>
+ </div>
+ <Switch v-model="local.use_brand_voice" />
+ </div>
+
+ <div v-show="!editorExpanded && local.target_slide_count >= 1" class="flex items-start justify-between gap-3">
<div class="space-y-0.5">
- <Label class="text-sm font-bold">{{ $t('automations.config.generate.include_image') }}</Label>
- <p class="text-xs text-foreground/60">{{ $t('automations.config.generate.include_image_hint') }}</p>
+ <Label class="text-sm font-bold">{{ $t('automations.config.generate.use_brand_visuals') }}</Label>
+ <p class="text-xs text-foreground/60">{{ $t('automations.config.generate.use_brand_visuals_hint') }}</p>
</div>
- <Switch v-model="local.include_image" />
+ <Switch v-model="local.use_brand_visuals" />
</div>
- <div>
+ <div v-show="!editorExpanded">
<label class="mb-1 block text-sm font-medium">{{ $t('automations.config.generate.prompt_template') }}</label>
<div class="h-40">
<CodeEditor
diff --git a/resources/js/components/automations/config/HttpRequestNodeConfig.vue b/resources/js/components/automations/config/HttpRequestNodeConfig.vue
index 57b1f627b..bbc063fdb 100644
--- a/resources/js/components/automations/config/HttpRequestNodeConfig.vue
+++ b/resources/js/components/automations/config/HttpRequestNodeConfig.vue
@@ -14,6 +14,7 @@ import {
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
+import { useExpandedEditor } from '@/composables/useExpandedEditor';
type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
type AuthType = 'none' | 'bearer' | 'basic' | 'api_key';
@@ -91,6 +92,8 @@ const removeHeader = (index: number): void => {
watch(local, (val) => emit('update', val), { deep: true });
+const editorExpanded = useExpandedEditor();
+
const supportsBody = computed(() => ['POST', 'PUT', 'PATCH'].includes(local.value.method));
const isBodyJsonInvalid = computed(() => {
@@ -179,7 +182,7 @@ const isBodyJsonInvalid = computed(() => {
</div>
</template>
- <div v-if="supportsBody">
+ <div v-if="supportsBody" v-show="!editorExpanded">
<label class="mb-1 block text-sm font-medium">{{ $t('automations.config.http_request.body_template') }}</label>
<div class="h-36">
<CodeEditor
diff --git a/resources/js/components/automations/config/WebhookNodeConfig.vue b/resources/js/components/automations/config/WebhookNodeConfig.vue
index 99dfc683a..fe909a6e5 100644
--- a/resources/js/components/automations/config/WebhookNodeConfig.vue
+++ b/resources/js/components/automations/config/WebhookNodeConfig.vue
@@ -4,6 +4,7 @@ import { computed, ref, watch } from 'vue';
import CodeEditor from '@/components/CodeEditor.vue';
import InputError from '@/components/InputError.vue';
import { Input } from '@/components/ui/input';
+import { useExpandedEditor } from '@/composables/useExpandedEditor';
import {
Select,
SelectContent,
@@ -25,6 +26,8 @@ const props = defineProps<{
}>();
const emit = defineEmits<{ update: [Record<string, unknown>] }>();
+const editorExpanded = useExpandedEditor();
+
const local = ref<WebhookConfig>({
url: (props.data.url as string) ?? '',
method: (props.data.method as WebhookConfig['method']) ?? 'POST',
@@ -73,7 +76,7 @@ const isPayloadJsonInvalid = computed(() => {
<InputError :message="errors?.method" class="mt-1" />
</div>
- <div>
+ <div v-show="!editorExpanded">
<label class="mb-1 block text-sm font-medium">{{ $t('automations.config.webhook.payload_template') }}</label>
<div class="h-40">
<CodeEditor
diff --git a/resources/js/components/settings/BrandTab.vue b/resources/js/components/settings/BrandTab.vue
index b4b3ab0ae..c71786e38 100644
--- a/resources/js/components/settings/BrandTab.vue
+++ b/resources/js/components/settings/BrandTab.vue
@@ -11,8 +11,7 @@ interface Workspace {
name: string;
brand_website: string | null;
brand_description: string | null;
- brand_tone: string;
- brand_voice_notes: string | null;
+ brand_voice_traits: string[] | null;
brand_color: string | null;
background_color: string | null;
text_color: string | null;
@@ -25,14 +24,14 @@ const props = defineProps<{
workspace: Workspace;
availableFonts: string[];
availableImageStyles: string[];
+ availableVoiceTraits: Record<string, string[]>;
}>();
const form = useForm({
name: props.workspace.name,
brand_website: props.workspace.brand_website ?? '',
brand_description: props.workspace.brand_description ?? '',
- brand_tone: props.workspace.brand_tone ?? 'professional',
- brand_voice_notes: props.workspace.brand_voice_notes ?? '',
+ brand_voice_traits: props.workspace.brand_voice_traits ?? [],
brand_color: props.workspace.brand_color,
background_color: props.workspace.background_color,
text_color: props.workspace.text_color,
@@ -58,6 +57,7 @@ const submit = () => {
:errors="form.errors"
:available-fonts="availableFonts"
:available-image-styles="availableImageStyles"
+ :available-voice-traits="availableVoiceTraits"
/>
<Button :disabled="form.processing">{{ $t('settings.workspace.save') }}</Button>
diff --git a/resources/js/components/ui/field/Field.vue b/resources/js/components/ui/field/Field.vue
new file mode 100644
index 000000000..5519d3705
--- /dev/null
+++ b/resources/js/components/ui/field/Field.vue
@@ -0,0 +1,25 @@
+<script setup lang="ts">
+import type { HTMLAttributes } from "vue"
+import type { FieldVariants } from "."
+import { cn } from "@/lib/utils"
+import { fieldVariants } from "."
+
+const props = defineProps<{
+ class?: HTMLAttributes["class"]
+ orientation?: FieldVariants["orientation"]
+}>()
+</script>
+
+<template>
+ <div
+ role="group"
+ data-slot="field"
+ :data-orientation="orientation"
+ :class="cn(
+ fieldVariants({ orientation }),
+ props.class,
+ )"
+ >
+ <slot />
+ </div>
+</template>
diff --git a/resources/js/components/ui/field/FieldContent.vue b/resources/js/components/ui/field/FieldContent.vue
new file mode 100644
index 000000000..d9a23fd75
--- /dev/null
+++ b/resources/js/components/ui/field/FieldContent.vue
@@ -0,0 +1,20 @@
+<script setup lang="ts">
+import type { HTMLAttributes } from "vue"
+import { cn } from "@/lib/utils"
+
+const props = defineProps<{
+ class?: HTMLAttributes["class"]
+}>()
+</script>
+
+<template>
+ <div
+ data-slot="field-content"
+ :class="cn(
+ 'group/field-content flex flex-1 flex-col gap-1.5 leading-snug',
+ props.class,
+ )"
+ >
+ <slot />
+ </div>
+</template>
diff --git a/resources/js/components/ui/field/FieldDescription.vue b/resources/js/components/ui/field/FieldDescription.vue
new file mode 100644
index 000000000..7240a837d
--- /dev/null
+++ b/resources/js/components/ui/field/FieldDescription.vue
@@ -0,0 +1,22 @@
+<script setup lang="ts">
+import type { HTMLAttributes } from "vue"
+import { cn } from "@/lib/utils"
+
+const props = defineProps<{
+ class?: HTMLAttributes["class"]
+}>()
+</script>
+
+<template>
+ <p
+ data-slot="field-description"
+ :class="cn(
+ 'text-muted-foreground text-sm leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance',
+ 'last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5',
+ '[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4',
+ props.class,
+ )"
+ >
+ <slot />
+ </p>
+</template>
diff --git a/resources/js/components/ui/field/FieldError.vue b/resources/js/components/ui/field/FieldError.vue
new file mode 100644
index 000000000..8a0a63f02
--- /dev/null
+++ b/resources/js/components/ui/field/FieldError.vue
@@ -0,0 +1,53 @@
+<script setup lang="ts">
+import type { HTMLAttributes } from "vue"
+import { computed } from "vue"
+import { cn } from "@/lib/utils"
+
+const props = defineProps<{
+ class?: HTMLAttributes["class"]
+ errors?: Array<string | { message: string | undefined } | undefined>
+}>()
+
+const content = computed(() => {
+ if (!props.errors || props.errors.length === 0)
+ return null
+
+ const uniqueErrors = [
+ ...new Map(
+ props.errors
+ .filter(Boolean)
+ .map((error) => {
+ const message = typeof error === "string" ? error : error?.message
+ return [message, error]
+ }),
+ ).values(),
+ ]
+
+ if (uniqueErrors.length === 1 && uniqueErrors[0]) {
+ return typeof uniqueErrors[0] === "string" ? uniqueErrors[0] : uniqueErrors[0].message
+ }
+
+ return uniqueErrors.map(error => typeof error === "string" ? error : error?.message)
+})
+</script>
+
+<template>
+ <div
+ v-if="$slots.default || content"
+ role="alert"
+ data-slot="field-error"
+ :class="cn('text-destructive text-sm font-normal', props.class)"
+ >
+ <slot v-if="$slots.default" />
+
+ <template v-else-if="typeof content === 'string'">
+ {{ content }}
+ </template>
+
+ <ul v-else-if="Array.isArray(content)" class="ml-4 flex list-disc flex-col gap-1">
+ <li v-for="(error, index) in content" :key="index">
+ {{ error }}
+ </li>
+ </ul>
+ </div>
+</template>
diff --git a/resources/js/components/ui/field/FieldGroup.vue b/resources/js/components/ui/field/FieldGroup.vue
new file mode 100644
index 000000000..834d8ced7
--- /dev/null
+++ b/resources/js/components/ui/field/FieldGroup.vue
@@ -0,0 +1,20 @@
+<script setup lang="ts">
+import type { HTMLAttributes } from "vue"
+import { cn } from "@/lib/utils"
+
+const props = defineProps<{
+ class?: HTMLAttributes["class"]
+}>()
+</script>
+
+<template>
+ <div
+ data-slot="field-group"
+ :class="cn(
+ 'group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4',
+ props.class,
+ )"
+ >
+ <slot />
+ </div>
+</template>
diff --git a/resources/js/components/ui/field/FieldLabel.vue b/resources/js/components/ui/field/FieldLabel.vue
new file mode 100644
index 000000000..ce6c49853
--- /dev/null
+++ b/resources/js/components/ui/field/FieldLabel.vue
@@ -0,0 +1,23 @@
+<script setup lang="ts">
+import type { HTMLAttributes } from "vue"
+import { cn } from "@/lib/utils"
+import { Label } from '@/components/ui/label'
+
+const props = defineProps<{
+ class?: HTMLAttributes["class"]
+}>()
+</script>
+
+<template>
+ <Label
+ data-slot="field-label"
+ :class="cn(
+ 'group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50',
+ 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4',
+ 'has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10',
+ props.class,
+ )"
+ >
+ <slot />
+ </Label>
+</template>
diff --git a/resources/js/components/ui/field/FieldLegend.vue b/resources/js/components/ui/field/FieldLegend.vue
new file mode 100644
index 000000000..c620fed43
--- /dev/null
+++ b/resources/js/components/ui/field/FieldLegend.vue
@@ -0,0 +1,24 @@
+<script setup lang="ts">
+import type { HTMLAttributes } from "vue"
+import { cn } from "@/lib/utils"
+
+const props = defineProps<{
+ class?: HTMLAttributes["class"]
+ variant?: "legend" | "label"
+}>()
+</script>
+
+<template>
+ <legend
+ data-slot="field-legend"
+ :data-variant="variant"
+ :class="cn(
+ 'mb-3 font-medium',
+ 'data-[variant=legend]:text-base',
+ 'data-[variant=label]:text-sm',
+ props.class,
+ )"
+ >
+ <slot />
+ </legend>
+</template>
diff --git a/resources/js/components/ui/field/FieldSeparator.vue b/resources/js/components/ui/field/FieldSeparator.vue
new file mode 100644
index 000000000..97d0efa86
--- /dev/null
+++ b/resources/js/components/ui/field/FieldSeparator.vue
@@ -0,0 +1,29 @@
+<script setup lang="ts">
+import type { HTMLAttributes } from "vue"
+import { cn } from "@/lib/utils"
+import { Separator } from '@/components/ui/separator'
+
+const props = defineProps<{
+ class?: HTMLAttributes["class"]
+}>()
+</script>
+
+<template>
+ <div
+ data-slot="field-separator"
+ :data-content="!!$slots.default"
+ :class="cn(
+ 'relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2',
+ props.class,
+ )"
+ >
+ <Separator class="absolute inset-0 top-1/2" />
+ <span
+ v-if="$slots.default"
+ class="bg-background text-muted-foreground relative mx-auto block w-fit px-2"
+ data-slot="field-separator-content"
+ >
+ <slot />
+ </span>
+ </div>
+</template>
diff --git a/resources/js/components/ui/field/FieldSet.vue b/resources/js/components/ui/field/FieldSet.vue
new file mode 100644
index 000000000..7be4dc9e7
--- /dev/null
+++ b/resources/js/components/ui/field/FieldSet.vue
@@ -0,0 +1,21 @@
+<script setup lang="ts">
+import type { HTMLAttributes } from "vue"
+import { cn } from "@/lib/utils"
+
+const props = defineProps<{
+ class?: HTMLAttributes["class"]
+}>()
+</script>
+
+<template>
+ <fieldset
+ data-slot="field-set"
+ :class="cn(
+ 'flex flex-col gap-6',
+ 'has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',
+ props.class,
+ )"
+ >
+ <slot />
+ </fieldset>
+</template>
diff --git a/resources/js/components/ui/field/FieldTitle.vue b/resources/js/components/ui/field/FieldTitle.vue
new file mode 100644
index 000000000..f564b8b8a
--- /dev/null
+++ b/resources/js/components/ui/field/FieldTitle.vue
@@ -0,0 +1,20 @@
+<script setup lang="ts">
+import type { HTMLAttributes } from "vue"
+import { cn } from "@/lib/utils"
+
+const props = defineProps<{
+ class?: HTMLAttributes["class"]
+}>()
+</script>
+
+<template>
+ <div
+ data-slot="field-label"
+ :class="cn(
+ 'flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50',
+ props.class,
+ )"
+ >
+ <slot />
+ </div>
+</template>
diff --git a/resources/js/components/ui/field/index.ts b/resources/js/components/ui/field/index.ts
new file mode 100644
index 000000000..162ba14de
--- /dev/null
+++ b/resources/js/components/ui/field/index.ts
@@ -0,0 +1,39 @@
+import type { VariantProps } from "class-variance-authority"
+import { cva } from "class-variance-authority"
+
+export const fieldVariants = cva(
+ "group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
+ {
+ variants: {
+ orientation: {
+ vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
+ horizontal: [
+ "flex-row items-center",
+ "[&>[data-slot=field-label]]:flex-auto",
+ "has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
+ ],
+ responsive: [
+ "flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto",
+ "@md/field-group:[&>[data-slot=field-label]]:flex-auto",
+ "@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
+ ],
+ },
+ },
+ defaultVariants: {
+ orientation: "vertical",
+ },
+ },
+)
+
+export type FieldVariants = VariantProps<typeof fieldVariants>
+
+export { default as Field } from "./Field.vue"
+export { default as FieldContent } from "./FieldContent.vue"
+export { default as FieldDescription } from "./FieldDescription.vue"
+export { default as FieldError } from "./FieldError.vue"
+export { default as FieldGroup } from "./FieldGroup.vue"
+export { default as FieldLabel } from "./FieldLabel.vue"
+export { default as FieldLegend } from "./FieldLegend.vue"
+export { default as FieldSeparator } from "./FieldSeparator.vue"
+export { default as FieldSet } from "./FieldSet.vue"
+export { default as FieldTitle } from "./FieldTitle.vue"
diff --git a/resources/js/components/ui/label/Label.vue b/resources/js/components/ui/label/Label.vue
index a7d0a85cb..ee6397024 100644
--- a/resources/js/components/ui/label/Label.vue
+++ b/resources/js/components/ui/label/Label.vue
@@ -3,33 +3,24 @@ import type { LabelProps } from "reka-ui"
import type { HTMLAttributes } from "vue"
import { reactiveOmit } from "@vueuse/core"
import { Label } from "reka-ui"
-import { IconInfoCircle } from "@tabler/icons-vue"
-import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
-
import { cn } from "@/lib/utils"
-const props = defineProps<LabelProps & { class?: HTMLAttributes["class"], required?: boolean, tooltip?: string }>()
+const props = defineProps<LabelProps & { class?: HTMLAttributes["class"] }>()
-const delegatedProps = reactiveOmit(props, "class", "required", "tooltip")
+const delegatedProps = reactiveOmit(props, "class")
</script>
<template>
- <Label data-slot="label" v-bind="delegatedProps" :class="cn(
- 'flex items-center gap-0.5 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
- props.class,
- )
- ">
+ <Label
+ data-slot="label"
+ v-bind="delegatedProps"
+ :class="
+ cn(
+ 'flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
+ props.class,
+ )
+ "
+ >
<slot />
- <span v-if="required" class="text-red-500">*</span>
- <TooltipProvider v-if="tooltip">
- <Tooltip>
- <TooltipTrigger as-child>
- <IconInfoCircle class="size-4 text-muted-foreground cursor-help" />
- </TooltipTrigger>
- <TooltipContent>
- <p>{{ tooltip }}</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
</Label>
-</template>
\ No newline at end of file
+</template>
diff --git a/resources/js/composables/useExpandedEditor.ts b/resources/js/composables/useExpandedEditor.ts
new file mode 100644
index 000000000..1f3da4fc3
--- /dev/null
+++ b/resources/js/composables/useExpandedEditor.ts
@@ -0,0 +1,12 @@
+import { computed, inject } from 'vue';
+
+/**
+ * Reactive flag, provided by the automation editor (Form.vue), that is true
+ * while an expandable CodeEditor is open in the side panel. Config panels use it
+ * to collapse the inline field — the editing happens in the panel instead.
+ */
+export const useExpandedEditor = () => {
+ const state = inject<{ active: boolean } | null>('automationExpandedEditor', null);
+
+ return computed(() => state?.active ?? false);
+};
diff --git a/resources/js/composables/useExpressionCompletions.ts b/resources/js/composables/useExpressionCompletions.ts
index f1cdf903e..88c5e28ed 100644
--- a/resources/js/composables/useExpressionCompletions.ts
+++ b/resources/js/composables/useExpressionCompletions.ts
@@ -127,6 +127,26 @@ export const buildExpressionCatalog = (
return suggestions.filter((item) => (seen.has(item.label) ? false : seen.add(item.label)));
};
+/**
+ * Whether a `{{ path }}` references something the node can actually resolve.
+ * Lenient on purpose: a path is known if it matches a catalog entry, is a
+ * parent of one, or is a child of one (e.g. HTTP `fetched.*` is arbitrary, so
+ * `fetched` in the catalog makes any `fetched.x.y` valid). When the catalog is
+ * empty (no upstream context yet) nothing is flagged.
+ */
+export const isKnownExpression = (path: string, suggestions: ExpressionSuggestion[]): boolean => {
+ if (suggestions.length === 0) {
+ return true;
+ }
+
+ return suggestions.some(
+ (item) =>
+ path === item.label ||
+ path.startsWith(`${item.label}.`) ||
+ item.label.startsWith(`${path}.`),
+ );
+};
+
/**
* CodeMirror completion source that only fires inside a `{{ ... }}` block —
* matching how n8n scopes completions to its `Resolvable` syntax node. The typed
diff --git a/resources/js/pages/automations/Form.vue b/resources/js/pages/automations/Form.vue
index a342429c5..80136b4bb 100644
--- a/resources/js/pages/automations/Form.vue
+++ b/resources/js/pages/automations/Form.vue
@@ -268,7 +268,7 @@ const defaultConfigFor = (type: string): Record<string, unknown> => {
schedule_minute: 0,
schedule_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
};
- case NodeType.Generate: return { accounts: [], prompt_template: '', include_image: true, target_slide_count: 5 };
+ case NodeType.Generate: return { accounts: [], prompt_template: '', target_slide_count: 1 };
case NodeType.Delay: return { duration: 1, unit: 'hours' };
case NodeType.Condition: return { field: '', operator: 'contains', value: '' };
case NodeType.Publish: return { mode: 'now', scheduled_offset: 60 };
diff --git a/resources/js/pages/settings/workspace/Brand.vue b/resources/js/pages/settings/workspace/Brand.vue
index 2ff2c99e3..7a25c4236 100644
--- a/resources/js/pages/settings/workspace/Brand.vue
+++ b/resources/js/pages/settings/workspace/Brand.vue
@@ -16,8 +16,7 @@ interface Workspace {
name: string;
brand_website: string | null;
brand_description: string | null;
- brand_tone: string;
- brand_voice_notes: string | null;
+ brand_voice_traits: string[] | null;
brand_color: string | null;
background_color: string | null;
text_color: string | null;
@@ -30,6 +29,7 @@ defineProps<{
workspace: Workspace;
availableFonts: string[];
availableImageStyles: string[];
+ availableVoiceTraits: Record<string, string[]>;
}>();
const tabs = computed(() => [
@@ -56,6 +56,7 @@ const tabs = computed(() => [
:workspace="workspace"
:available-fonts="availableFonts"
:available-image-styles="availableImageStyles"
+ :available-voice-traits="availableVoiceTraits"
/>
</div>
</AppLayout>
diff --git a/resources/js/pages/settings/workspace/Workspace.vue b/resources/js/pages/settings/workspace/Workspace.vue
index 4371b2805..f525273df 100644
--- a/resources/js/pages/settings/workspace/Workspace.vue
+++ b/resources/js/pages/settings/workspace/Workspace.vue
@@ -18,8 +18,7 @@ interface Workspace {
logo_url: string | null;
brand_website: string | null;
brand_description: string | null;
- brand_tone: string;
- brand_voice_notes: string | null;
+ brand_voice_traits: string[] | null;
content_language: string;
}
diff --git a/resources/js/pages/workspaces/Create.vue b/resources/js/pages/workspaces/Create.vue
index 084fb4bd0..6009a65fa 100644
--- a/resources/js/pages/workspaces/Create.vue
+++ b/resources/js/pages/workspaces/Create.vue
@@ -9,14 +9,14 @@ import { store as storeWorkspace } from '@/routes/app/workspaces';
defineProps<{
availableFonts: string[];
availableImageStyles: string[];
+ availableVoiceTraits: Record<string, string[]>;
}>();
const form = useForm({
name: '',
brand_website: '',
brand_description: '',
- brand_tone: 'professional',
- brand_voice_notes: '',
+ brand_voice_traits: [] as string[],
brand_color: null as string | null,
background_color: null as string | null,
text_color: null as string | null,
@@ -44,6 +44,7 @@ const submit = () => {
:errors="form.errors"
:available-fonts="availableFonts"
:available-image-styles="availableImageStyles"
+ :available-voice-traits="availableVoiceTraits"
:autofill="true"
:show-name="true"
/>
diff --git a/resources/views/prompts/brand_analyzer.blade.php b/resources/views/prompts/brand_analyzer.blade.php
index 131c8d28b..30f7de335 100644
--- a/resources/views/prompts/brand_analyzer.blade.php
+++ b/resources/views/prompts/brand_analyzer.blade.php
@@ -10,25 +10,18 @@ From the provided markdown content of the homepage, produce:
2. **description** — a concise 2-3 sentence brand description explaining what the company does, who they serve, and what makes them unique. Write it in the detected content language. Avoid marketing fluff; be specific.
-3. **tone** — identify the tone of voice the brand uses. Pick exactly one of:
- - `professional` — formal, business-oriented
- - `casual` — relaxed, conversational
- - `friendly` — warm, approachable
- - `bold` — confident, assertive
- - `inspirational` — motivating, uplifting
- - `humorous` — witty, playful
- - `educational` — informative, teaching-oriented
+3. **language** — detect the primary content language of the site. Pick exactly one of: `en`, `pt-BR`, `es`. If the site is in a different language entirely, pick the closest match (prefer `en`).
-4. **language** — detect the primary content language of the site. Pick exactly one of: `en`, `pt-BR`, `es`. If the site is in a different language entirely, pick the closest match (prefer `en`).
+4. **voice_traits** — infer the brand's voice as a set of traits, returned as an array of values chosen ONLY from the allowed list below. For each single-select dimension pick AT MOST ONE value (or none if unclear); for the `style` group pick any number that fit. Aim for a coherent set of roughly 5-9 traits.
+@foreach($voice_groups as $group => $values)
+ - **{{ $group }}**{{ in_array($group, $single_select_groups, true) ? ' (pick at most one)' : ' (pick any that fit)' }}: {{ implode(', ', $values) }}
+@endforeach
+ Only return values from the lists above — never invent new ones.
-5. **voice_notes** — 2-3 sentences of concrete writing guidelines the brand appears to follow, inferred from the actual content on the page. Write them in the detected content language. Good examples:
- - "Use technical but approachable language. Reference specific features by name. Avoid generic marketing buzzwords."
- - "Keep sentences short and punchy. Use emojis sparingly. Address the reader as 'you'."
+5. **brand_color** — the primary brand color as a hex string starting with `#`, lowercase, 6 digits (e.g. `#0ea5e9`). This is the accent color most prominently used in CTAs, primary buttons, links, or the logo. Return an empty string if you can't confidently identify it.
-6. **brand_color** — the primary brand color as a hex string starting with `#`, lowercase, 6 digits (e.g. `#0ea5e9`). This is the accent color most prominently used in CTAs, primary buttons, links, or the logo. Return an empty string if you can't confidently identify it.
+6. **background_color** — the dominant page background color as a hex string starting with `#`, lowercase, 6 digits (e.g. `#ffffff` for light themes, `#0b0f19` for dark themes). Return an empty string if you can't confidently identify it.
-7. **background_color** — the dominant page background color as a hex string starting with `#`, lowercase, 6 digits (e.g. `#ffffff` for light themes, `#0b0f19` for dark themes). Return an empty string if you can't confidently identify it.
-
-8. **text_color** — the dominant body text color as a hex string starting with `#`, lowercase, 6 digits (e.g. `#0f172a`). Return an empty string if you can't confidently identify it.
+7. **text_color** — the dominant body text color as a hex string starting with `#`, lowercase, 6 digits (e.g. `#0f172a`). Return an empty string if you can't confidently identify it.
Be accurate and specific to what the page actually shows. Do not invent features or claims that aren't on the page. For colors, prefer values visible in the markup/CSS; never guess.
diff --git a/resources/views/prompts/post_content/_voice.blade.php b/resources/views/prompts/post_content/_voice.blade.php
new file mode 100644
index 000000000..6d2261802
--- /dev/null
+++ b/resources/views/prompts/post_content/_voice.blade.php
@@ -0,0 +1,53 @@
+@php
+ // Maps each BrandVoiceTrait value to the instruction the model should follow.
+ $voicePhrases = [
+ // Point of view.
+ 'first_person' => 'Write in the first person (I / we), as the brand owner.',
+ 'second_person' => 'Address the reader directly in the second person (you).',
+ 'third_person' => "Write in the third person — report the topic, don't speak as the brand owner or claim its experiences as your own.",
+ // Formality.
+ 'formal' => 'Keep a formal register.',
+ 'balanced' => 'Keep a balanced register — neither stiff nor slangy.',
+ 'casual' => 'Keep a casual, relaxed register.',
+ // Energy.
+ 'calm' => 'Keep a calm, measured energy.',
+ 'moderate' => 'Keep a moderate energy — neither flat nor hyped.',
+ 'enthusiastic' => 'Bring upbeat, enthusiastic energy.',
+ 'vibrant' => 'Bring vibrant, high-energy delivery.',
+ // Humor.
+ 'serious' => 'Stay serious and straight; no jokes.',
+ 'dry' => 'Use dry, subtle, understated humor.',
+ 'witty' => 'Add light wit where it fits.',
+ 'playful' => 'Be playful and fun.',
+ // Attitude.
+ 'respectful' => 'Stay respectful and considerate.',
+ 'even_handed' => 'Stay even-handed and balanced in your stance.',
+ 'bold' => 'Take a clear, opinionated stance.',
+ 'provocative' => 'Be provocative — challenge conventions and play with provocation.',
+ // Warmth.
+ 'neutral' => 'Keep an emotionally neutral, professional warmth.',
+ 'friendly' => 'Be warm and friendly.',
+ 'empathetic' => 'Be empathetic and understanding.',
+ // Confidence.
+ 'humble' => 'Be humble and modest.',
+ 'confident' => 'Write with quiet confidence.',
+ 'assertive' => 'Be assertive and authoritative.',
+ // Additive style traits.
+ 'direct' => 'Use direct, plain, accessible language.',
+ 'concise' => 'Keep sentences short and objective.',
+ 'transparent' => 'Be transparent — share behind-the-scenes details and real learnings.',
+ 'no_hype' => 'Avoid hype and overly promotional language.',
+ 'practical' => 'Focus on practical, actionable takeaways.',
+ 'data_driven' => 'Back claims with concrete results, numbers and specifics.',
+ 'storytelling' => 'Use narrative and storytelling.',
+ 'inspirational' => 'Be inspiring and motivating.',
+ 'educational' => 'Teach and explain clearly.',
+ 'technical' => 'Use precise, technical language for an expert audience.',
+ 'minimalist' => 'Use few or no emojis.',
+ ];
+@endphp
+@foreach(($brand_voice_traits ?? []) as $trait)
+@if(isset($voicePhrases[$trait]))
+- {{ $voicePhrases[$trait] }}
+@endif
+@endforeach
diff --git a/resources/views/prompts/post_content/generator.blade.php b/resources/views/prompts/post_content/generator.blade.php
index aab49cea3..0f1a2c8e8 100644
--- a/resources/views/prompts/post_content/generator.blade.php
+++ b/resources/views/prompts/post_content/generator.blade.php
@@ -3,11 +3,9 @@ You write social media posts for the brand "{{ $brand_name }}".
@if(!empty($brand_description))
About the brand: {{ $brand_description }}
@endif
-@if(!empty($brand_tone))
-Brand tone: {{ $brand_tone }}.
-@endif
-@if(!empty($brand_voice_notes))
-Voice guidelines: {{ $brand_voice_notes }}
+@if(!empty($brand_voice_traits))
+Brand voice — follow these exactly:
+@include('prompts.post_content._voice', ['brand_voice_traits' => $brand_voice_traits])
@endif
@if(!empty($current_content))
@@ -20,7 +18,7 @@ The user already has this content in the editor (use as context only — your ou
Write the output in the language with code: {{ $content_language ?? 'en' }}.
Rules:
-- Match the brand tone and voice guidelines exactly.
+- Match the brand voice guidelines exactly.
- Avoid AI-clichés (testament, pivotal moment, emojis on every line, "Let's dive in").
- Keep paragraphs short. Vary sentence rhythm.
- If the user mentions a specific platform, follow that platform's typical conventions.
diff --git a/resources/views/prompts/post_content/humanizer.blade.php b/resources/views/prompts/post_content/humanizer.blade.php
index 3cf8893a8..68f063b10 100644
--- a/resources/views/prompts/post_content/humanizer.blade.php
+++ b/resources/views/prompts/post_content/humanizer.blade.php
@@ -3,16 +3,22 @@ You are a copy editor that rewrites social media text to remove AI-generated pat
@if(!empty($brand_name))
You are editing content for the brand "{{ $brand_name }}".
@endif
-@if(!empty($brand_tone))
-Brand tone: {{ $brand_tone }}.
-@endif
-@if(!empty($brand_voice_notes))
-Brand voice notes (use as voice calibration sample — match this tone, vocabulary, and rhythm):
-{{ $brand_voice_notes }}
+@if(!empty($brand_voice_traits))
+Brand voice — match this tone, vocabulary, and rhythm:
+@include('prompts.post_content._voice', ['brand_voice_traits' => $brand_voice_traits])
@endif
Output language: {{ $content_language ?? 'en' }}.
+@if(!empty($hard_max_chars))
+## CRITICAL — length limit for {{ $platform_label ?? 'the target platform' }}
+
+The rewritten text MUST fit this platform. This overrides the "match original length" guidance below:
+- Hard cap (must NEVER exceed): {{ $hard_max_chars }} characters total for the `content`/`caption` field — including spaces, line breaks, hashtags and emojis.
+- Sweet spot: around {{ $target_chars }} characters. Concise posts perform better.
+- If a faithful rewrite would exceed the cap, cut words — never go over. Count before responding.
+
+@endif
## What to remove (AI-tells)
**Promotional / inflated language:**
@@ -76,7 +82,7 @@ Replace " " ' ' with straight " " ' '.
3. **Be specific.** Replace abstractions with concrete details when possible.
4. **Use "is/are/has"** where AI-elaborate constructions appear.
5. **Cut filler.** "In order to" → "to". "Due to the fact that" → "because". "At this point in time" → "now".
-6. **Match the brand voice.** If brand_voice_notes was provided, mirror its rhythm and word choices.
+6. **Match the brand voice.** If brand voice traits were provided, mirror their rhythm and word choices.
7. **Preserve meaning.** The core message and any specific facts/numbers/claims stay intact.
8. **Match the original length roughly.** Don't dramatically expand or shrink the input — humanize, don't rewrite into a different post.
diff --git a/resources/views/prompts/post_content/reviewer.blade.php b/resources/views/prompts/post_content/reviewer.blade.php
index de135dd12..efd284168 100644
--- a/resources/views/prompts/post_content/reviewer.blade.php
+++ b/resources/views/prompts/post_content/reviewer.blade.php
@@ -2,8 +2,10 @@ You are a writing reviewer. Your job: spot grammar, spelling, and clarity issues
Brand context:
- Brand: {{ $brand_name }}
-@if(!empty($brand_tone))- Tone: {{ $brand_tone }}@endif
-@if(!empty($brand_voice_notes))- Voice: {{ $brand_voice_notes }}@endif
+@if(!empty($brand_voice_traits))
+Brand voice:
+@include('prompts.post_content._voice', ['brand_voice_traits' => $brand_voice_traits])
+@endif
Output language: {{ $content_language ?? 'en' }}.
diff --git a/tests/Feature/Actions/Workspace/CreateWorkspaceTest.php b/tests/Feature/Actions/Workspace/CreateWorkspaceTest.php
index ec7569d21..a31bf419d 100644
--- a/tests/Feature/Actions/Workspace/CreateWorkspaceTest.php
+++ b/tests/Feature/Actions/Workspace/CreateWorkspaceTest.php
@@ -15,16 +15,14 @@ test('CreateWorkspace persists name and brand fields', function () {
'name' => 'Acme Inc',
'brand_website' => 'https://acme.example',
'brand_description' => 'We sell rockets.',
- 'brand_tone' => 'professional',
- 'brand_voice_notes' => 'short, punchy.',
+ 'brand_voice_traits' => ['third_person', 'no_hype'],
'content_language' => 'en',
]);
expect($workspace->name)->toBe('Acme Inc');
expect($workspace->brand_website)->toBe('https://acme.example');
expect($workspace->brand_description)->toBe('We sell rockets.');
- expect($workspace->brand_tone)->toBe('professional');
- expect($workspace->brand_voice_notes)->toBe('short, punchy.');
+ expect($workspace->brand_voice_traits)->toBe(['third_person', 'no_hype']);
expect($workspace->content_language)->toBe('en');
expect($workspace->account_id)->toBe($account->id);
expect($workspace->user_id)->toBe($user->id);
diff --git a/tests/Feature/Ai/AutofillBrandTest.php b/tests/Feature/Ai/AutofillBrandTest.php
index c10b832c0..8cea1673c 100644
--- a/tests/Feature/Ai/AutofillBrandTest.php
+++ b/tests/Feature/Ai/AutofillBrandTest.php
@@ -359,18 +359,17 @@ test('when llm is configured, polishes description/tone/language/voice_notes via
BrandAnalyzer::fake([
[
'description' => 'Widget Co helps small teams ship production widgets faster.',
- 'tone' => 'friendly',
'language' => 'en',
- 'voice_notes' => 'Use short punchy sentences. Focus on developer benefits.',
+ // A bogus value (dropped) and a second POV (dropped — single-select).
+ 'voice_traits' => ['third_person', 'first_person', 'direct', 'no_hype', 'not_a_trait'],
],
]);
$result = ($this->autofill)('https://example.com');
expect($result->description)->toBe('Widget Co helps small teams ship production widgets faster.');
- expect($result->tone)->toBe('friendly');
expect($result->language)->toBe('en');
- expect($result->voiceNotes)->toBe('Use short punchy sentences. Focus on developer benefits.');
+ expect($result->toArray()['brand_voice_traits'])->toBe(['third_person', 'direct', 'no_hype']);
});
test('when llm is not configured, falls back to meta tags only', function () {
@@ -394,8 +393,6 @@ test('when llm is not configured, falls back to meta tags only', function () {
expect($result->description)->toBe('Uma descrição curta.');
expect($result->language)->toBe('pt-BR');
- expect($result->tone)->toBeNull();
- expect($result->voiceNotes)->toBeNull();
});
test('falls back to meta tags when BrandAnalyzer throws', function () {
@@ -422,8 +419,6 @@ test('falls back to meta tags when BrandAnalyzer throws', function () {
expect($result->description)->toBe('Fallback desc.');
expect($result->language)->toBe('en');
- expect($result->tone)->toBeNull();
- expect($result->voiceNotes)->toBeNull();
});
test('toArray swaps site background and text colours for the image palette fields', function () {
@@ -453,8 +448,10 @@ test('BrandMetadata toArray exposes the shape the controller expects', function
'name',
'brand_description',
'content_language',
- 'brand_tone',
- 'brand_voice_notes',
+ 'brand_color',
+ 'background_color',
+ 'text_color',
'logo_url',
+ 'brand_voice_traits',
]);
});
diff --git a/tests/Feature/Ai/StreamPostCreationTest.php b/tests/Feature/Ai/StreamPostCreationTest.php
index 55963bd22..78343bcc5 100644
--- a/tests/Feature/Ai/StreamPostCreationTest.php
+++ b/tests/Feature/Ai/StreamPostCreationTest.php
@@ -89,3 +89,22 @@ test('AI single feed generation stores the post as an instagram feed', function
expect($platform->content_type)->toBe(ContentType::InstagramFeed);
});
+
+test('the humanizer is given the same platform context as the generator so the rewrite honours the character cap', function () {
+ PostContentGenerator::fake([[
+ 'content' => 'A single productivity tip',
+ 'image_title' => 'Tip',
+ 'image_body' => 'Do less',
+ 'image_keywords' => [],
+ ]]);
+ PostContentHumanizer::fake([[
+ 'content' => 'A single productivity tip',
+ 'image_title' => 'Tip',
+ 'image_body' => 'Do less',
+ ]]);
+
+ runStreamPostCreation('instagram_feed', $this->account, 0);
+
+ PostContentGenerator::assertPrompted(fn ($prompt) => $prompt->agent->platformContext === 'instagram_feed');
+ PostContentHumanizer::assertPrompted(fn ($prompt) => $prompt->agent->platformContext === 'instagram_feed');
+});
diff --git a/tests/Feature/Automation/AutomationCrudTest.php b/tests/Feature/Automation/AutomationCrudTest.php
index a6179876a..6ca759800 100644
--- a/tests/Feature/Automation/AutomationCrudTest.php
+++ b/tests/Feature/Automation/AutomationCrudTest.php
@@ -60,6 +60,73 @@ it('updates nodes and connections via PUT', function () {
expect($automation->fresh()->nodes)->toHaveCount(3);
});
+it('persists every trigger schedule editor field through a save round-trip', function (array $scheduleData) {
+ $automation = Automation::factory()->for($this->workspace)->create();
+
+ $this->actingAs($this->user)
+ ->put(route('app.automations.update', $automation->id), [
+ 'nodes' => [
+ ['id' => 'n1', 'type' => 'trigger', 'position' => ['x' => 0, 'y' => 0], 'data' => array_merge([
+ 'trigger_type' => 'schedule',
+ 'cron' => '0 9 * * *',
+ ], $scheduleData)],
+ ],
+ 'connections' => [],
+ ])
+ ->assertRedirect()
+ ->assertSessionHasNoErrors();
+
+ $trigger = collect($automation->fresh()->nodes)->firstWhere('id', 'n1');
+
+ foreach ($scheduleData as $key => $value) {
+ expect($trigger['data'][$key])->toBe($value);
+ }
+})->with([
+ 'minutes interval' => [['schedule_field' => 'minutes', 'schedule_minutes_interval' => 15]],
+ 'hours interval' => [['schedule_field' => 'hours', 'schedule_hours_interval' => 6, 'schedule_minute' => 30]],
+ 'daily at time' => [['schedule_field' => 'days', 'schedule_days_interval' => 2, 'schedule_hour' => 8, 'schedule_minute' => 45]],
+ 'weekly on weekdays' => [['schedule_field' => 'weeks', 'schedule_weekdays' => [1, 3, 5], 'schedule_hour' => 14, 'schedule_minute' => 0]],
+ 'monthly on day-of-month' => [['schedule_field' => 'months', 'schedule_day_of_month' => 15, 'schedule_hour' => 9, 'schedule_minute' => 0]],
+ 'custom cron' => [['schedule_field' => 'custom', 'schedule_custom_cron' => '0 9 * * 1,3,5']],
+ 'timezone' => [['schedule_timezone' => 'America/Sao_Paulo']],
+ 'all fields together' => [[
+ 'schedule_field' => 'weeks',
+ 'schedule_minutes_interval' => 5,
+ 'schedule_hours_interval' => 3,
+ 'schedule_days_interval' => 1,
+ 'schedule_hour' => 14,
+ 'schedule_minute' => 30,
+ 'schedule_weekdays' => [0, 6],
+ 'schedule_day_of_month' => 28,
+ 'schedule_custom_cron' => '*/5 * * * *',
+ 'schedule_timezone' => 'Europe/Lisbon',
+ ]],
+]);
+
+it('rejects a trigger node with an out-of-range or invalid schedule field', function (array $scheduleData, string $invalidKey) {
+ $automation = Automation::factory()->for($this->workspace)->create();
+
+ $this->actingAs($this->user)
+ ->putJson(route('app.automations.update', $automation->id), [
+ 'nodes' => [
+ ['id' => 'n1', 'type' => 'trigger', 'position' => ['x' => 0, 'y' => 0], 'data' => array_merge([
+ 'trigger_type' => 'schedule',
+ 'cron' => '0 9 * * *',
+ ], $scheduleData)],
+ ],
+ 'connections' => [],
+ ])
+ ->assertStatus(422)
+ ->assertJsonValidationErrors(["nodes.0.data.{$invalidKey}"]);
+})->with([
+ 'bad schedule_field' => [['schedule_field' => 'fortnightly'], 'schedule_field'],
+ 'hour over 23' => [['schedule_field' => 'days', 'schedule_hour' => 24], 'schedule_hour'],
+ 'minute over 59' => [['schedule_field' => 'days', 'schedule_minute' => 60], 'schedule_minute'],
+ 'weekday over 6' => [['schedule_field' => 'weeks', 'schedule_weekdays' => [7]], 'schedule_weekdays.0'],
+ 'day-of-month over 31' => [['schedule_field' => 'months', 'schedule_day_of_month' => 32], 'schedule_day_of_month'],
+ 'invalid timezone' => [['schedule_timezone' => 'Mars/Phobos'], 'schedule_timezone'],
+]);
+
it('rejects update with cycle', function () {
$automation = Automation::factory()->for($this->workspace)->create();
diff --git a/tests/Feature/Automation/GenerateNodeValidationTest.php b/tests/Feature/Automation/GenerateNodeValidationTest.php
index 1404f1de2..0f3eaebde 100644
--- a/tests/Feature/Automation/GenerateNodeValidationTest.php
+++ b/tests/Feature/Automation/GenerateNodeValidationTest.php
@@ -58,6 +58,31 @@ it('allows saving a generate node within the content type limit', function () {
expect($automation->fresh()->nodes)->toHaveCount(2);
});
+it('persists the brand toggles on the generate node', function () {
+ $automation = Automation::factory()->for($this->workspace)->create();
+
+ $this->actingAs($this->user)
+ ->put(route('app.automations.update', $automation->id), [
+ 'nodes' => [
+ ['id' => 'n1', 'type' => 'trigger', 'position' => ['x' => 0, 'y' => 0], 'data' => ['trigger_type' => 'schedule', 'cron' => '0 9 * * *']],
+ ['id' => 'n2', 'type' => 'generate', 'position' => ['x' => 1, 'y' => 0], 'data' => [
+ 'accounts' => [['social_account_id' => 'acc-1', 'content_type' => 'pinterest_carousel']],
+ 'prompt_template' => 'hi',
+ 'target_slide_count' => 4,
+ 'use_brand_voice' => false,
+ 'use_brand_visuals' => false,
+ ]],
+ ],
+ 'connections' => [['id' => 'e1', 'source' => 'n1', 'target' => 'n2']],
+ ])
+ ->assertRedirect();
+
+ $generate = collect($automation->fresh()->nodes)->firstWhere('id', 'n2');
+ expect($generate['data']['target_slide_count'])->toBe(4);
+ expect($generate['data']['use_brand_voice'])->toBeFalse();
+ expect($generate['data']['use_brand_visuals'])->toBeFalse();
+});
+
it('saves a generate node using the exact frontend payload (no image_source field)', function () {
$automation = Automation::factory()->for($this->workspace)->create();
@@ -68,7 +93,6 @@ it('saves a generate node using the exact frontend payload (no image_source fiel
['id' => 'n2', 'type' => 'generate', 'position' => ['x' => 1, 'y' => 0], 'data' => [
'accounts' => [['social_account_id' => 'acc-1', 'content_type' => 'instagram_feed', 'meta' => []]],
'prompt_template' => 'hi',
- 'include_image' => true,
'target_slide_count' => 5,
]],
],
@@ -86,7 +110,7 @@ it('refuses to activate an automation whose generate node requests images for an
'nodes' => array_merge($automation->nodes, [
['id' => 'n2', 'type' => 'generate', 'position' => ['x' => 1, 'y' => 1], 'data' => [
'accounts' => [['social_account_id' => 'acc-1', 'content_type' => 'tiktok_video']],
- 'include_image' => true,
+ 'target_slide_count' => 1,
]],
]),
'connections' => [['id' => 'e1', 'source' => 'trigger_1', 'target' => 'n2']],
diff --git a/tests/Feature/Automation/Node/GenerateNodeTest.php b/tests/Feature/Automation/Node/GenerateNodeTest.php
index 69153e678..813e65fb7 100644
--- a/tests/Feature/Automation/Node/GenerateNodeTest.php
+++ b/tests/Feature/Automation/Node/GenerateNodeTest.php
@@ -47,6 +47,162 @@ it('creates a draft post and writes generated output to run context', function (
expect($post->status)->toBe(PostStatus::Draft);
});
+it('applies brand voice by default', function () {
+ PostContentGenerator::fake([
+ ['content' => 'c', 'image_title' => 't', 'image_body' => 'b', 'image_keywords' => ['k']],
+ ]);
+ PostContentHumanizer::fake([['content' => 'c', 'image_title' => 't', 'image_body' => 'b']]);
+
+ $run = AutomationRun::factory()->create(['context' => ['trigger' => ['title' => 'News']]]);
+
+ app(RunGenerateNode::class)($run, [
+ 'accounts' => [],
+ 'prompt_template' => 'Write about {{ trigger.title }}',
+ ]);
+
+ PostContentGenerator::assertPrompted(fn ($prompt) => $prompt->agent->applyBrandVoice === true);
+ PostContentHumanizer::assertPrompted(fn ($prompt) => $prompt->agent->applyBrandVoice === true);
+});
+
+it('skips brand voice when use_brand_voice is off', function () {
+ PostContentGenerator::fake([
+ ['content' => 'c', 'image_title' => 't', 'image_body' => 'b', 'image_keywords' => ['k']],
+ ]);
+ PostContentHumanizer::fake([['content' => 'c', 'image_title' => 't', 'image_body' => 'b']]);
+
+ $run = AutomationRun::factory()->create(['context' => ['trigger' => ['title' => 'OpenAI news']]]);
+
+ app(RunGenerateNode::class)($run, [
+ 'accounts' => [],
+ 'prompt_template' => 'Write about {{ trigger.title }}',
+ 'use_brand_voice' => false,
+ ]);
+
+ PostContentGenerator::assertPrompted(fn ($prompt) => $prompt->agent->applyBrandVoice === false);
+ PostContentHumanizer::assertPrompted(fn ($prompt) => $prompt->agent->applyBrandVoice === false);
+});
+
+it('passes the selected network as the generator platform context', function () {
+ PostContentGenerator::fake([
+ ['content' => 'c', 'image_title' => 't', 'image_body' => 'b', 'image_keywords' => ['k']],
+ ]);
+ PostContentHumanizer::fake([['content' => 'c', 'image_title' => 't', 'image_body' => 'b']]);
+
+ $workspace = Workspace::factory()->create();
+ $account = SocialAccount::factory()->for($workspace)->create(['platform' => 'linkedin']);
+ $run = AutomationRun::factory()->for(Automation::factory()->for($workspace))->create([
+ 'context' => ['trigger' => ['title' => 'News']],
+ ]);
+
+ app(RunGenerateNode::class)($run, [
+ 'accounts' => [['social_account_id' => (string) $account->id, 'content_type' => ContentType::LinkedInPost->value]],
+ 'prompt_template' => 'Write about {{ trigger.title }}',
+ ]);
+
+ PostContentGenerator::assertPrompted(fn ($prompt) => $prompt->agent->platformContext === ContentType::LinkedInPost->value);
+});
+
+it('writes for the most restrictive network when several are selected', function () {
+ PostContentGenerator::fake([
+ ['content' => 'c', 'image_title' => 't', 'image_body' => 'b', 'image_keywords' => ['k']],
+ ]);
+ PostContentHumanizer::fake([['content' => 'c', 'image_title' => 't', 'image_body' => 'b']]);
+
+ $workspace = Workspace::factory()->create();
+ $linkedin = SocialAccount::factory()->for($workspace)->create(['platform' => 'linkedin']);
+ $x = SocialAccount::factory()->for($workspace)->create(['platform' => 'x']);
+ $run = AutomationRun::factory()->for(Automation::factory()->for($workspace))->create([
+ 'context' => ['trigger' => ['title' => 'News']],
+ ]);
+
+ // X caps at 280 chars, LinkedIn at 3000 — copy must fit the tighter one.
+ app(RunGenerateNode::class)($run, [
+ 'accounts' => [
+ ['social_account_id' => (string) $linkedin->id, 'content_type' => ContentType::LinkedInPost->value],
+ ['social_account_id' => (string) $x->id, 'content_type' => ContentType::XPost->value],
+ ],
+ 'prompt_template' => 'Write about {{ trigger.title }}',
+ ]);
+
+ PostContentGenerator::assertPrompted(fn ($prompt) => $prompt->agent->platformContext === ContentType::XPost->value);
+ // The humanizer second pass gets the same context so it can't rewrite the
+ // copy back over the platform's character cap.
+ PostContentHumanizer::assertPrompted(fn ($prompt) => $prompt->agent->platformContext === ContentType::XPost->value);
+});
+
+it('leaves the platform context null when no account carries a content type', function () {
+ PostContentGenerator::fake([
+ ['content' => 'c', 'image_title' => 't', 'image_body' => 'b', 'image_keywords' => ['k']],
+ ]);
+ PostContentHumanizer::fake([['content' => 'c', 'image_title' => 't', 'image_body' => 'b']]);
+
+ $workspace = Workspace::factory()->create();
+ $account = SocialAccount::factory()->for($workspace)->create(['platform' => 'x']);
+ $run = AutomationRun::factory()->for(Automation::factory()->for($workspace))->create([
+ 'context' => ['trigger' => ['title' => 'News']],
+ ]);
+
+ app(RunGenerateNode::class)($run, [
+ 'accounts' => [['social_account_id' => (string) $account->id]],
+ 'prompt_template' => 'Write about {{ trigger.title }}',
+ ]);
+
+ PostContentGenerator::assertPrompted(fn ($prompt) => $prompt->agent->platformContext === null);
+});
+
+it('still resolves the most restrictive context when the format is a carousel', function () {
+ PostContentGenerator::fake([
+ ['caption' => 'cap', 'slides' => [
+ ['title' => 'S1', 'body' => 'B1', 'image_keywords' => ['a']],
+ ['title' => 'S2', 'body' => 'B2', 'image_keywords' => ['b']],
+ ]],
+ ]);
+ PostContentHumanizer::fake([
+ ['caption' => 'cap', 'slides' => [['title' => 'S1', 'body' => 'B1'], ['title' => 'S2', 'body' => 'B2']]],
+ ]);
+
+ $workspace = Workspace::factory()->create();
+ $instagram = SocialAccount::factory()->for($workspace)->create(['platform' => 'instagram']);
+ $x = SocialAccount::factory()->for($workspace)->create(['platform' => 'x']);
+ $run = AutomationRun::factory()->for(Automation::factory()->for($workspace))->create([
+ 'context' => ['trigger' => ['title' => 'News']],
+ ]);
+
+ // Instagram feed is carousel-capable, so the format is a carousel, yet the
+ // platform context must still be X (280) — the tightest selected network.
+ app(RunGenerateNode::class)($run, [
+ 'accounts' => [
+ ['social_account_id' => (string) $instagram->id, 'content_type' => ContentType::InstagramFeed->value],
+ ['social_account_id' => (string) $x->id, 'content_type' => ContentType::XPost->value],
+ ],
+ 'prompt_template' => 'Write about {{ trigger.title }}',
+ 'target_slide_count' => 2,
+ ]);
+
+ PostContentGenerator::assertPrompted(fn ($prompt) => $prompt->agent->format === 'carousel'
+ && $prompt->agent->platformContext === ContentType::XPost->value);
+});
+
+it('leaves the platform context null for the legacy social_account_ids shape', function () {
+ PostContentGenerator::fake([
+ ['content' => 'c', 'image_title' => 't', 'image_body' => 'b', 'image_keywords' => ['k']],
+ ]);
+ PostContentHumanizer::fake([['content' => 'c', 'image_title' => 't', 'image_body' => 'b']]);
+
+ $workspace = Workspace::factory()->create();
+ $account = SocialAccount::factory()->for($workspace)->create(['platform' => 'x']);
+ $run = AutomationRun::factory()->for(Automation::factory()->for($workspace))->create([
+ 'context' => ['trigger' => ['title' => 'News']],
+ ]);
+
+ app(RunGenerateNode::class)($run, [
+ 'social_account_ids' => [(string) $account->id],
+ 'prompt_template' => 'Write about {{ trigger.title }}',
+ ]);
+
+ PostContentGenerator::assertPrompted(fn ($prompt) => $prompt->agent->platformContext === null);
+});
+
it('interpolates the prompt template before passing it to the generator', function () {
PostContentGenerator::fake([
['content' => 'Interpolated content', 'image_title' => 'Title', 'image_body' => 'Body', 'image_keywords' => ['kw']],
@@ -165,7 +321,7 @@ it('attaches a generated image to a single-format post', function () {
['social_account_id' => (string) $account->id, 'content_type' => ContentType::XPost->value, 'meta' => []],
],
'prompt_template' => 'Write about {{ trigger.title }}',
- 'include_image' => true,
+ 'target_slide_count' => 1,
]);
expect($result->status->value)->toBe('completed');
@@ -221,7 +377,7 @@ it('attaches one image per slide for carousel', function () {
expect($post->media)->toHaveCount(3);
});
-it('skips images when include_image is false', function () {
+it('skips images when image count is zero', function () {
PostContentGenerator::fake([
['content' => 'No image post', 'image_title' => 'Title', 'image_body' => 'Body', 'image_keywords' => ['kw']],
]);
@@ -248,7 +404,7 @@ it('skips images when include_image is false', function () {
['social_account_id' => (string) $account->id, 'content_type' => ContentType::XPost->value, 'meta' => []],
],
'prompt_template' => 'Write about {{ trigger.title }}',
- 'include_image' => false,
+ 'target_slide_count' => 0,
]);
expect($result->status->value)->toBe('completed');
@@ -286,7 +442,7 @@ it('does not generate images or persist on a dry run', function () {
['social_account_id' => (string) $account->id, 'content_type' => ContentType::XPost->value, 'meta' => []],
],
'prompt_template' => 'Write about {{ trigger.title }}',
- 'include_image' => true,
+ 'target_slide_count' => 1,
]);
expect($result->status->value)->toBe('completed');
diff --git a/tests/Feature/Automation/Tree/ContentPipelineTreesTest.php b/tests/Feature/Automation/Tree/ContentPipelineTreesTest.php
index f83d36d6d..b1eef5da2 100644
--- a/tests/Feature/Automation/Tree/ContentPipelineTreesTest.php
+++ b/tests/Feature/Automation/Tree/ContentPipelineTreesTest.php
@@ -64,7 +64,7 @@ it('runs cron → generate → publish to completion and creates a draft post',
['social_account_id' => (string) $account->id, 'content_type' => 'instagram_feed', 'meta' => []],
],
'prompt_template' => 'Write something',
- 'include_image' => false,
+ 'target_slide_count' => 0,
]],
['id' => 'p', 'type' => 'publish', 'position' => ['x' => 2, 'y' => 0], 'data' => ['mode' => 'draft']],
],
@@ -107,7 +107,7 @@ it('runs fetch_rss → generate → delay → publish, pausing at the delay then
['social_account_id' => (string) $account->id, 'content_type' => 'instagram_feed', 'meta' => []],
],
'prompt_template' => 'Write about {{ fetched.title }}',
- 'include_image' => false,
+ 'target_slide_count' => 0,
]],
['id' => 'd', 'type' => 'delay', 'position' => ['x' => 3, 'y' => 0], 'data' => ['duration' => 2, 'unit' => 'hours']],
['id' => 'p', 'type' => 'publish', 'position' => ['x' => 4, 'y' => 0], 'data' => ['mode' => 'draft']],
@@ -225,7 +225,7 @@ it('runs fetch_rss → (no_items) → end when the feed yields no new items and
'nodes' => [
['id' => 't', 'type' => 'trigger', 'position' => ['x' => 0, 'y' => 0], 'data' => ['trigger_type' => 'schedule']],
['id' => 'f', 'type' => 'fetch_rss', 'position' => ['x' => 1, 'y' => 0], 'data' => ['feed_url' => 'https://1.1.1.1/feed']],
- ['id' => 'g', 'type' => 'generate', 'position' => ['x' => 2, 'y' => 0], 'data' => ['prompt_template' => 'x', 'include_image' => false]],
+ ['id' => 'g', 'type' => 'generate', 'position' => ['x' => 2, 'y' => 0], 'data' => ['prompt_template' => 'x', 'target_slide_count' => 0]],
['id' => 'e', 'type' => 'end', 'position' => ['x' => 2, 'y' => 1], 'data' => []],
],
'connections' => [
diff --git a/tests/Feature/Brand/VoicePromptTest.php b/tests/Feature/Brand/VoicePromptTest.php
new file mode 100644
index 000000000..35101348a
--- /dev/null
+++ b/tests/Feature/Brand/VoicePromptTest.php
@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Enums\Workspace\BrandVoiceTrait;
+
+test('the voice prompt partial renders an instruction for every trait', function () {
+ $rendered = view('prompts.post_content._voice', [
+ 'brand_voice_traits' => BrandVoiceTrait::values(),
+ ])->render();
+
+ $lines = array_filter(
+ explode("\n", trim($rendered)),
+ fn (string $line) => str_starts_with(trim($line), '- '),
+ );
+
+ // Every trait must map to exactly one instruction line — if a trait is added
+ // to the enum but not to the Blade phrase map, this catches the silent skip.
+ expect($lines)->toHaveCount(count(BrandVoiceTrait::values()));
+});
+
+test('the voice prompt partial skips unknown traits without erroring', function () {
+ $rendered = view('prompts.post_content._voice', [
+ 'brand_voice_traits' => ['not_a_trait', 'direct'],
+ ])->render();
+
+ expect(trim($rendered))->toBe('- Use direct, plain, accessible language.');
+});
diff --git a/tests/Feature/WorkspaceControllerTest.php b/tests/Feature/WorkspaceControllerTest.php
index aa0ed4f24..6b04cd7b4 100644
--- a/tests/Feature/WorkspaceControllerTest.php
+++ b/tests/Feature/WorkspaceControllerTest.php
@@ -220,6 +220,30 @@ test('update workspace settings updates workspace and redirects back', function
expect($this->workspace->name)->toBe('Updated Name');
});
+test('update workspace settings persists brand voice traits', function () {
+ $this->actingAs($this->user)
+ ->from(route('app.workspace.brand'))
+ ->put(route('app.workspace.settings.update'), [
+ 'name' => $this->workspace->name,
+ 'brand_font' => 'Inter',
+ 'image_style' => 'cinematic',
+ 'brand_voice_traits' => ['third_person', 'no_hype', 'data_driven'],
+ ])->assertRedirect(route('app.workspace.brand'));
+
+ expect($this->workspace->refresh()->brand_voice_traits)->toBe(['third_person', 'no_hype', 'data_driven']);
+});
+
+test('update workspace settings rejects an unknown brand voice trait', function () {
+ $this->actingAs($this->user)
+ ->from(route('app.workspace.brand'))
+ ->put(route('app.workspace.settings.update'), [
+ 'name' => $this->workspace->name,
+ 'brand_font' => 'Inter',
+ 'image_style' => 'cinematic',
+ 'brand_voice_traits' => ['third_person', 'not_a_real_trait'],
+ ])->assertSessionHasErrors('brand_voice_traits.1');
+});
+
test('update workspace settings persists the image_style choice', function () {
$this->actingAs($this->user)
->from(route('app.workspace.brand'))
@@ -438,7 +462,7 @@ test('autofillBrand returns metadata without persisting anything', function () {
->postJson(route('app.workspaces.autofill'), ['url' => 'https://example.com']);
$response->assertOk();
- $response->assertJsonStructure(['name', 'brand_description', 'brand_tone', 'brand_voice_notes', 'content_language', 'logo_url']);
+ $response->assertJsonStructure(['name', 'brand_description', 'content_language', 'logo_url']);
expect(Workspace::count())->toBe($initialWorkspaceCount);
});
@@ -470,8 +494,7 @@ test('store persists brand fields and redirects to /accounts with openDialog fla
'name' => 'Acme Inc',
'brand_website' => 'https://acme.example',
'brand_description' => 'We sell rockets.',
- 'brand_tone' => 'professional',
- 'brand_voice_notes' => 'short, punchy.',
+ 'brand_voice_traits' => ['third_person', 'no_hype'],
'content_language' => 'en',
]);
diff --git a/tests/Unit/Ai/Agents/PostContentGeneratorTest.php b/tests/Unit/Ai/Agents/PostContentGeneratorTest.php
index b791a18ab..fd14118c0 100644
--- a/tests/Unit/Ai/Agents/PostContentGeneratorTest.php
+++ b/tests/Unit/Ai/Agents/PostContentGeneratorTest.php
@@ -10,8 +10,7 @@ test('instructions render brand context', function () {
$workspace = Workspace::factory()->make([
'name' => 'TryPost',
'brand_description' => 'Social media scheduling tool',
- 'brand_tone' => 'friendly',
- 'brand_voice_notes' => 'Use everyday language, no jargon.',
+ 'brand_voice_traits' => ['friendly', 'direct'],
'content_language' => 'en',
]);
@@ -19,8 +18,26 @@ test('instructions render brand context', function () {
$instructions = $agent->instructions();
expect($instructions)->toContain('TryPost');
- expect($instructions)->toContain('friendly');
- expect($instructions)->toContain('everyday language');
+ expect($instructions)->toContain('friendly'); // "Be warm and friendly."
+ expect($instructions)->toContain('direct'); // "Use direct, plain, accessible language."
+ expect($instructions)->toContain('en');
+});
+
+test('instructions omit brand description and voice when applyBrandVoice is false', function () {
+ $workspace = Workspace::factory()->make([
+ 'name' => 'TryPost',
+ 'brand_description' => 'A social scheduling tool for founders',
+ 'brand_voice_traits' => ['first_person', 'transparent'],
+ 'content_language' => 'en',
+ ]);
+
+ $agent = new PostContentGenerator(workspace: $workspace, applyBrandVoice: false);
+ $instructions = $agent->instructions();
+
+ expect($instructions)->not->toContain('A social scheduling tool for founders');
+ expect($instructions)->not->toContain('first person');
+ expect($instructions)->not->toContain('behind-the-scenes');
+ // Language still applies — it isn't part of the brand voice.
expect($instructions)->toContain('en');
});
@@ -149,3 +166,16 @@ test('instructions do not include examples section when platform context is null
expect($agent->instructions())->not->toContain('curated library');
});
+
+test('instructions inject the platform character cap from the shared budget', function () {
+ $agent = new PostContentGenerator(
+ workspace: Workspace::factory()->make(),
+ format: 'single',
+ platformContext: 'x_post',
+ );
+
+ $instructions = $agent->instructions();
+
+ expect($instructions)->toContain('280'); // X hard cap
+ expect($instructions)->toContain('Hard cap');
+});
diff --git a/tests/Unit/Ai/Agents/PostContentHumanizerTest.php b/tests/Unit/Ai/Agents/PostContentHumanizerTest.php
new file mode 100644
index 000000000..4d3763ff4
--- /dev/null
+++ b/tests/Unit/Ai/Agents/PostContentHumanizerTest.php
@@ -0,0 +1,38 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Ai\Agents\PostContentHumanizer;
+use App\Enums\PostPlatform\ContentType;
+use App\Models\Workspace;
+
+test('instructions inject the platform character cap so the rewrite cannot drift over it', function () {
+ $workspace = Workspace::factory()->make(['content_language' => 'en']);
+
+ $agent = new PostContentHumanizer(
+ workspace: $workspace,
+ platformContext: ContentType::XPost->value,
+ );
+
+ $instructions = $agent->instructions();
+
+ // X caps at 280 chars — the humanizer must be told, mirroring the generator.
+ expect($instructions)->toContain('280');
+ expect($instructions)->toContain('Hard cap');
+});
+
+test('instructions omit the length section when no platform context is given', function () {
+ $workspace = Workspace::factory()->make(['content_language' => 'en']);
+
+ $agent = new PostContentHumanizer(workspace: $workspace);
+
+ expect($agent->instructions())->not->toContain('Hard cap');
+});
+
+test('instructions still render the AI-tell removal rules', function () {
+ $workspace = Workspace::factory()->make(['content_language' => 'en']);
+
+ $agent = new PostContentHumanizer(workspace: $workspace);
+
+ expect($agent->instructions())->toContain('AI-tells');
+});
diff --git a/tests/Unit/Ai/Agents/PostContentReviewerTest.php b/tests/Unit/Ai/Agents/PostContentReviewerTest.php
index 2fdc4b11a..a99413928 100644
--- a/tests/Unit/Ai/Agents/PostContentReviewerTest.php
+++ b/tests/Unit/Ai/Agents/PostContentReviewerTest.php
@@ -9,8 +9,7 @@ use Illuminate\JsonSchema\JsonSchemaTypeFactory;
test('instructions render brand context and language', function () {
$workspace = Workspace::factory()->make([
'name' => 'TryPost',
- 'brand_tone' => 'friendly',
- 'brand_voice_notes' => 'Use plain English.',
+ 'brand_voice_traits' => ['friendly', 'concise'],
'content_language' => 'pt-BR',
]);
@@ -18,8 +17,8 @@ test('instructions render brand context and language', function () {
$instructions = $agent->instructions();
expect($instructions)->toContain('TryPost');
- expect($instructions)->toContain('friendly');
- expect($instructions)->toContain('plain English');
+ expect($instructions)->toContain('friendly'); // "Be warm and friendly."
+ expect($instructions)->toContain('short'); // "Keep sentences short and objective."
expect($instructions)->toContain('pt-BR');
});
diff --git a/tests/Unit/Enums/BrandVoiceTraitTest.php b/tests/Unit/Enums/BrandVoiceTraitTest.php
new file mode 100644
index 000000000..900724d6d
--- /dev/null
+++ b/tests/Unit/Enums/BrandVoiceTraitTest.php
@@ -0,0 +1,49 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Enums\Workspace\BrandVoiceTrait;
+
+test('coerce drops invalid and non-string values', function () {
+ expect(BrandVoiceTrait::coerce(['third_person', 'not_a_trait', 42, null, 'direct']))
+ ->toBe(['third_person', 'direct']);
+});
+
+test('coerce keeps only the first value of each single-select dimension', function () {
+ // Two POV + two formality values — only the first of each survives.
+ expect(BrandVoiceTrait::coerce(['third_person', 'first_person', 'formal', 'casual']))
+ ->toBe(['third_person', 'formal']);
+});
+
+test('coerce stacks multiple style traits', function () {
+ expect(BrandVoiceTrait::coerce(['direct', 'concise', 'no_hype']))
+ ->toBe(['direct', 'concise', 'no_hype']);
+});
+
+test('coerce preserves input order', function () {
+ expect(BrandVoiceTrait::coerce(['no_hype', 'third_person', 'direct']))
+ ->toBe(['no_hype', 'third_person', 'direct']);
+});
+
+test('coerce returns empty for empty input', function () {
+ expect(BrandVoiceTrait::coerce([]))->toBe([]);
+});
+
+test('every trait maps to a group, and style is the only multi-select group', function () {
+ $single = BrandVoiceTrait::singleSelectGroups();
+
+ foreach (BrandVoiceTrait::cases() as $trait) {
+ $group = $trait->group();
+ expect($group)->not->toBeEmpty();
+
+ if ($group !== 'style') {
+ expect($single)->toContain($group);
+ }
+ }
+});
+
+test('grouped buckets every trait value exactly once', function () {
+ $flat = array_merge(...array_values(BrandVoiceTrait::grouped()));
+
+ expect($flat)->toEqualCanonicalizing(BrandVoiceTrait::values());
+});
diff --git a/tests/Unit/Services/Image/TemplateImageGeneratorTest.php b/tests/Unit/Services/Image/TemplateImageGeneratorTest.php
index 7c3f806cc..938f9855b 100644
--- a/tests/Unit/Services/Image/TemplateImageGeneratorTest.php
+++ b/tests/Unit/Services/Image/TemplateImageGeneratorTest.php
@@ -90,6 +90,32 @@ test('renders a slide and stores webp when AI returns bytes', function () use ($
&& $prompt->contains('blue'));
})->skip(fn () => ! extension_loaded('gd'), 'GD extension required');
+test('omits the brand colour palette from the AI image prompt when brand visuals are off', function () use ($minimalPng) {
+ Image::fake([base64_encode($minimalPng())]);
+
+ if (! file_exists(base_path('resources/fonts/Inter-Bold.ttf'))) {
+ $this->markTestSkipped('Inter fonts not available — skipping render-dependent test.');
+ }
+
+ $service = new TemplateImageGenerator(new BrandColorMapper, new AiImageClient);
+ $service->render(
+ workspace: Workspace::factory()->make([
+ 'brand_color' => '#0000ff',
+ 'background_color' => '#ffffff',
+ 'text_color' => '#000000',
+ ]),
+ socialAccount: SocialAccount::factory()->make(['username' => 'u', 'display_name' => 'U']),
+ title: 'Hello',
+ body: 'Body',
+ imageKeywords: ['kitchen'],
+ applyBrandVisuals: false,
+ );
+
+ // Despite the workspace having brand colours, the prompt must stay neutral.
+ Image::assertGenerated(fn ($prompt) => $prompt->contains('kitchen')
+ && ! $prompt->contains('BRAND COLOR PALETTE'));
+})->skip(fn () => ! extension_loaded('gd'), 'GD extension required');
+
test('reuses existing background path when provided', function () use ($minimalPng) {
if (! file_exists(base_path('resources/fonts/Inter-Bold.ttf'))) {
$this->markTestSkipped('Inter fonts not available — skipping render-dependent test.');