Skip to content

feat(completion): add opt-in coordinated suggestions - #281

Merged
fcoury merged 2 commits into
mainfrom
fcoury/copilot-coordinated
Aug 18, 2026
Merged

fcoury merged 2 commits into
mainfrom
fcoury/copilot-coordinated

Conversation

@fcoury-oai

@fcoury-oai fcoury-oai commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

Why

#279 keeps ordinary autocomplete and Copilot available together, with the completion popup taking priority. Keep that behavior as the default while letting users opt into a coordinated preview—or turn ordinary completion off and use Copilot alone.

What changed

  • Add completion.inline_mode = "coordinated"; the default remains "popup_first".
  • Send the selected completion's real range and text to Copilot without synchronizing fictional document contents. Show an inline suggestion beside the menu only when it safely extends that selected item.
  • Keep Up/Down, Tab, and Enter owned by the menu. Tab/Enter accepts the ordinary item first and preserves a valid AI suffix; Ctrl-L accepts the whole suggestion in one undo step. Alt + backslash (\) requests standalone Copilot.
  • Fall back to popup-first for snippets, commands, additional edits, incompatible ranges, and incompatible AI results. Cancel stale previews when the selected item changes, even if the buffer revision does not.
  • Add completion.enabled = false to disable automatic, trigger-character, and Ctrl-Space completion independently of Copilot. Preserve the existing narrower meaning of completion.auto_trigger.
  • Document the settings and cover selection races, acceptance/undo, UTF-16, CRLF, late responses, and protocol synchronization.

How to Test

  1. Build with cargo build --bin red. With Copilot installed and authenticated, open a source file using target/debug/red -c 'copilot.enabled=true'. Without an inline-mode override, the ordinary menu should still hide ghost text and own Tab/Enter.
  2. Restart with target/debug/red -c 'copilot.enabled=true' -c 'completion.inline_mode="coordinated"'. Type an identifier prefix with ordinary completions. If Copilot returns a compatible extension, both the menu and ghost text should remain visible. Up/Down must invalidate the previous item's preview.
  3. Press Tab or Enter: only the selected ordinary item should be inserted. If an AI suffix remains, another Tab should accept it. Repeat with Ctrl-L: the whole suggestion should be inserted, and one undo should remove that combined edit.
  4. With the menu open, press Alt + backslash (\). The menu should close and a standalone Copilot request should run. An older ordinary-completion response must not reopen the menu.
  5. Restart with target/debug/red -c 'copilot.enabled=true' -c 'completion.enabled=false'. Identifier typing, language-server trigger characters, and Ctrl-Space must not open ordinary completion; Copilot should still work.
  6. Run cargo test --lib completion -- --test-threads=1. In particular, coordinated_rejects_incompatible_results_and_unsafe_ordinary_items and coordinated_selection_change_rejects_old_results_without_a_text_edit verify safe fallback and stale-response rejection.

Validation completed

  • Full library run: 1,984 passed, 1 ignored.
  • Final completion-focused run, including three additional regressions: 131 passed.
  • cargo clippy --all-targets --all-features -- -D warnings: passed.
  • Formatting, diff checks, and cargo build --bin red: passed.

Live Copilot and end-to-end testing remain intentionally deferred for the manual feel check.

@fcoury
fcoury force-pushed the fcoury/copilot-coordinated branch from 6193c3e to 0fb8d10 Compare August 18, 2026 04:07
@fcoury
fcoury merged commit 9181829 into main Aug 18, 2026
11 checks passed
@fcoury
fcoury deleted the fcoury/copilot-coordinated branch August 18, 2026 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants