Repository navigation
fix(desktop): GitHub 登录内置产品 OAuth client ID,设置页恢复登录入口 - #2035
Merged
Merged
Conversation
Viva 桌面端只从 LITHE_GITHUB_CLIENT_ID 读取 OAuth client ID,打包构建从不设置它, 所以“设置 → 版本控制 → GitHub 账号”永远显示“此构建未配置 GitHub 登录。”。 旧 macOS 客户端把产品的 client ID 内置在 Info.plist(498906dcc),#1799 迁移时丢了。 - 内置 githubProductClientID,环境变量只用于替换成 fork 或开发用的 OAuth App。 - 可登录只取决于内核能否规划 GitHub 请求;删除 client ID 为空的分支和 desktop.github.notConfigured 词条,不可用时复用 desktop.github.unavailable。 - GitHub 账号卡片移进版本控制页的滚动区,和其他卡片对齐并随页面滚动。 - 新增回归测试 github_account_test.go(修复前失败),无头截图场景加入该卡片, 功能矩阵 github-device-authorization 证据与说明同步更新。
xiaoyumuxi
marked this pull request as ready for review
November 16, 2026 10:03
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
Viva 桌面端“设置 → 版本控制 → GitHub 账号”在所有正常启动的构建里都只显示“此构建未配置 GitHub 登录。”,没有登录入口,用户无法登录 GitHub。原因是登录用的 OAuth client ID 只从环境变量
LITHE_GITHUB_CLIENT_ID读取,而打包构建从来不设置它。旧 macOS 客户端把产品的 OAuth App client ID 内置在 Info.plist 里,#1799 迁移到 Viva 时这个值丢了。设备码流程是公开客户端流程,没有 client secret,client ID 不是凭据,可以直接内置在代码里。
改动 / Changes
desktop/internal/workbench/github_account.gogithubProductClientID = "Ov23li60nlOOHwDY3MO6",与旧 macOS 客户端 Info.plist 的LitheGitHubOAuthClientID相同(498906dcc 引入)。已用该 ID 实际请求https://github.com/login/device/code,GitHub 返回了有效的设备码。githubClientID():设置了LITHE_GITHUB_CLIENT_ID时用它(去掉首尾空白),用于 fork 或开发用的 OAuth App;否则返回内置 ID。githubAccountSnapshot():“可登录”只取决于内核能否规划 GitHub 请求(githubAPI() != nil),不再要求 client ID 非空。startGitHubSignIn():删除 client ID 为空时的“未配置”分支,它已不可能触发。desktop/internal/settingswindow/github_account_view.godesktop.github.unavailable,与 PR 面板相同)。GitHubState/Available的注释。desktop/internal/settingswindow/version_control_view.go:GitHub 账号卡片移进页面滚动区,作为第一张卡片。之前它画在滚动区外面,比下面的卡片更靠左、更宽,也不随页面滚动(见截图对照)。同时更新页面注释。desktop.github.notConfigured(shared/i18n/messages.json、en-US.json、zh-CN.json),并重新生成desktop/internal/i18n/shared.generated.go。desktop/internal/workbench/github_account_test.goTestGitHubSignInIsAvailableWithoutClientIDVariable:清空LITHE_GITHUB_CLIENT_ID后,client ID 非空,设置页快照仍可登录。TestGitHubClientIDVariableReplacesBuiltInClient:设置该变量时会替换内置 ID,并去掉首尾空白。desktop/internal/settingswindow/visual_capture_test.go:无头截图场景加入 GitHub 账号卡片(可登录、未连接),版本控制页的截图从此包含这张卡片。github-device-authorization:两端证据加入新测试;说明改为“client ID 内置,环境变量只用于替换”。两端验证状态保持pending。不在本 PR 范围内 / Out of scope
api.github.com,不在本次范围。类型专属:fix
复现与根因
LITHE_GITHUB_CLIENT_ID),打开“设置 → 版本控制”。实际:GitHub 账号卡片只显示“此构建未配置 GitHub 登录。”,没有登录按钮。期望:显示“登录 GitHub”,可以走设备码流程登录。github_account.go只从LITHE_GITHUB_CLIENT_ID读取 client ID,没有内置值,available又要求 client ID 非空,所以打包构建永远不可登录。同一个 PR 删除了旧 macOS 客户端,它的 Info.plist 里有LitheGitHubOAuthClientID(498906dcc),这个值没有迁过来。检查项
desktop/internal/workbench/github_account_test.go,修复前TestGitHubSignInIsAvailableWithoutClientIDVariable失败:githubClientID() is empty without LITHE_GITHUB_CLIENT_ID; the product's OAuth client must be built ingithubClientID、GitHubState.Available、desktop.github.notConfigured在仓库中已无其他引用;desktop.settings.updates.notConfigured是另一个词条(更新源由打包脚本写入package_info.go,不是同类问题).agents/notes/implemented/bug-fix/记录:约束(client ID 内置、环境变量只用于替换)已写在代码注释和功能矩阵说明里,并由回归测试固定范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/github-device-authorization.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
desktop/下运行LITHE_VISUAL_OUTPUT_DIR=<目录> LITHE_VISUAL_LANGUAGE=<zh-Hans|en> ../scripts/desktop/desktop-go.sh test -count=1 -tags 'vivahead lithevisual' -run 'TestVisualSettings/26-settings-git' ./internal/settingswindow/。改动后是本 PR 的 e51a1a2;改动前用 ebdea8a 的github_account_view.go、version_control_view.go、shared.generated.go,场景设为GitHubState{Available: false},即修复前打包构建的状态。场景26-settings-git、26-settings-git-console,明暗两种主题,中文和英文,窗口 900×700 点(截图 2x)。改动后页面滚到底部时,GitHub 账号卡片和其他卡片一起滚出视野:
统一日志系统 / Structured logging
N/A:没有新增或改动生命周期里程碑、操作终态或失败路径。登录的已有
github.signIn操作记录不变,只删除了一个不可能再触发的分支。界面文案 / i18n
shared/i18n/补齐中英词条,运行node scripts/i18n/generate-i18n.mjs并提交生成结果,没有手改生成文件;Viva 代码通过desktop/internal/i18n/的接口读取(本 PR 只删除词条,复用已有的desktop.github.unavailable)shared/i18n/:不涉及插件文案node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,没有放宽脚本或扩大豁免名单逻辑归属 / Logic placement
refactorIssue:同上性能与内存 / Performance and memory
N/A:没有新增后台功能、子进程、缓存或定时器,也没有改动启动、输入、滚动等路径。设置页快照仍只读内存状态。
设置 / Settings
插件契约 / Plugin contract
N/A:没有改动插件契约、能力版本、插件函数协议或宿主方法。
发行包与资源 / Bundle and resources
N/A:没有新增运行时资源、缓存或下载物,也没有改动构建步骤。
无用代码与重构 / Dead code and refactoring
startGitHubSignIn里 client ID 为空的分支,以及词条desktop.github.notConfiguredrefactor标签的 Issue,没有在本 PR 顺手处理:没有发现验证 / Verification
github_account.go):desktop-go.sh test -run 'TestGitHub' ./internal/workbench/githubClientID() is empty without LITHE_GITHUB_CLIENT_ID; the product's OAuth client must be built indesktop/下../scripts/desktop/desktop-go.sh test -count=1 ./...internal/localshell的TestClosingAnIntegratedShellHangsUpTheShellAndItsJobs/zsh在整套并行负载下失败一次(关闭终端后后台任务 5 s 内没有退出),与本 PR 无关;单独-count=3重跑全部通过../scripts/desktop/desktop-go.sh test -count=1 -race ./internal/workbench/./.agents/skills/write-stable-tests/scripts/test-stability-macos.sh --package ./internal/workbench --filter 'TestGitHub'./.agents/skills/write-stable-tests/scripts/verify-test-stability.shnode scripts/i18n/verify-app-language-localization.mjsnode scripts/i18n/generate-i18n.mjs --checknode --test --test-timeout=60000 scripts/i18n/test-i18n.mjs./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEADdevelop-lithe第三节插件零依赖自查rg命令gofmt -l(改动的 Go 文件)POST https://github.com/login/device/codedevice_code/user_code未能执行的检查和原因:
pending。提交前确认 / Final checks
main创建;目标分支:feat、fix、docs 为main,release 以发布流程要求为准.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图