Repository navigation
feat(desktop): 在窗口中回答 Git 的用户名、密码、口令和重试询问 - #2253
Merged
Merged
Conversation
xiaoyumuxi
marked this pull request as ready for review
November 20, 2026 22:49
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
用户在 Lithe 中克隆、拉取、推送一个需要认证的仓库,而本机又没有可用的凭据助手时,Git 会去终端读用户名和密码。桌面应用没有终端,所以操作会一直卡住直到超时,用户也看不到原因。远程开发(#2231)里 Git 运行在远端,这个问题会更常见。
Core 在 #137 已经提供了 AskPass 中转:Git 以
GIT_ASKPASS/SSH_ASKPASS启动lithe可执行文件的助手模式,助手通过 Core 的本地连接把问题转给发起操作的请求,请求的执行事件里带上问题,宿主用git.authRespond回答。本 PR 把桌面端接上:助手模式入口、问题对话框,以及所有由用户发起的 Git 操作。改动 / Changes
助手模式入口
desktop/cmd/lithe/main.go:main开头先用core.GitAskPassRequest(os.Args)判断是否以助手身份被 Git/SSH 启动;是的话调用core.GitAskPass转发问题、把答案写到标准输出后立即退出,不创建窗口、日志、存储,也不读取登录环境。desktop/internal/core/bridge.go:新增GitAskPass,经 C ABI 调用 Core 的lithe_core_git_askpass。desktop/internal/workbench/settings_toolchains_test.go:测试二进制的TestMain同样先做助手检查,这样端到端测试里 Git 启动的是同一个测试程序。Core 客户端
desktop/internal/core/gitauth.go(新增):GitAuthChallenge:requestId、已脱敏的提示原文、是否密文、是否“重试”问题、第几次、Git 的工作目录,以及请求结束时关闭的Done。WithGitAuthentication(ctx, prompt):给上下文挂上提问回调;只对git.*请求、且不在gitConsoleUnrecorded中的命令生效。gitAuthenticationObserver:只解码含"authentication"的执行事件行,把问题交给回调,其余事件照常传给下一个观察者。GitAuthRespond(git.authRespond)、GitRetryAnswer、GitAskPassRequest。desktop/internal/core/client.go:gitExecution增加Interactive;可交互请求一定挂执行事件观察者(Core 拒绝不观察事件的可交互请求),请求返回时关闭Done。desktop/internal/core/gitconsole.go:gitExecutionOf为挂了提问回调的 Git 请求设置Interactive,自动刷新永远不交互;与 feat(workspace): 安全模式不启动会运行项目代码的语言服务器、Git 和版本控制 #2251 的ProjectCodeAllowed合并在同一个策略里。窗口里的问题对话框(
desktop/internal/workbench/git_auth.go,新增)Username for 'https://…':),密文问题输入框用圆点显示,并提示“回答只交给这个 Git 进程,Lithe 不会保存”;第 2 次以上询问显示黄色提示“上一次的回答没有通过”。GitRetryAnswer。Done关闭)时,它还没回答的问题自动从队列移除,输入内容一起清空。operation_rejected/answer_refused;问题已过期则不提示。git.authentication.answer/retry/cancel三种动作和失败/拒绝终态,不含提示原文、用户名、主机或答案。接入的操作(只接用户发起的操作,后台刷新不询问)
clone.go)、拉取/推送/同步(gitsync.go)、删除远程分支(branch_delete.go)、提交并推送(commit.go)、GitHub 新建仓库后发布分支(github_create.go)、检出 PR(github_prs.go)。github_create.go发布分支和github_prs.go检出 PR 的超时从gitTimeout(30 秒)改为syncTimeout(10 分钟),与其他推送/抓取一致:等待用户输入凭据时 30 秒不够。其他
desktop/internal/workbench/app.go:Kernel接口增加GitAuthRespond;App增加gitAuth状态。desktop/internal/workbench/root.go:问题对话框放在所有浮层最后绘制,保证在克隆等对话框之上。shared/i18n/features/git-authentication.json(新增):11 条中英词条,已生成shared.generated.go。shared/platform-feature-matrix/features/git-authentication-prompts.json(新增):两端 implemented / pending。desktop/internal/workbench/logevents_test.go:新增事件加入目录校验。不在本 PR 范围内 / Out of scope
gitauth_test.go的取消用例。类型专属:feat
多平台对齐
Viva 桌面端代码两端共用。Windows 上
lithe.exe是 GUI 子系统程序,Git for Windows 启动助手时会重定向它的标准输出,理论上可以读到答案,但还没有在 Windows 实机验证,功能矩阵 Windows 端保持 pending。范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/git-authentication-prompts.json:两端的实现状态和验证状态、证据路径、owner、验证动作都如实填写;没有运行验证的保持pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh;改了平台实现路径的,还运行了./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD.artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空shared/i18n/;插件的构建步骤、资源路径和补丁没有写进docs/ci-builds.md、Agent Note 或 SkillUI 验证 / UI evidence
LITHE_VISUAL_OUTPUT_DIR=docs/assets/git-askpass scripts/desktop/desktop-go.sh test -tags vivahead -run TestVisualGitAuthentication ./internal/workbench,用户名 / 密码第 2 次询问 / 是否重试三种状态,深色中文与浅色英文,1280×800 @2x统一日志系统 / Structured logging
app.action.performed、operation_failed、operation_rejected事件,没有新增事件 ID;logevents_test.go已加入目录校验界面文案 / i18n
shared/i18n/features/git-authentication.json补齐中英词条,运行node scripts/i18n/generate-i18n.mjs并提交生成结果node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --checkGit 的原始提示(
Username for '…':等)是上游诊断内容,原样显示、不翻译;“是否重试”问题由 Core 发起,窗口显示翻译后的说明。逻辑归属 / Logic placement
性能与内存 / Performance and memory
"authentication"的事件行才解码;问题队列随请求结束清空main最开头返回,不加载窗口和插件设置 / Settings
N/A:没有新增或修改设置项。
插件契约 / Plugin contract
N/A:没有修改插件契约、能力版本或宿主方法;
git.authRespond是应用命令,不是插件宿主方法。发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh无用代码与重构 / Dead code and refactoring
验证 / Verification
scripts/desktop/desktop-go.sh test ./... -count=1internal/localshell的TestShellIsBusyWhileAForegroundCommandRuns在全量负载下超时一次,单独-count=3重跑通过(既有偶发,与本改动无关)scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestCloneAsksForCredentialsInTheWindow|TestGitAuth' -count=1 -v:真实 Core + Git 克隆一个拒绝认证的 HTTP 远程,窗口依次回答用户名、密码,Esc 取消重试;远程收到alice:s3cret,克隆失败且不留目录;Core 拒收回答、问题过期、请求已返回、正常接受四种情况;多问题按序排队scripts/desktop/desktop-go.sh test ./internal/core -run GitAuth -count=1scripts/desktop/desktop-go.sh test -tags vivahead -run TestVisualGitAuthentication ./internal/workbenchnode scripts/i18n/generate-i18n.mjs --check、node scripts/i18n/verify-app-language-localization.mjs./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD./scripts/desktop/verify/verify-runtime-bundle-immutability.shgofmt -l desktop未能执行的检查和原因:
lithe.exe助手的标准输出尚未验证。提交前确认 / Final checks
main创建(已 rebase 到 aef31af,含 feat(workspace): 安全模式不启动会运行项目代码的语言服务器、Git 和版本控制 #2251);目标分支main.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图(截图里的目录是示例路径/Users/dev/Projects/Demo)