Additional fixes for epic and task number

This commit is contained in:
mijauexe
2025-06-16 10:13:07 +02:00
parent 0562986ff0
commit b6ec4b0958
3 changed files with 28 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ from core.agents.base import BaseAgent
from core.agents.convo import AgentConvo
from core.agents.mixins import ChatWithBreakdownMixin, RelevantFilesMixin
from core.agents.response import AgentResponse
from core.cli.helpers import get_epic_task_number
from core.config import PARSE_TASK_AGENT_NAME, TASK_BREAKDOWN_AGENT_NAME
from core.config.actions import (
DEV_EXECUTE_TASK,
@@ -331,10 +332,8 @@ class Developer(ChatWithBreakdownMixin, RelevantFilesMixin, BaseAgent):
buttons["skip"] = "Skip Task"
description = self.current_state.current_task["description"]
task_index = self.current_state.tasks.index(self.current_state.current_task) + 1
epic_index = (
self.current_state.current_task.get("sub_epic_id", 1) + 2
) # 2 because we have spec writer and frontend before backend
epic_index, task_index = get_epic_task_number(self.current_state, self.current_state.current_task)
await self.ui.send_project_stage(
{
"stage": ProjectStage.STARTING_TASK,

View File

@@ -415,6 +415,24 @@ def find_first_todo_task_index(tasks):
return -1
def get_epic_task_number(state, current_task) -> (int, int):
epic_num = -1
task_num = -1
for task in state.tasks:
epic_n = task.get("sub_epic_id", 1) + 2
if epic_n != epic_num:
epic_num = epic_n
task_num = 1
if current_task["id"] == task["id"]:
return epic_num, task_num
task_num += 1
return epic_num, task_num
def trim_logs(logs: str) -> str:
"""
Trim logs by removing everything after specific marker phrases.

View File

@@ -954,12 +954,18 @@ class ProjectState(Base):
last_task = {}
# separate all elements from task_histories that have same start_id and end_id
for th in task_histories:
if task_histories[th].get("start_id") == task_histories[th].get("end_id"):
if task_histories[th].get("start_id") == task_histories[th].get("end_id") or task_histories[th][
"status"
] in [TaskStatus.TODO, TaskStatus.IN_PROGRESS]:
last_task = task_histories[th]
break
task_histories = {k: v for k, v in task_histories.items() if v.get("start_id") != v.get("end_id")}
if not last_task and len(task_histories.items()) == 1:
# If there is only one task in the history, use it as the last task
last_task = next(iter(task_histories.values()))
if last_task:
unfinished_task = last_task["status"] in [TaskStatus.TODO, TaskStatus.IN_PROGRESS]
project_states = await ProjectState.get_task_conversation_project_states(