fix: docs
This commit is contained in:
imccyu
2026-07-30 15:56:41 +08:00
parent 085383b145
commit 1e10966ef6
160 changed files with 2521 additions and 1135 deletions
@@ -10,8 +10,13 @@
import { Fragment, useEffect, useRef, useSyncExternalStore } from 'react'
import clsx from 'clsx'
import { useAnchoredMaxHeight } from '@deepseek-ai/dsh-client-ui-primitives'
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
import css from './MenuView.module.css'
import type { MenuViewInjected } from './slots.ts'
import type { MenuKey } from './locales.ts'
/** Full menu props: injected face + the locale seat. */
export type MenuViewProps = MenuViewInjected & PropsLocale<'slash.menu'>
/** Design cap on the list height (figma SLASH 39:26572 MenuDropdown). */
const MAX_HEIGHT = 320
@@ -23,10 +28,10 @@ function optionId(source: string, index: number): string {
/**
* Render the candidate menu overlay entry.
* @param props - injected face: the menu store, the pick route, and the menu-namespace translator.
* @param props - injected face (the menu store and the pick route); `t` rides the standard locale seat.
* @returns the dropdown while open; null while closed.
*/
export function MenuView({ menu, onPick, onDismiss, t }: MenuViewInjected) {
export function MenuView({ menu, onPick, onDismiss, t }: MenuViewProps) {
const state = useSyncExternalStore(
fn => menu.subscribe(fn),
() => menu.getSnapshot(),
@@ -65,7 +70,7 @@ export function MenuView({ menu, onPick, onDismiss, t }: MenuViewInjected) {
className={css.menu}
style={{ maxHeight }}
role="listbox"
aria-label="Trigger suggestions"
aria-label={t('suggestions.aria')}
aria-activedescendant={highlight !== null ? optionId(highlight.source, highlight.index) : undefined}
>
<div className={css.viewport}>
@@ -73,7 +78,10 @@ export function MenuView({ menu, onPick, onDismiss, t }: MenuViewInjected) {
? null
: (
<Fragment key={group.source}>
<div className={css.groupTitle} role="presentation" data-source={group.source}>{t(group.source)}</div>
{/* Source names key the dictionary open-endedly: the lookup chain
returns an unknown key verbatim, so an unregistered source
shows its raw name — hence the cast past the typed key union. */}
<div className={css.groupTitle} role="presentation" data-source={group.source}>{t(group.source as MenuKey)}</div>
{group.status === 'pending'
? <div className={css.loading} data-source={group.source}>{t('loading')}</div>
: group.items.map((item, index) => {
+13 -9
View File
@@ -10,11 +10,14 @@ import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'
import { SlashService } from './service.ts'
import type { MenuViewInjected } from './slots.ts'
import { MenuView } from './MenuView.tsx'
import { en, zh, type MenuKey } from './locales.ts'
export { SlashService } from './service.ts'
export { SlashController } from './controller.ts'
export type { SlashControllerDeps, SourceRoster } from './controller.ts'
export type { MenuViewInjected } from './slots.ts'
export type { MenuViewProps } from './MenuView.tsx'
export type { MenuKey } from './locales.ts'
export type {
ArbitrateKey, ArbitrateOutcome, BeginCommandRequest, CandidateRequest, ClientSessionContext,
CommandClaim, ConsumeTokenRequest, InsertReferenceRequest, PickOutcome, PickVia, ReferenceCodec,
@@ -31,7 +34,14 @@ declare module 'cordis' {
}
}
/** Namespace owning the candidate-menu copy: group titles keyed by source name plus the pending row. */
declare module '@deepseek-ai/dsh-client-ui-slots' {
interface LocaleNamespaceMap {
/** The candidate menu's copy: group titles keyed by source name, the pending row, and the listbox aria. */
'slash.menu': MenuKey
}
}
/** Namespace owning the candidate-menu copy. */
const MENU_NS = 'slash.menu'
/** Required services: controller resolution reads the session scope tree; the menu copy is localized. */
@@ -44,13 +54,7 @@ export const inject = ['sessions', 'locale']
*/
export function apply(ctx: ClientContext): void {
ctx.plugin(SlashService)
ctx.effect(() => {
const disposers = [
ctx.locale.register(MENU_NS, 'zh', { command: '命令', skill: '技能', subagent: '子智能体', loading: '正在加载…' }),
ctx.locale.register(MENU_NS, 'en', { command: 'Commands', skill: 'Skills', subagent: 'Subagents', loading: 'Loading…' }),
]
return () => { for (const dispose of disposers) dispose() }
}, 'ui-slash: menu dictionaries')
ctx.effect(() => ctx.locale.register(MENU_NS, { zh, en }), 'ui-slash: menu dictionaries')
// Conditional mount: 'conversation.input.overlay' is declared by the
// conversation composer entry, and the conversation service is mounted
// after that declaration lands on the ledger — its presence is the
@@ -62,6 +66,7 @@ export function apply(ctx: ClientContext): void {
name: 'conversation.input.overlay',
id: 'slash-menu',
order: 0,
locale: MENU_NS,
inject: (sessionId): MenuViewInjected => {
// Session-scoped slot: resolve this session's controller (the slot
// frame hands ids, not ctx — the registered id→ctx interchange).
@@ -72,7 +77,6 @@ export function apply(ctx: ClientContext): void {
menu: controller.menu,
onPick: (source, index) => { controller.pick(source, index) },
onDismiss: () => { controller.dismiss() },
t: scope.locale.bind(MENU_NS),
}
},
}, MenuView), 'ui-slash: MenuView overlay registration')
@@ -0,0 +1,26 @@
/**
* `slash.menu` namespace dictionaries: group titles keyed by source name
* (the lookup chain returns the key itself, so an unknown source shows its
* raw name), the pending row, and the listbox aria label.
*/
/** Simplified Chinese dictionary (the key-set source of truth). */
export const zh = {
'command': '命令',
'skill': '技能',
'subagent': '子智能体',
'loading': '正在加载…',
'suggestions.aria': '触发候选建议',
} satisfies Record<string, string>
/** The slash.menu namespace key union. */
export type MenuKey = keyof typeof zh
/** English dictionary, checked complete against the zh key set. */
export const en = {
'command': 'Commands',
'skill': 'Skills',
'subagent': 'Subagents',
'loading': 'Loading…',
'suggestions.aria': 'Trigger suggestions',
} satisfies Record<MenuKey, string>
+1 -8
View File
@@ -9,7 +9,6 @@
*/
// Type-only edge: the SlotMap augmentation below merges into this package's interface.
import type {} from '@deepseek-ai/dsh-client-ui-slots'
import type { Translate } from '@deepseek-ai/dsh-client-locale/client'
import type { SnapshotStore } from '@deepseek-ai/dsh-client-runtime/client'
import type { MenuState } from '../core/contract.ts'
@@ -26,7 +25,7 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
}
}
/** Injected business face of the MenuView overlay entry. */
/** Injected business face of the MenuView overlay entry (copy rides the standard locale seat, not this face). */
export interface MenuViewInjected {
/** The service's menu state store (read-only here; MenuView subscribes). */
menu: SnapshotStore<MenuState>
@@ -38,10 +37,4 @@ export interface MenuViewInjected {
onPick: (source: string, index: number) => void
/** Dismiss the menu (external pointer outside the composer area). */
onDismiss: () => void
/**
* Bound translator for the menu namespace: group titles keyed by source
* name (the locale fallback chain returns the key itself, so an unknown
* source shows its raw name) plus the pending-row text.
*/
t: Translate
}