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(chat): 对话的时候,在工具栏直接显示当前模型的名称 #5516

Closed
wants to merge 2 commits into from

Conversation

frostime
Copy link
Contributor

@frostime frostime commented Sep 24, 2024

💻 变更类型 | Change Type

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

🔀 变更说明 | Description of Change

在 Chat.tsx 组件的对话工具栏的最右侧,添加了一个标注文本,显示当前所使用的模型的名称。

image

📝 补充信息 | Additional Information

由于要放在最后面,所以后续如果要添加更多按钮,需要放在这个元素的上方。这一点在注释中已经说明了。

Summary by CodeRabbit

  • New Features
    • Enhanced chat interface by displaying the current model name in the chat actions area.
  • Style
    • Updated styling for improved layout and visibility of chat actions.

Copy link

vercel bot commented Sep 24, 2024

@frostime 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 Sep 24, 2024

Walkthrough

The changes involve the addition of a new JSX structure within the ChatActions component of the app/components/chat.tsx file. A new div element is introduced to display the currentModelName, enhancing the user interface by providing visibility of the model name in the chat actions area.

Changes

File Change Summary
app/components/chat.tsx Added a new div to the ChatActions component to display currentModelName, styled with flex properties and opacity.

Possibly related PRs

Suggested reviewers

  • lloydzhou

Poem

In the chat where bunnies play,
A model name now brightens the day.
With a flex and a span,
It shows who we am,
Hopping along in a stylish way! 🐰✨


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 72e6cd7 and ba0651d.

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

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>, please review it.
    -- 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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: 0

Outside diff range and nitpick comments (1)
app/components/chat.tsx (1)

783-795: New UI element added to display current model name.

A new div has been added to the end of the ChatActions component to display the current model name. This enhancement improves user awareness of the active model during conversations.

Some observations and suggestions:

  1. The styling is done inline, which might be better moved to a separate CSS file or styled-component for better maintainability.
  2. The opacity of 0.8 for the model name text makes it slightly less prominent, which is a good design choice to not distract from the main content.
  3. The font size of 0.7rem might be too small for some users. Consider making this configurable or slightly larger.
  4. The placement at the end ensures it doesn't interfere with other UI elements, but it might be worth considering if this is the optimal position for user visibility.

Consider extracting the inline styles to a separate CSS class or styled-component for better maintainability. For example:

-      <div
-        style={{
-          display: "flex",
-          alignItems: "top",
-          flex: 1,
-          fontSize: "0.7rem",
-        }}
-      >
-        <div style={{ flex: 1 }}></div>
-        <span style={{ opacity: 0.8 }}>{currentModelName}</span>
-      </div>
+      <div className={styles["model-name-container"]}>
+        <div className={styles["model-name-spacer"]}></div>
+        <span className={styles["model-name"]}>{currentModelName}</span>
+      </div>

Then define these styles in your CSS module:

.model-name-container {
  display: flex;
  align-items: top;
  flex: 1;
  font-size: 0.7rem;
}

.model-name-spacer {
  flex: 1;
}

.model-name {
  opacity: 0.8;
}

This approach would make the styles easier to maintain and modify in the future.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 46fc2a5 and 72e6cd7.

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

Line range hint 1-795: Overall assessment of changes

The changes made to this file are minimal and focused. The addition of the current model name display in the ChatActions component is a valuable feature that enhances user awareness without disrupting the existing functionality.

Key points:

  1. The change is isolated and doesn't affect other parts of the component.
  2. It aligns well with the PR objectives of displaying the current model name in the chat interface.
  3. The implementation is straightforward and doesn't introduce any apparent issues.

While the feature addition is good, there's room for minor improvements in code style and maintainability, as suggested in the previous comment.

@lloydzhou
Copy link
Contributor

需要测一下,移动端的样式

@Issues-translate-bot
Copy link

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


Need to test the style of mobile terminal

Copy link
Contributor

Your build has completed!

Preview deployment

@frostime
Copy link
Contributor Author

frostime commented Sep 24, 2024 via email

Copy link
Member

打开浏览器的那个开发者工具,然后你把它显显示到 H5模式就可以了

@Issues-translate-bot
Copy link

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


Open the developer tools of the browser, and then you can display it in H5 mode.

@frostime
Copy link
Contributor Author

需要测一下,移动端的样式

您好,我又调整了一下样式,感觉目前这个效果应该是可以接受的了。

image

image

image

image

@Issues-translate-bot
Copy link

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


Need to test the mobile style

Hello, I have adjusted the style again, and I feel that the current effect should be acceptable.

image

image

image

image

Copy link
Member

觉得更合适的做法是。嗯,选择了模型,在选择模型的那个按钮自动展开的,而不关闭

@Issues-translate-bot
Copy link

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


I think it's more appropriate. Well, after selecting the model, the button for selecting the model is automatically expanded instead of closed.

@Leizhenpeng
Copy link
Member

image

@frostime
Copy link
Contributor Author

觉得更合适的做法是。嗯,选择了模型,在选择模型的那个按钮自动展开的,而不关闭

觉得更合适的做法是。嗯,选择了模型,在选择模型的那个按钮自动展开的,而不关闭

你指的是这个按钮一直开启,总是显示名称?

image

@Issues-translate-bot
Copy link

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


I think a more appropriate approach is. Well, after selecting the model, the button for selecting the model is automatically expanded instead of closed.

Bag

