Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zkry opened this issue Jan 6, 2024 · 2 comments
Open

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

zkry opened this issue Jan 6, 2024 · 2 comments

Comments

@zkry
Copy link

zkry commented Jan 6, 2024

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.

@xenodium
Copy link
Owner

xenodium commented Jan 9, 2024

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
Copy link
Author

zkry commented Jan 10, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants