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:
parent
56484dac02
commit
681bfb5719
2 changed files with 26 additions and 3 deletions
|
|
@ -238,6 +238,21 @@ const UserProfileSelector = ({ profiles, selectedUserId, onSelect, onConnect })
|
||||||
};
|
};
|
||||||
|
|
||||||
const SESSION_KEY = 'openshorts_session';
|
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
|
// Matches the self-host JOB_RETENTION_SECONDS default. A restore whose job was
|
||||||
// already purged server-side fails gracefully and clears the saved session.
|
// already purged server-side fails gracefully and clears the saved session.
|
||||||
const SESSION_MAX_AGE = 86400000; // 24 hours
|
const SESSION_MAX_AGE = 86400000; // 24 hours
|
||||||
|
|
@ -263,6 +278,8 @@ function App() {
|
||||||
const [partialJob, setPartialJob] = useState(null);
|
const [partialJob, setPartialJob] = useState(null);
|
||||||
// {position, ahead, eta_seconds} while the job waits in line, else null.
|
// {position, ahead, eta_seconds} while the job waits in line, else null.
|
||||||
const [queueInfo, setQueueInfo] = useState(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
|
// 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).
|
// the ephemeral local /videos/ files have been cleaned up (e.g. after a reload).
|
||||||
const [durableClips, setDurableClips] = useState({});
|
const [durableClips, setDurableClips] = useState({});
|
||||||
|
|
@ -728,6 +745,7 @@ function App() {
|
||||||
} else if (data.status === 'failed') {
|
} else if (data.status === 'failed') {
|
||||||
setStatus('error');
|
setStatus('error');
|
||||||
const errorMsg = data.error || (data.logs && data.logs.length > 0 ? data.logs[data.logs.length - 1] : "Process failed");
|
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]);
|
setLogs(prev => [...prev, "Error: " + errorMsg]);
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
refreshMe();
|
refreshMe();
|
||||||
|
|
@ -933,6 +951,7 @@ function App() {
|
||||||
// Past every gate, so this request is really running: nothing left to resume.
|
// Past every gate, so this request is really running: nothing left to resume.
|
||||||
clearPendingJob();
|
clearPendingJob();
|
||||||
setStatus('processing');
|
setStatus('processing');
|
||||||
|
setJobError('');
|
||||||
setLogs(["Starting process..."]);
|
setLogs(["Starting process..."]);
|
||||||
setResults(null);
|
setResults(null);
|
||||||
// Studio handovers have no local media object; the preview switches to the
|
// Studio handovers have no local media object; the preview switches to the
|
||||||
|
|
@ -1045,8 +1064,10 @@ function App() {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const reason = readableError(e.message);
|
||||||
|
setJobError(reason);
|
||||||
setStatus('error');
|
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);
|
setNoSource(false);
|
||||||
setPartialJob(null);
|
setPartialJob(null);
|
||||||
setQueueInfo(null);
|
setQueueInfo(null);
|
||||||
|
setJobError('');
|
||||||
localStorage.removeItem(SESSION_KEY);
|
localStorage.removeItem(SESSION_KEY);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -2354,6 +2376,7 @@ function App() {
|
||||||
<ClipTutorial
|
<ClipTutorial
|
||||||
phase={tutorialPhase}
|
phase={tutorialPhase}
|
||||||
jobStatus={status}
|
jobStatus={status}
|
||||||
|
errorText={jobError}
|
||||||
onStart={startTutorial}
|
onStart={startTutorial}
|
||||||
onSkip={skipTutorial}
|
onSkip={skipTutorial}
|
||||||
onDismissCelebrate={finishTutorial}
|
onDismissCelebrate={finishTutorial}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ function placeTip(rect, tipW, tipH, vw, vh) {
|
||||||
*
|
*
|
||||||
* QA: #app?tutorial=1
|
* 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 [step, setStep] = useState(0);
|
||||||
const [spot, setSpot] = useState(null);
|
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="eyebrow mb-2">First clips</p>
|
||||||
<p className={`text-sm leading-relaxed ${jobStatus === 'error' ? 'text-danger' : 'text-muted'}`}>
|
<p className={`text-sm leading-relaxed ${jobStatus === 'error' ? 'text-danger' : 'text-muted'}`}>
|
||||||
{jobStatus === 'error'
|
{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.'}
|
: 'Hang on — Clip Generator is finding the moments and cutting vertical shorts.'}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue