Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a page to search chat history #5274

Merged
merged 18 commits into from
Aug 20, 2024

Conversation

Movelocity
Copy link
Contributor

@Movelocity Movelocity commented Aug 14, 2024

💻 变更类型 | Change Type

  • feat
  • fix
  • refactor
  • perf
  • style
  • test
  • docs
  • ci
  • chore
  • build

🔀 变更说明 | Description of Change

增加一个搜索历史记录的页面,方便查看之前问过 GPT 的问题

📝 补充信息 | Additional Information

Demo: feature demo is here. You can import some chat history and experience the searching feature

Snipaste_2024-08-15_17-17-02

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new SearchChat component for searching through chat history.
    • Added a dynamic import for improved loading times of the SearchChat page.
    • Included a navigation button in the sidebar for quick access to the search feature.
    • Expanded localization support for SearchChat in multiple languages (English, Chinese, Japanese, Russian, Arabic, Bengali, Czech, German, Spanish, French, Indonesian, Korean, Norwegian, Portuguese, Turkish, Vietnamese).
  • Bug Fixes

    • Improved error handling within the SearchChat component.

These changes enhance user experience by providing efficient search capabilities and better accessibility across different languages.

Copy link

vercel bot commented Aug 14, 2024

Someone is attempting to deploy a commit to the NextChat Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Aug 14, 2024

Walkthrough

The recent updates introduce a SearchChat feature that significantly enhances user experience by enabling efficient searches through chat sessions. This includes dynamic imports for improved performance, comprehensive localization in multiple languages, and navigation enhancements via an IconButton. Overall, these updates refine accessibility and interactivity within the chat application.

Changes

Files Change Summary
app/components/home.tsx, app/components/sidebar.tsx Introduced dynamic import for SearchChat and added navigation capabilities with a new IconButton.
app/components/search-chat.tsx Added SearchChatPage component to manage chat session searches, utilizing hooks and displaying results.
app/constant.ts Added SearchChat path to the Path enum and updated PLUGINS to include the new search feature.
app/locales/* Extended localization with SearchChat strings in multiple languages, enhancing UI text for search functionality.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Sidebar
    participant Home
    participant SearchChat

    User->>Sidebar: Click on SearchChat Icon
    Sidebar->>Home: Navigate to SearchChat Route
    Home->>SearchChat: Load SearchChat Component
    SearchChat->>User: Display Search Input
    User->>SearchChat: Input Keywords and Press Enter
    SearchChat->>SearchChat: Execute Search Logic
    SearchChat->>User: Display Search Results
Loading

🐰 In the garden of chat, a new path unfolds,
With whispers of search, and stories retold.
Click on the icon, let curiosity sprout,
Explore every message, let no detail go out!
A hop and a skip, through memories we glide,
In this cheerful search, let the chats be our guide! 🌼✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
app/components/search-chat.tsx (1)

1-11: Optimize imports for better readability.

Consider grouping related imports together for better readability. For instance, group icon imports and utility imports separately.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between edb92f7 and cd92036.

Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (8)
  • app/components/home.tsx (2 hunks)
  • app/components/search-chat.tsx (1 hunks)
  • app/components/sidebar.tsx (1 hunks)
  • app/constant.ts (1 hunks)
  • app/locales/cn.ts (1 hunks)
  • app/locales/en.ts (1 hunks)
  • app/locales/jp.ts (1 hunks)
  • app/locales/ru.ts (1 hunks)
Additional comments not posted (10)
app/components/search-chat.tsx (2)

26-42: Ensure initial search results are meaningful.

The setDefaultItems function currently slices the first six sessions and uses the first message's content. Ensure this logic aligns with user expectations for default search results.


85-159: Ensure accessibility and localization support.

The JSX structure should ensure accessibility features such as ARIA labels where necessary. Additionally, verify that all text content is localized using the Locale object.

app/components/home.tsx (2)

62-67: Dynamic import for SearchChat looks good.

The dynamic import pattern is consistent with other components, ensuring modularity and potentially improved load times.


184-184: Ensure new route integration is seamless.

The new route for SearchChat is added correctly. Verify that navigation to this route is tested and does not disrupt existing routes.

app/locales/jp.ts (1)

247-262: Localization entries for SearchChat are well-structured.

The entries cover various UI elements and states for the SearchChat feature. Ensure these entries are utilized in the component and correctly displayed.

app/locales/ru.ts (1)

195-210: Localization strings for SearchChat look good.

The new SearchChat section is well-integrated and consistent with the existing localization format. The strings cover various aspects of the search feature, including titles, instructions, and status messages.

app/components/sidebar.tsx (1)

253-261: Integration of IconButton for search chat feature is well done.

The new IconButton for the search chat feature is correctly integrated into the sidebar. It uses the DiscoveryIcon and navigates to the SearchChat path. The conditional text display based on shouldNarrow is a nice touch for responsive design.

app/constant.ts (1)

44-44: Addition of SearchChat path is correct.

The SearchChat path is correctly added to the Path enum. It follows the existing naming conventions and is consistent with other paths in the application.

app/locales/cn.ts (1)

522-536: Ensure Consistency in Translation and Structure.

The SearchChat section has been added for the Chinese locale. The translations seem appropriate and consistent with the rest of the file. Ensure that these strings are used correctly in the application to support the new search functionality.

app/locales/en.ts (1)

530-545: Ensure Consistency in Structure and Usage.

The SearchChat section has been added for the English locale. The structure and language are consistent with the rest of the file. Ensure these strings are integrated correctly in the application to support the new search functionality.

app/components/search-chat.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

Your build has completed!

Preview deployment

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cd92036 and 3da5284.

Files ignored due to path filters (1)
  • app/icons/zoom.svg is excluded by !**/*.svg
