generated from kgod/ai-review-template
feat: start resume sessions in new flow
This commit is contained in:
+27
-1
@@ -17,6 +17,7 @@ from .fsm import (
|
||||
gate_allowed,
|
||||
initial_turn,
|
||||
missing_fields,
|
||||
new_resume_transition,
|
||||
process_component_event,
|
||||
required_fields,
|
||||
)
|
||||
@@ -867,7 +868,7 @@ class ResumeAgent(ResumeEditingMixin, OptimizationFlowMixin):
|
||||
return self.timeline(session_id)
|
||||
|
||||
def timeline(self, session_id: str) -> TimelineResponse:
|
||||
session = self._require_session(session_id)
|
||||
session = self._advance_legacy_resume_source_stage(session_id)
|
||||
turns = self.database.list_turns(session_id)
|
||||
gate = self._gate(session)
|
||||
resume = self._resume_view(session)
|
||||
@@ -885,6 +886,31 @@ class ResumeAgent(ResumeEditingMixin, OptimizationFlowMixin):
|
||||
trace_id=self._trace_id(),
|
||||
)
|
||||
|
||||
def _advance_legacy_resume_source_stage(self, session_id: str) -> dict[str, Any]:
|
||||
"""Move sessions parked on removed source/import screens into new-resume setup."""
|
||||
session = self._require_session(session_id)
|
||||
removed_stages = {Stage.RESUME_SOURCE_SELECT, Stage.RESUME_IMPORT_UPLOAD}
|
||||
if Stage(session["stage"]) not in removed_stages or session.get("resume_id"):
|
||||
return session
|
||||
|
||||
with self.database.transaction(immediate=True) as connection:
|
||||
current = self.database.fetch_session(connection, session_id, for_update=True)
|
||||
if current is None:
|
||||
raise FSMError("session_not_found", "Session not found", status_code=404)
|
||||
if Stage(current["stage"]) not in removed_stages or current.get("resume_id"):
|
||||
return current
|
||||
|
||||
transition = new_resume_transition(current["profile"])
|
||||
self.database.supersede_active_components(connection, session_id)
|
||||
updated = self.database.update_session(
|
||||
connection,
|
||||
session_id,
|
||||
stage=transition.stage,
|
||||
profile=transition.profile,
|
||||
)
|
||||
self.database.insert_turn(connection, session_id=session_id, **transition.turn)
|
||||
return updated
|
||||
|
||||
def component_event(
|
||||
self, session_id: str, request: ComponentEventRequest
|
||||
) -> ActionResponse:
|
||||
|
||||
Reference in New Issue
Block a user