Skip to content

fix: raw md page has no titlebar on macOS#238

Merged
lollipopkit merged 2 commits intomainfrom
lollipopkit/issue237
Feb 20, 2025
Merged

fix: raw md page has no titlebar on macOS#238
lollipopkit merged 2 commits intomainfrom
lollipopkit/issue237

Conversation

@lollipopkit
Copy link
Copy Markdown
Owner

@lollipopkit lollipopkit commented Feb 20, 2025

Fixes #237

Summary by Sourcery

This pull request fixes a bug where the raw markdown page was missing a title bar on macOS. It also improves the performance of the history page by using a simple Text widget instead of a ListenBuilder with an RNode for displaying the title, and by using a single RNode instance for history updates instead of multiple instances.

Bug Fixes:

  • Fixes an issue where the raw markdown page was missing a title bar on macOS.

Enhancements:

  • The history list items now use a simple Text widget instead of a ListenBuilder with an RNode for displaying the title, improving performance.
  • The app now uses a single RNode instance for history updates instead of multiple instances, reducing memory usage and improving performance.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Feb 20, 2025

Reviewer's Guide by Sourcery

This pull request addresses issue #237 by refactoring the MarkdownCopyPage to use a CustomAppBar and improving the structure of the Scaffold widget. It also simplifies the HistoryPage by removing the need for individual RNode instances for each history item, instead using a single RNode to manage updates. Additionally, the key parameter was removed from the AutoHide widget in _ChatPageState.

Sequence diagram for renaming a chat

sequenceDiagram
    participant User
    participant _ChatPageState
    participant ChatHistoryItem
    participant _historyRN
    participant Storage

    User->>_ChatPageState: Taps 'Rename Chat'
    activate _ChatPageState
    _ChatPageState->>_ChatPageState: Shows dialog to enter new title
    User->>_ChatPageState: Enters new title
    _ChatPageState->>ChatHistoryItem: copyWith(name: title)
    activate ChatHistoryItem
    ChatHistoryItem-->>_ChatPageState: Returns new ChatHistoryItem
    deactivate ChatHistoryItem
    _ChatPageState->>ChatHistoryItem: save()
    activate ChatHistoryItem
    ChatHistoryItem-->>_ChatPageState: void
    deactivate ChatHistoryItem
    _ChatPageState->>_historyRN: notify()
    activate _historyRN
    _historyRN-->>_ChatPageState: void
    deactivate _historyRN
    _ChatPageState->>Storage: _storeChat(chatId)
    activate Storage
    Storage-->>_ChatPageState: void
    deactivate Storage
    deactivate _ChatPageState
Loading

Sequence diagram for deleting a chat item

sequenceDiagram
    participant User
    participant _ChatPageState
    participant chatItems
    participant _historyRN
    participant Storage

    User->>_ChatPageState: Taps 'Delete Chat'
    activate _ChatPageState
    _ChatPageState->>_ChatPageState: Shows confirmation dialog
    User->>_ChatPageState: Confirms deletion
    _ChatPageState->>chatItems: remove(chatItem)
    activate chatItems
    chatItems-->>_ChatPageState: void
    deactivate chatItems
    _ChatPageState->>Storage: _storeChat(chatId)
    activate Storage
    Storage-->>_ChatPageState: void
    deactivate Storage
    _ChatPageState->>_historyRN: notify()
    activate _historyRN
    _historyRN-->>_ChatPageState: void
    deactivate _historyRN
    _ChatPageState->>_ChatPageState: _chatRN.notify()
    deactivate _ChatPageState
Loading

Sequence diagram for generating chat title

sequenceDiagram
    participant _Req
    participant Completer
    participant Loggers
    participant ChatHistoryItem
    participant _historyRN
    participant _appbarTitleVN

    _Req->>Completer: Completer()
    activate Completer
    Completer-->>_Req: completer
    deactivate Completer
    _Req->>Loggers: Loggers.app.warning('Gen title: $e')
    activate Loggers
    Loggers-->>_Req: void
    deactivate Loggers
    _Req->>_historyRN: _historyRN.notify()
    activate _historyRN
    _historyRN-->>_Req: void
    deactivate _historyRN
    _Req->>Completer: completer.complete()
    activate Completer
    Completer-->>_Req: void
    deactivate Completer
    _Req->>ChatHistoryItem: copyWith(name: title)
    activate ChatHistoryItem
    ChatHistoryItem-->>_Req: ne
    deactivate ChatHistoryItem
    _Req->>ChatHistoryItem: ne.save()
    activate ChatHistoryItem
    ChatHistoryItem-->>_Req: void
    deactivate ChatHistoryItem
    _Req->>_historyRN: _historyRN.notify()
    activate _historyRN
    _historyRN-->>_Req: void
    deactivate _historyRN
    _Req->>_appbarTitleVN: _appbarTitleVN.value = title
    activate _appbarTitleVN
    _appbarTitleVN-->>_Req: void
    deactivate _appbarTitleVN
Loading

Updated class diagram for MarkdownCopyPage

classDiagram
    class _MarkdownCopyPage {
        build(BuildContext context) Widget
    }
    class Scaffold {
        appBar: CustomAppBar
        body: FutureWidget
    }
    class CustomAppBar {
        title: Text
        centerTitle: bool
    }
    class FutureWidget {
        future: Future<String>
        error: (e, s) => SimpleMarkdown
        success: _buildBody
    }
    class SimpleMarkdown {
        data: String
    }

    _MarkdownCopyPage -- Scaffold : contains
    Scaffold -- CustomAppBar : has
    Scaffold -- FutureWidget : has
    FutureWidget -- SimpleMarkdown : on error
Loading

Updated class diagram for HistoryPage

classDiagram
    class _HistoryPageState {
        _buildHistoryListItem(String chatId) Widget
    }
    class ListTile {
        title: Text
        subtitle: ListenBuilder
    }
    class Text {
        String data
        TextOverflow overflow
        TextStyle style
    }
    class ListenBuilder {
        listenable: _timeRN
        builder: (BuildContext context, Widget child) => Widget
    }

    _HistoryPageState -- ListTile : contains
    ListTile -- Text : has title
    ListTile -- ListenBuilder : has subtitle
Loading

File-Level Changes

Change Details Files
Refactors the MarkdownCopyPage to use CustomAppBar and improve the structure of the Scaffold widget.
  • Replaces the standard AppBar with CustomAppBar.
  • Moves the FutureWidget inside the Scaffold body to ensure the CustomAppBar is always visible.
  • Removes the loading state from the MarkdownCopyPage.
lib/view/page/home/md_copy.dart
Removes the RNode from the HistoryPage and simplifies the ListTile widget.
  • Removes the RNode instantiation and usage for history items.
  • Removes the ListenBuilder widget from the ListTile title.
  • The title now directly uses the Text widget to display the history item's name.
lib/view/page/home/history.dart
Removes the need to notify individual history items and instead notifies a single RNode for all history items.
  • Removes the _historyRNMap.
  • Introduces a single _historyRN to manage history updates.
  • Updates the _onTapDelChatItem, _onTapRenameChat, _genChatTitle methods to notify the single _historyRN instead of individual RNode instances.
  • Removes the key parameter from the AutoHide widget in _ChatPageState.
lib/view/page/home/ctrl.dart
lib/view/page/home/req.dart
lib/view/page/home/var.dart
lib/view/page/home/chat.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#237 Ensure the raw markdown page displays a titlebar on macOS.

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:

  • It looks like you're removing _historyRNMap and replacing it with a single _historyRN - does this mean only one history item can be updated at a time?
  • Consider extracting the title update logic into a separate function to improve readability.
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 e16acc9 into main Feb 20, 2025
1 check passed
@lollipopkit lollipopkit deleted the lollipopkit/issue237 branch February 20, 2025 08:26
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: raw md page has no titlebar on macOS

1 participant