codex icon indicating copy to clipboard operation
codex copied to clipboard

Feature request: Codex CLI TUI extension API for inline word completion (input events, ghost text, Tab)

Open elcodabra opened this issue 1 month ago • 4 comments

Summary

Please expose a supported, opt-in extension API for the Codex CLI terminal UI composer so local plugins can provide low-latency inline completions while a user is typing. The primary use case is completing the current partially typed word, not suggesting a new prompt after a turn.

This is a request for extension points, not for Codex to ship a specific prediction model.

Example

Typed:       check authent
Ghost text:                ication
After Tab:   check authentication

Or in English: implem + ghost suffix entation → Tab → implementation.

After completing a word, a plugin could optionally predict the next word, but that is secondary.

Requested minimal API

  1. Input-change event (similar in purpose to Claude Code's prompt.edit): read-only current draft, cursor/caret, edit range and inserted text; events for typing, paste, deletion and cursor movement. Support Unicode and IME composition.
  2. Inline virtual text (similar in purpose to decorations[].virtualText): render a non-persistent ghost-text suffix at the caret. It must never enter the submitted prompt unless accepted.
  3. Completion provider / Tab acceptance (similar in purpose to prompt.autocomplete): offer a completion with an explicit replacement/insertion range, and accept it into the editable draft on Tab without submitting.
  4. Native behavior and priority: preserve built-in file/path, @ mention and slash-command completion; if the plugin has no valid suggestion, Tab must behave exactly as before.
  5. Cancellation and lifecycle: invalidate stale results when text, cursor, context or composition changes; avoid blocking the TUI rendering loop.
  6. Privacy and permissions: local-only operation by default, explicit opt-in for plugins reading draft text, and per-plugin enable/disable controls.

An initial synchronous/local completion provider would already be useful; an asynchronous provider could be added later.

Why an API instead of a built-in AI feature?

A local dictionary/trie can complete common developer terms in Russian and English in milliseconds, without model inference, network requests, or token consumption. Third-party providers could later support personalized vocabulary, command history, project terms and optional local models.

The desired interaction is word-first: authent → authentication via Tab. Longer sentence suggestions are optional and should not interfere with typing.

Current limitation

In a local investigation of Codex CLI 0.162.1, input handling appears internal to the Rust TUI. We could not identify a supported public extension point for per-keystroke draft access, virtual text decorations, or third-party Tab completion candidates. We would prefer not to maintain a fork or a terminal wrapper.

For comparison, a local inspection of Claude Code 2.1.304 identified prompt.edit, decorations[].virtualText, and prompt.autocomplete as relevant extension mechanisms. This is a conceptual comparison, not a request to copy their exact API.

Related issues

  • #2616 — context-aware autocomplete in Codex CLI (closed); this proposal asks specifically for a public third-party extension interface rather than a built-in predictor.
  • #17341 — native composer suggestion hooks for local plugins, focused on Desktop.
  • #55206 — inline Tab completion plugin API for Codex Desktop; this issue focuses on the terminal CLI TUI.
  • #42587 — next-prompt suggestions, a different empty-composer use case.

Acceptance criteria

  • A minimal local plugin can observe authent in the CLI composer, show ghost suffix ication, and insert it on Tab.
  • No text is inserted or submitted before explicit acceptance.
  • Native completion and keyboard shortcuts continue to work.
  • No cloud calls or model inference are required.
  • Plugins can be disabled without affecting the CLI.

Would the maintainers be open to a small TUI composer extension interface or an upstream contribution implementing these hooks?

elcodabra avatar Oct 20 '26 10:10 elcodabra

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #55206

Powered by Codex Action

github-actions[bot] avatar Oct 20 '26 10:10 github-actions[bot]

Related to #55206, which asks for the same capability in the Codex Desktop composer. This issue is about the Codex CLI TUI, a separate input surface, so I'm keeping it open; both could share one extension contract (input events → ghost-text suffix → Tab to accept).

elcodabra avatar Oct 22 '26 08:10 elcodabra

Huge +1 to exposing these minimal TUI extension points! I just filed a closely related architectural proposal in #56675 before seeing this.

Once the input-change, virtualText, and Tab acceptance hooks you described are available, we can go even beyond static word dictionaries (authent -> authentication) and build a lightweight local habit engine:

  • Bootstrapping a Trie + N-gram model from local session history on startup.
  • Using Tab acceptance events as implicit positive feedback to dynamically boost weights for a user's repetitive workflow phrases (following the 80/20 rule), all running locally in milliseconds with zero token consumption.

zhchoice2023-star avatar Oct 24 '26 08:10 zhchoice2023-star

@elcodabra this is the input side of the same gap. #53663 asks for the output side: plugins rendering fenced code blocks of their own language. One TUI extension point could likely serve both.

NahumLitvin avatar Nov 30 '26 09:11 NahumLitvin