[FEATURE]: TUI plugin API for inline prompt suggestions

Offen
#65,338 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
15/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
typescript

Rechercherichtung

Start from the plugin host's context.ui.prompt surface and the existing prompt/textarea renderer that the external opencode-autosuggestions plugin currently patches through renderer internals; read the prior art in #51209 (draft and cursor access) and #54197 (empty-composer suggestions) before designing the API. The proposal spans keybind handling (Tab, Ctrl+Right, Escape), trimming on typed prefix, and suppression rules for shell mode, open autocomplete/dialogs and non-end cursors, so it needs agreement on the contract first and tests against opencode-autosuggestions to be considered done. The author has stated they intend to implement it in a single PR, so coordinate before starting.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

area/plugins type/feature version/v2
Feature hasn't been suggested before.
  • I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request

TUI plugins have no supported way to show an inline suggestion in the prompt. opencode-autosuggestions already completes drafts while typing and suggests follow-ups after each turn, but it finds the prompt textarea through renderer internals and draws the ghost text in an absolutely positioned overlay at the cursor's screen coordinates. Its source notes that an OpenCode update can break this.

Proposal: add a suggestion API to context.ui.prompt, next to the draft access requested in #51209.

context.ui.prompt.suggest({ sessionID, text }): () => void
  • The host draws text as muted ghost text right after the cursor, in an empty or non-empty draft, and handles wrapping.
  • Tab accepts the whole suggestion, Ctrl+Right accepts the next word, and Escape dismisses it. All three are configurable keybinds. Accepting inserts text into the draft and never submits.
  • When the user types characters that match the start of the suggestion, the host trims it. Any other edit, cursor move or session switch clears it.
  • Suggestions are ignored in shell mode, while autocomplete or a dialog is open, and when the cursor is not at the end of the draft.
  • Plugins also need to read the draft and cursor (#51209) and get a change event, so they can debounce their own requests.

This covers what #54197 did for the empty composer and extends it to drafts in progress. Model calls stay in plugins, so core sends no extra model requests.

I plan to implement this in a single PR and test it against opencode-autosuggestions.

Vorherrschende Sprache
TypeScript
Sterne
227k
Forks
30.7k
Ø Merge
3 Std. 57 Min.
Gemergte PRs (30 T.)
484

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus anomalyco/opencode

Alle Issues in anomalyco/opencode

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.