【已审核】feat(git-diff): 文件改动 tab 仓库选择器——按仓库聚合所有 worktree 变更与分支对比 - #1432
Open
climashscape wants to merge 1 commit into
Open
【已审核】feat(git-diff): 文件改动 tab 仓库选择器——按仓库聚合所有 worktree 变更与分支对比#1432climashscape wants to merge 1 commit into
climashscape wants to merge 1 commit into
Conversation
仓库选择器(文件改动 tab 顶部): - 扫描到的 Git 仓库加入下拉并绑定会话,选中后该会话只扫描此仓库的所有 worktree - 仓库列表按 worktree 数优先排序,支持手动添加仓库(系统目录对话框) - 工作树过滤条:聚合视图 ↔ 单个 worktree 视图切换 仓库聚合视图: - 按 worktree 分组展示未提交改动 + 领先/落后 commit 概览(hash/作者/日期) - 每个 worktree 显示 分支/head/±commits 徽章/改动统计,支持搜索与折叠 - 点击文件预览 diff,基准对齐自动探测结果 分支对比: - 对比基准可选(默认自动探测 origin/main → origin/master → 本地 → HEAD~) - 显式对比基准用两点 diff(两分支全部差异),并展示基准独有 commits(双向) 性能(合并 perf/git-diff-parallel-cache): - 扫描并发预检(porcelain 快速跳过干净仓库)+ 六层缓存(scan/perRepo/gitRoots/ worktrees/repoChanges/listRepos)+ 定向失效 + watcher 噪声过滤 - 仓库根发现/基准探测/工作树枚举均缓存;getRepoChanges 会话隔离缓存 修复: - findAllGitRootsDown 将 worktree 目录(.git 指针文件)误识别为独立仓库 - 默认「会话改动」视图枚举 worktree,未提交改动直接可见 - Electron window.prompt 不可用(改系统对话框);跨会话缓存泄漏;定向失效 不覆盖聚合缓存;选基准无效果(三点 diff 语义)等 测试:git-diff-service 集成测试(临时仓库验证发现/枚举/聚合/基准探测)
climashscape
force-pushed
the
feat/git-repo-selector
branch
from
August 4, 2026 16:36
d8cddce to
2fef994
Compare
climashscape
marked this pull request as ready for review
August 4, 2026 19:17
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.
概述
右侧边栏「文件改动」tab 在包含大量 Git 仓库的项目根(monorepo / fork 集合)下存在两个痛点:所有仓库的改动混杂显示无法聚焦;主仓库的 git worktree 分支改动(
.worktrees/下)默认扫描不到。本 PR 引入仓库选择器:把工作区扫描到的 Git 仓库加入下拉并绑定会话,选中后该会话只扫描此仓库的所有 worktree(含 main 与各分支 worktree),以聚合视图展示未提交改动 + 领先/落后 commit 概览;支持仓库内单 worktree 细化、分支间对比(A vs B)、手动添加仓库、基准分支自动探测。同时以 merge 形式包含
perf/git-diff-parallel-cache(PR #1424)的扫描性能优化作为基础设施。改动
apps/electron/src/main/lib/git-diff-service.ts(+831):新增listRepos/getRepoChanges/listWorktreesFromRoot/resolveDefaultBaseBranch(单次 for-each-ref + 30s 缓存);findAllGitRootsDown区分 .git 目录与 worktree 指针文件;默认getUnstagedChanges枚举 worktree;多级缓存 + 定向失效apps/electron/src/main/ipc.ts:新增git:list-repos/git:get-repo-changes/shell:select-directory,逐 worktree 路径授权、缓存 key 会话隔离apps/electron/src/preload/index.ts:electronAPI 新增listRepos/getRepoChanges/selectDirectorypackages/shared/src/types/runtime.ts:新增RepoInfo/RepoChangesResult/RepoWorktreeChanges/CommitSummary类型与 3 个 IPC 通道apps/electron/src/renderer/components/diff/RepoSelector.tsx(新增):仓库下拉选择器,绑定会话,支持手动添加仓库apps/electron/src/renderer/components/diff/WorktreeSelector.tsx:改造为仓库内工作树过滤条,支持对比基准选择(A vs B 双向 commit 概览)apps/electron/src/renderer/components/diff/DiffChangesList.tsx:聚合视图(worktree 分组 + 领先/落后 commit + 折叠/搜索)+ 单 worktree 细化视图切换;兼容上游 feat(agent): surface non-git file changes #1429 的 non-git 文件变更展示apps/electron/src/renderer/atoms/agent-atoms.ts/SidePanel.tsx/LeftSidebar.tsx/useGlobalAgentListeners.ts/workspace-watcher.ts:per-session 选择状态、缓存清理、预览基准透传、写文件失效apps/electron/src/main/lib/git-diff-service.test.ts(新增):临时仓库集成测试(发现/枚举/聚合/基准探测)与 PR #1424 的关系(重要)
perf/git-diff-parallel-cache(PR 【已审核】perf(git-diff): 大量 git 仓库项目根扫描卡顿优化——并发预检 + 三层缓存 + 定向失效 #1424)的扫描性能优化(并发预检 + scanCache/perRepoCache/gitRootsCache 三层缓存 + 定向失效 + watcher 过滤),作为仓库选择器功能的基础设施(findAllGitRoots缓存、invalidateGitDiffCache定向失效被listRepos/getRepoChanges依赖)。测试
bun run --filter=@proma/electron typecheck✅build:main / build:preload / build:renderer✅bun test5 个集成用例全过(临时 git 仓库验证 findAllGitRoots / listRepos / worktree 枚举 / getRepoChanges 聚合 / 基准自动探测)紧急度
常规
备注
listRepos60s TTL + 强制刷新d7f76914),已兼容上游 feat(agent): surface non-git file changes #1429(non-git file changes)的 DiffChangesList 改动