Skip to content

Commit 0b4cf0b

Browse files
feat(zsh): add fuzzy search query parameter to provider selection (#2385)
1 parent a0ffc65 commit 0b4cf0b

4 files changed

Lines changed: 28 additions & 9 deletions

File tree

shell-plugin/lib/actions/auth.zsh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
# Action handler: Login to provider
66
function _forge_action_login() {
7+
local input_text="$1"
78
echo
89
local selected
9-
selected=$(_forge_select_provider)
10+
# Pass input_text as query parameter for fuzzy search
11+
selected=$(_forge_select_provider "" "" "" "$input_text")
1012
if [[ -n "$selected" ]]; then
1113
# Extract the second field (provider ID)
1214
local provider=$(echo "$selected" | awk '{print $2}')
@@ -16,9 +18,11 @@ function _forge_action_login() {
1618

1719
# Action handler: Logout from provider
1820
function _forge_action_logout() {
21+
local input_text="$1"
1922
echo
2023
local selected
21-
selected=$(_forge_select_provider "\[yes\]")
24+
# Pass input_text as query parameter for fuzzy search
25+
selected=$(_forge_select_provider "\[yes\]" "" "" "$input_text")
2226
if [[ -n "$selected" ]]; then
2327
# Extract the second field (provider ID)
2428
local provider=$(echo "$selected" | awk '{print $2}')

shell-plugin/lib/actions/config.zsh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ function _forge_action_agent() {
7474

7575
# Action handler: Select provider
7676
function _forge_action_provider() {
77+
local input_text="$1"
7778
echo
7879
local selected
7980
# Only show LLM providers (exclude context_engine and other non-LLM types)
80-
selected=$(_forge_select_provider "" "" "llm")
81+
# Pass input_text as query parameter for fuzzy search
82+
selected=$(_forge_select_provider "" "" "llm" "$input_text")
8183

8284
if [[ -n "$selected" ]]; then
8385
# Extract the second field (provider ID) from the selected line
@@ -90,7 +92,8 @@ function _forge_action_provider() {
9092

9193
# Action handler: Select model
9294
function _forge_action_model() {
93-
_forge_select_and_set_config "list models" "model" "Model" "$($_FORGE_BIN config get model --porcelain)" "2,3.."
95+
local input_text="$1"
96+
_forge_select_and_set_config "list models" "model" "Model" "$($_FORGE_BIN config get model --porcelain)" "2,3.." "$input_text"
9497
}
9598

9699
# Action handler: Sync workspace for codebase search
@@ -108,6 +111,7 @@ function _forge_select_and_set_config() {
108111
local prompt_text="$3"
109112
local default_value="$4"
110113
local with_nth="${5:-}" # Optional column selection parameter
114+
local query="${6:-}" # Optional query parameter for fuzzy search
111115
(
112116
echo
113117
local output
@@ -128,6 +132,11 @@ function _forge_select_and_set_config() {
128132
fzf_args+=(--with-nth="$with_nth")
129133
fi
130134

135+
# Add query parameter if provided
136+
if [[ -n "$query" ]]; then
137+
fzf_args+=(--query="$query")
138+
fi
139+
131140
if [[ -n "$default_value" ]]; then
132141
# For models, compare against the first field (model_id)
133142
local index=$(_forge_find_index "$output" "$default_value" 1)

shell-plugin/lib/actions/provider.zsh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# Provider selection helper
44

55
# Helper function to select a provider from the list
6-
# Usage: _forge_select_provider [filter_status] [current_provider] [filter_type]
6+
# Usage: _forge_select_provider [filter_status] [current_provider] [filter_type] [query]
77
# Returns: selected provider line (via stdout)
88
function _forge_select_provider() {
99
local filter_status="${1:-}"
1010
local current_provider="${2:-}"
1111
local filter_type="${3:-}"
12+
local query="${4:-}"
1213
local output
1314

1415
# Build the command with type filter if specified
@@ -47,6 +48,11 @@ function _forge_select_provider() {
4748
--with-nth=1,3..
4849
)
4950

51+
# Add query parameter if provided
52+
if [[ -n "$query" ]]; then
53+
fzf_args+=(--query="$query")
54+
fi
55+
5056
# Position cursor on current provider if available
5157
if [[ -n "$current_provider" ]]; then
5258
# For providers, compare against the first field (display name)

shell-plugin/lib/dispatcher.zsh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ function forge-accept-line() {
157157
_forge_action_conversation "$input_text"
158158
;;
159159
provider|p)
160-
_forge_action_provider
160+
_forge_action_provider "$input_text"
161161
;;
162162
model|m)
163-
_forge_action_model
163+
_forge_action_model "$input_text"
164164
;;
165165
tools|t)
166166
_forge_action_tools
@@ -193,10 +193,10 @@ function forge-accept-line() {
193193
_forge_action_sync
194194
;;
195195
login)
196-
_forge_action_login
196+
_forge_action_login "$input_text"
197197
;;
198198
logout)
199-
_forge_action_logout
199+
_forge_action_logout "$input_text"
200200
;;
201201
doctor)
202202
_forge_action_doctor

0 commit comments

Comments
 (0)