Skip to content

Add inline suggestion display API#114

Closed
M09Ic wants to merge 1 commit into
reeflective:masterfrom
M09Ic:pr/readline-inline-suggestion
Closed

Add inline suggestion display API#114
M09Ic wants to merge 1 commit into
reeflective:masterfrom
M09Ic:pr/readline-inline-suggestion

Conversation

@M09Ic

@M09Ic M09Ic commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Background

Applications that build interactive shells often have suggestions that do not come from readline history: AI command suggestions, remote completions, or application-specific prediction engines. These suggestions are best displayed as ghost text after the cursor, similar to history autosuggest, but callers currently have no public API to provide such text.

Approach

  • Add Shell.SetInlineSuggestion, Shell.ClearInlineSuggestion, and Shell.GetInlineSuggestion.
  • Store the suggestion in the display engine and render only the suffix after the current line.
  • Apply the suggestion only when the cursor is at the end of the line and the suggestion extends the current line.
  • Keep existing history autosuggest behavior first, so history suggestions continue to win when enabled and available.
  • Include the inline suggestion in display coordinate calculation so wrapping and cleanup account for the ghost text width.

Tests

  • Added public API coverage for set/get/clear.
  • Added display-engine tests for prefix matching, cursor-position gating, coordinate line selection, and history-autosuggest precedence.
  • Ran go test ./...

@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.77778% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.81%. Comparing base (088046b) to head (6ce8284).

Files with missing lines Patch % Lines
internal/display/engine.go 66.66% 9 Missing ⚠️
shell.go 50.00% 3 Missing and 3 partials ⚠️
internal/display/refresh.go 33.33% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #114      +/-   ##
==========================================
+ Coverage   38.33%   38.81%   +0.47%     
==========================================
  Files          59       59              
  Lines        9516     9556      +40     
==========================================
+ Hits         3648     3709      +61     
+ Misses       5785     5762      -23     
- Partials       83       85       +2     

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

@maxlandon

Copy link
Copy Markdown
Member

Superseded by #115, which merged this change (recommitted as a signed commit with your authorship preserved) into master via dev. Thanks for the contribution! 🙏

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