Skip to content

feat(git): 多仓库工作区的「仓库 ▾」下拉选择器(同名仓库可辨) - #1130

Closed
iasiv5 wants to merge 4 commits into
omdsh-dev:devfrom
iasiv5:feat/repo-repository-dropdown
Closed

iasiv5 wants to merge 4 commits into
omdsh-dev:devfrom
iasiv5:feat/repo-repository-dropdown

Conversation

@iasiv5

@iasiv5 iasiv5 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

背景:仓库胶囊行的两个实际问题

容器工作区(本身不是 Git 仓库、内含多个独立仓库的目录)会在「更改」上方显示一排仓库胶囊(#1112 引入,基于 #607 的仓库发现)。实际使用中遇到两个问题:

图 1|窄侧边栏(改造前)
247cfb39226a6e50c829ab860b656f5e

  • 仓库超过 6 个时显示不全,超出宽度的仓库实际无法点选;
  • 没有滚动箭头提示,鼠标滚轮悬停无法横向滚动(仅触屏可滑)。

图 2|全屏侧边栏(改造前)

6f7264fb83378f6a3be867807789f552
  • 即使全屏能排开,同名仓库(两个 knowhow、两个 openbmc,位于不同层级)在鼠标悬停前完全无法区分。

方案:「仓库 ▾」带标签下拉

图 3|改造后,收起态(提交图工具栏)

image
  • 位置:提交图工具栏首位,与「所有分支」筛选同一行,仓库在前、分支在后(2026-11-12 起;此前为面板顶部独立一行)。
  • 当前选中仓库始终可见;完整列表一键展开;无论多少仓库只占一行;
  • 标签与分区标题同款字体;下拉框与分支筛选同高、同边框样式;
  • 原生 <select>:键盘、读屏、触屏与内部滚动都由浏览器原生提供。

图 4|改造后,展开态(提交图工具栏)

image
  • 选项使用位置消歧标签:深层仓库显示 名 (相对父路径),如 knowhow (ob-harness/contexts) 与 knowhow (ob-harness-ast2700-a0/contexts) 同屏可辨;极端冲突才回退完整路径。

细节与取舍

  • 选中值是服务端解析后的实际状态根:若所选仓库已不在发现列表(服务端会回退到首个仓库),下拉以禁用临时项如实显示实际根及其短标签,而不是静默选中第一项或沿用失效请求。
  • 同行的理由:仓库是范围选择,分支列表本就属于所选仓库,同行即表达「先选仓库、再选分支」;相比顶部独立一行,省下一整条控件带的纵向空间。「更多操作 → 仓库」二级菜单保留,作为提交图折叠时的切换兜底。
  • 已知取舍:相对 #1112 的胶囊行,完整列表从「平铺可见」变为「一键展开」。胶囊在仓库较多、且需要位置标签消歧时无法容纳;若维护者倾向在仓库数较少时保留胶囊形态,欢迎讨论。
  • 位置迁移的取舍:仓库切换作用于整个面板,控件却位于更改区下方的提交图区块内;提交图折叠时控件随之隐藏(以「更多操作 → 仓库」兜底);两个下拉同行,侧栏很窄时两者都会变短(未做窄宽度实测)。
  • 标签基准为界面当前会话目录(尽力参照,可能随活动 worktree 变化);纯显示层改动,不新增请求、Git 命令或轮询。服务端 repoRoot 未命中时的回退逻辑未改动;单仓库工作区不显示此下拉。

测试

  • 新增 tests/git-repo-labels.spec.ts(32 例:POSIX / Windows 盘符 / UNC / \\?\ 扩展路径、同名消歧、顺序与输入不变性);tests/git-repo-switcher.spec.tsx 重写为下拉契约(选项标签、拼写折叠、服务端回退禁用临时项、单仓不显示);tests/git-view-worktree.spec.tsx 的切仓用例改走下拉。
  • 本地(Linux,Git 2.56):typecheck / lint / 全量 vitest(247 文件、3060 通过)/ build / check:consumer-types 全部通过。
  • 真实宿主手动验证:切换仓库后更改区、提交信息与提交图联动正确。
  • 2026-11-12 迁移后复验(e87b2f58,Linux,Git 2.43):tsc --noEmit 通过(默认堆会 OOM,需 NODE_OPTIONS=--max-old-space-size=4096);build 通过;vitest 全量 3513 用例:3495 通过、17 跳过、1 失败,失败项为 tests/git.spec.ts 的 checkout --end-of-options 用例(Git 2.43 环境问题,与本 PR 无关);headless GUI 冒烟通过:仓库下拉 19 个选项,联动后提交图重查 42 commits 无告警。
  • CI(head e87b2f58):ci、ci-windows(Windows lane)、plugin-mount 全部通过。

Sidebar Test and others added 4 commits November 5, 2026 18:52
A container workspace that discovers several repositories rendered one
chip per root above the Changes section; with location labels the row
does not scale, and same-named checkouts were indistinguishable. The
row is now a compact labeled select: the current root stays on screen,
the full list is one click away, and options carry disambiguation
labels (deeper roots show their relative parent) shared with the
More -> Repository submenu. The picker shows the resolved status root —
a server fallback renders as a disabled stand-in with its own short
label instead of silently selecting the first option. Single-repo
workspaces render no row; switching still goes through chooseRepo.
…p the redundant submenu

The picker label now uses the section-header face (matching 更改/提交图)
and the select mirrors the graph toolbar branch filter. The More-actions
Repository submenu is removed: the standalone picker owns repository
switching, and branch filtering already lives under the graph toolbar.
…he branch filter

Move the multi-repo picker from its own band above Changes to the head of
the commit-graph toolbar, ahead of the branch filter - repository first,
filter second, one scope row, and one less row of vertical space. The
picker rides the foldable graph section, so the dots -> Repository submenu
returns as the always-reachable fallback while the graph is folded; its
submenu labels now carry the same disambiguation labels as the picker
options.
The relocated picker dropped its visible 仓库 caption, which left the first box of the scope row as a bare repository name. Restore the caption at the section-header type and pin it with an assertion.
Menghuan1918 added a commit that referenced this pull request Nov 15, 2026
Keep the contributor label work but place the control above Changes per the product decision: chips at natural width while every root fits, one native select once it does not. A hidden measurement row makes the decision content-driven; the More -> Repository submenu stays as the folded fallback.
@Menghuan1918

Copy link
Copy Markdown
Collaborator

感谢 @iasiv5!四个提交已 rebase 到当前 dev,作者字段保持原样(前两个提交的 author 是 Sidebar Test 自动化账号,未改写;后两个是 iasi)。

按产品决定,维护者提交 83a25c27 保留了你的位置消歧标签与 repo-labels,但把切换器放回「更改」上方独立一行,并改成响应式:宽度足够时横排自然宽度胶囊,放不下时切换为「仓库 ▾」下拉;隐藏测量行按内容宽度决策,「更多操作 → 仓库」保留为兜底;服务端回退根以禁用项显示。新增 32 例标签测试与宽/窄两种形态的切换测试。

验证:全量 303 文件 / 3,518 例通过(rc.2 串行 lane,17 跳过),typecheck / lint / build / consumer types 通过,真实宿主 Chromium 挂载在 0.2.2-rc.2 与 rc.3 各 26 通过 / 6 跳过。

已合入 dev(当前 dev head 2647fbac)。因为无法向你的 fork 推送,这里以评论关闭 PR;你的提交与作者身份保留在 first-parent 历史里。谢谢!

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.

2 participants