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) {
|
if (data.sub_sessions && data.sub_sessions.length > 0) {
|
||||||
setSubSessions(data.sub_sessions)
|
setSubSessions(data.sub_sessions)
|
||||||
setParentSessionId(sid)
|
setParentSessionId(sid)
|
||||||
// Parent has sub-sessions — open the most advanced one automatically
|
// Parent has sub-sessions — open the first incomplete one (or most advanced if all done)
|
||||||
const sorted = [...data.sub_sessions].sort(
|
const incomplete = data.sub_sessions.find(
|
||||||
(a: SubSession, b: SubSession) => (b.current_step || 0) - (a.current_step || 0),
|
(s: SubSession) => !s.current_step || s.current_step < 10,
|
||||||
)
|
)
|
||||||
openSession(sorted[0].id, true)
|
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
|
return
|
||||||
|
}
|
||||||
} else if (data.parent_session_id) {
|
} else if (data.parent_session_id) {
|
||||||
// This is a sub-session — keep parent info but don't reset sub-session list
|
// This is a sub-session — keep parent info but don't reset sub-session list
|
||||||
setParentSessionId(data.parent_session_id)
|
setParentSessionId(data.parent_session_id)
|
||||||
@@ -217,12 +222,28 @@ export default function OcrPipelinePage() {
|
|||||||
if (currentStep >= steps.length - 1) {
|
if (currentStep >= steps.length - 1) {
|
||||||
// Last step completed
|
// Last step completed
|
||||||
if (parentSessionId && sessionId !== parentSessionId) {
|
if (parentSessionId && sessionId !== parentSessionId) {
|
||||||
// Sub-session completed — update its status and stay in tab view
|
// Sub-session completed — mark it and find next incomplete one
|
||||||
setSubSessions((prev) =>
|
const updatedSubs = subSessions.map((s) =>
|
||||||
prev.map((s) => s.id === sessionId ? { ...s, status: 'completed', current_step: 10 } : s)
|
s.id === sessionId ? { ...s, status: 'completed' as const, current_step: 10 } : s,
|
||||||
)
|
)
|
||||||
// Switch back to parent
|
setSubSessions(updatedSubs)
|
||||||
handleSessionChange(parentSessionId)
|
|
||||||
|
// 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
|
return
|
||||||
}
|
}
|
||||||
// Main session: return to session list
|
// Main session: return to session list
|
||||||
|
|||||||
Reference in New Issue
Block a user