I think a more appropriate approach is. Well, after selecting the model, the button for selecting the model is automatically expanded instead of closed.

Do you mean that the button is always on and the name is always displayed?

image

Copy link
Member

yes

@frostime
Copy link
Contributor Author

觉得更合适的做法是。嗯,选择了模型,在选择模型的那个按钮自动展开的,而不关闭

觉得更合适的做法是。嗯,选择了模型,在选择模型的那个按钮自动展开的,而不关闭

你指的是这个按钮一直开启,总是显示名称?

image

我发这个 PR 缘由是感觉每次悬浮到按钮上看模型,还要等一个一秒钟(有过渡动画),觉得有点啰嗦。

从功能上将,确实可以直接用悬浮按钮查看来替代,就是要多一步操作,所谓的「心智负担」大一点。

当然这个是个人感受,可能 PR 的内容也更多是处于个人的偏好。看作者们怎么想吧,要是感觉没有必要我撤掉也行。(这个代码其实我很久前就写了,这次发 PR 主要是烦每次改了这部分代码后,自动 sync 就会 failed,需要手动 merge 😂)

@Issues-translate-bot
Copy link

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


I think a more appropriate approach is. Well, after selecting the model, the button for selecting the model is automatically expanded instead of closed.

package

I think a more appropriate approach is. Well, after selecting the model, the button for selecting the model is automatically expanded instead of closed.

You mean that this button is always on and the name is always displayed?

![image](https://private-user-images.githubusercontent.com/27268127/370204244-b8908706-d25c-4f0a-9e7f-efdffc75c869.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiO iJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjcxNjc1OTEsIm5iZiI6MTcyNzE2NzI5MSwicGF0aCI6Ii8yNzI2ODE yNy8zNzAyMDQyNDQtYjg5MDg3MDYtZDI1Yy00ZjBhLTllN2YtZWZkZmZjNzVjODY5LnBuZz9YLU Ftei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWU xTQTUzUFFLNFpBJTJGMjAyNDA5MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTI0VDA4NDEzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJ lPWE4MWU2ZTI3M2Y0OWVjMDFhMmZmNzM2YzgxZmRmMGU0NDFkNGFiZGM5NzRmODZjMjM4NDVlM2YwMjNmNjI2ZTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Oepu4Eo3q6cLOT_YrLp COT2pkU2GqR2bBVmJR0t188g)

The reason why I posted this PR is that every time I hover over the button to look at the model, I have to wait for one second (there is a transition animation), which is a bit verbose.

In terms of function, it can indeed be replaced by directly using the floating button to view, but it requires one more step of operation and the so-called "mental burden" is greater.

Of course, this is a personal feeling, and the content of PR may be more of a personal preference. It depends on what the authors think, if I feel it is unnecessary I can remove it. (I actually wrote this code a long time ago. The main reason for issuing PR this time is that every time I change this part of the code, the automatic sync will fail and manual merge is required 😂)

@frostime
Copy link
Contributor Author

yes

yes

这个看 @lloydzhou 怎么决策吧。如果他倾向于你说的那个方案,那我这个 PR withdraw 掉也行。🤞

@Issues-translate-bot
Copy link

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


yes

yes

It depends on how @lloydzhou decides. If he prefers the plan you mentioned, then I can withdraw the PR. 🤞

@lloydzhou
Copy link
Contributor

  1. 看起来在移动端 h5上面,位置有点挤了

这个工具栏,有可能还会增加图标...
另外dall-e-3模型也会有几个额外的图标

  1. 另外,这个信息与模型图标展开后的信息重复了

基于以上两点,暂时不合并这个pr了,最后还是非常感谢 @frostime 的pr

@Issues-translate-bot
Copy link

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


  1. It seems that the location is a bit crowded on the mobile h5.

This toolbar may also add icons...
In addition, the dall-e-3 model will also have several additional icons

  1. In addition, this information is duplicated with the information after the model icon is expanded.

Based on the above two points, I will not merge this PR for the time being. Finally, I am very grateful to @frostime for the PR.

@frostime
Copy link
Contributor Author

  1. 看起来在移动端 h5上面,位置有点挤了

这个工具栏,有可能还会增加图标...
另外dall-e-3模型也会有几个额外的图标

  1. 另外,这个信息与模型图标展开后的信息重复了

基于以上两点,暂时不合并这个pr了,最后还是非常感谢 @frostime 的pr

fine, I'll close it.

@frostime frostime closed this Sep 24, 2024
@Issues-translate-bot
Copy link

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


  1. It seems that the position is a bit crowded on the mobile h5.

This toolbar may also add icons...
In addition, the dall-e-3 model will also have several additional icons

  1. In addition, this information is duplicated with the information after the model icon is expanded.

Based on the above two points, I will not merge this PR for the time being. Finally, I am very grateful to @frostime for the PR.

fine, I'll close it.

@QAbot-zh
Copy link

觉得更合适的做法是。嗯,选择了模型,在选择模型的那个按钮自动展开的,而不关闭

我有个自用版本就是在 PC 端默认展开不关闭的,省得提问完发现不是自己想要问的模型

@Issues-translate-bot
Copy link

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


I think a more appropriate approach is. Well, after selecting the model, the button for selecting the model is automatically expanded instead of closed.

I have a version for my own use that is expanded and not closed by default on the PC side, so as not to find out after asking questions that it is not the model I wanted to ask about.

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.

5 participants