Skip to content

feat(git-review): support repositories in workspace subdirectories#152

Merged
coder-hhx merged 3 commits into
mainfrom
feat/git-review-subdirectory-repositories
Jul 19, 2026
Merged

feat(git-review): support repositories in workspace subdirectories#152
coder-hhx merged 3 commits into
mainfrom
feat/git-review-subdirectory-repositories

Conversation

@coder-hhx

@coder-hhx coder-hhx commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

背景

当工作区根目录本身不是 git 仓库、但其子目录中存在 git 仓库时(例如把多个项目放在一个父目录下打开),Git 审查面板会一直显示"未找到 Git 仓库",无法读取子目录仓库的任何 git 信息。

方案

参考 VSCode git 扩展的仓库扫描机制(git.repositoryScanMaxDepth / git.repositoryScanIgnoredFolders):

后端(Rust)

  • 新增 git_discover_repositories 命令:在工作区内扫描 git 仓库(深度 ≤ 2,跳过隐藏/忽略目录,扫描量有上限),候选目录经 git rev-parse 校验并按仓库根去重
  • 同步接入 gateway 直通通道(discover_repositories,只读 action,不受 enable_web_git 写门控影响)

前端(GUI + WebUI 双端)

  • GitClient 新增可选 discoverRepositories 能力,旧桌面端不支持时静默降级
  • Git 审查面板:所有 git 请求以选中仓库为 workdir;根目录不是仓库时自动选中第一个子仓库;头部按"仓库在上、分支在下"重排,多仓库时仓库行是胶囊下拉选择器,单仓库时显示目录名(完整路径悬停提示)
  • Git 审查面板支持切换分支:分支名即切换器,打开时懒加载本地/远程分支;checkout 因未提交更改中止时弹出"暂存并切换"确认框,替代裸露的 git 报错
  • 基线行重构:基线标签 chip + 云图标 + 等宽字体 ref
  • 输入框分支选择器:同样支持子目录仓库,仓库切换行带"仓库"标签/数量徽标/箭头;切换仓库后菜单保持打开,由用户手动选择分支

镜像与 i18n

  • git-review 镜像文件两端字节级同步(CI check-mirror 通过);GitBranchSelector 保留两端既有字号差异
  • 新增 i18n key 均已加到两端 zh/en

测试

  • cargo test -p liveagent --lib git:41 项通过(含 3 个新增 discover 测试)
  • 两端 tsc --noEmit、biome lint、check-mirror.mjs(79 文件)通过
  • GUI node --test 1036 项、WebUI 360 项通过
  • 本地 tauri dev 实际验证:多仓库工作区自动发现/切换、分支切换、冲突暂存切换流程

🤖 Generated with Claude Code

coder-hhx and others added 3 commits July 19, 2026 21:12
When the workspace folder is not itself a git repository, the review
panel previously showed "no repository" even when subdirectories held
repositories. Following VSCode's repository scanning approach
(git.repositoryScanMaxDepth / repositoryScanIgnoredFolders), a new
git_discover_repositories command scans the workspace for repositories
(depth <= 2, skipping dot/ignored folders, bounded scan budget) and the
panel auto-selects the first discovered repository, with a toolbar
picker to switch between them.

- backend: git_discover_repositories_sync + tauri command + gateway
  "discover_repositories" action (read action, passes the web git guard)
- frontend: optional GitClient.discoverRepositories on both clients;
  useGitReviewData keys all requests to the picked repository root and
  rescans on manual refresh; toolbar repository picker
- mirror: git-review files synced byte-for-byte; i18n keys added to
  both frontends

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…upport

Follow-up UI polish on subdirectory repository support:

- git-review toolbar: replace the native <select> with the app's
  dropdown-menu component, rendered as a pill trigger (folder icon +
  repo name + chevron) under the branch title
- composer branch selector: discover subdirectory repositories too and
  add a repository switcher submenu row (repository label, current repo
  name, count badge, chevron) so the switch affordance is obvious
- shared repo label helpers in lib/git/types.ts on both frontends;
  mirrored files synced byte-for-byte, i18n keys added to both ends

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…polish

- git-review toolbar: the branch title is now a switcher — branches load
  lazily on open, switching runs the shared operation flow with
  status/history refresh
- checkout conflicts (uncommitted changes would be overwritten) surface
  as a stash-and-switch confirm dialog instead of the raw git error
- header hierarchy reordered repository-first (repository line above the
  branch, as in GitHub Desktop/VSCode); single-repo line shows the
  folder basename with the full path as tooltip
- baseline row restyled (base label chip + cloud icon + monospace ref)
  and the tracking card pulled closer to the header
- composer branch selector: picking a repository closes only the
  submenu and keeps the menu open so the branch is chosen manually

Mirrored files synced byte-for-byte; i18n keys added to both frontends.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coder-hhx
coder-hhx merged commit 02b5e4b into main Jul 19, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant