diff --git a/navie/mode/edit.py b/navie/mode/edit.py index bbf0762..3fb8dbd 100644 --- a/navie/mode/edit.py +++ b/navie/mode/edit.py @@ -168,7 +168,8 @@ def main(): print("Error: Issue description is required in non-interactive mode") sys.exit(1) - problem_statement = interactions.collect_problem_statement() + problem_statement = interactions.collect_problem_statement() + if not problem_statement.strip(): print("Problem statement is empty. Exiting.") sys.exit(1) @@ -194,8 +195,9 @@ def main(): pass try: - changed = True - while changed: + replan_required = True + while replan_required: + replan_required = False user_interface.display_message("Planning...") plan = edit.plan() @@ -206,16 +208,24 @@ def main(): for file in edit.files_to_edit: user_interface.display_message(f" {file}", color="white") - changed = False if interactive: - interactions.enter_to_continue() - - updated_problem_statement = interactions.prompt_user_for_adjustments( - edit.problem_statement - ) - if updated_problem_statement != edit.problem_statement: - edit.problem_statement = updated_problem_statement - changed = True + if interactions.prompt_for_edit(): + updated_problem_statement = ( + interactions.prompt_user_for_adjustments(edit.problem_statement) + ) + if updated_problem_statement != edit.problem_statement: + edit.problem_statement = updated_problem_statement + replan_required = True + + updated_files = interactions.prompt_user_for_adjustments( + "\n".join(edit.files_to_edit) + ) + if updated_files != "\n".join(edit.files_to_edit): + edit.files_to_edit = [ + file.strip() + for file in updated_files.split("\n") + if file.strip() + ] user_interface.display_message("Generating code...") diff --git a/navie/mode/interactions.py b/navie/mode/interactions.py index f1e49f6..3e4cc70 100644 --- a/navie/mode/interactions.py +++ b/navie/mode/interactions.py @@ -15,12 +15,22 @@ def enter_to_continue(self): ) if confirmation.lower() == "q": raise QuitException() + return True def collect_problem_statement(self) -> str: return self.user_interface.open_editor_and_read() - def prompt_user_for_adjustments(self, problem_statement: str) -> str: - return self.user_interface.open_editor_and_read(problem_statement) + def prompt_user_for_adjustments(self, content: str) -> str: + return self.user_interface.open_editor_and_read(content) + + def prompt_for_edit(self): + confirmation = self.user_interface.get_input( + "Press enter to continue, or (e) to edit the requirements or file list: " + ) + if confirmation.lower() == "q": + raise QuitException() + + return confirmation.lower() == "e" def confirm_diff(self, file: str, diff_output: str) -> bool: self.user_interface.display_message(f"Diff for file {file}:")