Fix sub-session completion flow: navigate to next incomplete sub-session
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 25s
CI / test-go-edu-search (push) Successful in 26s
CI / test-python-klausur (push) Failing after 1m51s
CI / test-python-agent-core (push) Successful in 15s
CI / test-nodejs-website (push) Successful in 15s
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 25s
CI / test-go-edu-search (push) Successful in 26s
CI / test-python-klausur (push) Failing after 1m51s
CI / test-python-agent-core (push) Successful in 15s
CI / test-nodejs-website (push) Successful in 15s
Instead of returning to parent (which creates a redirect loop), the handleNext function now finds the next incomplete sub-session and opens it directly. When all sub-sessions are done, returns to session list. Also fixes openSession auto-redirect to prefer the first incomplete sub-session over the most advanced one. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -73,12 +73,17 @@ export default function OcrPipelinePage() {
|
||||
if (data.sub_sessions && data.sub_sessions.length > 0) {
|
||||
setSubSessions(data.sub_sessions)
|
||||
setParentSessionId(sid)
|
||||
// Parent has sub-sessions — open the most advanced one automatically
|
||||
const sorted = [...data.sub_sessions].sort(
|
||||
(a: SubSession, b: SubSession) => (b.current_step || 0) - (a.current_step || 0),
|
||||
// Parent has sub-sessions — open the first incomplete one (or most advanced if all done)
|
||||
const incomplete = data.sub_sessions.find(
|
||||
(s: SubSession) => !s.current_step || s.current_step < 10,
|
||||
)
|
||||
openSession(sorted[0].id, true)
|
||||
return
|
||||
const target = incomplete || [...data.sub_sessions].sort(
|
||||
(a: SubSession, b: SubSession) => (b.current_step || 0) - (a.current_step || 0),
|
||||
)[0]
|
||||
if (target) {
|
||||
openSession(target.id, true)
|
||||
return
|
||||
}
|
||||
} else if (data.parent_session_id) {
|
||||
// This is a sub-session — keep parent info but don't reset sub-session list
|
||||
setParentSessionId(data.parent_session_id)
|
||||
@@ -217,12 +222,28 @@ export default function OcrPipelinePage() {
|
||||
if (currentStep >= steps.length - 1) {
|
||||
// Last step completed
|
||||
if (parentSessionId && sessionId !== parentSessionId) {
|
||||
// Sub-session completed — update its status and stay in tab view
|
||||
setSubSessions((prev) =>
|
||||
prev.map((s) => s.id === sessionId ? { ...s, status: 'completed', current_step: 10 } : s)
|
||||
// Sub-session completed — mark it and find next incomplete one
|
||||
const updatedSubs = subSessions.map((s) =>
|
||||
s.id === sessionId ? { ...s, status: 'completed' as const, current_step: 10 } : s,
|
||||
)
|
||||
// Switch back to parent
|
||||
handleSessionChange(parentSessionId)
|
||||
setSubSessions(updatedSubs)
|
||||
|
||||
// Find next incomplete sub-session
|
||||
const nextIncomplete = updatedSubs.find(
|
||||
(s) => s.id !== sessionId && (!s.current_step || s.current_step < 10),
|
||||
)
|
||||
if (nextIncomplete) {
|
||||
// Open next incomplete sub-session
|
||||
openSession(nextIncomplete.id, true)
|
||||
} else {
|
||||
// All sub-sessions done — return to session list
|
||||
setSteps(PIPELINE_STEPS.map((s, i) => ({ ...s, status: i === 0 ? 'active' : 'pending' })))
|
||||
setCurrentStep(0)
|
||||
setSessionId(null)
|
||||
setSubSessions([])
|
||||
setParentSessionId(null)
|
||||
loadSessions()
|
||||
}
|
||||
return
|
||||
}
|
||||
// Main session: return to session list
|
||||
|
||||
Reference in New Issue
Block a user