Skip to content

fix(webui): unify search input clear behavior#6017

Merged
Soulter merged 2 commits intoAstrBotDevs:masterfrom
Flartiny:fix/search-clearable
Mar 11, 2026
Merged

fix(webui): unify search input clear behavior#6017
Soulter merged 2 commits intoAstrBotDevs:masterfrom
Flartiny:fix/search-clearable

Conversation

@Flartiny
Copy link
Contributor

@Flartiny Flartiny commented Mar 11, 2026

统一webui搜索框清除行为,补充几处缺失

Modifications / 改动点

仅前端修改
dashboard/src/components/extension/componentPanel/composables/useCommandFilters.ts
dashboard/src/components/extension/componentPanel/index.vue
dashboard/src/components/provider/ProviderModelsPanel.vue
dashboard/src/composables/useProviderSources.ts
dashboard/src/views/ConfigPage.vue
dashboard/src/views/alkaid/KnowledgeBase.vue
dashboard/src/views/alkaid/LongTermMemory.vue
dashboard/src/views/extension/InstalledPluginsTab.vue
dashboard/src/views/extension/MarketPluginsTab.vue

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

image

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

Summary by Sourcery

通过规范文本值并启用统一的可清除搜索字段,在多个 WebUI 视图中统一并强化搜索输入处理。

Bug Fixes:

  • 解决当清除搜索输入后产生 null 或非字符串值时,导致搜索和过滤逻辑出错的问题。

Enhancements:

  • 通过共享的输入规范化工具,在命令过滤器、插件列表、提供方模型搜索,以及配置、知识库和长期记忆视图中启用可清除搜索字段和一致的输入规范化。
Original summary in English

Summary by Sourcery

Unify and harden search input handling across multiple WebUI views by normalizing text values and enabling consistent clearable search fields.

Bug Fixes:

  • Prevent search and filter logic from breaking when cleared search inputs produce null or non-string values.

Enhancements:

  • Enable clearable search fields and consistent input normalization in command filters, plugin lists, provider model searches, and configuration, knowledge base, and long-term memory views via a shared input normalization utility.

Bug 修复:

  • 防止在清空搜索后搜索输入值变为 null 时导致搜索和过滤逻辑出错。

功能增强:

  • 在多个视图和面板中启用可清空的搜索字段,提供更一致且更友好的搜索体验。
Original summary in English

Summary by Sourcery

通过规范文本值并启用统一的可清除搜索字段,在多个 WebUI 视图中统一并强化搜索输入处理。

Bug Fixes:

  • 解决当清除搜索输入后产生 null 或非字符串值时,导致搜索和过滤逻辑出错的问题。

Enhancements:

  • 通过共享的输入规范化工具,在命令过滤器、插件列表、提供方模型搜索,以及配置、知识库和长期记忆视图中启用可清除搜索字段和一致的输入规范化。
Original summary in English

Summary by Sourcery

Unify and harden search input handling across multiple WebUI views by normalizing text values and enabling consistent clearable search fields.

Bug Fixes:

  • Prevent search and filter logic from breaking when cleared search inputs produce null or non-string values.

Enhancements:

  • Enable clearable search fields and consistent input normalization in command filters, plugin lists, provider model searches, and configuration, knowledge base, and long-term memory views via a shared input normalization utility.

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 11, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request unifies the behavior of search input fields throughout the web UI. The primary goal is to enhance user experience by providing a consistent and robust mechanism for clearing search queries, both visually through a clear button and programmatically by ensuring search logic correctly handles empty or null input states.

Highlights

  • Enhanced Search Input Usability: Implemented clearable functionality for search input fields across various UI components, providing users with a quick and consistent way to clear their search queries.
  • Standardized Search Query Handling: Improved the robustness of search logic by ensuring that null or undefined search input values are consistently normalized to empty strings, preventing unexpected behavior in filters.
