🐛 fix mobile drawer review regressions
This commit is contained in:
1 parent
453f93236d
commit
5e5346497c
30 files changed
+314
-82
No files matched your search
@@ -10,7 +10,7 @@ tooltips: sidebar and workspace controls escape the drawer and fit the viewport
|
||||
search input: 16px on touch; 13px with a fine pointer
|
||||
simulated keyboard: homepage and drawer retain 844px layout height without following the 360px visual viewport; Settings stays within the viewport
|
||||
keyboard close: layout height stays 844px; sidebar search retained; Settings close remains reachable
|
||||
safe areas: drawer backing and mask cover 844px; content retains 56px top and 34px bottom insets
|
||||
shell coverage: drawer backing and mask cover 844px without synthetic safe-area insets
|
||||
rotation: 844x390 then 390x844 restores shell height and sidebar breakpoint
|
||||
folded landscape: 951px frame splits at 475.5px without a resize handle; unfolding restores 280px and search focus; portrait retains the drawer
|
||||
fold transitions: sidebar controls follow the divider in both directions; reduced motion changes width without animation
|
||||
|
||||
@@ -331,12 +331,6 @@ it('overlays the conversation and closes after navigation without losing its sid
|
||||
await restoreViewport.dispose()
|
||||
await expect.poll(() => root.boundingBox()).toEqual({ x: 0, y: 0, width: 390, height: 844 })
|
||||
await expect.poll(async () => (await drawer.boundingBox())?.height).toBe(844)
|
||||
// Desktop Chromium supplies zero safe-area insets; exercise the shell's
|
||||
// inset properties with the same geometry as a phone's protected edges.
|
||||
await root.evaluate((el) => {
|
||||
el.style.setProperty('--dsh-safe-area-top', '56px')
|
||||
el.style.setProperty('--dsh-safe-area-bottom', '34px')
|
||||
})
|
||||
await frame.evaluate((el) => { el.scrollLeft = 10 })
|
||||
expect(await frame.evaluate(el => el.scrollLeft)).toBe(0)
|
||||
await expect.poll(() => mask.boundingBox()).toEqual({ x: 0, y: 0, width: 390, height: 844 })
|
||||
@@ -347,14 +341,6 @@ it('overlays the conversation and closes after navigation without losing its sid
|
||||
const { y, height } = column.getBoundingClientRect()
|
||||
return { y, height }
|
||||
})).toEqual({ y: 0, height: 844 })
|
||||
await expect.poll(async () => {
|
||||
const box = await drawer.boundingBox()
|
||||
return { y: box?.y, height: box?.height }
|
||||
}).toEqual({ y: 56, height: 754 })
|
||||
await root.evaluate((el) => {
|
||||
el.style.removeProperty('--dsh-safe-area-top')
|
||||
el.style.removeProperty('--dsh-safe-area-bottom')
|
||||
})
|
||||
await expect.poll(async () => (await drawer.boundingBox())?.height).toBe(844)
|
||||
await page.setViewportSize({ width: 844, height: 390 })
|
||||
await expect.poll(async () => (await root.boundingBox())?.height).toBe(390)
|
||||
@@ -471,7 +457,7 @@ it('overlays the conversation and closes after navigation without losing its sid
|
||||
'search input: 16px on touch; 13px with a fine pointer',
|
||||
'simulated keyboard: homepage and drawer retain 844px layout height without following the 360px visual viewport; Settings stays within the viewport',
|
||||
'keyboard close: layout height stays 844px; sidebar search retained; Settings close remains reachable',
|
||||
'safe areas: drawer backing and mask cover 844px; content retains 56px top and 34px bottom insets',
|
||||
'shell coverage: drawer backing and mask cover 844px without synthetic safe-area insets',
|
||||
'rotation: 844x390 then 390x844 restores shell height and sidebar breakpoint',
|
||||
'folded landscape: 951px frame splits at 475.5px without a resize handle; unfolding restores 280px and search focus; portrait retains the drawer',
|
||||
'fold transitions: sidebar controls follow the divider in both directions; reduced motion changes width without animation',
|
||||
@@ -577,3 +563,83 @@ it('uses arrows inside one tree entry and keeps pointer focus from pinning row a
|
||||
} finally { await browser.close() }
|
||||
} finally { await scaffold.close() }
|
||||
})
|
||||
|
||||
it('keeps drawer shortcuts and hit targets above fullscreen and floating right panels', async () => {
|
||||
const scaffold = await launchWebScaffold({
|
||||
extraOverlayPath: fileURLToPath(new URL('./pin-browse-picker.overlay.yml', import.meta.url)),
|
||||
})
|
||||
try {
|
||||
const workspace = await scaffold.ctx.workspaceRegistry.create(scaffold.workspaceCwd)
|
||||
const seed = await readFile(new URL('../../../snapshots/web/seeded-history/session.v3.jsonl', import.meta.url), 'utf8')
|
||||
const sessionId = await seedSession(scaffold, seed, 'session-c4421b66-252e-44c0-80ed-6e320abeba25')
|
||||
await workspace.attachSession(sessionId)
|
||||
await scaffold.ctx.sessionController.rename({ sessionId, title: 'Drawer overlay checks' })
|
||||
const browser = await chromium.launch()
|
||||
try {
|
||||
const page = await browser.newPage({ viewport: { width: 1280, height: 844 }, locale: 'en-US' })
|
||||
await page.addInitScript(() => { Object.defineProperty(navigator, 'platform', { value: 'MacIntel' }) })
|
||||
await page.goto(scaffold.authenticatedUrl)
|
||||
const row = page.getByRole('treeitem').filter({ has: page.getByText('Drawer overlay checks', { exact: true }) })
|
||||
await row.click()
|
||||
await page.locator('[data-sidebar-right-expand]').click()
|
||||
await page.locator('[data-sidebar-right-guide-entry="files"]').click()
|
||||
const panel = page.locator('[data-sidebar-right-open]')
|
||||
const primary = await page.evaluate(() => /mac/i.test(navigator.platform) ? 'Meta' : 'Control')
|
||||
const toggle = `${primary}+Alt+b`
|
||||
await row.hover()
|
||||
const card = page.getByRole('button', { name: 'Copy: Drawer overlay checks', exact: true })
|
||||
await card.waitFor()
|
||||
await page.setViewportSize({ width: 390, height: 844 })
|
||||
await card.waitFor({ state: 'hidden' })
|
||||
expect(await row.count()).toBe(1)
|
||||
const drawer = page.getByRole('dialog', { name: 'Navigation', exact: true })
|
||||
await expect.poll(() => panel.getAttribute('data-sidebar-right-panel')).toBe('fullscreen')
|
||||
const assertAboveRightPanel = async (coveredPoint?: { x: number; y: number }) => {
|
||||
await page.locator('[data-sidebar-drawer][data-sidebar-collapsed]').waitFor()
|
||||
await page.keyboard.press(toggle)
|
||||
await drawer.waitFor()
|
||||
const collapse = drawer.getByRole('button', { name: 'Collapse sidebar', exact: true })
|
||||
await expect.poll(() => collapse.evaluate(el => document.activeElement === el)).toBe(true)
|
||||
await expect.poll(() => drawer.evaluate((el) => {
|
||||
const box = el.getBoundingClientRect()
|
||||
return el.contains(document.elementFromPoint(box.left + 140, 30))
|
||||
})).toBe(true)
|
||||
expect(await page.evaluate(() => document.elementFromPoint(380, 420)?.hasAttribute('data-sidebar-mask'))).toBe(true)
|
||||
if (coveredPoint !== undefined) {
|
||||
expect(await drawer.evaluate((el, point) => {
|
||||
const hit = document.elementFromPoint(point.x, point.y)
|
||||
return el.contains(hit) || hit?.hasAttribute('data-sidebar-mask')
|
||||
}, coveredPoint)).toBe(true)
|
||||
}
|
||||
await page.keyboard.press(`${primary}+Alt+k`)
|
||||
await expect.poll(() => drawer.getByPlaceholder('Search session names').evaluate(el => document.activeElement === el)).toBe(true)
|
||||
await page.keyboard.press(toggle)
|
||||
await drawer.waitFor({ state: 'hidden' })
|
||||
expect(await panel.evaluate(el => el.closest('[inert]') === null)).toBe(true)
|
||||
}
|
||||
await assertAboveRightPanel()
|
||||
await page.setViewportSize({ width: 1280, height: 844 })
|
||||
await expect.poll(() => panel.getAttribute('data-sidebar-right-panel')).toBe('push')
|
||||
const tab = panel.locator('[data-dockkit-tab]').filter({ hasText: 'Files' })
|
||||
const bounds = (await tab.boundingBox())!
|
||||
await page.mouse.move(bounds.x + 6, bounds.y + bounds.height / 2)
|
||||
await page.mouse.down()
|
||||
try {
|
||||
await page.mouse.move(190, 400, { steps: 8 })
|
||||
} finally { await page.mouse.up() }
|
||||
const floating = page.locator('[data-dockkit-float]')
|
||||
await floating.waitFor()
|
||||
await page.setViewportSize({ width: 390, height: 844 })
|
||||
const box = (await floating.boundingBox())!
|
||||
expect(box.x).toBeLessThan(390)
|
||||
expect(box.x + box.width).toBeGreaterThan(0)
|
||||
const point = { x: (Math.max(0, box.x) + Math.min(390, box.x + box.width)) / 2, y: box.y + 40 }
|
||||
await expect.poll(() => floating.evaluate((el, at) => el.contains(document.elementFromPoint(at.x, at.y)), point)).toBe(true)
|
||||
await assertAboveRightPanel(point)
|
||||
} finally {
|
||||
await browser.close()
|
||||
}
|
||||
} finally {
|
||||
await scaffold.close()
|
||||
}
|
||||
})
|
||||
@@ -18,8 +18,8 @@
|
||||
en: ea872ff2c2089037
|
||||
zh: b3ec3a218eacd5c8
|
||||
/deepseek-ai-dsh-client-ui-dockkit/embedding-it:
|
||||
en: 47b9852393643b6a
|
||||
zh: ce5f2ab60eec9564
|
||||
en: 78bf57f52daa97cb
|
||||
zh: 0a057bf648f7667a
|
||||
/deepseek-ai-dsh-client-ui-dockkit/interaction-rules-worth-keeping:
|
||||
en: 7e5c1e9a9f9f244f
|
||||
zh: 7e3a8fcef86bc7dd
|
||||
|
||||
@@ -56,6 +56,8 @@ Everything host-specific arrives through props:
|
||||
|
||||
`dropZones="horizontal"` offers two half-pane hints; once budget or width forbids another split, the whole body accepts a move. A hint is a dashed card inset 8px inside its region, showing the zone's glyph and `labels.dropZone[zone]`; the preview layer covers all tab-body content, while the card under the pointer takes the accent and its neighbour stays a quiet outline. `minPaneFraction` sets the preview minimum, and `planResizeSplit` accepts the same minimum for the committed operation. The Sidebar uses 0.2 and enforces two panes in its own store. The generic engine retains its tree and other split directions. `hideSplitWhenBlocked` hides a blocked split control — pane budget spent or pane too narrow — instead of rendering it disabled; its default is false.
|
||||
|
||||
The split control wrapper exposes `data-dockkit-split-control` for embedder styling, independently of its element tag.
|
||||
|
||||
A tab's `kind` is an opaque string. Seeded tabs are factories (`DockControllerOptions`), so what a fresh pane contains is the embedder's decision, not this package's. Content identity is the pair (`kind`, `contentId`): `findContentTab(state, contentId, kind?)` finds the tab showing it anywhere and `findPaneContentTab(state, paneId, contentId, kind?)` within one pane, and `planOpenContent` focuses that tab instead of opening another unless told `revealIfOpened: false`; an explicit `index` seats a new tab at a strip slot rather than at the end.
|
||||
|
||||
`DockLayout`, used by the Sidebar, keeps each tab in a stable DOM cell across selection, pane moves and floating. It accepts one docked pane or two horizontal panes; CSS Grid resolves their widths. `keepMounted(tab)` retains visited bodies and `active` controls Session visibility without reparenting content.
|
||||
|
||||
@@ -56,6 +56,8 @@ kind: "package-reference"
|
||||
|
||||
`dropZones="horizontal"` 提供左右两个半区提示;预算或宽度不允许再拆时,正文整格接收移动。提示是一张内缩 8px 的虚线卡片,显示该落区的图形和 `labels.dropZone[zone]`;预览层覆盖全部 tab 正文,指针所在的卡片取强调色,另一张保持安静的轮廓。`minPaneFraction` 控制预览的最小比例,`planResizeSplit` 接受相同最小值以约束提交;Sidebar使用0.2并在自己的store限制两格。通用引擎仍保留原有树与其它分割方向。 `hideSplitWhenBlocked` 在分栏被阻止时(窗格预算已满或格太窄)直接隐藏分栏控件而不是渲染禁用态,默认值为 false。
|
||||
|
||||
分栏控件的包裹元素通过 `data-dockkit-split-control` 提供宿主样式入口,不依赖具体元素标签。
|
||||
|
||||
tab 的 `kind` 是不透明字符串。种子 tab 是工厂(`DockControllerOptions`),因此新格里放什么由嵌入方决定,与本包无关。内容身份是二元组(`kind`、`contentId`):`findContentTab(state, contentId, kind?)` 在任意位置找到展示它的 tab,`findPaneContentTab(state, paneId, contentId, kind?)` 在一个格内找;`planOpenContent` 会聚焦该 tab 而非再开一个,除非被告知 `revealIfOpened: false`;显式的 `index` 把新 tab 放到 tab 条的某个位置而非末尾。
|
||||
|
||||
Sidebar 使用的 `DockLayout` 在选中项变化、跨格移动与浮动期间,把每个 tab 保留在稳定的 DOM 容器中。它接受一个停靠格或左右两个格,由 CSS Grid 计算宽度。`keepMounted(tab)` 保留已访问正文,`active` 控制 Session 可见性,不改变内容的父子关系。
|
||||
|
||||
@@ -367,6 +367,7 @@ export function TabStrip({ state, pane, callbacks }: TabPanelProps): ReactNode {
|
||||
{!(callbacks.hideSplitWhenBlocked && block !== undefined) && (
|
||||
<Tooltip label={block === undefined ? callbacks.labels.splitPane : splitBlockedTitle(callbacks.labels, block)} shortcutKeys={callbacks.labels.splitPaneKeys} side="bottom" delayMs={500}>
|
||||
<span
|
||||
data-dockkit-split-control
|
||||
tabIndex={block === undefined ? undefined : 0}
|
||||
aria-label={block === undefined ? undefined : splitBlockedTitle(callbacks.labels, block)}
|
||||
>
|
||||
|
||||
@@ -280,6 +280,7 @@ describe('DockSurface', () => {
|
||||
expect(disabled.hasAttribute('disabled')).toBe(true)
|
||||
expect(disabled.parentElement?.getAttribute('aria-label')).toBe(TEST_LABELS.splitPaneDisabled)
|
||||
expect(disabled.getAttribute('data-dockkit-split-blocked')).toBe('budget')
|
||||
expect(disabled.parentElement?.hasAttribute('data-dockkit-split-control')).toBe(true)
|
||||
})
|
||||
|
||||
it('names the enabled split control through the shared tooltip, not a native title', () => {
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
en: d152484eb41ac6b4
|
||||
zh: 09388d293f9be9cb
|
||||
/deepseek-ai-dsh-client-ui-layout/use-this-package:
|
||||
en: 38023531069269dd
|
||||
zh: f8ae2ad72cadc56a
|
||||
en: 762116247685afd7
|
||||
zh: cfb0767cb6c7e923
|
||||
/deepseek-ai-dsh-client-ui-layout/use-this-package/window-chrome-seat:
|
||||
en: 7eac53b38d0777fe
|
||||
zh: 7f9422dff671ba50
|
||||
|
||||
@@ -25,13 +25,13 @@ This package provides the Web GUI's three-column AppFrame, edge-column widths, a
|
||||
<a id="use-this-package"></a>
|
||||
## Use this package
|
||||
|
||||
Desktop Mod+B toggles the left sidebar through the same layout action used by its controls. The shortcut command is unavailable behind modal dialogs and yields to terminal input.
|
||||
Desktop Mod+B toggles the left sidebar through the same layout action used by its controls. The shortcut remains available inside the navigation drawer, is unavailable behind other modal dialogs, and yields to terminal input.
|
||||
|
||||
The root slot composes the sidebar, main content, and right column. The sidebar spans 264–420px, defaults to 280px, and retains a 56px rail when collapsed at widths of 768px and above. Below 768px, without a native Windows caption, it uses a modal drawer without reserving a column; the header retains the reopen controls, and navigation closes the drawer. Below 1024px it collapses automatically, and opening the right panel collapses a manually expanded sidebar. The right panel first opens at 45% of the viewport, then retains the user's pixel preference, capped at 70%. To protect 400px for the center, the frame first reduces the right panel to 300px, then reports insufficient room so its occupant closes it, and only then compresses the center further. Dragging has no transition delay; the right handle is absent while closed or fullscreen.
|
||||
|
||||
When the browser reports a folded device in landscape and the frame is at least 768px wide, the expanded sidebar occupies half the frame, aligning its divider with the center fold. Its resize handle is hidden; unfolding restores the saved width. Fold changes at a stable viewport width use the existing track transition; reduced motion disables it. Browsers without the device-posture media feature keep the ordinary layout.
|
||||
|
||||
The drawer mask fades with the panel’s transition duration and easing on both open and close; reduced motion disables both transitions. Entering drawer mode from an already collapsed sidebar hides the drawer immediately; an expanded sidebar keeps its closing slide. The drawer has no edge divider, and its frame does not scroll. The frame fills the shell’s layout viewport, retaining its height while the keyboard opens. Drawer backing and mask cover its full height, including the top and bottom safe areas and `shell.bottom`; frame and drawer content retain the safe-area insets once.
|
||||
The drawer mask fades with the panel’s transition duration and easing on both open and close; reduced motion disables both transitions. Entering drawer mode from an already collapsed sidebar hides the drawer immediately; an expanded sidebar keeps its closing slide. The drawer has no edge divider, and its frame does not scroll. The frame fills the shell’s layout viewport, retaining its height while the keyboard opens. Drawer backing and mask cover the shell’s full height, including `shell.bottom`, above fullscreen and floating right panels. Browser-owned status and address bars remain outside the shell; the layout adds no synthetic safe-area insets.
|
||||
|
||||
Global panels occupy the root-scoped `main` keyed slot; `conversation` is the reserved key for the Conversation. `ctx.layout.selectPanel(id)` selects a registered panel, and `null` selects the Conversation without changing the current Session. The Plugins page contributes one of the shipped global panels.
|
||||
|
||||
|
||||
@@ -25,13 +25,13 @@ kind: "package-reference"
|
||||
<a id="use-this-package"></a>
|
||||
## 使用本包
|
||||
|
||||
桌面 Mod+B 通过与控件共用的布局操作切换左侧栏。模态弹窗打开时此快捷键不可用;终端输入优先。
|
||||
桌面 Mod+B 通过与控件共用的布局操作切换左侧栏。此快捷键在导航抽屉内仍可用,在其他模态弹窗打开时不可用;终端输入优先。
|
||||
|
||||
本插件在 root slot 中组合侧边栏、主内容和右栏。侧边栏宽度为 264~420px,默认为 280px,在宽度不低于 768px 时,收起后保留 56px 控制栏。低于 768px 且没有原生 Windows 顶栏时,采用模态抽屉,不占据列宽;标题区域保留重新打开的控件,导航后关闭抽屉。窗口宽度低于 1024px 时自动收起,打开右侧面板也会收起手动展开的侧边栏。右侧面板首次打开时使用视口宽度的 45%,之后保留用户的像素宽度偏好,上限为 70%。为给中栏保留 400px,框架先将右侧面板缩减至 300px,再报告空间不足,使占用方将其关闭,最后才进一步压缩中栏。拖动没有过渡延迟;右侧手柄在关闭或全屏时不显示。
|
||||
|
||||
当浏览器报告设备处于横屏半折叠状态,且框架宽度不低于 768px 时,展开的侧边栏占据一半宽度,分隔线与屏幕中央的折痕对齐。此时隐藏拖拽手柄;完全展开后恢复保存的宽度。视口宽度不变时,折叠状态切换复用现有的列宽过渡;减少动态效果时禁用该过渡。不支持 device-posture 媒体特性的浏览器继续使用常规布局。
|
||||
|
||||
抽屉遮罩使用与面板相同的时长和缓动,在打开与关闭时渐变透明度;减少动态效果时两者均不播放动画。从已收起的侧栏切换到抽屉布局时,抽屉立即隐藏;已展开的侧栏保留收起动画。抽屉边缘不绘制分隔线,外层框架不滚动。框架铺满外壳的布局视口,在键盘抬起时保留原有高度。抽屉背景和遮罩覆盖完整高度,包括上下安全区与 `shell.bottom`;框架和抽屉的内容各保留一次安全区边距。
|
||||
抽屉遮罩使用与面板相同的时长和缓动,在打开与关闭时渐变透明度;减少动态效果时两者均不播放动画。从已收起的侧栏切换到抽屉布局时,抽屉立即隐藏;已展开的侧栏保留收起动画。抽屉边缘不绘制分隔线,外层框架不滚动。框架铺满外壳的布局视口,在键盘抬起时保留原有高度。抽屉背景和遮罩覆盖外壳完整高度,包括 `shell.bottom`,并显示在全屏和浮动右侧面板之上。浏览器管理的状态栏和地址栏位于外壳之外;布局不添加模拟安全区边距。
|
||||
|
||||
全局面板占据 root 作用域的 `main` keyed slot;`conversation` 是为会话界面保留的 key。`ctx.layout.selectPanel(id)` 选中已注册面板,`null` 则选中会话界面,但不改变当前会话。Plugins 页面是默认组合中的一个全局面板。
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
grid-template-rows: minmax(0, 1fr) auto;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
padding-block: var(--dsh-safe-area-top, 0px) var(--dsh-safe-area-bottom, 0px);
|
||||
overflow: hidden;
|
||||
background: var(--dsw-alias-bg-base);
|
||||
}
|
||||
@@ -299,10 +298,9 @@
|
||||
position: absolute;
|
||||
grid-area: auto;
|
||||
inset: 0 auto 0 0;
|
||||
z-index: 31;
|
||||
z-index: 71;
|
||||
box-sizing: border-box;
|
||||
border-right: none;
|
||||
padding-block: var(--dsh-safe-area-top, 0px) var(--dsh-safe-area-bottom, 0px);
|
||||
transform: translateX(0);
|
||||
visibility: visible;
|
||||
transition: transform var(--ds-transition-duration-slow) var(--ds-ease-in-out);
|
||||
@@ -323,7 +321,7 @@
|
||||
.drawerMask {
|
||||
position: absolute;
|
||||
inset: var(--dsh-frame-chrome-top, 0px) 0 0;
|
||||
z-index: 30;
|
||||
z-index: 70;
|
||||
background: var(--dsw-alias-bg-mask-1);
|
||||
backdrop-filter: var(--dsw-mask-blur);
|
||||
opacity: 0;
|
||||
@@ -337,7 +335,7 @@
|
||||
}
|
||||
|
||||
.frame[data-sidebar-drawer] .leadingSeat {
|
||||
top: calc(11px + var(--dsh-safe-area-top, 0px));
|
||||
top: 11px;
|
||||
left: 12px;
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ export function apply(ctx: ClientContext): void {
|
||||
'web:macos': { code: 'KeyB', modifiers: ['primary', 'alt'] },
|
||||
'web:windows': { code: 'KeyB', modifiers: ['primary', 'alt'] },
|
||||
},
|
||||
regions: ['page', 'editable'], modals: [],
|
||||
regions: ['page', 'editable'], modals: ['sidebar'],
|
||||
resolve: () => ({ status: 'handled', run: () => { layout.toggleSidebar() } }),
|
||||
})
|
||||
const disposePanels = ctx.slots.subscribe('main', retainMainPanels)
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
en: cb874a0ca53a6747
|
||||
zh: 31179193dd1d6e12
|
||||
/deepseek-ai-dsh-client-ui-primitives/use-this-package/controls-and-icons:
|
||||
en: 09c61f61c560f8a2
|
||||
zh: 895ac73add1199b8
|
||||
en: 9400611fcfd53402
|
||||
zh: 753dedbcaafba974
|
||||
/deepseek-ai-dsh-client-ui-primitives/use-this-package/rendering-agent-output:
|
||||
en: 3a31ad8de6dd0af8
|
||||
zh: 6b22881a929c33df
|
||||
|
||||
@@ -96,6 +96,8 @@ The catalog above lists what each export is for; this section covers the behavio
|
||||
|
||||
`HoverCardGroup` owns private state for one mounted physical list. A `HoverCard` with `grouped` shares the first actually displayed card's dwell: subsequent cards replace the current card immediately during the same pointer interaction. The list and its active portaled card form one pointer interaction: the pointer may enter the card to read or copy, then return to another list item for immediate replacement. After the pointer leaves both, the shared dwell resets when the active card closes through its existing pointer-grace and close lifecycle; the group adds no separate timer. Leaving a list with no active card resets the dwell immediately. Opening an inline card by keyboard focus while the pointer is outside the list does not warm the next pointer visit. Exclusive display includes fading previews: ordinary preview dismissal retains its fade, but a group replacement removes the previous card immediately. Cards without `grouped` remain independent.
|
||||
|
||||
An open hover card closes immediately when an ancestor of its anchor becomes inert or hidden.
|
||||
|
||||
### Rendering agent output
|
||||
|
||||
The nearest `MarkdownDelegateProvider` supplies optional `openExternalLink` and `openFile` navigation callbacks. Nested providers replace the enclosing capabilities, and callback changes reach already-rendered links without rebuilding Markdown. Its `openFile` makes local Markdown links clickable after settlement. Absolute and workspace-relative paths support percent escapes and `#L24` / `#L24-L30` fragments; ranges open at their first line. Literal `?` and `#` in filenames must be percent-encoded. The tooltip uses the decoded path and supplies the accessible name when the label is empty. The callback receives the decoded path and optional line, while the renderer preserves the label and displays a file icon. Without a callback, local links remain text. URL schemes, queries, unsupported fragments, and malformed destinations never reach the file opener.
|
||||
|
||||
@@ -96,6 +96,8 @@ kind: "package-library"
|
||||
|
||||
`HoverCardGroup` 为一个已挂载的物理列表持有私有状态。设置 `grouped` 的 `HoverCard` 共享首张实际显示卡片的等待:在同一次指针交互中,后续卡片立即替换当前卡片。列表与其当前活动的 portal 卡片构成一次指针交互:指针可进入卡片阅读或复制,再返回其他列表项并立即替换卡片。指针离开两者后,共享等待在活动卡片通过原有指针宽限及关闭生命周期关闭时重置;分组不另设计时器。列表没有活动卡片时,指针离开便立即重置等待。指针位于列表外时,通过键盘聚焦打开行内卡片不会让下一次指针进入跳过等待。互斥显示也包括正在淡出的预览:普通预览关闭保留淡出,但分组内替换会立即移除前一张卡片。未设置 `grouped` 的卡片保持独立。
|
||||
|
||||
锚点的祖先变为 inert 或隐藏时,已打开的悬浮卡片立即关闭。
|
||||
|
||||
### 渲染 agent 输出
|
||||
|
||||
最近的 `MarkdownDelegateProvider` 提供可选的 `openExternalLink` 和 `openFile` 导航回调。嵌套 Provider 替换外层能力,回调变化无需重新构建 Markdown 即可到达已渲染链接。其 `openFile` 使本地 Markdown 链接在落定后可点击。绝对路径和工作区相对路径支持百分号转义以及 `#L24` / `#L24-L30` 片段;范围定位到起始行。文件名中的字面 `?` 和 `#` 必须百分号编码。悬停提示使用解码后的路径,并在标签为空时提供可访问名称。回调接收解码后的路径和可选行号,渲染器保留标签并显示文件图标。不传回调时,本地链接仍为文本。URL 协议、查询串、不支持的片段及格式错误的目标不会传给文件打开器。
|
||||
|
||||
@@ -159,6 +159,10 @@ export function HoverCard({
|
||||
const wrapper = rootRef.current
|
||||
/* v8 ignore next -- the ref is attached before the layout effect runs and the listeners die with it. */
|
||||
if (wrapper === null) return
|
||||
if (wrapper.closest('[inert], [hidden]') !== null) {
|
||||
dismissImmediately()
|
||||
return
|
||||
}
|
||||
const r = wrapper.getBoundingClientRect()
|
||||
const h = cardRef.current?.offsetHeight ?? 0
|
||||
if (variant === 'preview') {
|
||||
@@ -197,6 +201,11 @@ export function HoverCard({
|
||||
setPos({ left: r.right + ANCHOR_GAP, top })
|
||||
}
|
||||
place()
|
||||
// Observe only the anchor's ancestors: an offscreen drawer can hide without resizing its retained row.
|
||||
const visibility = new MutationObserver(place)
|
||||
for (let ancestor = rootRef.current?.parentElement; ancestor != null; ancestor = ancestor.parentElement) {
|
||||
visibility.observe(ancestor, { attributes: true, attributeFilter: ['inert', 'hidden'] })
|
||||
}
|
||||
const observer = (variant === 'preview' || inline) && typeof ResizeObserver !== 'undefined' ? new ResizeObserver(place) : null
|
||||
for (const element of [cardRef.current, rootRef.current, widthAnchorRef?.current]) {
|
||||
if (element !== null && element !== undefined) observer?.observe(element)
|
||||
@@ -205,10 +214,11 @@ export function HoverCard({
|
||||
window.addEventListener('resize', place)
|
||||
return () => {
|
||||
observer?.disconnect()
|
||||
visibility.disconnect()
|
||||
window.removeEventListener('scroll', place, true)
|
||||
window.removeEventListener('resize', place)
|
||||
}
|
||||
}, [open, variant, widthAnchorRef, positioned, inline])
|
||||
}, [open, variant, widthAnchorRef, positioned, inline, dismissImmediately])
|
||||
|
||||
// The first placement ran before the card mounted (height read 0): once the
|
||||
// card's real height is measurable, correct the bottom-edge clamp. The
|
||||
|
||||
@@ -96,6 +96,22 @@ describe('HoverCard', () => {
|
||||
expect(screen.getByRole('tooltip').textContent).toBe('Details')
|
||||
})
|
||||
|
||||
it.each(['inert', 'hidden'])('dismisses a portal when its retained anchor ancestor becomes %s', async (attribute) => {
|
||||
const view = render(<section><HoverCard anchor={<span>row</span>} content={<div>card body</div>} /></section>)
|
||||
const row = screen.getByText('row')
|
||||
const wrapper = row.parentElement!
|
||||
fireEvent.pointerEnter(wrapper)
|
||||
act(() => { vi.advanceTimersByTime(500) })
|
||||
expect(screen.getByText('card body')).toBeTruthy()
|
||||
await act(async () => { view.container.firstElementChild!.setAttribute(attribute, '') })
|
||||
expect(screen.queryByText('card body')).toBeNull()
|
||||
expect(screen.getByText('row')).toBe(row)
|
||||
view.container.firstElementChild!.removeAttribute(attribute)
|
||||
fireEvent.pointerEnter(wrapper)
|
||||
act(() => { vi.advanceTimersByTime(500) })
|
||||
expect(screen.getByText('card body')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('opens after the dwell delay, positioned right of the anchor', () => {
|
||||
const { wrapper } = mount()
|
||||
fireEvent.pointerEnter(wrapper)
|
||||
|
||||
@@ -157,7 +157,7 @@
|
||||
|
||||
@media (pointer: coarse) {
|
||||
/* Retain the footprint so hiding the control cannot change its room measurement. */
|
||||
.panelBody :global(span:has(> [data-dockkit-split-blocked])) {
|
||||
.panelBody :global([data-dockkit-split-control]:has(> [data-dockkit-split-blocked])) {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
en: d152484eb41ac6b4
|
||||
zh: 09388d293f9be9cb
|
||||
/deepseek-ai-dsh-client-ui-sidebar/use-this-package:
|
||||
en: abeb2c660306846e
|
||||
zh: 807296f5830a60ea
|
||||
en: 90255789ba8051e5
|
||||
zh: 8fa1d34539f58e2e
|
||||
/deepseek-ai-dsh-client-ui-sidebar/use-this-package/brand-and-new-session:
|
||||
en: e68a91220fd47f98
|
||||
zh: 531277d0fc42767f
|
||||
|
||||
@@ -29,7 +29,7 @@ The dsh web client sidebar lets users recognize the active build, start a new se
|
||||
|
||||
The sidebar is the navigation shell: users see the brand, start new sessions, collapse the rail, and reach Settings. Feature plugins fill its seats — ui-workspace fills `sidebar.workspaces`, ui-settings registers the trigger row and settings panel at `sidebar.settings`.
|
||||
|
||||
Below 768px, without a native Windows caption, the sidebar keeps its expanded content mounted inside the frame's drawer. The drawer traps keyboard focus, closes with Escape or a mask press, and restores the invoking control unless a foreground dialog remains open. When an open drawer becomes a collapsed rail, focus transfers to the rail toggle if the invoking control unmounts and focus remains in the sidebar. Returning from a closed drawer renders the compact rail immediately, without a crossfade. Its toggle tooltip renders outside the drawer. Opening it does not resize the conversation.
|
||||
Below 768px, without a native Windows caption, the sidebar keeps its expanded content mounted inside the frame's drawer. The drawer initially focuses its collapse toggle, traps keyboard focus, closes with Escape or a mask press, and restores the invoking control unless a foreground dialog remains open. When an open drawer becomes a collapsed rail, focus transfers to the rail toggle if the invoking control unmounts and focus remains in the sidebar. Returning from a closed drawer renders the compact rail immediately, without a crossfade. Its toggle tooltip renders outside the drawer. Opening it does not resize the conversation.
|
||||
|
||||
### Brand and New Session
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ dsh Web 客户端的侧边栏让用户识别当前构建、启动新会话、将
|
||||
|
||||
侧边栏是导航外壳:用户看到品牌、启动新会话、折叠轨道并到达 Settings。功能插件填充它的席位——ui-workspace 填充 `sidebar.workspaces`,ui-settings 在 `sidebar.settings` 注册触发行与设置面板。
|
||||
|
||||
宽度低于 768px 且没有原生 Windows 顶栏时,侧边栏在框架抽屉内保留展开内容。抽屉限制键盘焦点范围,支持 Escape 和点击蒙层关闭,并在没有上层弹窗时将焦点还给打开它的控件。打开的抽屉切换为收起图标栏时,若打开入口已卸载且焦点仍在侧栏内,焦点转交给图标栏开关。关闭的抽屉切回图标栏时,立即使用紧凑布局,不播放交叉淡入淡出。开关的提示气泡在抽屉外渲染。打开抽屉不改变会话宽度。
|
||||
宽度低于 768px 且没有原生 Windows 顶栏时,侧边栏在框架抽屉内保留展开内容。抽屉首先聚焦收起按钮,并限制键盘焦点范围,支持 Escape 和点击蒙层关闭,并在没有上层弹窗时将焦点还给打开它的控件。打开的抽屉切换为收起图标栏时,若打开入口已卸载且焦点仍在侧栏内,焦点转交给图标栏开关。关闭的抽屉切回图标栏时,立即使用紧凑布局,不播放交叉淡入淡出。开关的提示气泡在抽屉外渲染。打开抽屉不改变会话宽度。
|
||||
|
||||
### 品牌与 New Session
|
||||
|
||||
|
||||
@@ -245,6 +245,7 @@ export function SidebarRoot({
|
||||
<Tooltip label={toggleLabel} shortcutKeys={shortcut?.keys} delayMs={500} side={captionTooltipSide} portal={drawer}>
|
||||
<button
|
||||
ref={toggleButton}
|
||||
data-modal-autofocus={drawer || undefined}
|
||||
type="button"
|
||||
className={clsx(css.iconButton, css.toggle)}
|
||||
aria-label={toggleLabel}
|
||||
@@ -267,6 +268,7 @@ export function SidebarRoot({
|
||||
<div
|
||||
ref={column}
|
||||
role={drawer ? 'dialog' : undefined}
|
||||
data-shortcut-modal={drawer ? 'sidebar' : undefined}
|
||||
aria-modal={drawer && !collapsed ? true : undefined}
|
||||
aria-label={drawer ? t('navigation.label') : undefined}
|
||||
tabIndex={drawer ? -1 : undefined}
|
||||
|
||||
@@ -418,6 +418,8 @@ it('retains drawer content through close and restores focus without entering an
|
||||
const h = mountShell({ drawer: true })
|
||||
const dialog = screen.getByRole('dialog', { name: 'Navigation' })
|
||||
expect(dialog.getAttribute('aria-modal')).toBe('true')
|
||||
expect(dialog.getAttribute('data-shortcut-modal')).toBe('sidebar')
|
||||
expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Collapse sidebar' }))
|
||||
expect(dialog.contains(document.activeElement)).toBe(true)
|
||||
const region = screen.getByTestId('region')
|
||||
fireEvent.keyDown(document.activeElement!, { key: 'Escape' })
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
en: 29facc4eae028dae
|
||||
zh: 754ebac4cc294e65
|
||||
/deepseek-ai-dsh-client-ui-workspace/use-this-package/managing-sessions:
|
||||
en: 93e93bc4687f87ab
|
||||
zh: 4a913b48690b3f25
|
||||
en: 0d7cdaeae0c4f091
|
||||
zh: d215741831966165
|
||||
/deepseek-ai-dsh-client-ui-workspace/use-this-package/pending-interactions:
|
||||
en: 9fb88260380bf093
|
||||
zh: 3bace2b96ecd4a82
|
||||
@@ -36,8 +36,8 @@
|
||||
en: 0ae90db57a09c62c
|
||||
zh: 453f350f1dea2ac4
|
||||
/deepseek-ai-dsh-client-ui-workspace/understand-the-implementation:
|
||||
en: f3359f823f3f0bcf
|
||||
zh: a7529c1d078a427f
|
||||
en: a77669e375db58bc
|
||||
zh: 8d4dfbf745cd8bf8
|
||||
/deepseek-ai-dsh-client-ui-workspace/understand-the-implementation/the-directory-flow-hole:
|
||||
en: 868904dbfb5713f8
|
||||
zh: 225906bfef7398bf
|
||||
|
||||
@@ -53,7 +53,7 @@ Collapsed search is one header action beside the view and add actions: activatin
|
||||
|
||||
### Managing sessions
|
||||
|
||||
Session row actions appear on hover for devices that support hovering. On devices without hover, selecting a non-blank Session keeps More visible in place of its trailing time. The built-in archive and pin buttons stay hidden there; both actions remain in More, and the static pin marker remains visible. Plugin row actions retain their registered presentation. An open row menu keeps its action strip visible on either device type.
|
||||
Session row actions appear on hover for devices that support hovering. On devices without hover, every non-blank Session keeps More visible alongside its trailing time and static pin marker. Quick-action buttons stay hidden there; the built-in archive and pin actions remain available through More. Workspace row actions appear only while that Workspace is expanded, leaving collapsed folders focused on navigation. An open row menu keeps its action strip visible on either device type.
|
||||
|
||||
The final built-in item in a Session row's "..." menu is Copy Session ID. It closes the menu and copies the complete ID directly, without opening a dialog. Clipboard success or failure appears in the global toast; a failed copy can be retried from the menu. Copying does not retain the Session, load its history, or call the Host.
|
||||
|
||||
@@ -63,7 +63,7 @@ Archive commits without a confirmation dialog for a quiet Session and retains th
|
||||
|
||||
Session update times use the tertiary label color, including on archived rows. A Session title wider than its row is clipped with an ellipsis at rest. Hovering the row scrolls the title to its far edge — the incremented title of a fork, for example — and reveals it without the ellipsis; leaving the row returns the title to its start.
|
||||
|
||||
The keyboard reference exposes New Session, Search sessions, Add workspace, Rename session, Fork session, and Archive session. Desktop defaults use the platform's primary modifier, with Mod+K for search; Windows and macOS Web use the [shortcut service’s platform defaults](../shortcuts/README.md); Linux Web leaves these commands unbound until configured. Button tooltips and Session row menus display the effective bindings. Clicking a menu item targets that row; pressing its shortcut targets the main Session. Desktop and Windows/macOS Web rename use Mod+Alt+G, leaving Mod+Shift+R to browser reload. Rename requires a nonblank main Conversation with no modal obscuring it; a retained Session behind another main panel is unavailable. Other Windows and macOS Desktop bindings also execute from terminal input and modal dialogs; other environments follow the command's region and modal restrictions. Search and rename requests belong to this package; input drafts remain in the browser. The directory picker rejects another open while selection or Workspace adoption is pending. Fork captures the retained main-view Session, for which navigation has requested history opening, and keeps automatic migration. It uses the row action's Host operation to select its last completed turn, without loading older Client history. Missing or blank Sessions are unavailable; the Host rejects a source with no completed turn. A rejected shortcut fork preserves the current selection, displays a localized notification, and can be retried; unexpected failures also retain diagnostic logging. Its notification shares the frame-wide Workspace notice channel: only the latest notice remains visible, and removing the browsing region does not dismiss it.
|
||||
The keyboard reference exposes New Session, Search sessions, Add workspace, Rename session, Fork session, and Archive session. Desktop defaults use the platform's primary modifier, with Mod+K for search; Windows and macOS Web use the [shortcut service’s platform defaults](../shortcuts/README.md); Linux Web leaves these commands unbound until configured. Button tooltips and Session row menus display the effective bindings. Clicking a menu item targets that row; pressing its shortcut targets the main Session. Desktop and Windows/macOS Web rename use Mod+Alt+G, leaving Mod+Shift+R to browser reload. The navigation drawer allows these commands; other dialogs follow the command’s modal restrictions. Rename requires a nonblank main Conversation with no other modal obscuring it; a retained Session behind another main panel is unavailable. Other Windows and macOS Desktop bindings also execute from terminal input and modal dialogs; other environments follow the command's region and modal restrictions. Search and rename requests belong to this package; input drafts remain in the browser. The directory picker rejects another open while selection or Workspace adoption is pending. Fork captures the retained main-view Session, for which navigation has requested history opening, and keeps automatic migration. It uses the row action's Host operation to select its last completed turn, without loading older Client history. Missing or blank Sessions are unavailable; the Host rejects a source with no completed turn. A rejected shortcut fork preserves the current selection, displays a localized notification, and can be retried; unexpected failures also retain diagnostic logging. Its notification shares the frame-wide Workspace notice channel: only the latest notice remains visible, and removing the browsing region does not dismiss it.
|
||||
|
||||
### Pending interactions
|
||||
|
||||
@@ -103,7 +103,7 @@ On hover-capable devices, hovering a Session row, giving keyboard focus to the r
|
||||
|
||||
Hoverless devices keep the static details and the More menu trigger visible, including while the menu is open; pin and archive remain available in that menu.
|
||||
|
||||
Each tree has one row in the Tab order, initially the selected row or the first row. Up/Down and Home/End move focus between visible rows; Left/Right collapse, expand, or move between a folder and its children. Enter or Space activates the focused row. Tab reaches the current row’s actions and any list-expansion controls; other rows are skipped. Modified keys remain available to global shortcuts.
|
||||
Each tree has one row in the Tab order, initially the focused row, otherwise the selected row or the first row. Up/Down and Home/End move focus between visible rows; Left/Right collapse, expand, or move between a folder and its children. Enter or Space activates the focused row. Tab reaches the current row’s actions and any list-expansion controls; other rows are skipped. Modified keys remain available to global shortcuts.
|
||||
|
||||
Client callers can pass `prompt`, `whenDraftExists`, and `clearPreviousDraft` in the second argument to `uiWorkspace.startSession`. A prompt is plain text; structured drafts are handled internally during restoration and Workspace transfer. An empty draft adopts the prompt. When the target already has text or attachments, `whenDraftExists: 'keep'` (the default) preserves them, `'replace'` replaces only the target Session's text and inline references with the prompt or clears them without one, and `'append'` adds the prompt as new paragraphs after the existing text; attachments stay in every case. `clearPreviousDraft: true` acts as `'replace'` only when `whenDraftExists` is omitted. Option values are captured before asynchronous creation and applied to the exact retained binding before navigation commits. Superseded navigation does not write content; a submission-blocked input refuses preparation and keeps the previous selection. Calls with or without options open the blank Session chosen as described above, so New Session returns to its unsent draft. The [draft initialization decision](../../../.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.md) describes the input owner's data flow.
|
||||
|
||||
@@ -194,7 +194,6 @@ The sidebar hides durable summaries with `origin: 'subagent'`. A visible ordinar
|
||||
|
||||
Row motion belongs to [AnimatedRows](src/client/rows/AnimatedRows.tsx). It measures keyed rows before and after React commits that change their membership or order, and uses native movement and opacity animations. Removed rows fade as inert copies outside the scrolling list; they do not delay React unmounting or extend its scroll range. Initial loading, drag commits, overflow expansion, and view-option changes settle immediately. The animator has no layout observers or polling and does not measure content-only updates or scrolling.
|
||||
|
||||
|
||||
### Hover cards
|
||||
|
||||
Workspace and Session hover cards copy the value their row clips: activating a Workspace card writes its full directory path, while activating a non-blank Session card writes its full display title. A provisional blank New Session card remains read-only because its localized label is a placeholder rather than session content. A Session card, including a blank New Session card, shows its working directory below the title, abbreviating a POSIX home prefix as `~`, and omits that line when the Host reports no directory or an empty one. A Session card also renders its `sidebar.session.row.hover` seat between the relative time and the trailing status lines whenever the card is open, independent of the row's own state. The first Workspace or Session card in a physical list waits 800ms; after a card is displayed, moving to another Workspace or Session in the same list replaces it immediately. The list and its active portaled card form one pointer interaction: entering the card to read or copy preserves immediate handoff to a neighboring Workspace or Session. After the pointer leaves both, the shared dwell resets when the active card closes through its existing pointer-grace and close lifecycle, with no separate group timer. Leaving a list with no active card resets the dwell immediately. Small action tooltips coexist with the right-side hover card; pin, archive, Workspace new-session, and search-result unarchive tooltips use portals to stay above it. Hovering actions, including More, preserves the card; opening the More menu or starting a Session drag dismisses it.
|
||||
|
||||
@@ -53,7 +53,7 @@ kind: "package-reference"
|
||||
|
||||
### 管理会话
|
||||
|
||||
在支持悬停的设备上,悬停 Session 行会显示操作按钮。在不支持悬停的设备上,选中非空 Session 会常驻显示“更多”,替换尾部时间。内置的归档和置顶按钮在此隐藏,两个操作仍可从“更多”菜单进入,静态置顶标记保留。插件行操作仍按各自的注册方式展示。无论设备是否支持悬停,行菜单打开期间都会保持操作区可见。
|
||||
在支持悬停的设备上,悬停 Session 行会显示操作按钮。在不支持悬停的设备上,每个非空 Session 都会常驻显示“更多”,并保留尾部时间和静态置顶标记。快捷操作按钮在此隐藏,内置归档和置顶操作仍可从“更多”菜单进入。Workspace 行仅在展开时显示操作按钮,让折叠文件夹优先用于导航。无论设备是否支持悬停,行菜单打开期间都会保持操作区可见。
|
||||
|
||||
Session 行“...”菜单的最后一个内置项为“复制 Session ID”。点击后关闭菜单并直接复制完整 ID,不打开对话框。复制成功或失败通过全局提示反馈;失败时可从菜单重试。复制不会 retain 会话、加载历史或调用 Host。
|
||||
|
||||
@@ -63,7 +63,7 @@ Session 行内的 Rename 操作打开一个以该行显示标题预填的对话
|
||||
|
||||
会话更新时间使用 tertiary 文本色,包括已归档行。标题宽于所在行时,静止状态以省略号裁切。把指针停在行上,标题会滚动到远端——例如 fork 递增后的标题——并在揭示时不显示省略号;指针离开后标题回到开头。
|
||||
|
||||
快捷键速查提供新建会话、搜索会话、添加工作区、重命名会话、分叉会话和归档会话。桌面默认使用平台的主修饰键,搜索为 Mod+K;Windows 和 macOS Web 使用[快捷键服务的平台默认值](../shortcuts/README.zh.md);Linux Web 在用户配置前不绑定这些命令。按钮提示和会话行菜单显示当前有效绑定。点击菜单项操作该行,按快捷键操作主会话。Desktop 和 Windows/macOS Web 的重命名均使用 Mod+Alt+G,将 Mod+Shift+R 留给浏览器刷新。重命名要求主区域正在显示非空会话,且没有模态对话框遮挡;切换到其他主面板后,后台保留的会话不可作为重命名目标。其他 Windows 和 macOS Desktop 绑定也可从终端输入区域和模态对话框中执行;其他环境遵循命令的区域和模态限制。搜索和重命名的打开请求归本包管理,输入草稿保留在浏览器中。目录选择或工作区接纳尚未结束时,目录选择器拒绝重复打开。分叉捕获主视图已持有并发起历史打开的会话,保留自动迁移;它使用与行菜单相同的 Host 操作选择最近已完成轮次,不读取更早的 Client 历史。没有会话或会话为空时不可用;没有已完成轮次的源会话由 Host 拒绝。快捷键分叉被拒绝时保留当前选择、显示本地化提示,并允许重试;非预期失败还会保留诊断日志。该提示共用应用级 Workspace 通知通道:只显示最新提示,移除浏览区域不会关闭它。
|
||||
快捷键速查提供新建会话、搜索会话、添加工作区、重命名会话、分叉会话和归档会话。桌面默认使用平台的主修饰键,搜索为 Mod+K;Windows 和 macOS Web 使用[快捷键服务的平台默认值](../shortcuts/README.zh.md);Linux Web 在用户配置前不绑定这些命令。按钮提示和会话行菜单显示当前有效绑定。点击菜单项操作该行,按快捷键操作主会话。Desktop 和 Windows/macOS Web 的重命名均使用 Mod+Alt+G,将 Mod+Shift+R 留给浏览器刷新。导航抽屉允许这些命令,其他对话框遵循命令的模态限制。重命名要求主区域正在显示非空会话,且没有其他模态对话框遮挡;切换到其他主面板后,后台保留的会话不可作为重命名目标。其他 Windows 和 macOS Desktop 绑定也可从终端输入区域和模态对话框中执行;其他环境遵循命令的区域和模态限制。搜索和重命名的打开请求归本包管理,输入草稿保留在浏览器中。目录选择或工作区接纳尚未结束时,目录选择器拒绝重复打开。分叉捕获主视图已持有并发起历史打开的会话,保留自动迁移;它使用与行菜单相同的 Host 操作选择最近已完成轮次,不读取更早的 Client 历史。没有会话或会话为空时不可用;没有已完成轮次的源会话由 Host 拒绝。快捷键分叉被拒绝时保留当前选择、显示本地化提示,并允许重试;非预期失败还会保留诊断日志。该提示共用应用级 Workspace 通知通道:只显示最新提示,移除浏览区域不会关闭它。
|
||||
|
||||
### 待处理交互
|
||||
|
||||
@@ -103,7 +103,7 @@ Workspace 和 Session 的启动基线均就绪后,空安装环境调用 `works
|
||||
|
||||
不支持悬停的设备始终保留静态信息和更多菜单入口,菜单打开时也不隐藏;置顶与归档仍可通过该菜单操作。
|
||||
|
||||
每个树形列表只有一个行入口参与 Tab 顺序,初始为选中行或第一行。上、下方向键及 Home、End 在可见行间移动焦点;左、右方向键收起、展开文件夹,或在文件夹与其子项间移动。Enter 或空格激活当前行。Tab 可到达当前行的操作按钮及列表展开控件,其余行不参与 Tab 顺序。组合键继续交由全局快捷键处理。
|
||||
每个树形列表只有一个行入口参与 Tab 顺序,初始优先采用已聚焦行,否则采用选中行或第一行。上、下方向键及 Home、End 在可见行间移动焦点;左、右方向键收起、展开文件夹,或在文件夹与其子项间移动。Enter 或空格激活当前行。Tab 可到达当前行的操作按钮及列表展开控件,其余行不参与 Tab 顺序。组合键继续交由全局快捷键处理。
|
||||
|
||||
客户端调用方可以在 `uiWorkspace.startSession` 的第二参数中传入 `prompt`、`whenDraftExists` 与 `clearPreviousDraft`。提示词仅接受普通文字;结构化草稿由内部恢复和工作区携带流程处理。空稿直接采用提示词。目标已有文字或附件时,`whenDraftExists: 'keep'`(默认)保留原稿,`'replace'` 只用提示词替换目标 Session 的文字和内联引用、无提示词时清空,`'append'` 在原有文字之后另起段落追加提示词;附件在各种情况下都保留。只有未传 `whenDraftExists` 时,`clearPreviousDraft: true` 才等同 `'replace'`。在异步创建前捕获选项值,在导航提交前应用到准确保留的 binding。已被后续操作取代的导航不写内容;输入处于提交阻塞状态时拒绝准备并保留原选择。无论是否传入选项,都按上文所述选择并打开空白 Session,因此新会话会回到其未发送的草稿。[草稿初始化决策](../../../.agents/notes/implemented/architecture/2026-09-30-structured-draft-initialization.zh.md)说明输入 owner 的数据流。
|
||||
|
||||
@@ -194,7 +194,6 @@ Workspace 基线就绪后,浏览器持久化的展开状态和 Session 顺序
|
||||
|
||||
行动画由 [AnimatedRows](src/client/rows/AnimatedRows.tsx) 负责。它仅在 React 提交改变行成员或顺序时读取更新前后的位置,并使用浏览器原生位移与透明度动画。被移除的行以不可交互的副本在滚动列表外淡出,不会延迟 React 卸载,也不会扩大列表的滚动范围。初始加载、拖拽提交、展开其余会话和视图选项变化直接完成。动画组件不使用布局观察器或轮询,也不会因仅内容更新或滚动而测量位置。
|
||||
|
||||
|
||||
### 悬浮卡片
|
||||
|
||||
Workspace 与 Session 悬浮卡片会复制对应行被截断的值:激活 Workspace 卡片会写入其完整目录路径,激活非空白 Session 卡片则会写入其完整显示标题。临时的空白「新会话」卡片保持只读,因为其本地化标签是占位文案,并非会话内容。Session 卡片(包括空白「新会话」卡片)在标题下方显示其工作目录,POSIX 主目录前缀缩写为 `~`;Host 未报告目录或目录为空时省略该行。 Session 卡片在卡片打开期间还会在相对时间与行尾状态行之间渲染 `sidebar.session.row.hover` seat,与行自身状态无关。同一物理列表中的首张 Workspace 或 Session 卡片等待 800ms;实际显示一张后,移到该列表的其他 Workspace 或 Session 会立即替换卡片。列表与其当前活动的 portal 卡片构成一次指针交互:进入卡片阅读或复制后,移到相邻 Workspace 或 Session 仍会立即切换。指针离开两者后,共享等待在活动卡片通过原有指针宽限及关闭生命周期关闭时重置,不另设分组计时器。列表没有活动卡片时,指针离开便立即重置等待。小型操作提示与右侧悬浮卡片同时显示;置顶、归档、Workspace 新建会话及搜索结果取消归档的提示通过 portal 保持在卡片上层。悬停操作按钮(包括「更多」)保留卡片;打开「更多」菜单或开始拖拽 Session 会关闭卡片。
|
||||
|
||||
@@ -16,36 +16,88 @@ export function TreeRows({ children, className, label, listRef, onInput }: {
|
||||
}) {
|
||||
const ownRef = useRef<HTMLDivElement>(null)
|
||||
const root = listRef ?? ownRef
|
||||
const active = useRef<HTMLElement | null>(null)
|
||||
const originalTabs = useRef(new WeakMap<HTMLElement, string | null>())
|
||||
const activateRow = useRef<((row: HTMLElement) => void) | null>(null)
|
||||
const originalTabs = useRef(new WeakMap<HTMLElement, string | null>()).current
|
||||
const rows = (tree: HTMLDivElement): HTMLElement[] => Array.from(tree.querySelectorAll<HTMLElement>('[role="treeitem"]'))
|
||||
const activate = (row: HTMLElement, tree: HTMLDivElement): void => {
|
||||
active.current = row
|
||||
for (const item of rows(tree)) {
|
||||
item.tabIndex = item === row ? 0 : -1
|
||||
for (const action of item.querySelectorAll<HTMLElement>('button, a[href], input, select, textarea, [tabindex]')) {
|
||||
if (!originalTabs.current.has(action)) originalTabs.current.set(action, action.getAttribute('tabindex'))
|
||||
const original = originalTabs.current.get(action)
|
||||
if (item !== row) action.tabIndex = -1
|
||||
else if (original == null) action.removeAttribute('tabindex')
|
||||
else action.setAttribute('tabindex', original)
|
||||
useLayoutEffect(() => {
|
||||
const tree = root.current
|
||||
/* v8 ignore next -- the tree element is attached before its layout effect. */
|
||||
if (tree === null) return
|
||||
let active: HTMLElement | undefined
|
||||
let known = new Set<HTMLElement>()
|
||||
const actions = (row: HTMLElement) => row.querySelectorAll<HTMLElement>('button, a[href], input, select, textarea, [tabindex]')
|
||||
const syncRow = (row: HTMLElement): void => {
|
||||
const enabled = row === active
|
||||
row.tabIndex = enabled ? 0 : -1
|
||||
for (const action of actions(row)) {
|
||||
if (enabled) {
|
||||
if (!originalTabs.has(action)) continue
|
||||
const original = originalTabs.get(action)
|
||||
if (original == null) action.removeAttribute('tabindex')
|
||||
else action.setAttribute('tabindex', original)
|
||||
originalTabs.delete(action)
|
||||
} else {
|
||||
if (!originalTabs.has(action)) originalTabs.set(action, action.getAttribute('tabindex'))
|
||||
action.tabIndex = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
useLayoutEffect(() => {
|
||||
const tree = root.current as HTMLDivElement
|
||||
const update = (): void => {
|
||||
const select = (row: HTMLElement): void => {
|
||||
if (row === active) return
|
||||
const previous = active
|
||||
active = row
|
||||
if (previous !== undefined) syncRow(previous)
|
||||
syncRow(row)
|
||||
}
|
||||
const syncMembers = (): void => {
|
||||
const items = rows(tree)
|
||||
const target = items.find(row => row === active.current)
|
||||
?? items.find(row => row.getAttribute('aria-selected') === 'true') ?? items[0]
|
||||
if (target !== undefined) activate(target, tree)
|
||||
const next = new Set(items)
|
||||
for (const row of next) if (!known.has(row)) syncRow(row)
|
||||
known = next
|
||||
if (active === undefined || !known.has(active)) {
|
||||
const target = items.find(row => row.contains(tree.ownerDocument.activeElement))
|
||||
?? items.find(row => row.getAttribute('aria-selected') === 'true') ?? items[0]
|
||||
if (target !== undefined) select(target)
|
||||
else active = undefined
|
||||
}
|
||||
}
|
||||
const observe = (): void => { observer.observe(tree, { childList: true, subtree: true, attributes: true, attributeFilter: ['tabindex'] }) }
|
||||
const syncMutations = (records: MutationRecord[]): void => {
|
||||
const changed = new Set<HTMLElement>()
|
||||
let membershipChanged = false
|
||||
for (const record of records) {
|
||||
const target = record.target instanceof HTMLElement ? record.target : record.target.parentElement
|
||||
const row = target?.closest<HTMLElement>('[role="treeitem"]')
|
||||
if (row != null) changed.add(row)
|
||||
if (record.type === 'attributes' && target != null && target !== row && originalTabs.has(target)) {
|
||||
originalTabs.set(target, target.getAttribute('tabindex'))
|
||||
}
|
||||
for (const node of [...record.addedNodes, ...record.removedNodes]) {
|
||||
if (node instanceof Element && (node.matches('[role="treeitem"]') || node.querySelector('[role="treeitem"]') !== null)) {
|
||||
membershipChanged = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if (membershipChanged) syncMembers()
|
||||
for (const row of changed) if (known.has(row)) syncRow(row)
|
||||
}
|
||||
// Only DOM membership or owned tabindex changes require work; Session text updates touch their own row.
|
||||
const observer = new MutationObserver((records) => {
|
||||
observer.disconnect()
|
||||
syncMutations(records)
|
||||
observe()
|
||||
})
|
||||
syncMembers()
|
||||
observe()
|
||||
activateRow.current = (row) => {
|
||||
const pending = observer.takeRecords()
|
||||
observer.disconnect()
|
||||
syncMutations(pending)
|
||||
select(row)
|
||||
observe()
|
||||
}
|
||||
update()
|
||||
// Slot-owned actions can mount without rerendering their tree container.
|
||||
const observer = new MutationObserver(update)
|
||||
observer.observe(tree, { childList: true, subtree: true })
|
||||
return () => { observer.disconnect() }
|
||||
})
|
||||
}, [root, originalTabs])
|
||||
const navigate = (event: KeyboardEvent<HTMLDivElement>): void => {
|
||||
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return
|
||||
const items = rows(event.currentTarget)
|
||||
@@ -78,7 +130,7 @@ export function TreeRows({ children, className, label, listRef, onInput }: {
|
||||
onPointerDownCapture={onInput} onKeyDownCapture={onInput} onKeyDown={navigate}
|
||||
onFocusCapture={(event) => {
|
||||
const row = event.target.closest<HTMLElement>('[role="treeitem"]')
|
||||
if (row !== null && event.currentTarget.contains(row)) activate(row, event.currentTarget)
|
||||
if (row !== null && event.currentTarget.contains(row)) activateRow.current?.(row)
|
||||
}}>
|
||||
{children}
|
||||
</div>
|
||||
|
||||
@@ -48,7 +48,7 @@ export function createWorkspaceShortcutControls(): WorkspaceShortcutControls {
|
||||
|
||||
/**
|
||||
* Register navigation commands against the existing workspace owner.
|
||||
* Rename requires a nonblank main Conversation with no modal obscuring it.
|
||||
* Rename requires a nonblank main Conversation with no modal other than the navigation drawer obscuring it.
|
||||
* @param ctx - plugin context with the shortcut, locale, and model services.
|
||||
* @param navigation - session creation and forking from the pointer controls' navigation service.
|
||||
* @param controls - browser-owned opening requests.
|
||||
@@ -75,7 +75,7 @@ export function installWorkspaceShortcuts(
|
||||
'desktop:macos': { code, modifiers }, 'desktop:windows': { code, modifiers }, 'desktop:linux': { code, modifiers },
|
||||
'web:macos': { code, modifiers: webModifiers }, 'web:windows': { code, modifiers: webModifiers },
|
||||
},
|
||||
regions: ['page', 'editable'], modals: [], resolve,
|
||||
regions: ['page', 'editable'], modals: ['sidebar'], resolve,
|
||||
}), `ui-workspace: ${id}`)
|
||||
}
|
||||
register('session.new', () => t('session.new'), ['new session', 'new chat'], 'KeyN', ['primary'], ['primary', 'alt'],
|
||||
@@ -89,7 +89,7 @@ export function installWorkspaceShortcuts(
|
||||
})
|
||||
register('session.rename', () => t('rename.session.title'), ['rename session'], 'KeyG', ['primary', 'alt'], ['primary', 'alt'], (context) => {
|
||||
const target = current()
|
||||
return target === undefined || target.blank || context.modal !== null || ctx.layout.panelInfo.getSnapshot().activePanelId !== null
|
||||
return target === undefined || target.blank || (context.modal !== null && context.modal !== 'sidebar') || ctx.layout.panelInfo.getSnapshot().activePanelId !== null
|
||||
? { status: 'blocked', reason: t('shortcut.noSession') }
|
||||
: { status: 'handled', run: () => { controls.rename(target.id, target.title?.trim() ?? '') } }
|
||||
})
|
||||
|
||||
@@ -79,6 +79,17 @@ describe('workspace shortcut ownership', () => {
|
||||
b.controls.add()
|
||||
expect(b.controls.state.getSnapshot().addRequested).toBe(false)
|
||||
})
|
||||
it.each([
|
||||
['session.new', 'KeyN'], ['session.search', 'KeyK'], ['workspace.add', 'KeyO'],
|
||||
['session.rename', 'KeyG'], ['session.fork', 'KeyF'], ['session.archive', 'KeyA'],
|
||||
])('allows %s from the drawer and blocks it behind another dialog', async (id, code) => {
|
||||
const b = await bench('web')
|
||||
const gesture = key(code, { alt: code !== 'KeyF', shift: code === 'KeyF' })
|
||||
expect(b.registry.dispatch(gesture, { ...context, modal: 'settings' }, vi.fn()).status).toBe('blocked')
|
||||
expect(b.registry.dispatch(gesture, { ...context, modal: 'sidebar' }, vi.fn()).status).toBe('handled')
|
||||
expect(b.commands.get(id)!.modals).toContain('sidebar')
|
||||
})
|
||||
|
||||
it('registers six commands with Desktop and Web defaults and removes registrations with the plugin', async () => {
|
||||
const b = await bench()
|
||||
expect(b.registry.catalog.getSnapshot().map(row => row.id)).toEqual([
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @vitest-environment jsdom
|
||||
/** Focus traversal through visible rows and their own action controls. */
|
||||
import { useState } from 'react'
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { StrictMode, useState } from 'react'
|
||||
import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
import { TreeRows } from '../src/client/rows/TreeRows.tsx'
|
||||
|
||||
@@ -48,13 +48,13 @@ it('walks rows without opening them and clamps at both ends', () => {
|
||||
expect(fireEvent.keyDown(rows[0]!, { key: 'Escape' })).toBe(true)
|
||||
})
|
||||
|
||||
it('retains the entry across reorder and chooses a surviving row after removal', () => {
|
||||
it('retains the entry across reorder and chooses a surviving row after removal', async () => {
|
||||
const view = render(list(['one', 'two']))
|
||||
screen.getAllByRole('treeitem')[1]!.focus()
|
||||
view.rerender(list(['two', 'one', 'three']))
|
||||
expect(screen.getAllByRole('treeitem').map(row => row.tabIndex)).toEqual([0, -1, -1])
|
||||
view.rerender(list(['one', 'three']))
|
||||
expect(screen.getAllByRole('treeitem').map(row => row.tabIndex)).toEqual([0, -1])
|
||||
await waitFor(() => { expect(screen.getAllByRole('treeitem').map(row => row.tabIndex)).toEqual([0, -1]) })
|
||||
view.rerender(list([]))
|
||||
screen.getByRole('tree').focus()
|
||||
expect(fireEvent.keyDown(screen.getByRole('tree'), { key: 'Home' })).toBe(true)
|
||||
@@ -123,3 +123,70 @@ it('keeps late slot actions out of the Tab order on inactive rows', async () =>
|
||||
await new Promise<void>((resolve) => { queueMicrotask(resolve) })
|
||||
expect(screen.getByRole('button', { name: 'Late action' }).tabIndex).toBe(-1)
|
||||
})
|
||||
|
||||
it('restores the latest action tabindex after a React update on an inactive row', async () => {
|
||||
function List({ tabIndex }: { tabIndex: number }) {
|
||||
return <TreeRows label="Sessions">
|
||||
<div role="treeitem" tabIndex={-1}>First</div>
|
||||
<div role="treeitem" tabIndex={-1}>Second<button tabIndex={tabIndex}>Action</button></div>
|
||||
</TreeRows>
|
||||
}
|
||||
const view = render(<List tabIndex={0} />)
|
||||
view.rerender(<List tabIndex={-1} />)
|
||||
await act(async () => {})
|
||||
screen.getAllByRole('treeitem')[1]!.focus()
|
||||
expect(screen.getByRole('button').tabIndex).toBe(-1)
|
||||
view.rerender(<List tabIndex={0} />)
|
||||
await waitFor(() => { expect(screen.getByRole('button').tabIndex).toBe(0) })
|
||||
})
|
||||
|
||||
it('updates one running row without traversing the remaining 199 rows', async () => {
|
||||
function List({ running }: { running: boolean }) {
|
||||
return <TreeRows label="Sessions">{Array.from({ length: 200 }, (_, i) =>
|
||||
<div key={i} role="treeitem" tabIndex={-1}>{i === 100 && running ? <span>Running</span> : null}<button>Action {i}</button></div>,
|
||||
)}</TreeRows>
|
||||
}
|
||||
const view = render(<List running={false} />)
|
||||
const scans = screen.getAllByRole('treeitem').map(row => vi.spyOn(row, 'querySelectorAll'))
|
||||
view.rerender(<List running />)
|
||||
await act(async () => {})
|
||||
expect(screen.getByText('Running')).toBeTruthy()
|
||||
expect(scans.filter(scan => scan.mock.calls.length > 0)).toHaveLength(1)
|
||||
scans.forEach((scan) => { scan.mockRestore() })
|
||||
})
|
||||
|
||||
it('accepts focus during mounting and updates SVG and text children without changing the entry', async () => {
|
||||
render(<TreeRows label="Sessions">
|
||||
<div role="treeitem" tabIndex={-1} aria-selected>First</div>
|
||||
<div role="treeitem" tabIndex={-1}><button autoFocus>Action</button><svg data-testid="status" /></div>
|
||||
</TreeRows>)
|
||||
const [first, row] = screen.getAllByRole('treeitem') as [HTMLElement, HTMLElement]
|
||||
await act(async () => {
|
||||
screen.getByTestId('status').append(document.createElementNS('http://www.w3.org/2000/svg', 'path'))
|
||||
row.append(document.createTextNode('Running'))
|
||||
})
|
||||
expect(first.tabIndex).toBe(-1)
|
||||
expect(row.tabIndex).toBe(0)
|
||||
expect(screen.getByRole('button').tabIndex).toBe(0)
|
||||
expect(document.activeElement).toBe(screen.getByRole('button'))
|
||||
})
|
||||
|
||||
it('ignores action updates from a row removed in the same commit', async () => {
|
||||
const view = render(list(['one', 'two']))
|
||||
const removed = screen.getAllByRole('treeitem')[1]!
|
||||
act(() => {
|
||||
removed.append(document.createElement('button'))
|
||||
view.rerender(list(['one']))
|
||||
})
|
||||
await act(async () => {})
|
||||
expect(removed.isConnected).toBe(false)
|
||||
expect(screen.getByRole('treeitem').tabIndex).toBe(0)
|
||||
expect(screen.getByRole('button', { name: 'one actions' }).tabIndex).toBe(0)
|
||||
})
|
||||
|
||||
it('keeps inactive actions reachable after StrictMode replays the layout effect', () => {
|
||||
render(<StrictMode>{list(['one', 'two'])}</StrictMode>)
|
||||
screen.getAllByRole('treeitem')[1]!.focus()
|
||||
expect(screen.getByRole('button', { name: 'two actions' }).tabIndex).toBe(0)
|
||||
expect(screen.getByRole('button', { name: 'one actions' }).tabIndex).toBe(-1)
|
||||
})
|
||||
Reference in new issue
Block a user