Skip to content

更新微软账户登录对话框#5531

Open
Glavo wants to merge 32 commits intoHMCL-dev:mainfrom
Glavo:microsoft-login
Open

更新微软账户登录对话框#5531
Glavo wants to merge 32 commits intoHMCL-dev:mainfrom
Glavo:microsoft-login

Conversation

@Glavo
Copy link
Member

@Glavo Glavo commented Feb 13, 2026

No description provided.

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 pull request updates the Microsoft account login dialog to improve the user experience by adding QR code login support and refactoring the authentication flow with a cleaner state-based architecture.

Changes:

  • Added QR code generation capability using the nayuki QR code library for device-based authentication
  • Refactored login flow using a sealed interface pattern with distinct states (Init, StartAuthorizationCodeLogin, WaitForOpenBrowser, StartDeviceCodeLogin, WaitForScanQrCode, LoginFailed)
  • Simplified UI layout by consolidating authentication methods into a single streamlined interface with dynamic state transitions

Reviewed changes

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

Show a summary per file
File Description
gradle/libs.versions.toml Added nayuki QR code generator library dependency (version 1.8.0)
HMCL/build.gradle.kts Imported nayuki-qrcodegen library for QR code generation
HMCLCore/src/main/java/org/jackhuang/hmcl/util/StringUtils.java Added XML attribute escaping utility function
HMCL/src/main/java/org/jackhuang/hmcl/util/QrCodeUtils.java New utility class for converting QR codes to SVG path format
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/JFXHyperlink.java Added constructor accepting text and external link
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/HintPane.java Added overload for setSegment with custom hyperlink action
HMCL/src/main/java/org/jackhuang/hmcl/ui/account/MicrosoftAccountLoginPane.java Major refactor with state-based architecture and QR code support
HMCL/src/main/java/org/jackhuang/hmcl/ui/account/CreateAccountPane.java Updated to use simplified MicrosoftAccountLoginPane
HMCL/src/main/resources/assets/lang/*.properties Updated localization strings for new login flow
HMCL/src/main/resources/assets/css/root.css Updated CSS for new dialog layout and code box styling

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

@3gf8jv4dv

This comment was marked as resolved.

@3gf8jv4dv

This comment was marked as resolved.

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

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


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

deviceHint.setSegment(i18n("account.methods.microsoft.methods.device.hint",
StringUtils.escapeXmlAttribute(wait.verificationUri()),
wait.verificationUri(),
wait.userCode()
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The userCode parameter is not being escaped before being passed to the i18n function, which then formats it into an HTML string. If the userCode contains special XML/HTML characters like "&", "<", ">", etc., they will not be properly escaped and could break the HTML rendering or potentially cause security issues. Consider escaping the userCode parameter similar to how verificationUri is escaped.

Suggested change
wait.userCode()
StringUtils.escapeXmlAttribute(wait.userCode())

Copilot uses AI. Check for mistakes.

rootContainer.getChildren().addAll(deviceHint, new Group(qrCode), codeBox);
} else if (currentStep instanceof Step.LoginFailed failed) {
loginButtonSpinner.setLoading(true);
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

In the LoginFailed state, the spinner is set to loading (true) when it should likely be set to not loading (false). When a login has failed, the user should be able to retry or cancel, so the login button should not be in a loading state. This is inconsistent with other error handling patterns where the spinner is stopped after an error occurs.

Suggested change
loginButtonSpinner.setLoading(true);
loginButtonSpinner.setLoading(false);

Copilot uses AI. Check for mistakes.
Comment on lines +202 to +208
} else if (currentStep instanceof Step.LoginFailed failed) {
loginButtonSpinner.setLoading(true);

HintPane errHintPane = new HintPane(MessageDialogPane.MessageType.ERROR);
errHintPane.setText(failed.message());
rootContainer.getChildren().add(errHintPane);
}
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

When the login process fails, users may want to retry the login. However, there is no button action set for btnLogin in the LoginFailed state, which means clicking the login button won't trigger any retry logic. Consider adding a retry mechanism by setting btnLogin.setOnAction to restart the login flow (e.g., transitioning back to Step.Init or Step.StartAuthorizationCodeLogin).

Copilot uses AI. Check for mistakes.
******************************************************************************/

.microsoft-login-dialog:bodyonly {
-fx-padding: 0px 0px 0px 0px;
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The CSS padding value "0px 0px 0px 0px" is unnecessarily verbose. It can be simplified to just "0" or "0px" which is more concise and follows common CSS best practices. All four values being the same can be represented with a single value.

Suggested change
-fx-padding: 0px 0px 0px 0px;
-fx-padding: 0;

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants