Skip to content

feat: open prompt in configured external editor - #7606

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

sayan-oai merged 26 commits into
mainfrom
dev/sayan/prompt-editor

Conversation

@sayan-oai

Copy link
Copy Markdown
Contributor

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

github-actions Bot commented Dec 4, 2025 •

Copy link
Copy Markdown
Contributor

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

@sayan-oai

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

@codex review this

@chatgpt-codex-connector

Copy link
Copy Markdown
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
Copy Markdown
Contributor

@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
Comment thread codex-rs/tui/src/editor.rs Outdated
Comment thread codex-rs/tui/src/app.rs Outdated
Comment thread codex-rs/tui/src/app.rs Outdated
Comment thread codex-rs/tui/src/app.rs Outdated
Comment thread codex-rs/tui/src/bottom_pane/chat_composer.rs
@sayan-oai
sayan-oai marked this pull request as ready for review December 5, 2025 07:34
@sayan-oai

Copy link
Copy Markdown
Contributor Author

@codex review this

@chatgpt-codex-connector

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

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.

Comment thread codex-rs/tui/src/bottom_pane/chat_composer.rs Outdated
Comment thread codex-rs/tui/src/app.rs Outdated
@sayan-oai

Copy link
Copy Markdown
Contributor Author

@codex review this

@chatgpt-codex-connector

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

@codex review this

@chatgpt-codex-connector

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

@codex review this

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

Copy link
Copy Markdown
Contributor

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

Comment thread codex-rs/tui/src/external_editor.rs
@sayan-oai
sayan-oai force-pushed the dev/sayan/prompt-editor branch from f83dadc to a6376c9 Compare December 17, 2025 03:02
Comment thread codex-rs/tui/src/lib.rs Outdated
Comment thread codex-rs/tui/src/app.rs Outdated
Comment thread codex-rs/tui/src/app.rs Outdated
Comment thread codex-rs/tui/src/app.rs Outdated
@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
Copy Markdown
Contributor Author

@codex review this

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

Copy link
Copy Markdown
Contributor

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

Comment thread codex-rs/tui/src/external_editor.rs Outdated

@nornagon-openai nornagon-openai left a comment

Copy link
Copy Markdown
Contributor

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?

Comment thread codex-rs/tui/src/app.rs Outdated
Comment thread codex-rs/tui/src/app.rs Outdated
Comment thread codex-rs/tui/src/tui.rs Outdated
Comment thread codex-rs/tui/src/tui.rs Outdated
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
Copy Markdown
Contributor 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