Fix retry reprocessing all proofs instead of just the failed one

DB-loaded proofs don't have a tempId, so the retry handler's
proof.tempId === tempId check matched all DB proofs (both undefined).
Now the handler uses a matchProof helper that checks both tempId and
_id, and call sites pass proof.tempId || proof._id as the identifier.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
michael 2026-02-12 18:15:09 -06:00
parent a15bce8796
commit f3d7f9b6d3
3 changed files with 9 additions and 9 deletions

View file

@ -347,8 +347,9 @@ const App: React.FC = () => {
}
};
const handleRetryAnalysis = async (campaignName: string, tempId: string) => {
const proofToRetry = campaignProofs[campaignName]?.find(proof => proof.tempId === tempId);
const handleRetryAnalysis = async (campaignName: string, proofId: string) => {
const matchProof = (proof: any) => proof.tempId === proofId || proof._id === proofId;
const proofToRetry = campaignProofs[campaignName]?.find(matchProof);
if (!proofToRetry) {
console.error("Proof to retry not found");
@ -385,7 +386,7 @@ const App: React.FC = () => {
setCampaignProofs(prevProofs => ({
...prevProofs,
[campaignName]: prevProofs[campaignName].map(proof =>
proof.tempId === tempId ? { ...proof, status: 'analyzing', analysisProgress: { completed: 0, total: AGENT_NAMES.length + 1 } } : proof
matchProof(proof) ? { ...proof, status: 'analyzing', analysisProgress: { completed: 0, total: AGENT_NAMES.length + 1 } } : proof
)
}));
@ -393,7 +394,7 @@ const App: React.FC = () => {
setCampaignProofs(prevProofs => {
const currentProofs = prevProofs[campaignName] || [];
const updatedProofs = currentProofs.map(proof => {
if (proof.tempId === tempId && proof.status === 'analyzing') {
if (matchProof(proof) && proof.status === 'analyzing') {
const newCompleted = (proof.analysisProgress?.completed ?? 0) + 1;
return { ...proof, analysisProgress: { ...proof.analysisProgress, completed: newCompleted } };
}
@ -423,10 +424,9 @@ const App: React.FC = () => {
}));
} catch (refreshError) {
console.error('Failed to refresh proofs after retry:', refreshError);
// Remove the temp placeholder since analysis succeeded
setCampaignProofs(prevProofs => ({
...prevProofs,
[campaignName]: prevProofs[campaignName].filter(p => p.tempId !== tempId)
[campaignName]: prevProofs[campaignName].filter(p => !matchProof(p))
}));
}
@ -447,7 +447,7 @@ const App: React.FC = () => {
setCampaignProofs(prevProofs => ({
...prevProofs,
[campaignName]: prevProofs[campaignName].map(proof =>
proof.tempId === tempId ? { ...proof, status: 'error' } : proof
matchProof(proof) ? { ...proof, status: 'error' } : proof
)
}));
}

View file

@ -1259,7 +1259,7 @@ const CampaignDetail: React.FC<{
Analysis failed.
</button>
<button
onClick={() => onRetryAnalysis(campaignName, proof.tempId)}
onClick={() => onRetryAnalysis(campaignName, proof.tempId || proof._id)}
className="flex items-center gap-1.5 text-xs font-semibold text-active-blue hover:text-primary-blue whitespace-nowrap px-3 py-1.5 rounded-full bg-active-blue/10 hover:bg-active-blue/20 transition-colors"
>
<ArrowPathIcon className="h-4 w-4" />

View file

@ -773,7 +773,7 @@ const ProjectDetail: React.FC<{
Analysis failed.
</button>
<button
onClick={() => onRetryAnalysis(projectName, asset.tempId)}
onClick={() => onRetryAnalysis(projectName, asset.tempId || asset._id)}
className="flex items-center gap-1.5 text-xs font-semibold text-active-blue hover:text-primary-blue whitespace-nowrap px-3 py-1.5 rounded-full bg-active-blue/10 hover:bg-active-blue/20 transition-colors"
>
<ArrowPathIcon className="h-4 w-4" />