mirror of
https://github.com/Pythagora-io/gpt-pilot.git
synced 2026-01-10 13:37:55 -05:00
Fix backend back logs
This commit is contained in:
@@ -110,13 +110,13 @@ class Architect(BaseAgent):
|
||||
telemetry.set("templates", spec.templates)
|
||||
self.next_state.action = ARCHITECTURE_STEP_NAME
|
||||
await self.ui.clear_main_logs()
|
||||
await self.ui.send_front_logs_headers("be_0", ["E2 / T3", "done"], "Setting up backend")
|
||||
await self.ui.send_front_logs_headers("be_0", ["E2 / T2", "done"], "Setting up backend")
|
||||
await self.ui.send_back_logs(
|
||||
[
|
||||
{
|
||||
"title": "Setting up backend",
|
||||
"project_state_id": self.current_state.id,
|
||||
"labels": ["E2 / T3", "Backend setup", "done"],
|
||||
"project_state_id": "be_0",
|
||||
"labels": ["E2 / T2", "Backend setup", "done"],
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
from enum import Enum
|
||||
from typing import Annotated, Literal, Union
|
||||
from uuid import uuid4
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
@@ -347,6 +347,30 @@ class Developer(ChatWithBreakdownMixin, RelevantFilesMixin, BaseAgent):
|
||||
description,
|
||||
self.current_state.current_task.get("id"),
|
||||
)
|
||||
|
||||
# find latest finished task, send back logs for it being finished
|
||||
tasks_done = [task for task in self.current_state.tasks if task not in self.current_state.unfinished_tasks]
|
||||
previous_task = tasks_done[-1] if tasks_done else None
|
||||
if previous_task:
|
||||
task_convo = await self.state_manager.get_task_conversation_project_states(UUID(previous_task["id"]))
|
||||
await self.ui.send_back_logs(
|
||||
[
|
||||
{
|
||||
"title": previous_task["description"],
|
||||
"project_state_id": str(task_convo[0].id) if task_convo else "be_0",
|
||||
"start_id": str(task_convo[0].id) if task_convo else "be_0",
|
||||
"end_id": str(task_convo[-1].id) if task_convo else "be_0",
|
||||
"labels": [f"E{epic_index} / T{task_index - 1}", "Backend", "done"],
|
||||
}
|
||||
]
|
||||
)
|
||||
await self.ui.send_front_logs_headers(
|
||||
f"be_{epic_index}_{task_index}",
|
||||
[f"E{epic_index} / T{task_index}", "Backend", "working"],
|
||||
previous_task["description"],
|
||||
self.current_state.current_task.get("id"),
|
||||
)
|
||||
|
||||
await self.ui.send_back_logs(
|
||||
[
|
||||
{
|
||||
|
||||
@@ -761,31 +761,34 @@ class ProjectState(Base):
|
||||
result = await session.execute(query)
|
||||
states = result.scalars().all()
|
||||
|
||||
log.debug(f"Found {len(states)} states with task start action")
|
||||
log.debug(f"Found {len(states)} states with custom action")
|
||||
|
||||
start = -1
|
||||
end = -1
|
||||
|
||||
# for the FIRST task, it is todo in the same state as Create a development plan, while other tasks are "Task #N start" (action)
|
||||
|
||||
# this is done solely to be able to reload to the first task, due to the fact that we need the same project_state_id for the send_back_logs
|
||||
# for the first task, we need to start from the FIRST state that has that task in TODO status
|
||||
# for all other tasks, we need to start from LAST state that has that task in TODO status
|
||||
for i, state in enumerate(states):
|
||||
if start != -1 and end != -1:
|
||||
break
|
||||
if (
|
||||
start == -1
|
||||
and state.current_task
|
||||
and UUID(state.current_task["id"]) == task_id
|
||||
and state.current_task["status"] in [TaskStatus.TODO, TaskStatus.IN_PROGRESS]
|
||||
):
|
||||
start = i
|
||||
if end == -1:
|
||||
for task in state.tasks:
|
||||
if UUID(task["id"]) == task_id and task.get("status") in [
|
||||
TaskStatus.SKIPPED,
|
||||
TaskStatus.DOCUMENTED,
|
||||
TaskStatus.REVIEWED,
|
||||
TaskStatus.DONE,
|
||||
]:
|
||||
end = i
|
||||
break
|
||||
for task in state.tasks:
|
||||
if UUID(task["id"]) == task_id and task.get("status", "") == TaskStatus.TODO:
|
||||
if UUID(task["id"]) == UUID(state.tasks[0]["id"]):
|
||||
# First task: set start only once (first occurrence)
|
||||
if start == -1:
|
||||
start = i
|
||||
else:
|
||||
# Other tasks: update start every time (last occurrence)
|
||||
start = i
|
||||
|
||||
if UUID(task["id"]) == task_id and task.get("status", "") in [
|
||||
TaskStatus.SKIPPED,
|
||||
TaskStatus.DOCUMENTED,
|
||||
TaskStatus.REVIEWED,
|
||||
TaskStatus.DONE,
|
||||
]:
|
||||
end = i
|
||||
|
||||
if end == -1:
|
||||
query = select(ProjectState).where(
|
||||
@@ -807,14 +810,15 @@ class ProjectState(Base):
|
||||
|
||||
# Remove the last state from the list because that state is not yet committed in the database!
|
||||
results = results[:-1]
|
||||
# only return sublist of states, first state should have action like "Task #<task_number> start"
|
||||
index = -1
|
||||
for i, state in enumerate(results):
|
||||
if state.action and "Task #" in state.action and "start" in state.action:
|
||||
index = i
|
||||
break
|
||||
|
||||
return results[index:]
|
||||
# index = -1
|
||||
# for i, state in enumerate(results):
|
||||
# if state.action and "Task #" in state.action and "start" in state.action:
|
||||
# index = i
|
||||
# break
|
||||
#
|
||||
# return results[index:]
|
||||
return results
|
||||
|
||||
@staticmethod
|
||||
async def get_fe_states(session: "AsyncSession", branch_id: UUID) -> Optional["ProjectState"]:
|
||||
|
||||
Reference in New Issue
Block a user