mirror of
https://github.com/openai/codex.git
synced 2026-05-02 12:21:26 +03:00
2.0 KiB
2.0 KiB
Task 06: External Editor Integration for Prompt Entry
This task is specific to codex-rs.
Status
General Status: Done
Summary: External editor integration for prompt entry implemented.
Goal
Allow users to spawn an external editor (e.g. Neovim) to compose or edit the chat prompt. The prompt box should update with the editor's contents when closed.
Acceptance Criteria
- A slash command
/edit-prompt(orCtrl+E) launches the user's preferred editor on a temporary file pre-populated with the current draft. - Upon editor exit, the draft is re-read into the composer widget.
- Configurable via
editor = "${VISUAL:-${EDITOR:-nvim}}"setting inconfig.toml.
Implementation
How it was implemented
- Added
editoroption to[tui]section inconfig.toml, defaulting to${VISUAL:-${EDITOR:-nvim}}. - Exposed the
tui.editorsetting in thecodex-coreconfig model (config_types.rs) and wired it through to the TUI. - Added a new slash-command variant
EditPromptintui/src/slash_command.rsto trigger external-editor mode. - Implemented
ChatComposer::open_external_editor()intui/src/bottom_pane/chat_composer.rs:- Creates a temporary file pre-populated with the current draft prompt.
- Launches the configured editor (from
VISUAL/EDITORwithnvimfallback) in a blocking subprocess. - Reads the edited contents back into the
TextAreaon editor exit.
- Wired both
Ctrl+Eand the/edit-promptslash command to invokeopen_external_editor(). - Updated
config.mdto document the neweditorsetting under[tui].
How it works
- Pressing
Ctrl+E, or typing/edit-promptand hitting Enter, spawns the user's preferred editor on a temporary file containing the current draft. - When the editor process exits, the plugin reads back the file and updates the chat composer with the edited text.
- The default editor is determined by
VISUAL, thenEDITOR, falling back tonvimif neither is set.