From fac99939fa47e15504db5706a35dd50340360761 Mon Sep 17 00:00:00 2001 From: weichen Date: Mon, 12 Oct 2026 02:49:46 +0000 Subject: [PATCH] Move AdminZoneSection out of the generated contracts mirror Why: src/contracts.ts is fully regenerated from Core by make contracts; the hand-added interface there is deleted on every sync (surfaced as a dirty tree in the Dev composite test run). Evidence: npx vitest run 101/101, tsc --noEmit clean, knip 42 <= 43; Dev composite CI is authoritative. Impact: AdminZoneSection now lives in api.ts (backend-only endpoint type, matching existing local-type precedent); contracts.ts restored to the generated mirror; imports updated in store and AdminZone. Refs: WP3-I3; follows Frontend PR #63. --- src/api.ts | 7 ++++++- src/components/AdminZone.tsx | 2 +- src/contracts.ts | 7 ------- src/store.ts | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/api.ts b/src/api.ts index be0a0c9..8edca83 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,7 +1,7 @@ // API 客户端(API-first:UI 只是第一个客户端)与 SSE 流客户端(游标重放 + 终态对账)。 // 认证:服务端开启 API key 时经 auth.fetch/withKey 注入凭证(嵌入式档无认证则透传)。 import { auth } from './auth' -import type { AdminZoneSection, +import type { Project, Conversation, Message, Run, Artifact, HITLCard, HITLResponse, AgentProfile, SettingDesc, StreamEvent, StreamEventType, PlanSnapshot, TodoList, UploadInfo, PromptModule, ActivityCard, @@ -9,6 +9,11 @@ import type { AdminZoneSection, const BASE = '' +/** 管理区声明分区(WP3-I3/KTD4,backend 专属端点类型):编译插件经 + * Registry.AddAdminZone 声明;入口不做前端权限合并,区内数据能力由组件 + * 自身命令面 fail-closed。 */ +export interface AdminZoneSection { id: string; title: string; icon?: string; desc?: string; order?: number } + async function json(res: Response): Promise { if (!res.ok) { const text = await res.text() diff --git a/src/components/AdminZone.tsx b/src/components/AdminZone.tsx index 5061901..a5f50a4 100644 --- a/src/components/AdminZone.tsx +++ b/src/components/AdminZone.tsx @@ -9,7 +9,7 @@ import { store, useStore } from '../store' import { EmptyState, Icon, type IconName } from '@ui' import { UsersPanel, ProfilesSection, PluginsSection, PluginWorkspacesPanel } from './adminSections' import { RdmAuditWorkspace } from './RdmAuditWorkspace' -import type { AdminZoneSection } from '../contracts' +import type { AdminZoneSection } from '../api' interface AdminSectionDef { key: string diff --git a/src/contracts.ts b/src/contracts.ts index 1feb97e..da69011 100644 --- a/src/contracts.ts +++ b/src/contracts.ts @@ -288,13 +288,6 @@ export interface PluginManifest { backend?: { mode?: 'inproc' | 'sidecar'; command?: string; args?: string[]; schemaVersion?: number }; } -// ---- 管理区声明分区(WP3-I3/KTD4)---- -/** 编译插件经 Registry.AddAdminZone 声明的管理区展示分区;入口不做前端权限合并, - * 分区内数据能力由组件自身的命令面 fail-closed。 */ -export interface AdminZoneSection { - id: string; title: string; icon?: string; desc?: string; order?: number; -} - export interface PluginPanel { id: string; title: string; icon?: string; body: UINode[]; refreshTool?: string; } diff --git a/src/store.ts b/src/store.ts index dfc82f9..b8bad35 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1,7 +1,7 @@ // 应用状态:服务端权威(事件 + Query 对账),前端 store 是投影。 // useSyncExternalStore 驱动;live 流式部件为会话内临时态,run 终态后由消息树对账收敛。 import { useSyncExternalStore } from 'react' -import { api, connectEvents } from './api' +import { type AdminZoneSection, api, connectEvents } from './api' import { applyTextDelta, applyThinkingDelta, applyToolCall, applyToolCallDelta, applyToolResult, applyToolOutput, applyArtifactCreated, applyArtifactUpdated, applyCheck, applyFinalizing, type LiveItem } from './live' import { closePreviewTab, mergeOrphanPreviewTabs, openPreviewTab, previewTabsKey, type PreviewTab } from './previewtabs' import { deliveryRequestId, enqueueMessage, enqueueMessageFront, newQueuedMessage, promoteQueuedMessage, removeQueuedMessage, replaceQueuedText, type QueuedMessage } from './outbox' @@ -15,7 +15,7 @@ const FONT_SIZE_CHOICES: readonly FontSizeChoice[] = [13, 14, 16, 18] export function isFontSizeChoice(value: number): value is FontSizeChoice { return (FONT_SIZE_CHOICES as readonly number[]).includes(value) } -import type { AdminZoneSection, +import type { ActivityCard, AgentProfile, Artifact,