Support pasted search text in the skills toggle view (#58130)

## What changed

Append pasted text to the skills search query and immediately refresh the filtered list. Normalize whitespace for a single-line query and ignore whitespace-only pastes.

## Testing

Extend the filtering test to cover pasting after typed text, verify the rendered search results with a snapshot, and check that whitespace-only pastes leave the view unchanged.

GitOrigin-RevId: fa82d2b5f1c78a7c3a7f61fc2d4f24c94c960386
This commit is contained in:
Matthew Ma
2026-10-29 17:35:44 +00:00
committed by copyberry
parent 875a1a78f0
commit 03b7e22f94
2 changed files with 33 additions and 2 deletions
@@ -14,6 +14,7 @@ use ratatui::widgets::Wrap;
use crate::app_event::AppEvent;
use crate::app_event_sender::AppEventSender;
use crate::clipboard_paste::normalize_pasted_search_query;
use crate::key_hint;
use crate::key_hint::KeyBindingListExt;
use crate::key_hint::ShortcutHint;
@@ -243,6 +244,15 @@ impl BottomPaneView for SkillsToggleView {
}
}
fn handle_paste(&mut self, pasted: String) -> bool {
let Some(pasted) = normalize_pasted_search_query(&pasted) else {
return false;
};
self.search_query.push_str(&pasted);
self.apply_filter();
true
}
fn is_complete(&self) -> bool {
self.complete
}
@@ -468,8 +478,14 @@ mod tests {
tx,
crate::keymap::RuntimeKeymap::defaults().list,
);
view.search_query = "completion".to_string();
view.apply_filter();
view.handle_key_event(KeyEvent::new(KeyCode::Char('c'), KeyModifiers::NONE));
assert!(view.handle_paste(" ompletion\r\n\t ".to_string()));
assert_eq!(view.search_query, "completion");
let rendered = render_lines(&view, /*width*/ 96);
assert_snapshot!("skills_toggle_pasted_search", rendered);
assert!(!view.handle_paste(" \r\n\t ".to_string()));
assert_eq!(render_lines(&view, /*width*/ 96), rendered);
let row_names = view
.build_rows()
@@ -0,0 +1,15 @@
---
source: tui/src/bottom_pane/skills_toggle_view.rs
expression: "render_lines(&view, 96)"
---
Enable/Disable Skills
Turn skills on or off. Your changes are saved automatically.
completion
› [ ] superpowers-verification-before-completion (polish) Verify completion before claiming su…
space/enter toggle · esc close