fix(ui): 修复F12-F16入口与追溯缺陷
build / build (push) Successful in 1m59s

Dockerfile 运行阶段补齐 dws_dingtalk_scan(F12),并新增 runtime-scripts 门禁
做脚本依赖闭包正负例;就绪探测每次解析当前端点/绑定/凭据并区分 404、未配置、
不可达(F13);路由写入来源路径与父目录,历史空值仅按同连接同 item 的意图读时
补齐(F14);目标筛选显示短 ID 与当前绑定/历史并提供快捷筛选(F15);刷新终态
移除后台运行、展示失败时间/旧快照/脱敏原因/作业 ID 与重试(F16)。

验证:make verify 17 项全过(identity 本地按设计 skipped);一次性 schema 的
Monitor 目录/路由集成用例通过;8088 部署与真实 UI 验收仍由父会话执行。
This commit is contained in:
姚章浩
2026-11-05 10:38:26 +08:00
parent dfbf3336b2
commit 1c80b07f2c
29 changed files with 1436 additions and 75 deletions
+70 -7
View File
@@ -8,6 +8,7 @@ import {
actionLabels,
stageLabels,
taskStatusLabels,
targetLabel,
} from './monitorTasks'
import type { MonitorFilters, MonitorTask, MonitorTaskPage } from './monitorTasks'
import { requeueJobFailure, retryPublicationsBatch } from './testPublications'
@@ -16,7 +17,16 @@ import { useOptionalAuth } from './auth'
import { WorkspaceContextTabsSetter } from './workspaceContext'
import './monitorWorkbench.css'
const emptyPage: MonitorTaskPage = { items: [], total: 0, limit: 20, offset: 0, sources: [], targets: [], retryable: 0 }
const emptyPage: MonitorTaskPage = {
items: [],
total: 0,
limit: 20,
offset: 0,
sources: [],
targets: [],
bindings: { internal: '', external: '' },
retryable: 0,
}
const time = (value: string) => (value ? new Date(value).toLocaleString('zh-CN', { hour12: false }) : '—')
const percent = (value: number | null | undefined) => (value == null ? '—' : `${value}%`)
const seconds = (value: number | null | undefined) => (value == null ? '—' : `${Number(value.toFixed(1))} 秒`)
@@ -51,6 +61,7 @@ interface ViewProps {
onRetry: (rows: MonitorTask[]) => void
onDetail: (row: MonitorTask) => void
onRefresh: () => void
onLocateSource?: (sourceID: string, parentNodeID: string) => void
}
export function WeKnoraMonitorView(p: ViewProps) {
const { overview, metrics, page, filters, selected, busy, loading } = p
@@ -63,6 +74,8 @@ export function WeKnoraMonitorView(p: ViewProps) {
const selectedIDs = new Set(selected.map((r) => r.id))
const allPage = eligible.length > 0 && eligible.every((r) => selectedIDs.has(r.id))
const kbName = (id: string) => overview?.knowledge_bases.find((k) => k.id === id)?.name || id
const bindings = page.bindings
const scopeBinding = filters.scope === 'external' ? bindings.external : bindings.internal
return (
<main className="page-shell monitor-workbench">
<header className="monitor-heading">
@@ -180,7 +193,8 @@ export function WeKnoraMonitorView(p: ViewProps) {
</summary>
<p>{s.reason || '未提供状态说明'}</p>
<small>
检测:{time(s.observed_at)} · {s.latency_ms} ms
检测:{time(s.observed_at)} · {s.latency_ms} ms · 存活 {s.liveness || '未确认'}
{s.probe_target ? ` · 探测对象 ${s.probe_target}` : ''}
</small>
</details>
))
@@ -234,10 +248,23 @@ export function WeKnoraMonitorView(p: ViewProps) {
<option value="">全部目标知识库</option>
{page.targets.map((t) => (
<option key={t.id} value={t.id}>
{kbName(t.id)}
{targetLabel(kbName(t.id), t.id, t.scope || '', bindings)}
</option>
))}
</select>
<button
type="button"
className="monitor-link"
disabled={busy || !scopeBinding}
title={
scopeBinding
? `当前${filters.scope === 'external' ? '对外' : '对内'}绑定:${scopeBinding}`
: '尚未配置当前绑定'
}
onClick={() => scopeBinding && patchFilter('target', scopeBinding)}
>
仅当前绑定
</button>
<select
aria-label="处理动作"
value={filters.action}
@@ -407,7 +434,9 @@ export function WeKnoraMonitorView(p: ViewProps) {
<td>{item.source_name}</td>
<td>
<span className="monitor-scope">{item.target_scope === 'internal' ? '对内' : '对外'}</span>
<small title={kbName(item.target_kb)}>{kbName(item.target_kb)}</small>
<small title={item.target_kb}>
{targetLabel(kbName(item.target_kb), item.target_kb, item.target_scope, bindings)}
</small>
</td>
<td>{actionLabels[item.action]}</td>
<td>{stageLabels[item.stage]}</td>
@@ -466,7 +495,15 @@ export function WeKnoraMonitorView(p: ViewProps) {
</main>
)
}
function TaskDetail({ item, onClose }: { item: MonitorTask; onClose: () => void }) {
function TaskDetail({
item,
onClose,
onLocateSource,
}: {
item: MonitorTask
onClose: () => void
onLocateSource?: (sourceID: string, parentNodeID: string) => void
}) {
const ref = useRef<HTMLDialogElement>(null)
useEffect(() => {
ref.current?.showModal()
@@ -483,6 +520,7 @@ function TaskDetail({ item, onClose }: { item: MonitorTask; onClose: () => void
<dl>
{[
['来源', item.source_name],
['来源连接', item.source_id],
['目录', item.path],
['目标知识库', item.target_kb],
['处理动作', actionLabels[item.action]],
@@ -499,6 +537,17 @@ function TaskDetail({ item, onClose }: { item: MonitorTask; onClose: () => void
</div>
))}
</dl>
{onLocateSource ? (
<button
type="button"
className="monitor-link"
disabled={!item.parent_node_id}
title={item.parent_node_id ? '回到该文件所在的来源目录' : '该记录没有可定位的来源目录'}
onClick={() => onLocateSource(item.source_id, item.parent_node_id)}
>
在来源与目录定位
</button>
) : null}
{item.history?.length ? (
<section className="monitor-history">
<h3>版本与重试记录</h3>
@@ -522,7 +571,13 @@ function TaskDetail({ item, onClose }: { item: MonitorTask; onClose: () => void
</dialog>
)
}
export function WeKnoraMonitor() {
export function WeKnoraMonitor({
focus,
onLocateSource,
}: {
focus?: { source: string; q: string } | null
onLocateSource?: (sourceID: string, parentNodeID: string) => void
} = {}) {
const auth = useOptionalAuth()
const canOperate = auth?.identity?.role === 'admin' || auth?.identity?.role === 'engineer'
const [overview, setOverview] = useState<MonitorOverview | null>(null),
@@ -544,6 +599,13 @@ export function WeKnoraMonitor() {
setTabs([])
return () => setTabs([])
}, [setTabs])
// 从来源目录“查看处理”进入:一次性套用来源+文件名定位,之后由用户自行改筛选。
useEffect(() => {
if (!focus) return
setFilters((current) => ({ ...current, q: focus.q, source: focus.source, target: '', scope: '' }))
setOffset(0)
setSelected([])
}, [focus])
useEffect(() => {
const c = new AbortController()
void fetchActiveUISettings(c.signal)
@@ -742,8 +804,9 @@ export function WeKnoraMonitor() {
.catch((e) => setMessage(e instanceof Error ? e.message : '读取详情失败'))
}}
onRefresh={refresh}
onLocateSource={onLocateSource}
/>
{detail ? <TaskDetail item={detail} onClose={() => setDetail(null)} /> : null}
{detail ? <TaskDetail item={detail} onClose={() => setDetail(null)} onLocateSource={onLocateSource} /> : null}
</>
)
}