Skip to content

fix: add Enter key support to login and exclude Windows from Unix tests - #1409

Open
ankitsharma101 wants to merge 2 commits into
apache:developfrom
ankitsharma101:fix/issue-1405-ux-and-windows-fixes
Open

ankitsharma101 wants to merge 2 commits into
apache:developfrom
ankitsharma101:fix/issue-1405-ux-and-windows-fixes

Conversation

@ankitsharma101

Copy link
Copy Markdown

What This Fixes

Closes #1405

I ran into a couple of issues while trying to build Dubbo Admin on Windows 11:

  1. The login form doesn't submit when you press Enter (you have to click the button)
  2. The build fails on Windows because limits_test.go tries to import Unix-specific packages

This PR fixes both issues.

Changes Made

Login Form Improvements

The login form now works like you'd expect - press Enter and it submits. I also made it so the username field gets focus automatically when the page loads, which feels more natural.

What I changed:

  • Added @pressEnter handlers to both input fields (using Ant Design Vue's built-in event)
  • Used Vue 3's ref and onMounted to auto-focus the username field on page load
  • The button click still works exactly the same way as before

Windows Build Fix

The test file pkg/common/util/os/limits_test.go was causing build failures on Windows because it imports golang.org/x/sys/unix, which obviously doesn't exist on Windows.

What I changed:

  • Added Go build tags at the top of the file to exclude it from Windows builds
  • This matches the pattern already used in limits.go in the same directory

The build tags look like this:

//go:build !windows
// +build !windows

Testing

I tested everything on my Windows 11 machine with Go 1.24.6.

Login form:

  • Auto-focus works - cursor is already in the username field when you load the page
  • Pressing Enter in either field submits the form (I verified this in the browser's Network tab - it makes the API call to /api/v1/auth/login)
  • Clicking the button still works
  • No errors in the console

Windows build:
Before my changes, running go build would fail with an error about the Unix package not being available. After adding the build tags, it builds successfully and creates the dubbo-admin.exe file (~97MB).

Notes

I'm working on GSoC 2026 prep and trying to get Dubbo Admin running on Windows. These are real issues I hit while following the build instructions, so hopefully this helps other Windows developers too.

My Apache ICLA was confirmed on Feb 5, 2026.

Let me know if you'd like me to adjust anything!

Part 1: Login UX Enhancement
- Add form submission on Enter key press
- Auto-focus username field on page load
- Add @pressEnter handlers to both input fields
- Import ref and onMounted from Vue composition API

Part 2: Windows Build Fix
- Add build tags to limits_test.go to exclude from Windows builds
- Fixes golang.org/x/sys/unix import error on Windows
- Aligns with existing limits.go build constraints

Tested on Windows 11:
- Go 1.24.6: Build succeeds without errors
- Chrome/Edge: Enter key and auto-focus work correctly

Fixes apache#1405
@ankitsharma101

Copy link
Copy Markdown
Author

Hi! I see the CI failed, but it looks like a file system error on the testing side. My changes only added Enter key support to the login form and build tags for Windows. These errors seem unrelated to my code.

The build worked fine on my Windows machine. Should I do anything, or can you re-run the tests?

Thanks!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Improves cross-platform developer experience and login UX by enabling Enter-to-submit behavior on the Vue 3 login screen and preventing Unix-only limit tests from running on Windows.

Changes:

  • Add template @pressEnter handlers so pressing Enter in username/password inputs triggers login.
  • Auto-focus the username input on mount for a smoother login flow.
  • Add //go:build !windows build tags to exclude limits_test.go from Windows builds (matching limits.go).

Reviewed changes

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

File Description
ui-vue3/src/Login.vue Adds Enter key submission and autofocus for the username field.
pkg/common/util/os/limits_test.go Adds !windows build constraints to avoid importing x/sys/unix on Windows.

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

@robocanic

Copy link
Copy Markdown
Contributor

The ci fails because the license header should be placed at the very beginning of the file, as well as pkg/common/util/os/limits_test.go.

@ankitsharma101

Copy link
Copy Markdown
Author

Thanks for the review! I've moved the build tags to after the license header as requested. The file now has the correct order.
Pushed the fix in commit . CI should pass now!

@robocanic

Copy link
Copy Markdown
Contributor

@ikun-Lg reviewer

@ankitsharma101

Copy link
Copy Markdown
Author

I noticed that limits.go in the same directory also has build tags before the license header (lines 1-3). Should I fix that file too for consistency, even though I didn't modify it in this PR?

Let me know and I'll update accordingly!

@robocanic

Copy link
Copy Markdown
Contributor

I rerun the ci step make fmt && git status && [[ -z git status -s ]] on my local mac, it seems that the build tag must put in the front of the file.
PixPin_2026-02-12_15-21-29

@robocanic

robocanic commented Feb 12, 2026 •

Copy link
Copy Markdown
Contributor

Can you rollback to the this commit? I will rerun the ci and let's investigate the specific reasons why it failed.
PixPin_2026-02-12_15-25-37

@ankitsharma101
ankitsharma101 force-pushed the fix/issue-1405-ux-and-windows-fixes branch from 125d6c3 to 15a05fa Compare February 12, 2026 19:47
@ankitsharma101

Copy link
Copy Markdown
Author

Thanks for the suggestion — I’ve rolled back the branch to commit 15a05fa and force-pushed the changes.

Please go ahead and re-run the CI. I’m happy to help investigate further if any issues still persist or if you’d like me to test additional scenarios (especially on Windows).

Thanks again for the guidance!

@robocanic

Copy link
Copy Markdown
Contributor

I found that the limit.go and limit_test.go are useless, I've already remove them, you can merge the develop branch and re-commit.

@ankitsharma101

Copy link
Copy Markdown
Author

Thanks for the update!

I've merged the latest develop branch into my PR branch and removed the obsolete limits_test.go file as suggested. The branch is now synced with develop.

Please let me know if any further changes are needed.

@sonarqubecloud

sonarqubecloud Bot commented Mar 1, 2026

Copy link
Copy Markdown

@robocanic robocanic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review 总结

回车提交登录的方向是合理的,但当前分支基于旧版 Login.vue,与 develop 已有冲突,且直接 rebase 之后自动聚焦会失效。

问题

  1. ui-vue3/src/Login.vue(整体):PR 当前状态为 CONFLICTING。develop 上的 Login.vue 已重构为通过 loadAuthConfiguration() 异步加载认证配置,密码表单位于 <a-row v-if="passwordEnabled">,并且 <a-card :loading="loadingConfiguration">。需要先 rebase 到最新 develop 并重新应用改动,同时保留 Provider 登录相关逻辑。
  2. ui-vue3/src/Login.vue:39-41(onMounted + usernameInputRef.value?.focus()):在最新 develop 上,用户名输入框要等配置加载完成(loadingConfiguration 变为 false 且 passwordEnabled 为 true)后才会渲染,而 onMounted 触发时 usernameInputRef.value 仍是 undefined。因为使用了 ?.,不会报错,但自动聚焦会静默失效。建议在表单渲染后再聚焦,例如在 loadAuthConfiguration 完成后 await nextTick() 再 focus(),或 watch passwordEnabled && !loadingConfiguration。
  3. ui-vue3/src/Login.vue:80, 92(@pressEnter="loginHandle"):回车直接调用 loginHandle,没有并发保护。按住 Enter 会连续触发 keydown,导致多次并发的 login 请求以及重复的 meshesSearch / router.replace。建议增加 submitting 标志位(并同时用于按钮的 loading/disabled),或者在提交前调用表单的 validate()(目前 rules: required 实际并未被任何提交路径使用)。
  4. 缺失测试:develop 已有 ui-vue3/src/Login.test.ts(其中 a-input 被 stub 成 <input />)。建议补充用例覆盖“在用户名/密码输入框按回车会触发登录”以及“密码表单渲染后用户名输入框获得焦点”。
  5. PR 描述/标题已过期:描述和标题中提到的 pkg/common/util/os/limits_test.go 的 //go:build !windows 改动已不在本 PR 中(相关文件已在 develop 上被移除,diff 只剩 Login.vue)。请更新标题和描述,避免 Closes #1405 误导 reviewer 认为 Windows 构建问题也已在此修复。

@AlexStocks AlexStocks left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

本轮审查基于 merge-base 82e2512e(Base develop 已领先该分支 20 个 commit)。changed_files=1,实际 Diff 也只有 ui-vue3/src/Login.vue。

结论:当前不可合并

P1 · CI 失败原因可确定性复现:格式化门禁

Head c362767a 的 CI (ubuntu-latest - Go 1.24) 为 failure。失败链路在 .github/workflows/ci.yml:

- name: Build Frontend (Vue3)
  working-directory: ui-vue3
  run: |
    yarn install --frozen-lockfile
    yarn build          # 内部执行 prettier --write src/
...
- name: Check Code Format
  run: make fmt && git status && [[ -z $(git status -s) ]]

新增的三行带行尾空格:

77:            <a-input 
89:            <a-input 
90:              type="password" 

用仓库的 ui-vue3/.prettierrc.json 在 Head 文件上实测:

$ npx prettier@3.0.3 --check src/Login.vue
[warn] src/Login.vue
[warn] Code style issues found in the above file. Run Prettier to fix.   (exit 1)

$ npx prettier@3.0.3 --write src/Login.vue
-            <a-input 
+            <a-input
-              type="password" 
+              type="password"

yarn build 会把这 3 行改写掉,随后 git status -s 非空,[[ -z ... ]] 为假,作业失败。这不是 flaky,而是每次必现。去掉行尾空格即可。

P1 · PR 声称的 Windows 构建修复不存在

PR 描述写「pkg/common/util/os/limits_test.go 添加 //go:build !windows」,但:

$ git ls-tree -r --name-only origin/develop | grep -i limits
(无输出)

该路径在 develop 上不存在,整个 Diff 也没有任何 Go 文件改动。也就是说,描述里的第 2 项修复(也是这个 PR 标题的一部分:「exclude Windows from Unix tests」)没有提交进来。请确认是漏推 commit,还是这部分已被上游以其他方式解决。

P3 · 分支落后 20 个 commit

登录页所在的 ui-vue3 在此期间可能有改动,建议 rebase 后重跑前端构建,避免与已合入的样式/接口变更冲突。

交互改动本身

@pressEnter + onMounted 自动聚焦的实现与 ant-design-vue 4.x 的事件契约一致,a-input 组件实例也暴露 focus(),这部分没有问题。可以顺带考虑两点(非阻断):

  • 连续按 Enter 会并发触发多次 loginHandle,当前没有 in-flight 防护;
  • loginHandle 未先调用表单校验,空用户名会直接打到后端(与按钮点击的既有行为一致,不是本 PR 引入)。

@AlexStocks

Copy link
Copy Markdown

补充一点状态更新(相对上面那条审查意见):

当前 develop 已推进到 f1c3f3a,重新做三方合并检测后,本 PR 新增了一处文本冲突:

$ git merge-tree --write-tree origin/develop pr/1409
CONFLICT (content): Merge conflict in ui-vue3/src/Login.vue

也就是说本 PR 唯一修改的文件 ui-vue3/src/Login.vue 已经在 develop 上被改动过,PR 现有的 diff 无法直接应用。结合之前实测的两点:

  1. npx prettier@3.0.3 --check src/Login.vue(使用仓库自己的 ui-vue3/.prettierrc.json)在 PR 的 Head c362767 上 exit 1,差异恰为 3 行尾随空格,CI 里 Check Code Format: make fmt && git status && [[ -z $(git status -s) ]] 必然失败;
  2. PR 描述里提到的 limits_test.go Windows 修复在 Diff 中并不存在,该路径在 develop 上也不存在。

因此建议:先 rebase 到当前 develop、在解冲突时一并去掉那 3 行尾随空格、并修正 PR 描述使其与实际改动一致。在此之前这个 PR 无法进入合并流程。

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.

UX Enhancements and Windows Build Fixes

4 participants