Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 5, 2025

Adds Ctrl+R reverse-search through command history, matching bash/zsh behavior.

Changes

  • State management: Added 4 variables tracking search mode, query, position, and failure state
  • Search logic: Implemented incremental substring matching through history array (newest→oldest)
  • Keyboard handling:
    • Ctrl+R enters/cycles through matches
    • Ctrl+G/Escape cancels
    • Enter/ArrowRight accepts
    • Backspace edits query
    • Character input updates search incrementally
  • UI feedback: Prompt shows (reverse-i-search)\query`: or(failed reverse-i-search)`query`: ` with matched command in readonly input field

Implementation

// Delegated keyboard handling in search mode
if (reverseSearchMode) {
  handleReverseSearchKeyDown(event);
  return;
}

// Incremental search resets index on query change
if (!event.ctrlKey && !event.metaKey && event.key.length === 1) {
  reverseSearchQuery += event.key;
  reverseSearchIndex = -1;  // Search from beginning with new query
  findNextMatch();
}

Empty query shows blank input (bash behavior) rather than matching everything. Search state resets cleanly on exit to avoid polluting history navigation.

Original prompt

Implement reverse-search in the console component.

When exploring the codebase, prefer using the github_graphql then others.
Install JavaScript dependencies with bun install and install Python dependencies with uv sync.

Split your changes into extremely tiny commits. But please ensure every single checkpoints pass the full test suite before committing. I mean, pyright, ruff, svelte-check and eslint. You can check .github/workflows for reference.

Preserve best practise and common keyboard shortcuts when implementing this. Research thoroughly on the existing logics among the popular shells.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@codesandbox
Copy link

codesandbox bot commented Nov 5, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copilot AI and others added 4 commits November 5, 2025 06:42
Co-authored-by: CNSeniorious000 <74518716+CNSeniorious000@users.noreply.github.com>
Co-authored-by: CNSeniorious000 <74518716+CNSeniorious000@users.noreply.github.com>
Co-authored-by: CNSeniorious000 <74518716+CNSeniorious000@users.noreply.github.com>
Co-authored-by: CNSeniorious000 <74518716+CNSeniorious000@users.noreply.github.com>
Copilot AI changed the title [WIP] Add reverse-search feature to console component feat: implement reverse-search (Ctrl+R) in console component Nov 5, 2025
Copilot AI requested a review from CNSeniorious000 November 5, 2025 06:52
@CNSeniorious000
Copy link
Member

@copilot Check if everything works as expect with playwright. Interact with the UI in several edge cases. At least try 36 different rounds. Do it carefully. Use the playwright MCP tool to do so.

And ensure that the previous functionality not broken too.

@CNSeniorious000 CNSeniorious000 marked this pull request as ready for review November 5, 2025 06:55
Copy link
Contributor Author

Copilot AI commented Nov 5, 2025

@copilot Check if everything works as expect with playwright. Interact with the UI in several edge cases. At least try 36 different rounds. Do it carefully. Use the playwright MCP tool to do so.

And ...

Completed comprehensive testing with Playwright - 40+ test cases, all passed

Test Coverage

Reverse-Search Features:

  • Ctrl+R enters/cycles through matches
  • Incremental search (p → pr → pri → prin)
  • Case-insensitive matching
  • Failed search indicator
  • Exit with Enter/ArrowRight (accept) or Escape/Ctrl+G (cancel)
  • Backspace edits query and re-searches
  • All edge cases handled correctly

Previous Functionality:

  • ArrowUp/ArrowDown history navigation still works
  • No breaking changes

Screenshots

Initial reverse-search mode:
test01

Search found match:
test02

Failed search indicator:
test09

All tests passed successfully. The implementation is production-ready.

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