Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Dec 31, 2025

Link issues

fixes #7452

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

Integrate a new browser detection module and update client and table components to use its async API and revised device naming.

New Features:

  • Add bundled browser-tool module to detect browsers and devices, including Huawei browser support.

Enhancements:

  • Update client-side detection to use the new browser module API and expose more precise browser and system information.
  • Adjust table header handling to use async browser info and align device naming with the new detection library by renaming the PC device type to Desktop.

Copilot AI review requested due to automatic review settings December 31, 2025 04:19
@bb-auto bb-auto bot added the enhancement New feature or request label Dec 31, 2025
@bb-auto bb-auto bot added this to the v10.1.0 milestone Dec 31, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 31, 2025

Reviewer's Guide

Switches browser/client detection to a new async, modular browser-tool implementation (including Huawei browser support) and aligns device naming from PC to Desktop across JS and .NET so table header fixing and client info work consistently on more browsers.

Sequence diagram for the new browser-tool based getClientInfo flow

sequenceDiagram
    actor BrowserUser
    participant ClientModule
    participant BrowserTool
    participant AjaxServer

    BrowserUser->>ClientModule: getClientInfo(url)
    ClientModule->>BrowserTool: getInfo([browser, system, device, language])
    BrowserTool-->>ClientModule: browserInfo (browser, browserVersion, device, language, engine)
    ClientModule->>ClientModule: build data (browser string, device, language, engine)
    ClientModule->>AjaxServer: execute(url, invoke, method, data)
    AjaxServer-->>ClientModule: response
    ClientModule-->>BrowserUser: resolved client info request
Loading

Sequence diagram for async table reset and header fixing using browser-tool

sequenceDiagram
    actor User
    participant TableComponent
    participant TableJsModule as TableJs
    participant BrowserTool

    User->>TableComponent: trigger reset
    TableComponent->>TableJsModule: reset(id)
    TableJsModule->>TableJsModule: restore column order and DOM
    TableJsModule->>TableJsModule: set scrollWidth
    TableJsModule->>TableJsModule: await fixHeader(table)
    TableJsModule->>BrowserTool: getInfo([device])
    BrowserTool-->>TableJsModule: device info (device)
    TableJsModule->>TableJsModule: if device != Desktop adjust right margin
    TableJsModule-->>TableComponent: reset completed
Loading

Updated class diagram for browser/client detection and table modules

classDiagram
    class BrowserTool {
        +parse(userAgent)
        +getInfo(scopes)
        +getFingerprint(scopes)
        +isSupport(feature, value)
    }

    class ClientModule {
        +ping(url, invoke, method)
        +getClientInfo(url)
    }

    class TableModule {
        +saveColumnOrder(options)
        +reset(id)
        +fixHeader(table)
    }

    class WebClientDeviceType {
        <<enum>>
        Desktop
        Mobile
        Tablet
    }

    ClientModule --> BrowserTool : uses getInfo
    TableModule --> BrowserTool : uses getInfo
    WebClientDeviceType ..> ClientModule : aligned device naming
    WebClientDeviceType ..> TableModule : aligned device naming
Loading

File-Level Changes

Change Details Files
Make table header reset logic compatible with async browser detection and updated device type naming.
  • Change table reset function to be async to await header fixing before wiring scroll handlers.
  • Update fixHeader to be async and to call the new browser.getInfo API instead of a synchronous browser() helper.
  • Adjust device comparison in header margin logic from 'PC' to 'Desktop' to match the new device classification.
src/BootstrapBlazor/Components/Table/Table.razor.js
Replace the existing browser.js helper with the bundled browser-tool library and update client info collection to use its async API and new field names.
  • Import the new browser.min.mjs module as the browser helper instead of the previous browser.js.
  • Use browser.getInfo with an explicit list of sections to obtain browser, system, device, and language info asynchronously.
  • Update how browser name/version are composed, switching from 'version' to 'browserVersion' returned by the new library.
src/BootstrapBlazor/wwwroot/modules/client.js
Align server-side device enum with new client-side device naming and vendor library expectations.
  • Rename WebClientDeviceType enum member from PC to Desktop to reflect the new device type string used by browser-tool.
  • Normalize file header BOM and comment so the license header remains valid after the edit.
src/BootstrapBlazor/Enums/WebClientDeviceType.cs
Introduce minified third-party browser-tool implementation to enhance browser, system, device, and environment detection, including Huawei browser support.
  • Add browser.min.mjs containing the minified browser-tool v1.3.3 library with extensive user-agent parsing (including Huawei and other OEM browsers), system detection, and fingerprint helpers.
  • Remove the legacy browser.js implementation that previously provided synchronous browser() detection.
src/BootstrapBlazor/wwwroot/modules/browser.min.mjs
src/BootstrapBlazor/wwwroot/modules/browser.js

Assessment against linked issues

Issue Objective Addressed Explanation
#7452 Add Huawei browser detection/support to the client-side browser detection logic so that Huawei browser is correctly identified and handled in the application.

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