Changelog
  • dashboard/src/components/extension/componentPanel/components/CommandFilters.vue
    • Added a normalizeSearchQuery utility function.
    • Enabled the clearable property for the search text field.
    • Updated the update:model-value event to use the new normalizeSearchQuery function.
  • dashboard/src/components/extension/componentPanel/composables/useCommandFilters.ts
    • Modified the searchQuery processing to explicitly handle null values by defaulting to an empty string.
  • dashboard/src/components/extension/componentPanel/index.vue
    • Adjusted toolSearch processing to default to an empty string if null.
  • dashboard/src/components/provider/ProviderModelsPanel.vue
    • Added the clearable property to the model search text field.
    • Updated the modelSearchProxy setter to ensure the search value is always a string.
  • dashboard/src/composables/useProviderSources.ts
    • Modified modelSearch processing to explicitly handle null values by defaulting to an empty string.
  • dashboard/src/views/ConfigPage.vue
    • Enabled the clearable property for the configuration search text field.
  • dashboard/src/views/alkaid/KnowledgeBase.vue
    • Enabled the clearable property for the knowledge base search text field.
  • dashboard/src/views/alkaid/LongTermMemory.vue
    • Enabled the clearable property for both user ID and query search text fields.
  • dashboard/src/views/extension/InstalledPluginsTab.vue
    • Enabled the clearable property for the installed plugins search text field.
  • dashboard/src/views/extension/MarketPluginsTab.vue
    • Enabled the clearable property for the market plugins search text field.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot bot added the area:webui The bug / feature is about webui(dashboard) of astrbot. label Mar 11, 2026
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我已经留下了一些总体反馈:

  • 你在 CommandFilters.vue 中引入了 normalizeSearchQuery,但在其他地方则使用内联的 (value || '')typeof val === 'string' ? val : ''。建议将这种标准化逻辑集中到一个共享的工具函数中,或者至少在这些组件之间使用同一个辅助函数,以确保行为真正保持一致。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- You’ve introduced `normalizeSearchQuery` in `CommandFilters.vue` but elsewhere use inline `(value || '')` or `typeof val === 'string' ? val : ''`; consider centralizing this normalization in a shared utility or at least using the same helper across these components to keep the behavior truly consistent.

Sourcery 对开源项目永久免费——如果你觉得我们的代码审查有帮助,请考虑分享给他人 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English

Hey - I've left some high level feedback:

  • You’ve introduced normalizeSearchQuery in CommandFilters.vue but elsewhere use inline (value || '') or typeof val === 'string' ? val : ''; consider centralizing this normalization in a shared utility or at least using the same helper across these components to keep the behavior truly consistent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- You’ve introduced `normalizeSearchQuery` in `CommandFilters.vue` but elsewhere use inline `(value || '')` or `typeof val === 'string' ? val : ''`; consider centralizing this normalization in a shared utility or at least using the same helper across these components to keep the behavior truly consistent.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances various search input fields across the dashboard, including command filters, model search, configuration search, knowledge base search, long-term memory search, and plugin search, by adding a clearable button. To prevent potential runtime errors where clearing an input could result in a null value being passed to functions expecting a string (e.g., .trim(), .toLowerCase()), the changes also introduce logic to normalize search queries to empty strings if they are null. The review comments highlight that adding clearable without explicit null handling for configSearchKeyword, and searchQuery in both KnowledgeBase.vue and LongTermMemory.vue could lead to crashes, recommending normalization to an empty string for these cases.

@@ -16,6 +16,7 @@
v-model="configSearchKeyword"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Adding clearable can cause configSearchKeyword to become null when the input is cleared. This is likely to cause a crash in the child component AstrBotCoreConfigWrapper if it doesn't handle null values for its search-keyword prop. To prevent this and to be consistent with other changes in this PR, you should normalize the cleared value to an empty string.

           :model-value="configSearchKeyword"
           @update:model-value="configSearchKeyword = $event ?? ''"

