Add Type Ahead experiment#151
Conversation
Adds AI-powered autocomplete suggestions: - Real-time text completion in the block editor - Context-aware suggestions based on content - Keyboard shortcuts for accepting suggestions
The generate_suggestion() method was calling a non-existent get_model_preferences() method. Changed to use the shared get_preferred_models() helper function like other abilities.
- Prioritize gpt-5.1-nano, then claude-haiku-4-5 for faster responses - Lower ghost text z-index to avoid overlap with WordPress UI elements
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #151 +/- ##
=============================================
- Coverage 76.71% 76.50% -0.21%
- Complexity 1828 1868 +40
=============================================
Files 87 89 +2
Lines 7764 7985 +221
=============================================
+ Hits 5956 6109 +153
- Misses 1808 1876 +68
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds an AI-powered type-ahead experiment that provides inline ghost text autocomplete suggestions in the WordPress block editor. Users can accept suggestions using keyboard shortcuts (Tab for full, Ctrl+Right for word/sentence, Escape to dismiss). The feature includes configurable completion modes and targets fast, low-cost AI models for responsive performance.
Key changes:
- New Type Ahead ability with structured input/output schemas and caching
- React-based block editor integration with ghost text overlay and keyboard handling
- Experiment registration with comprehensive settings UI (mode, delay, confidence, max words)
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| webpack.config.js | Adds entry point for the type-ahead experiment bundle |
| src/utils/run-ability.ts | New utility for safe ability execution with REST API fallback |
| src/experiments/type-ahead/style.scss | Styles for ghost text overlay positioning and appearance |
| src/experiments/type-ahead/index.tsx | Main React component with DOM tracking, caret monitoring, and keyboard handlers |
| includes/Experiments/Type_Ahead/Type_Ahead.php | Experiment registration, settings, and asset enqueuing |
| includes/Experiment_Loader.php | Registers Type_Ahead experiment in default experiments list |
| includes/Abilities/Type_Ahead/system-instruction.php | AI prompt instruction for generating inline completions |
| includes/Abilities/Type_Ahead/Type_Ahead.php | Ability implementation with AI client integration and caching |
| docs/experiments/type-ahead.md | Documentation for hooks, data flow, and testing procedures |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
Would something like this have the ability to adhere to the defined content guidelines should someone have that implemented? |
jeffpaul
left a comment
There was a problem hiding this comment.
In testing this again, I could see where some sort of loading indicator might actually be helpful. I had inadvertently started testing with only Ollama installed and the type ahead never got triggered, but when I added back OpenAI things worked as expected. The problem now is there's no clue as to what's happening if the available Connector(s) don't properly work with the feature, but perhaps a pulsing ellipses or WP logo in place of the blinking cursor might be a worthwhile test? I can't seem to decide whether we add something like that now or ship this experiment and iterate if there's community feedback to do so in the future?
|
Testing again via Playground, thinking we ignore the loading/cursor questions above and can funnel that off as a post-release issue to see what the community feedback is on the experiment and can adjust In the future. Otherwise, I think we should hide the options for the feature and just have the enable/disable toggle only. That would mean another top right elipses menu option for "Show/hide advanced options" sort of an option that would display these Type-ahead Text options and any other Features or Experiments that have similar advanced options (like Content Classification). |
Yeah, been on my mind on how we introduce more advanced settings while still keeping the interface clean. I think likely worth a larger conversation and not something I'd try and wrap into this PR personally. That said, looking at the settings we're adding here for Type Ahead, I'd suggest just removing those all together I think. These were added as part of the initial PR work and I just left them in place but these are all fairly advanced settings and not sure they provide much value here. @jeffpaul Any concerns if I just remove those settings all together and just have decent defaults (maybe with filters that can be used to change those?) |
|
@dkotter yes let's go ahead and remove those settings here, as I prefer to keep options in the AI settings as simple as possible (for now). I'll open a separate issue for the loading animation/cursor and the advanced settings topics so we can sort out approach on both separate from landing this Experiment. |
…sed through a filter. Fix a bug where types were incorrect
Okay, settings removed and merge conflicts resolved so I think this is good to go |
jeffpaul
left a comment
There was a problem hiding this comment.
Works well in testing via Playground, thanks!!!
What?
Adds a new type ahead experimental Feature. Automatically triggers at the end of a paragraph block and can be manually triggered within the block.
Why?
Type ahead / ghost text autocomplete is a fairly common AI pattern so this experimental Feature brings it into WordPress. Works on paragraph blocks and optionally heading blocks if turned on. Will send the surrounding content and asks the LLM to generate the next handful of words (could be a full sentence, could be a partial one).
How?
Type_Aheadexperimental Feature and aType_AheadAbilityclaude-haiku-4-5→gemini-2.5-flash→gpt-4.1-nanoUse of AI Tools
Can't speak to the original code but in the cleanup, used Cursor running Codex 5.3 to refactor the typescript and debug a few issues
Testing Instructions
npm i && npm run buildScreenshots