Merge remote-tracking branch 'origin/master' into mergebot/pr1005

# Conflicts:
#	docs/module-graph.md
#	packages/client/ui-conversation/README.i18n.yaml
#	packages/client/ui-conversation/README.md
#	packages/client/ui-conversation/README.zh.md
#	packages/client/ui-conversation/src/client/apply.ts
#	packages/client/ui-conversation/src/client/skeleton/InputBar.tsx
#	packages/client/ui-conversation/tests/input-bar.spec.tsx
#	packages/client/ui-conversation/tests/input-matrix.spec.tsx
#	packages/client/ui-plan/README.i18n.yaml
#	packages/client/ui-plan/README.md
#	packages/client/ui-plan/README.zh.md
#	packages/client/ui-plan/src/client/PlanModeControl.tsx
#	packages/client/ui-plan/src/client/index.ts
#	packages/client/ui-plan/tests/browser-plugin.spec.ts
#	packages/client/ui-plan/tests/plan-mode-control.spec.tsx
This commit is contained in:
imccyu
2026-07-31 03:47:24 +08:00
238 changed files with 3273 additions and 1304 deletions

View File

@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react'
import type { InjectFace, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
import { IconCloseFill14 } from '@deepseek-ai/dsh-client-ui-primitives'
// Type-only: pulls the ui-conversation SlotMap merge (the input.plan seat and
// its {locked} owner share).
@@ -7,16 +7,16 @@ import type {} from '@deepseek-ai/dsh-client-ui-conversation/client'
import type { PlanChipInjected } from './index.ts'
import css from './PlanModeControl.module.css'
/** Full plan-seat component props: runtime share (standard kit + locked owner prop) & injected share. */
/** Full plan-seat component props: runtime share (standard kit + locked owner prop) & injected share & the locale seat. */
export type PlanChipProps =
PropsRuntime<'conversation.input.plan'> & InjectFace<PlanChipInjected>
PropsRuntime<'conversation.input.plan'> & InjectFace<PlanChipInjected> & PropsLocale<'plan'>
/**
* Plan-mode status over the host-computed `plan` projection. The chip renders
* only while the effective target is plan mode (`pending ? !active : active`
* — a folded host value, not client optimism) and executes /plan off.
*/
export function PlanChip({ useProjection, locked, exitPlanMode }: PlanChipProps) {
export function PlanChip({ useProjection, locked, exitPlanMode, t }: PlanChipProps) {
const plan = useProjection('plan')
const [leaving, setLeaving] = useState(false)
const [error, setError] = useState<string | null>(null)
@@ -34,6 +34,7 @@ export function PlanChip({ useProjection, locked, exitPlanMode }: PlanChipProps)
if (!target) return null
const off = (): void => {
// No leaving/locked guard: both disable the button, so no click arrives.
setLeaving(true)
setError(null)
void exitPlanMode().then((failure) => {
@@ -52,17 +53,19 @@ export function PlanChip({ useProjection, locked, exitPlanMode }: PlanChipProps)
<button
type="button"
className={css.chip}
aria-label="Plan mode on, press to turn off"
title="Plan mode on — click to turn off (/plan off)"
aria-label={t('chip.on.aria')}
title={t('chip.on.title')}
disabled={locked || leaving}
onClick={off}
>
{/* Design literal, not copy: the chip wordmark stays 'Plan' in every locale. */}
Plan
<span className={css.close} aria-hidden>
<IconCloseFill14 size={12} />
</span>
</button>
{error !== null && <span className={css.error} role="status" title={error}>退出 plan mode 失败</span>}
{/* Failure copy stays English (error-surface policy: not localized). */}
{error !== null && <span className={css.error} role="status" title={error}>failed to exit plan mode</span>}
</span>
)
}

View File

@@ -11,9 +11,24 @@ import type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client
import type { ClientContext, SessionId } from '@deepseek-ai/dsh-client-runtime/client'
// Type-only: pulls the ui-conversation SlotMap merge (the input.plan seat).
import type {} from '@deepseek-ai/dsh-client-ui-conversation/client'
// Type-only: pulls the locale plugin's Context merge (ctx.locale).
import type {} from '@deepseek-ai/dsh-client-locale/client'
// Type-only: pulls the `plan` SessionProjectionMap merge for useProjection.
import type {} from '@deepseek-ai/dsh-plan-mode/client'
import { PlanChip } from './PlanModeControl.tsx'
import { en, zh, type PlanKey } from './locales.ts'
export type { PlanKey } from './locales.ts'
declare module '@deepseek-ai/dsh-client-ui-slots' {
interface LocaleNamespaceMap {
/** The composer plan chip's copy. */
plan: PlanKey
}
}
/** Dictionary namespace owned by this plugin. */
const NS = 'plan'
/** Injected business face of the composer plan seat. */
export interface PlanChipInjected {
@@ -25,24 +40,29 @@ export interface PlanChipInjected {
}
/**
* Required services: the seat's slot registry, the transport, and the
* conversation service whose presence guarantees the seat is declared.
* Required services: the seat's slot registry, the transport, the copy's
* locale registry, and the conversation service whose presence guarantees
* the seat is declared.
*/
export const inject = ['slots', 'connection', 'conversation']
export const inject = ['slots', 'connection', 'conversation', 'locale']
/**
* Client plugin body: register the plan chip over the command channel.
* @param ctx - client root context.
*/
export function apply(ctx: ClientContext): void {
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'ui-plan: dictionaries')
ctx.effect(() => ctx.slots.register({
name: 'conversation.input.plan',
locale: NS,
inject: (sessionId: SessionId): PlanChipInjected => ({
// Failure strings stay English (error-surface policy: not localized).
exitPlanMode: async () => {
const connection = ctx.get('connection') as ConnectionHandle
const { result } = await connection.api.commands.execute({ sessionId, line: '/plan off' })
if (!result.ok) return `${result.error.message}(${result.error.code})`
if (!result.value.matched) return '未知命令:/plan off'
if (!result.ok) return `${result.error.message} (${result.error.code})`
if (!result.value.matched) return 'unknown command: /plan off'
return null
},
}),

View File

@@ -0,0 +1,20 @@
/** `plan` namespace dictionaries (the composer plan chip's copy). */
/** Simplified Chinese dictionary (the key-set source of truth). */
export const zh = {
'chip.on.aria': 'plan mode 已开启,按下关闭',
'chip.on.title': 'plan mode 已开启 — 点击关闭(/plan off)',
'chip.off.aria': 'plan mode 已关闭,按下开启',
'chip.off.title': 'plan mode 已关闭 — 点击开启(/plan)',
} satisfies Record<string, string>
/** The plan namespace key union. */
export type PlanKey = keyof typeof zh
/** English dictionary, checked complete against the zh key set. */
export const en = {
'chip.on.aria': 'Plan mode on, press to turn off',
'chip.on.title': 'Plan mode on — click to turn off (/plan off)',
'chip.off.aria': 'Plan mode off, press to turn on',
'chip.off.title': 'Plan mode off — click to turn on (/plan)',
} satisfies Record<PlanKey, string>