@@ -356,7 +356,7 @@
<v-text-field v-model="searchQuery" :label="tm('search.queryLabel')"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Adding clearable can cause searchQuery to become null, which will lead to a crash in searchKnowledgeBase when calling .trim(). To prevent this, you should handle the null value by normalizing it to an empty string.

                                    <v-text-field :model-value="searchQuery" @update:model-value="searchQuery = $event ?? ''" :label="tm('search.queryLabel')"

<v-text-field v-model="searchMemoryUserId" :label="tm('search.userIdLabel')" variant="outlined" density="compact" hide-details
class="mb-2"></v-text-field>
class="mb-2" clearable></v-text-field>
<v-text-field v-model="searchQuery" :label="tm('search.queryLabel')" variant="outlined" density="compact" hide-details
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Adding clearable to this text field can cause searchQuery to become null, which will lead to a crash in searchMemory() when .trim() is called. To prevent this, you should handle the null value by normalizing it to an empty string.

            <v-text-field :model-value="searchQuery" @update:model-value="searchQuery = $event ?? ''" :label="tm('search.queryLabel')" variant="outlined" density="compact" hide-details

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Mar 11, 2026
@Flartiny
Copy link
Contributor Author

@sourcery-ai review

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些整体性的反馈:

  • 在多个组件中有相当多重复的 :model-value@update:model-value="foo = normalizeTextInput($event)" 绑定逻辑;可以考虑抽取一个小的可复用 composable 或封装组件,用于标准化搜索输入字段,以减少样板代码并保持行为一致。
  • 在某些地方,你会在输入时做一次标准化,然后在真正使用这个值之前(例如 KnowledgeBase 和 LongTermMemory 中的 searchQuery)又做了一次标准化;你可以只在其中一层做标准化,从而避免重复调用,并让数据流更清晰。
给 AI Agents 的提示
Please address the comments from this code review:

## Overall Comments
- There’s quite a bit of repeated `:model-value` + `@update:model-value="foo = normalizeTextInput($event)"` wiring across components; consider extracting a small reusable composable or wrapper component for normalized search fields to reduce boilerplate and keep behavior consistent.
- In some places you normalize on input and again right before using the value (e.g. `searchQuery` in KnowledgeBase and LongTermMemory); you could simplify by relying on normalization in only one of those layers to avoid redundant calls and make the data flow clearer.

Sourcery 对开源项目是免费的——如果你觉得我们的代码评审有帮助,欢迎分享给更多人 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据这些反馈改进后续的代码评审。
Original comment in English

Hey - I've left some high level feedback:

  • There’s quite a bit of repeated :model-value + @update:model-value="foo = normalizeTextInput($event)" wiring across components; consider extracting a small reusable composable or wrapper component for normalized search fields to reduce boilerplate and keep behavior consistent.
  • In some places you normalize on input and again right before using the value (e.g. searchQuery in KnowledgeBase and LongTermMemory); you could simplify by relying on normalization in only one of those layers to avoid redundant calls and make the data flow clearer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There’s quite a bit of repeated `:model-value` + `@update:model-value="foo = normalizeTextInput($event)"` wiring across components; consider extracting a small reusable composable or wrapper component for normalized search fields to reduce boilerplate and keep behavior consistent.
- In some places you normalize on input and again right before using the value (e.g. `searchQuery` in KnowledgeBase and LongTermMemory); you could simplify by relying on normalization in only one of those layers to avoid redundant calls and make the data flow clearer.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 11, 2026
@Soulter Soulter merged commit 8e6aaee into AstrBotDevs:master Mar 11, 2026
6 checks passed
@Flartiny Flartiny deleted the fix/search-clearable branch March 12, 2026 05:17
stevessr pushed a commit to stevessr/AstrBot that referenced this pull request Mar 12, 2026
* fix(webui): unify search input clear behavior

* fix: centralize search input normalization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:webui The bug / feature is about webui(dashboard) of astrbot. lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants