Remove Hauptseite/Box tabs from Kombi pipeline
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 27s
CI / test-go-edu-search (push) Successful in 29s
CI / test-python-klausur (push) Failing after 2m15s
CI / test-python-agent-core (push) Successful in 16s
CI / test-nodejs-website (push) Successful in 20s

Page-split now creates independent sessions that appear directly in
the session list. After split, the UI switches to the first child
session. BoxSessionTabs, sub-session state, and parent-child tracking
removed from Kombi code. Legacy ocr-overlay still uses BoxSessionTabs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-27 17:43:58 +01:00
parent 925f4356ce
commit 0168ab1a67
4 changed files with 36 additions and 130 deletions

View File

@@ -2,7 +2,6 @@
import { Suspense } from 'react' import { Suspense } from 'react'
import { PagePurpose } from '@/components/common/PagePurpose' import { PagePurpose } from '@/components/common/PagePurpose'
import { BoxSessionTabs } from '@/components/ocr-pipeline/BoxSessionTabs'
import { KombiStepper } from '@/components/ocr-kombi/KombiStepper' import { KombiStepper } from '@/components/ocr-kombi/KombiStepper'
import { SessionList } from '@/components/ocr-kombi/SessionList' import { SessionList } from '@/components/ocr-kombi/SessionList'
import { SessionHeader } from '@/components/ocr-kombi/SessionHeader' import { SessionHeader } from '@/components/ocr-kombi/SessionHeader'
@@ -27,8 +26,6 @@ function OcrKombiContent() {
loadingSessions, loadingSessions,
activeCategory, activeCategory,
isGroundTruth, isGroundTruth,
subSessions,
parentSessionId,
steps, steps,
gridSaveRef, gridSaveRef,
groupedSessions, groupedSessions,
@@ -40,11 +37,8 @@ function OcrKombiContent() {
deleteSession, deleteSession,
renameSession, renameSession,
updateCategory, updateCategory,
handleSessionChange,
setSessionId, setSessionId,
setSessionName, setSessionName,
setSubSessions,
setParentSessionId,
setIsGroundTruth, setIsGroundTruth,
} = useKombiPipeline() } = useKombiPipeline()
@@ -75,17 +69,11 @@ function OcrKombiContent() {
<StepPageSplit <StepPageSplit
sessionId={sessionId} sessionId={sessionId}
sessionName={sessionName} sessionName={sessionName}
onNext={() => { onNext={handleNext}
// If sub-sessions were created, switch to the first one onSplitComplete={(childId, childName) => {
if (subSessions.length > 0) { // Switch to the first child session and refresh the list
setSessionId(subSessions[0].id) setSessionId(childId)
setSessionName(subSessions[0].name) setSessionName(childName)
}
handleNext()
}}
onSubSessionsCreated={(subs) => {
setSubSessions(subs)
if (sessionId) setParentSessionId(sessionId)
loadSessions() loadSessions()
}} }}
/> />
@@ -161,15 +149,6 @@ function OcrKombiContent() {
onStepClick={handleStepClick} onStepClick={handleStepClick}
/> />
{subSessions.length > 0 && parentSessionId && sessionId && (
<BoxSessionTabs
parentSessionId={parentSessionId}
subSessions={subSessions}
activeSessionId={sessionId}
onSessionChange={handleSessionChange}
/>
)}
<div className="min-h-[400px]">{renderStep()}</div> <div className="min-h-[400px]">{renderStep()}</div>
</div> </div>
) )

View File

