Terminal ghost suggetions - #86
Conversation
Stop inventing leading spaces on history completions (ls/lsblk), prefer mid-token ranking, position ghost from line origin under echo lag, and size overlay glyphs with terminal display width. Backend owns suffix spacing; frontend clamp removed.
Promote ghost mid-token spacing and SSH lag overlay fixes to 2.22.1.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughGhost suggestion spacing and ranking now favor provider-defined boundaries and mid-token continuations. The terminal overlay gains SSH-lag-aware positioning, display-width segmentation, layout propagation, updated tests, and 2.22.1 release metadata. ChangesGhost Suggestions
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant TerminalInput
participant useTerminalGhost
participant TerminalHost
participant GhostSuggestionOverlay
participant getGhostPixelPosition
TerminalInput->>useTerminalGhost: process typed input and echo events
useTerminalGhost->>useTerminalGhost: capture origin and typed cell count
useTerminalGhost->>TerminalHost: provide ghostLayout
TerminalHost->>GhostSuggestionOverlay: pass layout and suggestion
GhostSuggestionOverlay->>getGhostPixelPosition: resolve ghost pixel position
getGhostPixelPosition-->>GhostSuggestionOverlay: return predicted or live position
Possibly related PRs
🚥 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 |
PR Summary by QodoFix ghost suggestion spacing and SSH echo-lag overlay alignment
AI Description
Diagram
High-Level Assessment
Files changed (17)
|
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src-tauri/src/ghost/ranking.rs (1)
71-77: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the mid-token bonus into a named constant.
50.0is a hard-coded value that fully dominatessuffix_bonus_for_command's bonus range (including the-3shell-separator and-2chained-command penalties). That's likely intentional per the PR's stated goal, but as a bare magic number it's hard to tune/reason about later, and it effectively neutralizes the existing safety-oriented penalties for mid-token candidates.♻️ Proposed refactor
+/// Mid-token continuations should outrank a "new word" match unless the +/// combined structural bonus for the new-word candidate is enormous. Chosen +/// to be larger than the full `suffix_bonus_for_command` range. +const MID_TOKEN_BONUS: f64 = 50.0; + fn effective_rank_score(frecency: f64, bonus: i32, mid_token: bool) -> f64 { - let mid = if mid_token { 50.0 } else { 0.0 }; + let mid = if mid_token { MID_TOKEN_BONUS } else { 0.0 }; frecency + mid + f64::from(bonus) }🤖 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 `@src-tauri/src/ghost/ranking.rs` around lines 71 - 77, Extract the hard-coded 50.0 mid-token score in effective_rank_score into a clearly named constant, then use that constant when mid_token is true. Keep the existing scoring behavior and suffix bonus handling 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.
Inline comments:
In `@src/lib/ghostSuggestions/displayWidth.ts`:
- Around line 85-121: Update segmentTerminalCells to calculate each grapheme
cluster’s terminal width using grapheme-aware logic rather than relying solely
on stringDisplayWidth(segment). Ensure ZWJ emoji, skin-tone sequences, and
combining-mark clusters receive the correct cell count while preserving
zero-width standalone characters and the existing segment filtering behavior.
---
Nitpick comments:
In `@src-tauri/src/ghost/ranking.rs`:
- Around line 71-77: Extract the hard-coded 50.0 mid-token score in
effective_rank_score into a clearly named constant, then use that constant when
mid_token is true. Keep the existing scoring behavior and suffix bonus handling
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1b367e26-792d-4e71-8f85-43abf116d7e0
⛔ Files ignored due to path filters (2)
package-lock.jsonis excluded by!**/package-lock.jsonsrc-tauri/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (17)
CHANGELOG.mdpackage.jsonsrc-tauri/Cargo.tomlsrc-tauri/src/ghost/path_suggest.rssrc-tauri/src/ghost/ranking.rssrc-tauri/src/ghost/suffix.rssrc-tauri/tauri.conf.jsonsrc/components/terminal/GhostSuggestionOverlay.tsxsrc/components/terminal/Terminal.tsxsrc/components/terminal/TerminalHost.tsxsrc/components/terminal/useTerminalGhost.tssrc/lib/ghostSuggestions/client.tssrc/lib/ghostSuggestions/cursorPosition.tssrc/lib/ghostSuggestions/displayWidth.tssrc/lib/ghostSuggestions/suggestionSuffix.tstests/ghostSuggestionsHelpers.test.mjstsconfig.agent-tests.json
Require a single-token line before treating last_arg as bare cd/pushd/popd (fixes cd cd). Merge zero-width marks into the previous base glyph, use grapheme-aware display width for ZWJ/emoji, and name the mid-token ranking bonus constant.
Summary by CodeRabbit
Bug Fixes
Release
Tests