refactor(git): the repository picker joins the graph toolbar beside the 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.
This commit is contained in:
1 parent
3590ec9c53
commit
54fa7a56ef
8 files changed
+61
-60
No files matched your search
+1
-1
@@ -156,7 +156,7 @@
|
||||
|
||||
### v0.30.1
|
||||
|
||||
- 🌿 **Git 面板新增「仓库 ▾」下拉,同名仓库一眼可辨**:容器工作区发现多个仓库时,顶部显示与分区标题同款的「仓库 [当前仓库 ▾]」下拉,下拉框样式与提交图的分支筛选一致——当前选中的仓库始终可见,完整列表一键展开,仓库再多也只占一行。选项使用位置消歧标签:深层仓库显示 `名 (相对父路径)`(如 `knowhow (ob-harness/contexts)`),同名可辨,极端冲突用完整路径兜底。若服务端把所选仓库回退到其他根,下拉会以禁用项如实显示实际根,不冒充候选;原「更多操作 → 仓库」二级菜单随独立下拉移除。单仓库工作区不显示此行;切换仍走既有 `chooseRepo`,读数、写操作与提交图继续钉在选中的根上。
|
||||
- 🌿 **Git 面板新增「仓库 ▾」下拉,同名仓库一眼可辨**:容器工作区发现多个仓库时,提交图工具栏开头与「所有分支」筛选并排一行显示「仓库 ▾」下拉(仓库在前、分支在后)——当前选中的仓库始终可见,完整列表一键展开,仓库再多也只占一行,且比独立成行更省纵向空间。选项使用位置消歧标签:深层仓库显示 `名 (相对父路径)`(如 `knowhow (ob-harness/contexts)`),同名可辨,极端冲突用完整路径兜底。若服务端把所选仓库回退到其他根,下拉会以禁用项如实显示实际根,不冒充候选;「更多操作 → 仓库」二级菜单保留,作为提交图折叠时的切换兜底。单仓库工作区不显示此下拉;切换仍走既有 `chooseRepo`,读数、写操作与提交图继续钉在选中的根上。
|
||||
- 🧪 测试:`tests/git-repo-labels.spec.ts`(32 例:路径方言、同名消歧、顺序与输入不变)与 `tests/git-repo-switcher.spec.tsx`(下拉选项与标签、拼写折叠、服务端回退的禁用临时项、单仓不显示)。
|
||||
|
||||
- 🎯 **设置页「侧边卡片」的导航图标不再叠成两个**:插件此前按"宿主设置导航还没有图标通道"的老假设,用 CSS 把兜底齿轮藏起来、再画自己的图标;宿主早已提供按 section id 寻址的 `settings.section.icon` 插槽,而且图标的 DOM 外面多了一层 span,老选择器失效后兜底 SVG 露了出来,与插件图标并排显示。现在改为**走宿主插槽**提供图标,删掉标记 + CSS 遮罩那一套(顺带去掉了一个监听整个 document 的 MutationObserver)。
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@
|
||||
|
||||
### v0.30.1
|
||||
|
||||
- 🌿 **A labeled "Repository" dropdown for multi-repo workspaces, with same-named checkouts tellable apart**: when a container workspace discovers several repositories, the panel shows a `Repository [current ▾]` select styled like the section headers and the graph's branch filter — the current root stays on screen and the full list is one click away, one line however many roots discovery finds. Options carry location labels: deeper repositories show `name (relative/parent)` (e.g. `knowhow (ob-harness/contexts)`), so same-named checkouts are distinguishable, and extreme collisions fall back to full paths. If the server fell back from the requested root, the picker displays the actual root as a disabled stand-in instead of masquerading as a candidate; the former ⋯ → Repository submenu is removed now that the picker stands alone. Single-repository workspaces render no row; switching still goes through the existing `chooseRepo`, so reads, mutations and the commit graph stay pinned to the chosen root.
|
||||
- 🌿 **A labeled "Repository" dropdown for multi-repo workspaces, with same-named checkouts tellable apart**: when a container workspace discovers several repositories, the graph toolbar opens with a `Repository ▾` select sharing one row with the branch filter (repository first, filter second) — the current root stays on screen and the full list is one click away, one line however many roots discovery finds, and no extra row above the sections. Options carry location labels: deeper repositories show `name (relative/parent)` (e.g. `knowhow (ob-harness/contexts)`), so same-named checkouts are distinguishable, and extreme collisions fall back to full paths. If the server fell back from the requested root, the picker displays the actual root as a disabled stand-in instead of masquerading as a candidate; the ⋯ → Repository submenu stays reachable as the fallback surface while the graph is folded. Single-repository workspaces render no picker; switching still goes through the existing `chooseRepo`, so reads, mutations and the commit graph stay pinned to the chosen root.
|
||||
- 🧪 `tests/git-repo-labels.spec.ts` (32 cases: path dialects, duplicate disambiguation, order and input immutability) and `tests/git-repo-switcher.spec.tsx` (picker options and labels, spelling folding, the server-fallback disabled stand-in, single-repo absence).
|
||||
|
||||
- 🎯 **The "Side card" settings row no longer shows two icons**: the plugin still assumed the settings navigation had no icon channel, so it hid the fallback gear with CSS and painted its own glyph. The shell has long since exposed a `settings.section.icon` slot addressed by section id, and it now wraps the nav icon in a span — the stale `> svg:first-child` rule stopped hiding the fallback, so both glyphs rendered side by side. The row now contributes its icon **through the slot**, and the marker + CSS-mask apparatus is gone (along with a document-wide MutationObserver).
|
||||
|
||||
@@ -35,6 +35,18 @@ export interface GraphDetailsSelection {
|
||||
readonly slot: number
|
||||
}
|
||||
|
||||
/** The lens-owned multi-repository picker state. `labels` pairs each
|
||||
* discovered root with its display-only disambiguation label; `value` is the
|
||||
* RESOLVED status root; `standInLabel` is set when the server fell back from
|
||||
* the requested root — rendered as a disabled option, never a candidate. */
|
||||
export interface RepoPickerState {
|
||||
readonly labels: ReadonlyArray<{ readonly root: string; readonly label: string }>
|
||||
readonly value: string
|
||||
readonly standInLabel?: string
|
||||
readonly disabled: boolean
|
||||
readonly onChooseRepo: (root: string) => void
|
||||
}
|
||||
|
||||
export interface GitGraphSectionProps {
|
||||
scope: SessionScope
|
||||
worktree?: string
|
||||
@@ -52,6 +64,12 @@ export interface GitGraphSectionProps {
|
||||
/** Row context menu: the Git lens's advanced commit actions (view / copy /
|
||||
* revert / cherry-pick). Absent, the rows simply carry no menu. */
|
||||
onContextMenu?: (event: MouseEvent<HTMLButtonElement>, entry: GraphEntry) => void
|
||||
/** The lens-owned multi-repository picker, rendered at the head of the
|
||||
* toolbar so the row reads as one scope line: pick the root, then filter
|
||||
* its history. Present only when the workspace holds several roots; the
|
||||
* lens keeps the ⋯ → Repository submenu reachable so a FOLDED graph never
|
||||
* orphans the switcher (the toolbar unmounts with the section). */
|
||||
repoPicker?: RepoPickerState
|
||||
}
|
||||
|
||||
/** One-line rows: the GitLens-style picture is rail + ref pills + subject on
|
||||
@@ -136,7 +154,7 @@ export function RefPill({ pill, slot }: { pill: RefPillModel; slot?: number }) {
|
||||
</span>
|
||||
}
|
||||
|
||||
export function GitGraphSection({ scope, worktree, visible, refreshTick = 0, onPreview, selectedRef, onClearPreview, onDetailsChange, onContextMenu }: GitGraphSectionProps) {
|
||||
export function GitGraphSection({ scope, worktree, visible, refreshTick = 0, onPreview, selectedRef, onClearPreview, onDetailsChange, onContextMenu, repoPicker }: GitGraphSectionProps) {
|
||||
const [branch, setBranch] = useState('')
|
||||
const [page, setPage] = useState<GraphPage | null>(null)
|
||||
const [branches, setBranches] = useState<GraphPage['branches']>([])
|
||||
@@ -350,6 +368,17 @@ export function GitGraphSection({ scope, worktree, visible, refreshTick = 0, onP
|
||||
return <section className={css.root} aria-label={t('gitGraph')} data-git-graph
|
||||
data-graph-count={page?.entries.length ?? 0}>
|
||||
<div className={css.toolbar}>
|
||||
{repoPicker && (
|
||||
<label className={css.repoPick} data-scm-repos>
|
||||
<select className={css.select} aria-label={t('gitRepository')}
|
||||
value={repoPicker.value} disabled={repoPicker.disabled}
|
||||
onChange={event => { repoPicker.onChooseRepo(event.target.value) }}>
|
||||
{repoPicker.standInLabel !== undefined &&
|
||||
<option value={repoPicker.value} disabled>{repoPicker.standInLabel}</option>}
|
||||
{repoPicker.labels.map(item => <option key={item.root} value={item.root}>{item.label}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
{linearFallback && <div role="status">{t('graphLinearFallback')}</div>}
|
||||
{!linearFallback && <select className={css.select} aria-label={t('graphBranchFilter')}
|
||||
value={branch} onChange={event => { chooseBranch(event.target.value) }}>
|
||||
|
||||
@@ -1133,27 +1133,6 @@ export function GitLens(props: GitLensProps) {
|
||||
{snapshot !== null && !isRepo && <Notice kind="empty" tone="page">{t('notRepo')}</Notice>}
|
||||
{snapshot?.truncated === true && <Notice kind="warn">{t('statusTruncated')}</Notice>}
|
||||
|
||||
{/* A container workspace can hold several independent repositories, and
|
||||
every view below is pinned to ONE of them — without this picker the
|
||||
panel silently shows the first root, so nothing on screen says the
|
||||
others exist. The picker is not a second source of truth:
|
||||
`repoChoices` comes from the status snapshot, `chooseRepo` re-pins
|
||||
the scope (reads, writes, graph) to the picked root. A labeled
|
||||
select keeps the current root on screen and the rest one click away
|
||||
however many repositories discovery finds. */}
|
||||
{isRepo && repoChoices.length > 1 && (
|
||||
<label className={css.repoPick} data-scm-repos>
|
||||
<span className={css.repoPickLabel}>{t('gitRepository')}</span>
|
||||
<select className={css.repoPickSelect} aria-label={t('gitRepository')}
|
||||
value={resolvedRepository ?? ''} disabled={busy || suggesting}
|
||||
onChange={event => { chooseRepo(event.target.value) }}>
|
||||
{resolvedRepository !== undefined && !repositoryLabels.some(item => item.root === resolvedRepository) &&
|
||||
<option value={resolvedRepository} disabled>{resolvedRepositoryLabel ?? t('gitRepository')}</option>}
|
||||
{repositoryLabels.map(item => <option key={item.root} value={item.root}>{item.label}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
|
||||
{isRepo && (
|
||||
<section className={css.changesSection} data-scm-section="changes">
|
||||
<div className={css.scmHeader}>
|
||||
@@ -1181,6 +1160,11 @@ export function GitLens(props: GitLensProps) {
|
||||
items={[
|
||||
{ id: 'pull', label: t('pull'), disabled: busy || suggesting || snapshot?.detached === true },
|
||||
{ id: 'push', label: t('push'), disabled: busy || suggesting || snapshot?.detached === true },
|
||||
...(repoChoices.length > 1 ? [{ id: 'repos', label: t('gitRepository'),
|
||||
submenu: repoChoices.map(root => ({ id: `repo:${root}`,
|
||||
label: repositoryLabels.find(item => item.root === root)?.label ?? baseName(root), disabled: busy || suggesting,
|
||||
})),
|
||||
}] : []),
|
||||
...(worktrees.length > 1 ? [{ id: 'worktrees', label: t('worktree'),
|
||||
submenu: worktrees.map(entry => ({ id: `worktree:${entry.path}`,
|
||||
label: `${entry.branch || t('gitDetached')} · ${baseName(entry.path)} (${entry.changes})`, disabled: busy || suggesting,
|
||||
@@ -1191,6 +1175,7 @@ export function GitLens(props: GitLensProps) {
|
||||
setMoreMenu(null)
|
||||
if (id === 'push') push()
|
||||
else if (id === 'pull') pull()
|
||||
else if (id.startsWith('repo:')) chooseRepo(id.slice(5))
|
||||
else if (id.startsWith('worktree:')) chooseWorktree(id.slice(9))
|
||||
}} />
|
||||
</div>
|
||||
@@ -1229,6 +1214,10 @@ export function GitLens(props: GitLensProps) {
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* The graph toolbar hosts the multi-repo picker at its head (repository
|
||||
first, then the branch filter — one scope row). The picker rides the
|
||||
section, so a folded graph hides it; the ⋯ → Repository submenu in
|
||||
the Changes header stays reachable as the fallback surface. */}
|
||||
{isRepo && <section className={graphOpen ? css.graphSection : undefined} data-scm-section="graph">
|
||||
<div className={css.scmHeader}>
|
||||
<button type="button" className={css.scmDisclosure} aria-expanded={graphOpen}
|
||||
@@ -1250,6 +1239,13 @@ export function GitLens(props: GitLensProps) {
|
||||
onClearPreview={() => { props.onClearPreview?.() }}
|
||||
onDetailsChange={props.onDetailsChange}
|
||||
onContextMenu={openHistoryMenu}
|
||||
repoPicker={repoChoices.length > 1 ? {
|
||||
labels: repositoryLabels,
|
||||
value: resolvedRepository ?? '',
|
||||
standInLabel: resolvedRepositoryLabel,
|
||||
disabled: busy || suggesting,
|
||||
onChooseRepo: chooseRepo,
|
||||
} : undefined}
|
||||
/>
|
||||
</div>}
|
||||
</section>}
|
||||
|
||||
@@ -58,37 +58,6 @@
|
||||
.scmHeader:hover .scmActions, .scmHeader:focus-within .scmActions { opacity: 1; }
|
||||
@media (hover: none) { .scmActions { opacity: 1; } }
|
||||
|
||||
/* Child repositories of a workspace container: every view in this panel is
|
||||
pinned to ONE root, so the picker is the only surface that names the current
|
||||
one and lists the others one click away. A labeled select scales to any
|
||||
number of discovered roots in a single compact band — a chip per root does
|
||||
not, once location labels distinguish same-named checkouts. The label
|
||||
mirrors the section headers; the box mirrors the graph's branch select. */
|
||||
.repoPick {
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
min-height: 28px;
|
||||
padding: 0 6px;
|
||||
font: var(--dsw-font-xxs-strong-12);
|
||||
color: var(--dsw-alias-label-primary);
|
||||
cursor: pointer;
|
||||
}
|
||||
.repoPickLabel { flex: none; white-space: nowrap; }
|
||||
.repoPickSelect {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
height: 28px;
|
||||
border: 1px solid var(--dsw-alias-border-l2);
|
||||
border-radius: 3px;
|
||||
background: var(--dsw-alias-bg-base);
|
||||
color: var(--dsw-alias-label-primary);
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
/* Docked by the flex column above (a sibling of `.gitScroll`), plus sticky so
|
||||
it also survives the case where the host tab body itself scrolls the whole
|
||||
tab — the branch control must never leave the bottom of the pane.
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
.root { display: flex; flex: 1; flex-direction: column; min-height: 0; min-width: 0; font: var(--dsw-font-xxs-12); color: var(--dsw-alias-label-primary); }
|
||||
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 12px; }
|
||||
.select { flex: 1; min-width: 0; max-width: 100%; height: 28px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 3px; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font: inherit; }
|
||||
/* The multi-repo picker slots in ahead of the branch filter so the toolbar
|
||||
reads as one scope row — root first, then its history filter. The slot
|
||||
flexes like .select, so both boxes share the row instead of stacking. */
|
||||
.repoPick { flex: 1; min-width: 0; display: flex; }
|
||||
.hint { color: var(--dsw-alias-label-secondary); font: var(--dsw-font-xxxs-11); }
|
||||
.scroll { flex: 1; min-height: 0; overflow: auto; }
|
||||
/* A commit row is ONE 28px line — rail, ref pills, subject (the GitLens-style
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
*
|
||||
* Contract:
|
||||
* - `git.status` reports `repositories` (every discovered root). When it holds
|
||||
* more than one, the lens renders a labeled <select> ("Repository") above
|
||||
* the Changes section: each option pairs the display-only disambiguation
|
||||
* more than one, the lens renders a labeled <select> ("Repository") at the
|
||||
* head of the commit-graph toolbar, ahead of the branch filter: each option
|
||||
* pairs the display-only disambiguation
|
||||
* label (`buildRepositoryLabels(roots, scope.cwd, hostHome)` — deeper roots
|
||||
* carry their relative parent, so same-named checkouts stay tellable apart)
|
||||
* with its absolute root as the value.
|
||||
@@ -19,8 +20,10 @@
|
||||
* so the next status read carries that root and the picker
|
||||
* survives the following read (a selected child still reports the full
|
||||
* `repositories` list).
|
||||
* - A single-repository workspace renders NO picker: the row must not steal
|
||||
* vertical space from the ordinary case.
|
||||
* - A single-repository workspace renders NO picker: nothing steals vertical
|
||||
* space from the ordinary case.
|
||||
* - The picker lives in the graph toolbar, so a folded graph hides it; the
|
||||
* ⋯ → Repository submenu stays reachable as the fallback surface.
|
||||
*/
|
||||
// @vitest-environment jsdom
|
||||
import { act } from 'react-dom/test-utils'
|
||||
|
||||
@@ -287,7 +287,7 @@ describe('GitLens (changes tab, git lens) linked-worktree consistency', () => {
|
||||
act(() => { document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })) })
|
||||
act(() => { document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })) })
|
||||
|
||||
// The standalone picker replaced the ⋯ → Repository submenu.
|
||||
// The toolbar picker stays alongside the ⋯ → Repository fallback submenu.
|
||||
const picker = container.querySelector<HTMLSelectElement>(`[data-scm-repos] select[aria-label="${t('gitRepository')}"]`)!
|
||||
await act(async () => { picker.value = REPO_A; picker.dispatchEvent(new Event('change', { bubbles: true })) })
|
||||
await flushEffects()
|
||||
|
||||
Reference in new issue
Block a user