Skip to content

feat(ai_chat_view): 模型下拉支持模糊搜索 - #442

Merged
feigeCode merged 1 commit into
mainfrom
feat/llm-model-fuzzy-search-405
Oct 22, 2026
Merged

feigeCode merged 1 commit into
mainfrom
feat/llm-model-fuzzy-search-405

Conversation

@feigeCode

Copy link
Copy Markdown
Owner

问题

Closes #405

openrouter 这类聚合 provider 返回数百个模型,底部模型下拉一次性全量渲染,无法快速定位想要的模型。

改动

  • 选项数量超过 MODEL_MENU_SEARCH_MIN_OPTIONS(15)时,在下拉列表顶部显示搜索框:
    • 独立 InputState 实体(与上下文面板搜索框同款),不抢主输入框焦点、不拦截回车提交;
    • 打开下拉时在 render 阶段自动清空上次的搜索词。
  • 过滤逻辑 filter_model_options:
    • provider 名 / model 名 / hint 子串匹配,忽略大小写、trim 首尾空白;
    • 空关键字原样返回,保持上层注入顺序;
    • model 名以关键字开头的选项排前面(前缀优先),其余保持原相对顺序;
    • 无匹配显示「未匹配到模型」空态。
  • 列表限高 MODEL_MENU_LIST_MAX_HEIGHT(320px)内部滚动,选项标签 truncate,长模型名不再撑爆 popover。

验证

  • cargo test -p ai_chat_view --lib:450 passed,含新增回归测试:
    • model_option_search_matches_provider_model_and_hint(provider/model/hint 三字段命中);
    • filter_model_options_ranks_model_prefix_first_and_keeps_order_without_query(空关键字保序、前缀优先、无匹配为空)。
  • cargo fmt --check:本次改动文件无差异(仓库既有 118 处漂移未动);
  • cargo clippy -p ai_chat_view --lib:无新增警告(剩余 2 处 too_many_arguments 为 main 既有)。

openrouter 等聚合 provider 有数百个模型,下拉一次性全量渲染难以定位。
选项超过阈值(15)时在列表顶部显示搜索框,按 provider/model/hint 子串
不区分大小写过滤,并把 model 名以关键字开头的选项排前;列表限高滚动,
无匹配时显示空态文案。搜索框独立 InputState 实体,打开下拉时自动清空,
不影响主输入框焦点与回车提交。

Closes #405
@feigeCode
feigeCode merged commit cc9319e into main Oct 22, 2026
8 checks passed
@newbirdking

Copy link
Copy Markdown
image 没有模糊搜索的呀,输入不了.最新版本0.20.4

@feigeCode
feigeCode deleted the feat/llm-model-fuzzy-search-405 branch October 22, 2026 02:34
@feigeCode

feigeCode commented Oct 22, 2026 via email

Copy link
Copy Markdown
Owner Author

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.

[Feature]: LLM提供商模型都可以支持模糊匹配,

2 participants