chatgpt-shell icon indicating copy to clipboard operation
chatgpt-shell copied to clipboard

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

Open zkry opened this issue 1 year ago • 2 comments

Hi!

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

  • 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.
  • 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.

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.

zkry avatar Jan 06 '24 19:01 zkry

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).

xenodium avatar Jan 09 '24 12:01 xenodium

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:

  • user calls chatgpt-shell-prompt-compose for the first time
  • whatever has been typed so far in the CLI is erased
  • the new composite buffer is created
  • the text that was on the CLI is added to the compose buffer
  • when the user submits the compose buffer, only the contents of the buffer is passed to ChatGPT

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.

zkry avatar Jan 10 '24 03:01 zkry

I've reworked chatgpt-shell-prompt-compose quite a bit. See how you find the latest usabillity. https://github.com/xenodium/chatgpt-shell/blob/main/chatgpt-shell.el#L2670 Of interest, chatgpt-shell-prompt-compose can now swap promtps too via chatgpt-shell-prompt-compose-swap-system-prompt.

With the latest compose UX, I've found myself rarely dropping to the shell directly. Note that you can quickly navigate to previous interactions using n/p keys from the read-only compose buffer.

I'm hoping some of the previous requests are now somewhat obsolete. Please reopen if otherwise.

xenodium avatar Oct 04 '24 12:10 xenodium