Skip to content

fix(ai): add word acceptance feature in AI suggestions - #8607

Merged
utkarsh-bruno merged 1 commit into
usebruno:mainfrom
naman-bruno:feat/autocomplete-next-word
Jul 14, 2026
Merged

utkarsh-bruno merged 1 commit into
usebruno:mainfrom
naman-bruno:feat/autocomplete-next-word

Conversation

@naman-bruno

@naman-bruno naman-bruno commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • New Features

    • Added a keyboard shortcut, Cmd/Ctrl + Right Arrow, to accept the next word from an AI autocomplete suggestion.
    • Remaining suggestion text stays available for continued completion.
  • Documentation

    • Updated autocomplete keyboard help to include the new shortcut.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

AI autocomplete now documents and handles Cmd/Ctrl+Right to accept only the next word of a ghost-text suggestion, while preserving and re-rendering any remaining suggestion.

Changes

AI autocomplete shortcuts

Layer / File(s) Summary
Shortcut documentation
packages/bruno-app/src/components/Preferences/AI/AutocompletePane.js, packages/bruno-app/src/utils/codemirror/aiGhostText.js
Adds Cmd/Ctrl+Right to the preferences keymap and ghost-text keyboard documentation.
Next-word acceptance flow
packages/bruno-app/src/utils/codemirror/aiGhostText.js
Extracts and inserts the next suggested word, updates remaining ghost text, and handles Cmd/Ctrl+ArrowRight in onKeyDown.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CodeMirror
  participant WordAcceptance
  participant Editor
  User->>CodeMirror: Press Cmd/Ctrl+ArrowRight
  CodeMirror->>WordAcceptance: Accept next suggested word
  WordAcceptance->>Editor: Insert word and update remaining ghost text
Loading

Possibly related PRs

  • usebruno/bruno#8300: Introduced the related AI autocomplete implementation and shortcut behavior.
  • usebruno/bruno#8430: Updated platform-correct modifier symbols in the autocomplete shortcut hints.

Suggested reviewers: helloanoop, lohit-bruno, sid-bruno, vijayh-bruno, bijin-bruno

Poem

A ghostly word appears in flight,
One keystroke trims it just right.
Tab takes all, Right takes one,
The rest awaits the next run.
Shortcuts shine, autocomplete sings.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding word-level acceptance for AI suggestions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@utkarsh-bruno
utkarsh-bruno merged commit ac31126 into usebruno:main Jul 14, 2026
12 of 18 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/bruno-app/src/utils/codemirror/aiGhostText.js (1)

287-289: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Consider using getRange instead of getValue().slice for better performance.

cm.getValue() creates a single string from the entire document, which can be inefficient if the editor contains a large script or JSON payload. CodeMirror's getRange retrieves only the necessary text without serializing the remainder of the document.

♻️ Proposed refactor
-    const newCursorIdx = cm.indexFromPos(cm.getCursor());
-    s.reusePrefix = cm.getValue().slice(0, newCursorIdx);
+    s.reusePrefix = cm.getRange({ line: 0, ch: 0 }, cm.getCursor());
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/bruno-app/src/utils/codemirror/aiGhostText.js` around lines 287 -
289, Update the reuse-prefix assignment in the ghost-text suggestion flow to use
CodeMirror’s getRange with the document start and the current cursor position
instead of cm.getValue().slice. Keep s.reusePrefix equal to the text before the
cursor and leave s.reuseSuggestion unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/bruno-app/src/utils/codemirror/aiGhostText.js`:
- Around line 287-289: Update the reuse-prefix assignment in the ghost-text
suggestion flow to use CodeMirror’s getRange with the document start and the
current cursor position instead of cm.getValue().slice. Keep s.reusePrefix equal
to the text before the cursor and leave s.reuseSuggestion unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7fae966f-67f3-4a10-96cd-c01d13ac07ba

📥 Commits

Reviewing files that changed from the base of the PR and between 3c04838 and e4e1f0f.

📒 Files selected for processing (2)
  • packages/bruno-app/src/components/Preferences/AI/AutocompletePane.js
  • packages/bruno-app/src/utils/codemirror/aiGhostText.js

pooja-bruno added a commit to pooja-bruno/bruno that referenced this pull request Jul 15, 2026
The 'accept word' shortcut added in usebruno#8607 introduced a second
<kbd>{modifier}</kbd> in the keymap, so getByText(modifier) now throws
on multiple matches. Use getAllByText to assert all occurrences.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants