Mentions in post comments
- @mention autocomplete (workspace members, current user excluded) with
marker syntax @[uuid] persisted, display names rendered via CommentBody
chips; live edit replaces markers with names and converts back on save.
- NotifyMentions action with workspace-scoped membership check, dedupes
same user, only newly-added mentions on update.
- Email + in-app via SendNotification job, respecting per-user
notification_preferences.mentioned_in_comment.
- Heartbeat-based presence (Cache, 60s TTL, 30s ping) so online recipients
get only the in-app notification — no email noise.
- Real-time bell on workspace.{id}.user.{id} private channel
(NotificationCreated event), scoped channel name avoids client-side
filtering and lays out a convention for future workspace channels.
- Mailable localized via lang/{en,es,pt-BR}/mail.php; Maizzle source
template for the email is committed and built into resources/views/mail.
AI generation refactor (Action layer + MCP)
- Extracted Actions/Ai/Generate{Image,Video} with QuotaExhaustedException
so agent tools and MCP tools share a single domain entry point.
- Mcp/Tools/Ai/Generate{Image,Video}Tool registered in TryPostServer; both
return MediaResource payloads.
- Orientation::imageApiSize maps non-OpenAI ratios to 1:1/2:3/3:2.
- config/ai.php is now the single source of truth driven by env, removing
the trypost.ai shim. Default text/image providers flipped to OpenAI.
Settings/UX
- /settings/workspace split into shadcn Tabs (Workspace / Brand / Users)
with three components.
- /assets and the in-editor MediaPicker open the ImagePreviewDialog
lightbox on image click while preserving action button behaviour.
- Comments tab landed via ?tab=comments&comment=<id> from notification
click (scroll-to + temporary highlight).
- Mention autocomplete popover flips above when near the viewport bottom.
- Real social platform PNGs replace Tabler brand glyphs in schedule
pills and post list, with hover tooltip carrying display_name + handle.
Bug fixes
- AcceptInvite: controller now passes workspace + role payload that the
Vue page expects; login/register CTAs preselect the invite email.
- WorkspaceInvite mailable: stopped referencing nonexistent
$invite->workspace and $invite->role; column added to the migration,
Invite model casts role to WorkspaceRole, CreateInvite persists it.
- PostCommentCreated: added broadcastAs so .PostCommentCreated actually
matches the Echo listener; payload now includes mentioned_users so
receivers render the chip correctly without a refetch.
- Preview components for X/Pinterest/Threads/Bluesky/LinkedIn/Mastodon/
TikTok/YouTube switched from item.type === 'image' to
!isVideoMedia(item) so media without a persisted type still renders.
- UpdatePostRequest now accepts media.*.{type,mime_type,size,...} so the
posts.media JSON keeps the metadata that the previews need.
- Removed throttle:6,1 from social connect routes (was 429ing legitimate
OAuth retries).
- Used MediaType enum cases instead of literal 'image'/'video' strings
when creating media rows.
Tests
- MentionParser unit tests, NotifyMentions feature tests including
online/offline channel selection and preference gating, MCP AI tool
happy paths, MentionedInComment mailable rendering, AcceptInvite +
search-members + index mentioned_users path. 1229 passing.
115 lines
3.4 KiB
PHP
115 lines
3.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Ai\Tools\AttachmentCollector;
|
|
use App\Ai\Tools\GenerateImage;
|
|
use App\Enums\Ai\UsageType;
|
|
use App\Enums\UserWorkspace\Role;
|
|
use App\Models\AiUsageLog;
|
|
use App\Models\Post;
|
|
use App\Models\User;
|
|
use App\Models\Workspace;
|
|
use Illuminate\JsonSchema\JsonSchemaTypeFactory;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Laravel\Ai\Image;
|
|
use Laravel\Ai\Tools\Request as ToolRequest;
|
|
|
|
beforeEach(function () {
|
|
Storage::fake('public');
|
|
$this->user = User::factory()->create([]);
|
|
$this->workspace = Workspace::factory()->create(['user_id' => $this->user->id]);
|
|
$this->workspace->members()->attach($this->user->id, ['role' => Role::Member->value]);
|
|
$this->post = Post::factory()->create([
|
|
'workspace_id' => $this->workspace->id,
|
|
'user_id' => $this->user->id,
|
|
]);
|
|
app(AttachmentCollector::class)->clear();
|
|
});
|
|
|
|
test('tool generates image, pushes attachment to collector, creates usage log', function () {
|
|
Image::fake();
|
|
|
|
$tool = new GenerateImage(
|
|
workspace: $this->workspace,
|
|
post: $this->post,
|
|
userId: $this->user->id,
|
|
);
|
|
|
|
$summary = $tool->handle(new ToolRequest([
|
|
'prompt' => 'A sunset beach',
|
|
'orientation' => 'vertical',
|
|
]));
|
|
|
|
expect((string) $summary)->toContain('image');
|
|
|
|
$collector = app(AttachmentCollector::class);
|
|
expect($collector->all())->toHaveCount(1);
|
|
|
|
$attachment = $collector->all()[0];
|
|
expect($attachment)->toHaveKeys(['id', 'path', 'url', 'mime_type', 'type']);
|
|
expect($attachment['type'])->toBe('image');
|
|
expect($attachment['mime_type'])->toBe('image/png');
|
|
|
|
Image::assertGenerated(fn ($prompt) => true);
|
|
|
|
$this->assertDatabaseHas('workspace_ai_usages', [
|
|
'workspace_id' => $this->workspace->id,
|
|
'type' => UsageType::Image->value,
|
|
'provider' => config('ai.default_for_images'),
|
|
]);
|
|
});
|
|
|
|
test('tool defaults to vertical when orientation is unknown', function () {
|
|
Image::fake();
|
|
|
|
$tool = new GenerateImage(
|
|
workspace: $this->workspace,
|
|
post: $this->post,
|
|
userId: $this->user->id,
|
|
);
|
|
|
|
$tool->handle(new ToolRequest([
|
|
'prompt' => 'A forest',
|
|
'orientation' => 'gibberish',
|
|
]));
|
|
|
|
expect(app(AttachmentCollector::class)->all()[0]['type'])->toBe('image');
|
|
});
|
|
|
|
test('tool refuses to generate when monthly image quota is exhausted', function () {
|
|
Image::fake();
|
|
|
|
// Fill up the image quota. Default (no plan attached) is 50 images.
|
|
AiUsageLog::factory()->image()->count(50)->create([
|
|
'account_id' => $this->workspace->account_id,
|
|
'workspace_id' => $this->workspace->id,
|
|
]);
|
|
|
|
$tool = new GenerateImage(
|
|
workspace: $this->workspace,
|
|
post: $this->post,
|
|
userId: $this->user->id,
|
|
);
|
|
|
|
$summary = $tool->handle(new ToolRequest([
|
|
'prompt' => 'A sunset',
|
|
'orientation' => 'vertical',
|
|
]));
|
|
|
|
expect((string) $summary)->toContain('quota exhausted');
|
|
expect(app(AttachmentCollector::class)->all())->toBeEmpty();
|
|
Image::assertNothingGenerated();
|
|
});
|
|
|
|
test('tool exposes schema with prompt and orientation parameters', function () {
|
|
$tool = new GenerateImage(
|
|
workspace: $this->workspace,
|
|
post: $this->post,
|
|
userId: $this->user->id,
|
|
);
|
|
|
|
$schema = $tool->schema(new JsonSchemaTypeFactory);
|
|
|
|
expect($schema)->toHaveKeys(['prompt', 'orientation']);
|
|
});
|