[FEATURE]: TUI plugin API for inline prompt suggestions

Đang mở
#65,338 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
15/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
227k
Fork
30.7k
Merge trung bình
3 giờ 57 phút
Pull request đã merge (30 ngày)
484

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của anomalyco/opencode

Tất cả issue của anomalyco/opencode

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.