From 6727cdd30f8553ab4e28f91612e7a9c303ad86e8 Mon Sep 17 00:00:00 2001 From: weichen Date: Sun, 18 Oct 2026 00:12:58 +0000 Subject: [PATCH] Locate render diagnostics by tree node id and expect published DHF rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: Browser acceptance (/tmp/renderer-browser-acceptance/20261017T061021Z) found §11-4 showed 25/25 diagnostics as 未定位节点 because the renderer nodeId is the canonical mapping id (pp.cover.document-number.value) while the workspace tree uses dn-… ids; RDM now adds treeNodeId to every diagnostic. §11-3 failed only because the e2e spec still expected 已验证/未发布 although all 44 DHF profiles are published. Evidence: npx tsc --noEmit exit 0; npx vitest run 39 files / 445 tests passed (4 new in test/document-render-workspace.test.ts covering treeNodeId, nodeId fallback, unknown ids and per-node counts); npm run build ok; node scripts/check-knip.mjs unused exports 51 <= 51; e2e/document-renderer.playwright.ts type-checks (tsc exit 0) and playwright test --list loads 13 tests. Real rdm.render.profiles payload in evidence/network/item3-author.jsonl: template rule state=published, publicationAllowed=true, no blockedReason, refusal controlled_requires_exact_profile. Impact: normalizeDiagnostics keeps treeNodeId; locateDiagnostic resolves treeNodeId first and falls back to nodeId, otherwise the diagnostic stays explicitly unlocated. Badges and the 有诊断问题 filter count by the located tree node. Clicking a located diagnostic selects the node and scrolls it into view in canvas or reader, also on a repeated click. Diagnostics loading keeps its single request guard. §11-3 now asserts 已发布, 可正式交付, an enabled option and no reason, and still asserts source, version, the no-fallback notice and refusal. Not run against a live backend or browser here. Refs: unified renderer plan Task 13 §11 items 3 and 4; spec 10 §11 item 3; summary.md root causes §A and §B. Co-authored-by: Cursor --- e2e/document-renderer.playwright.ts | 7 +++- src/components/DocumentRenderWorkspace.tsx | 36 +++++++++------- src/documentRenderPresentation.ts | 21 ++++++++-- test/document-render-workspace.test.ts | 49 +++++++++++++++++++++- 4 files changed, 92 insertions(+), 21 deletions(-) diff --git a/e2e/document-renderer.playwright.ts b/e2e/document-renderer.playwright.ts index fea5c8d..0c8769b 100644 --- a/e2e/document-renderer.playwright.ts +++ b/e2e/document-renderer.playwright.ts @@ -279,8 +279,11 @@ test('§11-3 受控文档:规则来源、版本与不回退说明', async ({ b await expect(option.locator('.drw-profile-source')).toHaveText('模板规则') await expect(option.locator('.drw-profile-id')).toHaveText(TEMPLATE_PROFILE) await expect(option.locator('.drw-profile-ver')).toHaveText(`v${env('RBA_TEMPLATE_VERSION')}`) - await expect(option.locator('.ui-chip').first()).toHaveText('已验证') - await expect(option.locator('.drw-profile-reason')).toContainText('未发布') + // 44 个 DHF 专用规则均已发布(state=published、publicationAllowed=true):状态为已发布,可正式交付,无未发布原因。 + await expect(option.locator('.ui-chip').first()).toHaveText('已发布') + await expect(option.locator('.ui-chip', { hasText: '可正式交付' })).toBeVisible() + await expect(option.locator('input[type="radio"]')).toBeEnabled() + await expect(option.locator('.drw-profile-reason')).toHaveCount(0) await expect(rules.locator('.drw-notice')).toContainText('不会回退到项目或公司默认规则') await expect(rules.locator('.drw-failure-msg')).toContainText('不得回退到项目或公司默认规则') await expectReadableFailures(page) diff --git a/src/components/DocumentRenderWorkspace.tsx b/src/components/DocumentRenderWorkspace.tsx index c9b839d..2c90f79 100644 --- a/src/components/DocumentRenderWorkspace.tsx +++ b/src/components/DocumentRenderWorkspace.tsx @@ -13,7 +13,7 @@ import { DELIVERY_MODE_LABELS, DOC_TREE_LIMITS, MIND_MAP, REVISION_KIND_LABELS, annotatePayload, buildDocTree, controlledNotice, createRequestGuard, currentSubmissionId, decodeBase64, defaultProfileKey, diagnosticCountsByNode, diagnosticsSummaryText, downloadOptions, formatRenderTime, - groupDiagnostics, hasFacts, layoutMindMap, loadDeliveryDiagnostics, mergeDeliveries, moveSelection, + groupDiagnostics, hasFacts, layoutMindMap, loadDeliveryDiagnostics, locateDiagnostic, mergeDeliveries, moveSelection, nextOperation, nodeAnchorId, nodeFacts, normalizeDeliveries, normalizeDownload, normalizeProfiles, normalizeReviewView, partitionAnnotations, partitionRevisions, profileOptionViews, receiptStateView, renderScope, revisePayload, submissionIdOf, truncateMiddle, validateReviewText, visibleNodeIds, visibleOrder, walkDocTree, @@ -88,11 +88,11 @@ function DiagnosticGroupBody({ items, nodeTitle, onSelectNode }: { return (