Skip to content

The agent that turns websites into APIs!

fix: flush local sync before prompting for follow-up input

kalil03213523778ba22c
diff --git a/src/reverse_api/base_engineer.py b/src/reverse_api/base_engineer.py
index 8c7aa11..2e7e3e6 100644
--- a/src/reverse_api/base_engineer.py
+++ b/src/reverse_api/base_engineer.py
@@ -131,6 +131,11 @@ class BaseEngineer(ABC):
finally:
self.sync_watcher = None
+ def flush_sync(self):
+ """Flush pending sync events and ensure all files are synced locally."""
+ if self.sync_watcher:
+ self.sync_watcher.flush()
+
def get_sync_status(self) -> dict | None:
"""Get current sync status."""
if self.sync_watcher:
@@ -277,6 +282,8 @@ class BaseEngineer(ABC):
Uses plain input() via executor instead of questionary to avoid
terminal state issues after the SDK subprocess exits.
"""
+ # Ensure all files are synced locally before waiting for user input
+ self.flush_sync()
self.ui.console.print()
self.ui.console.print(f" [{THEME_PRIMARY}]─[/{THEME_PRIMARY}] [dim]type a follow-up or press Enter to finish[/dim]")
try:
diff --git a/src/reverse_api/sync.py b/src/reverse_api/sync.py
index 0b8be0f..c03aa7b 100644
--- a/src/reverse_api/sync.py
+++ b/src/reverse_api/sync.py
@@ -197,6 +197,11 @@ class FileSyncWatcher:
# Perform final sync of all existing files to ensure nothing is missed
self._final_sync()
+ def flush(self):
+ """Flush pending events and perform a full sync without stopping the watcher."""
+ self.handler.process_pending()
+ self._final_sync()
+
def _process_loop(self):
"""Background loop to process pending sync events."""
while not self.stop_event.is_set():