Root cause of the visual split:
1. Icon system mismatch: apes used react-icons (FiCpu/FiGrid/FiUser,
static 14px ReactNode) while native builtins use DSH's Icon*16
components (function form, host-controlled size). Two different
icon libraries → inconsistent visual style.
2. Order 901-903 pushed apes tabs far after native builtins (10-35),
creating two visually separate groups in the tab strip.
Fix:
- icon: react-icons Fi* → @deepseek-ai/dsh-client-ui-primitives
Icon*16 (function form, same as builtins):
agents → IconAgentPresetOutline16
apps → IconGaugeOutline16
profile → IconUserOutline16
- order: 901/902/903 → 40/45/50 (immediately after native builtins)
- SIDEBAR_SERVICE_VERSION + dsh.plugin.json version → 1.1.0
(lockstep with package.json, required by manifest tests)
Gate: typecheck ✓ / build ✓ / test 119 files · 1249 passed · 9 skipped · 0 failed ✓
123 lines
4.6 KiB
TypeScript
123 lines
4.6 KiB
TypeScript
/**
|
|
* apes:* tab registration tests (Phase 1/1b, C6: 3 tabs). The fork registers
|
|
* its three information-layer tabs (agents / apps / profile) through the same
|
|
* BetterSidebarService the upstream builtins use (dogfood). `apes:tasks` was
|
|
* removed in C6 — it overlaps the official DSH session tree in the native
|
|
* sidebar. The spec pins the registration contract (id / single / order /
|
|
* component presence) and the isolated i18n contract (the apes namespace
|
|
* resolves zh vs en through the attached locale service, and every apesZh
|
|
* key has an apesEn entry).
|
|
*
|
|
* Runs in the node vitest environment like builtins.spec.ts — no DOM, no
|
|
* real DSH host (a live cordis scratch mount is Phase 2+).
|
|
*/
|
|
import { describe, expect, it } from 'vitest'
|
|
// Browser globals before the client graph loads (mirror of builtins.spec.ts).
|
|
import './browser-globals.ts'
|
|
|
|
import type { Context } from '../src/context-types.ts'
|
|
import { createBetterSidebarService } from '../src/client/service.ts'
|
|
import { createSidebarStore } from '../src/client/state.ts'
|
|
import { registerApesTabs } from '../src/client/apes/index.ts'
|
|
import { apesZh, apesEn, attachApesLocale, t, type ApesCopyKey } from '../src/client/apes/locales.ts'
|
|
|
|
function setup(): {
|
|
service: ReturnType<typeof createBetterSidebarService>
|
|
store: ReturnType<typeof createSidebarStore>
|
|
dispose: () => void
|
|
} {
|
|
const store = createSidebarStore()
|
|
const service = createBetterSidebarService(store)
|
|
const dispose = registerApesTabs({} as Context, service)
|
|
return { service, store, dispose }
|
|
}
|
|
|
|
describe('apes:* tab registrations', () => {
|
|
it('registers the 3 apes tabs with the apes: namespace', () => {
|
|
const { service, dispose } = setup()
|
|
try {
|
|
expect(service.getTabs().map(t => t.id).sort()).toEqual(
|
|
['apes:agents', 'apes:apps', 'apes:profile'],
|
|
)
|
|
} finally {
|
|
dispose()
|
|
}
|
|
})
|
|
|
|
it('every apes tab is single-instance, visible, and component-carrying', () => {
|
|
const { service, dispose } = setup()
|
|
try {
|
|
for (const id of ['apes:agents', 'apes:apps', 'apes:profile']) {
|
|
const tab = service.getTab(id)
|
|
expect(tab, `${id} registered`).toBeDefined()
|
|
expect(tab?.single, `${id} single`).toBe(true)
|
|
expect(tab?.hidden, `${id} hidden`).not.toBe(true)
|
|
expect(tab?.component, `${id} component`).toBeDefined()
|
|
expect(tab?.icon, `${id} icon`).toBeDefined()
|
|
}
|
|
} finally {
|
|
dispose()
|
|
}
|
|
})
|
|
|
|
it('apes tabs sort after the upstream builtins (order 40+)', () => {
|
|
const { service, dispose } = setup()
|
|
try {
|
|
const orders = {
|
|
agents: service.getTab('apes:agents')?.order,
|
|
apps: service.getTab('apes:apps')?.order,
|
|
profile: service.getTab('apes:profile')?.order,
|
|
}
|
|
// C8: order 40-50 places apes tabs immediately after the native builtins
|
|
// (10-35), not in a far-away 900+ band — visual unity in the tab strip.
|
|
expect(orders.agents).toBeGreaterThanOrEqual(40)
|
|
expect(orders.apps).toBeGreaterThanOrEqual(40)
|
|
expect(orders.profile).toBeGreaterThanOrEqual(40)
|
|
// Strictly ordered: agents < apps < profile.
|
|
expect(orders.agents!).toBeLessThan(orders.apps!)
|
|
expect(orders.apps!).toBeLessThan(orders.profile!)
|
|
} finally {
|
|
dispose()
|
|
}
|
|
})
|
|
|
|
it('the disposer unregisters all apes tabs (HMR-safe)', () => {
|
|
const store = createSidebarStore()
|
|
const service = createBetterSidebarService(store)
|
|
const dispose = registerApesTabs({} as Context, service)
|
|
expect(service.getTabs()).toHaveLength(3)
|
|
dispose()
|
|
expect(service.getTabs()).toHaveLength(0)
|
|
})
|
|
})
|
|
|
|
describe('apes i18n contract', () => {
|
|
it('every apesZh key has an apesEn entry (no missing translations)', () => {
|
|
const zhKeys = Object.keys(apesZh) as ApesCopyKey[]
|
|
for (const key of zhKeys) {
|
|
expect(apesEn[key], `en entry for ${key}`).toBeDefined()
|
|
expect(typeof apesEn[key]).toBe('string')
|
|
expect((apesEn[key] ?? '').length).toBeGreaterThan(0)
|
|
}
|
|
})
|
|
|
|
it('resolves zh when the DSH preference is zh', () => {
|
|
attachApesLocale({ getSnapshot: () => ({ active: 'zh-CN' }) })
|
|
expect(t('apesAgentsTitle')).toBe('智能体')
|
|
expect(t('apesAppsTitle')).toBe('应用')
|
|
expect(t('apesProfileTitle')).toBe('画像')
|
|
})
|
|
|
|
it('resolves en when the DSH preference is en', () => {
|
|
attachApesLocale({ getSnapshot: () => ({ active: 'en' }) })
|
|
expect(t('apesAgentsTitle')).toBe('Agents')
|
|
expect(t('apesAppsTitle')).toBe('Apps')
|
|
expect(t('apesProfileTitle')).toBe('Profile')
|
|
})
|
|
|
|
it('falls back to zh when no locale service is attached', () => {
|
|
attachApesLocale(undefined)
|
|
expect(t('apesAgentsTitle')).toBe('智能体')
|
|
})
|
|
})
|