[PR #14266] [CLOSED] feat: add search bar with clear button to user chats modal #10225

Closed
opened 2025-11-11 18:59:26 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/14266
Author: @silentoplayz
Created: 5/24/2025
Status: Closed

Base: devHead: user-chats-modal


📝 Commits (2)

  • 54aa103 feat: add search bar to user chats modal
  • e6049ac feat: Add clear button for search bar

📊 Changes

1 file changed (+118 additions, -41 deletions)

View changed files

📝 src/lib/components/admin/Users/UserList/UserChatsModal.svelte (+118 -41)

📄 Description

Pull Request Checklist

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests to validate the changes?
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Changelog Entry

Description

This pull request introduces search functionality and improves the sorting capabilities within the User Chats modal. It also refactors the data fetching and deletion logic for better structure and error handling, and correctly implements the deletion confirmation using the ConfirmDialog component.

Added

  • Search input field to filter user chats by title.
  • searchValue state variable to store the current search query.
  • Logic to filter the displayed chat list based on searchValue.
  • Error handling for chat fetching using toast.error.
  • on:cancel handler for the ConfirmDialog to reset the chat to delete.
  • Loading state handling (showing spinner) while chats are being fetched (chats === null).
  • Specific message displayed when no chats match the current search filter.

Changed

  • Refactored chat fetching logic into a dedicated fetchUserChats function.
  • Updated the reactive statement ($: if (show)) to fetch chats only once when the modal opens and chats is null.
  • Improved sorting logic in setSortKey to set the default order based on the key (descending for date, ascending for title).
  • Enhanced sorting comparison logic to handle potential null or undefined values and use localeCompare for string sorting.
  • Refactored the chat deletion process to be fully managed by the ConfirmDialog component's on:confirm event.
  • Updated the delete handler (deleteChatHandler) to close the confirm dialog and re-fetch the chat list only if the modal is still open and the user is valid.
  • Adjusted spinner and empty state display logic to reflect the new filtering and loading states.
  • Added check for user existence in the modal title display.

Removed

  • Removed unused import getArchivedChatList.

Fixed

  • Corrected the flow for deleting a chat using the ConfirmDialog, ensuring the deletion happens only on confirmation and the modal state is managed correctly.

Additional Information

  • The modal now provides a more user-friendly experience for administrators searching through a user's potentially large chat history.
  • The refactoring improves code readability and maintainability.
  • The previous reactive statement that set chats = null when show was false has been removed. Chats now remain in memory when the modal is hidden, which might be a performance consideration for users with many chats, but simplifies the fetching logic on re-opening.

Screenshots or Videos

Before:
image
After:
image
image

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/14266 **Author:** [@silentoplayz](https://github.com/silentoplayz) **Created:** 5/24/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `user-chats-modal` --- ### 📝 Commits (2) - [`54aa103`](https://github.com/open-webui/open-webui/commit/54aa1038459895bf17814007e4a6b5c6fda517b5) feat: add search bar to user chats modal - [`e6049ac`](https://github.com/open-webui/open-webui/commit/e6049ac83c1f8b9f47b8c230f6cb5154c478d67a) feat: Add clear button for search bar ### 📊 Changes **1 file changed** (+118 additions, -41 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/admin/Users/UserList/UserChatsModal.svelte` (+118 -41) </details> ### 📄 Description # Pull Request Checklist **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Have you written and run sufficient tests to validate the changes? - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: - **BREAKING CHANGE**: Significant changes that may affect compatibility - **build**: Changes that affect the build system or external dependencies - **ci**: Changes to our continuous integration processes or workflows - **chore**: Refactor, cleanup, or other non-functional code changes - **docs**: Documentation update or addition - **feat**: Introduces a new feature or enhancement to the codebase - **fix**: Bug fix or error correction - **i18n**: Internationalization or localization changes - **perf**: Performance improvement - **refactor**: Code restructuring for better maintainability, readability, or scalability - **style**: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.) - **test**: Adding missing tests or correcting existing tests - **WIP**: Work in progress, a temporary label for incomplete or ongoing work # Changelog Entry ### Description This pull request introduces search functionality and improves the sorting capabilities within the User Chats modal. It also refactors the data fetching and deletion logic for better structure and error handling, and correctly implements the deletion confirmation using the `ConfirmDialog` component. ### Added - Search input field to filter user chats by title. - `searchValue` state variable to store the current search query. - Logic to filter the displayed chat list based on `searchValue`. - Error handling for chat fetching using `toast.error`. - `on:cancel` handler for the `ConfirmDialog` to reset the chat to delete. - Loading state handling (showing spinner) while chats are being fetched (`chats === null`). - Specific message displayed when no chats match the current search filter. ### Changed - Refactored chat fetching logic into a dedicated `fetchUserChats` function. - Updated the reactive statement (`$: if (show)`) to fetch chats only once when the modal opens and `chats` is null. - Improved sorting logic in `setSortKey` to set the default order based on the key (descending for date, ascending for title). - Enhanced sorting comparison logic to handle potential `null` or `undefined` values and use `localeCompare` for string sorting. - Refactored the chat deletion process to be fully managed by the `ConfirmDialog` component's `on:confirm` event. - Updated the delete handler (`deleteChatHandler`) to close the confirm dialog and re-fetch the chat list only if the modal is still open and the user is valid. - Adjusted spinner and empty state display logic to reflect the new filtering and loading states. - Added check for `user` existence in the modal title display. ### Removed - Removed unused import `getArchivedChatList`. ### Fixed - Corrected the flow for deleting a chat using the `ConfirmDialog`, ensuring the deletion happens only on confirmation and the modal state is managed correctly. --- ### Additional Information - The modal now provides a more user-friendly experience for administrators searching through a user's potentially large chat history. - The refactoring improves code readability and maintainability. - The previous reactive statement that set `chats = null` when `show` was false has been removed. Chats now remain in memory when the modal is hidden, which might be a performance consideration for users with many chats, but simplifies the fetching logic on re-opening. ### Screenshots or Videos **Before:** ![image](https://github.com/user-attachments/assets/b77467fd-bf60-4ce7-a6f9-e1b8a9251f9e) **After:** ![image](https://github.com/user-attachments/assets/a49ab7c2-e80a-4fc3-9eeb-64dcdacc72f2) ![image](https://github.com/user-attachments/assets/2ba7992c-b2ae-49f8-a7ae-f1e7a5066af4) ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-11 18:59:26 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#10225