xenodium / chatgpt-shell

ChatGPT and DALL-E Emacs shells + Org babel 🦄 + a shell maker for other providers
https://xenodium.com
GNU General Public License v3.0
796 stars 72 forks source link

better chatgpt-shell-prompt-compose interactions with existing prompt #182

Open zkry opened 7 months ago

zkry commented 7 months ago

Hi!

I really like the new compose interface and find it helpful! I noticed a few edge cases when a prompt already exists:

I'd be happy to provide a MR for this. So my idea is that it would go something like this:

When chatgpt-shell-prompt-compose is called, check for existing prompt text and save it. If the prefix was sent, then erase the existing prompt, then send the "clear" command. Next, when creating the compose buffer, insert the pre-existing prompt text. Finally when compose is sent via C-c C-c, first clear the existing prompt text, then send the prompt from the compose buffer.

xenodium commented 7 months ago

Thanks for the feedback and reporting issues. Glad you find it useful!

If chatgpt-shell-prompt-compose is called with a prefix, it sends the "clear" command after the previously existing text, which ends up sending a malformed message.

Sounds like a bug (sending a malformed message), though the prefix clearing the shell history (by sending clear) is indeed intended as a way to change the topic (by dropping previous topic/history). I'll have a look into the malformed message.

If chatgpt-shell-prompt-compose is called without a prefix, things end up working, but maybe it would be more useful if the existing prompt text got copied into the compose buffer.

It kinda works like that at the moment, but maybe worth clarifying... the compose buffer is usually in either of two states:

  1. Read/write (prior to sending)
  2. Read-only (after sending)

Read-write

When in 1. the user is still composing a query. Further chatgpt-shell-prompt-compose invokations with a selected region from another buffer, prepend the region to compose buffer.

If I'm understanding correctly, the feature request is to do the same but without selected region. I can add this soon.

Read-only

Query has already been send. Always clear buffer (but not history, unless with prefix).

zkry commented 7 months ago

That makes sense how it works. With the second point, I think how it is now is good actually. I think the only case where it could be improved is when the compose buffer is first created. It could do the following steps:

This would be useful in the case where a user starts to type into the CLI, but then changes their mind and decides they want to use the compose buffer.