fix(dashboard): show why a job was rejected instead of a generic failure

A new user in the first-clips tutorial who submitted a 30 s video saw only
'That run failed. Try another video'; the server's actual reason ('this video
is only 30s long, clip generation needs at least 45s') was hidden, and outside
the tutorial it landed in the log panel as raw JSON. The FastAPI detail is now
read into plain text and shown in the tutorial card and the logs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
victorcavero14 2026-09-23 08:34:27 +02:00
parent 56484dac02
commit 681bfb5719
2 changed files with 26 additions and 3 deletions

View file

@ -238,6 +238,21 @@ const UserProfileSelector = ({ profiles, selectedUserId, onSelect, onConnect })
};
const SESSION_KEY = 'openshorts_session';
// The server's own explanation for a rejected/failed job, readable: FastAPI
// answers {"detail": "..."} or {"detail": {"message": ...}}. Showing the raw
// JSON (or a generic "failed") hid actionable reasons such as "this video is
// only 30s long", and new users in the tutorial saw only "That run failed".
const readableError = (raw) => {
const text = String(raw || '').trim();
try {
const body = JSON.parse(text);
const d = body?.detail ?? body;
if (typeof d === 'string' && d) return d.slice(0, 300);
if (d && typeof d.message === 'string') return d.message.slice(0, 300);
} catch (_) { /* not JSON */ }
return text.replace(/^Error:\s*/, '').slice(0, 300) || 'Something went wrong.';
};
// Matches the self-host JOB_RETENTION_SECONDS default. A restore whose job was
// already purged server-side fails gracefully and clears the saved session.
const SESSION_MAX_AGE = 86400000; // 24 hours
@ -263,6 +278,8 @@ function App() {
const [partialJob, setPartialJob] = useState(null);
// {position, ahead, eta_seconds} while the job waits in line, else null.
const [queueInfo, setQueueInfo] = useState(null);
// Why the last job could not start or failed, in plain words (or '').
const [jobError, setJobError] = useState('');
// Durable R2 URLs (per clip index) for the current job — used as a fallback when
// the ephemeral local /videos/ files have been cleaned up (e.g. after a reload).
const [durableClips, setDurableClips] = useState({});
@ -728,6 +745,7 @@ function App() {
} else if (data.status === 'failed') {
setStatus('error');
const errorMsg = data.error || (data.logs && data.logs.length > 0 ? data.logs[data.logs.length - 1] : "Process failed");
setJobError(readableError(errorMsg));
setLogs(prev => [...prev, "Error: " + errorMsg]);
clearInterval(interval);
refreshMe();
@ -933,6 +951,7 @@ function App() {
// Past every gate, so this request is really running: nothing left to resume.
clearPendingJob();
setStatus('processing');
setJobError('');
setLogs(["Starting process..."]);
setResults(null);
// Studio handovers have no local media object; the preview switches to the
@ -1045,8 +1064,10 @@ function App() {
}
return;
}
const reason = readableError(e.message);
setJobError(reason);
setStatus('error');
setLogs(l => [...l, `Error starting job: ${e.message}`]);
setLogs(l => [...l, `Error starting job: ${reason}`]);
}
};
@ -1084,6 +1105,7 @@ function App() {
setNoSource(false);
setPartialJob(null);
setQueueInfo(null);
setJobError('');
localStorage.removeItem(SESSION_KEY);
};
@ -2354,6 +2376,7 @@ function App() {
<ClipTutorial
phase={tutorialPhase}
jobStatus={status}
errorText={jobError}
onStart={startTutorial}
onSkip={skipTutorial}
onDismissCelebrate={finishTutorial}

View file

@ -64,7 +64,7 @@ function placeTip(rect, tipW, tipH, vw, vh) {
*
* QA: #app?tutorial=1
*/
export default function ClipTutorial({ phase, jobStatus, onStart, onSkip, onDismissCelebrate }) {
export default function ClipTutorial({ phase, jobStatus, errorText, onStart, onSkip, onDismissCelebrate }) {
const [step, setStep] = useState(0);
const [spot, setSpot] = useState(null);
@ -149,7 +149,7 @@ export default function ClipTutorial({ phase, jobStatus, onStart, onSkip, onDism
<p className="eyebrow mb-2">First clips</p>
<p className={`text-sm leading-relaxed ${jobStatus === 'error' ? 'text-danger' : 'text-muted'}`}>
{jobStatus === 'error'
? 'That run failed. Try another video — other tools stay locked until one job finishes.'
? `${errorText ? `That video could not be clipped: ${errorText}` : 'That run failed.'} Try another video. Other tools unlock once one job finishes.`
: 'Hang on — Clip Generator is finding the moments and cutting vertical shorts.'}
</p>
</div>