@@ -8,7 +8,6 @@ export { DOCUMENT_CATEGORIES } from '../ocr-pipeline/types'
export type { export type {
SessionListItem, SessionListItem,
SessionInfo, SessionInfo,
SubSession,
OrientationResult, OrientationResult,
CropResult, CropResult,
DeskewResult, DeskewResult,

View File

@@ -4,7 +4,7 @@ import { useCallback, useEffect, useState, useRef } from 'react'
import { useSearchParams } from 'next/navigation' import { useSearchParams } from 'next/navigation'
import type { PipelineStep, DocumentCategory } from './types' import type { PipelineStep, DocumentCategory } from './types'
import { KOMBI_V2_STEPS, dbStepToKombiV2Ui } from './types' import { KOMBI_V2_STEPS, dbStepToKombiV2Ui } from './types'
import type { SubSession, SessionListItem } from '../ocr-pipeline/types' import type { SessionListItem } from '../ocr-pipeline/types'
export type { SessionListItem } export type { SessionListItem }
@@ -33,8 +33,6 @@ export function useKombiPipeline() {
const [loadingSessions, setLoadingSessions] = useState(true) const [loadingSessions, setLoadingSessions] = useState(true)
const [activeCategory, setActiveCategory] = useState<DocumentCategory | undefined>(undefined) const [activeCategory, setActiveCategory] = useState<DocumentCategory | undefined>(undefined)
const [isGroundTruth, setIsGroundTruth] = useState(false) const [isGroundTruth, setIsGroundTruth] = useState(false)
const [subSessions, setSubSessions] = useState<SubSession[]>([])
const [parentSessionId, setParentSessionId] = useState<string | null>(null)
const [steps, setSteps] = useState<PipelineStep[]>(initSteps()) const [steps, setSteps] = useState<PipelineStep[]>(initSteps())
const searchParams = useSearchParams() const searchParams = useSearchParams()
@@ -115,7 +113,7 @@ export function useKombiPipeline() {
// ---- Open session ---- // ---- Open session ----
const openSession = useCallback(async (sid: string, keepSubSessions?: boolean) => { const openSession = useCallback(async (sid: string) => {
try { try {
const res = await fetch(`${KLAUSUR_API}/api/v1/ocr-pipeline/sessions/${sid}`) const res = await fetch(`${KLAUSUR_API}/api/v1/ocr-pipeline/sessions/${sid}`)
if (!res.ok) return if (!res.ok) return
@@ -126,17 +124,6 @@ export function useKombiPipeline() {
setActiveCategory(data.document_category || undefined) setActiveCategory(data.document_category || undefined)
setIsGroundTruth(!!data.ground_truth?.build_grid_reference) setIsGroundTruth(!!data.ground_truth?.build_grid_reference)
// Sub-session handling
if (data.sub_sessions?.length > 0) {
setSubSessions(data.sub_sessions)
setParentSessionId(sid)
} else if (data.parent_session_id) {
setParentSessionId(data.parent_session_id)
} else if (!keepSubSessions) {
setSubSessions([])
setParentSessionId(null)
}
// Determine UI step from DB state // Determine UI step from DB state
const dbStep = data.current_step || 1 const dbStep = data.current_step || 1
const hasGrid = !!data.grid_editor_result const hasGrid = !!data.grid_editor_result
@@ -159,22 +146,10 @@ export function useKombiPipeline() {
uiStep = 1 uiStep = 1
} }
const skipIds: string[] = []
const isSubSession = !!data.parent_session_id
if (isSubSession && dbStep >= 5) {
skipIds.push('upload', 'orientation', 'page-split', 'deskew', 'dewarp', 'content-crop')
if (uiStep < 6) uiStep = 6
} else if (isSubSession && dbStep >= 2) {
skipIds.push('upload', 'orientation')
if (uiStep < 2) uiStep = 2
}
setSteps( setSteps(
KOMBI_V2_STEPS.map((s, i) => ({ KOMBI_V2_STEPS.map((s, i) => ({
...s, ...s,
status: skipIds.includes(s.id) status: i < uiStep ? 'completed' : i === uiStep ? 'active' : 'pending',
? 'skipped'
: i < uiStep ? 'completed' : i === uiStep ? 'active' : 'pending',
})), })),
) )
setCurrentStep(uiStep) setCurrentStep(uiStep)
@@ -226,8 +201,6 @@ export function useKombiPipeline() {
setSteps(initSteps()) setSteps(initSteps())
setCurrentStep(0) setCurrentStep(0)
setSessionId(null) setSessionId(null)
setSubSessions([])
setParentSessionId(null)
loadSessions() loadSessions()
return return
} }
@@ -249,8 +222,6 @@ export function useKombiPipeline() {
setSessionId(null) setSessionId(null)
setSessionName('') setSessionName('')
setCurrentStep(0) setCurrentStep(0)
setSubSessions([])
setParentSessionId(null)
setSteps(initSteps()) setSteps(initSteps())
}, []) }, [])
@@ -292,40 +263,6 @@ export function useKombiPipeline() {
} }
}, [sessionId]) }, [sessionId])
// ---- Orientation completion (checks for page-split sub-sessions) ----
const handleOrientationComplete = useCallback(async (sid: string) => {
setSessionId(sid)
loadSessions()
try {
const res = await fetch(`${KLAUSUR_API}/api/v1/ocr-pipeline/sessions/${sid}`)
if (res.ok) {
const data = await res.json()
if (data.sub_sessions?.length > 0) {
const subs: SubSession[] = data.sub_sessions.map((s: SubSession) => ({
id: s.id,
name: s.name,
box_index: s.box_index,
current_step: s.current_step,
}))
setSubSessions(subs)
setParentSessionId(sid)
openSession(subs[0].id, true)
return
}
}
} catch (e) {
console.error('Failed to check for sub-sessions:', e)
}
handleNext()
}, [loadSessions, openSession, handleNext])
const handleSessionChange = useCallback((newSessionId: string) => {
openSession(newSessionId, true)
}, [openSession])
return { return {
// State // State
currentStep, currentStep,
@@ -335,8 +272,6 @@ export function useKombiPipeline() {
loadingSessions, loadingSessions,
activeCategory, activeCategory,
isGroundTruth, isGroundTruth,
subSessions,
parentSessionId,
steps, steps,
gridSaveRef, gridSaveRef,
// Computed // Computed
@@ -351,11 +286,7 @@ export function useKombiPipeline() {
deleteSession, deleteSession,
renameSession, renameSession,
updateCategory, updateCategory,
handleOrientationComplete,
handleSessionChange,
setSessionId, setSessionId,
setSubSessions,
setParentSessionId,
setSessionName, setSessionName,
setIsGroundTruth, setIsGroundTruth,
} }

View File

@@ -1,8 +1,6 @@
'use client' 'use client'
import { useState, useEffect, useRef } from 'react' import { useState, useEffect, useRef } from 'react'
import type { SubSession } from '@/app/(admin)/ai/ocr-pipeline/types'
const KLAUSUR_API = '/klausur-api' const KLAUSUR_API = '/klausur-api'
interface PageSplitResult { interface PageSplitResult {
@@ -18,10 +16,10 @@ interface StepPageSplitProps {
sessionId: string | null sessionId: string | null
sessionName: string sessionName: string
onNext: () => void onNext: () => void
onSubSessionsCreated: (subs: SubSession[]) => void onSplitComplete: (firstChildId: string, firstChildName: string) => void
} }
export function StepPageSplit({ sessionId, sessionName, onNext, onSubSessionsCreated }: StepPageSplitProps) { export function StepPageSplit({ sessionId, sessionName, onNext, onSplitComplete }: StepPageSplitProps) {
const [detecting, setDetecting] = useState(false) const [detecting, setDetecting] = useState(false)
const [splitResult, setSplitResult] = useState<PageSplitResult | null>(null) const [splitResult, setSplitResult] = useState<PageSplitResult | null>(null)
const [error, setError] = useState('') const [error, setError] = useState('')
@@ -40,30 +38,33 @@ export function StepPageSplit({ sessionId, sessionName, onNext, onSubSessionsCre
setDetecting(true) setDetecting(true)
setError('') setError('')
try { try {
// First check if sub-sessions already exist // First check if this session was already split (status='split')
const sessionRes = await fetch(`${KLAUSUR_API}/api/v1/ocr-pipeline/sessions/${sessionId}`) const sessionRes = await fetch(`${KLAUSUR_API}/api/v1/ocr-pipeline/sessions/${sessionId}`)
if (sessionRes.ok) { if (sessionRes.ok) {
const sessionData = await sessionRes.json() const sessionData = await sessionRes.json()
if (sessionData.sub_sessions?.length > 0) { if (sessionData.status === 'split' && sessionData.crop_result?.multi_page) {
// Already split — show existing sub-sessions // Already split — find the child sessions in the session list
const subs = sessionData.sub_sessions as { id: string; name: string; page_index?: number; box_index?: number; current_step?: number }[] const listRes = await fetch(`${KLAUSUR_API}/api/v1/ocr-pipeline/sessions`)
setSplitResult({ if (listRes.ok) {
multi_page: true, const listData = await listRes.json()
page_count: subs.length, // Child sessions have names like "ParentName — Seite N"
sub_sessions: subs.map((s: { id: string; name: string; page_index?: number; box_index?: number }) => ({ const baseName = sessionName || sessionData.name || ''
id: s.id, const children = (listData.sessions || [])
name: s.name, .filter((s: { name?: string }) => s.name?.startsWith(baseName + ' — '))
page_index: s.page_index ?? s.box_index ?? 0, .sort((a: { name: string }, b: { name: string }) => a.name.localeCompare(b.name))
})), if (children.length > 0) {
}) setSplitResult({
onSubSessionsCreated(subs.map((s: { id: string; name: string; page_index?: number; box_index?: number; current_step?: number }) => ({ multi_page: true,
id: s.id, page_count: children.length,
name: s.name, sub_sessions: children.map((s: { id: string; name: string }, i: number) => ({
box_index: s.page_index ?? s.box_index ?? 0, id: s.id, name: s.name, page_index: i,
current_step: s.current_step ?? 2, })),
}))) })
setDetecting(false) onSplitComplete(children[0].id, children[0].name)
return setDetecting(false)
return
}
}
} }
} }
@@ -92,12 +93,8 @@ export function StepPageSplit({ sessionId, sessionName, onNext, onSubSessionsCre
sub.name = newName sub.name = newName
} }
onSubSessionsCreated(data.sub_sessions.map(s => ({ // Signal parent to switch to the first child session
id: s.id, onSplitComplete(data.sub_sessions[0].id, data.sub_sessions[0].name)
name: s.name,
box_index: s.page_index,
current_step: 2,
})))
} }
} catch (e) { } catch (e) {
setError(e instanceof Error ? e.message : String(e)) setError(e instanceof Error ? e.message : String(e))