feat(client): redesign master kanban workbench and single-project sidebar UI

This commit is contained in:
qyh15 2026-11-29 14:09:37 +08:00
parent 0598543799
commit 977013c8c7
7 changed files with 8140 additions and 5055 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
// 三省六部 Web 插件入口:左侧追加「三省六部」入口,点开右侧工作台。
// 所有对宿主可选服务的调用都用 ctx.get(...) 特性探测,探测不到就降级,不伪造接口。
import { createElement as h, Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { createPortal } from 'react-dom'
import { createElement as h, useCallback } from 'react'
import { SEAT_IDS, SEATS } from '../shared/roles.js'
import { WorkbenchV2 } from './workbench-v2.js'
import { MasterWorkbench } from './master-workbench.js'
import { workspaceForSession, workspaceItemsFromSnapshot, sessionSummaryFromSnapshot } from './workspace.js'
import { request } from './transport.js'
import { CSS as WORKBENCH_CSS } from './styles.js'
@ -608,73 +608,33 @@ export function apply(ctx) {
})
}
// 导航行内容(宿主只把这里当图标渲染,标签由宿主按 label() 画)。
// 点击只开右侧工作台,并阻止冒泡,避免宿主把主区切成面板页——中央原生聊天因此保持原样。
// 导航行图标:由宿主 sidebar.panellist 整行接管点击,直接把主区切到主工作台总台。
function SanshengNavButton(props) {
const size = props && typeof props.size === 'number' ? props.size : 16
const [floating, setFloating] = useState(false)
const stop = (event) => {
if (event && isFn(event.stopPropagation)) event.stopPropagation()
}
const onClick = (event) => {
if (event && isFn(event.stopPropagation)) event.stopPropagation()
if (event && isFn(event.preventDefault)) event.preventDefault()
if (openRightWorkbench(currentSessionId())) { setFloating(false); return }
setFloating(value => !value)
}
let panel = null
if (floating) {
const card = h('div', { className: 'ssw-float', role: 'dialog', 'aria-label': '三省六部工作台' },
h(SanshengWorkbench, { sessionId: currentSessionId(), onClose: () => setFloating(false) }))
const canPortal = typeof document !== 'undefined' && document.body && isFn(createPortal)
panel = canPortal ? createPortal(card, document.body) : card
}
return h(Fragment, null,
h('span', {
className: 'ssw-nav-hit', role: 'presentation', title: '三省六部', onClick,
onPointerDown: stop, onMouseDown: stop,
'aria-expanded': floating ? 'true' : 'false',
}, h(TreeIcon, { width: size, height: size })),
panel,
)
return h('span', {
className: 'ssw-nav-hit',
role: 'presentation',
title: '三省六部',
}, h(TreeIcon, { width: size, height: size }))
}
// 兜底:若宿主按整行点击切了主区,先把工作台打开到右侧并切回会话;
// 右侧打不开时就在主区直接渲染工作台(而不是空白),保证点击一定有反应。
function backToChat() {
const layout = get('layout')
if (layout && isFn(layout.selectPanel)) { try { layout.selectPanel(null) } catch { /* 忽略 */ } }
}
function SanshengNavFallback() {
// 点击左侧「三省六部」整行时,优先把工作台停靠到右侧;打不开就在主区内嵌显示。
// openRightWorkbench 必须在组件仍挂载时同步尝试,避免切走主区后定时器落在卸载实例上。
const [mode, setMode] = useState('pending')
useEffect(() => {
let opened = false
try { opened = openRightWorkbench(currentSessionId()) } catch { opened = false }
if (opened) {
setMode('docked')
backToChat()
return undefined
}
setMode('inline')
return undefined
}, [])
useEffect(() => {
if (mode !== 'docked') return
backToChat()
const timer = setTimeout(backToChat, 700)
return () => clearTimeout(timer)
}, [mode])
if (mode === 'pending') return null
if (mode === 'docked') return null
return h('div', { className: 'ssw-tab-body' },
h('div', { className: 'ssw-inline-bar' },
h('span', null, '工作台 · 内嵌模式'),
h('button', { type: 'button', className: 'ssw-link', onClick: backToChat }, '返回对话'),
),
h(SanshengWorkbench, { sessionId: currentSessionId() }),
)
function SanshengMasterPanel() {
return h('div', { className: 'ssw-main-panel', 'data-sansheng-main': 'master-workbench' },
h(MasterWorkbench, {
getWorkspaces: workspaceItems,
getCurrentWorkspace: currentWorkspace,
navigateToSession: (sid) => {
const ok = navigateToSession(sid)
backToChat()
return ok
},
openRightTab: tryOpenRightTab,
}))
}
function registerNavEntry() {
@ -689,7 +649,7 @@ export function apply(ctx) {
for (const dispose of disposers.splice(0)) { try { if (isFn(dispose)) dispose() } catch { /* 忽略 */ } }
}
try {
disposers.push(ctx.slots.register({ name: 'main', key: NAV_PANEL_ID, inject: () => ({}) }, SanshengNavFallback))
disposers.push(ctx.slots.register({ name: 'main', key: NAV_PANEL_ID, inject: () => ({}) }, SanshengMasterPanel))
disposers.push(ctx.slots.register({ name: 'sidebar.panellist', id: NAV_PANEL_ID, order: NAV_ORDER, label: () => '三省六部' }, SanshengNavButton))
} catch (error) {
disposeAll()

View File

@ -0,0 +1,394 @@
// 纯视图模型:不 import React、不触碰 DOM,供主工作台看板与节点单测共用。
import { SEATS } from '../shared/roles.js'
import { collectModelOptions, SEAT_STATUS_LABELS } from './workbench.js'
export const MASTER_ACTIVE_COLUMNS = Object.freeze([
{ id: 'planning', title: '待规划 · 需求池', subtitle: '丞相接单 / 中书拟案', tone: 'muted' },
{ id: 'review', title: '门下复核', subtitle: '方案审议 / 验收复核', tone: 'primary' },
{ id: 'running', title: '六部执行中', subtitle: '尚书派工 · 并行交付', tone: 'success' },
])
export const MASTER_BLOCKED_COLUMN = Object.freeze({
id: 'blocked',
title: '阻塞 / 异常',
subtitle: '需审批 / 失败 / 重投',
tone: 'error',
})
export const MASTER_DONE_COLUMN = Object.freeze({
id: 'done',
title: '已交付',
subtitle: '验收通过归档',
tone: 'success',
})
export const PROJECT_DOT_VARS = Object.freeze([
'--chart-1',
'--chart-2',
'--chart-3',
'--primary',
'--success',
'--warning',
])
const TASK_BLOCK_LABELS = {
failed: '执行失败',
returned: '已退回',
reconfirm: '待重新确认',
}
export function computeMasterLayoutMode(frameWidth, hasPendingDock) {
const w = Number(frameWidth) || 1280
const dockW = hasPendingDock ? (w <= 1160 ? 312 : 344) : 0
const boardW = Math.max(0, w - dockW)
if (boardW >= 880) return 'board4'
if (boardW >= 640) return 'board3'
return 'list'
}
export function groupModelChoices(modelsOrOptions) {
const options = Array.isArray(modelsOrOptions) ? modelsOrOptions : collectModelOptions(modelsOrOptions)
const out = []
const byKey = new Map()
for (const option of options) {
if (!option || option.value === 'inherit') continue
const provider = typeof option.provider === 'string' ? option.provider : ''
const model = typeof option.model === 'string' ? option.model : ''
if (!provider || !model) continue
const key = provider + '::' + model
if (key === 'inherit') continue
let entry = byKey.get(key)
if (!entry) {
entry = { value: key, label: model, provider, model, efforts: [] }
byKey.set(key, entry)
out.push(entry)
}
if (typeof option.reasoningEffort === 'string' && option.reasoningEffort && !entry.efforts.includes(option.reasoningEffort)) {
entry.efforts.push(option.reasoningEffort)
}
}
return out
}
export function modelPartsOf(model) {
if (!model || typeof model !== 'object' || typeof model.provider !== 'string' || typeof model.model !== 'string') {
return { modelKey: '', effort: '' }
}
return {
modelKey: model.provider + '::' + model.model,
effort: typeof model.reasoningEffort === 'string' ? model.reasoningEffort : '',
}
}
export function modelObjectFromParts(modelKey, effort) {
const raw = String(modelKey || '').trim()
if (!raw || raw === 'inherit') return null
const parts = raw.split('::')
const provider = parts[0]?.trim()
const model = parts[1]?.trim()
if (!provider || !model) return null
const eff = String(effort || parts[2] || '').trim()
return eff ? { provider, model, reasoningEffort: eff } : { provider, model }
}
export function shortModelName(model) {
if (!model || typeof model !== 'object' || typeof model.model !== 'string' || !model.model.trim()) {
return '未选模型'
}
const clean = model.model.trim().replace(/^deepseek-/, '')
const effort = typeof model.reasoningEffort === 'string' && model.reasoningEffort.trim() ? model.reasoningEffort.trim() : ''
return effort ? clean + ' · ' + effort : clean
}
export function classifyTaskColumn(task) {
if (!task || typeof task !== 'object') return 'planning'
if (task.status === 'done' || task.stage === 'delivered') return 'done'
if (
task.stage === 'menxia_review'
|| task.stage === 'menxia_acceptance'
|| task.stage === 'awaiting_execution_approval'
|| task.ownerSeatId === 'menxia'
|| task.status === 'prepared'
|| task.status === 'waiting_user'
) {
return 'review'
}
if (
task.stage === 'zhongshu_draft'
|| task.status === 'draft'
|| task.ownerSeatId === 'zhongshu'
|| (task.ownerSeatId === 'lead' && task.stage !== 'lead_delivery')
) {
return 'planning'
}
return 'running'
}
export function detectTaskBlockage(task, childTasks = []) {
if (!task || typeof task !== 'object') return null
if (task.status === 'done' || task.stage === 'delivered' || task.status === 'cancelled') return null
if (task.workflowBlockage) {
return {
label: task.workflowBlockage.label || '流程阻塞',
reason: task.workflowBlockage.reason || task.blockedReason || '流程推进受阻,请排查后继续',
canRedispatch: task.deliveryState === 'unknown' && Boolean(task.deliveryId),
deliveryId: task.deliveryId || null,
targetTaskId: task.id,
}
}
if (task.deliveryState === 'unknown') {
return {
label: '投递结果未知',
reason: task.note || task.blockedReason || '投递状态未知,核对会话后可显式重投',
canRedispatch: Boolean(task.deliveryId),
deliveryId: task.deliveryId || null,
targetTaskId: task.id,
}
}
if (['failed', 'returned', 'reconfirm'].includes(task.status) || task.stage === 'reconfirm') {
const label = TASK_BLOCK_LABELS[task.status] || (task.stage === 'reconfirm' ? '待重新确认' : '任务异常')
return {
label,
reason: task.blockedReason || task.note || task.reviewNote || '任务异常或需要重新确认',
canRedispatch: false,
deliveryId: null,
targetTaskId: task.id,
}
}
for (const child of childTasks) {
if (!child || child.status === 'cancelled') continue
if (child.workflowBlockage) {
return {
label: '子项阻塞',
reason: child.workflowBlockage.reason || child.blockedReason || '部门子任务流程受阻',
canRedispatch: child.deliveryState === 'unknown' && Boolean(child.deliveryId),
deliveryId: child.deliveryId || null,
targetTaskId: child.id,
}
}
if (child.deliveryState === 'unknown') {
return {
label: '子项阻塞',
reason: child.note || child.blockedReason || '部门子任务投递结果未知,可显式重投',
canRedispatch: Boolean(child.deliveryId),
deliveryId: child.deliveryId || null,
targetTaskId: child.id,
}
}
if (child.status === 'failed') {
return {
label: '子项阻塞',
reason: child.blockedReason || child.note || child.result || '部门子任务执行失败',
canRedispatch: false,
deliveryId: null,
targetTaskId: child.id,
}
}
}
return null
}
function normalizeSeatsMap(seats) {
const map = {}
if (Array.isArray(seats)) {
for (const seat of seats) {
if (seat && typeof seat.id === 'string') map[seat.id] = seat
}
} else if (seats && typeof seats === 'object') {
for (const [id, seat] of Object.entries(seats)) {
if (seat && typeof seat === 'object') map[id] = { id, ...seat }
}
}
return map
}
function formatShortElapsed(startTs, endTs, now) {
const start = Number(startTs || 0)
const end = Number(endTs || now || 0)
if (!Number.isFinite(start) || start <= 0 || !Number.isFinite(end) || end <= start) return '—'
const sec = Math.max(1, Math.round((end - start) / 1000))
if (sec < 60) return sec + 's'
const min = Math.floor(sec / 60)
if (min < 60) return min + 'm'
const hr = Math.floor(min / 60)
const remMin = min % 60
return remMin > 0 ? hr + 'h ' + remMin + 'm' : hr + 'h'
}
export function buildMasterItems(projectBundles, modelsOrOptions, now = Date.now()) {
const bundles = Array.isArray(projectBundles) ? projectBundles : []
const items = []
bundles.forEach((bundle, projIndex) => {
const proj = bundle?.project?.project ?? bundle?.project ?? bundle
if (!proj || typeof proj.id !== 'string' || !proj.id) return
const colorVar = PROJECT_DOT_VARS[projIndex % PROJECT_DOT_VARS.length]
const seatMap = normalizeSeatsMap(proj.seats)
const allTasks = (Array.isArray(bundle?.tasks) ? bundle.tasks : []).filter(t => t && t.status !== 'cancelled')
const allReqs = (Array.isArray(bundle?.requirements) ? bundle.requirements : []).filter(r => r && r.status !== 'cancelled')
const allArtifacts = Array.isArray(bundle?.artifacts) ? bundle.artifacts : []
const workflowIds = new Set(allTasks.filter(t => t.kind === 'workflow').map(t => t.id))
const childrenByParent = new Map()
for (const t of allTasks) {
if (t.kind === 'execution' && t.parentTaskId && workflowIds.has(t.parentTaskId)) {
let arr = childrenByParent.get(t.parentTaskId)
if (!arr) { arr = []; childrenByParent.set(t.parentTaskId, arr) }
arr.push(t)
}
}
const coveredReqKeys = new Set()
for (const t of allTasks) {
if (t.kind === 'workflow' && t.requirementId) {
coveredReqKeys.add(t.requirementId + '@' + String(t.requirementRevision ?? ''))
}
}
for (const task of allTasks) {
if (task.kind === 'execution' && task.parentTaskId && workflowIds.has(task.parentTaskId)) {
continue
}
const childTasks = childrenByParent.get(task.id) || []
const col = classifyTaskColumn(task)
const blockage = detectTaskBlockage(task, childTasks)
const seatRec = seatMap[task.ownerSeatId] || null
const seatModel = seatRec?.configuredModel ?? seatRec?.model ?? null
const childIdSet = new Set(childTasks.map(c => c.id))
const matchedArtifacts = allArtifacts.filter(a => a && (a.taskId === task.id || (a.taskId && childIdSet.has(a.taskId))))
const subtasks = childTasks.map(child => {
const childBlock = detectTaskBlockage(child)
const childSeat = seatMap[child.ownerSeatId] || null
const st = child.status === 'done'
? 'done'
: childBlock
? 'blocked'
: (child.status === 'running' || child.status === 'dispatched')
? 'running'
: 'pending'
return {
id: child.id,
seatId: child.ownerSeatId,
title: child.title || child.id,
status: st,
statusLabel: childBlock ? childBlock.label : (SEATS[child.ownerSeatId]?.label || child.status),
sessionId: childSeat?.sessionId || null,
blockage: childBlock,
result: child.result || child.note || '',
}
})
const ticker = blockage
? blockage.label + ':' + blockage.reason
: (col === 'done'
? (task.deliveryNote || task.result || task.summary || '已完成验收交付')
: (task.result || task.note || task.blockedReason || task.goal || task.requirement || '等待推进'))
items.push({
key: proj.id + '::task::' + task.id,
id: task.id,
itemKind: 'task',
projectId: proj.id,
projectName: proj.name || proj.id,
projectColorVar: colorVar,
col,
seatId: task.ownerSeatId || 'lead',
seatStatusLabel: SEAT_STATUS_LABELS[seatRec?.status] || '',
title: task.title || task.id,
ticker,
originalText: task.requirementSnapshot?.originalText || task.requirement || '',
goal: task.goal || task.requirement || '',
result: task.result || task.deliveryNote || task.summary || '',
stage: task.stage || null,
status: task.status,
blockage,
subtasks,
progress: subtasks.length > 0
? { done: childTasks.filter(c => c.status === 'done').length, total: childTasks.length }
: null,
consultations: Array.isArray(task.consultations) ? task.consultations : [],
decisions: Array.isArray(task.decisions) ? task.decisions : [],
artifacts: matchedArtifacts,
modelLabel: shortModelName(seatModel),
durationText: formatShortElapsed(task.dispatchedAt || task.createdAt, task.resultAt, now),
updatedAt: Number(task.updatedAt || task.createdAt || 0),
rawTask: task,
rawRequirement: null,
})
}
for (const req of allReqs) {
if (!['discussing', 'ready', 'returned'].includes(req.status)) continue
const coverKey = req.id + '@' + String(req.revision ?? '')
if (coveredReqKeys.has(coverKey)) continue
const leadSeat = seatMap.lead || null
const leadModel = leadSeat?.configuredModel ?? leadSeat?.model ?? null
const blockage = req.status === 'returned'
? { label: '需求退回', reason: req.blockedReason || '已退回,等待与丞相重新确认', canRedispatch: false, deliveryId: null, targetTaskId: null }
: null
items.push({
key: proj.id + '::req::' + req.id,
id: req.id,
itemKind: 'requirement',
projectId: proj.id,
projectName: proj.name || proj.id,
projectColorVar: colorVar,
col: 'planning',
seatId: 'lead',
seatStatusLabel: SEAT_STATUS_LABELS[leadSeat?.status] || '',
title: req.title || req.id,
ticker: req.summary || req.blockedReason || req.originalText || '待丞相整理或下派中书拟案',
originalText: req.originalText || '',
goal: req.scope || req.summary || req.originalText || '',
result: req.acceptanceCriteria || req.judgementReason || '',
stage: null,
status: req.status,
blockage,
subtasks: [],
progress: null,
consultations: [],
decisions: [],
artifacts: [],
modelLabel: shortModelName(leadModel),
durationText: formatShortElapsed(req.updatedAt || req.createdAt, null, now),
updatedAt: Number(req.updatedAt || req.createdAt || 0),
rawTask: null,
rawRequirement: req,
})
}
})
return items
}
export function sortMasterColumnItems(items) {
return [...(Array.isArray(items) ? items : [])].sort((a, b) => {
const ba = a?.blockage ? 1 : 0
const bb = b?.blockage ? 1 : 0
if (ba !== bb) return bb - ba
return Number(b?.updatedAt || 0) - Number(a?.updatedAt || 0)
})
}
export function filterMasterItems(items, { projectFilter = 'all', search = '' } = {}) {
const list = Array.isArray(items) ? items : []
const q = String(search || '').trim().toLowerCase()
return list.filter(item => {
if (projectFilter && projectFilter !== 'all' && item.projectId !== projectFilter) return false
if (!q) return true
const seatLabel = SEATS[item.seatId]?.label || item.seatId || ''
const subtaskFields = (item.subtasks || []).flatMap(st => [
st.id,
st.title,
SEATS[st.seatId]?.label || st.seatId,
st.result,
])
const haystack = [item.id, item.title, item.ticker, item.projectName, seatLabel, item.goal, item.result, ...subtaskFields]
.filter(Boolean)
.join(' ')
.toLowerCase()
return haystack.includes(q)
})
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,156 @@
// 只测纯视图模型与静态前端契约,绝不 import React 组件入口。
import test from 'node:test'
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import {
buildMasterItems,
computeMasterLayoutMode,
filterMasterItems,
groupModelChoices,
modelObjectFromParts,
sortMasterColumnItems,
} from '../src/client/master-model.js'
const CATALOG = {
providers: [
{
provider: 'deepseek',
models: [
{ model: 'deepseek-chat', reasoningEffort: ['low', 'high'] },
{ model: 'deepseek-reasoner' },
],
},
],
}
test('computeMasterLayoutMode 严格按看板有效宽度划分四列 / 三列 / 自动列表', () => {
assert.equal(computeMasterLayoutMode(1280, true), 'board4')
assert.equal(computeMasterLayoutMode(1100, true), 'board3')
assert.equal(computeMasterLayoutMode(900, true), 'list')
assert.equal(computeMasterLayoutMode(900, false), 'board4')
assert.equal(computeMasterLayoutMode(760, false), 'board3')
assert.equal(computeMasterLayoutMode(520, false), 'list')
})
test('groupModelChoices 去重汇总推理等级,且绝不出现 inherit', () => {
const choices = groupModelChoices(CATALOG)
assert.equal(choices.length, 2)
assert.equal(choices[0].value, 'deepseek::deepseek-chat')
assert.deepEqual(choices[0].efforts, ['low', 'high'])
assert.equal(choices[1].value, 'deepseek::deepseek-reasoner')
assert.deepEqual(choices[1].efforts, [])
assert.ok(!choices.some(c => c.value === 'inherit'))
assert.equal(modelObjectFromParts('inherit', ''), null)
assert.deepEqual(modelObjectFromParts('deepseek::deepseek-chat', 'high'), {
provider: 'deepseek',
model: 'deepseek-chat',
reasoningEffort: 'high',
})
})
test('buildMasterItems 汇总流程与执行子项、传播阻塞、纳入未下派需求并剔除已取消项', () => {
const bundles = [
{
project: {
id: 'proj-a',
name: 'alpha',
seats: [
{ id: 'lead', status: 'bound', model: { provider: 'deepseek', model: 'deepseek-chat' } },
{ id: 'zhongshu', status: 'bound', model: { provider: 'deepseek', model: 'deepseek-reasoner' } },
{ id: 'menxia', status: 'bound', model: { provider: 'deepseek', model: 'deepseek-chat' } },
{ id: 'gongbu', status: 'bound', model: { provider: 'deepseek', model: 'deepseek-chat', reasoningEffort: 'high' } },
{ id: 'bingbu', status: 'missing', model: { provider: 'deepseek', model: 'deepseek-chat' } },
],
},
tasks: [
{
id: 't-plan', title: '拟案中', kind: 'workflow', ownerSeatId: 'zhongshu',
stage: 'zhongshu_draft', status: 'running', requirementId: 'R-001', requirementRevision: 1, updatedAt: 100,
},
{
id: 't-rev', title: '待门下复核', kind: 'workflow', ownerSeatId: 'menxia',
stage: 'menxia_review', status: 'prepared', requirementId: 'R-002', requirementRevision: 1, updatedAt: 200,
},
{
id: 't-run', title: '六部并行实施', kind: 'workflow', ownerSeatId: 'gongbu',
stage: 'department_exec', status: 'running', requirementId: 'R-003', requirementRevision: 1, updatedAt: 300,
},
{
id: 't-sub-1', title: '前端样式', kind: 'execution', parentTaskId: 't-run', ownerSeatId: 'gongbu',
status: 'done', result: '已完成', updatedAt: 310,
},
{
id: 't-sub-2', title: '部署验证', kind: 'execution', parentTaskId: 't-run', ownerSeatId: 'bingbu',
status: 'running', deliveryState: 'unknown', deliveryId: 'del-9', note: '会话缺失导致未知', updatedAt: 320,
},
{
id: 't-done', title: '已交付基线', kind: 'workflow', ownerSeatId: 'zhongshu',
stage: 'delivered', status: 'done', deliveryNote: '验收通过', updatedAt: 50,
},
{
id: 't-cancel', title: '作废任务', kind: 'workflow', ownerSeatId: 'zhongshu',
stage: 'zhongshu_draft', status: 'cancelled', updatedAt: 999,
},
],
requirements: [
{ id: 'R-001', revision: 1, title: '已下派的需求', status: 'published', summary: '应由 t-plan 承接' },
{ id: 'R-004', revision: 1, title: '待下派新需求', status: 'ready', summary: '待丞相发布', updatedAt: 400 },
{ id: 'R-005', revision: 1, title: '已取消需求', status: 'cancelled', updatedAt: 500 },
],
artifacts: [
{ id: 'art-1', taskId: 't-sub-1', title: '样式产出', path: 'src/styles.js' },
],
},
]
const items = buildMasterItems(bundles, CATALOG, 1000)
const keys = items.map(i => i.id)
assert.ok(!keys.includes('t-sub-1'), '已归并到父任务的子项不应重复铺在看板顶层')
assert.ok(!keys.includes('t-sub-2'))
assert.ok(!keys.includes('t-cancel'), '已取消任务不应出现在看板')
assert.ok(!keys.includes('R-001'), '已有流转任务覆盖的需求不重复建卡')
assert.ok(!keys.includes('R-005'), '已取消需求不应出现')
assert.ok(keys.includes('R-004'), '未下派活跃需求应落入规划列')
const plan = items.find(i => i.id === 't-plan')
const rev = items.find(i => i.id === 't-rev')
const run = items.find(i => i.id === 't-run')
const reqCard = items.find(i => i.id === 'R-004')
const done = items.find(i => i.id === 't-done')
assert.equal(plan.col, 'planning')
assert.equal(rev.col, 'review')
assert.equal(run.col, 'running')
assert.equal(reqCard.col, 'planning')
assert.equal(done.col, 'done')
assert.deepEqual(run.progress, { done: 1, total: 2 })
assert.equal(run.subtasks.length, 2)
assert.equal(run.artifacts.length, 1)
assert.equal(run.blockage.label, '子项阻塞')
assert.equal(run.blockage.canRedispatch, true)
assert.equal(run.blockage.targetTaskId, 't-sub-2')
assert.equal(run.blockage.deliveryId, 'del-9')
const sorted = sortMasterColumnItems([plan, run])
assert.equal(sorted[0].id, 't-run', '阻塞任务在同列排序时置顶')
const filtered = filterMasterItems(items, { projectFilter: 'proj-a', search: '兵部' })
assert.equal(filtered.length, 1)
assert.equal(filtered[0].id, 't-run')
})
test('前端源码静态检查:无 Tailwind CDN、无 inherit 选项、保留关键契约类名与文案', async () => {
const masterSrc = await readFile(new URL('../src/client/master-workbench.js', import.meta.url), 'utf8')
const sidebarSrc = await readFile(new URL('../src/client/workbench-v2.js', import.meta.url), 'utf8')
const stylesSrc = await readFile(new URL('../src/client/styles.js', import.meta.url), 'utf8')
for (const src of [masterSrc, sidebarSrc]) {
assert.doesNotMatch(src, /tailwindcss/i)
assert.doesNotMatch(src, /value:\s*['"]inherit['"]/)
}
assert.match(sidebarSrc, /ssv2 ssw-tab-body/)
assert.match(sidebarSrc, /需求清单/)
assert.match(stylesSrc, /\.ssmwb/)
assert.match(stylesSrc, /\.ssv2/)
})