@ArgoZhang ArgoZhang merged commit 30f3eb5 into main Dec 31, 2025
5 of 6 checks passed
@ArgoZhang ArgoZhang deleted the feat-browser branch December 31, 2025 04:20
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 - I've left some high level feedback:

  • Renaming the C# enum member from PC to Desktop is a breaking change for any existing consumers (including persisted string values); consider adding a new Desktop member and mapping from the old value instead of renaming in place.
  • The reset and fixHeader functions are now async, but callers of reset in other modules may still treat it as synchronous; verify call sites and, if needed, return a resolved promise or introduce a new async API to avoid subtle timing regressions.
  • The large third-party browser.min.mjs bundle is checked in as a single minified file, which is hard to review and maintain; consider adding the unminified source (or using a package manager build step) and keeping the minified output generated instead of hand-committed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Renaming the C# enum member from `PC` to `Desktop` is a breaking change for any existing consumers (including persisted string values); consider adding a new `Desktop` member and mapping from the old value instead of renaming in place.
- The `reset` and `fixHeader` functions are now `async`, but callers of `reset` in other modules may still treat it as synchronous; verify call sites and, if needed, return a resolved promise or introduce a new async API to avoid subtle timing regressions.
- The large third-party `browser.min.mjs` bundle is checked in as a single minified file, which is hard to review and maintain; consider adding the unminified source (or using a package manager build step) and keeping the minified output generated instead of hand-committed.

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 Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (36a30dd) to head (937e303).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7453   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          749       749           
  Lines        32919     32919           
  Branches      4574      4574           
=========================================
  Hits         32919     32919           
Flag Coverage Δ
BB 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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 upgrades the browser detection functionality by replacing a custom browser.js implementation with the browser-tool v1.3.3 library to add support for Huawei browser detection and improve overall browser identification capabilities.

Key Changes

  • Replaced custom browser detection with the browser-tool v1.3.3 library (browser.min.mjs)
  • Updated API from synchronous browser() to asynchronous browser.getInfo()
  • Changed device type from 'PC' to 'Desktop' for consistency with modern terminology
  • Made corresponding async updates to Table.razor.js to accommodate the new API

Reviewed changes

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

Show a summary per file
File Description
src/BootstrapBlazor/wwwroot/modules/browser.min.mjs New minified browser detection library (browser-tool v1.3.3)
src/BootstrapBlazor/wwwroot/modules/browser.js Removed old custom browser detection implementation
src/BootstrapBlazor/wwwroot/modules/client.js Updated to use new async browser.getInfo() API with proper parameters
src/BootstrapBlazor/Enums/WebClientDeviceType.cs Renamed enum value from PC to Desktop (breaking change)
src/BootstrapBlazor/Components/Table/Table.razor.js Made fixHeader function async and updated device type check from 'PC' to 'Desktop'
src/BootstrapBlazor/BootstrapBlazor.csproj Version bump from 10.2.1-beta01 to 10.2.1-beta02

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


export async function getClientInfo(url) {
const info = browser()
const info = await browser.getInfo(['browser', 'system', 'device', 'language']);
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The API call has changed from synchronous to asynchronous. The old implementation called browser() synchronously, but the new implementation uses await browser.getInfo(['browser', 'system', 'device', 'language']). However, the function getClientInfo is already marked as async, so this change is compatible. Ensure that all callers of getClientInfo are handling the Promise correctly.

Copilot uses AI. Check for mistakes.
///
/// </summary>
PC,
Desktop,
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The enum value has been renamed from PC to Desktop. This is a breaking change that could affect existing code that references WebClientDeviceType.PC. While the new name Desktop is more descriptive and aligns with modern terminology, this change should be clearly documented as a breaking change in the release notes, and consumers of this API will need to update their code.

Copilot uses AI. Check for mistakes.
const b = window.browser()
if (b.device !== 'PC') {
const b = await browser.getInfo();
if (b.device !== 'Desktop') {
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The device type comparison has been changed from 'PC' to 'Desktop' to match the new browser detection library's return value. However, this hardcoded string should ideally match the enum value in WebClientDeviceType.cs. Since the C# enum now uses Desktop instead of PC, this change maintains consistency. Consider using a constant or enum value instead of a magic string to prevent future inconsistencies.

Copilot uses AI. Check for mistakes.
margin = margin.replace('px', '')
const b = window.browser()
if (b.device !== 'PC') {
const b = await browser.getInfo();
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The call to browser.getInfo() is made without parameters, but in client.js the same method is called with parameters: browser.getInfo(['browser', 'system', 'device', 'language']). According to the browser-tool library API, both usages are valid - calling without parameters will fetch all available information. However, for consistency and performance, consider specifying only the needed properties. In this case, only the 'device' property is needed, so the call could be optimized to browser.getInfo(['device']).

Suggested change
const b = await browser.getInfo();
const b = await browser.getInfo(['device']);

Copilot uses AI. Check for mistakes.
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(browser): support Huawei browser

2 participants