feat(reconciliation): T6 导入对账(契约/后端/前端) #41

Merged
zheromiku merged 10 commits from hifox-agent/rin/CYWL-34 into main 2026-12-01 16:17:38 +08:00
19 changed files with 211 additions and 143 deletions
Showing only changes of commit e855261b4d - Show all commits
+1
View File
@@ -259,6 +259,7 @@ func run(ctx context.Context, getenv func(string) string) error {
ConfirmConcurrency: config.ReconciliationConfirmConcurrency,
KeepRuns: config.ReconciliationKeepRuns,
MaxAge: config.ReconciliationMaxAge,
WeKnoraWebBase: testEndpointResolver,
})
if serviceErr != nil {
return serviceErr
+6
View File
@@ -293,6 +293,12 @@ func run(ctx context.Context, getenv func(string) string) error {
ConfirmConcurrency: config.ReconciliationConfirmConcurrency,
KeepRuns: config.ReconciliationKeepRuns,
MaxAge: config.ReconciliationMaxAge,
WeKnoraWebBase: func(resolveCtx context.Context) string {
if kbBindings != nil {
return kbBindings.ResolveBaseURL(resolveCtx, kbbinding.EnvTest)
}
return config.TestWeKnoraBaseURL
},
})
if err != nil {
return err
+1 -1
View File
@@ -73,7 +73,7 @@ func listMonitorTasks(w http.ResponseWriter, r *http.Request, config Config) {
writeJSON(w, 400, map[string]string{"error": "invalid filter"})
return
}
for _, pair := range [][2]string{{f.Scope, "|internal|external"}, {f.Action, "|add|update|remove"}, {f.Status, "|active|waiting|running|retrying|attention|completed|cancelled"}, {f.Stage, "|waiting|fetch|upload|parsing|indexing|removal|finished"}} {
for _, pair := range [][2]string{{f.Scope, "|internal|external"}, {f.Action, "|add|update|remove"}, {f.Status, "|active|waiting|running|retrying|attention|completed|cancelled"}, {f.Stage, "|waiting|fetch|upload|parsing|indexing|removal|finished|weknora"}} {
if !strings.Contains("|"+pair[1]+"|", "|"+pair[0]+"|") {
writeJSON(w, 400, map[string]string{"error": "invalid filter"})
return
+7
View File
@@ -33,6 +33,13 @@ func TestMonitorTasksRoute(t *testing.T) {
if s.filter.Status != "active" || s.filter.Offset != 40 {
t.Fatalf("filter %#v", s.filter)
}
// §8 merges 解析/索引增强 into one "WeKnora 处理中" facet.
merged := httptest.NewRequest("GET", "/api/v1/monitor/tasks?stage=weknora", nil).WithContext(req.Context())
wm := httptest.NewRecorder()
h.ServeHTTP(wm, merged)
if wm.Code != 200 || s.filter.Stage != "weknora" {
t.Fatalf("weknora stage: %d filter %#v", wm.Code, s.filter)
}
for _, query := range []string{"status=garbage", "stage=internal&scope=internal", "limit=101", "offset=-1", "since=bad"} {
r := httptest.NewRequest("GET", "/api/v1/monitor/tasks?"+query, nil).WithContext(req.Context())
rr := httptest.NewRecorder()
+3 -4
View File
@@ -306,11 +306,10 @@ func (provider *RealProvider) Services(ctx context.Context) []governance.Service
health = append(health, provider.weKnoraProbe(ctx, now))
health = append(health, provider.productionWeKnoraProbe(ctx, now))
health = append(health, provider.httpProbe(ctx, "mineru", "MinerU", provider.minerUBaseURL, now))
// Not-applicable dependencies stay explicit (embedding/llm managed by
// WeKnora, redis/mq/oss not deployed).
// Not-applicable dependencies stay explicit (redis/mq/oss not deployed).
// Embedding/LLM are managed inside WeKnora and are not platform services;
// listing them here produced two permanent "unknown" cards on the page.
health = append(health,
provider.track(classify("embedding", "Embedding模型", false, false, ProbeOutcome{ObservedAt: now})),
provider.track(classify("llm", "LLM模型", false, false, ProbeOutcome{ObservedAt: now})),
provider.track(classify("redis", "Redis / MQ", false, false, ProbeOutcome{ObservedAt: now})),
provider.track(classify("oss", "OSS", false, false, ProbeOutcome{ObservedAt: now})),
)
@@ -59,11 +59,18 @@ func TestRealServicesHealthMatrix(t *testing.T) {
if byKey["weknora-production/r"] != ReadNotConfigured || byKey["weknora-production/l"] != LiveUnknown {
t.Fatalf("unconfigured production endpoint = %v/%v", byKey["weknora-production/l"], byKey["weknora-production/r"])
}
for _, key := range []string{"redis", "oss", "embedding", "llm"} {
for _, key := range []string{"redis", "oss"} {
if byKey[key+"/r"] != ReadNotApplicable || byKey[key+"/l"] != LiveUnknown {
t.Fatalf("not-deployed %s = %v/%v", key, byKey[key+"/l"], byKey[key+"/r"])
}
}
// Embedding/LLM belong to WeKnora; the platform must not render them as
// permanent unknown cards (requirement §8).
for _, key := range []string{"embedding", "llm"} {
if _, ok := byKey[key+"/r"]; ok {
t.Fatalf("platform health still lists %s", key)
}
}
// Readiness must be blocked ONLY by configured+deployed failures: worker.
ok, blocked := overallReadiness(health)
if ok || len(blocked) != 1 || blocked[0] != "worker" {
@@ -32,10 +32,13 @@ func TestOverviewRemovalDemandAndSharedViewAgree(t *testing.T) {
exec(`INSERT INTO source_items(id,source_connection_id,stable_external_id,canonical_uri_hash,title,item_type,policy_state)
VALUES('si-recon-view','conn-recon-view','recon.md',repeat('b',64),'对账视图','file','blocked')`)
exec(`INSERT INTO source_item_versions(id,source_item_id,revision,content_state) VALUES('sv-recon-view','si-recon-view','r1','verified')`)
// test_publications is unique on (source_item_version_id,test_kb_id): a second
// publication in the same KB must point at its own version, not reuse r1.
exec(`INSERT INTO source_item_versions(id,source_item_id,revision,content_state) VALUES('sv-recon-removing','si-recon-view','r2','verified')`)
exec(`INSERT INTO test_publications(id,source_item_version_id,test_kb_id,knowledge_id,ingest_state,processing_state,retrieval_state)
VALUES('pub-recon-view','sv-recon-view','kb-recon-view','doc-recon-view','uploaded','completed','unpublished')`)
exec(`INSERT INTO test_publications(id,source_item_version_id,test_kb_id,knowledge_id,ingest_state,processing_state,retrieval_state)
VALUES('pub-recon-removing','sv-recon-view','kb-recon-view','doc-recon-removing','uploaded','completed','disabling')`)
VALUES('pub-recon-removing','sv-recon-removing','kb-recon-view','doc-recon-removing','uploaded','completed','disabling')`)
provider, err := NewRealProvider(RealProviderConfig{DB: metricsPool{pool: pool}})
if err != nil {
+1 -1
View File
@@ -145,7 +145,7 @@ const monitorTasksCTE = `WITH history_publications AS (
SELECT * FROM projected WHERE ($1='' OR strpos(lower(title || ' ' || path),lower($1))>0)
AND ($2='' OR source_id=$2) AND ($3='' OR target_scope=$3) AND ($4='' OR action=$4)
AND ($5='' OR ($5='active' AND status NOT IN ('completed','cancelled')) OR status=$5)
AND ($6='' OR stage=$6) AND ($7='' OR id=$7) AND ($10='' OR target_kb=$10)
AND ($6='' OR stage=$6 OR ($6='weknora' AND stage IN ('parsing','indexing'))) AND ($7='' OR id=$7) AND ($10='' OR target_kb=$10)
AND ($11='' OR updated_at>=NULLIF($11,'')::timestamptz) AND ($12='' OR updated_at<=NULLIF($12,'')::timestamptz)
) `
@@ -97,8 +97,8 @@ func (s *Store) ReapStaleReconciliationRuns(ctx context.Context, now time.Time,
return 0, nil
}
tag, err := s.db.Exec(ctx, `UPDATE reconciliation_runs
SET state='failed',finished_at=$2,error_code='stale_timeout'
WHERE state='running' AND started_at < $3`, now, now.Add(-threshold))
SET state='failed',finished_at=$1,error_code='stale_timeout'
WHERE state='running' AND started_at < $2`, now, now.Add(-threshold))
if err != nil {
return 0, fmt.Errorf("reap stale reconciliation runs: %w", err)
}
@@ -222,6 +222,13 @@ WHERE id=$1 AND state='running'`, run.ID, run.FinishedAt, run.LedgerCount, run.K
return ErrReconciliationNotRunning
}
for _, finding := range findings {
// The column default only applies when the insert omits the column; the
// service always fills it, but direct callers may pass "" and must not
// violate the check constraint.
confirmation := finding.ConfirmationState
if confirmation == "" {
confirmation = "confirmed"
}
if _, err := tx.Exec(ctx, `INSERT INTO reconciliation_findings
(id,run_id,finding_type,publication_id,knowledge_id,title,path,source,target_scope,
ledger_state,weknora_parse_status,normalized_state,ledger_sha256,declared_sha256,
@@ -231,7 +238,7 @@ VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,'open'
finding.ID, finding.RunID, finding.Type, finding.PublicationID, finding.DocumentID,
finding.Title, finding.Path, finding.Source, finding.TargetScope, finding.LedgerState,
finding.WeKnoraParseState, finding.NormalizedState, finding.LedgerSHA256, finding.DeclaredSHA256,
finding.WeKnoraFileMD5, finding.EvidenceLevel, finding.ConfirmationState, finding.Detail,
finding.WeKnoraFileMD5, finding.EvidenceLevel, confirmation, finding.Detail,
finding.SuggestedAction, finding.WeKnoraURL, run.FinishedAt); err != nil {
return fmt.Errorf("insert reconciliation finding: %w", err)
}
+20
View File
@@ -336,6 +336,26 @@ func TestClientProvidesPaginatedInventoryChunkAndScopedSearchReads(t *testing.T)
}
}
// Acceptance #16: the reconciliation scan must be one 1000-per-page read, and
// the wire query is the evidence — not just the constant passed to the interface.
func TestListKnowledgeSendsScanPageSizeOnTheWire(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Query().Get("page") != "1" || r.URL.Query().Get("page_size") != "1000" {
t.Fatalf("knowledge list query = %s", r.URL.RawQuery)
}
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(`{"success":true,"data":[],"total":0,"page":1,"page_size":1000}`))
}))
defer server.Close()
client, err := NewClient(ClientConfig{BaseURL: server.URL, APIKey: "test-api-key", Timeout: time.Second})
if err != nil {
t.Fatal(err)
}
if _, _, err := client.ListKnowledge(context.Background(), "kb-1", 1, 1000); err != nil {
t.Fatal(err)
}
}
func TestClientRejectsRedirectWithoutForwardingAPIKey(t *testing.T) {
var targetHits atomic.Int32
target := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+6
View File
@@ -5,6 +5,7 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
"net/url"
"sort"
"strings"
"sync"
@@ -152,6 +153,11 @@ func (s *Service) buildFindings(ctx context.Context, run governance.Reconciliati
}
finding.ActionState = "open"
finding.ID = deterministicFindingID(run.ID, finding)
if finding.WeKnoraURL == "" && run.KBID != "" && s.weKnoraWebBase != nil {
if base := strings.TrimSpace(s.weKnoraWebBase(ctx)); base != "" {
finding.WeKnoraURL = strings.TrimSuffix(base, "/") + "/platform/knowledge-bases/" + url.PathEscape(run.KBID)
}
}
findings = append(findings, finding)
}
+5
View File
@@ -72,6 +72,9 @@ type Config struct {
ConfirmConcurrency int
KeepRuns int
MaxAge time.Duration
// WeKnoraWebBase resolves the WeKnora origin used to build the finding's
// jump link. Empty or nil leaves weknora_url empty, which the contract allows.
WeKnoraWebBase func(context.Context) string
}
type Service struct {
@@ -86,6 +89,7 @@ type Service struct {
confirmConcurrency int
keepRuns int
maxAge time.Duration
weKnoraWebBase func(context.Context) string
}
func New(config Config) (*Service, error) {
@@ -120,6 +124,7 @@ func New(config Config) (*Service, error) {
store: config.Store, remote: config.Remote, runtime: config.Runtime, queue: config.Queue,
now: config.Now, grace: config.Grace, stallAfter: config.StallAfter, staleAfter: config.StaleAfter,
confirmConcurrency: config.ConfirmConcurrency, keepRuns: config.KeepRuns, maxAge: config.MaxAge,
weKnoraWebBase: config.WeKnoraWebBase,
}, nil
}
+41 -1
View File
@@ -3,6 +3,7 @@ package reconciliation
import (
"context"
"errors"
"strings"
"testing"
"time"
@@ -203,7 +204,8 @@ func TestExecuteRunFindsR1ToR8WithoutRemoteWrites(t *testing.T) {
}
service, err := New(Config{Store: store, Remote: remote, Now: func() time.Time { return now },
Grace: 30 * time.Minute, StallAfter: 2 * time.Hour, StaleAfter: 6 * time.Hour,
ConfirmConcurrency: 1, KeepRuns: 30, MaxAge: 90 * 24 * time.Hour})
ConfirmConcurrency: 1, KeepRuns: 30, MaxAge: 90 * 24 * time.Hour,
WeKnoraWebBase: func(context.Context) string { return "https://test.example/" }})
if err != nil {
t.Fatal(err)
}
@@ -234,6 +236,44 @@ func TestExecuteRunFindsR1ToR8WithoutRemoteWrites(t *testing.T) {
if store.completedRun.Counts["R8"] != 1 || store.completedRun.LedgerCount != len(ledger) || store.completedRun.KBCount != len(items) {
t.Fatalf("run counts = %#v", store.completedRun)
}
// Every finding carries the WeKnora jump link built from the resolved test
// origin; an empty base would leave it empty, but a resolved one must not.
for _, finding := range store.findings {
if finding.WeKnoraURL != "https://test.example/platform/knowledge-bases/kb-1" {
t.Fatalf("%s weknora_url = %q", finding.Type, finding.WeKnoraURL)
}
}
}
// Two ledger publications may legitimately hold the same bytes in one test KB
// (adoption). R8 is keyed by publication_id, so that case must stay silent.
func TestR8DoesNotFlagAdoptedDuplicatesWithDistinctPublications(t *testing.T) {
now := time.Date(2026, 12, 1, 12, 0, 0, 0, time.UTC)
sha := strings.Repeat("a", 64)
md5 := strings.Repeat("b", 32)
row := func(pub, doc string) governance.ReconciliationLedgerRow {
return governance.ReconciliationLedgerRow{
PublicationID: pub, KnowledgeID: doc, ProcessingState: "completed", RetrievalState: "unpublished",
TargetScope: "internal", Title: doc, SHA256: sha, UploadMD5: md5, UpdatedAt: now.Add(-time.Hour),
}
}
ledger := []governance.ReconciliationLedgerRow{row("pub-a", "doc-a"), row("pub-b", "doc-b")}
items := []weknora.Knowledge{
{ID: "doc-a", KnowledgeBaseID: "kb-1", Channel: "governance", ParseStatus: "completed", FileHash: md5, Metadata: map[string]any{"publication_id": "pub-a", "content_sha256": sha}},
{ID: "doc-b", KnowledgeBaseID: "kb-1", Channel: "governance", ParseStatus: "completed", FileHash: md5, Metadata: map[string]any{"publication_id": "pub-b", "content_sha256": sha}},
}
service, err := New(Config{Store: &fakeReconciliationStore{}, Remote: &fakeReconciliationRemote{}, Now: func() time.Time { return now }})
if err != nil {
t.Fatal(err)
}
run := governance.ReconciliationRun{ID: "run-1", KBID: "kb-1", StartedAt: now}
findings, err := service.buildFindings(context.Background(), run, ledger, items, false)
if err != nil {
t.Fatal(err)
}
if len(findings) != 0 {
t.Fatalf("adopted duplicates produced findings: %#v", findings)
}
}
func TestExecuteRunFailsWholeBatchWithoutFindings(t *testing.T) {
+11 -1
View File
@@ -1,6 +1,6 @@
import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it, vi } from 'vitest'
import { ReconciliationFindingsView } from './ReconciliationFindings'
import { FindingDetail, ReconciliationFindingsView } from './ReconciliationFindings'
import type { ReconciliationFinding, ReconciliationRun } from './reconciliationApi'
const run: ReconciliationRun = {
@@ -103,4 +103,14 @@ describe('reconciliation findings', () => {
const failed = renderToStaticMarkup(<ReconciliationFindingsView {...props} error="读取对账批次失败" />)
expect(failed).toContain('读取对账批次失败')
})
it('links a finding to WeKnora when the backend supplies a URL', () => {
const html = renderToStaticMarkup(
<FindingDetail
finding={{ ...finding, weknora_url: 'https://weknora.test/platform/knowledge-bases/kb-1' }}
onClose={vi.fn()}
/>
)
expect(html).toContain('href="https://weknora.test/platform/knowledge-bases/kb-1"')
expect(html).toContain('在 WeKnora 中打开')
})
})
+65 -21
View File
@@ -62,11 +62,42 @@ interface FindingsProps {
onDetail: (finding: ReconciliationFinding) => void
}
// ServiceStrip is the page-top one-line status required by §8: the service and
// dependency area collapses into a row on both tabs. Queue truth comes from
// weknora_queues; an unavailable queue is stated, never rendered as a zero.
export function ServiceStrip({ overview }: { overview: MonitorOverview | null }) {
const queue = overview?.weknora_queues
const ready = overview?.health.filter((item) => item.readiness === 'ready').length
const attention = overview?.health.filter(
(item) => item.applicable && item.configured && item.readiness !== 'ready'
).length
return (
<section className="monitor-service-strip" aria-label="服务与队列">
<span>
WeKnora 队列:
{queue ? (
<b>
{queue.queues.reduce((sum, item) => sum + item.pending, 0)} 等待 ·{' '}
{queue.queues.reduce((sum, item) => sum + item.active, 0)} 运行
</b>
) : (
<b className="monitor-muted">未配置只读 Key 或队列不可用</b>
)}
</span>
<span>
服务:
<b>{ready == null ? '等待运行快照' : `${ready} 可接单`}</b>
{attention ? <b className="monitor-bad"> · {attention} 项需关注</b> : null}
</span>
<span className="monitor-muted">一期只对测试库;生产下架依赖测试移除 + 下一轮整库发布</span>
</section>
)
}
export function ReconciliationFindingsView(p: FindingsProps) {
const run = p.runs.items.find((item) => item.id === p.selectedRunID) || p.runs.items[0] || null
const previous = run?.previous_counts || null
const pageCount = Math.max(1, Math.ceil(p.findings.total / p.findings.limit))
const queue = p.overview?.weknora_queues
return (
<main className="page-shell monitor-workbench">
<header className="monitor-heading page-header">
@@ -92,23 +123,7 @@ export function ReconciliationFindingsView(p: FindingsProps) {
{p.error}
</div>
) : null}
<section className="monitor-service-strip" aria-label="服务与队列">
<span>
WeKnora 队列:
{queue ? (
<b>
{queue.queues.reduce((sum, item) => sum + item.pending, 0)} 等待 ·{' '}
{queue.queues.reduce((sum, item) => sum + item.active, 0)} 运行
</b>
) : (
<b className="monitor-muted">未配置只读 Key 或队列不可用</b>
)}
</span>
<span>
服务:<b>{p.overview?.health.filter((item) => item.readiness === 'ready').length ?? 0} 可接单</b>
</span>
<span className="monitor-muted">一期只对测试库;生产下架依赖测试移除 + 下一轮整库发布</span>
</section>
<ServiceStrip overview={p.overview} />
<section className="monitor-recon-overview" aria-label="最近一次对账">
<div className="monitor-recon-controls">
<label>
@@ -327,7 +342,15 @@ export function ReconciliationFindingsView(p: FindingsProps) {
)
}
export function WeKnoraProgress({ documentID, compact = false }: { documentID: string; compact?: boolean }) {
export function WeKnoraProgress({
documentID,
weknoraURL,
compact = false,
}: {
documentID: string
weknoraURL?: string
compact?: boolean
}) {
const [progress, setProgress] = useState<ReconciliationProgress | null>(null)
const [error, setError] = useState('')
const [loading, setLoading] = useState(true)
@@ -364,7 +387,19 @@ export function WeKnoraProgress({ documentID, compact = false }: { documentID: s
<small>实时读取,不落库</small>
</div>
{loading ? <p className="monitor-muted">正在读取…</p> : null}
{error ? <p className="monitor-alert">{error}</p> : null}
{error ? (
<p className="monitor-alert">
{error}
{weknoraURL ? (
<>
{' '}
<a href={weknoraURL} target="_blank" rel="noreferrer">
在 WeKnora 中打开
</a>
</>
) : null}
</p>
) : null}
{progress ? (
<>
<p className="monitor-muted">
@@ -438,7 +473,16 @@ export function FindingDetail({ finding, onClose }: { finding: ReconciliationFin
</div>
))}
</dl>
{finding.document_id ? <WeKnoraProgress documentID={finding.document_id} compact /> : null}
{finding.weknora_url ? (
<p>
<a href={finding.weknora_url} target="_blank" rel="noreferrer">
在 WeKnora 中打开
</a>
</p>
) : null}
{finding.document_id ? (
<WeKnoraProgress documentID={finding.document_id} weknoraURL={finding.weknora_url} compact />
) : null}
</dialog>
)
}
+8 -5
View File
@@ -92,18 +92,21 @@ describe('unified monitor', () => {
'状态说明',
'共 145',
'重试所选',
'服务与依赖',
'monitor-service-strip',
'WeKnora 队列:',
])
expect(html).toContain(s)
expect(html).not.toContain('开始处理')
expect(html).not.toContain('role="tab"')
expect(html).not.toContain('monitor-service-grid')
expect(html).toContain('value="active" selected=""')
})
it('does not claim healthy zeroes or 100% when metrics are unavailable', () => {
const html = renderToStaticMarkup(<WeKnoraMonitorView {...props} error="无法读取运行指标" />)
expect(html).toContain('无法读取运行指标')
expect(html).not.toContain('100%')
expect(html).toContain('尚未取得服务状态')
expect(html).toContain('等待运行快照')
expect(html).not.toContain('0 可接单')
})
it('keeps removal semantics and does not offer retry for completed rows', () => {
const html = renderToStaticMarkup(<WeKnoraMonitorView {...props} />)
@@ -135,7 +138,7 @@ describe('target identity and probe attribution', () => {
expect(html).toContain('历史')
expect(html).toContain('产品/维护')
})
it('shows liveness and the sanitized probe target separately from readiness', () => {
it('surfaces a blocked service in the one-line strip without claiming readiness', () => {
const overview = {
mode: 'real',
simulated: false,
@@ -170,7 +173,7 @@ describe('target identity and probe attribution', () => {
],
}
const html = renderToStaticMarkup(<WeKnoraMonitorView {...props} overview={overview} />)
expect(html).toContain('存活 up')
expect(html).toContain('探测对象 实例 weknora.test · 知识库 1b52c140')
expect(html).toContain('0 可接单')
expect(html).toContain('1 项需关注')
})
})
+4 -37
View File
@@ -7,6 +7,7 @@ import {
canRetryTask,
actionLabels,
stageLabels,
stageFilterLabels,
taskStatusLabels,
targetLabel,
} from './monitorTasks'
@@ -15,7 +16,7 @@ import { requeueJobFailure, retryPublicationsBatch, startPublicationRemoval } fr
import { fetchActiveUISettings, settingsRefreshDelays } from './uiSettings'
import { useOptionalAuth } from './auth'
import { WorkspaceContextTabsSetter } from './workspaceContext'
import { ReconciliationFindingsView, FindingDetail, WeKnoraProgress } from './ReconciliationFindings'
import { ReconciliationFindingsView, FindingDetail, ServiceStrip, WeKnoraProgress } from './ReconciliationFindings'
import type { FindingFilters } from './ReconciliationFindings'
import {
createReconciliationRun,
@@ -196,41 +197,7 @@ export function WeKnoraMonitorView(p: ViewProps) {
</div>
</article>
</section>
<section className="monitor-service-panel">
<div className="monitor-section-heading">
<h2>服务与依赖</h2>
<span>展开查看状态原因</span>
</div>
<div className="monitor-service-grid">
{overview?.health.length ? (
overview.health.map((s) => (
<details key={s.key} className="monitor-service">
<summary>
<span>{s.name}</span>
<b
className={
healthLabel(s) === '可接单'
? 'monitor-good'
: ['阻断', '不可达'].includes(healthLabel(s))
? 'monitor-bad'
: ''
}
>
● {healthLabel(s)}
</b>
</summary>
<p>{s.reason || '未提供状态说明'}</p>
<small>
检测:{time(s.observed_at)} · {s.latency_ms} ms · 存活 {s.liveness || '未确认'}
{s.probe_target ? ` · 探测对象 ${s.probe_target}` : ''}
</small>
</details>
))
) : (
<p className="monitor-muted">尚未取得服务状态</p>
)}
</div>
</section>
<ServiceStrip overview={overview} />
<section className="monitor-files">
<div className="monitor-section-heading">
<div className="monitor-heading-group">
@@ -333,7 +300,7 @@ export function WeKnoraMonitorView(p: ViewProps) {
onChange={(e) => patchFilter('stage', e.target.value)}
>
<option value="">全部阶段</option>
{Object.entries(stageLabels).map(([key, label]) => (
{Object.entries(stageFilterLabels).map(([key, label]) => (
<option key={key} value={key}>
{label}
</option>
+10
View File
@@ -74,6 +74,16 @@ export const stageLabels: Record<string, string> = {
removal: '测试库移除',
finished: '结束',
}
// 阶段筛选按需求 §8 合并「解析」「索引增强」为「WeKnora 处理中」;行内展示仍用
// stageLabels 的细粒度阶段,两者不要互相替代。
export const stageFilterLabels: Record<string, string> = {
waiting: '等待调度',
fetch: '取件',
upload: '上传',
weknora: 'WeKnora 处理中',
removal: '测试库移除',
finished: '结束',
}
export const taskStatusLabels: Record<string, string> = {
waiting: '等待中',
running: '执行中',
-67
View File
@@ -77,25 +77,14 @@
.monitor-numbers .monitor-memory {
font-size: 24px;
}
.monitor-good {
color: var(--c-done) !important;
}
.monitor-bad {
color: var(--c-fail) !important;
}
.monitor-service-panel,
.monitor-files {
border: 1px solid var(--border-base);
border-radius: var(--r-lg);
background: var(--bg-panel);
box-shadow: var(--shadow-card);
overflow: hidden;
}
.monitor-service-panel {
padding: 18px 20px;
margin-bottom: 16px;
}
.monitor-files {
/* 时间范围浮层要能溢出卡片;圆角由表头/分页各自裁切 */
overflow: visible;
}
@@ -125,56 +114,6 @@
font-size: 11px;
color: var(--ink-mute);
}
.monitor-service-grid {
display: grid;
grid-template-columns: repeat(6, minmax(0, 1fr));
gap: 9px;
margin-top: 13px;
align-items: start;
}
.monitor-service {
border: 1px solid var(--border-soft);
border-radius: var(--r-md);
background: var(--bg-soft);
padding: 10px 12px;
transition:
border-color 120ms ease,
background 120ms ease;
}
.monitor-service:hover,
.monitor-service[open] {
border-color: var(--border-base);
background: var(--bg-panel);
font-size: 12px;
min-width: 0;
}
.monitor-service summary {
list-style: none;
cursor: pointer;
display: flex;
flex-direction: column;
gap: 6px;
}
.monitor-service summary::-webkit-details-marker {
display: none;
}
.monitor-service summary > span {
overflow-wrap: anywhere;
color: var(--ink-base);
font-weight: 500;
}
.monitor-service b {
font-size: 11px;
font-weight: 500;
color: var(--ink-mute);
}
.monitor-service p,
.monitor-service small {
font-size: 11px;
color: var(--ink-mute);
overflow-wrap: anywhere;
line-height: 1.6;
}
.monitor-files > .monitor-section-heading {
padding: 18px 20px 14px;
}
@@ -542,9 +481,6 @@
.monitor-metric-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.monitor-service-grid {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
}
@media (max-width: 760px) {
.monitor-heading {
@@ -553,9 +489,6 @@
.monitor-heading > span {
margin-left: 0;
}
.monitor-service-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.monitor-metric-grid {
gap: 8px;
}