From 040b7285d7b72a951ed953dce204c0ff25beb58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E7=AB=A0=E6=B5=A9?= Date: Tue, 17 Nov 2026 13:38:25 +0800 Subject: [PATCH] =?UTF-8?q?style(release):=20=E6=94=B6=E6=95=9B=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E4=B8=BB=E6=B5=81=E7=A8=8B=E5=B9=B6=E6=8A=98=E5=8F=A0?= =?UTF-8?q?=E8=AF=8A=E6=96=AD=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根据封存、授权和作业状态切换唯一主动作,保留独立签发与执行确认。 收起变更、完整性、恢复验证和历史;维护占用及失败作业保持可见。 补充挂载交互回归和流程说明,保持原有 API 与恢复所有者约束。 验证:make verify 退出 0,本地全部必需门禁通过;前端 574 项通过, Go 1536 项通过、487 项声明的可选集成跳过。候选构建经只读代理 接入测试 API,核验切库、折叠与快照入口;未执行真实发布/恢复。 --- CHANGELOG.md | 6 + docs/release-ui-flow.md | 45 +++ web/src/ReleaseTargets.flow.test.tsx | 258 ++++++++++++ web/src/ReleaseTargets.test.tsx | 17 +- web/src/ReleaseTargets.tsx | 566 ++++++++++++++------------- web/src/releaseTargets.css | 98 +++++ 6 files changed, 700 insertions(+), 290 deletions(-) create mode 100644 docs/release-ui-flow.md create mode 100644 web/src/ReleaseTargets.flow.test.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index c1b1a5f..44ff282 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased] + +### Changed + +- 发布管理按封存、授权、同步与查看任务切换主操作,合并重复入口;变更明细、完整性和恢复验证按需展开,维护占用与失败作业保持可见。流程说明见 [发布管理流程与页面精简](docs/release-ui-flow.md)。 + ## 开发快照 0.1.382(采集 agent 允许显式 peer uid) ### Added diff --git a/docs/release-ui-flow.md b/docs/release-ui-flow.md new file mode 100644 index 0000000..f3c4b6b --- /dev/null +++ b/docs/release-ui-flow.md @@ -0,0 +1,45 @@ +# 发布管理流程与页面精简 + +## 目标与边界 + +现有整库发布页面同时呈现日常发布、维护诊断、恢复演练与历史快照,且封存操作位于页面底部,版本入口重复。此次优化聚焦 `ReleaseTargets` 的信息层级和操作位置,沿用现有 API、权限、授权绑定、维护所有者与恢复确认。 + +基线采用云测试站当前前端对应的工作树 `cbc6b98`;该提交的 web 与部署版本 `0b753e5` 相同。并行主干及其他工作树不合并、不覆盖。 + +## 操作者主流程 + +| 顺序 | 页面操作 | 后台行为 | 完成边界 | +| --- | --- | --- | --- | +| 1 | 选择对内或对外知识库 | 读取该范围 overview、快照、作业及维护窗口 | 目标身份与版本来自所选范围;读取失败不当作空库 | +| 2 | 封存测试版本 | POST `/api/v1/library/captures`,由队列及执行器捕获测试整库版本 | 投递不等于完成,以作业与登记快照为准;此步不发布生产 | +| 3 | 查看变更及发布条件 | 展开变更、备份与恢复验证;若缺基线或恢复证据,沿用对应管理员入口 | 逐条呈现服务端阻塞原因,不删除发布门槛 | +| 4 | 签发同步授权 | 管理员调用 `/api/v1/library/authorizations`,绑定目标与当前快照 | 有效期内仍需单独点击启动;不自动执行同步 | +| 5 | 启动同步 | 沿用现有同步请求与执行链:固定版本、生产预备份、同步、校验及收尾 | 只在接口条件允许时可执行;运行中主按钮改为查看任务 | +| 6 | 查看结果 | 自动刷新作业进度,终态按真实记录呈现 | 失败显示原始原因;维护占用不被其他作业成功覆盖 | +| 异常 | 从版本与快照选择恢复点 | 继续执行独立恢复授权、影响确认和恢复条件校验 | 恢复整套目标知识状态,不回退测试知识库 | + +封存、签发授权、启动同步三个动作保持独立,不将其合并为一键生产写入。 + +## 页面保留规则 + +- 顶栏:唯一的「版本与快照」入口和刷新。 +- 主工作区:实际目标身份、当前生产版本、候选测试版本、紧凑变更统计、当前主动作与一份阻塞原因。 +- 已有封存时提供次级「重新封存」;运行时不提供重复封存、授权或同步入口。 +- 「查看变更明细」「发布准备与恢复验证」「封存完整性」默认折叠;原有详情和验证回调继续存在。 +- 目标维护正常时折叠,持有维护窗口时自动展开;仍按窗口持有作业展示恢复信息。 +- 最近作业仅在有记录时展示,正常完成默认折叠,失败默认展开;运行中保留主进度,分项明细按需展开。 +- 版本抽屉保留历史筛选、分页、校验记录、恢复授权和影响确认,移除重复的封存按钮。 +- 旧文档级流程与历史来源关联继续保留在原有折叠入口,此次不改变其业务范围。 + +## 验收清单 + +- [x] 前端生产构建通过。 +- [x] 原发布、恢复、维护所有者和刷新/切库回归通过。 +- [x] 同一挂载下依次切换封存、授权、同步,点击只调用对应动作。 +- [x] 折叠与展开、打开历史不触发业务写入。 +- [x] 运行时主操作只查看任务,不调用封存、授权或同步。 +- [x] 正常维护折叠、持有时展开、释放后折叠;切库重置明细展开状态。 +- [x] 无作业不画空进度;失败原因默认可见。 +- [x] 只读角色和读取失败时禁止主动作。 + +浏览器验收使用本地候选构建,GET/HEAD 通过已有 SSH 通道读取云测试 API;代理拒绝所有写请求。界面验收与真实封存、生产同步及恢复演练分开记录;本任务不执行这些业务写入。完整仓库门禁和云端部署结论以实际运行结果为准,不用上述前端检查替代。 diff --git a/web/src/ReleaseTargets.flow.test.tsx b/web/src/ReleaseTargets.flow.test.tsx new file mode 100644 index 0000000..c479e2a --- /dev/null +++ b/web/src/ReleaseTargets.flow.test.tsx @@ -0,0 +1,258 @@ +// @vitest-environment jsdom +import { act } from 'react' +import { createRoot, type Root } from 'react-dom/client' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { ReleaseTargetsView } from './ReleaseTargets' +import type { LibraryJobRecord, LibraryOverview, LibrarySnapshot } from './librarySnapshots' + +// The existing mounted suite exercises transport races and owner-bound recovery. +// This suite exercises the visible flow without authorizing any real operation. +vi.mock('./RestoreVerificationSection', () => ({ + RestoreVerificationSection: () =>
恢复验证入口
, +})) + +type Props = Parameters[0] +const snapshot: LibrarySnapshot = { + snapshot_id: 'a'.repeat(64), + scope: 'internal', + knowledge_base_id: 'test-kb', + tenant_id: 1, + created_at: '2026-11-17T01:00:00Z', + validation_policy: 'artifact-acceptance-v1', + format: 'weknora-library-snapshot/v1', + compatibility: { + weknora_version: 'v0.9.0', + schema_version: 134, + retriever_engine: 'elasticsearch_v8', + embedding_model: 'test-model', + embedding_dimension: 1024, + index_mapping_sha256: 'b'.repeat(64), + }, + parts: [], + logical_bytes: 0, + unique_bytes: 0, + shared_bytes: 0, + totals: {}, +} +const overview: LibraryOverview = { + scope: 'internal', + production: { state: 'unknown', empty_baseline: true }, + prebackup: { state: 'unknown' }, + diff: { state: 'computed', added: [], updated: [], removed: [] }, + gate: { sync_allowed: false, reasons: ['没有与目标快照匹配的有效发布授权'] }, + authorization: { state: 'none' }, + capture_available: true, + jobs: [], + now: '2026-11-17T01:00:00Z', +} +let props: Props +let container: HTMLDivElement +let root: Root +const draw = async (next: Partial = {}) => { + props = { ...props, ...next } + await act(async () => root.render()) +} +const primary = () => container.querySelector('.rel-primary')! +const details = (label: string) => + Array.from(container.querySelectorAll('details')).find((item) => + item.querySelector('summary')?.textContent?.startsWith(label) + )! +const click = async (element: HTMLElement) => { + await act(async () => element.click()) +} + +beforeEach(() => { + Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true }) + container = document.createElement('div') + document.body.appendChild(container) + root = createRoot(container) + props = { + page: null, + jobs: [], + overview, + loading: false, + error: null, + notice: null, + scope: 'internal', + onScope: vi.fn(), + drawerOpen: false, + onDrawer: vi.fn(), + expandedSnapshot: null, + onExpandSnapshot: vi.fn(), + pendingCapture: false, + canCapture: true, + canWrite: true, + canReconcileCapture: false, + pendingReconcileCapture: '', + onReconcileCapture: vi.fn(), + sync: { canSign: true, pendingGrant: false, onGrant: vi.fn(), canStart: false, pending: false, onStart: vi.fn() }, + baseline: { canStart: false, pending: false, onStart: vi.fn() }, + verification: { onAccepted: vi.fn(), onComplete: vi.fn() }, + canRestore: false, + restore: null, + restoreNotice: null, + pendingRestore: false, + pendingGrant: false, + onGrantRestore: vi.fn(), + onRestore: vi.fn(), + maintenance: null, + now: 0, + onRefresh: vi.fn(), + onCapture: vi.fn(), + onRecover: vi.fn(), + } +}) +afterEach(async () => { + await act(async () => root.unmount()) + container.remove() + vi.restoreAllMocks() +}) + +describe('发布管理精简主流程', () => { + it('同一挂载依次封存、授权、同步,每次点击只调用当前动作', async () => { + await draw() + expect(primary().textContent).toBe('封存测试版本') + await click(primary()) + expect(props.onCapture).toHaveBeenCalledOnce() + expect(props.sync.onGrant).not.toHaveBeenCalled() + expect(props.sync.onStart).not.toHaveBeenCalled() + await draw({ overview: { ...overview, test_sealed: snapshot } }) + expect(primary().textContent).toBe('签发同步授权(30 分钟)') + await click(primary()) + expect(props.sync.onGrant).toHaveBeenCalledOnce() + expect(props.sync.onStart).not.toHaveBeenCalled() + await draw({ + overview: { + ...overview, + test_sealed: snapshot, + authorization: { state: 'active' }, + gate: { sync_allowed: true, reasons: [] }, + }, + sync: { ...props.sync, canStart: true }, + }) + expect(primary().textContent).toBe('▶ 启动同步') + expect(primary().disabled).toBe(false) + await click(primary()) + expect(props.sync.onStart).toHaveBeenCalledOnce() + }) + + it('默认收起明细,展开和收起均不调用业务写入;历史只保留一个入口', async () => { + await draw({ overview: { ...overview, test_sealed: snapshot } }) + expect(container.querySelectorAll('button').length).toBeGreaterThan(0) + const history = Array.from(container.querySelectorAll('button')).filter((b) => + b.textContent?.includes('版本与快照') + ) + expect(history).toHaveLength(1) + for (const label of ['查看变更明细', '发布准备与恢复验证', '目标维护', '封存完整性']) { + const panel = details(label) + expect(panel.open).toBe(false) + await click(panel.querySelector('summary')!) + expect(panel.open).toBe(true) + await click(panel.querySelector('summary')!) + expect(panel.open).toBe(false) + } + await click(history[0]) + expect(props.onDrawer).toHaveBeenCalledWith(true) + expect(props.onCapture).not.toHaveBeenCalled() + expect(props.sync.onGrant).not.toHaveBeenCalled() + expect(props.sync.onStart).not.toHaveBeenCalled() + expect(props.onRestore).not.toHaveBeenCalled() + }) + + it('运行时只查看进度,不能再封存、授权或同步', async () => { + const job: LibraryJobRecord = { + id: 'job-1', + scope: 'internal', + kind: 'sync', + state: 'running', + stage: 'database', + request_digest: '', + queue_job_id: '', + snapshot_id: '', + target_snapshot_id: snapshot.snapshot_id, + actor: 'test', + error: '', + recovery: '', + created_at: overview.now, + updated_at: overview.now, + finished_at: null, + stages: [], + } + await draw({ + overview: { ...overview, test_sealed: snapshot, job, jobs: [job] }, + sync: { ...props.sync, canStart: true }, + }) + expect(primary().textContent).toBe('查看当前任务') + expect(container.textContent).not.toContain('重新封存') + await click(primary()) + expect(props.onCapture).not.toHaveBeenCalled() + expect(props.sync.onGrant).not.toHaveBeenCalled() + expect(props.sync.onStart).not.toHaveBeenCalled() + expect(details('查看执行明细').open).toBe(false) + }) + + it('无作业不展示空进度,失败作业展开显示原始原因', async () => { + await draw() + expect(container.textContent).not.toContain('最近作业') + const job: LibraryJobRecord = { + id: 'job-failed', + scope: 'internal', + kind: 'sync', + state: 'failed', + stage: 'database', + request_digest: '', + queue_job_id: '', + snapshot_id: '', + target_snapshot_id: '', + actor: 'test', + error: '目标连接失败', + recovery: '', + created_at: overview.now, + updated_at: overview.now, + finished_at: overview.now, + stages: [], + } + await draw({ overview: { ...overview, job, jobs: [job] } }) + expect(details('最近作业').open).toBe(true) + expect(details('最近作业').textContent).toContain('目标连接失败') + }) + + it('维护占用时自动展开,释放后恢复折叠;切库不沿用展开状态', async () => { + await draw({ maintenance: { held: false } }) + expect(details('目标维护').open).toBe(false) + await draw({ maintenance: { held: true } }) + expect(details('目标维护').open).toBe(true) + await draw({ maintenance: { held: false } }) + expect(details('目标维护').open).toBe(false) + await click(details('查看变更明细').querySelector('summary')!) + expect(details('查看变更明细').open).toBe(true) + const external = Array.from(container.querySelectorAll('[role="tab"]'))[1] + await click(external) + expect(props.onScope).toHaveBeenCalledWith('external') + await draw({ scope: 'external', overview: { ...overview, scope: 'external' } }) + expect(details('查看变更明细').open).toBe(false) + expect(container.querySelector('[aria-selected="true"]')?.textContent).toContain('对外知识库') + }) + + it('只读权限与刷新失败均不提供可执行主动作', async () => { + await draw({ canWrite: false, canCapture: false }) + expect(primary().disabled).toBe(true) + await click(primary()) + expect(props.onCapture).not.toHaveBeenCalled() + await draw({ overview: { ...overview, test_sealed: snapshot }, sync: { ...props.sync, canSign: false } }) + expect(primary().textContent).toBe('等待管理员授权') + expect(primary().disabled).toBe(true) + await draw({ error: '网络中断', sync: { ...props.sync, canSign: true } }) + expect(primary().disabled).toBe(true) + expect(container.textContent).toContain('网络中断') + await click(primary()) + expect(props.sync.onGrant).not.toHaveBeenCalled() + await draw({ canWrite: true, canCapture: true }) + const recapture = Array.from(container.querySelectorAll('button')).find( + (button) => button.textContent === '重新封存' + )! + expect(recapture.disabled).toBe(true) + await click(recapture) + expect(props.onCapture).not.toHaveBeenCalled() + }) +}) diff --git a/web/src/ReleaseTargets.test.tsx b/web/src/ReleaseTargets.test.tsx index f3d72e0..fbbb1d8 100644 --- a/web/src/ReleaseTargets.test.tsx +++ b/web/src/ReleaseTargets.test.tsx @@ -228,12 +228,10 @@ describe('ReleaseTargetsView(确认稿布局)', () => { it('没有当前作业时不把历史封存当成阶段完成', () => { const html = render() - // 阶段条第一段必须是 idle(○),"✓" 只允许出现在准备清单,不出现在阶段条 - const stageBar = html.slice(html.indexOf('aria-label="作业阶段"'), html.indexOf('rel-steps-note')) - expect(stageBar).not.toContain('✓') - expect(stageBar).toContain('本次作业尚未开始') - expect(html).toContain('已有测试封存') - expect(html).toContain('没有当前作业证据时不会把历史封存当作阶段完成') + // 没有作业就不展示空进度,更不能将历史封存伪装成当前作业完成。 + expect(html).not.toContain('aria-label="作业阶段"') + expect(html).not.toContain('启动后的作业进度') + expect(html).toContain('尚未启动,不修改生产') }) it('差异已计算时按文档身份列增改撤销,并标注比对的两个版本', () => { @@ -895,7 +893,7 @@ describe('ReleaseTargetsView(确认稿布局)', () => { it('闸口全满足时“启动同步”真的可点,并给出执行说明', () => { const html = render({ sync: { canSign: false, pendingGrant: false, onGrant: vi.fn(), canStart: true, pending: false, onStart: vi.fn() }, - overview: { ...overview, gate: { sync_allowed: true, reasons: [] } }, + overview: { ...overview, authorization: { state: 'active' }, gate: { sync_allowed: true, reasons: [] } }, }) expect(html).toMatch(/]*class="rel-primary"[^>]*>▶ 启动同步/) expect(html).not.toMatch(/class="rel-primary"[^>]*disabled/) @@ -1060,7 +1058,7 @@ describe('生产目标四类状态:known / 空 / 非空 / 不可读', () => { expect(html).not.toMatch(/建立目标权威基线(维护隔离)<\/button>/) }) - it('空目标但没有测试封存:启动同步保持禁用并说明缺候选', () => { + it('空目标但没有测试封存:主动作是封存,不提供启动同步', () => { const html = render({ baseline, overview: { @@ -1070,7 +1068,8 @@ describe('生产目标四类状态:known / 空 / 非空 / 不可读', () => { test_sealed_reason: '还没有该目标的测试封存', }, }) - expect(html).toMatch(/]*class="rel-primary"[^>]*disabled/) + expect(html).toMatch(/]*class="rel-primary"[^>]*>封存测试版本/) + expect(html).not.toContain('▶ 启动同步') expect(html).toContain('尚无测试封存') }) }) diff --git a/web/src/ReleaseTargets.tsx b/web/src/ReleaseTargets.tsx index 1902533..d2461be 100644 --- a/web/src/ReleaseTargets.tsx +++ b/web/src/ReleaseTargets.tsx @@ -34,12 +34,8 @@ import './releaseTargets.css' import { RestoreVerificationSection } from './RestoreVerificationSection' import { fetchSnapshotVerification } from './restoreVerification' -// 发布管理:按已确认稿实现——顶部两个知识库页签,下面是**一个**作业区。 -// -// 真实能力只有「测试库封存」这一段;生产当前版本、变更差异、生产预备份、 -// 同步与生产验证都还没有接线。页面照原稿结构全部画出来,但未接线的位置一律 -// 写「未接入 / 尚无记录」,不用 0、无变化或已同步冒充。队列状态、封存、传输、 -// 生产验证是四个不同阶段,不能互相顶替。 +// 一个知识库对应一个发布工作区。主操作随封存、授权、执行状态推进; +// 诊断按需展开,维护占用与失败恢复始终可见。 const stamp = (value: string) => value && Number.isFinite(new Date(value).getTime()) @@ -872,7 +868,6 @@ function ProtectionCard({ sync, baseline, scope, - onOpen, verification, }: { production: LibraryOverview['production'] | null @@ -886,7 +881,6 @@ function ProtectionCard({ sync: ReleaseSyncActions baseline: ReleaseBaselineActions scope: Scope - onOpen: () => void verification: { onAccepted: (jobId: string) => void onComplete: (jobId: string) => void @@ -964,19 +958,8 @@ function ProtectionCard({ onAccepted={verification.onAccepted} onComplete={verification.onComplete} /> - {gate.reasons.length > 0 ? ( -
    - {gate.reasons.map((reason) => ( -
  • {reason}
  • - ))} -
- ) : null} +
- {sync.canSign && authorization.state !== 'active' && targetSealed ? ( - - ) : null} {baseline.canStart && baselineNeeded ? ( -

恢复版本会恢复一整套生产知识状态,不回退测试知识库。

+

需要恢复旧版本时,从页面右上角「版本与快照」选择恢复点。

) } @@ -1005,11 +984,6 @@ interface ReadyProps { prebackup: LibraryOverview['prebackup'] gate: LibraryOverview['gate'] authorization: LibraryOverview['authorization'] - canCapture: boolean - canWrite: boolean - pendingCapture: boolean - onCapture: () => void - onOpen: () => void sync: ReleaseSyncActions baseline: ReleaseBaselineActions verification: { @@ -1030,17 +1004,25 @@ function ReadyBody({ sync, baseline, verification, - canCapture, - canWrite, - pendingCapture, - onCapture, - onOpen, }: ReadyProps) { - const snapshot = view.snapshot return ( <> -
+
+ + 查看变更明细{' '} + + {diff.state === 'computed' + ? `${diff.added.length + diff.updated.length + diff.removed.length} 篇文档` + : '尚未取得对比结果'} + + +
+
+ + 发布准备与恢复验证{' '} + {gate.reasons.length ? `待满足 ${gate.reasons.length} 项发布条件` : '查看备份与验证记录'} + -
-
-
-

启动后的作业进度

- {/* 作业跑完/失败后不能还说"此时尚未运行":这个徽标说的是**最近一次作业**的终态。 */} - - {view.job - ? `${jobKindText(view.job.kind)} · ${jobStateText(view.job)} · ${stamp(view.job.finished_at ?? view.job.updated_at)}` - : '此时尚未运行'} - -
- -
-
-
-

测试库封存

-

- {snapshot - ? `最近一次封存 ${stamp(snapshot.created_at)},快照 ${snapshot.snapshot_id.slice(0, 12)}。封存只读测试库,不影响生产。` - : '还没有测试库封存。封存会短暂停住测试写入者,导出完整版本后恢复。'} -

-
- {canCapture ? ( - - ) : ( - {captureHint(view, canWrite)} - )} -
+ + {view.job ? ( +
+ + 最近作业{' '} + + {jobKindText(view.job.kind)} · {jobStateText(view.job)} + + +
+
+

启动后的作业进度

+ {/* 作业跑完/失败后不能还说"此时尚未运行":这个徽标说的是**最近一次作业**的终态。 */} + + {view.job + ? `${jobKindText(view.job.kind)} · ${jobStateText(view.job)} · ${stamp(view.job.finished_at ?? view.job.updated_at)}` + : '此时尚未运行'} + +
+ + {view.job.error ?

{view.job.error}

: null} +
+
+ ) : null} ) } @@ -1097,14 +1067,12 @@ function ReadyBody({ function ProgressBody({ view, now, - onOpen, canReconcileCapture, pendingReconcileCapture, onReconcileCapture, }: { view: ScopeView now: number - onOpen: () => void canReconcileCapture: boolean pendingReconcileCapture: string onReconcileCapture: (jobID: string) => void @@ -1238,148 +1206,150 @@ function ProgressBody({ ? jobStateText(job) : '本次作业尚未开始'} -
- {sealJob ? ( -
-
-

封存范围

- 只读 -
-

- 本作业只读取测试库并导出快照,不备份生产、不写目标、不做生产验证,也不持有目标维护窗口。 - 快照完成后在“版本与快照”查看;没有真实导出总量时显示未知,不补零或 100%。 -

-
- ) : ( - <> -
+
+ + 查看执行明细 各类数据进度与阶段记录 + + {sealJob ? ( +
-

各类数据同步情况

- 没有真实总量与完成量的项目只显示状态,不编造百分比 +

封存范围

+ 只读
-
- {cards.map((card) => ( -
-
-

{card.title}

- - {card.row - ? card.row.state === 'succeeded' - ? '已完成' - : card.row.state === 'running' - ? '执行中' - : card.row.state === 'failed' - ? '失败' - : '等待' - : '未接入'} - -
-

- {card.count} · {card.axis} -

- {card.counts ?

封存快照分项:{card.counts}

: null} -
- -
-

- {card.row?.detail - ? card.row.detail - : card.row - ? card.row.state === 'running' - ? '执行中;执行器尚未提供该分项明细' - : card.row.state === 'pending' - ? '等待执行;不能按完成展示' - : card.row.state === 'failed' - ? '失败;没有可核对完成量' - : card.row.state === 'succeeded' - ? card.row.total != null - ? `已完成 ${card.row.completed ?? card.row.total} / ${card.row.total} 条存储行` - : '该分项已完成,执行器未提供可核对总量' - : '状态未知;不按完成展示' - : dataJob - ? '本次作业没有产生该分项阶段记录' - : '目标同步执行链未接通,分项不会产生数据'} -

-
- ))} +

+ 本作业只读取测试库并导出快照,不备份生产、不写目标、不做生产验证,也不持有目标维护窗口。 + 快照完成后在“版本与快照”查看;没有真实导出总量时显示未知,不补零或 100%。 +

+
+ ) : ( + <> +
+
+

各类数据同步情况

+ 没有真实总量与完成量的项目只显示状态,不编造百分比 +
+
+ {cards.map((card) => ( +
+
+

{card.title}

+ + {card.row + ? card.row.state === 'succeeded' + ? '已完成' + : card.row.state === 'running' + ? '执行中' + : card.row.state === 'failed' + ? '失败' + : '等待' + : '未接入'} + +
+

+ {card.count} · {card.axis} +

+ {card.counts ?

封存快照分项:{card.counts}

: null} +
+ +
+

+ {card.row?.detail + ? card.row.detail + : card.row + ? card.row.state === 'running' + ? '执行中;执行器尚未提供该分项明细' + : card.row.state === 'pending' + ? '等待执行;不能按完成展示' + : card.row.state === 'failed' + ? '失败;没有可核对完成量' + : card.row.state === 'succeeded' + ? card.row.total != null + ? `已完成 ${card.row.completed ?? card.row.total} / ${card.row.total} 条存储行` + : '该分项已完成,执行器未提供可核对总量' + : '状态未知;不按完成展示' + : dataJob + ? '本次作业没有产生该分项阶段记录' + : '目标同步执行链未接通,分项不会产生数据'} +

+
+ ))} +
-
-
-
-

同步明细

- 行来自持久作业阶段,worker 重启后仍可读 -
- - - - - - - - - - - - {(job?.stages ?? []).length === 0 ? ( +
+
+

同步明细

+ 行来自持久作业阶段,worker 重启后仍可读 +
+
任务 / 对象阶段进度状态说明
+ - + + + + + - ) : ( - job!.stages.map((row) => ( - - - - + + {(job?.stages ?? []).length === 0 ? ( + + - - - )) - )} - -
- 尚无阶段记录 - 任务 / 对象阶段进度状态说明
{row.stage}{row.stage === 'export' ? '测试封存' : row.stage} - {row.total != null ? `${row.completed ?? '—'} / ${row.total}` : '未知总量'} - {row.bytes_total != null - ? ` · ${formatBytes(row.bytes_done ?? 0)} / ${formatBytes(row.bytes_total)}` - : ''} +
+ 尚无阶段记录 - {row.state === 'succeeded' - ? '已完成' - : row.state === 'running' - ? '执行中' - : row.state === 'failed' - ? '失败' - : row.state === 'skipped' - ? '已跳过' - : '等待'} - {row.detail || '—'}
-
- - 最近事件: - {job?.error - ? job.error.slice(0, 120) - : running - ? '作业执行中;无错误。' - : job - ? `作业${jobStateText(job)};无错误。` - : sealJob - ? '封存作业已结束。' - : '尚无作业记录。'} - - 文件传输 100% ≠ 作业完成;生产验证通过前不显示“完成”。 -
-
- - )} + ) : ( + job!.stages.map((row) => ( + + {row.stage} + {row.stage === 'export' ? '测试封存' : row.stage} + + {row.total != null ? `${row.completed ?? '—'} / ${row.total}` : '未知总量'} + {row.bytes_total != null + ? ` · ${formatBytes(row.bytes_done ?? 0)} / ${formatBytes(row.bytes_total)}` + : ''} + + + {row.state === 'succeeded' + ? '已完成' + : row.state === 'running' + ? '执行中' + : row.state === 'failed' + ? '失败' + : row.state === 'skipped' + ? '已跳过' + : '等待'} + + {row.detail || '—'} + + )) + )} + + +
+ + 最近事件: + {job?.error + ? job.error.slice(0, 120) + : running + ? '作业执行中;无错误。' + : job + ? `作业${jobStateText(job)};无错误。` + : sealJob + ? '封存作业已结束。' + : '尚无作业记录。'} + + 文件传输 100% ≠ 作业完成;生产验证通过前不显示“完成”。 +
+
+ + )} + ) } @@ -1481,10 +1451,7 @@ interface DrawerProps { expanded: string | null onExpand: (id: string | null) => void onClose: () => void - canCapture: boolean canRestore: boolean - pendingCapture: boolean - onCapture: () => void // 恢复条件来自容器(真实接口判定):双闸 / 该快照的授权 / 目标是否在维护。 restore: LibraryRestoreAvailability | null restoreNotice: string | null @@ -1502,10 +1469,7 @@ function Drawer({ expanded, onExpand, onClose, - canCapture, canRestore, - pendingCapture, - onCapture, restore, restoreNotice, pendingRestore, @@ -1820,14 +1784,6 @@ function Drawer({ : ' 无'}

-

归档占用(只读):被版本引用的去重内容 {formatBytes(page?.content_bytes ?? 0)} · 磁盘分配{' '} @@ -1897,7 +1853,6 @@ export function ReleaseTargetsView(props: ViewProps) { const active = Boolean(view.activeJob) || view.job?.state === 'running' || view.job?.state === 'pending' || legacyOrphanJob // F06: 运行中禁止再次启动,也禁止把主按钮继续显示成可启动的绿色动作。 - const runningJob = active && view.job ? view.job : undefined // 三类版本严格分开:target 是测试封存,production 是生产权威版本,prebackup 是本次预备份。 const target = view.overview?.test_sealed // 没有 overview 时不能补一个 {state:'unknown'} 再当成"已探测且非空": @@ -1917,13 +1872,43 @@ export function ReleaseTargetsView(props: ViewProps) { } const gate = view.overview?.gate ?? { sync_allowed: false, reasons: ['整库状态接口不可用'] } const authorization = view.overview?.authorization ?? { state: 'none' as const, reason: '整库状态接口不可用' } + const primaryAction = active + ? { + label: '查看当前任务', + disabled: false, + hint: '作业正在处理,请勿重复启动', + onClick: () => + document.getElementById('rel-progress')?.scrollIntoView?.({ behavior: 'smooth', block: 'start' }), + } + : !target + ? { + label: pendingCapture ? '投递中…' : '封存测试版本', + disabled: !canCapture || pendingCapture || loading || Boolean(error), + hint: canCapture ? '短暂停止测试写入,保存完整版本后恢复' : captureHint(view, canWrite), + onClick: onCapture, + } + : authorization.state !== 'active' + ? { + label: !sync.canSign ? '等待管理员授权' : sync.pendingGrant ? '签发中…' : '签发同步授权(30 分钟)', + disabled: !sync.canSign || sync.pendingGrant || pendingCapture || loading || Boolean(error), + hint: sync.canSign ? '授权绑定当前目标与快照;签发后仍需单独启动同步' : '请管理员完成本次授权', + onClick: sync.onGrant, + } + : { + label: sync.pending ? '投递中…' : '▶ 启动同步', + disabled: !sync.canStart || sync.pending || pendingCapture || loading || Boolean(error), + hint: sync.canStart + ? '按已签发的同步授权启动:先固定测试版本,再备份目标并写入' + : `暂不能启动同步:${gate.reasons.join(';')}`, + onClick: sync.onStart, + } return (

发布管理

-

测试维护与验证,生产按知识库版本同步。

+

封存测试版本 → 检查并授权 → 同步到生产

+ {target && !active && canCapture ? ( + + ) : null}
@@ -2069,29 +2049,50 @@ export function ReleaseTargetsView(props: ViewProps) {

快照摘要:{target.snapshot_id}

) : null} -
    -
  • - {target - ? `✓ 文档解析与索引完整(${target.totals.chunks ?? 0} 分块 / ${target.totals.index_documents ?? 0} 索引)` - : '○ 文档解析与索引:未接入'} - {target ? ( - - 依据 {stamp(target.created_at)} 封存的测试库全库快照,不代表实时测试库已就绪 - - ) : null} -
  • -
  • - {target ? `✓ Wiki 快照完整(${target.totals.wiki_pages ?? 0} 页)` : '○ Wiki 快照:未接入'} - {target ? 同一份封存快照,不是实时 Wiki 队列状态 : null} -
  • -
  • - {target ? `✓ 清单与摘要登记:${target.parts.length} 项部件摘要已记录` : '○ 数据完整性:尚无封存可核验'} - {target ? ( - 封存时逐项哈希登记;列表只校验清单自身,字节级复核在同步/恢复执行前进行 - ) : null} -
  • -
- {gate.reasons.length > 0 ? ( +
+ + 封存完整性 {target ? '查看分块、索引与 Wiki 清单' : '尚无封存'} + +
    +
  • + {target + ? `✓ 文档解析与索引完整(${target.totals.chunks ?? 0} 分块 / ${target.totals.index_documents ?? 0} 索引)` + : '○ 文档解析与索引:未接入'} + {target ? ( + + 依据 {stamp(target.created_at)} 封存的测试库全库快照,不代表实时测试库已就绪 + + ) : null} +
  • +
  • + {target ? `✓ Wiki 快照完整(${target.totals.wiki_pages ?? 0} 页)` : '○ Wiki 快照:未接入'} + {target ? 同一份封存快照,不是实时 Wiki 队列状态 : null} +
  • +
  • + {target ? `✓ 清单与摘要登记:${target.parts.length} 项部件摘要已记录` : '○ 数据完整性:尚无封存可核验'} + {target ? ( + 封存时逐项哈希登记;列表只校验清单自身,字节级复核在同步/恢复执行前进行 + ) : null} +
  • +
+ {!canCapture ?

{captureHint(view, canWrite)}

: null} +
+

+ {active + ? '正在处理,页面会自动更新进度。' + : !target + ? canCapture + ? '还没有测试库封存。下一步:封存测试版本。' + : captureHint(view, canWrite) + : authorization.state !== 'active' + ? sync.canSign + ? '下一步:检查下方发布条件,再签发本次同步授权。' + : '下一步:请管理员签发本次同步授权。' + : sync.canStart + ? '条件已满足,可启动同步。' + : '请先处理以下阻塞项;备份与恢复验证入口在下方「发布准备与恢复验证」。'} +

+ {!active && gate.reasons.length > 0 ? (
    {gate.reasons.map((reason) => (
  • {reason}
  • @@ -2101,19 +2102,30 @@ export function ReleaseTargetsView(props: ViewProps) {

    启动后先固定测试版本,再备份生产。备份失败或恢复条件不满足,不进入生产写入。

    - +
    + + 目标维护{' '} + + {maintenance?.held ? '维护占用中,请关注当前作业' : maintenance ? '查看维护记录与诊断' : '维护状态尚未读取'} + + + +
    {active ? ( onDrawer(true)} canReconcileCapture={canReconcileCapture} pendingReconcileCapture={pendingReconcileCapture} onReconcileCapture={onReconcileCapture} @@ -2131,11 +2143,6 @@ export function ReleaseTargetsView(props: ViewProps) { sync={sync} baseline={baseline} verification={verification} - canCapture={canCapture} - canWrite={canWrite} - pendingCapture={pendingCapture} - onCapture={onCapture} - onOpen={() => onDrawer(true)} /> )} @@ -2147,10 +2154,7 @@ export function ReleaseTargetsView(props: ViewProps) { expanded={expandedSnapshot} onExpand={onExpandSnapshot} onClose={() => onDrawer(false)} - canCapture={canCapture} canRestore={canRestore} - pendingCapture={pendingCapture} - onCapture={onCapture} restore={restore} restoreNotice={restoreNotice} pendingRestore={pendingRestore} diff --git a/web/src/releaseTargets.css b/web/src/releaseTargets.css index 6acdeab..a384cb6 100644 --- a/web/src/releaseTargets.css +++ b/web/src/releaseTargets.css @@ -711,3 +711,101 @@ border-radius: 7px; padding: 8px; } + +/* 主流程保持展开;诊断共享一组轻量折叠行,避免面板套面板。 */ +.rel-disclosure { + min-width: 0; + border: 1px solid var(--rel-line); + border-radius: 8px; + background: #fff; +} +.rel-disclosure > summary { + padding: 13px 16px; + color: var(--rel-ink); + font-size: 14px; + font-weight: 600; + cursor: pointer; + overflow-wrap: anywhere; +} +.rel-disclosure > summary > span { + margin-left: 12px; + color: #586c7b; + font-size: 12px; + font-weight: 400; +} +.rel-disclosure[open] > summary { + border-bottom: 1px solid var(--rel-line); +} +.rel-disclosure > .rel-panel { + border: 0; + border-radius: 0; + background: transparent; + overflow-x: auto; +} +.rel-integrity { + margin-top: 12px; + background: #f8fbfa; +} +.rel-integrity .rel-checklist { + margin: 0; + background: transparent; +} +.rel-next-step { + margin: 14px 0 0; + color: #41596b; + font-size: 13px; + line-height: 1.6; +} +.release-targets .rel-primary:disabled { + background: #e9eef1 !important; + border-color: #d6e2e8 !important; + color: #657786 !important; + opacity: 1; + box-shadow: none; +} +.release-targets button:focus-visible, +.rel-disclosure > summary:focus-visible { + outline: 2px solid var(--rel-teal); + outline-offset: 3px; +} +.rel-metrics { + display: flex; + flex-wrap: wrap; + gap: 12px 24px; + padding: 12px 0; + border-bottom: 1px solid var(--rel-line); +} +.rel-metrics div { + display: flex; + align-items: baseline; + gap: 8px; + border: 0; + padding: 0; +} +.rel-metrics dd { + margin: 0; + font-size: 16px; +} +@media (max-width: 640px) { + .release-targets { + padding: 16px 12px 24px; + } + .rel-panel { + padding: 16px; + } + .rel-tab { + width: 100%; + } + .rel-disclosure > summary > span { + display: block; + margin: 6px 0 0 16px; + } + .rel-maintenance-rows { + grid-template-columns: 1fr; + } +} +@media (prefers-reduced-motion: reduce) { + .release-targets * { + scroll-behavior: auto !important; + } +}