Add storyboard/video-gen/video-editing handlers and asset previews (#37-39, #45, #46)

StoryboardHandler (#37): breaks the project's script into a numbered
scene-by-scene breakdown (description + image prompt per scene) via
OpenAI in JSON mode (added json_mode support to OpenAiDriver for
reliable structured output), stored as a JSON asset.

VideoGenerationHandler (#38): generates one still image per storyboard
scene via StabilityAI — the scene *visuals*, not motion/video clips
(no text-to-video model integrated; see the task comment for why).

VideoEditingHandler (#39): the step that actually produces a video
file — assembles the scene stills into an MP4 via ffmpeg's concat
demuxer, timed to the voiceover audio's duration (probed via ffprobe)
or a fixed per-scene duration if there's no audio, then muxes the
audio track in. Verified against the real ffmpeg/ffprobe binaries on
this box, not just Process::fake().

Asset previews (#45, #46): a reusable partial renders each asset
inline by type — image/audio/video get real playback elements, text/
JSON gets a truncated <pre> block, everything else a download link.
Wired into both the awaiting_approval step view (so approving/
rejecting is an actual content review, not just a word count) and a
general project assets grid.

Also fixes a latent bug in AssetStorage::url(), found while wiring up
previews: it called Storage::url() on the default 'local' disk, which
has no configured URL driver and throws in production — only worked
before because Storage::fake() is more permissive than the real local
driver. Now serves assets through a new authenticated streaming route
instead (VideoProjectAssetController).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
m105
2026-08-06 21:15:31 +03:00
co-authored by Claude Sonnet 5
parent 55fa2ebfda
commit c249a14d78
18 changed files with 1026 additions and 34 deletions
@@ -2,10 +2,13 @@
use App\Jobs\RunWorkflowStepJob;
use App\Livewire\VideoProjects\Show;
use App\Models\User;
use App\Models\VideoProject;
use App\Models\WorkflowTemplate;
use App\Support\AssetStorage\AssetStorage;
use App\Support\VideoWorkflow\WorkflowEngine;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\Storage;
use Livewire\Livewire;
test('starting the default pipeline creates steps and queues the first handled one', function () {
@@ -29,7 +32,7 @@ test('starting the default pipeline creates steps and queues the first handled o
test('starting from a template uses its steps and does not queue unhandled types', function () {
Queue::fake();
$template = WorkflowTemplate::factory()->create(['steps' => [
['type' => 'video_generation'],
['type' => 'thumbnail_generation'],
['type' => 'youtube_publish'],
]]);
$project = VideoProject::factory()->create();
@@ -41,7 +44,7 @@ test('starting from a template uses its steps and does not queue unhandled types
expect($project->fresh()->workflow_template_id)->toBe($template->id);
expect($project->steps()->count())->toBe(2);
// video_generation has no handler yet, so nothing should be queued
// thumbnail_generation has no handler yet, so nothing should be queued
Queue::assertNotPushed(RunWorkflowStepJob::class);
});
@@ -127,3 +130,29 @@ test('skipping a step advances and queues the next handled step', function () {
expect($next->status)->toBe('in_progress');
Queue::assertPushed(RunWorkflowStepJob::class, fn ($job) => $job->stepId === $next->id);
});
test('an awaiting_approval step shows a preview of its generated asset', function () {
Storage::fake();
$project = VideoProject::factory()->create();
$engine = new WorkflowEngine;
$step = $engine->start($project, [['type' => 'script_generation', 'requires_approval' => true]]);
$asset = (new AssetStorage)->store($project, 'script', 'Once upon a time, a script.', 'txt', step: $step, mimeType: 'text/plain');
$engine->completeStep($step, ['asset_id' => $asset->id]);
$this->actingAs(User::factory()->create())
->get(route('video-projects.show', $project))
->assertOk()
->assertSee('Once upon a time, a script.');
});
test('the assets section renders a preview for an image asset', function () {
Storage::fake();
$project = VideoProject::factory()->create();
$asset = (new AssetStorage)->store($project, 'image', 'fake-png-bytes', 'png', mimeType: 'image/png');
$response = $this->actingAs(User::factory()->create())
->get(route('video-projects.show', $project));
$response->assertOk();
$response->assertSee(route('video-projects.assets.show', [$project, $asset]), false);
});