Skip to content

Comments

feat: open prompt in configured external editor#7606

Merged
sayan-oai merged 26 commits intomainfrom
dev/sayan/prompt-editor
Dec 22, 2025
Merged

feat: open prompt in configured external editor#7606
sayan-oai merged 26 commits intomainfrom
dev/sayan/prompt-editor

Conversation

@sayan-oai
Copy link
Collaborator

Add ctrl+g shortcut to enable opening current prompt in configured editor ($VISUAL or $EDITOR).

  • Prompt is updated with editor's content upon editor close.
  • Paste placeholders are automatically expanded when opening the external editor, and are not "recompressed" on close
    • They could be preserved in the editor, but it would be hard to prevent the user from modifying the placeholder text directly, which would drop the mapping to the pending_paste value
  • Image placeholders stay as-is
  • ctrl+g explanation added to shortcuts menu, snapshot tests updated
Screen.Recording.2025-12-04.at.12.41.42.PM.mov

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@sayan-oai
Copy link
Collaborator Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Dec 4, 2025
@sayan-oai
Copy link
Collaborator Author

@codex review this

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@etraut-openai
Copy link
Collaborator

@sayan-oai, looks like there are a few lint (cargo clippy) errors to fix.

@sayan-oai sayan-oai marked this pull request as draft December 4, 2025 21:35
@sayan-oai sayan-oai marked this pull request as ready for review December 5, 2025 07:34
@sayan-oai
Copy link
Collaborator Author

@codex review this

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@hasan-ozdemir
Copy link

Dear Participants; i have also implemented "ctrl+e:edit prompt in external editor" feature on windows since i was not aware of the improvement on this issue yet.
Now, it can open default notepad on windows.
Then how do i bring up my implementation in my topic branch so that you can check for the potential integration option into your solution if you like?
BTW: i have implemented it as a modular .JS extension along with an extension host on Rust TUI side.

@sayan-oai
Copy link
Collaborator Author

@codex review this

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sayan-oai
Copy link
Collaborator Author

@codex review this

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sayan-oai sayan-oai force-pushed the dev/sayan/prompt-editor branch from 8499e00 to a32377c Compare December 12, 2025 19:45
@jmpaz jmpaz mentioned this pull request Dec 13, 2025
@sayan-oai sayan-oai force-pushed the dev/sayan/prompt-editor branch from a32377c to 3cb00b6 Compare December 16, 2025 19:11
@sayan-oai
Copy link
Collaborator Author

@codex review this

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sayan-oai sayan-oai force-pushed the dev/sayan/prompt-editor branch from f83dadc to a6376c9 Compare December 17, 2025 03:02
@sayan-oai sayan-oai force-pushed the dev/sayan/prompt-editor branch from a6376c9 to eb7ca03 Compare December 19, 2025 05:09
@sayan-oai
Copy link
Collaborator Author

@codex review this

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Collaborator

@nornagon-openai nornagon-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience and attention to detail, this is looking good! Some minor comments below but otherwise good to merge.

One minor thing for a followup: for non-terminal editors (e.g. code --wait), it would be nice to be able to cancel waiting for the editor to quit, in case it got stuck somehow. I'm not totally sure if this is possible to do given we're pausing the terminal event stream, but maybe we could still watch for ^C or something?

windows doesnt allow saving files directly while another process has a handle, so rework editor logic to keep a temppath rather than the handle itself. this keeps windows happy and works with mac/linux
@sayan-oai
Copy link
Collaborator Author

@nornagon-openai Thanks, I appreciate your detailed reviews.

for non-terminal editors (e.g. code --wait), it would be nice to be able to cancel waiting for the editor to quit, in case it got stuck somehow. I'm not totally sure if this is possible to do given we're pausing the terminal event stream, but maybe we could still watch for ^C or something?

The two approaches that come to mind initially both have problems:

  1. Spawn another process that listens for Ctrl+C on stdin (or its equivalent in raw mode since we keep that on), and wait until editor closes OR we read Ctrl+C from stdin.
    • But, I think this would steal keystrokes from terminal editors (vim, nano) as they also read stdin
  2. Handle SIGINT
    • This would require us to leave raw mode, which would reintroduce the need for cursor gymnastics to clear potential input typed while the external editor is open.

Happy to consider other alternatives, and I will get opinions from others internally.

@sayan-oai sayan-oai merged commit 4673090 into main Dec 22, 2025
26 checks passed
@sayan-oai sayan-oai deleted the dev/sayan/prompt-editor branch December 22, 2025 23:12
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants