1. 统一会话列宽度轴:新增 --dsh-chat-content-width(748px),输入框、todo、goal、queue、approval、plan review、ask question 等容器的宽度与边距全部由该变量推导,消除各面板之间的像素漂移,窄视口下的边缘留白也保持一致。 2. 输入框自适应与细节:控制行改为容器查询(460px 阈值以下权限选择器只显示图标+下拉,隐藏文字);卡片圆角 20→22、行内边距调整并整体下移 2px(发送按钮除外);permission/model 触发器统一 24px 圆角;Plan 与 Read Only 间距 +8。 3. 修复浮层菜单溢出:slash 菜单与命令弹层钳制到输入卡片宽度,超长行以省略号截断;Tooltip 增加 12px 视口边缘安全距离。 4. 增加与替换图标:Add provider 改用输入框同款加号图标(IconPlusOutline16),统一图标尺寸与字号。 5. 统一 Settings → Models 组件:补齐按钮 hover 态、select 下拉箭头不再贴边、标题区与 provider 卡片间距 +12。 6. 侧边栏交互:add workspace / group by / create session / 收起侧边栏四个图标按钮增加 500ms 延迟 tooltip(前两个向下弹出);展开态的 New Session 不再重复显示 tooltip;侧边栏窄屏自适应收起逻辑微调。 7. 其他:hero 区 workspace 徽章右移对齐;附带 Agent Note(中英双语)记录共享宽度轴与容器查询的设计取舍。
104 lines
4.0 KiB
TypeScript
104 lines
4.0 KiB
TypeScript
// @vitest-environment jsdom
|
|
/**
|
|
* createLayoutStore unit account: init shape, the action write set (clamp
|
|
* inside actions), and the absence of browser persistence. Uses the
|
|
* test-sanctioned path: factory self-call + .create() gives the
|
|
* real engine instance (same create path as production).
|
|
*/
|
|
import { beforeEach, describe, expect, it } from 'vitest'
|
|
import { createLayoutStore } from '@deepseek-ai/dsh-client-ui-layout/src/client/stores.ts'
|
|
import {
|
|
DETAILS_DEFAULT, DETAILS_MAX, DETAILS_MIN,
|
|
SIDEBAR_DEFAULT, SIDEBAR_MAX, SIDEBAR_MIN,
|
|
} from '@deepseek-ai/dsh-client-ui-layout/src/client/columns.ts'
|
|
|
|
const PERSIST_KEY = 'dsh.layout.panels'
|
|
|
|
beforeEach(() => { localStorage.clear() })
|
|
|
|
describe('createLayoutStore', () => {
|
|
it('initializes the sidebar at its default width, details closed, wide viewport assumed', () => {
|
|
const { store } = createLayoutStore().create()
|
|
expect(store.getSnapshot()).toEqual({ sidebar: SIDEBAR_DEFAULT, details: 0, narrow: false, narrowExpanded: false })
|
|
})
|
|
|
|
it('each create() is an independent instance (factory is not a singleton)', () => {
|
|
const a = createLayoutStore().create()
|
|
const b = createLayoutStore().create()
|
|
a.actions.setSidebar(400)
|
|
expect(b.store.getSnapshot().sidebar).toBe(SIDEBAR_DEFAULT)
|
|
})
|
|
|
|
it('setSidebar/setDetails clamp into the contract ranges', () => {
|
|
const { store, actions } = createLayoutStore().create()
|
|
actions.setSidebar(1)
|
|
expect(store.getSnapshot().sidebar).toBe(SIDEBAR_MIN)
|
|
actions.setSidebar(9999)
|
|
expect(store.getSnapshot().sidebar).toBe(SIDEBAR_MAX)
|
|
actions.setDetails(1)
|
|
expect(store.getSnapshot().details).toBe(DETAILS_MIN)
|
|
actions.setDetails(9999)
|
|
expect(store.getSnapshot().details).toBe(DETAILS_MAX)
|
|
})
|
|
|
|
it('toggleSidebar flips closed <-> contract default (drag width forgotten)', () => {
|
|
const { store, actions } = createLayoutStore().create()
|
|
actions.setSidebar(400)
|
|
actions.toggleSidebar()
|
|
expect(store.getSnapshot().sidebar).toBe(0)
|
|
actions.toggleSidebar()
|
|
expect(store.getSnapshot().sidebar).toBe(SIDEBAR_DEFAULT)
|
|
})
|
|
|
|
it('narrow toggleSidebar flips only the re-expand override; the width preference survives', () => {
|
|
const { store, actions } = createLayoutStore().create()
|
|
actions.setSidebar(400)
|
|
actions.setNarrow(true)
|
|
actions.toggleSidebar()
|
|
expect(store.getSnapshot()).toEqual({ sidebar: 400, details: 0, narrow: true, narrowExpanded: true })
|
|
actions.toggleSidebar()
|
|
expect(store.getSnapshot().narrowExpanded).toBe(false)
|
|
expect(store.getSnapshot().sidebar).toBe(400)
|
|
})
|
|
|
|
it('crossing the breakpoint drops the override; a same-value setNarrow keeps it', () => {
|
|
const { store, actions } = createLayoutStore().create()
|
|
actions.setNarrow(true)
|
|
actions.toggleSidebar()
|
|
expect(store.getSnapshot().narrowExpanded).toBe(true)
|
|
actions.setNarrow(true)
|
|
expect(store.getSnapshot().narrowExpanded).toBe(true)
|
|
actions.setNarrow(false)
|
|
expect(store.getSnapshot()).toMatchObject({ narrow: false, narrowExpanded: false })
|
|
actions.setNarrow(true)
|
|
expect(store.getSnapshot().narrowExpanded).toBe(false)
|
|
})
|
|
|
|
it('openDetails uses the contract default, preserves an open width, and closeDetails zeroes', () => {
|
|
const { store, actions } = createLayoutStore().create()
|
|
actions.openDetails()
|
|
expect(store.getSnapshot().details).toBe(DETAILS_DEFAULT)
|
|
actions.setDetails(500)
|
|
actions.openDetails()
|
|
expect(store.getSnapshot().details).toBe(500)
|
|
actions.closeDetails()
|
|
expect(store.getSnapshot().details).toBe(0)
|
|
})
|
|
|
|
it('does not persist panel geometry', () => {
|
|
const first = createLayoutStore().create()
|
|
first.actions.setSidebar(400)
|
|
first.actions.openDetails()
|
|
first.actions.setDetails(500)
|
|
expect(localStorage.getItem(PERSIST_KEY)).toBeNull()
|
|
|
|
const second = createLayoutStore().create()
|
|
expect(second.store.getSnapshot()).toEqual({
|
|
sidebar: SIDEBAR_DEFAULT,
|
|
details: 0,
|
|
narrow: false,
|
|
narrowExpanded: false,
|
|
})
|
|
})
|
|
})
|