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 <noreply@anthropic.com>
This commit is contained in:
Simon Kuehn 2026-05-18 10:01:54 +00:00
parent 0453d0542c
commit 6e17fb82a0
2 changed files with 11 additions and 2 deletions

View file

@ -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

View file

@ -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);
}
}
}