Skip to content

Conversation

@ysmoradi
Copy link
Member

@ysmoradi ysmoradi commented Nov 16, 2025

closes #11644

Summary by CodeRabbit

  • Bug Fixes

    • Fixed SignalR connection state validation for more reliable connection initialization.
    • Improved asynchronous connection startup handling.
  • Performance

    • Optimized async operations in Blazor Hybrid environments for enhanced performance.

@ysmoradi ysmoradi requested a review from Copilot November 16, 2025 05:50
@coderabbitai
Copy link

coderabbitai bot commented Nov 16, 2025

Walkthrough

Two components are optimized for Blazor Hybrid responsiveness: SignalR connection state logic is corrected in AppClientCoordinator with proper parenthesization and Task.Run wrapping, and NoOpPrerenderStateService is refactored to add async support with conditional Task.Run execution for platform-specific optimization.

Changes

Cohort / File(s) Summary
SignalR Connection Handling
src/Templates/Boilerplate/.../Components/AppClientCoordinator.cs
Fixed SignalR state check logic by correcting operator precedence: grouping connected/connecting states under collective negation instead of disjointed. Wrapped StartAsync invocation in Task.Run wrapper.
Prerender State Service Async Refactoring
src/Templates/Boilerplate/.../Services/NoOpPrerenderStateService.cs
Reorganized GetValue overloads to support async execution with key parameter. Added Blazor Hybrid-specific optimization: executes factory via Task.Run when AppPlatform.IsBlazorHybrid is true, otherwise awaits directly. Second overload now delegates to first with empty string key.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • AppClientCoordinator: Logic fix is straightforward (parenthesization and Task.Run wrapper)
  • NoOpPrerenderStateService: Public API signature changes require verification that callers are compatible; conditional platform-specific execution logic should be validated

Poem

🐰 A hop through the hybrid land so fine,
Where signals connect in perfect time,
Tasks run swift, no responsiveness to pine,
Blazor's responsiveness now starts to shine! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main changes: improving responsiveness in Blazor Hybrid by optimizing SignalR connection handling and prerender state service execution.
Linked Issues check ✅ Passed The PR implements responsiveness improvements through SignalR async optimization (#11644) and task-based factory execution for Blazor Hybrid, directly addressing the linked issue's objective.
Out of Scope Changes check ✅ Passed All changes are focused on responsiveness improvements in Blazor Hybrid through SignalR and prerender state optimizations, with no unrelated modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ysmoradi ysmoradi marked this pull request as draft November 16, 2025 05:52
Copilot finished reviewing on behalf of ysmoradi November 16, 2025 05:52
Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between c0a0d0a and 23b7c67.

📒 Files selected for processing (2)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/AppClientCoordinator.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/NoOpPrerenderStateService.cs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: build api + blazor web
  • GitHub Check: build blazor hybrid (iOS-macOS)
  • GitHub Check: build blazor wasm standalone
  • GitHub Check: build blazor hybrid (android)
  • GitHub Check: build blazor hybrid (windows)
  • GitHub Check: CodeQL analysis (csharp)
  • GitHub Check: Agent
  • GitHub Check: build and test
🔇 Additional comments (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/AppClientCoordinator.cs (1)

288-288: Good catch on the operator precedence bug!

The parenthesization fix correctly changes the logic from (is not Connected) or Connecting to is not (Connected or Connecting). The original code would incorrectly enter the if-block whenever the state was Connecting, which is not the intended behavior.

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/NoOpPrerenderStateService.cs (1)

19-25: No action required.

The concern has been verified as addressed by design. The NoOpPrerenderStateService is explicitly documented as a no-op implementation for non-prerendering scenarios (Blazor Hybrid), where state persistence is unnecessary. The interface contract ensures that:

  • When consuming code calls GetValue with caller attributes (the recommended pattern), the key is derived from caller information and passed to the no-op, which safely ignores it since no persistence occurs
  • When real prerendering implementations (WebClientPrerenderStateService, WebServerPrerenderStateService) are used, the key is used meaningfully for state retrieval and persistence
  • The empty string parameter behavior is correct: no-op implementations don't need meaningful keys because they don't persist state

The design is sound and well-documented in the interface comments.

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 aims to improve the overall responsiveness of the bit Boilerplate application in Blazor Hybrid scenarios by offloading potentially blocking operations to thread pool threads using Task.Run.

Key Changes

  • Modified NoOpPrerenderStateService.GetValue to use Task.Run for factory execution in Blazor Hybrid scenarios
  • Updated SignalR connection initialization in AppClientCoordinator to use Task.Run for improved responsiveness
  • Fixed pattern matching syntax for HubConnectionState checks (improved readability)

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
NoOpPrerenderStateService.cs Added conditional Task.Run execution for Blazor Hybrid to offload async factory work to thread pool; refactored method order for consistency
AppClientCoordinator.cs Updated pattern matching syntax for state checks; wrapped SignalR StartAsync in Task.Run for improved responsiveness

@ysmoradi ysmoradi closed this Nov 17, 2025
@ysmoradi ysmoradi deleted the 11644 branch November 17, 2025 12:22
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.

bit Boilerplate overall responsiveness can be improved in Blazor Hybrid

1 participant