Keep brand clicks bubbling and the copy target's width
The copy handler no longer stops propagation; the brand button skips New Session for clicks inside the local-build fallbacks instead. The copied label now overlays the 12px title row so the target keeps its width, and repeated clicks during the feedback are ignored.
This commit is contained in:
1 parent
e5ba436f16
commit
4fc8ac8dda
8 files changed
+73
-23
No files matched your search
@@ -38,7 +38,8 @@ describe.skipIf(MODE === 'record')('web e2e: refused New Session', () => {
|
||||
expect(scaffold.ctx.sessions.list()).toEqual([])
|
||||
expect(await page.getByRole('alert').count()).toBe(0)
|
||||
|
||||
await page.getByRole('button', { name: '新建会话', exact: true }).first().click()
|
||||
// The capsule: on a local build the wordmark's fallback copies the version.
|
||||
await page.getByRole('button', { name: '新建会话', exact: true }).last().click()
|
||||
const notice = page.getByRole('alert').filter({ hasText: '新建会话失败' })
|
||||
await notice.waitFor()
|
||||
await compareOrRefreshGolden(NOTICE_EXPECTED, await notice.ariaSnapshot(), MODE)
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
en: a970f0547496634f
|
||||
zh: 36ef9a85b26e19f1
|
||||
/deepseek-ai-dsh-client-ui-sidebar/use-this-package/brand-and-new-session:
|
||||
en: 8d1f4fb785e6ba91
|
||||
zh: 6eb84300c65302db
|
||||
en: 5c6c56a13165b3e9
|
||||
zh: b441b3d2492f5631
|
||||
/deepseek-ai-dsh-client-ui-sidebar/use-this-package/global-panel-entries:
|
||||
en: 5d3300d3506254c5
|
||||
zh: 541ae1ee1e10b921
|
||||
@@ -48,8 +48,8 @@
|
||||
en: ca75c51c89c2c9b0
|
||||
zh: de54f3467ef3b9be
|
||||
/deepseek-ai-dsh-client-ui-sidebar/known-limitations-and-deferred-work:
|
||||
en: 262db5b10dfb7d98
|
||||
zh: c1b5cf6aa58b054e
|
||||
en: 1598ec799afb4483
|
||||
zh: f359ade03cbc92d2
|
||||
/deepseek-ai-dsh-client-ui-sidebar/known-limitations-and-deferred-work/dev-note:
|
||||
en: e67f633dc6fe7773
|
||||
zh: 3bb0c20c93f16f98
|
||||
@@ -31,7 +31,7 @@ The sidebar is the navigation shell: users see the brand, start new sessions, co
|
||||
|
||||
### Brand and New Session
|
||||
|
||||
The expanded brand row renders `sidebar.brand.mark` and `sidebar.brand.name` as independent single slots; the collapsed rail renders the same mark slot. On Web and Windows desktop, clicking the expanded brand starts a new session; hovering or focusing it shows no tooltip. Without occupants, the shell uses the fish mark and a localized local-build label. A complete build stacks a code badge below the label as `version[-commit][-dirty]`, using `DSH_CLIENT_VERSION`, the optional 7-character `DSH_CLIENT_COMMIT_HASH`, and `DSH_CLIENT_GIT_DIRTY=true`; missing version metadata omits the badge. Clicking the fallback mark or label of such a build copies that badge text instead of starting a session, also on macOS desktop, and the badge reads Copied for one second after a successful write. New Session targets the explicit Workspace used by a scoped action, otherwise the current Session's Workspace, otherwise the most recently active Workspace; when none exists it clears into the blank New Session page. The expanded New Session button displays the effective binding as trailing grey text on hover or keyboard focus. While the shortcut is visible, the centered icon and label fade before it when space is narrow; CSS reserves the shortcut’s width without measuring the button. Icon-only controls retain tooltips with platform-formatted keycaps, including the resident macOS header control when the sidebar is hidden. All controls expose `aria-keyshortcuts`.
|
||||
The expanded brand row renders `sidebar.brand.mark` and `sidebar.brand.name` as independent single slots; the collapsed rail renders the same mark slot. On Web and Windows desktop, clicking the expanded brand starts a new session; hovering or focusing it shows no tooltip. Without occupants, the shell uses the fish mark and a localized local-build label. A complete build stacks a code badge below the label as `version[-commit][-dirty]`, using `DSH_CLIENT_VERSION`, the optional 7-character `DSH_CLIENT_COMMIT_HASH`, and `DSH_CLIENT_GIT_DIRTY=true`; missing version metadata omits the badge. Clicking the fallback mark or label of such a build copies that badge text instead of starting a session, also on macOS desktop, and the label line reads Copied for one second after a successful write while keeping its width. New Session targets the explicit Workspace used by a scoped action, otherwise the current Session's Workspace, otherwise the most recently active Workspace; when none exists it clears into the blank New Session page. The expanded New Session button displays the effective binding as trailing grey text on hover or keyboard focus. While the shortcut is visible, the centered icon and label fade before it when space is narrow; CSS reserves the shortcut’s width without measuring the button. Icon-only controls retain tooltips with platform-formatted keycaps, including the resident macOS header control when the sidebar is hidden. All controls expose `aria-keyshortcuts`.
|
||||
|
||||
### Global panel entries
|
||||
|
||||
@@ -105,6 +105,7 @@ These limits define what the shell owns versus what its occupants own; they are
|
||||
- **Session state-dot rendering is owned by ui-workspace** — no done/error notification sources are available to this shell.
|
||||
- **Workspace browser behavior is composition-owned** — grouping, ordering, search, and row state belong to ui-workspace, not this shell.
|
||||
- **"New task completed" unread marking is local viewing state** — completion-time > last-seen never reaches the host.
|
||||
- **Copying the local-build version is mouse-only** — keyboard activation of the brand starts a session, and screen readers do not announce the copied state.
|
||||
|
||||
<a id="dev-note"></a>
|
||||
### Dev Note
|
||||
|
||||
@@ -31,7 +31,7 @@ dsh Web 客户端的侧边栏让用户识别当前构建、启动新会话、将
|
||||
|
||||
### 品牌与 New Session
|
||||
|
||||
展开的品牌行把 `sidebar.brand.mark` 与 `sidebar.brand.name` 渲染为两个独立的 single slot;收起轨道则渲染同一个 mark slot。在 Web 和 Windows 桌面端,点击展开态的品牌会新建会话,悬停或聚焦时不显示 tooltip。没有占位者时,外壳使用鱼形标记和本地化的本地构建标签。完整构建会在标签下方显示代码徽标;该徽标使用 `DSH_CLIENT_VERSION`、可选的 7 位 `DSH_CLIENT_COMMIT_HASH` 与 `DSH_CLIENT_GIT_DIRTY=true` 组装成 `version[-commit][-dirty]`;缺少版本元数据时不显示徽标。此类构建中点击回退的标记或标签会复制该徽标文本而非新建会话,macOS 桌面端同样适用;写入成功后徽标显示“复制成功”一秒。New Session 优先使用作用域操作明确指定的 Workspace,否则使用当前 Session 所属 Workspace,再否则使用最近活跃 Workspace;一个 Workspace 都没有时则清空选择,进入空白 New Session 页面。 展开态的新建会话按钮在悬停或键盘聚焦时于右侧以灰色文字显示当前有效绑定。快捷键可见且空间较窄时,居中的图标与文字在快捷键之前渐隐;CSS 为快捷键保留宽度,无需测量按钮。纯图标控件保留使用平台键位样式的 tooltip,侧栏隐藏时常驻的 macOS 头部控件也保持一致。所有控件均提供 `aria-keyshortcuts`。
|
||||
展开的品牌行把 `sidebar.brand.mark` 与 `sidebar.brand.name` 渲染为两个独立的 single slot;收起轨道则渲染同一个 mark slot。在 Web 和 Windows 桌面端,点击展开态的品牌会新建会话,悬停或聚焦时不显示 tooltip。没有占位者时,外壳使用鱼形标记和本地化的本地构建标签。完整构建会在标签下方显示代码徽标;该徽标使用 `DSH_CLIENT_VERSION`、可选的 7 位 `DSH_CLIENT_COMMIT_HASH` 与 `DSH_CLIENT_GIT_DIRTY=true` 组装成 `version[-commit][-dirty]`;缺少版本元数据时不显示徽标。此类构建中点击回退的标记或标签会复制该徽标文本而非新建会话,macOS 桌面端同样适用;写入成功后标签行显示“复制成功”一秒,宽度保持不变。New Session 优先使用作用域操作明确指定的 Workspace,否则使用当前 Session 所属 Workspace,再否则使用最近活跃 Workspace;一个 Workspace 都没有时则清空选择,进入空白 New Session 页面。 展开态的新建会话按钮在悬停或键盘聚焦时于右侧以灰色文字显示当前有效绑定。快捷键可见且空间较窄时,居中的图标与文字在快捷键之前渐隐;CSS 为快捷键保留宽度,无需测量按钮。纯图标控件保留使用平台键位样式的 tooltip,侧栏隐藏时常驻的 macOS 头部控件也保持一致。所有控件均提供 `aria-keyshortcuts`。
|
||||
|
||||
### 全局面板入口
|
||||
|
||||
@@ -105,6 +105,7 @@ dsh Web 客户端的侧边栏让用户识别当前构建、启动新会话、将
|
||||
- **Session 状态点渲染由 ui-workspace 持有**:本外壳没有可用的 done/error 通知数据源。
|
||||
- **Workspace 浏览行为由组合持有**:分组、排序、搜索与行状态都属于 ui-workspace,不属于此外壳。
|
||||
- **「New task completed」未读标记是本地查看状态**:完成时间 > 上次查看时间这一事实永远不会到达宿主。
|
||||
- **复制本地构建版本号仅支持鼠标**:键盘激活品牌会新建会话,读屏软件也不会播报复制成功。
|
||||
|
||||
<a id="dev-note"></a>
|
||||
### 开发备注
|
||||
|
||||
@@ -212,7 +212,8 @@
|
||||
single darwin rule carries the drag over its own box — below the top strip
|
||||
(40–100px: the strip's 52px foot with the row's -12px tuck). The brand rides
|
||||
that box (SidebarRoot renders the wordmark as a plain span there, so the
|
||||
global interactive no-drag rule never subtracts it); the dedicated New
|
||||
global interactive no-drag rule never subtracts it; only the local-build
|
||||
fallbacks opt out through .copyVersion); the dedicated New
|
||||
Session button below keeps the pointer and keyboard paths. Safe as a drag
|
||||
source: it precedes the sidebar's overlay slots in document order, so their
|
||||
no-drag still wins. */
|
||||
@@ -317,11 +318,20 @@
|
||||
}
|
||||
|
||||
.localBuildTitle {
|
||||
display: grid;
|
||||
font-size: 12px;
|
||||
line-height: 13px;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.localBuildTitle > * {
|
||||
grid-area: 1 / 1;
|
||||
}
|
||||
|
||||
.concealed {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.iconButton {
|
||||
position: relative;
|
||||
flex: none;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* scrollbar indirection away while it is elsewhere, so a list the user is not
|
||||
* pointing at carries no bar.
|
||||
*/
|
||||
import { useEffect, useRef, useState, type MouseEvent } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import clsx from 'clsx'
|
||||
import {
|
||||
FishLogo, IconNewChatOutlineMedium, IconNewChatOutlineRegular, IconPanelLeftOutlineRegular, isDarwinDesktop, ShortcutKeys, Tooltip,
|
||||
@@ -174,11 +174,12 @@ export function SidebarRoot({
|
||||
}, [pointerInside])
|
||||
|
||||
const buildVersion = localBuildVersion()
|
||||
// The local-build fallbacks copy the badge text instead of starting a
|
||||
// session; occupied brand slots keep the New Session click.
|
||||
// The local-build fallbacks copy the badge text; the brand button below
|
||||
// skips New Session for clicks inside them. The click still bubbles, so
|
||||
// document-level outside-click listeners see it.
|
||||
const [versionCopied, setVersionCopied] = useState(false)
|
||||
const copyVersion = (version: string) => (event: MouseEvent): void => {
|
||||
event.stopPropagation()
|
||||
const copyVersion = (version: string) => (): void => {
|
||||
if (versionCopied) return
|
||||
void writeClipboard(version).then((ok) => {
|
||||
if (!ok) return
|
||||
setVersionCopied(true)
|
||||
@@ -232,7 +233,8 @@ export function SidebarRoot({
|
||||
{/* Expanded, the brand doubles as a New Session shortcut — except on
|
||||
macOS, where it stays part of the logo row's window-drag surface
|
||||
(a button would subtract itself through the global no-drag rule);
|
||||
the collapsed rail's logo is the expand toggle below instead. */}
|
||||
the collapsed rail's logo is the expand toggle below instead.
|
||||
Mouse clicks on the local-build fallbacks copy the version instead. */}
|
||||
{wide && (() => {
|
||||
const identity = (
|
||||
<span className={css.brandIdentity} aria-hidden="true">
|
||||
@@ -240,7 +242,7 @@ export function SidebarRoot({
|
||||
{renderSlot('sidebar.brand.mark', { size: 24 }, {
|
||||
fallback: buildVersion === undefined
|
||||
? <FishLogo size={24} />
|
||||
: <span className={css.copyVersion} onClick={copyVersion(buildVersion)}><FishLogo size={24} /></span>,
|
||||
: <span className={css.copyVersion} data-copy-version onClick={copyVersion(buildVersion)}><FishLogo size={24} /></span>,
|
||||
})}
|
||||
</span>
|
||||
<span className={css.brandName}>
|
||||
@@ -248,9 +250,13 @@ export function SidebarRoot({
|
||||
fallback: buildVersion === undefined
|
||||
? <span className={css.fallbackBrandName}>{t('brand.localBuild')}</span>
|
||||
: (
|
||||
<span className={clsx(css.localBuildBrand, css.copyVersion)} onClick={copyVersion(buildVersion)}>
|
||||
<span className={css.localBuildTitle}>{t('brand.localBuild')}</span>
|
||||
<span className={css.buildVersion}>{versionCopied ? t('copied') : buildVersion}</span>
|
||||
<span className={clsx(css.localBuildBrand, css.copyVersion)} data-copy-version onClick={copyVersion(buildVersion)}>
|
||||
{/* The feedback shares the title's grid cell, so the copy target keeps its width. */}
|
||||
<span className={css.localBuildTitle}>
|
||||
<span className={versionCopied ? css.concealed : undefined}>{t('brand.localBuild')}</span>
|
||||
{versionCopied && <span>{t('copied')}</span>}
|
||||
</span>
|
||||
<span className={css.buildVersion}>{buildVersion}</span>
|
||||
</span>
|
||||
),
|
||||
})}
|
||||
@@ -265,7 +271,10 @@ export function SidebarRoot({
|
||||
className={clsx(css.brand, css.wide)}
|
||||
aria-label={t('session.new.label')}
|
||||
aria-keyshortcuts={newShortcut?.aria}
|
||||
onClick={() => { startSession() }}
|
||||
onClick={(event) => {
|
||||
if ((event.target as Element).closest('[data-copy-version]') !== null) return
|
||||
startSession()
|
||||
}}
|
||||
>
|
||||
{identity}
|
||||
</button>
|
||||
|
||||
+15
-3
@@ -122,6 +122,7 @@ exports[`sidebar shell snapshots > renders Windows caption controls in expanded
|
||||
>
|
||||
<span
|
||||
class="copyVersion"
|
||||
data-copy-version="true"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
@@ -143,11 +144,14 @@ exports[`sidebar shell snapshots > renders Windows caption controls in expanded
|
||||
>
|
||||
<span
|
||||
class="localBuildBrand copyVersion"
|
||||
data-copy-version="true"
|
||||
>
|
||||
<span
|
||||
class="localBuildTitle"
|
||||
>
|
||||
DSH Local Build
|
||||
<span>
|
||||
DSH Local Build
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="buildVersion"
|
||||
@@ -378,6 +382,7 @@ exports[`sidebar shell snapshots > renders the expanded column (wordmark, capsul
|
||||
>
|
||||
<span
|
||||
class="copyVersion"
|
||||
data-copy-version="true"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
@@ -399,11 +404,14 @@ exports[`sidebar shell snapshots > renders the expanded column (wordmark, capsul
|
||||
>
|
||||
<span
|
||||
class="localBuildBrand copyVersion"
|
||||
data-copy-version="true"
|
||||
>
|
||||
<span
|
||||
class="localBuildTitle"
|
||||
>
|
||||
DSH Local Build
|
||||
<span>
|
||||
DSH Local Build
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="buildVersion"
|
||||
@@ -525,6 +533,7 @@ exports[`sidebar shell snapshots > renders the expanded column in the default lo
|
||||
>
|
||||
<span
|
||||
class="copyVersion"
|
||||
data-copy-version="true"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
@@ -546,11 +555,14 @@ exports[`sidebar shell snapshots > renders the expanded column in the default lo
|
||||
>
|
||||
<span
|
||||
class="localBuildBrand copyVersion"
|
||||
data-copy-version="true"
|
||||
>
|
||||
<span
|
||||
class="localBuildTitle"
|
||||
>
|
||||
DSH 本地构建
|
||||
<span>
|
||||
DSH 本地构建
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="buildVersion"
|
||||
|
||||
@@ -26,6 +26,7 @@ afterEach(() => {
|
||||
delete document.documentElement.dataset.platform
|
||||
vi.unstubAllEnvs()
|
||||
vi.useRealTimers()
|
||||
Reflect.deleteProperty(navigator, 'clipboard')
|
||||
})
|
||||
|
||||
// The shell never reads the global hooks itself, but they ride the standard
|
||||
@@ -124,6 +125,8 @@ describe('SidebarRoot shell', () => {
|
||||
expect(Array.from(screen.getByRole('tooltip').querySelectorAll('kbd'), key => key.textContent)).toEqual(['Ctrl', 'N'])
|
||||
})
|
||||
it('routes New Session (capsule + wordmark) and the column toggle', () => {
|
||||
// Occupied brand slots keep New Session even when the build carries a version.
|
||||
vi.stubEnv('DSH_CLIENT_VERSION', '1.2.3')
|
||||
const b = mountShell()
|
||||
expect(screen.getByTestId('custom-brand-mark')).toBeTruthy()
|
||||
expect(screen.getByTestId('custom-brand-name')).toBeTruthy()
|
||||
@@ -213,8 +216,21 @@ describe('SidebarRoot shell', () => {
|
||||
await act(async () => { fireEvent.click(mark) })
|
||||
expect(writeText).toHaveBeenCalledTimes(3)
|
||||
expect(screen.getByText('Copied')).toBeTruthy()
|
||||
// A repeated click during the feedback neither copies again nor
|
||||
// falls through to New Session; the click still reaches document.
|
||||
const documentClick = vi.fn()
|
||||
document.addEventListener('click', documentClick)
|
||||
await act(async () => { fireEvent.click(screen.getByText('1.2.3-abcdef0')) })
|
||||
document.removeEventListener('click', documentClick)
|
||||
expect(documentClick).toHaveBeenCalledOnce()
|
||||
expect(writeText).toHaveBeenCalledTimes(3)
|
||||
expect(startSession).not.toHaveBeenCalled()
|
||||
Reflect.deleteProperty(navigator, 'clipboard')
|
||||
|
||||
// The rest of the brand button still starts a session.
|
||||
if (!darwin) {
|
||||
fireEvent.click(screen.getAllByRole('button', { name: 'New session' })[0]!)
|
||||
expect(startSession).toHaveBeenCalledOnce()
|
||||
}
|
||||
})
|
||||
|
||||
it('retains the local-build fallback without complete build metadata', () => {
|
||||
|
||||
Reference in new issue
Block a user