mirror of
https://github.com/openai/codex.git
synced 2026-05-03 04:42:20 +03:00
2.5 KiB
2.5 KiB
Task 15: Embedded Neovim Prompt Editor
This task is specific to codex-rs.
Status
General Status: Not started
Summary: Not started; missing Implementation details (How it was implemented and How it works).
Goal
Replace the basic line‑editing prompt composer with an embedded Neovim window so users can enjoy full-featured, multi-line editing of their chat prompt directly inside the TUI.
Acceptance Criteria
- Introduce a TUI-integrated Neovim editor pane activated via
/edit-promptorCtrl+Ewhenembedded_prompt_editor = truein[tui]config. - Pre-populate the Neovim buffer with the current draft prompt; upon exit, reload the buffer contents back into the composer.
- Support standard Neovim keybindings and commands (e.g. insert mode, visual mode, plugins) within the embedded pane.
- Cleanly restore the previous TUI layout after closing the editor, with prompt focus returned to the composer.
- Provide configuration toggle (
embedded_prompt_editor) and fall back to external-editor prompt behavior when disabled.
Implementation
How it was implemented
- Add a new module
tui/src/editor/neovim.rsthat wraps a headless Neovim RPC instance and renders its UI into a dedicated TUI layer. - Extend
tui/src/bottom_pane/chat_composer.rsto detectembedded_prompt_editorand invoke the embedded editor instead of spawning an external process. - Wire a config flag
embedded_prompt_editor: boolthroughConfigToml→Configunder thetuisection, defaulting tofalse. - Handle Neovim communication via
nvim-rscrate, multiplexing input/output over the TUI event loop.
How it works
- When the user triggers the editor, pause the main TUI rendering and allocate a full-screen or split view for Neovim.
- Start Neovim in embedded RPC mode, passing the current prompt text into a new buffer.
- Drive Neovim’s UI updates via RPC and render its screen cells into the TUI terminal using termion or similar backend.
- Detect the Neovim exit event (e.g. user
:qorZZ), fetch the buffer contents, and close the embedded view. - Restore the original TUI state and update the composer widget with the edited prompt.
Notes
- This relies on a working
nvimbinary in PATH or specified vianvim_binaryconfig. - Investigate performance impact of embedding a full editor in the TUI; ensure fallback to external-editor remains smooth.
- Consider edge cases (resizing, plugin‑heavy Neovim configs) and document prerequisites in the README.