Skip to content

fix: model name ui#236

Merged
lollipopkit merged 1 commit intomainfrom
lollipopkit/issue232
Feb 20, 2025
Merged

fix: model name ui#236
lollipopkit merged 1 commit intomainfrom
lollipopkit/issue232

Conversation

@lollipopkit
Copy link
Copy Markdown
Owner

@lollipopkit lollipopkit commented Feb 20, 2025

Fixes #232

Summary by Sourcery

This pull request fixes an issue where the chat title was not being generated correctly after creating a new chat. It also improves UI responsiveness by rebuilding the app widget only when necessary, and by using extension methods to get the window size and isWide state.

Bug Fixes:

  • Fixes an issue where the chat title was not being generated correctly after creating a new chat, by ensuring the database has stored the chat before attempting to generate the title.

Enhancements:

  • Improves UI responsiveness by rebuilding the app widget only when necessary.
  • Improves UI responsiveness by using extension methods to get the window size and isWide state.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Feb 20, 2025

Reviewer's Guide by Sourcery

This pull request addresses issue #232 by improving the way the model name is displayed in the UI. The changes include modifications to how the app is built, how chat titles are generated, and how the app determines the screen width. The app now uses extension methods to determine the screen size.

Sequence diagram for chat title generation

sequenceDiagram
  participant User
  participant _onCreateText
  participant _genChatTitle
  participant Cfg.client
  participant ChatTitleUtil

  User->>_onCreateText: Creates new text
  _onCreateText->>_genChatTitle: Calls _genChatTitle(context, chatId, config)
  alt Stores.setting.genTitle.get() is true
    _genChatTitle->>Cfg.client: createChatCompletion(request)
    Cfg.client-->>_genChatTitle: Response with title
    _genChatTitle->>ChatTitleUtil: prettify(title)
    ChatTitleUtil-->>_genChatTitle: prettifiedTitle
    alt title.isNotEmpty
      _genChatTitle->>_genChatTitle: Update chat history with title
    end
  else Stores.setting.genTitle.get() is false
    _genChatTitle-->>_onCreateText: return null
  end
  _genChatTitle-->>_onCreateText: Completer.future
  _onCreateText->>BakSync.instance: sync()
Loading

Updated class diagram for HomePage

classDiagram
class _HomePageState {
    -ValueNotifier<bool> _isWide
    -ValueNotifier<HomePageEnum> _curPage
    -FocusNode _imeFocus
    +void didChangeDependencies()
}

class BuildContext {
    +Size windowSize
    +bool isDark
    +bool isWide
}

_HomePageState --|> BuildContext : uses
Loading

File-Level Changes

Change Details Files
The app builder was refactored to improve performance.
  • The ListenBuilder widget was removed.
  • The app building logic was extracted into a separate _buildApp method.
  • The _buildApp method is now called by the RNodes.app.listen method.
lib/app.dart
The chat title generation logic was improved to prevent delays in storing the chat.
  • The _genChatTitle method now returns a Completer.
  • The await keyword was added to the titleCompleter?.future call to ensure that the chat title is generated before the chat is stored.
  • The _genChatTitle method is now called before the chat is stored.
lib/view/page/home/req.dart
The app now uses extension methods to determine the screen size.
  • The context.windowSize extension method is now used to get the screen size.
  • The context.isDark extension method is now used to determine if the app is in dark mode.
  • The context.isWide extension method is now used to determine if the screen is wide.
lib/view/page/home/search.dart
lib/view/page/home/appbar.dart
lib/view/page/home/home.dart
The window size variable was removed.
  • The _windowSize variable was removed.
lib/view/page/home/var.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#232 Fix the issue where long model names overflow the UI boundary by automatically omitting or wrapping the text.
#232 Address the bug where swiping up and down to switch chats doesn't work when there are more than three chat records. The PR only addresses the UI issue of the model name being too long. It does not address the issue of swiping to switch chats not working.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@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 @lollipopkit - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider extracting the theme-related code into a separate method for better readability.
  • The _genChatTitle function could benefit from more robust error handling, perhaps with a retry mechanism or more informative error messages.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

@lollipopkit lollipopkit merged commit cdce5c1 into main Feb 20, 2025
1 check passed
@lollipopkit lollipopkit deleted the lollipopkit/issue232 branch February 20, 2025 08:05
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.

bug:上下滑动切换聊天功能勾选不生效 模型名称过长

1 participant