Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit fe95fdc

Browse files
committed
Enhance user interaction with editor choice and input options 🎛️
In this commit, we've made some user-friendly enhancements to the CLI interaction. Now, the user's preferred editor, as specified by the `EDITOR` environment variable, is used for editing tasks. If no editor is specified, we default to vim. The prompt message has been updated to reflect this change. 📝 Additionally, we've introduced a new way to trigger the edit mode. If the user's input ends with `\e`, the input text (excluding `\e`) will be opened in the editor for further modification. This provides a more flexible way for users to edit their input. 🔄 As always, the user can quit the program by entering `q`. These changes aim to make the interaction more intuitive and user-friendly. Happy coding! 🚀
1 parent 76f595a commit fe95fdc

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

aicodebot/cli.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ def sidekick(request, verbose, files):
299299
streaming=True,
300300
)
301301

302+
# Open the temporary file in the user's editor
303+
editor = Path(os.getenv("EDITOR", "/usr/bin/vim")).name
304+
302305
# Set up the chain
303306
memory = ConversationTokenBufferMemory(
304307
memory_key="chat_history", input_key="task", llm=llm, max_token_limit=DEFAULT_MAX_TOKENS
@@ -311,13 +314,17 @@ def sidekick(request, verbose, files):
311314
request = None # clear the command line request once we've handled it
312315
else:
313316
human_input = click.prompt(
314-
"Enter a question OR (q) quit, OR (e) edit for entering a question in your editor\n>>>",
317+
f"Enter a question OR (q) quit, OR (e) to edit using {editor}\n>>>",
315318
prompt_suffix="",
316319
)
317-
if human_input.lower() == "q":
318-
break
319-
elif human_input.lower() == "e":
320-
human_input = click.edit()
320+
if len(human_input) == 1:
321+
if human_input.lower() == "q":
322+
break
323+
elif human_input.lower() == "e":
324+
human_input = click.edit()
325+
elif human_input.lower()[-2:] == r"\e":
326+
# If the text ends with \e then we want to edit it
327+
human_input = click.edit(human_input[:-2])
321328

322329
with Live(Markdown(""), auto_refresh=True) as live:
323330
callback = RichLiveCallbackHandler(live)

0 commit comments

Comments
 (0)