Skip to content

Commit 7ab7445

Browse files
author
Your Name
committed
#447: Tweak responses to work with TUI
1 parent 36873cf commit 7ab7445

3 files changed

Lines changed: 34 additions & 4 deletions

File tree

cecli/coders/architect_coder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ async def reply_completed(self):
2424
return
2525

2626
if confirmation == "tweak":
27-
content = self.io.edit_in_editor(content)
27+
if self.tui and self.tui():
28+
content = self.tui().get_response_from_editor(content)
29+
else:
30+
content = self.io.edit_in_editor(content)
2831

2932
await asyncio.sleep(0.1)
3033

cecli/coders/base_coder.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3718,9 +3718,14 @@ async def apply_updates(self):
37183718
confirmation = await self.io.confirm_ask("Tweak Response?", allow_tweak=True)
37193719

37203720
if confirmation or confirmation == "tweak":
3721-
self.partial_response_content = self.io.edit_in_editor(
3722-
self.partial_response_content
3723-
)
3721+
if self.tui and self.tui():
3722+
self.partial_response_content = self.tui().get_response_from_editor(
3723+
self.partial_response_content
3724+
)
3725+
else:
3726+
self.partial_response_content = self.io.edit_in_editor(
3727+
self.partial_response_content
3728+
)
37243729

37253730
await asyncio.sleep(0.1)
37263731

cecli/tui/app.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,28 @@ def _open_editor_suspended(self, initial_content=""):
738738
else:
739739
input_area.focus()
740740

741+
return edited_text
742+
743+
def get_response_from_editor(self, initial_content=""):
744+
"""Open an external editor with proper TUI suspension.
745+
746+
Args:
747+
initial_content: Initial text to populate the editor with
748+
749+
Returns:
750+
Edited text
751+
"""
752+
# Get editor from coder's commands or default
753+
editor = getattr(self.worker.coder.commands, "editor", None)
754+
755+
# Suspend TUI and open editor
756+
input_area = self.query_one("#input", InputArea)
757+
edited_text = ""
758+
edited_text = self.run_obstructive(pipe_editor, initial_content, suffix="md", editor=editor)
759+
input_area.focus()
760+
761+
return edited_text.rstrip()
762+
741763
def _encode_keys(self, key):
742764
key = key.replace("shift+enter", "ctrl+j")
743765

0 commit comments

Comments
 (0)