Skip to content

fix(app): resolve evidence upload silently failing after complete_maintenance - #63

Merged
licette32 merged 2 commits into
mainfrom
fix/evidence-race-condition
Aug 23, 2026
Merged

licette32 merged 2 commits into
mainfrom
fix/evidence-race-condition

Conversation

@licette32

Copy link
Copy Markdown
Owner

Summary

Dos problemas relacionados en el flujo de evidencia del técnico:

  1. Sin feedback visual para PDFs: EvidenceUploader solo mostraba preview/nombre para imágenes. Un PDF seleccionado quedaba correctamente guardado en estado, pero la UI no lo reflejaba, parecía que no había pasado nada.

  2. Race condition silenciosa: tras completar un mantenimiento, el refresh automático de "Available Jobs" reasignaba selectedJobId al siguiente job disponible, y un efecto separado limpiaba completeSig en cualquier cambio de selectedJobId — incluyendo ese cambio automático. Esto borraba la firma de transacción antes de que el upload de evidencia pudiera dispararse, sin ningún error visible.

Changes

  • EvidenceUploader.tsx / translations.ts: feedback visual (ícono + nombre) para cualquier archivo válido, no solo imágenes; nuevo texto aclarando que la subida ocurre al completar el mantenimiento.
  • TechnicianDashboard.tsx: ref autoSelectedJob que distingue un cambio de job automático (por refresh) de uno manual del usuario. Solo el cambio manual limpia completeSig.

Testing

  • tsc --noEmit: sin errores.
  • Verificado manualmente de punta a punta: seleccionar PDF → feedback visual correcto → completar mantenimiento → "Subiendo evidencia…" → fila en maintenance_events con tx_signature, evidence_url y evidence_hash reales.

After complete_maintenance lands, fetchAvailableJobs() drops the finished job and an effect auto-reassigns selectedJobId to the next available one. A separate effect was clearing completeSig on ANY selectedJobId change, including this synthetic one - killing the pending evidence upload before it could fire, silently, with no visible error.

Added an autoSelectedJob ref to distinguish the synthetic reassignment from a user-driven job switch. Only user actions clear completeSig now.
EvidenceUploader only rendered a preview/filename when the selected
file was an image (preview state), so selecting a PDF appeared to do
nothing - the file was actually staged (setFile ran fine), there was
just no visual confirmation.

Now renders based on the file state instead of preview: shows a
generic document icon for non-image files, the filename either way,
and a new hint clarifying the file uploads once maintenance completes
(since the actual upload is deferred until txSignature arrives).
@licette32 licette32 added this to the v1.1 — Demo Day milestone Aug 23, 2026
@licette32 licette32 self-assigned this Aug 23, 2026
@vercel

vercel Bot commented Aug 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
medovant-protocol Ready Ready Preview Aug 23, 2026 8:51pm

@licette32
licette32 merged commit 0e8e3e3 into main Aug 23, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Preview — 604938b4 Deployed Aug 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant