add category to all the fileStatus messages

This commit is contained in:
LeonOstrez
2024-12-19 16:42:57 +01:00
parent b08c436aef
commit 3bf1b67aec
7 changed files with 17 additions and 11 deletions

View File

@@ -83,13 +83,15 @@ class CodeMonkey(FileDiffMixin, BaseAgent):
attempt = data["attempt"] + 1
feedback = data["feedback"]
log.debug(f"Fixing file {file_name} after review feedback: {feedback} ({attempt}. attempt)")
await self.ui.send_file_status(file_name, "reworking")
await self.ui.send_file_status(file_name, "reworking", source=self.ui_source)
else:
log.debug(f"Implementing file {file_name}")
if data is None:
await self.ui.send_file_status(file_name, "updating" if file_content else "creating")
await self.ui.send_file_status(
file_name, "updating" if file_content else "creating", source=self.ui_source
)
else:
await self.ui.send_file_status(file_name, "reworking")
await self.ui.send_file_status(file_name, "reworking", source=self.ui_source)
self.next_state.action = "Updating files"
attempt = 1
feedback = None
@@ -176,7 +178,7 @@ class CodeMonkey(FileDiffMixin, BaseAgent):
# ------------------------------
async def run_code_review(self, data: Optional[dict]) -> Union[AgentResponse, dict]:
await self.ui.send_file_status(data["path"], "reviewing")
await self.ui.send_file_status(data["path"], "reviewing", source=self.ui_source)
if (
data is not None
and not data["old_content"]
@@ -203,7 +205,7 @@ class CodeMonkey(FileDiffMixin, BaseAgent):
return await self.accept_changes(data["path"], data["old_content"], approved_content)
async def accept_changes(self, file_path: str, old_content: str, new_content: str) -> AgentResponse:
await self.ui.send_file_status(file_path, "done")
await self.ui.send_file_status(file_path, "done", source=self.ui_source)
n_new_lines, n_del_lines = self.get_line_changes(old_content, new_content)
await self.ui.generate_diff(

View File

@@ -215,7 +215,7 @@ class Frontend(FileDiffMixin, BaseAgent):
new_content = content
old_content = self.current_state.get_file_content_by_path(file_path)
n_new_lines, n_del_lines = self.get_line_changes(old_content, new_content)
await self.ui.send_file_status(file_path, "done")
await self.ui.send_file_status(file_path, "done", source=self.ui_source)
await self.ui.generate_diff(
file_path, old_content, new_content, n_new_lines, n_del_lines, source=self.ui_source
)

View File

@@ -81,7 +81,9 @@ class SpecWriter(BaseAgent):
convo = AgentConvo(self).template("add_new_feature", feature_description=feature_description)
llm_response: str = await llm(convo, temperature=0, parser=StringParser())
updated_spec = llm_response.strip()
await self.ui.generate_diff("project_specification", self.current_state.specification.description, updated_spec)
await self.ui.generate_diff(
"project_specification", self.current_state.specification.description, updated_spec, source=self.ui_source
)
user_response = await self.ask_question(
"Do you accept these changes to the project specification?",
buttons={"yes": "Yes", "no": "No"},

View File

@@ -357,12 +357,13 @@ class UIBase:
"""
raise NotImplementedError()
async def send_file_status(self, file_path: str, file_status: str):
async def send_file_status(self, file_path: str, file_status: str, source: Optional[UISource] = None):
"""
Send file status.
:param file_path: File path.
:param file_status: File status.
:param source: Source of the file status.
"""
raise NotImplementedError()

View File

@@ -169,7 +169,7 @@ class PlainConsoleUI(UIBase):
async def send_test_instructions(self, test_instructions: str, project_state_id: Optional[str] = None):
pass
async def send_file_status(self, file_path: str, file_status: str):
async def send_file_status(self, file_path: str, file_status: str, source: Optional[UISource] = None):
pass
async def send_bug_hunter_status(self, status: str, num_cycles: int):

View File

@@ -496,9 +496,10 @@ class IPCClientUI(UIBase):
project_state_id=project_state_id,
)
async def send_file_status(self, file_path: str, file_status: str):
async def send_file_status(self, file_path: str, file_status: str, source: Optional[UISource] = None):
await self._send(
MessageType.FILE_STATUS,
category=source.type_name if source else None,
content={
"file_path": file_path,
"file_status": file_status,

View File

@@ -168,7 +168,7 @@ class VirtualUI(UIBase):
async def send_test_instructions(self, test_instructions: str, project_state_id: Optional[str] = None):
pass
async def send_file_status(self, file_path: str, file_status: str):
async def send_file_status(self, file_path: str, file_status: str, source: Optional[UISource] = None):
pass
async def send_bug_hunter_status(self, status: str, num_cycles: int):