revert: 回退「只在未展开时显示底部入口」——把「没展开」理解成了底栏,实际是指右侧面板
This commit is contained in:
1 parent
f7a70d1aae
commit
8e3447b27a
5 files changed
+10
-42
No files matched your search
@@ -4,8 +4,6 @@
|
||||
|
||||
### Unreleased
|
||||
|
||||
- 🧷 **底部入口改成「只在未展开时出现」**:展开态由面板自己的收起控件(页签条右端的 ×)负责,头部再来一个「收起」既冗余、又多一个要跟宿主 chrome 抢位置的状态。现在展开后入口退场(头部与备用入口都退),收起后重新出现——顺带把「展开态该把入口摆哪儿」这个问题整个去掉了。`tests/e2e/blank-session-dock-entry.e2e.ts` 已按新语义改写并在真机跑过:空白会话可见 1 个入口 → 点开后面板出现且**屏上 0 个入口** → 发首条消息备用入口退场 → 用面板 × 收起后会话头入口回来、仍是 1 套。
|
||||
|
||||
- 🧷 **再修一处同源的碰撞:右侧栏打开时,空白会话的底部入口压在宿主「收起右侧栏」上**。备用入口是按宿主**角落控件**的 rect 左移 8+28px 定位的,但那只认控件**关闭形态**的属性 `data-sidebar-right-expand`——右侧栏**打开**时这个属性整个消失、同一个座位换成 `data-sidebar-right-toggle`,于是定位落到视口兜底坐标(`innerWidth - 44`),而那里正是宿主自己的角落按钮群。实测 2200px 视口、右侧栏打开时:入口落在 `2156..2184`,与宿主「Collapse right sidebar」(`2166..2194`)**重叠 18px**、并切到「Fullscreen」2px——与用户截图逐字一致。现在锚点同时认两种形态,**并且让位不再是一个固定偏移**——宿主的角落控件是肩并肩一簇(打开态实测 `Split@2094 / Fullscreen@2130 / Collapse@2166`,各 28px、间隔 8px),只往左挪 36px 会精确落在**下一个**按钮上(实测压住 Fullscreen 28x28px),所以改为逐个槽位左移直到与**任何**宿主按钮都不相交。真机复测(2200px 视口):关闭态入口 `2124..2152`、宿主 `Open right sidebar@2160`,打开态入口让到 `2058..2086`、整簇从 `2094` 起——**两种状态都零重叠**。**占位判定改用命中测试**:早先按 `button, [role="button"]` 筛「谁占着这一格」,而右侧栏的**页签芯片**不是这两者——页签一多,让位就停在芯片上(用户报的「tab 多的时候位置也错误」)。现在用 `document.elementsFromPoint` 直接问页面「这一格下面有什么」:**不透明的小控件**(≤300px 宽,含页签芯片)算占位,整行的背景板(会话头 titleRow、面板 tabStrip、面板本体)不算;并且沿水平方向采 **5 个点**——只测中心点会漏掉「中心空着、右缘却压着邻居」的情况(实测这样压住 Split/Fullscreen)。让位步长同时收到 4px。判别性用例见 `tests/dock-fallback.spec.tsx`(还原锚点即红 `expected '980px' to be '464px'`;关掉让位步进即红 `expected '464px' to be '428px'`)。
|
||||
|
||||
- 🧷 **修掉「展开底部面板」按钮在会话头与备用入口之间叠成两个**:blank 会话里宿主不渲染会话头,插件的会话头入口随之不可达,于是空白会话专用入口以 `position: fixed` 贴到宿主「Open right sidebar」按钮左侧(#698 / #623)。但**相位判定不足以互斥**——相位是每 1s 轮询来的,而会话头入口由宿主自行决定何时渲染,两者之间必然存在窗口(相位读取失败时还会按「非 blank」降级,一个从未成功读到的会话可能一直停在 blank);而两套入口在版面上**就是同一个位置**,同时在场即精确重叠成一团。现在除相位外再加一条与相位无关的兜底:**会话头那套入口只要真的在 DOM 里,备用入口就让位**,判别性用例见 `tests/dock-fallback.spec.tsx`(造出「相位说 blank + 会话头入口在场」的不一致状态,还原守卫即红)。最多 500ms 的让位延迟(与位置对齐同一节拍)。
|
||||
|
||||
+6
-11
@@ -771,30 +771,25 @@ export function Sidebar(props: { ctx: Context; store: SidebarStore }) {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* The control that EXPANDS the bottom workbench (see
|
||||
* sidebar/bottom-toggle.tsx — registered into DSH's session header).
|
||||
*
|
||||
* **只在未展开时出现**:展开态由面板自己的收起控件(`.bottomClose`,面板页签条
|
||||
* 右端那个 ×)负责,头部再来一个「收起」既冗余、又多一个要跟宿主 chrome 抢位置的
|
||||
* 状态。收起后本按钮重新出现。
|
||||
*/
|
||||
/** The header control that expands/collapses the bottom workbench (see
|
||||
* sidebar/bottom-toggle.tsx — registered into DSH's session header). */
|
||||
export function BottomDockToggle(props: { store: SidebarStore }) {
|
||||
const { store } = props
|
||||
const snapshot = useSyncExternalStore(
|
||||
useCallback((callback: () => void) => store.subscribe(callback), [store]),
|
||||
useCallback(() => store.getSnapshot(), [store]),
|
||||
)
|
||||
if (snapshot.state?.bottomOpen === true) return null
|
||||
const label = t('expandBottomPanel')
|
||||
const open = snapshot.state?.bottomOpen === true
|
||||
const label = open ? t('collapseBottomPanel') : t('expandBottomPanel')
|
||||
return (
|
||||
<Tooltip label={label} side="bottom" delayMs={500}>
|
||||
<button
|
||||
type="button"
|
||||
className={css.toggleButton}
|
||||
data-dsh-bottom-toggle
|
||||
data-active={open ? 'true' : undefined}
|
||||
aria-label={label}
|
||||
aria-pressed={false}
|
||||
aria-pressed={open}
|
||||
onClick={() => { store.reduce(toggleBottomPanel) }}
|
||||
>
|
||||
<IconPanelBottomOutline16 size={15} />
|
||||
|
||||
@@ -163,9 +163,6 @@ export function DockFallback({ store }: { store: SidebarStore }): ReactNode {
|
||||
if (phase === undefined || !phase.blank) return null
|
||||
// 兜底:相位说 blank、但会话头的入口确实在 DOM 里 —— 让位,绝不叠出第二套。
|
||||
if (headerEntry) return null
|
||||
// 底栏已经展开时不渲染(里面那个按钮本身也会返回 null,这里连空壳一起省掉):
|
||||
// 收起由面板自己的 × 负责。
|
||||
if (snapshot.state?.bottomOpen === true) return null
|
||||
// portal 到 body:面板宿主(z 20-30)的层叠上下文压不过会话头,按钮会被 titleRow
|
||||
// 拦截点击。40 高于 AppFrame(20) 与会话头、低于 DSH 浮层(100+)。
|
||||
return createPortal(
|
||||
|
||||
@@ -20,7 +20,7 @@ import './browser-globals.ts'
|
||||
import { renderRoot, setupReactAct } from './test-utils.ts'
|
||||
import { DockFallback } from '../src/client/sidebar/dock-fallback.tsx'
|
||||
import { sessionPhase } from '../src/client/api.ts'
|
||||
import { createSidebarStore, toggleBottomPanel } from '../src/client/state.ts'
|
||||
import { createSidebarStore } from '../src/client/state.ts'
|
||||
|
||||
setupReactAct()
|
||||
|
||||
@@ -215,24 +215,6 @@ describe('dock fallback(空白会话入口)', () => {
|
||||
}
|
||||
})
|
||||
|
||||
// 「只有没展开的时候才显示」:展开态由面板自己的 × 收起,头部入口退场 ——
|
||||
// 顺带把「头部入口 vs 备用入口」要争的那个位置从展开态整个去掉。
|
||||
it('renders no entry at all while the bottom workbench is open', async () => {
|
||||
phaseIs(true)
|
||||
const { unmount, store } = renderDockFallback()
|
||||
try {
|
||||
await vi.waitFor(() => {
|
||||
expect(document.querySelector('[data-dsh-dock-fallback]'), '未展开时备用入口应当在').not.toBeNull()
|
||||
})
|
||||
act(() => { store.reduce(toggleBottomPanel) })
|
||||
expect(store.getSnapshot().state?.bottomOpen, '底栏已展开').toBe(true)
|
||||
expect(document.querySelector('[data-dsh-dock-fallback]'), '展开态不该有备用入口').toBeNull()
|
||||
expect(document.querySelector('[data-dsh-bottom-toggle]'), '展开态一个底部入口都没有').toBeNull()
|
||||
} finally {
|
||||
unmount()
|
||||
}
|
||||
})
|
||||
|
||||
it('degrades to nothing when the host route is unavailable', async () => {
|
||||
vi.mocked(sessionPhase).mockRejectedValue(new Error('unsupported'))
|
||||
const { unmount } = renderDockFallback()
|
||||
|
||||
@@ -91,19 +91,15 @@ test('a blank session keeps the bottom workbench reachable from the top-right en
|
||||
await expect(page.locator('[data-sidebar-right-expand]'), '宿主的侧边栏按钮仍在').toBeVisible()
|
||||
await expect.poll(() => onScreenCount(page), { timeout: 30_000 }).toBe(1)
|
||||
|
||||
// 点击 → 底部面板真的展开;**入口随即退场**(它只在未展开时出现,收起交给面板
|
||||
// 自己的 ×),所以展开态屏幕上一个入口都不该有。
|
||||
// 点击 → 打开态 + 底部面板真的展开。
|
||||
const bottomEntry = fallback.locator('[data-dsh-bottom-toggle]')
|
||||
await bottomEntry.click()
|
||||
await expect(bottomEntry).toHaveAttribute('data-active', 'true')
|
||||
await expect(page.locator('[data-dsh-bottom-panel]').first()).toBeVisible()
|
||||
await expect(bottomEntry, '展开后入口退场').toHaveCount(0, { timeout: 30_000 })
|
||||
await expect.poll(() => onScreenCount(page), { timeout: 30_000 }).toBe(0)
|
||||
|
||||
// 发出第一条消息 → 会话脱离 blank:备用入口退场,入口交回会话头。
|
||||
// 发出第一条消息 → 会话脱离 blank:备用入口退场,入口交回会话头,仍只有一套。
|
||||
await sendFirstMessage(page)
|
||||
await expect(fallback, '会话头恢复后备用入口退场').toHaveCount(0, { timeout: 60_000 })
|
||||
// 用面板自己的 × 收起 → 会话头那个「展开」入口回来,且仍然只有一套。
|
||||
await page.locator('[data-dsh-bottom-panel] [class*="bottomClose"]').first().click()
|
||||
await expect.poll(() => onScreenCount(page), { timeout: 30_000 }).toBe(1)
|
||||
|
||||
expect(pageErrors, 'uncaught page errors').toEqual([])
|
||||
|
||||
Reference in new issue
Block a user