Repository navigation
fix(desktop): clear or update stale Git Log branch filter on delete or rename - #2094
Merged
Merged
Conversation
1lck
marked this pull request as ready for review
November 17, 2026 08:24
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
lithe core: git.historyPage: Git history failed (process_failed)且左侧分支树被清空)PR 类型 / Type
改动说明 / What changes
背景 / Why
在 Git Log 左侧分支树点击某个分支后,
p.log.reference、p.log.referenceLabel与p.log.refSelected会记录该分支(顶部页签变为日志: <分支>)。随后在分支工具栏或右键菜单删除该分支时,runBranchWrite在重新加载日志前未清理指向已删除分支的筛选状态,导致loadLog继续用已不存在的引用调用git.historyPage,触发Git history failed (process_failed);同时loadLog在err != nil时会清空刚刚读到的l.refs与l.sections,使左侧分支树只剩一行HEAD(当前分支)。改动 / Changes
desktop/internal/workbench/gitlog.gohasReference、dropLogReference、renameLogReference辅助函数,在对应仓库删除或重命名分支/标签时同步清理或更新p.log.reference、p.log.referenceLabel、p.log.refSelected与待比较来源a.logView.compareSource。loadLog中readReferences成功后校验非空且非HEAD的reference是否仍存在于refs.References,若已被外部删除则自动回退为全部引用("")再调用GitHistoryPage,并在 UI 回调中清理已失效的l.reference、l.refSelected与compareSource。desktop/internal/workbench/branch.gorunBranchWrite中将b.dialog = branchDialogNone与done(a, status)提前到a.loadLog(p)之前,确保分支写操作回调先更新日志筛选引用,再触发loadLog读取历史。submitRename的成功回调调用a.renameLogReference,在confirmDelete的成功回调调用a.dropLogReference。desktop/internal/workbench/branch_tags.goconfirmDeleteTag的成功回调调用a.dropLogReference。desktop/internal/workbench/gitsync_test.goTestLogNewAndDeleteBranchFromTheBranchesPane:覆盖选中分支筛选后删除该分支(验证p.log.err == nil、筛选与选中清空、提交列表与main分支保留)、重命名当前筛选分支后同步更新筛选、以及外部git branch -D删除当前筛选分支后loadLog自动回退全部引用。shared/platform-feature-matrix/features/git-branches-remotes.jsonbranch.go、branch_tags.go、gitlog.go证据路径,并在verification记录本次验证行为。不在本 PR 范围内 / Out of scope
Lithe-core-rust中write.rs的"renameBranch"对非当前分支未剥离refs/heads/前缀导致git branch -m refs/heads/<old> <new>失败的问题属于 Core 仓库独立缺陷,不在本 PR 修改范围内。类型专属:fix
复现与根因
topic(日志进入日志: topic筛选状态)→ 删除topic→ 期望自动回退到全部引用并正常刷新日志与分支树;修复前loadLog仍以refs/heads/topic调用git.historyPage,报错lithe core: git.historyPage: Git history failed (process_failed)并清空左侧分支列表。0faecba49(Epic(0.7.0): 基于 Viva 框架的跨平台方案的迁移(#1794) #1799)引入,runBranchWrite在删除/重命名分支后直接调用a.loadLog(p),未清理或更新p.log.reference,且loadLog未在调用GitHistoryPage前检查当前筛选引用是否仍存在。desktop/internal/workbench)。检查项
desktop/internal/workbench/gitsync_test.go(TestLogNewAndDeleteBranchFromTheBranchesPane),修复前失败输出为gitsync_test.go:274: log err after deleting filtered branch: lithe core: git.historyPage: Git history failed (process_failed),修复后通过。runBranchWrite的全部调用方(checkoutWith、submitCreate、submitRename、submitRevision、confirmDelete、submitTag、confirmDeleteTag、setLogUpstream)与loadLog调用方均已核对,行为正常。desktop/internal/workbench实现。.agents/notes/implemented/bug-fix/记录:属于常规状态清理与失效引用回退,未改变架构边界或契约。范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/git-branches-remotes.json(verificationStatus保持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第三节“插件归属与宿主零依赖”自查命令,结果为空。UI 验证 / UI evidence
TestLogNewAndDeleteBranchFromTheBranchesPane与desktop/internal/workbench全量无头测试通过。统一日志系统 / Structured logging
N/A:未新增或修改日志事件。
界面文案 / i18n
node scripts/i18n/verify-app-language-localization.mjs与node scripts/i18n/generate-i18n.mjs --check并通过。逻辑归属 / Logic placement
p.log.reference、p.log.refSelected与a.logView.compareSource均为 Viva 桌面视图会话状态管理,不涉及可共享 Core 业务规则变更。性能与内存 / Performance and memory
N/A:未新增后台任务、轮询、缓存或大对象持有;
hasReference仅在一次loadLog中对已读取的引用切片做线性查找。验证 / Verification
./scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestLogNewAndDeleteBranchFromTheBranchesPane|TestBranch|TestLog' -count=1./scripts/desktop/desktop-go.sh test -race ./internal/workbench -run 'TestLogNewAndDeleteBranchFromTheBranchesPane' -count=1./scripts/desktop/desktop-go.sh vet ./internal/workbenchnode .agents/skills/write-stable-tests/scripts/run-go-tests-with-timing.mjs ... -run TestLogNewAndDeleteBranchFromTheBranchesPane ./internal/workbench.artifacts/test-stability/index.html)./scripts/desktop/desktop-go.sh test ./...internal/workbench(235.276s) 及除internal/localshell外所有包通过;internal/localshell两个现有 shell 挂断超时用例失败(与本次改动无关)./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh --base origin/mainnode scripts/i18n/verify-app-language-localization.mjs && node scripts/i18n/generate-i18n.mjs --check./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD && ./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh未能执行的检查和原因:
提交前确认 / Final checks
main创建;目标分支:main.build/、target/、dist/、.artifacts/等产物