Skip to content

Commit bd7b331

Browse files
yaadatayaadata
authored andcommitted
fix(codex): auto-submit mention and restore prompt draft (#8)
Reviewed-on: https://codeberg.org/yaadata/codex.nvim/pulls/8 Co-authored-by: Yadi Abdalhalim <abdalhalim.yaadata@gmail.com> Co-committed-by: Yadi Abdalhalim <abdalhalim.yaadata@gmail.com>
1 parent 07af42e commit bd7b331

4 files changed

Lines changed: 762 additions & 16 deletions

File tree

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ require("codex").setup({
3737
args = {},
3838
env = {},
3939
auto_start = false,
40+
log_level = "warn",
4041
terminal = {
4142
provider = "auto", -- auto | snacks | native
4243
window = "vsplit", -- vsplit | hsplit | float
@@ -113,11 +114,14 @@ require("codex").setup({
113114
- paths are normalized to be relative to the current working directory
114115
- paths are auto-quoted/escaped when they contain whitespace or
115116
shell-significant characters
116-
- payload is inserted via bracketed paste and is not auto-submitted
117+
- command is auto-submitted immediately
118+
- codex.nvim clears the current prompt line, inserts `/mention`, submits it,
119+
then re-applies previously typed prompt text (best effort)
120+
- if prompt text cannot be captured from the terminal buffer, mention still
121+
submits and prior input is not restored
117122
- if the terminal is still starting, payloads are queued and retried until
118123
ready (or until `terminal.startup.timeout_ms` elapses)
119-
- after sending, codex.nvim focuses the Codex terminal in insert mode; press
120-
Enter to submit
124+
- after sending, codex.nvim focuses the Codex terminal in insert mode
121125
- `:CodexResume[!]` resumes a session
122126
- with an active Codex session, sends `/resume` in-process
123127
- without an active session, launches `codex resume` (or `codex resume --last`

docs/contributing.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,17 @@ Use EmmyLua annotations for all public functions and types:
200200
function M.example(name, count) end
201201
```
202202

203+
Document every function (public and private) with a one-line summary placed
204+
before `---@param`/`---@return` tags:
205+
206+
```lua
207+
---Returns whether the active session is alive.
208+
---@param session codex.Session|nil
209+
---@param provider codex.Provider
210+
---@return boolean
211+
local function session_is_alive(session, provider) end
212+
```
213+
203214
Define shared types with `---@class` and `---@alias` in `lua/codex/types.lua`.
204215
Module-local types (like `codex.SelectionSpec`) can be defined in the module
205216
that owns them.
@@ -337,8 +348,9 @@ When cutting a new release tag:
337348

338349
## Adding a New Command
339350

340-
1. **API function** -- Add the public method in `lua/codex/init.lua` with
341-
`---@param`/`---@return` annotations and an `ensure_setup()` guard.
351+
1. **API function** -- Add the public method in `lua/codex/init.lua` with a
352+
one-line LuaDoc summary (description first), `---@param`/`---@return`
353+
annotations, and an `ensure_setup()` guard.
342354
2. **User command** -- Register the `:Codex*` command in
343355
`lua/codex/nvim/commands.lua`, delegating to the API function.
344356
3. **Unit tests** -- Add test cases in `tests/unit/init_spec.lua` covering the

0 commit comments

Comments
 (0)