fix: auto-trigger orientation for page-split sessions without result

Page-split sessions (start_step=1) have no orientation_result stored.
StepOrientation now auto-runs orientation detection when loading an
existing session that lacks a result.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-24 17:19:56 +01:00
parent f931091b57
commit 7fbcae954b

View File

@@ -30,7 +30,7 @@ export function StepOrientation({ sessionId: existingSessionId, onNext, onSessio
const [dragOver, setDragOver] = useState(false) const [dragOver, setDragOver] = useState(false)
const [sessionName, setSessionName] = useState('') const [sessionName, setSessionName] = useState('')
// Reload session data when navigating back // Reload session data when navigating back — auto-trigger orientation if missing
useEffect(() => { useEffect(() => {
if (!existingSessionId || session) return if (!existingSessionId || session) return
@@ -51,6 +51,28 @@ export function StepOrientation({ sessionId: existingSessionId, onNext, onSessio
if (data.orientation_result) { if (data.orientation_result) {
setOrientationResult(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) { } catch (e) {
console.error('Failed to reload session:', e) console.error('Failed to reload session:', e)