Files selected for processing (6)
  • app/components/search-chat.tsx (1 hunks)
  • app/components/sidebar.tsx (2 hunks)
  • app/locales/cn.ts (1 hunks)
  • app/locales/en.ts (1 hunks)
  • app/locales/jp.ts (1 hunks)
  • app/locales/ru.ts (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • app/locales/cn.ts
  • app/locales/jp.ts
  • app/locales/ru.ts
Additional comments not posted (9)
app/components/search-chat.tsx (6)

1-11: LGTM! Import statements are appropriate.

The imports are relevant and necessary for the component's functionality.


13-17: LGTM! Type declaration is appropriate.

The Item type is well-defined for representing search results.


26-44: LGTM! State management is well-implemented.

The use of useState and useRef is appropriate for managing component state and references.


45-82: Optimize search logic for performance.

The current search logic iterates over all sessions and messages, which might be inefficient for large datasets. Consider implementing a more efficient search algorithm or indexing strategy.


84-100: LGTM! Effect hook is correctly implemented.

The use of setInterval and cleanup on unmount is appropriate for monitoring input changes.


102-177: LGTM! JSX rendering is well-structured.

The layout is clear, and the use of localization and styles is consistent.

app/components/sidebar.tsx (2)

Line range hint 1-15:
LGTM! Import statements are appropriate.

The imports are relevant and necessary for the component's functionality.


253-261: LGTM! IconButton for search chat is well-integrated.

The new IconButton for navigating to the search chat feature is appropriately added and styled.

app/locales/en.ts (1)

530-543: LGTM! Localization for SearchChat is comprehensive.

The localization strings are well-structured and cover all necessary UI elements for the search chat feature.

package-lock.json Outdated Show resolved Hide resolved
@Movelocity Movelocity reopened this Aug 15, 2024
@Movelocity Movelocity changed the title Add page to search chat history feat: add page to search chat history Aug 15, 2024
@Movelocity Movelocity changed the title feat: add page to search chat history feat: add a page to search chat history Aug 15, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3da5284 and 65ed6b0.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (1)
  • app/components/search-chat.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/components/search-chat.tsx

@lloydzhou
Copy link
Member

image

看起来这里菜单位置不太够

@lloydzhou
Copy link
Member

或许还需要考虑一下,这个搜索入口放哪里比较合适?

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Maybe you need to think about where to put this search entry?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 65ed6b0 and e3f499b.

Files selected for processing (1)
  • app/components/sidebar.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/components/sidebar.tsx

@Movelocity
Copy link
Contributor Author

或许还需要考虑一下,这个搜索入口放哪里比较合适?

关于菜单位置不够的问题,我做了一些调整,尝试隐藏搜索按钮的文本

image

在测试过程中,我发现日语菜单项的显示效果也不理想,目前面具选择的文本设置得比较长

image

后续其实可以考虑仅使用图标来代表功能,文本显示在鼠标悬停时的提示框中。
Discovery 也可以考虑用写成 Explore 缩短文本
image

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e3f499b and b84bb72.

Files selected for processing (1)
  • app/components/search-chat.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/components/search-chat.tsx

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b84bb72 and 82298a7.

Files selected for processing (3)
  • app/constant.ts (1 hunks)
  • app/locales/jp.ts (1 hunks)
  • app/locales/ru.ts (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • app/constant.ts
  • app/locales/jp.ts
  • app/locales/ru.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 82298a7 and fd1c656.

Files selected for processing (17)
  • app/locales/ar.ts (1 hunks)
  • app/locales/bn.ts (1 hunks)
  • app/locales/cs.ts (1 hunks)
  • app/locales/de.ts (1 hunks)
  • app/locales/es.ts (1 hunks)
  • app/locales/fr.ts (1 hunks)
  • app/locales/id.ts (1 hunks)
  • app/locales/it.ts (1 hunks)
  • app/locales/jp.ts (1 hunks)
  • app/locales/ko.ts (1 hunks)
  • app/locales/no.ts (1 hunks)
  • app/locales/pt.ts (1 hunks)
  • app/locales/ru.ts (1 hunks)
  • app/locales/sk.ts (1 hunks)
  • app/locales/tr.ts (1 hunks)
  • app/locales/tw.ts (1 hunks)
  • app/locales/vi.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/locales/jp.ts
Additional comments not posted (18)
app/locales/tw.ts (1)

455-469: Localization for SearchChat added successfully.

The new SearchChat section is well-integrated and follows the existing structure for localization. Ensure that the translations are accurate and contextually appropriate.

app/locales/ko.ts (1)

461-475: Localization for SearchChat added successfully.

The new SearchChat section is well-structured and consistent with the localization approach in the file. Ensure that the translations are accurate.

app/locales/pt.ts (1)

408-422: Localization for SearchChat added successfully.

The SearchChat section is properly integrated and follows the established pattern for localization in the file. Verify the accuracy of the translations.

app/locales/sk.ts (1)

426-440: Localization additions look good.

The new SearchChat section for the Slovak locale is consistent with the existing structure and provides necessary translations for the search feature. Ensure that these translations are accurate and contextually appropriate for the application.

app/locales/ar.ts (1)

462-476: Localization additions look good.

The new SearchChat section for the Arabic locale is consistent with the existing structure and provides necessary translations for the search feature. Ensure that these translations are accurate and contextually appropriate for the application.

app/locales/cs.ts (1)

470-484: Localization additions look good.

The new SearchChat section for the Czech locale is consistent with the existing structure and provides necessary translations for the search feature. Ensure that these translations are accurate and contextually appropriate for the application.

app/locales/vi.ts (1)

469-483: Localization for SearchChat looks accurate and consistent.

The Vietnamese translations for the SearchChat feature are well-integrated and consistent with the rest of the file. Ensure that these strings are correctly used in the UI.

app/locales/id.ts (1)

473-487: Localization for SearchChat looks accurate and consistent.

The Indonesian translations for the SearchChat feature are well-integrated and consistent with the rest of the file. Ensure that these strings are correctly used in the UI.

app/locales/bn.ts (1)

469-483: Localization for SearchChat looks accurate and consistent.

The Bengali translations for the SearchChat feature are well-integrated and consistent with the rest of the file. Ensure that these strings are correctly used in the UI.

app/locales/no.ts (1)

477-491: Localization additions are well-structured.

The new SearchChat section in the Norwegian localization file is comprehensive and consistent with the rest of the file. The keys and values are appropriately named and translated, ensuring a seamless user experience for Norwegian-speaking users.

app/locales/tr.ts (1)

473-487: Localization additions are well-structured.

The new SearchChat section in the Turkish localization file is comprehensive and consistent with the rest of the file. The keys and values are appropriately named and translated, ensuring a seamless user experience for Turkish-speaking users.

app/locales/ru.ts (1)

474-488: Localization additions are well-structured.

The new SearchChat section in the Russian localization file is comprehensive and consistent with the rest of the file. The keys and values are appropriately named and translated, ensuring a seamless user experience for Russian-speaking users.

app/locales/it.ts (1)

484-498: Translations for SearchChat feature look correct.

The Italian translations for the SearchChat feature are well-structured and consistent with the rest of the localization file. Ensure these translations align with the application's context and user interface.

app/locales/es.ts (1)

483-497: Translations for SearchChat feature look correct.

The Spanish translations for the SearchChat feature are well-structured and consistent with the rest of the localization file. Ensure these translations align with the application's context and user interface.

app/locales/fr.ts (1)

483-497: Translations for SearchChat feature look correct.

The French translations for the SearchChat feature are well-structured and consistent with the rest of the localization file. Ensure these translations align with the application's context and user interface.

app/locales/de.ts (3)

485-486: Ensure localization consistency for SearchChat.Name.

The translation for "Search" is accurately localized as "Suche". Ensure consistency with similar entries in other locale files.


487-494: Review SearchChat.Page entries for localization and completeness.

The entries under Page are well-localized. The dynamic function for SubTitle correctly formats the count of results found. Ensure that similar dynamic entries in other locale files follow the same pattern.


496-498: Check SearchChat.Item.View for consistency.

The translation for "View" as "Ansehen" is consistent with other similar entries. Ensure this consistency is maintained across the application.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fd1c656 and 7ce2e8f.

Files selected for processing (1)
  • app/components/search-chat.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/components/search-chat.tsx

};

useEffect(() => {
const intervalId = setInterval(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

旁观,使用定时器来每秒判断值变化会不会不太好?使用useState绑定input的value,添加到deps中,并做防抖?doSearch函数也可以用useCallBack包裹一下? 仅旁观建议,如有说错请忽略🫣

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好建议!我有空更新一下

Copy link
Contributor Author

Choose a reason for hiding this comment

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

旁观,使用定时器来每秒判断值变化会不会不太好?使用useState绑定input的value,添加到deps中,并做防抖?doSearch函数也可以用useCallBack包裹一下? 仅旁观建议,如有说错请忽略🫣

1. 防抖方案

新建分支尝试实现了一下你提到的方案,https://github.com/Movelocity/ChatGPT-Next-Web/tree/test/search-history

使用防抖(debounce)机制时,防抖函数会在每次输入时重置计时器,只有在输入停止并且超过防抖时间后,才会执行搜索操作。
我把防抖时间设为1000毫秒。现在每隔500毫秒输入一个字符,最终只会在输入完成并且没有进一步输入的情况下(即等待时间超过防抖时间)触发一次搜索操作。

举个例子,当用户想搜索 javascript,输入 javas 后就大概率已经能搜索到完整的列表了。而每隔500毫秒输入 j a v a s c r i p t 的情况下,最终只会在输入完成(javascript 整个单词)并且等待超过1000毫秒后,才会执行一次以 javascript 为关键词的搜索

相比之下,使用定时器方案可以频繁地检查输入框的值,并立即触发搜索操作。这样可以显著提高搜索功能的响应速度,用户在快速输入时,不必等到整个单词输入完成再等待一次防抖的延时。

所以我还是打算保留原方案。

2. useCallback

doSearch 函数被 useEffect 依赖了,useCallback 确实需要加上

Copy link
Contributor

Choose a reason for hiding this comment

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

算了,每个人都有自己的想法

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (1)
app/components/search-chat.tsx (1)

88-165: Improve accessibility and consistency in UI rendering.

Ensure that all interactive elements have accessible labels and consider using consistent naming conventions for CSS classes.

- <div className="window-header-submai-title">
+ <div className="window-header-subtitle">

Additionally, ensure that all buttons and inputs have appropriate aria-label attributes for better accessibility.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7ce2e8f and fcd55df.

Files selected for processing (1)
  • app/components/search-chat.tsx (1 hunks)
Additional comments not posted (2)
app/components/search-chat.tsx (2)

1-11: Imports look good.

The imported modules and components are appropriate for the functionality implemented in this file.


30-68: Optimize search logic for performance.

The current search logic iterates over all sessions and messages, which might be inefficient for large datasets. Consider implementing a more efficient search algorithm or indexing strategy.

Comment on lines +70 to +86
useEffect(() => {
const intervalId = setInterval(() => {
if (searchInputRef.current) {
const currentValue = searchInputRef.current.value;
if (currentValue !== previousValueRef.current) {
if (currentValue.length > 0) {
const result = doSearch(currentValue);
setSearchResults(result);
}
previousValueRef.current = currentValue;
}
}
}, 1000);

// Cleanup the interval on component unmount
return () => clearInterval(intervalId);
}, [doSearch]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a debounced input change handler instead of a timer.

Using a timer to check for input changes is inefficient. Consider using a debounced input change handler with useState and useEffect to manage search execution.

import { useDebounce } from 'use-debounce'; // Assuming a debounce hook is available

// Inside the component
const [debouncedSearchText] = useDebounce(searchInputRef.current?.value, 500);

useEffect(() => {
  if (debouncedSearchText) {
    const result = doSearch(debouncedSearchText);
    setSearchResults(result);
  }
}, [debouncedSearchText, doSearch]);

This approach avoids unnecessary checks and improves performance.

Comment on lines +26 to +29
const [searchResults, setSearchResults] = useState<Item[]>([]);

const previousValueRef = useRef<string>("");
const searchInputRef = useRef<HTMLInputElement>(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using useState for tracking input changes.

Using useState instead of useRef for tracking changes in the input value can provide a more React idiomatic approach and simplify the code.

- const previousValueRef = useRef<string>("");
+ const [previousValue, setPreviousValue] = useState<string>("");

Update the logic accordingly to use setPreviousValue.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const [searchResults, setSearchResults] = useState<Item[]>([]);
const previousValueRef = useRef<string>("");
const searchInputRef = useRef<HTMLInputElement>(null);
const [searchResults, setSearchResults] = useState<Item[]>([]);
const [previousValue, setPreviousValue] = useState<string>("");
const searchInputRef = useRef<HTMLInputElement>(null);

@lloydzhou
Copy link
Member

  1. 能不能先临时把入口移到"发现"点击的弹窗里面和“Stable Diffusion”放一起。

只是临时放这个地方,因为这个pr的功能基本都开发完了,想在这个周合并进去

  1. 后面计划整体改一下左边的菜单(可能会使用v3版本中的菜单布局,再把搜索入口放到合适的位置)

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


  1. Can you temporarily move the entrance to the pop-up window clicked on "Discover" and put it together with "Stable Diffusion"?

I only put it here temporarily, because the functions of this PR have basically been developed and I want to merge it in this week.

  1. Later, we plan to change the menu on the left as a whole (we may use the menu layout in the v3 version, and then put the search entry in the appropriate position)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fcd55df and e275abd.

Files selected for processing (1)
  • app/constant.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/constant.ts

@Movelocity
Copy link
Contributor Author

  1. 能不能先临时把入口移到"发现"点击的弹窗里面和“Stable Diffusion”放一起。

只是临时放这个地方,因为这个pr的功能基本都开发完了,想在这个周合并进去

  1. 后面计划整体改一下左边的菜单(可能会使用v3版本中的菜单布局,再把搜索入口放到合适的位置)

已经将入口移到了"Stable Diffusion"所在的 PLUGINS 列表里

image

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


  1. Can you temporarily move the entrance to the pop-up window clicked on "Discover" and put it together with "Stable Diffusion".

I only put it here temporarily, because the functions of this PR have basically been developed and I want to merge it in this week.

  1. We plan to change the menu on the left as a whole later (we may use the menu layout in the v3 version, and then put the search entry in the appropriate position)

The entry has been moved to the PLUGINS list where "Stable Diffusion" is located

image

@lloydzhou lloydzhou merged commit a6b14c7 into ChatGPTNextWeb:main Aug 20, 2024
1 of 2 checks passed
@Leizhenpeng Leizhenpeng added the planned planned feature, will support in the future label Sep 12, 2024
This was referenced Sep 25, 2024
@coderabbitai coderabbitai bot mentioned this pull request Nov 6, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
planned planned feature, will support in the future
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants