Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Jun 28, 2025

Link issues

fixes #6324

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Enable asynchronous clear callbacks in the Console component by switching OnClear to Func, updating the component logic, markup, unit tests, and sample usage accordingly

Enhancements:

  • Change Console component OnClear parameter from Action to Func for async support
  • Replace ClearConsole method with async OnClearConsole that awaits the OnClear callback
  • Update Console markup to invoke the async OnClearConsole handler on the clear button

Tests:

  • Refactor Console unit tests to use async Task methods and Func for OnClear callbacks

Chores:

  • Update sample Consoles page to implement OnClear as a Task-returning method

@bb-auto bb-auto bot added the enhancement New feature or request label Jun 28, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jun 28, 2025

Reviewer's Guide

This PR enhances the Console component’s Clear API to support asynchronous handlers by switching the OnClear callback from Action to Func, refactors the internal ClearConsole method, updates the Razor markup, and adapts both unit tests and a sample component for async usage.

Sequence diagram for async OnClear invocation in Console component

sequenceDiagram
    participant User as actor User
    participant Console as Console component
    participant App as Application logic (OnClear handler)
    User->>Console: Click Clear button
    Console->>App: await OnClear()
    App-->>Console: Task completed
    Console-->>User: UI updated
Loading

Class diagram for updated Console component async OnClear support

classDiagram
    class Console {
        +Func<Task>? OnClear
        -bool ShowFooter
        +Task OnClearConsole()
    }

    class Consoles {
        -Task OnClear()
    }
Loading

File-Level Changes

Change Details Files
Convert Console.OnClear to an async callback and refactor ClearConsole
  • Change OnClear parameter type from Action? to Func?
  • Rename ClearConsole to OnClearConsole returning Task
  • Await OnClear inside OnClearConsole instead of invoking Action
  • Adjust ShowFooter visibility from protected to private
src/BootstrapBlazor/Components/Console/Console.razor.cs
Update Console Razor markup to call the new async handler
  • Change Button OnClick binding from ClearConsole to OnClearConsole
  • Convert self-closing to explicit closing tag
src/BootstrapBlazor/Components/Console/Console.razor
Adapt unit tests for async OnClear support
  • Change OnClear_OK test method to async Task and await OnClearConsole
  • Replace Action-based OnClear assignments with Func
  • Update test calls from ClearConsole() to await OnClearConsole()
test/UnitTest/Components/ConsoleTest.cs
Update sample component’s OnClear method to async
  • Change sample OnClear signature from void to Task
  • Invoke Messages.Clear inside async method and return Task.CompletedTask
src/BootstrapBlazor.Server/Components/Samples/Consoles.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#6324 Update the OnClear event in the Console component to support asynchronous operations.

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!

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

@bb-auto bb-auto bot added this to the 9.7.0 milestone Jun 28, 2025
@ArgoZhang ArgoZhang requested a review from Copilot June 28, 2025 00:50
@ArgoZhang ArgoZhang merged commit 2abfb68 into main Jun 28, 2025
3 checks passed
@ArgoZhang ArgoZhang deleted the feat-console branch June 28, 2025 00:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables asynchronous clear callbacks in the Console component by converting the OnClear delegate from Action to Func<Task> and updating related logic, markup, tests, and samples.

  • Change OnClear parameter to Func<Task> and introduce OnClearConsole async method
  • Update Razor markup to invoke OnClearConsole on button click
  • Refactor unit tests and sample usage to use async Task delegates

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/UnitTest/Components/ConsoleTest.cs Updated tests to async Task methods and use Func<Task> for OnClear callbacks
src/BootstrapBlazor/Components/Console/Console.razor.cs Switched OnClear to Func<Task>, made ShowFooter private, and implemented OnClearConsole async
src/BootstrapBlazor/Components/Console/Console.razor Updated <Button> markup to call OnClearConsole instead of ClearConsole
src/BootstrapBlazor.Server/Components/Samples/Consoles.razor.cs Changed sample OnClear handler to return Task
Comments suppressed due to low confidence (2)

src/BootstrapBlazor/Components/Console/Console.razor.cs:197

  • [nitpick] Consider renaming OnClearConsole to ClearConsoleAsync (or ClearAsync) to follow common async naming conventions and improve clarity.
    public async Task OnClearConsole()

src/BootstrapBlazor/Components/Console/Console.razor.cs:124

  • [nitpick] Update the XML doc comment above OnClear to note that it is now an async Func<Task> and will be awaited by the component.
    public Func<Task>? OnClear { get; set; }

{
<Button Text="@ClearButtonText" Icon="@ClearButtonIcon" Color="@ClearButtonColor" OnClick="ClearConsole" class="console-clear" />
<Button Text="@ClearButtonText" Icon="@ClearButtonIcon" Color="@ClearButtonColor"
OnClick="OnClearConsole" class="console-clear"></Button>
Copy link

Copilot AI Jun 28, 2025

Choose a reason for hiding this comment

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

[nitpick] For consistency with the rest of the component markup, consider using a self-closing <Button ... /> tag instead of an explicit closing </Button>.

Suggested change
OnClick="OnClearConsole" class="console-clear"></Button>
OnClick="OnClearConsole" class="console-clear" />

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@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 @ArgoZhang - I've reviewed your changes and they look great!


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.

@codecov
Copy link

codecov bot commented Jun 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.98%. Comparing base (a8c8dc7) to head (151dc61).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6325   +/-   ##
=======================================
  Coverage   99.98%   99.98%           
=======================================
  Files         715      715           
  Lines       31516    31519    +3     
  Branches     4447     4447           
=======================================
+ Hits        31512    31515    +3     
  Misses          3        3           
  Partials        1        1           
Flag Coverage Δ
BB 99.98% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(Console): update OnClear support async

2 participants