diff --git a/admin-lehrer/components/ocr-pipeline/StepOrientation.tsx b/admin-lehrer/components/ocr-pipeline/StepOrientation.tsx index 9d731c4..6935e1b 100644 --- a/admin-lehrer/components/ocr-pipeline/StepOrientation.tsx +++ b/admin-lehrer/components/ocr-pipeline/StepOrientation.tsx @@ -30,7 +30,7 @@ export function StepOrientation({ sessionId: existingSessionId, onNext, onSessio const [dragOver, setDragOver] = useState(false) const [sessionName, setSessionName] = useState('') - // Reload session data when navigating back + // Reload session data when navigating back — auto-trigger orientation if missing useEffect(() => { if (!existingSessionId || session) return @@ -51,6 +51,28 @@ export function StepOrientation({ sessionId: existingSessionId, onNext, onSessio if (data.orientation_result) { setOrientationResult(data.orientation_result) + } else { + // Session exists but orientation not yet run (e.g. page-split session) + // Auto-trigger orientation detection + setDetecting(true) + try { + const orientRes = await fetch( + `${KLAUSUR_API}/api/v1/ocr-pipeline/sessions/${existingSessionId}/orientation`, + { method: 'POST' }, + ) + if (orientRes.ok) { + const orientData = await orientRes.json() + setOrientationResult({ + orientation_degrees: orientData.orientation_degrees, + corrected: orientData.corrected, + duration_seconds: orientData.duration_seconds, + }) + } + } catch (e) { + console.error('Auto-orientation failed:', e) + } finally { + setDetecting(false) + } } } catch (e) { console.error('Failed to reload session:', e)