Skip to content

Commit b340436

Browse files
Asaif AliAsaif Ali
authored andcommitted
Fixing the backend
1 parent 12e1d83 commit b340436

2 files changed

Lines changed: 38 additions & 9 deletions

File tree

agent_service/app/presentation/routes/agent_router.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from app.infrastructure.utils.auth_client import get_current_user_http as get_current_user
2222
from app.infrastructure.repositories.migration_data_repository import fetch_migration_data, delete_migration_data
2323
from app.infrastructure.repositories.task_repository import create_task, update_task, get_task
24+
from app.infrastructure.utils.task_progress import bind_task
2425
from app.infrastructure.utils.migration_context import (
2526
migration_id_ctx,
2627
migration_name_ctx,
@@ -179,6 +180,9 @@ async def upload_team_files(
179180
async def execute_agent_team(task_id: str, request: RunTeamRequest, owner_user_id: str, llm_gateway_token: str = ""):
180181
logger.info("[TASK %s] STARTED | source_path=%r owner=%r", task_id, request.source_path, owner_user_id)
181182
create_task(task_id, user_id=owner_user_id, status=AgentConstants.TASK_STATUS_RUNNING)
183+
# Connect workflow progress events to this persisted task so the UI
184+
# receives live updates through GET /v1/tasks/{task_id}.
185+
bind_task(task_id)
182186
try:
183187
# Background task: bind the authenticated user (ignore client-supplied user_id on the body).
184188
try:

streamlit_ui/app.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -667,15 +667,40 @@ def count_up(label: str, target: int, duration: float = 0.5, steps: int = 12):
667667
terminal_progress["message"] = str(output_message)
668668
st.session_state.last_progress = terminal_progress
669669
render_live_plan(terminal_progress)
670-
if failed_payload.get("kind") == "blocked" or "release gate" in str(output_message).lower():
671-
if st.session_state.active_migration_name:
672-
try:
673-
data = client.download_migration(st.session_state.active_migration_name)
674-
st.download_button("Download gated artifact", data=data, file_name=f"{st.session_state.active_migration_name}.zip", mime="application/zip", width="stretch", key="blocked_demo_download")
675-
except ApiError:
676-
st.caption("Download will be available shortly.")
677-
else:
678-
st.error(f"Migration failed: {output_message}")
670+
st.error(f"Migration failed: {output_message}")
671+
672+
# Keep the download affordance visible for every terminal failure.
673+
# A real migrated ZIP is downloadable when packaging succeeded; otherwise
674+
# provide a small failure report so the user always has a retrievable artifact.
675+
if st.session_state.active_migration_name:
676+
try:
677+
data = client.download_migration(st.session_state.active_migration_name)
678+
st.download_button(
679+
"Download available artifact",
680+
data=data,
681+
file_name=f"{st.session_state.active_migration_name}.zip",
682+
mime="application/zip",
683+
width="stretch",
684+
key="failed_run_artifact_download",
685+
)
686+
except ApiError:
687+
failure_report = {
688+
"migration": st.session_state.active_migration_name,
689+
"task_id": st.session_state.active_task_id,
690+
"status": state,
691+
"message": str(output_message),
692+
"result": failed_payload or status.get("result"),
693+
"last_progress": st.session_state.get("last_progress"),
694+
}
695+
st.download_button(
696+
"Download failure report",
697+
data=json.dumps(failure_report, indent=2, default=str).encode("utf-8"),
698+
file_name=f"{st.session_state.active_migration_name}-failure-report.json",
699+
mime="application/json",
700+
width="stretch",
701+
key="failed_run_report_download",
702+
)
703+
st.caption("No migrated ZIP was created before the failure; the report preserves the run details for review.")
679704

680705
if status.get("result"):
681706
with st.expander("Workflow payload", expanded=False):

0 commit comments

Comments
 (0)