From 6e17fb82a0fb609575aed86c8ebae17f8771a6ec Mon Sep 17 00:00:00 2001 From: Simon Kuehn Date: Mon, 18 May 2026 10:01:54 +0000 Subject: [PATCH] fix: mark pipeline complete only after eBay text is generated DraftArticleHandler was calling markCompleted() before dispatching EbayTextMessage, causing the SSE to fire "completed" while the article title was still null. EbayTextHandler had no job tracking at all. - DraftArticleHandler: recordStep('draft_article') instead of markCompleted() - EbayTextHandler: call markCompleted() after setEbayTexts() so the job is only marked done once the title and description are actually written Co-Authored-By: Claude Sonnet 4.6 --- .../Messenger/Handler/DraftArticleHandler.php | 2 +- .../Messenger/Handler/EbayTextHandler.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/Messenger/Handler/DraftArticleHandler.php b/src/Infrastructure/Messenger/Handler/DraftArticleHandler.php index e294261..b4840c6 100644 --- a/src/Infrastructure/Messenger/Handler/DraftArticleHandler.php +++ b/src/Infrastructure/Messenger/Handler/DraftArticleHandler.php @@ -81,7 +81,7 @@ final class DraftArticleHandler $this->articleRepository->save($article); $job->setArticleId($article->getId()); - $job->markCompleted(['articleId' => $article->getId()->toRfc4122()]); + $job->recordStep('draft_article', ['articleId' => $article->getId()->toRfc4122()]); $this->jobRepository->save($job); // Attach any extra photos uploaded during ingest diff --git a/src/Infrastructure/Messenger/Handler/EbayTextHandler.php b/src/Infrastructure/Messenger/Handler/EbayTextHandler.php index 4956de4..1daa47f 100644 --- a/src/Infrastructure/Messenger/Handler/EbayTextHandler.php +++ b/src/Infrastructure/Messenger/Handler/EbayTextHandler.php @@ -30,8 +30,9 @@ final class EbayTextHandler return; } - $specsText = ''; $job = $this->jobRepository->findById(Uuid::fromString($message->jobId)); + + $specsText = ''; if (null !== $job) { $specsText = (string) ($job->getOutputData()['specs_research']['specsText'] ?? ''); } @@ -43,5 +44,13 @@ final class EbayTextHandler title: $texts['title'], description: $texts['description'], ); + + if (null !== $job) { + $job->markCompleted([ + 'articleId' => $message->articleId, + 'ebay_text' => ['title' => $texts['title']], + ]); + $this->jobRepository->save($job); + } } }