Skip to content

fix: anchor slash popup to prompt line#225

Merged
F16shen merged 1 commit into
AI-Shell-Team:mainfrom
F16shen:fix/slash-popup-newline-anchor
Jun 3, 2026
Merged

fix: anchor slash popup to prompt line#225
F16shen merged 1 commit into
AI-Shell-Team:mainfrom
F16shen:fix/slash-popup-newline-anchor

Conversation

@F16shen
Copy link
Copy Markdown
Collaborator

@F16shen F16shen commented Jun 3, 2026

Background

Rustyline appends a newline when the slash popup is triggered via Cmd::Interrupt, which can move the inline slash popup off the original prompt line and cause the extra-line behavior when re-opening slash completion after deleting input.

Changes

  • move the cursor back to the original prompt line before creating the inline slash popup viewport
  • drain pending keyboard events before ratatui queries cursor position, so stale bytes do not corrupt the viewport anchor
  • keep the fix localized to the slash popup session instead of compensating in the outer shell loop

Validation

  • cargo fmt --all --check
  • cargo test -p aish-shell --lib --no-run
  • manual interactive verification of slash popup reopen behavior after deleting input with Backspace

Risk

  • terminal-specific cursor movement behavior around the popup initialization path may still vary across environments, but the change is limited to slash popup startup

Summary by CodeRabbit

Bug Fixes

  • Improved terminal cursor handling in the slash input feature by correcting cursor position restoration and clearing stale keyboard events to prevent cursor corruption during input processing.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

Thanks for the pull request. A maintainer will review it when available.

Please keep the PR focused, explain the why in the description, and make sure local checks pass before requesting review.

Contribution guide: https://github.com/AI-Shell-Team/aish/blob/main/CONTRIBUTING.md

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

This pull request description looks incomplete. Please update the missing sections below before review.

Missing items:

  • Summary
  • User-visible Changes
  • Compatibility
  • Testing
  • Change Type
  • Scope

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bf8e2bb0-af42-4e2d-be0c-3b7e27bfce85

📥 Commits

Reviewing files that changed from the base of the PR and between dadc505 and 1443889.

📒 Files selected for processing (1)
  • crates/aish-ui/src/slash_input.rs

📝 Walkthrough

Walkthrough

The PR adjusts SlashInputSession::run to move the cursor back to the original prompt line and drain pending input events immediately after entering raw mode, before ratatui queries cursor position for the inline viewport. A duplicate drain call is removed to consolidate event draining to the earlier point.

Changes

Cursor Positioning and Event Draining

Layer / File(s) Summary
Cursor restoration and event draining
crates/aish-ui/src/slash_input.rs
After entering raw mode, the session moves the cursor back to the original prompt line and drains pending keyboard events before ratatui queries the cursor position for the inline viewport. The duplicate drain call later in the flow is removed, consolidating event draining to this earlier point.

Possibly related PRs

  • AI-Shell-Team/aish#219: Directly overlaps with slash-popup implementation that introduced SlashInputSession::run raw-mode cursor handling and event draining.

Suggested labels

size: XS

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐰 A cursor danced with drunken keys,
Raw mode chaos, events to appease,
Now drain before the viewport's gaze—
Restore the line, clear stale malaise,
One clean path through the terminal maze!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: anchor slash popup to prompt line' directly and specifically describes the main change: repositioning the slash popup to stay anchored to the original prompt line rather than being displaced to a new line.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@F16shen F16shen merged commit 0d156ac into AI-Shell-Team:main Jun 3, 2026
9 checks passed
@F16shen F16shen deleted the fix/slash-popup-newline-anchor branch June 3, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant