fix(git): let commit graph fill available sidebar height

Replace the 460px viewport cap with flex allocation. Bound the graph section minimum so long history scrolls internally instead of stretching the outer list. Verify tall and narrow panes, preview selection, folding and long Changes lists in the mounted host.
This commit is contained in:
Menghuan1918 committed 2026-10-17 11:33:55 +08:00
1 parent 0c7868cc07
commit 38d94bdb98
7 files changed
+79 -7

No files matched your search

+1
View File
@@ -4,6 +4,7 @@
### Unreleased
- **提交图使用完整可用高度**:移除 `min(60vh, 460px)` 高度限制,更改区下方到固定底栏之间的空间全部分配给图谱;打开差异预览或缩放窗口时自动调整。长历史仍在图谱内部滚动,待提交文件很多时保留原有外层滚动,避免把整个页面撑高。
- **dsh-context 可选联动**:Context 侧栏入口可用时,在 Agent 详情、后台任务输出窗和会话标题栏提供诊断入口;后台任务仅查看明确的真实属主,不改变任务输出观察或停止命令的会话语义。跨会话先定位目标再打开 Context,复用其他分栏已有的标签;用户继续导航时取消,等待最多 10 秒。未安装、禁用或仅显示会话标签页时隐藏入口,不修改上下文、不恢复 Agent 执行,也不修改 dsh-context 偏好。全部入口共用 Cordis 作用域内的可选适配器,空闲时不新增轮询。
### v0.27.0
+1
View File
@@ -1151,6 +1151,7 @@ interface SettingsDescriptor {
- **拖拽区退出(视口层)**:宿主把每个**直挂 body 的子元素**都设成 `no-drag`(`html[data-platform=darwin] body > :not(#root)`,选择器含 id,只能靠 `!important` 压过),而 app-region **无视 `pointer-events`**——插件宿主就是这样一个 body 子元素,在 Electron 里该值还会传到它内部的**铺满视口的面板层**(#772 的 CDP 实测;挂载 lane 用的浏览器引擎不传播该属性,所以面板层自己也声明了同一条规则),于是它把下面每条 `[data-window-drag]` 拖拽带一起抵消(窗口拖一次就失效,同时丢掉 macOS 双击标题栏缩放,issue #772)。契约:装饰性的视口层用**中性值** `-webkit-app-region: initial !important` 退出计算(`initial` 的计算值 `none` 不扣减拖拽区;注意**字面量 `none` 不是中性值**——它计算成 `no-drag`,是扣减值),层内的面板/控件再声明 `no-drag` 保住点击;当前覆盖 `[data-dsh-better-sidebar]`、`[data-dsh-panel-host]`(`> *` 保持 `no-drag`)与 `.mermaidModal`(放大视图是第二个**持久**铺满视口的 body 直挂层)。**交互弹层不要加 `initial`**(`.selectionPopup` 是 `<button>`,`FloatingWindow` / `AnchoredPopover` 自带指针拖拽、不是遮罩层):宿主 `:is(button, a, input, …)` 已给它们 `no-drag`,反过来声明 `initial !important` 会让按下变成拖窗(重演 #103/#111)。放大视图是**遮罩层例外**——它是模态,只有其中的控件必须保持 `no-drag`;代价是它覆盖在顶部拖拽带上时,点背景会变成拖窗而不是关闭(为「放大图时窗口仍可拖」付的账)。**未纳入**:`FileTree` 的 `.uploadDropChatHint` 同样是 body 直挂的装饰层,但它只在 OS 文件拖拽悬停期间存在且 `pointer-events: none`,收益极小、暂不处理(`FloatingWindow` / `AnchoredPopover` 是交互层,按上面的判据本就该保持 `no-drag`)。形状由 `tests/panel-host-css.spec.ts` 在 Linux 的 `pnpm test` 里守护(无 macOS runner;`tests/theme.spec.ts` 只守颜色,故本轮不涉及),真实级联由挂载 lane 的探针按宿主规则断言计算值(面板宿主探针复现宿主两条 darwin 规则,放大视图探针直接用页面里宿主自己的规则)。
- **z-index**:面板宿主层 25、按钮簇 45——低于 DSH ui-cordis 插件面板(30)与浮层栈(100/1000+),浮层天然盖住侧边栏。
- **更改行选中态**:Git 文件行和本轮操作行保持原有布局;选中只绘制 `--dsw-alias-interactive-bg-active` 背景,以及行内 inset 4px、宽 2px 的 `--dsw-alias-state-business-primary` 标记。选中规则与缩进参考线的绝对定位规则必须分开;`tests/theme.spec.ts` 解析实际 CSS 规则守护,挂载测试验证点击后文件行仍在原分组内。
- **提交图高度**:更改区保持自然高度,提交图区填满固定底栏上方的剩余空间,不设 `vh` 或固定最大高度。展开的图谱分区以 248px(28px 标题 + 220px 视口)为最小高度参与 flex 分配,避免自动最小内容高度把长历史撑到外层;折叠后只保留标题,长历史在内部滚动;更改列表过长时仍由原外层滚动容器承载。预览区展开或窗口缩放后随可用空间调整,无需额外尺寸观察器。
- **Context 诊断入口与提示**:图标沿用宿主 `Button` 与 `IconContextInjectionOutlineRegular`,标题栏为固定宽度按钮。跨会话错误通过 `shell.overlay` 展示一条可关闭提示,背景取 `--dsw-alias-bg-layer-3`、边框与图标取 `--dsw-alias-state-warn-primary`、正文取 label 令牌;宽度受视口约束,目标名与错误文案允许任意位置换行。能力中途消失时仍保留本次错误,不依赖来源弹层继续挂载。
+2 -2
View File
@@ -1078,7 +1078,7 @@ export function GitLens(props: GitLensProps) {
{snapshot?.truncated === true && <Notice kind="warn">{t('statusTruncated')}</Notice>}
{isRepo && (
<section data-scm-section="changes">
<section className={css.changesSection} data-scm-section="changes">
<div className={css.scmHeader}>
<button type="button" className={css.scmDisclosure} aria-expanded={changesOpen}
onClick={() => { setChangesOpen(open => !open) }}>
@@ -1150,7 +1150,7 @@ export function GitLens(props: GitLensProps) {
</section>
)}
{isRepo && <section data-scm-section="graph">
{isRepo && <section className={graphOpen ? css.graphSection : undefined} data-scm-section="graph">
<div className={css.scmHeader}>
<button type="button" className={css.scmDisclosure} aria-expanded={graphOpen}
onClick={() => { setGraphOpen(open => !open) }}>
+7 -4
View File
@@ -44,12 +44,15 @@
min-width: 0;
overflow-y: auto;
overflow-x: hidden;
display: flex;
flex-direction: column;
}
/* The Graph section's own viewport: the graph keeps ONE scroll box (its rows
page in as it reaches the end), so the section is given a bounded height
inside the lens's scroller rather than being clipped by it. */
.graphArea { display: flex; flex-direction: column; height: min(60vh, 460px); min-height: 220px; }
.changesSection { flex: none; }
/* Bound the section's minimum, not its maximum: 28px header + 220px viewport.
An automatic minimum would let the entire history stretch the outer scroller. */
.graphSection { flex: 1; min-height: 248px; display: flex; flex-direction: column; }
.graphArea { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.scmHeader { display: flex; align-items: center; min-height: 28px; padding: 0 6px; }
.scmDisclosure { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; min-height: 28px; padding: 0; border: none; background: transparent; color: var(--dsw-alias-label-primary); font: var(--dsw-font-xxs-strong-12); text-align: left; cursor: pointer; }
+5
View File
@@ -897,6 +897,11 @@ describe('ChangesTab', () => {
expect(rule('.gitScroll')).toContain('overflow-y: auto')
expect(rule('.gitScroll')).toContain('overflow-x: hidden')
expect(rule('.gitScroll')).toContain('flex: 1')
expect(rule('.gitScroll')).toContain('flex-direction: column')
expect(rule('.changesSection')).toContain('flex: none')
expect(rule('.graphSection')).toContain('flex: 1')
expect(rule('.graphArea')).toContain('flex: 1')
expect(rule('.graphArea')).not.toContain('height: min(')
// Docked by flex, and sticky so a host-scrolled tab body cannot carry the
// branch control off the bottom of the pane either.
expect(rule('.gitFooter')).toContain('flex: none')
+44 -1
View File
@@ -15,6 +15,8 @@ test('read-only Git Graph renders merge history and filters without checkout', a
writeFileSync(join(root, 'base.txt'), 'base\n')
git('add', '.')
git('commit', '-m', 'Graph base')
// The final history exceeds one 50-row page; its viewport must still stay bounded.
for (let index = 0; index < 48; index++) git('commit', '--allow-empty', '-m', `History ${String(index)}`)
git('checkout', '-b', 'feature')
writeFileSync(join(root, 'feature.txt'), 'feature\n')
git('add', '.')
@@ -50,7 +52,20 @@ test('read-only Git Graph renders merge history and filters without checkout', a
const graph = page.locator('[data-git-graph]:visible')
await expect(graph.getByText('Graph merge', { exact: true }).first()).toBeVisible({ timeout: 30_000 })
await expect(graph.getByText('Graph feature', { exact: true }).first()).toBeVisible()
const expectGraphFillsHeight = async () => {
await expect.poll(() => page.evaluate(() => {
const graphBox = document.querySelector('[data-git-graph]')!.getBoundingClientRect()
const footer = document.querySelector('[data-git-footer]')!.getBoundingClientRect()
return Math.abs(footer.top - graphBox.bottom)
}), { message: 'the graph must use the available height above the footer' }).toBeLessThanOrEqual(1)
}
await page.setViewportSize({ width: 1440, height: 1400 })
await expectGraphFillsHeight()
const graphScroll = graph.locator(':scope > [aria-busy]')
expect(await graphScroll.evaluate(el => el.scrollHeight > el.clientHeight)).toBe(true)
await page.screenshot({ path: testInfo.outputPath('git-graph-tall.png'), fullPage: true })
await graph.getByText('Graph merge', { exact: true }).first().click()
await expectGraphFillsHeight()
// The selection opens the DETAILS card in the shared bottom pane: the full
// hash chip, both merge parents (7-char chips), and no first-parent note.
// Scope to the card — short hashes also appear in the (hidden) Git lens.
@@ -70,8 +85,36 @@ test('read-only Git Graph renders merge history and filters without checkout', a
await branchFilter.selectOption('refs/heads/feature')
await expect(graph.getByText('Graph merge', { exact: true })).toHaveCount(0)
await expect(graph.getByText('Graph feature', { exact: true }).first()).toBeVisible()
expect(errors).toEqual([])
expect({ head: git('rev-parse', 'HEAD'), refs: git('show-ref'), status: git('status', '--porcelain') }).toEqual(before)
await page.setViewportSize({ width: 1024, height: 800 })
await graph.getByText('Graph feature', { exact: true }).first().click()
await expect(page.locator('[class*="diffPane"]')).toBeVisible()
await expectGraphFillsHeight()
await page.screenshot({ path: testInfo.outputPath('git-graph-narrow-preview.png'), fullPage: true })
await graphHeader.click()
await expect(graph).toHaveCount(0)
expect(await page.locator('[data-scm-section="graph"]').evaluate(el => Math.round(el.getBoundingClientRect().height))).toBe(28)
await graphHeader.click()
await expect(graph).toBeVisible()
await expect(graph.locator('[data-graph-commit]')).toHaveCount(50)
await expectGraphFillsHeight()
// Stress the outer scroller only after verifying graph interactions are read-only.
for (let index = 0; index < 40; index++) writeFileSync(join(root, `change-${String(index)}.txt`), 'pending\n')
const changes = page.locator('[data-scm-section="changes"]')
await changes.getByRole('button', { name: 'Refresh', exact: true }).click()
await expect(changes.locator('[data-row="change-39.txt"]')).toHaveCount(1)
await expect(graphScroll).toHaveAttribute('aria-busy', 'false')
await expect(graph.locator('[data-graph-commit]')).toHaveCount(50)
const outer = page.locator('[data-git-scroll]')
expect(await outer.evaluate(el => el.scrollHeight > el.clientHeight)).toBe(true)
expect(await graph.evaluate(el => Math.round(el.getBoundingClientRect().height))).toBe(220)
await outer.evaluate(el => { el.scrollTop = el.scrollHeight })
await expectGraphFillsHeight()
await page.screenshot({ path: testInfo.outputPath('git-graph-long-changes.png'), fullPage: true })
await changes.locator(':scope > div > button[aria-expanded]').click()
await expectGraphFillsHeight()
expect(errors).toEqual([])
} finally {
await api.dispose()
// Fixture retained with test artifacts for inspecting failures; no shared-path cleanup.
+19
View File
@@ -172,6 +172,25 @@ describe('skin contract: the plugin owns no color of its own', () => {
}
})
it('the graph viewport fills its container without a viewport-relative height cap', () => {
const sheet = document.createElement('style')
sheet.textContent = readFileSync(resolve(ROOT, 'src/client/changes/changes.module.css'), 'utf8')
document.head.append(sheet)
try {
const rules = Array.from(sheet.sheet!.cssRules).filter((rule): rule is CSSStyleRule => 'selectorText' in rule)
const graph = rules.find(rule => rule.selectorText === '.graphArea')!.style
expect(graph.getPropertyValue('flex-grow')).toBe('1')
expect(graph.getPropertyValue('height')).toBe('')
expect(graph.getPropertyValue('max-height')).toBe('')
expect(Number.parseFloat(graph.getPropertyValue('min-height'))).toBe(0)
const section = rules.find(rule => rule.selectorText === '.graphSection')!.style
expect(section.getPropertyValue('min-height')).toBe('248px')
expect(section.getPropertyValue('max-height')).toBe('')
} finally {
sheet.remove()
}
})
it('selected change rows keep their layout and separate their accent from indent guides', () => {
const sheet = document.createElement('style')
sheet.textContent = readFileSync(resolve(ROOT, 'src/client/changes/changes.module.css'), 'utf8')