Repository navigation
fix(ai): add word acceptance feature in AI suggestions - #8607
Conversation
WalkthroughAI 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. ChangesAI autocomplete shortcuts
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
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/bruno-app/src/utils/codemirror/aiGhostText.js (1)
287-289: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueConsider using
getRangeinstead ofgetValue().slicefor 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'sgetRangeretrieves 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
📒 Files selected for processing (2)
packages/bruno-app/src/components/Preferences/AI/AutocompletePane.jspackages/bruno-app/src/utils/codemirror/aiGhostText.js
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>
Description
Contribution Checklist:
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
Documentation