Skip to content

Add Type Ahead experiment#151

Merged
dkotter merged 35 commits into
WordPress:developfrom
Jameswlepage:feature/type-ahead
Jun 25, 2026
Merged

Add Type Ahead experiment#151
dkotter merged 35 commits into
WordPress:developfrom
Jameswlepage:feature/type-ahead

Conversation

@Jameswlepage

@Jameswlepage Jameswlepage commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

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?

  • Registers a new Type_Ahead experimental Feature and a Type_Ahead Ability
  • Automatically adds AI-powered ghost text autocomplete suggestions when at the end of a paragraph block and optionally a heading block
  • Suggestions should be context-aware based on surrounding content
  • Can trigger manually within a paragraph/heading block using the keyboard shortcut Ctrl+Space
  • Also supports Tab to accept, Escape to dismiss
  • Four different configurable completion modes (word, sentence, paragraph, smart)
  • Prioritizes fast, low-cost models for responsive completions:
    claude-haiku-4-5gemini-2.5-flashgpt-4.1-nano

Use 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

  • Clone this PR and run npm i && npm run build
  • Enable the Type Ahead experiment in AI settings
  • Create a new post and start typing in a paragraph block
  • Verify ghost text suggestions appear after a pause
  • Press Tab to accept or Escape to dismiss suggestions
  • Test different completion modes in experiment settings

Screenshots

CleanShot 2025-12-19 at 11 33 57@2x Open WordPress Playground Preview

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

codecov Bot commented Dec 19, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.23077% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.50%. Comparing base (dd7d364) to head (2d3add9).

Files with missing lines Patch % Lines
includes/Abilities/Type_Ahead/Type_Ahead.php 73.77% 48 Missing ⚠️
includes/Experiments/Type_Ahead/Type_Ahead.php 47.36% 20 Missing ⚠️
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     
Flag Coverage Δ
unit 76.50% <69.23%> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI 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.

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.

Comment thread src/experiments/type-ahead/index.tsx Outdated
Comment thread includes/Abilities/Type_Ahead/Type_Ahead.php
Comment thread src/utils/run-ability.ts Outdated
Comment thread src/utils/run-ability.ts
Comment thread includes/Abilities/Type_Ahead/Type_Ahead.php Outdated
Comment thread src/experiments/type-ahead/index.tsx Outdated
Comment thread src/experiments/type-ahead/index.tsx Outdated
Comment thread includes/Abilities/Type_Ahead/Type_Ahead.php Outdated
Comment thread includes/Experiments/Type_Ahead/Type_Ahead.php
Comment thread includes/Abilities/Type_Ahead/Type_Ahead.php
@jeffpaul

Copy link
Copy Markdown
Member

@jeffpaul

Copy link
Copy Markdown
Member
  • Reminder for us to add a screenshot gif and entry in the readme.txt for this feature before merging/releasing.

@JasonTheAdams JasonTheAdams removed their request for review December 21, 2025 05:58
@jeffpaul jeffpaul modified the milestones: 0.2.0, 0.3.0 Jan 7, 2026
@jeffpaul jeffpaul moved this from Needs review to In discussion / Needs decision in WordPress AI Roadmap Jan 7, 2026
@jeffpaul jeffpaul modified the milestones: 0.3.0, 0.4.0, Future Release Feb 3, 2026
@alansmodic

Copy link
Copy Markdown

Would something like this have the ability to adhere to the defined content guidelines should someone have that implemented?

jeffpaul
jeffpaul previously approved these changes Apr 21, 2026

@jeffpaul jeffpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

@jeffpaul jeffpaul modified the milestones: Future Release, 1.1.0 May 18, 2026
@dkotter dkotter modified the milestones: 1.0.1, 1.1.0 May 26, 2026
@jeffpaul jeffpaul modified the milestones: 1.0.2, 1.1.0 Jun 16, 2026
@jeffpaul

Copy link
Copy Markdown
Member

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).

@dkotter

dkotter commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

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?)

@jeffpaul

Copy link
Copy Markdown
Member

@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.

@dkotter

dkotter commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@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.

Okay, settings removed and merge conflicts resolved so I think this is good to go

@dkotter dkotter requested a review from jeffpaul June 25, 2026 17:26
jeffpaul
jeffpaul previously approved these changes Jun 25, 2026

@jeffpaul jeffpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works well in testing via Playground, thanks!!!

@dkotter dkotter merged commit 56cef56 into WordPress:develop Jun 25, 2026
21 of 23 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in WordPress AI Roadmap Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants