Merge pull request 'chore(types): green typecheck' (#3) from chore/typecheck-green into main

This commit is contained in:
QQ 2026-11-14 17:55:59 +08:00
commit 36785ffa08
6 changed files with 71 additions and 17 deletions

View File

@ -20,6 +20,13 @@ window.__ModuleLoader__.load({
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
let react_jsx_runtime = require("react/jsx-runtime");
// src/client/chat/bindings.ts
/** 「始终允许」的默认键帽;单列出来,展开时不会沾上 `null` 带来的可选键。 */
const DEFAULT_ALWAYS = {
key: "Enter",
primary: true,
shift: false,
alt: false
};
const DEFAULT_BINDINGS = {
allow: {
key: "Enter",
@ -27,12 +34,7 @@ window.__ModuleLoader__.load({
shift: false,
alt: false
},
always: {
key: "Enter",
primary: true,
shift: false,
alt: false
},
always: DEFAULT_ALWAYS,
reject: {
key: "Escape",
primary: false,
@ -95,16 +97,16 @@ window.__ModuleLoader__.load({
const rejectRaw = normalizeBinding(record.reject);
const allow = allowRaw && allowRaw.key === "Enter" ? allowRaw : { ...DEFAULT_BINDINGS.allow };
const reject = rejectRaw && rejectRaw.key === "Escape" ? rejectRaw : { ...DEFAULT_BINDINGS.reject };
const alwaysRaw = "always" in record ? record.always : DEFAULT_BINDINGS.always;
const alwaysRaw = "always" in record ? record.always : DEFAULT_ALWAYS;
const alwaysParsed = alwaysRaw === null ? null : normalizeBinding(alwaysRaw);
const out = {
allow,
always: alwaysParsed && alwaysParsed.key === "Enter" ? alwaysParsed : alwaysRaw === null ? null : { ...DEFAULT_BINDINGS.always },
always: alwaysRaw === null ? null : alwaysParsed && alwaysParsed.key === "Enter" ? alwaysParsed : { ...DEFAULT_ALWAYS },
reject
};
if (out.always && (!hasModifier(out.always) || bindingsEqual(out.allow, out.always))) {
out.allow = { ...DEFAULT_BINDINGS.allow };
out.always = { ...DEFAULT_BINDINGS.always };
out.always = { ...DEFAULT_ALWAYS };
}
if (out.always && bindingsEqual(out.reject, out.always)) out.reject = { ...DEFAULT_BINDINGS.reject };
if (bindingsEqual(out.allow, out.reject)) {

File diff suppressed because one or more lines are too long

View File

@ -32,9 +32,12 @@ export interface KeyEventLike {
altKey?: boolean
}
/** 「始终允许」的默认键帽;单列出来,展开时不会沾上 `null` 带来的可选键。 */
export const DEFAULT_ALWAYS: ApprovalBinding = { key: 'Enter', primary: true, shift: false, alt: false }
export const DEFAULT_BINDINGS: ApprovalBindings = {
allow: { key: 'Enter', primary: false, shift: false, alt: false },
always: { key: 'Enter', primary: true, shift: false, alt: false },
always: DEFAULT_ALWAYS,
reject: { key: 'Escape', primary: false, shift: false, alt: false },
}
@ -112,18 +115,20 @@ export function normalizeBindings(value: unknown): ApprovalBindings {
const rejectRaw = normalizeBinding(record.reject)
const allow = allowRaw && allowRaw.key === 'Enter' ? allowRaw : { ...DEFAULT_BINDINGS.allow }
const reject = rejectRaw && rejectRaw.key === 'Escape' ? rejectRaw : { ...DEFAULT_BINDINGS.reject }
const alwaysRaw = 'always' in record ? record.always : DEFAULT_BINDINGS.always
const alwaysRaw = 'always' in record ? record.always : DEFAULT_ALWAYS
const alwaysParsed = alwaysRaw === null ? null : normalizeBinding(alwaysRaw)
const always = alwaysParsed && alwaysParsed.key === 'Enter'
? alwaysParsed
: (alwaysRaw === null ? null : { ...DEFAULT_BINDINGS.always })
const always: ApprovalBinding | null = alwaysRaw === null
? null
: alwaysParsed && alwaysParsed.key === 'Enter'
? alwaysParsed
: { ...DEFAULT_ALWAYS }
const out: ApprovalBindings = { allow, always, reject }
// 冲突(或「始终允许」没修饰键)时把 allow/always 一起回落到默认,
// 避免一个按键命中两个动作;默认值本身互不冲突。
if (out.always && (!hasModifier(out.always) || bindingsEqual(out.allow, out.always))) {
out.allow = { ...DEFAULT_BINDINGS.allow }
out.always = { ...DEFAULT_BINDINGS.always }
out.always = { ...DEFAULT_ALWAYS }
}
if (out.always && bindingsEqual(out.reject, out.always)) {
out.reject = { ...DEFAULT_BINDINGS.reject }

35
src/client/host-augment.d.ts vendored Normal file
View File

@ -0,0 +1,35 @@
/**
* Structural faces for the host services this client plugin injects but whose
* packages are not published (see host-modules.d.ts). Kept deliberately small:
* only the members this plugin actually calls are typed, and the session face
* stays `any` because the host session facade is not part of the public API.
*/
import '@deepseek-ai/cordis';
export interface RemoteSessionFace {
openWorkspacePath: (arg: { path: string }) => Promise<{ ok: boolean; error?: { message: string } }>;
}
export interface RemoteFace {
/** Host projection store handed to the official reader host seat. */
$host: { home?: string };
session?: RemoteSessionFace;
}
export interface SessionsFace {
binding: (sessionId: string) => { session?: any } | undefined;
list: { getSnapshot: () => { byId: Record<string, { cwd?: string } | undefined> } };
}
declare module '@deepseek-ai/cordis' {
interface Context {
/** Injected as `remote` (see the client entry's `inject` array). */
remote: RemoteFace;
/** Injected as `sessions`. */
sessions: SessionsFace;
}
interface Events {
'connection/reset': () => void;
}
}

12
src/client/host-modules.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
/**
* Host-side client packages that the desktop build ships inside its own
* bundle but does not publish as installable dependencies. The plugin imports
* them only for their declaration-merging side effects (services and events on
* the Cordis context), so an empty ambient module is enough to keep the
* imports resolvable in this repository.
*/
declare module '@deepseek-ai/dsh-api-remotes/client' {}
declare module '@deepseek-ai/dsh-api-session-controller/client' {}
declare module '@deepseek-ai/dsh-client-connection/client' {}
declare module '@deepseek-ai/dsh-session-turn-outline/types' {}
declare module '@deepseek-ai/dsh-agent/types' {}

View File

@ -15,6 +15,6 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
'settings.section': { kind: 'list'; scope: 'root'; owner: SettingsSectionOwnerProps };
}
interface LocaleNamespaceMap {
'better-display': SettingsCopyKey;
'better-chat': SettingsCopyKey;
}
}