From 5fac6c3440519210c3a4015c0d7b904b35939473 Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Sat, 25 Apr 2026 20:04:04 -0500 Subject: [PATCH] fix(cli): write editor draft to prompt.md so syntax highlighting works MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Base CLI was handing prompt_toolkit's Buffer.open_in_editor() a default config — Buffer.tempfile_suffix and .tempfile both empty — so it created /tmp/tmpXXXXXX with no extension. nano/vim/helix all key syntax highlighting off the file extension, so the buffer rendered plain. The TUI already writes to /prompt.md and gets full markdown highlighting + a sensible title bar. Set buffer.tempfile = 'prompt.md' on the TextArea so prompt_toolkit's complex-tempfile path produces /prompt.md to match. shutil.rmtree cleanup is built-in. --- cli.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cli.py b/cli.py index 0390d4741..a4a05d55f 100644 --- a/cli.py +++ b/cli.py @@ -9783,6 +9783,12 @@ class HermesCLI: completer=_completer, ), ) + # Match the TUI's editor handoff: the temp file lands at + # /prompt.md so vim/nano/helix pick up markdown syntax + # highlighting from the .md extension and the title bar reads + # "prompt.md" instead of a random "tmpXXXXXX". prompt_toolkit's + # complex-tempfile path takes care of cleanup via shutil.rmtree. + input_area.buffer.tempfile = 'prompt.md' # Dynamic height: accounts for both explicit newlines AND visual # wrapping of long lines so the input area always fits its content.