Skip to content

fix(desktop): clear or update stale Git Log branch filter on delete or rename - #2094

Merged
1lck merged 1 commit into
mainfrom
fix/git-log-deleted-branch-filter
Nov 17, 2026
Merged

1lck merged 1 commit into
mainfrom
fix/git-log-deleted-branch-filter

Conversation

@1lck

@1lck 1lck commented Nov 17, 2026

Copy link
Copy Markdown
Owner

关联 Issue / Linked issue

  • 无(用户反馈在 Git Log 选中分支筛选后删除该分支,日志区域报 lithe core: git.historyPage: Git history failed (process_failed) 且左侧分支树被清空)

PR 类型 / Type

  • feat:新功能或用户可见的改进
  • fix:缺陷修复
  • docs:文档、Agent Note、Skill 等规则文件
  • release:稳定版发布准备

改动说明 / 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.go
    • 新增 hasReference、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.go
    • 在 runBranchWrite 中将 b.dialog = branchDialogNone 与 done(a, status) 提前到 a.loadLog(p) 之前,确保分支写操作回调先更新日志筛选引用,再触发 loadLog 读取历史。
    • 在 submitRename 的成功回调调用 a.renameLogReference,在 confirmDelete 的成功回调调用 a.dropLogReference。
  • desktop/internal/workbench/branch_tags.go
    • 在 confirmDeleteTag 的成功回调调用 a.dropLogReference。
  • desktop/internal/workbench/gitsync_test.go
    • 扩展 TestLogNewAndDeleteBranchFromTheBranchesPane:覆盖选中分支筛选后删除该分支(验证 p.log.err == nil、筛选与选中清空、提交列表与 main 分支保留)、重命名当前筛选分支后同步更新筛选、以及外部 git branch -D 删除当前筛选分支后 loadLog 自动回退全部引用。
  • shared/platform-feature-matrix/features/git-branches-remotes.json
    • 补充 branch.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

复现与根因

  • 复现步骤、实际结果、期望结果:打开 Git Log → 在左侧分支树点击非当前分支 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 前检查当前筛选引用是否仍存在。
  • 影响平台:桌面端(macOS / Windows / Linux 共用 Viva 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),修复后通过。
  • [N/A] 无法自动化时,已写明手动复现与验证步骤:已通过 Viva 无头回归测试自动化验证。
  • 已搜索被修改函数、类型、契约字段的全部调用方:runBranchWrite 的全部调用方(checkoutWith、submitCreate、submitRename、submitRevision、confirmDelete、submitTag、confirmDeleteTag、setLogUpstream)与 loadLog 调用方均已核对,行为正常。
  • 已检查另一平台是否有同类缺陷:macOS / Windows / Linux 共用同一份 desktop/internal/workbench 实现。
  • 只改了修复所需的代码,没有夹带重构。
  • [N/A] 修复改变了行为约束或容易复发,已在 .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 第三节“插件归属与宿主零依赖”自查命令,结果为空。
  • 新增或修改的测试仅使用临时 Git 仓库与 Core 客户端,不依赖任何具体插件。
  • 没有为具体插件新建或更新宿主功能矩阵条目或 i18n 词条。
  • [N/A] 修改了通用扩展点、可能影响已发布插件的:未修改插件扩展点或协议。

UI 验证 / UI evidence

  • 已运行受影响场景的 Viva 无头测试:TestLogNewAndDeleteBranchFromTheBranchesPane 与 desktop/internal/workbench 全量无头测试通过。
  • [N/A] 已在本 PR 嵌入截图或附上可访问的已上传截图 artifact 链接:本次修复日志状态同步与失效引用回退,无布局或样式变更,已由无头状态与命中测试验证。
  • [N/A] 布局与视觉变化有改动前后对照:未改动界面布局与样式。

统一日志系统 / 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 macOS (arm64) 通过 (33.582s)
./scripts/desktop/desktop-go.sh test -race ./internal/workbench -run 'TestLogNewAndDeleteBranchFromTheBranchesPane' -count=1 macOS (arm64) 通过 (7.673s)
./scripts/desktop/desktop-go.sh vet ./internal/workbench macOS (arm64) 通过
node .agents/skills/write-stable-tests/scripts/run-go-tests-with-timing.mjs ... -run TestLogNewAndDeleteBranchFromTheBranchesPane ./internal/workbench macOS (arm64) 通过 (3190ms,报告 .artifacts/test-stability/index.html)
./scripts/desktop/desktop-go.sh test ./... macOS (arm64) internal/workbench (235.276s) 及除 internal/localshell 外所有包通过;internal/localshell 两个现有 shell 挂断超时用例失败(与本次改动无关)
./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh --base origin/main macOS 通过
node scripts/i18n/verify-app-language-localization.mjs && node scripts/i18n/generate-i18n.mjs --check macOS 通过 (11412/11412)
./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD && ./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh macOS 通过 (197 capabilities)

未能执行的检查和原因:

  • Windows / Linux 原生窗口实机运行未在本机执行(当前在 macOS 环境开发与验证)。

提交前确认 / Final checks

  • 分支从最新的 main 创建;目标分支:main
  • 没有无关改动,没有提交 .build/、target/、dist/、.artifacts/ 等产物
  • 本次测试未启动常驻 Lithe 应用进程,无进程残留

@ghfind-review ghfind-review Bot added the review: high ghfind author score; see https://ghfind.com label Nov 17, 2026
@1lck
1lck marked this pull request as ready for review November 17, 2026 08:24
@1lck
1lck merged commit 780aad3 into main Nov 17, 2026
2 of 7 checks passed
@1lck
1lck deleted the fix/git-log-deleted-branch-filter branch November 17, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: high ghfind author score; see https://ghfind.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant