From 977013c8c7df11949b1dc3981d97cd77e0c15095 Mon Sep 17 00:00:00 2001 From: qyh15 Date: Sun, 29 Nov 2026 14:09:37 +0800 Subject: [PATCH] feat(client): redesign master kanban workbench and single-project sidebar UI --- sansheng/client.js | 7020 ++++++++++++++--------- sansheng/src/client/index.js | 84 +- sansheng/src/client/master-model.js | 394 ++ sansheng/src/client/master-workbench.js | 1184 ++++ sansheng/src/client/styles.js | 1132 ++-- sansheng/src/client/workbench-v2.js | 3225 ++++++----- sansheng/test/master-model.test.js | 156 + 7 files changed, 8140 insertions(+), 5055 deletions(-) create mode 100644 sansheng/src/client/master-model.js create mode 100644 sansheng/src/client/master-workbench.js create mode 100644 sansheng/test/master-model.test.js diff --git a/sansheng/client.js b/sansheng/client.js index ccf4273..e39ab46 100644 --- a/sansheng/client.js +++ b/sansheng/client.js @@ -356,6 +356,346 @@ function buildWorkbenchView(view, ui) { }; } +// src/client/master-model.js +var MASTER_ACTIVE_COLUMNS = Object.freeze([ + { id: "planning", title: "待规划 · 需求池", subtitle: "丞相接单 / 中书拟案", tone: "muted" }, + { id: "review", title: "门下复核", subtitle: "方案审议 / 验收复核", tone: "primary" }, + { id: "running", title: "六部执行中", subtitle: "尚书派工 · 并行交付", tone: "success" } +]); +var MASTER_BLOCKED_COLUMN = Object.freeze({ + id: "blocked", + title: "阻塞 / 异常", + subtitle: "需审批 / 失败 / 重投", + tone: "error" +}); +var MASTER_DONE_COLUMN = Object.freeze({ + id: "done", + title: "已交付", + subtitle: "验收通过归档", + tone: "success" +}); +var PROJECT_DOT_VARS = Object.freeze([ + "--chart-1", + "--chart-2", + "--chart-3", + "--primary", + "--success", + "--warning" +]); +var TASK_BLOCK_LABELS = { + failed: "执行失败", + returned: "已退回", + reconfirm: "待重新确认" +}; +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"; +} +function groupModelChoices(modelsOrOptions) { + const options = Array.isArray(modelsOrOptions) ? modelsOrOptions : collectModelOptions(modelsOrOptions); + const out = []; + const byKey = /* @__PURE__ */ 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; +} +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 : "" + }; +} +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 }; +} +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; +} +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"; +} +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) / 1e3)); + 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"; +} +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 = /* @__PURE__ */ 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 = /* @__PURE__ */ 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; +} +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); + }); +} +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 seatLabel2 = 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, seatLabel2, item.goal, item.result, ...subtaskFields].filter(Boolean).join(" ").toLowerCase(); + return haystack.includes(q); + }); +} + // src/client/transport.js var ROUTE = "api/sansheng"; var SanshengRequestError = class extends Error { @@ -402,232 +742,117 @@ var transport_default = request; // src/client/workbench-v2.js var import_react = require("react"); -var TODAY = () => { - const d = /* @__PURE__ */ new Date(); - d.setHours(0, 0, 0, 0); - return d.getTime(); +var SANSHENG_ORDER = ["zhongshu", "menxia", "shangshu"]; +var LIUBU_ORDER = ["libu", "hubu", "lipu", "bingbu", "xingbu", "gongbu"]; +var DELIB_SEATS = ["zhongshu", "menxia", "shangshu"]; +var AVATAR_MIME = ["image/png", "image/jpeg", "image/webp"]; +var AVATAR_MAX_BYTES = 120 * 1024; +var TASK_META = { + draft: { label: "待派发", tone: "muted" }, + dispatched: { label: "已派发", tone: "primary" }, + running: { label: "进行中", tone: "primary" }, + prepared: { label: "待复核", tone: "warning" }, + done: { label: "已完成", tone: "success" }, + cancelled: { label: "已取消", tone: "muted" }, + failed: { label: "失败", tone: "error" }, + waiting_user: { label: "待批准", tone: "warning" }, + returned: { label: "已退回", tone: "error" }, + reconfirm: { label: "待重确认", tone: "error" } }; -var TASK_LABELS = { - draft: "待派发", - dispatched: "已派发", - running: "进行中", - prepared: "待复核", - done: "已完成", - cancelled: "已取消", - failed: "失败", - waiting_user: "待用户批准", - returned: "已退回", - reconfirm: "待重新确认" -}; -var TASK_TONES = { - draft: "idle", - dispatched: "review", - running: "run", - prepared: "review", - done: "done", - cancelled: "idle", - failed: "fail", - waiting_user: "review", - returned: "fail", - reconfirm: "fail" -}; -var OPEN_STATUS = /* @__PURE__ */ new Set(["dispatched", "running", "prepared"]); -var REQ_STATUS_LABELS = { - discussing: "商讨中", - ready: "待下派", - published: "已下派", - returned: "已退回", - cancelled: "已取消" +var REQ_STATUS_META = { + discussing: { label: "商讨中", tone: "primary" }, + ready: { label: "待下派", tone: "warning" }, + published: { label: "已下派", tone: "success" }, + returned: { label: "已退回", tone: "error" }, + cancelled: { label: "已取消", tone: "muted" } }; var REQ_JUDGEMENT_LABELS = { can_do: "可立项", needs_discussion: "需商讨", not_now: "暂不可做" }; -var WORKFLOW_STAGE_LABELS = { - zhongshu_draft: "中书拟案", - menxia_review: "门下审核", - awaiting_execution_approval: "待用户批准", - shangshu_dispatch: "尚书调度", - department_exec: "六部执行", - menxia_acceptance: "门下验收", - lead_delivery: "丞相交付", - delivered: "已交付", - reconfirm: "待重新确认" -}; -function toneOfSeat(seat) { - if (!seat) return "idle"; - if (seat.runtimeState === "running") return "run"; - if (seat.runtimeState === "idle" || seat.runtimeState === "unknown") return "idle"; - if (seat.status === "failed" || seat.status === "missing") return "fail"; - if (seat.status === "creating") return "run"; - return "idle"; -} -function seatStateText(seat) { - if (!seat) return "待命"; - if (seat.approvalState === "waiting") return "等待审批"; - if (seat.runtimeLabel) return seat.runtimeLabel; - if (seat.status === "bound") return "待命"; - if (seat.status === "creating") return "开启中"; - if (seat.status === "missing") return "会话缺失"; - if (seat.status === "failed") return "创建失败"; - return "待命"; -} -function taskTone(status) { - return TASK_TONES[status] || "idle"; -} -function taskLabel(status) { - return TASK_LABELS[status] || status || "未知"; -} -function refreshList(value, previous, projectChanged = false) { - if (Array.isArray(value)) return value; - return projectChanged ? [] : previous; -} -var DELIVERY_LABELS = { pending: "待发送", sending: "发送中", unknown: "结果未知", accepted: "已接收" }; -function deliveryLabel(state) { - return DELIVERY_LABELS[state] || ""; +var WORKFLOW_STAGES = [ + { id: "zhongshu_draft", label: "中书拟案" }, + { id: "menxia_review", label: "门下审核" }, + { id: "awaiting_execution_approval", label: "待批准" }, + { id: "shangshu_dispatch", label: "尚书调度" }, + { id: "department_exec", label: "六部执行" }, + { id: "menxia_acceptance", label: "门下验收" }, + { id: "delivered", label: "已交付" } +]; +function smallSvg(paths, size = 14) { + return (0, import_react.createElement)("svg", { + viewBox: "0 0 24 24", + width: size, + height: size, + fill: "none", + stroke: "currentColor", + strokeWidth: 1.8, + strokeLinecap: "round", + strokeLinejoin: "round", + "aria-hidden": "true" + }, paths.map((d, idx) => (0, import_react.createElement)("path", { key: idx, d }))); } +var RefreshIcon = () => smallSvg(["M21 12a9 9 0 1 1-2.64-6.36", "M21 3v6h-6"], 13); +var ChatIcon = () => smallSvg(["M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"], 13); +var PlusIcon = () => smallSvg(["M12 5v14", "M5 12h14"], 13); +var SearchIcon = () => (0, import_react.createElement)("svg", { + viewBox: "0 0 24 24", + width: 14, + height: 14, + fill: "none", + stroke: "currentColor", + strokeWidth: 2, + strokeLinecap: "round", + "aria-hidden": "true" +}, (0, import_react.createElement)("circle", { cx: 11, cy: 11, r: 8 }), (0, import_react.createElement)("path", { d: "m21 21-4.3-4.3" })); +var ChevronDown = (open) => (0, import_react.createElement)("svg", { + viewBox: "0 0 24 24", + width: 14, + height: 14, + fill: "none", + stroke: "currentColor", + strokeWidth: 2, + strokeLinecap: "round", + strokeLinejoin: "round", + "aria-hidden": "true", + style: { transform: open ? "rotate(180deg)" : "none", transition: "transform 150ms ease" } +}, (0, import_react.createElement)("path", { d: "m6 9 6 6 6-6" })); function pad2(n) { return String(n).padStart(2, "0"); } -function clockText(ts) { - const n = Number(ts); - if (!Number.isFinite(n) || n <= 0) return "—"; - const d = new Date(n); - return pad2(d.getHours()) + ":" + pad2(d.getMinutes()); -} function dateText(ts) { const n = Number(ts); if (!Number.isFinite(n) || n <= 0) return "—"; const d = new Date(n); - return d.getMonth() + 1 + "-" + pad2(d.getDate()) + " " + clockText(n); + return d.getMonth() + 1 + "-" + pad2(d.getDate()) + " " + pad2(d.getHours()) + ":" + pad2(d.getMinutes()); } function durationText(ms) { const n = Number(ms); if (!Number.isFinite(n) || n <= 0) return "—"; - const total = Math.round(n / 1e3); - const sec = total % 60; - const min = Math.floor(total / 60) % 60; - const hour = Math.floor(total / 3600); - if (hour > 0) return hour + "h " + min + "m"; - if (min > 0) return min + "m " + pad2(sec) + "s"; - return sec + "s"; -} -function dateLabel() { - try { - return new Intl.DateTimeFormat("zh-CN", { weekday: "long", year: "numeric", month: "long", day: "numeric" }).format(/* @__PURE__ */ new Date()); - } catch { - return ""; - } + const s = Math.round(n / 1e3); + const m = Math.floor(s / 60) % 60; + const hr = Math.floor(s / 3600); + if (hr > 0) return hr + "h " + m + "m"; + if (m > 0) return m + "m " + pad2(s % 60) + "s"; + return s + "s"; } function taskDurationMs(task) { if (!task) return 0; - const start = Number(task.dispatchedAt || task.createdAt || 0); + const st = Number(task.dispatchedAt || task.createdAt || 0); const end = task.resultAt ? Number(task.resultAt) : Date.now(); - if (!Number.isFinite(start) || !Number.isFinite(end) || start <= 0 || end <= start) return 0; - return end - start; + if (!Number.isFinite(st) || !Number.isFinite(end) || st <= 0 || end <= st) return 0; + return end - st; } function shortText(text, max) { - const value = String(text || "").replace(/\s+/g, " ").trim(); - if (!value) return ""; - return value.length > max ? value.slice(0, max - 1) + "…" : value; + const val = String(text || "").replace(/\s+/g, " ").trim(); + if (!val) return ""; + return val.length > max ? val.slice(0, max - 1) + "…" : val; } -function splitResultText(text) { - const clean = String(text || "").replace(/\r/g, "").trim(); - if (!clean) return { summary: "", points: [], hasMore: false }; - const lines = clean.split("\n").map((line) => line.trim()).filter(Boolean); - const first = lines[0] || ""; - let summary = first.replace(/^#{1,6}\s*/, ""); - let rest = lines.slice(1); - if (/[。!?!?]/.test(first)) { - const sentences = first.split(/(?<=[。!?!?])/).map((item) => item.trim()).filter(Boolean); - if (sentences.length > 0) { - summary = sentences[0]; - rest = [...sentences.slice(1), ...lines.slice(1)]; - } - } - if (summary.length > 120) summary = summary.slice(0, 119) + "…"; - const bullets = rest.filter((line) => /^([-*•]\s+|\d+[.)、]\s+|[一二三四五六七八九十]+、)/.test(line)).map((line) => line.replace(/^([-*•]\s+|\d+[.)、]\s+|[一二三四五六七八九十]+、)/, "").trim()).filter(Boolean); - const source = bullets.length > 0 ? bullets : rest.flatMap((line) => line.split(/(?<=[。!?!?])/).map((item) => item.trim()).filter(Boolean)); - const points = source.slice(0, 3).map((item) => shortText(item, 90)); - const covered = summary.length + points.join("").length; - return { summary, points, hasMore: clean.length > covered + 12 }; +function refreshList(value, prev, projectChanged = false) { + if (Array.isArray(value)) return value; + return projectChanged ? [] : prev; } -function renderRichText(text) { - const lines = String(text || "").replace(/\r/g, "").split("\n"); - const blocks = []; - let list = []; - let code = null; - const flushList = () => { - if (list.length === 0) return; - blocks.push((0, import_react.createElement)("ul", { className: "rs-list", key: "list-" + blocks.length }, list.map((item, index) => (0, import_react.createElement)("li", { key: index }, item)))); - list = []; - }; - lines.forEach((line) => { - const value = line.trim(); - if (value.startsWith("```")) { - flushList(); - if (code === null) code = []; - else { - blocks.push((0, import_react.createElement)("pre", { className: "rs-code", key: "code-" + blocks.length }, (0, import_react.createElement)("code", null, code.join("\n")))); - code = null; - } - return; - } - if (code !== null) { - code.push(line); - return; - } - if (!value) { - flushList(); - return; - } - if (/^#{1,6}\s+/.test(value)) { - flushList(); - blocks.push((0, import_react.createElement)("h4", { className: "rs-heading", key: "h-" + blocks.length }, value.replace(/^#{1,6}\s+/, ""))); - return; - } - if (/^([-*•]\s+|\d+[.)、]\s+|[一二三四五六七八九十]+、)/.test(value)) { - list.push(value.replace(/^([-*•]\s+|\d+[.)、]\s+|[一二三四五六七八九十]+、)/, "")); - return; - } - flushList(); - if (/^(?:[A-Za-z]:[\\/]|\/|\.{0,2}\/|[\w.-]+[\\/])/.test(value) && !/\s{2,}/.test(value) && value.length <= 260) { - blocks.push((0, import_react.createElement)("code", { className: "rs-path", key: "p-" + blocks.length }, value)); - } else { - blocks.push((0, import_react.createElement)("p", { className: "rs-para", key: "p-" + blocks.length }, value)); - } - }); - flushList(); - if (code !== null) blocks.push((0, import_react.createElement)("pre", { className: "rs-code", key: "code-" + blocks.length }, (0, import_react.createElement)("code", null, code.join("\n")))); - return blocks; -} -function SummaryBlock(props) { - const text = String(props && props.text ? props.text : "").trim(); - const label = props && props.label ? props.label : "摘要"; - const empty = props && props.empty ? props.empty : "(暂无内容)"; - const max = props && props.max ? props.max : 120; - return (0, import_react.createElement)( - "div", - { className: "card-summary" + (text ? "" : " is-empty") }, - label ? (0, import_react.createElement)("span", { className: "t-label" }, label) : null, - (0, import_react.createElement)("p", { className: "card-summary-text" }, text ? shortText(text, max) : empty) - ); -} -function fileIcon(paths, size) { - return (0, import_react.createElement)( - "svg", - { viewBox: "0 0 24 24", width: size || 16, height: size || 16, fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, - paths.map((d, i) => (0, import_react.createElement)("path", { key: i, d })) - ); -} -var RefreshIcon = () => fileIcon(["M21 12a9 9 0 1 1-2.64-6.36", "M21 3v6h-6"]); -var ChatIcon = () => fileIcon(["M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"]); -var PlusIcon = () => fileIcon(["M12 5v14", "M5 12h14"]); -var SearchIcon = () => (0, import_react.createElement)("svg", { viewBox: "0 0 24 24", width: 15, height: 15, fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", "aria-hidden": "true" }, (0, import_react.createElement)("circle", { cx: 11, cy: 11, r: 8 }), (0, import_react.createElement)("path", { d: "m21 21-4.3-4.3" })); -var ArrowIcon = () => fileIcon(["m9 18 6-6-6-6"], 15); -var BookIcon = () => fileIcon(["M4 19.5A2.5 2.5 0 0 1 6.5 17H20", "M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"], 15); -var SlidersIcon = () => fileIcon(["M4 21v-7", "M4 10V3", "M12 21v-9", "M12 8V3", "M20 21v-5", "M20 12V3", "M2 14h4", "M10 8h4", "M18 16h4"], 15); function seatKind(id) { if (id === "lead") return "总协调"; if (id === "zhongshu") return "方案"; @@ -635,53 +860,63 @@ function seatKind(id) { if (id === "shangshu") return "调度"; return "工作"; } -function seatRecordOf(view, id) { - const seats = view && view.project ? view.project.seats : null; - if (Array.isArray(seats)) return seats.find((seat) => seat && seat.id === id) || null; - if (seats && typeof seats === "object") return seats[id] || null; - return null; +function seatTone(seat) { + if (!seat) return "muted"; + if (seat.status === "missing" || seat.status === "failed" || seat.modelSyncStatus === "failed") return "error"; + if (seat.approvalState === "waiting") return "error"; + if (seat.runtimeState === "running" || seat.status === "creating") return "success"; + return "muted"; } -function fmtModel(rec, options) { - const model = rec ? rec.configuredModel ?? rec.model : null; - const described = describeModel(model, options); - return described.modelLabel; +function seatStatusText(seat) { + if (!seat) return "待命"; + if (seat.status === "missing") return "会话缺失"; + if (seat.status === "failed") return "创建失败"; + if (seat.modelSyncStatus === "failed") return "同步失败"; + if (seat.approvalState === "waiting") return "等待审批"; + if (seat.runtimeLabel) return seat.runtimeLabel; + if (seat.status === "bound") return "待命"; + if (seat.status === "creating") return "开启中"; + return "未开启"; } -var DELIB_SEATS = ["zhongshu", "menxia", "shangshu"]; -var AVATAR_MIME = ["image/png", "image/jpeg", "image/webp"]; -var AVATAR_MAX_BYTES = 120 * 1024; -function seatTone(seatId) { - return seatId === "zhongshu" ? "#4c6ef5" : seatId === "menxia" ? "#12b886" : seatId === "shangshu" ? "#e8590c" : "#868e96"; +function seatChartVar(seatId) { + return seatId === "zhongshu" ? "--ss-chart-1" : seatId === "menxia" ? "--ss-chart-2" : "--ss-chart-3"; } -function avatarNode(seatId, avatars, size = 34, highlight = false) { +function seatDotTone(seatId) { + return seatId === "zhongshu" ? "chart-1" : seatId === "menxia" ? "chart-2" : "chart-3"; +} +function avatarNode(seatId, avatars, size = 32, activeRing = false) { const custom = avatars?.[seatId]; - const ring = highlight ? { boxShadow: "0 0 0 2px " + seatTone(seatId), borderRadius: "50%" } : {}; - if (custom?.type === "image") { + const colorVar = seatChartVar(seatId); + const ring = activeRing ? { boxShadow: "0 0 0 2px var(" + colorVar + ")" } : {}; + if (custom?.type === "image" && custom.dataUrl) { return (0, import_react.createElement)("img", { src: custom.dataUrl, - alt: (SEATS[seatId]?.name ?? seatId) + "头像", + alt: (SEATS[seatId]?.label ?? seatId) + "头像", width: size, height: size, style: { width: size, height: size, borderRadius: "50%", objectFit: "cover", flex: "0 0 auto", ...ring } }); } - const text = custom?.type === "char" ? custom.char : (SEATS[seatId]?.name ?? seatId).slice(0, 1); + const ch = custom?.type === "char" ? custom.char : (SEATS[seatId]?.label ?? seatId).slice(0, 1); return (0, import_react.createElement)("span", { "aria-hidden": "true", + className: "font-seal", style: { width: size, height: size, borderRadius: "50%", - background: seatTone(seatId), - color: "#fff", + background: "color-mix(in srgb, var(" + colorVar + ") 14%, var(--ss-card))", + border: "1px solid var(" + colorVar + ")", + color: "var(" + colorVar + ")", display: "inline-flex", alignItems: "center", justifyContent: "center", flex: "0 0 auto", fontSize: Math.max(12, Math.round(size * 0.42)), - fontWeight: 600, + fontWeight: 700, ...ring } - }, text); + }, ch); } async function shrinkAvatar(file) { if (!file || !AVATAR_MIME.includes(file.type)) throw new Error("头像只支持 PNG、JPEG 或 WebP 图片"); @@ -693,11 +928,11 @@ async function shrinkAvatar(file) { canvas.height = side; const ctx2d = canvas.getContext("2d"); const scale = Math.max(side / bitmap.width, side / bitmap.height); - const width = Math.max(1, Math.round(bitmap.width * scale)); - const height = Math.max(1, Math.round(bitmap.height * scale)); - ctx2d.drawImage(bitmap, Math.round((side - width) / 2), Math.round((side - height) / 2), width, height); - for (const quality of [0.9, 0.8, 0.7, 0.6, 0.5]) { - const dataUrl = canvas.toDataURL("image/jpeg", quality); + const w = Math.max(1, Math.round(bitmap.width * scale)); + const ht = Math.max(1, Math.round(bitmap.height * scale)); + ctx2d.drawImage(bitmap, Math.round((side - w) / 2), Math.round((side - ht) / 2), w, ht); + for (const q of [0.9, 0.8, 0.7, 0.6, 0.5]) { + const dataUrl = canvas.toDataURL("image/jpeg", q); if (Math.floor((dataUrl.length - dataUrl.indexOf(",") - 1) * 3 / 4) <= AVATAR_MAX_BYTES) return dataUrl; } throw new Error("图片压缩后仍超过 120KB,请换一张更简单的图片"); @@ -707,7 +942,6 @@ async function shrinkAvatar(file) { } function WorkbenchV2(props) { const { - onClose, sessionId, resolveWorkspace, navigateToSession, @@ -726,40 +960,36 @@ function WorkbenchV2(props) { const saved = typeof getLastSeatId === "function" ? getLastSeatId() : null; return SEAT_IDS.includes(saved) ? saved : SEAT_IDS[0]; }); - const [tab, setTab] = (0, import_react.useState)("overview"); + const [tab, setTab] = (0, import_react.useState)("court"); + const [inspectorTab, setInspectorTab] = (0, import_react.useState)("overview"); + const [seatFilter, setSeatFilter] = (0, import_react.useState)("all"); + const [flowSubTab, setFlowSubTab] = (0, import_react.useState)("tasks"); const [queueSearch, setQueueSearch] = (0, import_react.useState)(""); - const [selectedTask, setSelectedTask] = (0, import_react.useState)(null); - const [reviewPanelOpen, setReviewPanelOpen] = (0, import_react.useState)(false); - const [durationPanelOpen, setDurationPanelOpen] = (0, import_react.useState)(false); - const [tokenPanelOpen, setTokenPanelOpen] = (0, import_react.useState)(false); - const [queuePanelOpen, setQueuePanelOpen] = (0, import_react.useState)(false); + const [expandedConfigSeatId, setExpandedConfigSeatId] = (0, import_react.useState)(null); const [draft, setDraft] = (0, import_react.useState)({}); const [busy, setBusy] = (0, import_react.useState)(false); const [summaryBusy, setSummaryBusy] = (0, import_react.useState)(false); const [memory, setMemory] = (0, import_react.useState)(null); + const [memoryEditing, setMemoryEditing] = (0, import_react.useState)(false); const [memoryDraft, setMemoryDraft] = (0, import_react.useState)({ goal: "", constraints: "", acceptance: "", decisions: "" }); const [tasks, setTasks] = (0, import_react.useState)([]); const [requirements, setRequirements] = (0, import_react.useState)([]); - const [approvals, setApprovals] = (0, import_react.useState)([]); const [pendingApprovals, setPendingApprovals] = (0, import_react.useState)([]); const [approvalStatus, setApprovalStatus] = (0, import_react.useState)(null); const [deliberations, setDeliberations] = (0, import_react.useState)([]); const [deliberation, setDeliberation] = (0, import_react.useState)(null); const [delibSelectedId, setDelibSelectedId] = (0, import_react.useState)(null); const [delibDraft, setDelibDraft] = (0, import_react.useState)({ topic: "", taskId: "", requirementId: "", maxRounds: "3" }); - const [delibEndNote, setDelibEndNote] = (0, import_react.useState)(""); - const [delibBusy, setDelibBusy] = (0, import_react.useState)(false); - const [page, setPage] = (0, import_react.useState)("overview"); const [delibSettingsOpen, setDelibSettingsOpen] = (0, import_react.useState)(false); + const [delibBusy, setDelibBusy] = (0, import_react.useState)(false); const [avatarEdit, setAvatarEdit] = (0, import_react.useState)(null); const [agentRuns, setAgentRuns] = (0, import_react.useState)([]); - const [reqView, setReqView] = (0, import_react.useState)("requirements"); const [artifacts, setArtifacts] = (0, import_react.useState)([]); const [artifactDraft, setArtifactDraft] = (0, import_react.useState)({ title: "", path: "", summary: "" }); - const [artifactFormOpen, setArtifactFormOpen] = (0, import_react.useState)(false); - const [orgCols, setOrgCols] = (0, import_react.useState)(6); + const [artifactModalOpen, setArtifactModalOpen] = (0, import_react.useState)(false); + const [durationModalOpen, setDurationModalOpen] = (0, import_react.useState)(false); + const [selectedTask, setSelectedTask] = (0, import_react.useState)(null); const alive = (0, import_react.useRef)(true); - const orgRef = (0, import_react.useRef)(null); const loadedProjectId = (0, import_react.useRef)(null); const taskAnswerVersion = (0, import_react.useRef)(0); (0, import_react.useEffect)(() => { @@ -787,8 +1017,7 @@ function WorkbenchV2(props) { let modelCatalog = null; try { modelCatalog = await request("models"); - } catch (modelError) { - console.warn("[sansheng] 模型目录加载失败:", modelError && modelError.message ? modelError.message : modelError); + } catch { } let memoryData = null; try { @@ -797,11 +1026,13 @@ function WorkbenchV2(props) { } const nextProjectId = projectView.project.id; const answerVersion = taskAnswerVersion.current; - const [taskRes, artifactRes, requirementData, approvalData] = await Promise.allSettled([ + const [taskRes, artifactRes, requirementRes, approvalRes, delibRes, agentRes] = await Promise.allSettled([ request("tasks", { projectId: nextProjectId }), request("artifacts", { projectId: nextProjectId }), request("requirements", { projectId: nextProjectId }), - request("approvals", { projectId: nextProjectId }) + request("approvals", { projectId: nextProjectId }), + request("deliberations", { projectId: nextProjectId }), + request("agents", { projectId: nextProjectId }) ]); if (!alive.current) return; const projectChanged = loadedProjectId.current !== nextProjectId; @@ -809,23 +1040,40 @@ function WorkbenchV2(props) { setView(projectView); setModels(modelCatalog); setMemory(memoryData); - setMemoryDraft({ goal: memoryData?.goal ?? "", constraints: (memoryData?.constraints ?? []).join("\n"), acceptance: (memoryData?.acceptance ?? []).join("\n"), decisions: "" }); + setMemoryDraft({ + goal: memoryData?.goal ?? "", + constraints: (memoryData?.constraints ?? []).join("\n"), + acceptance: (memoryData?.acceptance ?? []).join("\n"), + decisions: "" + }); if (projectChanged) { setSelectedTask(null); setDelibSelectedId(null); setDeliberation(null); - setDeliberations([]); + setMemoryEditing(false); + } + if (projectChanged || taskAnswerVersion.current === answerVersion) { + setTasks((prev) => refreshList(taskRes.value?.tasks, prev, projectChanged)); + } + setArtifacts((prev) => refreshList(artifactRes.value?.artifacts, prev, projectChanged)); + setRequirements((prev) => refreshList(requirementRes.value?.requirements, prev, projectChanged)); + setPendingApprovals((prev) => refreshList(approvalRes.value?.approvals, prev, projectChanged)); + setApprovalStatus(approvalRes.status === "fulfilled" ? approvalRes.value?.status ?? null : { available: false, degraded: true }); + const delibList = delibRes.status === "fulfilled" && Array.isArray(delibRes.value?.deliberations) ? delibRes.value.deliberations : []; + setDeliberations(delibList); + if (agentRes.status === "fulfilled" && Array.isArray(agentRes.value?.runs)) setAgentRuns(agentRes.value.runs); + const targetDelibId = delibList.find((x) => x.status === "running")?.id || delibList[0]?.id || null; + if (targetDelibId) { + try { + const full = await request("deliberation", { projectId: nextProjectId, deliberationId: targetDelibId }); + if (alive.current && loadedProjectId.current === nextProjectId) setDeliberation(full?.deliberation ?? null); + } catch { + } } - if (projectChanged || taskAnswerVersion.current === answerVersion) setTasks((previous) => refreshList(taskRes.value?.tasks, previous, projectChanged)); - setArtifacts((previous) => refreshList(artifactRes.value?.artifacts, previous, projectChanged)); - setRequirements((previous) => refreshList(requirementData.value?.requirements, previous, projectChanged)); - setApprovals((previous) => refreshList(requirementData.value?.approvals, previous, projectChanged)); - setPendingApprovals((previous) => refreshList(approvalData.value?.approvals, previous, projectChanged)); - setApprovalStatus(approvalData.status === "fulfilled" ? approvalData.value?.status ?? null : { available: false, degraded: true }); setPhase("ready"); } catch (loadError) { if (!alive.current) return; - setError(loadError && loadError.message ? loadError.message : "加载失败"); + setError(loadError?.message || "加载失败"); setErrorRetryable(!(loadError && loadError.retryable === false)); setPhase("error"); } @@ -833,50 +1081,8 @@ function WorkbenchV2(props) { (0, import_react.useEffect)(() => { void loadProject(); }, [loadProject]); - const projectId = view && view.project ? view.project.id : null; - (0, import_react.useEffect)(() => { - if (!projectId) return void 0; - let disposed = false; - let running = false; - let timer = null; - const tick = async () => { - if (disposed || running) return; - if (typeof document !== "undefined" && document.visibilityState === "hidden") return; - running = true; - try { - const answerVersion = taskAnswerVersion.current; - const [projectRes, taskRes, artifactRes, requirementData, approvalData] = await Promise.allSettled([ - request("project", { projectId }), - request("tasks", { projectId }), - request("artifacts", { projectId }), - request("requirements", { projectId }), - request("approvals", { projectId }) - ]); - if (disposed || !alive.current || loadedProjectId.current !== projectId) return; - if (projectRes.value) setView(projectRes.value); - if (taskAnswerVersion.current === answerVersion) setTasks((previous) => refreshList(taskRes.value?.tasks, previous)); - setArtifacts((previous) => refreshList(artifactRes.value?.artifacts, previous)); - setRequirements((previous) => refreshList(requirementData.value?.requirements, previous)); - setApprovals((previous) => refreshList(requirementData.value?.approvals, previous)); - setPendingApprovals((previous) => refreshList(approvalData.value?.approvals, previous)); - setApprovalStatus(approvalData.status === "fulfilled" ? approvalData.value?.status ?? null : { available: false, degraded: true }); - } finally { - running = false; - } - }; - timer = setInterval(tick, 4e3); - const onVisibility = () => { - if (document.visibilityState === "visible") void tick(); - }; - document.addEventListener("visibilitychange", onVisibility); - void tick(); - return () => { - disposed = true; - if (timer !== null) clearInterval(timer); - document.removeEventListener("visibilitychange", onVisibility); - }; - }, [projectId]); - async function refreshDeliberations() { + const projectId = view?.project?.id || null; + const refreshDeliberations = (0, import_react.useCallback)(async () => { if (!projectId) return; const [data, agentsData] = await Promise.allSettled([ request("deliberations", { projectId }), @@ -894,30 +1100,372 @@ function WorkbenchV2(props) { const full = await request("deliberation", { projectId, deliberationId: target }); if (!alive.current || loadedProjectId.current !== projectId) return; setDeliberation(full?.deliberation ?? null); - } + }, [projectId, delibSelectedId]); (0, import_react.useEffect)(() => { - if (page !== "deliberations" || !projectId) return void 0; + if (!projectId) return void 0; + let disposed = false; + let running = false; + const tick = async () => { + if (disposed || running) return; + if (typeof document !== "undefined" && document.visibilityState === "hidden") return; + running = true; + try { + const answerVer = taskAnswerVersion.current; + const [projectRes, taskRes, artifactRes, requirementRes, approvalRes] = await Promise.allSettled([ + request("project", { projectId }), + request("tasks", { projectId }), + request("artifacts", { projectId }), + request("requirements", { projectId }), + request("approvals", { projectId }) + ]); + if (disposed || !alive.current || loadedProjectId.current !== projectId) return; + if (projectRes.value) setView(projectRes.value); + if (taskAnswerVersion.current === answerVer) setTasks((prev) => refreshList(taskRes.value?.tasks, prev)); + setArtifacts((prev) => refreshList(artifactRes.value?.artifacts, prev)); + setRequirements((prev) => refreshList(requirementRes.value?.requirements, prev)); + setPendingApprovals((prev) => refreshList(approvalRes.value?.approvals, prev)); + setApprovalStatus(approvalRes.status === "fulfilled" ? approvalRes.value?.status ?? null : { available: false, degraded: true }); + } finally { + running = false; + } + }; + const timer = setInterval(() => { + void tick(); + }, 4e3); + const onVis = () => { + if (document.visibilityState === "visible") void tick(); + }; + if (typeof document !== "undefined") document.addEventListener("visibilitychange", onVis); + void tick(); + return () => { + disposed = true; + clearInterval(timer); + if (typeof document !== "undefined") document.removeEventListener("visibilitychange", onVis); + }; + }, [projectId]); + (0, import_react.useEffect)(() => { + if (tab !== "deliberation" || !projectId) return void 0; let disposed = false; let running = false; - let timer = null; const tick = async () => { if (disposed || running) return; running = true; try { await refreshDeliberations(); - } catch (error2) { - if (!disposed && alive.current) console.warn("[sansheng] 议政刷新失败:", error2?.message ?? error2); + } catch { } finally { running = false; } }; - timer = setInterval(tick, 1500); + const timer = setInterval(() => { + void tick(); + }, 1500); void tick(); return () => { disposed = true; - if (timer !== null) clearInterval(timer); + clearInterval(timer); }; - }, [page, projectId, delibSelectedId]); + }, [tab, projectId, refreshDeliberations]); + (0, import_react.useEffect)(() => { + if (!projectId || !selectionCache) return; + const saved = selectionCache.get(projectId); + if (saved && SEAT_IDS.includes(saved)) setSelectedSeatId(saved); + }, [projectId, selectionCache]); + const wb = buildWorkbenchView(view, { selectedSeatId, models, draft }); + const seatById = (0, import_react.useMemo)(() => { + const map = {}; + for (const seat of wb.seats) map[seat.id] = seat; + return map; + }, [wb.seats]); + const seatRecMap = (0, import_react.useMemo)(() => { + const raw = view?.project?.seats; + const map = {}; + if (Array.isArray(raw)) { + for (const s of raw) if (s?.id) map[s.id] = s; + } else if (raw && typeof raw === "object") { + for (const [k, s] of Object.entries(raw)) map[k] = { id: k, ...s }; + } + return map; + }, [view]); + const activeChatSeatId = (0, import_react.useMemo)(() => { + if (!sessionId) return null; + for (const sid of SEAT_IDS) { + if (seatRecMap[sid]?.sessionId === sessionId) return sid; + } + return null; + }, [seatRecMap, sessionId]); + const groupedChoices = (0, import_react.useMemo)(() => groupModelChoices(wb.selected.modelOptions), [wb.selected.modelOptions]); + function selectSeat(id) { + if (!id || id === selectedSeatId) return; + setSelectedSeatId(id); + if (typeof setLastSeatId === "function") setLastSeatId(id); + if (projectId && selectionCache) selectionCache.set(projectId, id); + } + function seatDraftState(seatId) { + const seatRec = seatRecMap[seatId] || {}; + const dEntry = draftOf(draft, seatId); + let modelValue2 = ""; + if (Object.prototype.hasOwnProperty.call(dEntry, "modelValue")) { + modelValue2 = String(dEntry.modelValue || ""); + } else if (Object.prototype.hasOwnProperty.call(dEntry, "model")) { + modelValue2 = describeModel(dEntry.model, wb.selected.modelOptions).modelValue; + } else { + modelValue2 = describeModel(seatRec.model ?? null, wb.selected.modelOptions).modelValue; + } + const parts = modelValue2.split("::"); + const modelKey = parts[0] && parts[1] ? parts[0] + "::" + parts[1] : ""; + const effort = parts[2] || ""; + const instructions = Object.prototype.hasOwnProperty.call(dEntry, "instructions") ? dEntry.instructions : typeof seatRec.instructions === "string" ? seatRec.instructions : ""; + return { modelKey, effort, modelValue: modelValue2, instructions }; + } + function updateSeatDraftModel(seatId, nextKey, nextEffort) { + const val = nextKey ? nextEffort ? nextKey + "::" + nextEffort : nextKey : ""; + setDraft((prev) => updateDraft(prev, seatId, { modelValue: val })); + } + async function saveSeatConfigFor(seatId) { + if (!projectId) return; + const { modelKey, effort, instructions } = seatDraftState(seatId); + const model = modelObjectFromParts(modelKey, effort); + if (!model) { + setNotice("请先为当前角色选择模型"); + return; + } + setBusy(true); + setError(null); + setNotice("保存中…"); + try { + await request("configure", { projectId, seatId, model, instructions }); + const next = await request("project", { projectId }); + if (!alive.current) return; + setView(next); + setDraft((prev) => clearDraft(prev, seatId)); + setNotice("已保存「" + (SEATS[seatId]?.label || seatId) + "」配置"); + } catch (err) { + if (alive.current) setError(err?.message || "保存失败"); + } finally { + if (alive.current) setBusy(false); + } + } + async function setGlobalDefaultFor(seatId) { + if (!projectId) return; + const { modelKey, effort } = seatDraftState(seatId); + const configured = seatRecMap[seatId]?.configuredModel ?? seatRecMap[seatId]?.model ?? null; + const model = modelObjectFromParts(modelKey, effort) || configured; + if (!model) { + setNotice("请先为当前角色选择模型"); + return; + } + setBusy(true); + setError(null); + try { + const res = await request("setGlobalDefault", { seatId, model }); + const next = await request("project", { projectId }); + if (!alive.current) return; + setView(next); + setNotice("已将「" + (SEATS[seatId]?.label || seatId) + "」设为全局默认;已同步 " + (res.applied || []).length + " 个项目"); + } catch (err) { + if (alive.current) setError(err?.message || "设置全局默认失败"); + } finally { + if (alive.current) setBusy(false); + } + } + async function clearOverrideFor(seatId) { + if (!projectId) return; + setBusy(true); + setError(null); + try { + await request("configure", { projectId, seatId, model: null }); + const next = await request("project", { projectId }); + if (!alive.current) return; + setView(next); + setDraft((prev) => clearDraft(prev, seatId)); + setNotice("「" + (SEATS[seatId]?.label || seatId) + "」已恢复继承全局默认"); + } catch (err) { + if (alive.current) setError(err?.message || "恢复继承失败"); + } finally { + if (alive.current) setBusy(false); + } + } + async function retrySyncFor(seatId) { + if (!projectId) return; + setBusy(true); + setError(null); + try { + const res = await request("retrySeatModel", { projectId, seatId }); + const next = await request("project", { projectId }); + if (!alive.current) return; + setView(next); + setNotice("模型同步状态:" + (res.sync?.status ?? "unknown")); + } catch (err) { + if (alive.current) setError(err?.message || "重试同步失败"); + } finally { + if (alive.current) setBusy(false); + } + } + async function openSeat(seatId) { + const seat = seatById[seatId]; + if (!projectId || !seat) return; + if (seat.status === "missing") { + setNotice("「" + seat.name + "」的会话已缺失,点击「重建会话」可恢复"); + return; + } + if (seat.status !== "bound") { + setNotice("「" + seat.name + "」尚未开启,请先点击开启"); + return; + } + setBusy(true); + setError(null); + try { + const res = await request("openSeat", { projectId, seatId }); + if (!alive.current) return; + if (!res?.sessionId) throw new Error("宿主没有返回会话"); + navigateToSession?.(res.sessionId); + setNotice("已切换到「" + seat.name + "」原生会话"); + } catch (err) { + if (alive.current) setError(err?.message || "打开会话失败"); + if (err?.code === "sansheng/session-missing") { + try { + const next = await request("project", { projectId }); + if (alive.current) setView(next); + } catch { + } + } + } finally { + if (alive.current) setBusy(false); + } + } + async function enableSeat(seatId) { + if (!projectId) return; + const seat = seatById[seatId]; + setBusy(true); + setError(null); + setNotice("正在开启「" + (seat?.name || seatId) + "」…"); + try { + const next = await request("enableSeat", { projectId, seatId }); + if (!alive.current) return; + setView(next); + setNotice("已按需开启「" + (seat?.name || seatId) + "」独立会话"); + try { + if (typeof openRightTab === "function") openRightTab(); + } catch { + } + } catch (err) { + if (alive.current) setError(err?.message || "开启失败"); + } finally { + if (alive.current) setBusy(false); + } + } + async function rebuildSeat(seatId) { + const seat = seatById[seatId]; + if (!projectId || !seat) return; + const rec = seatRecMap[seatId]; + setBusy(true); + setError(null); + setNotice("正在重建「" + seat.name + "」会话…"); + try { + const next = await request("rebuildSeat", { + projectId, + seatId, + expectedSessionId: rec?.sessionId || void 0 + }); + if (!alive.current) return; + setView(next); + setNotice("已重建「" + seat.name + "」会话(旧历史保留)"); + } catch (err) { + if (alive.current) setError(err?.message || "重建失败"); + } finally { + if (alive.current) setBusy(false); + } + } + async function answerApproval(entry, choice) { + if (!projectId || !entry || busy) return; + setBusy(true); + setError(null); + try { + await request("approvalAnswer", { + projectId, + seatId: entry.seatId, + id: entry.id, + sessionId: entry.sessionId, + choice + }); + const data = await request("approvals", { projectId }); + if (!alive.current || loadedProjectId.current !== projectId) return; + setPendingApprovals((prev) => refreshList(data?.approvals, prev)); + setApprovalStatus(data?.status ?? null); + setNotice(choice === "allow" ? "已允许审批" : "已拒绝审批"); + } catch (err) { + if (alive.current) setError(err?.message || "审批应答失败"); + } finally { + if (alive.current) setBusy(false); + } + } + async function answerDecision(taskId, decisionId, value) { + if (!projectId || busy) return; + setBusy(true); + setError(null); + try { + await request("taskDecisionAnswer", { projectId, taskId, decisionId, value }); + if (!alive.current || loadedProjectId.current !== projectId) return; + taskAnswerVersion.current += 1; + setTasks((prev) => prev.map((t) => t.id === taskId && Array.isArray(t.decisions) ? { ...t, decisions: t.decisions.map((d) => d.id === decisionId ? { ...d, status: "answered", answer: value } : d) } : t)); + setNotice("已提交项目决定"); + } catch (err) { + if (alive.current && loadedProjectId.current === projectId) setError(err?.message || "项目决定提交失败"); + } finally { + if (alive.current) setBusy(false); + } + } + async function redispatchTask(task) { + if (!projectId || !task?.deliveryId || busy) return; + setBusy(true); + setError(null); + try { + const res = await request("taskRedispatch", { + projectId, + taskId: task.id, + expectedDeliveryId: task.deliveryId + }); + const nextTasks = await request("tasks", { projectId }); + if (!alive.current || loadedProjectId.current !== projectId) return; + setTasks((prev) => refreshList(nextTasks?.tasks, prev)); + const updated = nextTasks?.tasks?.find((x) => x.id === task.id); + if (updated) setSelectedTask(updated); + setNotice(res?.delivery?.status === "sent" ? "已显式重投此任务并送达席位会话" : "重投状态:" + (res?.delivery?.reason || res?.delivery?.status || "已处理")); + } catch (err) { + if (alive.current) setError(err?.message || "显式重投失败"); + } finally { + if (alive.current) setBusy(false); + } + } + async function summarizeByShangshu() { + if (!projectId || summaryBusy || busy) return; + setSummaryBusy(true); + setError(null); + try { + const res = await request("shangshuSummary", { projectId }); + if (!alive.current) return; + if (!res?.sessionId) throw new Error("宿主未返回尚书会话"); + setNotice("已请尚书汇总当前项目进度,正在前往尚书会话"); + navigateToSession?.(res.sessionId); + } catch (err) { + if (alive.current) setError(err?.message || "尚书汇总请求失败"); + } finally { + if (alive.current) setSummaryBusy(false); + } + } + async function reloadTasks() { + if (!projectId) return; + try { + const res = await request("tasks", { projectId }); + if (alive.current && loadedProjectId.current === projectId) { + setTasks((prev) => refreshList(res?.tasks, prev)); + setNotice("已同步最新派工队列"); + } + } catch (err) { + if (alive.current) setNotice(err?.message || "刷新失败"); + } + } async function startDeliberation() { if (!projectId || delibBusy) return; const topic = String(delibDraft.topic || "").trim(); @@ -940,62 +1488,61 @@ function WorkbenchV2(props) { if (!alive.current || loadedProjectId.current !== projectId) return; setDelibSelectedId(data.deliberation.id); setDeliberation(data.deliberation); - setDelibDraft((previous) => ({ ...previous, topic: "" })); + setDelibDraft((prev) => ({ ...prev, topic: "" })); setNotice(data.receipt?.text || "议政已发起,已叫中书。"); - } catch (error2) { - if (alive.current) setError(error2 && error2.message ? error2.message : "议政发起失败"); + await refreshDeliberations(); + } catch (err) { + if (alive.current) setError(err?.message || "发起议政失败"); } finally { if (alive.current) setDelibBusy(false); } } async function endDeliberation() { - const deliberationId = delibSelectedId || deliberations.find((item) => item.status === "running")?.id; - if (!projectId || !deliberationId || delibBusy) return; + const did = delibSelectedId || deliberations.find((item) => item.status === "running")?.id; + if (!projectId || !did || delibBusy) return; setDelibBusy(true); setError(null); try { - await request("deliberationEnd", { projectId, deliberationId, note: delibEndNote.trim() || void 0 }); - if (!alive.current || loadedProjectId.current !== projectId) return; - setDelibEndNote(""); - setNotice("议政已结束,结论已记录。"); + await request("deliberationEnd", { projectId, deliberationId: did }); + if (!alive.current) return; + setNotice("议政已收束结论"); await refreshDeliberations(); - } catch (error2) { - if (alive.current) setError(error2 && error2.message ? error2.message : "结束议政失败"); + } catch (err) { + if (alive.current) setError(err?.message || "收束议政失败"); } finally { if (alive.current) setDelibBusy(false); } } async function stopDeliberation() { - const deliberationId = delibSelectedId || deliberations.find((item) => item.status === "running")?.id; - if (!projectId || !deliberationId || delibBusy) return; + const did = delibSelectedId || deliberations.find((item) => item.status === "running")?.id; + if (!projectId || !did || delibBusy) return; setDelibBusy(true); setError(null); try { - const data = await request("deliberationStop", { projectId, deliberationId, note: delibEndNote.trim() || void 0 }); - if (!alive.current || loadedProjectId.current !== projectId) return; - setDelibEndNote(""); - setNotice(data.receipt?.text || "议政已停止。"); + const data = await request("deliberationStop", { projectId, deliberationId: did }); + if (!alive.current) return; setDeliberation(data.deliberation); + setNotice(data.receipt?.text || "已停止当前议政"); await refreshDeliberations(); - } catch (error2) { - if (alive.current) setError(error2 && error2.message ? error2.message : "停止议政失败"); + } catch (err) { + if (alive.current) setError(err?.message || "停止议政失败"); } finally { if (alive.current) setDelibBusy(false); } } async function retryDeliberation() { - const deliberationId = delibSelectedId || deliberations.find((item) => item.status === "running")?.id; - if (!projectId || !deliberationId || delibBusy) return; + const did = delibSelectedId || deliberations.find((item) => item.status === "running")?.id; + if (!projectId || !did || delibBusy) return; setDelibBusy(true); setError(null); try { - const data = await request("deliberationRetry", { projectId, deliberationId }); - if (!alive.current || loadedProjectId.current !== projectId) return; + const data = await request("deliberationRetry", { projectId, deliberationId: did }); + if (!alive.current) return; setDeliberation(data.deliberation); - setNotice(data.delivery?.ok ? "已重试当前席位。" : "重试没有成功,页面会保留当前状态。"); + setNotice(data.delivery?.ok ? "已重试当前席位" : "重试未能送达,请查看席位会话"); await refreshDeliberations(); - } catch (error2) { - if (alive.current) setError(error2 && error2.message ? error2.message : "重试议政失败"); + } catch (err) { + if (alive.current) setError(err?.message || "重试席位失败"); } finally { if (alive.current) setDelibBusy(false); } @@ -1007,17 +1554,17 @@ function WorkbenchV2(props) { try { const data = payload.clear ? await request("clearAvatar", { projectId, seatId }) : await request("setAvatar", { projectId, seatId, ...payload }); if (!alive.current || loadedProjectId.current !== projectId) return; - setView((previous) => { - if (!previous?.project) return previous; - const avatars = { ...previous.project.avatars ?? {} }; + setView((prev) => { + if (!prev?.project) return prev; + const avatars = { ...prev.project.avatars ?? {} }; if (data.avatar) avatars[seatId] = data.avatar; else delete avatars[seatId]; - return { ...previous, project: { ...previous.project, avatars } }; + return { ...prev, project: { ...prev.project, avatars } }; }); setAvatarEdit(null); - setNotice(data.avatar ? "头像已更新。" : "头像已恢复默认。"); - } catch (error2) { - if (alive.current) setError(error2 && error2.message ? error2.message : "保存头像失败"); + setNotice(data.avatar ? "头像已更新" : "已恢复默认头像"); + } catch (err) { + if (alive.current) setError(err?.message || "头像更新失败"); } finally { if (alive.current) setDelibBusy(false); } @@ -1026,8 +1573,8 @@ function WorkbenchV2(props) { try { const dataUrl = await shrinkAvatar(file); await saveAvatar(seatId, { dataUrl }); - } catch (error2) { - if (alive.current) setError(error2 && error2.message ? error2.message : "图片处理失败"); + } catch (err) { + if (alive.current) setError(err?.message || "图片处理失败"); } } async function stopAgentRun(run) { @@ -1036,246 +1583,21 @@ function WorkbenchV2(props) { setError(null); try { await request("agentStop", { projectId, runId: run.id, kind: run.kind }); - if (!alive.current || loadedProjectId.current !== projectId) return; - setNotice("已停止「" + (run.label || run.seatId || "后台子 Agent") + "」,不会再产生新动作。"); + if (!alive.current) return; + setNotice("已停止后台子 Agent「" + (run.label || run.seatId) + "」"); await refreshDeliberations(); - } catch (error2) { - if (alive.current) setError(error2 && error2.message ? error2.message : "停止失败"); + } catch (err) { + if (alive.current) setError(err?.message || "停止失败"); } finally { if (alive.current) setDelibBusy(false); } } - (0, import_react.useEffect)(() => { - if (!projectId || !selectionCache) return; - const saved = selectionCache.get(projectId); - if (saved && SEAT_IDS.includes(saved)) setSelectedSeatId(saved); - }, [projectId, selectionCache]); - const wb = buildWorkbenchView(view, { selectedSeatId, models, draft }); - const seatById = (0, import_react.useMemo)(() => { - const map = {}; - for (const seat of wb.seats) map[seat.id] = seat; - return map; - }, [wb.seats]); - (0, import_react.useEffect)(() => { - const node = orgRef.current; - if (!node || typeof ResizeObserver === "undefined") return void 0; - const sync = () => { - const w = node.clientWidth || 0; - setOrgCols(w <= 700 ? 2 : w <= 1180 ? 3 : 6); - }; - sync(); - const observer = new ResizeObserver(sync); - observer.observe(node); - return () => observer.disconnect(); - }, [phase, tab]); - function setSeat(id) { - if (!id || id === selectedSeatId) return; - setSelectedSeatId(id); - if (typeof setLastSeatId === "function") setLastSeatId(id); - if (projectId && selectionCache) selectionCache.set(projectId, id); - } - function setModelValue(value) { - setDraft((prev) => updateDraft(prev, selectedSeatId, { modelValue: value })); - void rememberModel(value, selectedSeatId); - } - function setInstructions(value) { - setDraft((prev) => updateDraft(prev, selectedSeatId, { instructions: value })); - } - function modelFromValue(value) { - const option = findModelOption(wb.selected.modelOptions, value); - if (option) { - return option.reasoningEffort ? { provider: option.provider, model: option.model, reasoningEffort: option.reasoningEffort } : { provider: option.provider, model: option.model }; - } - const parts = String(value || "").split("::"); - if (parts.length >= 2 && parts[0] && parts[1]) { - return parts[2] ? { provider: parts[0], model: parts[1], reasoningEffort: parts[2] } : { provider: parts[0], model: parts[1] }; - } - return null; - } - async function rememberModel(value, seatId) { - if (!projectId || !value || !seatId) return; - const model = modelFromValue(value); - if (!model) return; - try { - const saved = await request("configure", { projectId, seatId, model }); - if (!alive.current) return; - setView((prev) => { - if (!prev || !prev.project) return prev; - const seats = Array.isArray(prev.project.seats) ? prev.project.seats.map((seat) => seat && seat.id === seatId ? { ...seat, ...saved && saved.seat ? saved.seat : { model } } : seat) : prev.project.seats; - return { ...prev, revision: (prev.revision ?? 0) + 1, project: { ...prev.project, seats } }; - }); - setNotice("已记住「" + (SEATS[seatId]?.label ?? seatId) + "」的模型"); - } catch (error2) { - if (alive.current) setNotice(error2 && error2.message ? error2.message : "模型记忆失败"); - } - } - async function openSeat(seatId) { - const seat = seatById[seatId]; - if (!projectId || !seat) return; - if (seat.status === "missing") { - setNotice("「" + seat.name + "」的会话已不存在,点「重建会话」可重新建立"); - return; - } - if (seat.status !== "bound") { - setNotice("「" + seat.name + "」还没开启,先点「开启『" + seat.name + "』」"); - return; - } - setBusy(true); - setError(null); - try { - const result = await request("openSeat", { projectId, seatId }); - if (!alive.current) return; - if (!result || !result.sessionId) throw new Error("宿主没有返回会话"); - navigateToSession(result.sessionId); - setNotice("已切换到「" + seat.name + "」会话"); - } catch (openError) { - if (alive.current) setError(openError && openError.message ? openError.message : "打开会话失败"); - if (openError && openError.code === "sansheng/session-missing") { - try { - const next = await request("project", { projectId }); - if (alive.current) setView(next); - } catch { - } - } - } finally { - if (alive.current) setBusy(false); - } - } - async function rebuildSeat(seatId) { - const seat = seatById[seatId]; - if (!projectId || !seat) return; - const rec = seatRecordOf(view, seatId); - setBusy(true); - setError(null); - setNotice("正在重建「" + seat.name + "」的会话…"); - try { - const next = await request("rebuildSeat", { projectId, seatId, expectedSessionId: rec && rec.sessionId ? rec.sessionId : void 0 }); - if (!alive.current) return; - setView(next); - setNotice("已重建「" + seat.name + "」的会话;旧会话历史仍保留"); - } catch (rebuildError) { - if (alive.current) setError(rebuildError && rebuildError.message ? rebuildError.message : "重建会话失败"); - if (rebuildError && rebuildError.code === "sansheng/session-conflict") { - try { - const next = await request("project", { projectId }); - if (alive.current) setView(next); - } catch { - } - } - } finally { - if (alive.current) setBusy(false); - } - } - async function enableSeat(seatId) { - if (!projectId) return; - const seat = seatById[seatId]; - setBusy(true); - setError(null); - setNotice("正在开启「" + (seat ? seat.name : seatId) + "」…"); - try { - const next = await request("enableSeat", { projectId, seatId }); - if (!alive.current) return; - setView(next); - setNotice("已开启「" + (seat ? seat.name : seatId) + "」的独立会话"); - try { - if (typeof openRightTab === "function") openRightTab(); - } catch { - } - } catch (enableError) { - if (alive.current) setError(enableError && enableError.message ? enableError.message : "开启失败"); - } finally { - if (alive.current) setBusy(false); - } - } - async function saveConfig() { - if (!projectId) return; - const seatId = wb.selected.id; - const value = wb.selected.modelValue; - if (!value) { - setNotice("请先为当前角色选择模型"); - return; - } - const model = modelFromValue(value); - setBusy(true); - setError(null); - setNotice("保存中…"); - try { - await request("configure", { projectId, seatId, model, instructions: wb.selected.instructions }); - const next = await request("project", { projectId }); - if (!alive.current) return; - setView(next); - setDraft((prev) => clearDraft(prev, seatId)); - setNotice("已保存"); - } catch (saveError) { - if (alive.current) setError(saveError && saveError.message ? saveError.message : "保存失败"); - } finally { - if (alive.current) setBusy(false); - } - } - async function setGlobalDefaultForSeat() { - if (!projectId) return; - const seatId = wb.selected.id; - const model = modelFromValue(wb.selected.modelValue); - if (!model) { - setNotice("请先为当前角色选择模型"); - return; - } - if (typeof window !== "undefined" && typeof window.confirm === "function" && !window.confirm("把「" + wb.selected.name + "」当前模型设为全局默认?其他未覆盖的项目会继承。")) return; - setBusy(true); - setError(null); - try { - const result = await request("setGlobalDefault", { seatId, model }); - const next = await request("project", { projectId }); - if (!alive.current) return; - setView(next); - setNotice("已设为全局默认;继承项目已同步 " + (result.applied || []).length + " 个"); - } catch (error2) { - if (alive.current) setError(error2 && error2.message ? error2.message : "设置全局默认失败"); - } finally { - if (alive.current) setBusy(false); - } - } - async function clearSeatOverride() { - if (!projectId) return; - const seatId = wb.selected.id; - setBusy(true); - setError(null); - try { - await request("configure", { projectId, seatId, model: null }); - const next = await request("project", { projectId }); - if (!alive.current) return; - setView(next); - setDraft((prev) => clearDraft(prev, seatId)); - setNotice("已恢复继承全局默认"); - } catch (error2) { - if (alive.current) setError(error2 && error2.message ? error2.message : "恢复继承失败"); - } finally { - if (alive.current) setBusy(false); - } - } - async function retryModelSync() { - if (!projectId) return; - setBusy(true); - setError(null); - try { - const result = await request("retrySeatModel", { projectId, seatId: wb.selected.id }); - const next = await request("project", { projectId }); - if (!alive.current) return; - setView(next); - setNotice("模型同步:" + (result.sync?.status ?? "unknown")); - } catch (error2) { - if (alive.current) setError(error2 && error2.message ? error2.message : "重试同步失败"); - } finally { - if (alive.current) setBusy(false); - } - } async function saveMemory() { - if (!projectId) return; + if (!projectId || busy) return; setBusy(true); setError(null); - setNotice("保存项目共识…"); try { - const result = await request("memoryUpdate", { + const res = await request("memoryUpdate", { projectId, expectedRevision: memory?.revision ?? 0, goal: memoryDraft.goal, @@ -1285,45 +1607,18 @@ function WorkbenchV2(props) { sources: [] }); if (!alive.current) return; - setMemory(result.memory); + setMemory(res.memory); + setMemoryEditing(false); setMemoryDraft((prev) => ({ ...prev, decisions: "" })); - setNotice("项目共识已保存(v" + result.memory.revision + ")"); - } catch (memoryError) { - if (alive.current) setError(memoryError && memoryError.message ? memoryError.message : "保存项目共识失败"); + setNotice("项目共识已保存为 v" + res.memory.revision); + } catch (err) { + if (alive.current) setError(err?.message || "保存项目共识失败"); } finally { if (alive.current) setBusy(false); } } - async function reloadTasks() { - if (!projectId) return; - const answerVersion = taskAnswerVersion.current; - try { - const result = await request("tasks", { projectId }); - if (alive.current && loadedProjectId.current === projectId && taskAnswerVersion.current === answerVersion) { - setTasks((previous) => refreshList(result?.tasks, previous)); - } - } catch (error2) { - if (alive.current && loadedProjectId.current === projectId) setNotice(error2 && error2.message ? error2.message : "任务列表刷新失败"); - } - } - async function summarizeByShangshu() { - if (!projectId) return; - setSummaryBusy(true); - setError(null); - try { - const result = await request("shangshuSummary", { projectId }); - if (!alive.current) return; - if (!result || !result.sessionId) throw new Error("宿主没有返回尚书会话"); - setNotice("已请尚书汇总当前任务,正在打开尚书会话…"); - navigateToSession(result.sessionId); - } catch (summaryError) { - if (alive.current) setError(summaryError && summaryError.message ? summaryError.message : "尚书汇总请求失败"); - } finally { - if (alive.current) setSummaryBusy(false); - } - } async function addArtifact() { - if (!projectId) return; + if (!projectId || busy) return; const title = artifactDraft.title.trim(); if (!title) { setNotice("成果名称不能为空"); @@ -1332,1347 +1627,2956 @@ function WorkbenchV2(props) { setBusy(true); setError(null); try { - const result = await request("artifactAdd", { projectId, title, path: artifactDraft.path, summary: artifactDraft.summary }); - setArtifacts((list) => [...list, result.artifact]); + const res = await request("artifactAdd", { + projectId, + title, + path: artifactDraft.path.trim(), + summary: artifactDraft.summary.trim() + }); + if (!alive.current) return; + setArtifacts((list) => [...list, res.artifact]); setArtifactDraft({ title: "", path: "", summary: "" }); - setArtifactFormOpen(false); - setNotice("成果已登记。"); - } catch (error2) { - if (alive.current) setError(error2 && error2.message ? error2.message : "登记成果失败"); + setArtifactModalOpen(false); + setNotice("成果已登记"); + } catch (err) { + if (alive.current) setError(err?.message || "登记成果失败"); } finally { if (alive.current) setBusy(false); } } - const todayStart = TODAY(); - const todayTasks = tasks.filter((task) => Number(task.createdAt) >= todayStart); - const todayDone = todayTasks.filter((task) => task.status === "done"); - const reviewTasks = tasks.filter((task) => task.ownerSeatId === "menxia" && OPEN_STATUS.has(task.status)); - const anomalyTasks = tasks.filter((task) => task.workflowBlockage || task.status === "failed"); - const projectDurationMs = tasks.reduce((sum, task) => sum + taskDurationMs(task), 0); + const degraded = Boolean(approvalStatus?.degraded); + const toolApprovals = degraded ? [] : pendingApprovals; + const decisions = (0, import_react.useMemo)(() => tasks.flatMap((task) => (task.decisions || []).filter((d) => d.status === "pending").map((decision) => ({ task, decision }))), [tasks]); + const pendingCount = toolApprovals.length + decisions.length; + const openTasksCount = tasks.filter((t) => ["running", "prepared", "dispatched", "failed", "waiting_user", "reconfirm"].includes(t.status)).length; + const reviewCount = tasks.filter((t) => t.ownerSeatId === "menxia" && ["running", "prepared", "dispatched"].includes(t.status)).length; + const anomalyCount = tasks.filter((t) => t.workflowBlockage || t.status === "failed" || t.deliveryState === "unknown").length + wb.seats.filter((s) => s.status === "missing" || s.modelSyncStatus === "failed").length; + const activeDelib = deliberations.find((d) => d.status === "running") || null; + const syncIssues = wb.seats.filter((s) => s.modelSyncStatus === "failed" || s.status === "missing").length; + const projectDurationMs = tasks.reduce((sum, t) => sum + taskDurationMs(t), 0); + const runningSeatsCount = wb.seats.filter((s) => s.runtimeState === "running").length; function latestTaskOf(seatId) { - return tasks.filter((task) => task.ownerSeatId === seatId).sort((a, b) => Number(b.updatedAt || b.createdAt || 0) - Number(a.updatedAt || a.createdAt || 0))[0] || null; + return tasks.filter((t) => t.ownerSeatId === seatId && t.status !== "cancelled").sort((a, b) => Number(b.updatedAt || b.createdAt || 0) - Number(a.updatedAt || a.createdAt || 0))[0] || null; } - function tasksOf(seatId) { - return tasks.filter((task) => task.ownerSeatId === seatId).sort((a, b) => Number(b.updatedAt || b.createdAt || 0) - Number(a.updatedAt || a.createdAt || 0)); - } - function selectedSeatRecord(id) { - return seatRecordOf(view, id); - } - function modelLabelOf(id) { - return fmtModel(selectedSeatRecord(id), wb.selected.modelOptions); - } - const statusBanner = error ? (0, import_react.createElement)("p", { className: "ssv-banner is-error", role: "alert" }, error) : notice ? (0, import_react.createElement)("p", { className: "ssv-banner is-notice", role: "status" }, notice) : null; - function renderTopbar(title, extra) { - const shortcuts = [ - ...tab === "overview" ? [ - (0, import_react.createElement)("button", { type: "button", key: "memory", className: "icon-btn", title: "记忆", "aria-label": "记忆", onClick: () => setTab("memory") }, (0, import_react.createElement)(BookIcon)), - (0, import_react.createElement)("button", { type: "button", key: "settings", className: "icon-btn", title: "设置", "aria-label": "设置", onClick: () => setTab("settings") }, (0, import_react.createElement)(SlidersIcon)) - ] : [] - ]; - return (0, import_react.createElement)( - "header", - { className: "topbar" }, - (0, import_react.createElement)( - "div", - { className: "topbar-title" }, - (0, import_react.createElement)("h1", null, title), - tab === "overview" ? (0, import_react.createElement)("span", { className: "date" }, dateLabel()) : null, - (0, import_react.createElement)("div", { className: "topbar-icons" }, shortcuts) - ), - (0, import_react.createElement)("span", { className: "spacer" }), - ...extra || [] - ); - } - function renderSeatNode(seat) { - const tone = toneOfSeat(seat); - const latest = latestTaskOf(seat.id); - return (0, import_react.createElement)( - "div", - { key: seat.id, className: "node" + (seat.id === selectedSeatId ? " selected" : ""), "data-seat": seat.id }, - (0, import_react.createElement)( - "button", - { type: "button", className: "node-main", onClick: () => setSeat(seat.id), "aria-pressed": seat.id === selectedSeatId ? "true" : "false" }, - (0, import_react.createElement)("span", { className: "node-top" }, (0, import_react.createElement)("span", { className: "node-name" }, seat.name), (0, import_react.createElement)("span", { className: "status " + tone }, (0, import_react.createElement)("i"), seatStateText(seat))), - (0, import_react.createElement)("span", { className: "node-role" }, seat.duty), - (0, import_react.createElement)("span", { className: "node-task" }, (0, import_react.createElement)("span", { className: "t-label" }, "当前任务"), (0, import_react.createElement)("span", { className: "task-text" }, latest ? latest.title : "—")), - (0, import_react.createElement)("span", { className: "node-model" }, "主任模型 ", (0, import_react.createElement)("span", { className: "num" }, modelLabelOf(seat.id))) - ), - (0, import_react.createElement)("div", { className: "node-foot" }, (0, import_react.createElement)("span", { className: "elapsed" }, latest ? taskLabel(latest.status) : seat.status === "bound" ? "在线 · 待命" : "未运行 · 待命")) - ); - } - function reqTone(status) { - if (status === "ready" || status === "published") return "review"; - if (status === "returned") return "fail"; - if (status === "cancelled") return "idle"; - return "run"; - } - function copyRequirementText(text) { - try { - if (navigator.clipboard && typeof navigator.clipboard.writeText === "function") { - void navigator.clipboard.writeText(text).then(() => setNotice("已复制:" + text)).catch(() => { - }); - } - } catch { - } - } - function renderRequirementGate(selected) { - const views = [ - { id: "requirements", label: "需求清单" }, - { id: "flow", label: "流转任务" }, - { id: "delivery", label: "交付结果" } - ]; - const workflowTasks = tasks.filter((task) => task.kind === "workflow" || task.kind === "execution"); - const deliveryTasks = tasks.filter((task) => task.kind === "workflow" && (task.stage === "delivered" || task.status === "done")); - let body; - if (reqView === "flow") { - body = workflowTasks.length ? (0, import_react.createElement)("div", { className: "review-list req-list" }, workflowTasks.map((task) => (0, import_react.createElement)( - "article", - { className: "review-card req-card", key: task.id }, - (0, import_react.createElement)( - "div", - { className: "rc-head" }, - (0, import_react.createElement)("div", { className: "rc-title" }, task.title), - (0, import_react.createElement)("span", { className: "rc-status " + taskTone(task.status) }, (0, import_react.createElement)("i"), taskLabel(task.status)) - ), - (0, import_react.createElement)( - "div", - { className: "req-meta" }, - (0, import_react.createElement)("span", null, task.id), - (0, import_react.createElement)("span", null, SEATS[task.ownerSeatId] && SEATS[task.ownerSeatId].label || task.ownerSeatId || "—"), - (0, import_react.createElement)("span", null, WORKFLOW_STAGE_LABELS[task.stage] || task.stage || "—"), - task.requirementId ? (0, import_react.createElement)("span", null, task.requirementId + " v" + task.requirementRevision) : null, - task.approvalId ? (0, import_react.createElement)("span", null, task.approvalId) : null - ), - (0, import_react.createElement)(SummaryBlock, { text: task.goal || task.requirement || "", label: "任务说明", empty: "(无任务说明)", max: 110 }), - (0, import_react.createElement)(SummaryBlock, { text: task.workflowBlockage ? task.workflowBlockage.label + " · " + task.workflowBlockage.reason : task.result || task.note || task.blockedReason || "", label: "当前结果 / 阻塞", empty: "(尚未回报)", max: 110 }), - (0, import_react.createElement)("div", { className: "rc-actions" }, (0, import_react.createElement)("span", { className: "spacer" }), (0, import_react.createElement)("button", { type: "button", className: "r-open", onClick: () => setSelectedTask(task) }, "查看详情 →")) - ))) : (0, import_react.createElement)("p", { className: "empty-note" }, "还没有流转任务。丞相下派需求后会出现在这里。"); - } else if (reqView === "delivery") { - body = deliveryTasks.length ? (0, import_react.createElement)("div", { className: "review-list req-list" }, deliveryTasks.map((task) => { - const children = tasks.filter((item) => item.parentTaskId === task.id && item.kind === "execution"); - return (0, import_react.createElement)( - "article", - { className: "review-card req-card", key: task.id }, - (0, import_react.createElement)("div", { className: "rc-head" }, (0, import_react.createElement)("div", { className: "rc-title" }, task.title), (0, import_react.createElement)("span", { className: "rc-status done" }, (0, import_react.createElement)("i"), "已交付")), - (0, import_react.createElement)("div", { className: "req-meta" }, (0, import_react.createElement)("span", null, task.requirementId || "—"), (0, import_react.createElement)("span", null, "v" + (task.requirementRevision || "—")), (0, import_react.createElement)("span", null, task.id)), - (0, import_react.createElement)(SummaryBlock, { text: task.deliveryNote || task.summary || "", label: "交付说明", empty: "(暂无交付说明)", max: 110 }), - children.length ? (0, import_react.createElement)("div", { className: "req-children" }, children.map((child) => (0, import_react.createElement)( - "div", - { className: "req-child", key: child.id }, - (0, import_react.createElement)("span", { className: "req-child-owner" }, SEATS[child.ownerSeatId] && SEATS[child.ownerSeatId].label || child.ownerSeatId), - (0, import_react.createElement)("span", { className: "rc-status " + taskTone(child.status) }, (0, import_react.createElement)("i"), taskLabel(child.status)), - (0, import_react.createElement)("span", { className: "req-child-result" }, child.result || child.note || "(暂无结果)"), - (0, import_react.createElement)("span", { className: "req-child-session" }, child.resultSessionId ? "结果会话 " + child.resultSessionId : "尚无结果会话") - ))) : null - ); - })) : (0, import_react.createElement)("p", { className: "empty-note" }, "还没有已交付结果。"); - } else { - body = requirements.length ? (0, import_react.createElement)("div", { className: "review-list req-list" }, requirements.map((req) => (0, import_react.createElement)( - "article", - { className: "review-card req-card", key: req.id }, - (0, import_react.createElement)( - "div", - { className: "rc-head" }, - (0, import_react.createElement)("div", { className: "rc-title" }, req.id + " · " + req.title), - (0, import_react.createElement)("span", { className: "rc-status " + reqTone(req.status) }, (0, import_react.createElement)("i"), REQ_STATUS_LABELS[req.status] || req.status) - ), - (0, import_react.createElement)( - "div", - { className: "req-meta" }, - (0, import_react.createElement)("span", null, "v" + req.revision), - (0, import_react.createElement)("span", null, "丞相判断:" + (REQ_JUDGEMENT_LABELS[req.judgement] || req.judgement || "—")), - (0, import_react.createElement)("span", null, "当前阻塞:" + (req.blockedReason || "—")) - ), - (0, import_react.createElement)(SummaryBlock, { text: req.summary || req.originalText || "", label: "摘要", empty: "(暂无摘要)", max: 110 }), - (0, import_react.createElement)(SummaryBlock, { text: req.judgementReason || "", label: "判断理由", empty: "(暂无判断理由)", max: 110 }), - (0, import_react.createElement)( - "details", - { className: "req-details" }, - (0, import_react.createElement)("summary", null, "范围、验收与待补信息"), - (0, import_react.createElement)( - "dl", - { className: "kv" }, - (0, import_react.createElement)("dt", null, "用户原话"), - (0, import_react.createElement)("dd", null, req.originalText || "—"), - (0, import_react.createElement)("dt", null, "范围"), - (0, import_react.createElement)("dd", null, req.scope || "—"), - (0, import_react.createElement)("dt", null, "非目标"), - (0, import_react.createElement)("dd", null, req.nonGoals || "—"), - (0, import_react.createElement)("dt", null, "验收标准"), - (0, import_react.createElement)("dd", null, req.acceptanceCriteria || "—"), - (0, import_react.createElement)("dt", null, "风险"), - (0, import_react.createElement)("dd", null, req.risks || "—"), - (0, import_react.createElement)("dt", null, "依赖"), - (0, import_react.createElement)("dd", null, req.dependencies || "—"), - (0, import_react.createElement)("dt", null, "待补信息"), - (0, import_react.createElement)("dd", null, req.missingInfo || "—") - ) - ), - (0, import_react.createElement)( - "div", - { className: "rc-actions" }, - (0, import_react.createElement)("button", { type: "button", className: "btn", onClick: () => copyRequirementText(req.id) }, "复制条目编号"), - (0, import_react.createElement)("span", { className: "spacer" }) - ) - ))) : (0, import_react.createElement)("p", { className: "empty-note" }, "还没有需求条目。可以先与丞相讨论。"); - } + function renderPendingZone() { + if (pendingCount === 0 && !degraded) return null; return (0, import_react.createElement)( "section", - { className: "card req-gate", "aria-label": "丞相需求门控" }, - (0, import_react.createElement)("h3", null, "需求门控 ", (0, import_react.createElement)("span", { className: "seat-tag" }, selected.name)), - (0, import_react.createElement)("p", { className: "foot-note ws-hint" }, "与丞相商讨后,需求会整理到这里。想推进哪条需求,直接在聊天中告诉丞相下派。中书拟案,门下通过后由尚书安排执行。"), - (0, import_react.createElement)("div", { className: "req-tabs", role: "tablist" }, views.map((view2) => (0, import_react.createElement)("button", { - key: view2.id, - type: "button", - role: "tab", - "aria-selected": reqView === view2.id, - className: "req-tab" + (reqView === view2.id ? " is-active" : ""), - onClick: () => setReqView(view2.id) - }, view2.label))), - body - ); - } - async function answerApproval(entry, choice) { - if (!projectId || !entry) return; - setBusy(true); - setError(null); - try { - await request("approvalAnswer", { projectId, seatId: entry.seatId, id: entry.id, sessionId: entry.sessionId, choice }); - const data = await request("approvals", { projectId }); - if (!alive.current || loadedProjectId.current !== projectId) return; - setPendingApprovals((previous) => refreshList(data?.approvals, previous)); - setApprovalStatus(data?.status ?? null); - setNotice(choice === "allow" ? "已允许审批" : "已拒绝审批"); - } catch (error2) { - if (alive.current) setError(error2 && error2.message ? error2.message : "审批应答失败"); - } finally { - if (alive.current) setBusy(false); - } - } - async function answerDecision(taskId, decisionId, value) { - if (!projectId || busy) return; - setBusy(true); - setError(null); - try { - await request("taskDecisionAnswer", { projectId, taskId, decisionId, value }); - if (!alive.current || loadedProjectId.current !== projectId) return; - taskAnswerVersion.current += 1; - setTasks((previous) => previous.map((task) => task.id === taskId && Array.isArray(task.decisions) ? { ...task, decisions: task.decisions.map((decision) => decision.id === decisionId ? { ...decision, status: "answered", answer: value } : decision) } : task)); - setNotice("已提交项目决定"); - } catch (error2) { - if (alive.current && loadedProjectId.current === projectId) setError(error2?.message || "项目决定提交失败"); - } finally { - if (alive.current) setBusy(false); - } - } - function renderPendingActions() { - const degraded = approvalStatus?.degraded; - const toolApprovals = degraded ? [] : pendingApprovals; - const decisions = tasks.flatMap((task) => (task.decisions || []).filter((decision) => decision.status === "pending").map((decision) => ({ task, decision }))); - const count = toolApprovals.length + decisions.length; - if (!count && !degraded) return null; - return (0, import_react.createElement)( - "section", - { className: "card approval-card", "aria-label": "待你处理" }, - (0, import_react.createElement)("h3", null, "待你处理 ", count ? (0, import_react.createElement)("span", { className: "seat-tag" }, String(count)) : null), - degraded ? (0, import_react.createElement)("p", { className: "foot-note" }, "工作台暂时无法获取工具审批,请在席位会话中使用原生审批卡。" + (approvalStatus.reason ? "(" + approvalStatus.reason + ")" : "")) : null, - count ? (0, import_react.createElement)( + { className: "frameless-zone", "aria-label": "待你处理" }, + (0, import_react.createElement)( "div", - { className: "approval-list" }, - toolApprovals.map((entry) => (0, import_react.createElement)( + { className: "frameless-zone-head" }, + (0, import_react.createElement)( + "div", + { className: "frameless-zone-title-wrap" }, + (0, import_react.createElement)("span", { className: "ss-dot is-primary is-pulse" }), + (0, import_react.createElement)("h2", { className: "frameless-zone-title" }, "待你处理"), + pendingCount > 0 ? (0, import_react.createElement)("span", { className: "frameless-zone-count" }, String(pendingCount)) : null + ), + (0, import_react.createElement)("span", { className: "frameless-zone-sub" }, "原生审批与决定同步") + ), + degraded ? (0, import_react.createElement)( + "div", + { className: "frameless-code", style: { color: "var(--ss-error)" } }, + "工作台暂时无法获取工具审批队列,请在席位原生会话中使用审批卡。" + (approvalStatus?.reason ? "(" + approvalStatus.reason + ")" : "") + ) : null, + (0, import_react.createElement)( + "div", + { className: "frameless-zone-list" }, + toolApprovals.map((a) => (0, import_react.createElement)( "article", - { className: "approval-item", key: "tool:" + entry.sessionId + ":" + entry.id }, - (0, import_react.createElement)("div", { className: "approval-head" }, (0, import_react.createElement)("strong", null, SEATS[entry.seatId]?.label || entry.seatId), (0, import_react.createElement)("span", null, entry.tool || "工具审批")), - (0, import_react.createElement)("p", null, entry.reason || entry.detail?.text || "等待审批"), + { className: "frameless-item", key: "apr:" + a.sessionId + ":" + a.id }, (0, import_react.createElement)( "div", - { className: "approval-actions" }, - (0, import_react.createElement)("button", { type: "button", className: "btn primary", disabled: busy, onClick: () => answerApproval(entry, "allow") }, "允许一次"), - (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: busy, onClick: () => answerApproval(entry, "reject") }, "拒绝") + { className: "frameless-item-head" }, + (0, import_react.createElement)( + "div", + { className: "frameless-item-meta" }, + (0, import_react.createElement)("span", { className: "frameless-chip is-err" }, (0, import_react.createElement)("span", { className: "ss-dot is-error" }), "工具审批"), + (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 13 } }, SEATS[a.seatId]?.label || a.seatId), + a.tool ? (0, import_react.createElement)("span", { className: "font-mono-num", style: { fontSize: 12, color: "var(--ss-muted)" } }, a.tool) : null + ), + (0, import_react.createElement)("button", { type: "button", className: "frameless-link", disabled: busy, onClick: () => void openSeat(a.seatId) }, "查看会话 →") + ), + (0, import_react.createElement)("div", { className: "frameless-code" }, a.reason || a.detail?.text || "等待工具授权"), + (0, import_react.createElement)( + "div", + { className: "frameless-btn-group" }, + (0, import_react.createElement)("button", { type: "button", className: "frameless-btn", disabled: busy, onClick: () => void answerApproval(a, "reject") }, "拒绝"), + (0, import_react.createElement)("button", { type: "button", className: "frameless-primary-btn", disabled: busy, onClick: () => void answerApproval(a, "allow") }, "允许一次") ) )), decisions.map(({ task, decision }) => (0, import_react.createElement)( "article", - { className: "approval-item", key: "decision:" + task.id + ":" + decision.id }, - (0, import_react.createElement)("div", { className: "approval-head" }, (0, import_react.createElement)("strong", null, task.title || task.id), (0, import_react.createElement)("span", null, "项目决定")), - (0, import_react.createElement)("p", null, decision.question), - (0, import_react.createElement)("div", { className: "approval-actions", role: "group", "aria-label": decision.question }, decision.options.map( - (option) => (0, import_react.createElement)("button", { type: "button", className: "btn", key: option.value, disabled: busy, onClick: () => answerDecision(task.id, decision.id, option.value) }, option.label) - )) - )) - ) : null - ); - } - function renderOverview() { - const stats = [ - (0, import_react.createElement)( - "button", - { type: "button", className: "stat stat-link", key: "cost", onClick: () => setTokenPanelOpen(true) }, - (0, import_react.createElement)("div", { className: "label" }, "消耗金额"), - (0, import_react.createElement)("div", { className: "big" }, (0, import_react.createElement)("em", null, "—"), (0, import_react.createElement)("span", { className: "unit" }, "元")), - (0, import_react.createElement)("div", { className: "foot" }, "Token 统计待接入") - ), - (0, import_react.createElement)( - "button", - { type: "button", className: "stat stat-link", key: "duration", onClick: () => setDurationPanelOpen(true) }, - (0, import_react.createElement)("div", { className: "label" }, "消耗时间"), - (0, import_react.createElement)("div", { className: "big" }, projectDurationMs > 0 ? durationText(projectDurationMs) : "—"), - (0, import_react.createElement)("div", { className: "foot" }, "按任务单程累计") - ), - (0, import_react.createElement)( - "button", - { type: "button", className: "stat stat-link", key: "review", onClick: () => setReviewPanelOpen(true) }, - (0, import_react.createElement)("div", { className: "label" }, "待审核"), - (0, import_react.createElement)("div", { className: "big" }, (0, import_react.createElement)("em", null, String(reviewTasks.length)), " ", (0, import_react.createElement)("span", { className: "unit" }, "件")), - (0, import_react.createElement)("div", { className: "foot" }, "待门下复核") - ), - (0, import_react.createElement)( - "button", - { type: "button", className: "stat stat-link", key: "anomaly", onClick: () => { - setQueueSearch("失败"); - setQueuePanelOpen(true); - } }, - (0, import_react.createElement)("div", { className: "label" }, "异常 / 失败"), - (0, import_react.createElement)("div", { className: "big" }, (0, import_react.createElement)("em", null, String(anomalyTasks.length)), " ", (0, import_react.createElement)("span", { className: "unit" }, "条")), - (0, import_react.createElement)("div", { className: "foot" }, "失败或投递失败") - ) - ]; - const selected = wb.selected; - const selectedLatest = latestTaskOf(selected.id); - const selectedTasks = tasksOf(selected.id); - const selectedToday = todayTasks.filter((task) => task.ownerSeatId === selected.id); - const selectedDone = selectedToday.filter((task) => task.status === "done"); - const excerpt = selectedLatest && (selectedLatest.result || selectedLatest.note) || selected.responsibility; - const actionLabel = selected.status === "bound" ? "开始对话" : selected.status === "missing" ? "重建会话" : "开启「" + selected.name + "」"; - const action = selected.status === "bound" ? () => openSeat(selected.id) : selected.status === "missing" ? () => rebuildSeat(selected.id) : () => enableSeat(selected.id); - const detail = (0, import_react.createElement)( - "section", - { className: "card", "aria-label": "席位详情" }, - (0, import_react.createElement)("div", { className: "detail-head" }, (0, import_react.createElement)("h3", null, "席位详情"), (0, import_react.createElement)("button", { type: "button", className: "btn primary", disabled: busy || selected.status === "creating", onClick: action }, (0, import_react.createElement)(ChatIcon), actionLabel)), - (0, import_react.createElement)("div", { className: "detail-name" }, selected.name), - (0, import_react.createElement)("div", { className: "detail-role" }, selected.duty + " · " + selected.statusLabel), - (0, import_react.createElement)( - "dl", - { className: "kv" }, - (0, import_react.createElement)("dt", null, "主任模型"), - (0, import_react.createElement)("dd", null, selected.modelLabel), - (0, import_react.createElement)("dt", null, "当前任务"), - (0, import_react.createElement)("dd", null, selectedLatest ? selectedLatest.title : "—"), - (0, import_react.createElement)("dt", null, "本日派工"), - (0, import_react.createElement)("dd", null, selectedToday.length + " 条 · 完成 " + selectedDone.length), - (0, import_react.createElement)("dt", null, "最近会话"), - (0, import_react.createElement)("dd", null, selected.sessionId ? "已绑定 · " + selected.sessionId.slice(0, 8) : "尚未建立") - ), - (0, import_react.createElement)("div", { className: "excerpt" }, (0, import_react.createElement)(SummaryBlock, { text: excerpt, label: "最近产出", empty: "(暂无产出)", max: 110 })) - ); - const workspace = selected.id === "lead" ? renderRequirementGate(selected) : (0, import_react.createElement)( - "section", - { className: "card", "aria-label": "席位工作区" }, - (0, import_react.createElement)("h3", null, "席位工作区 ", (0, import_react.createElement)("span", { className: "seat-tag" }, selected.name), " ", (0, import_react.createElement)("span", { className: "w-kind" }, seatKind(selected.id))), - selected.id === "shangshu" ? (0, import_react.createElement)("div", { className: "ws-actions" }, (0, import_react.createElement)("button", { type: "button", className: "btn primary", disabled: summaryBusy || busy, onClick: summarizeByShangshu }, summaryBusy ? "汇总中…" : "尚书汇总当前任务")) : null, - (0, import_react.createElement)("p", { className: "foot-note ws-hint" }, "需求请先在聊天中与丞相商讨,再直接告诉丞相下派。中书拟案,门下通过后由尚书向六部派工。"), - selectedTasks.length === 0 ? (0, import_react.createElement)("p", { className: "empty-note" }, "该席位还没有任务记录。") : (0, import_react.createElement)("div", { className: "review-list" }, selectedTasks.slice(0, 3).map((task) => (0, import_react.createElement)( - "article", - { className: "review-card", key: task.id }, - (0, import_react.createElement)("div", { className: "rc-head" }, (0, import_react.createElement)("div", { className: "rc-title" }, task.title), (0, import_react.createElement)("span", { className: "rc-status " + taskTone(task.status) }, (0, import_react.createElement)("i"), taskLabel(task.status))), - (0, import_react.createElement)(SummaryBlock, { text: task.goal || task.requirement || "", label: "任务说明", empty: "(无任务说明)", max: 110 }), - (0, import_react.createElement)(SummaryBlock, { text: task.result || taskLabel(task.status), label: "任务完成情况", empty: "(暂无结果)", max: 110 }), - (0, import_react.createElement)( - "div", - { className: "rc-actions" }, - (0, import_react.createElement)("span", { className: "spacer" }), - (0, import_react.createElement)("button", { type: "button", className: "r-open", onClick: () => setSelectedTask(task) }, "查看详情 →") - ) - ))) - ); - const modelChoices = []; - const seenModels = /* @__PURE__ */ new Set(); - for (const option of selected.modelOptions) { - const key = option.provider + "::" + option.model; - if (seenModels.has(key)) continue; - seenModels.add(key); - modelChoices.push({ value: key, label: option.model, provider: option.provider, model: option.model }); - } - const valueParts = String(selected.modelValue || "").split("::"); - const currentProvider = valueParts[0] || ""; - const currentModel = valueParts[1] || ""; - const currentModelValue = currentProvider && currentModel ? currentProvider + "::" + currentModel : ""; - if (currentModelValue && !seenModels.has(currentModelValue)) { - modelChoices.unshift({ value: currentModelValue, label: currentModel, provider: currentProvider, model: currentModel }); - } - const effortChoices = []; - for (const option of selected.modelOptions) { - if (option.provider !== currentProvider || option.model !== currentModel || !option.reasoningEffort) continue; - if (!effortChoices.includes(option.reasoningEffort)) effortChoices.push(option.reasoningEffort); - } - const currentEffort = valueParts[2] || ""; - if (currentEffort && !effortChoices.includes(currentEffort)) effortChoices.unshift(currentEffort); - const configCard = (0, import_react.createElement)( - "details", - { className: "card dept-config-card", "aria-label": "部门配置" }, - (0, import_react.createElement)("summary", null, (0, import_react.createElement)("span", null, "部门配置"), (0, import_react.createElement)("span", { className: "seat-tag" }, selected.name)), - (0, import_react.createElement)( - "div", - { className: "dept-config-body" }, - (0, import_react.createElement)( - "div", - { className: "cfg-grid" }, - (0, import_react.createElement)("label", { className: "cfg-row" }, "主任模型", (0, import_react.createElement)( - "select", - { value: currentModelValue, onChange: (event) => setModelValue(event.target.value) }, - (0, import_react.createElement)("option", { value: "" }, "请选择模型"), - modelChoices.map((option) => (0, import_react.createElement)("option", { key: option.value, value: option.value }, option.label)) - )), - (0, import_react.createElement)("label", { className: "cfg-row" }, "推理等级", (0, import_react.createElement)( - "select", - { - value: currentEffort, - disabled: effortChoices.length === 0, - title: effortChoices.length === 0 ? "当前模型目录未提供可调推理等级" : void 0, - onChange: (event) => setModelValue(event.target.value ? currentProvider + "::" + currentModel + "::" + event.target.value : currentModelValue) - }, - effortChoices.length === 0 ? (0, import_react.createElement)("option", { value: "" }, "默认(模型固定)") : [(0, import_react.createElement)("option", { key: "default", value: "" }, "默认"), ...effortChoices.map((effort) => (0, import_react.createElement)("option", { key: effort, value: effort }, effort))] - )), - (0, import_react.createElement)("label", { className: "cfg-row", style: { gridColumn: "1 / -1" } }, "角色补充说明", (0, import_react.createElement)("textarea", { - rows: 3, - className: "ssv-textarea", - value: selected.instructions, - placeholder: "仅对该席位追加的补充说明", - onChange: (event) => setInstructions(event.target.value) - })) - ), - (0, import_react.createElement)( - "div", - { className: "cfg-model-status" }, - (0, import_react.createElement)("div", null, "配置来源:" + selected.modelSourceLabel), - (0, import_react.createElement)("div", null, "当前会话模型:" + (selected.sessionModel ? selected.sessionModel.provider + "/" + selected.sessionModel.model : "未知")), - (0, import_react.createElement)("div", null, "同步状态:" + (selected.modelStatus || "未同步") + (selected.modelSync && selected.modelSync.error ? "(" + selected.modelSync.error + ")" : "")) - ), - (0, import_react.createElement)( - "div", - { className: "cfg-skills" }, - (0, import_react.createElement)("span", { className: "t-label" }, "技能绑定"), - (0, import_react.createElement)( - "ul", - { className: "skill-list" }, - (0, import_react.createElement)("li", null, (0, import_react.createElement)("span", { className: "skill-name" }, "真实会话绑定"), (0, import_react.createElement)("span", { className: "skill-state" + (selected.status === "bound" ? " bound" : "") }, (0, import_react.createElement)("i"), selected.status === "bound" ? "已绑定" : "未绑定")), - (0, import_react.createElement)("li", null, (0, import_react.createElement)("span", { className: "skill-name" }, "工作台派工工具"), (0, import_react.createElement)("span", { className: "skill-state" + (selected.status === "bound" ? " bound" : "") }, (0, import_react.createElement)("i"), selected.status === "bound" ? "可用" : "待开启")), - (0, import_react.createElement)("li", null, (0, import_react.createElement)("span", { className: "skill-name" }, "职责"), (0, import_react.createElement)("span", { className: "skill-state bound" }, (0, import_react.createElement)("i"), selected.duty)) - ) - ), - (0, import_react.createElement)( - "div", - { className: "ws-actions" }, - (0, import_react.createElement)("button", { type: "button", className: "btn primary", disabled: busy, onClick: saveConfig }, busy ? "保存中…" : "保存配置"), - selected.status === "bound" && selected.configuredModel ? (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: busy, onClick: setGlobalDefaultForSeat }, "设为全局默认") : null, - selected.modelSource === "project" ? (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: busy, onClick: clearSeatOverride }, "恢复继承全局默认") : null, - selected.modelSyncStatus === "failed" || selected.modelSyncStatus === "unresolved" ? (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: busy, onClick: retryModelSync }, "重试同步") : null, - selected.status !== "bound" ? (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: busy, onClick: action }, actionLabel) : null - ) - ) - ); - return (0, import_react.createElement)( - "div", - { className: "page" }, - renderTopbar("总览", [ - (0, import_react.createElement)( - "button", - { type: "button", className: "btn primary btn-cx", onClick: () => { - setSeat("lead"); - if (seatById.lead.status === "bound") void openSeat("lead"); - else setTab("settings"); - } }, - (0, import_react.createElement)("span", { className: "cx-name" }, "丞相"), - (0, import_react.createElement)("span", { className: "cx-dot", "aria-hidden": "true" }), - (0, import_react.createElement)("span", { className: "cx-state" }, seatStateText(seatById.lead)) - ) - ]), - (0, import_react.createElement)("section", { className: "stats", "aria-label": "关键指标" }, stats), - renderPendingActions(), - (0, import_react.createElement)( - "section", - { "aria-label": "席位谱系", style: { marginTop: "22px" } }, - (0, import_react.createElement)("div", { className: "panel-head" }, (0, import_react.createElement)("h2", null, "席位谱系")), - (0, import_react.createElement)("div", { id: "orgTree", ref: orgRef }, (0, import_react.createElement)( - "div", - { className: "org-rows", "data-cols": String(orgCols) }, - (0, import_react.createElement)("div", { className: "org-row org-row-3" }, wb.groups.sansheng.map((id) => (0, import_react.createElement)("div", { className: "org-cell", key: id, "data-slot": id }, renderSeatNode(seatById[id])))), + { className: "frameless-item", key: "dec:" + task.id + ":" + decision.id }, (0, import_react.createElement)( "div", - { className: "org-wires org-wires-2", "aria-hidden": "true" }, - (0, import_react.createElement)("span", { className: "wire-v", style: { left: "50%", top: 0, height: 11 } }), - (0, import_react.createElement)("span", { className: "wire-h", style: { left: "8.3333%", right: "8.3333%", top: 11 } }), - ...[8.3333, 25, 41.6667, 58.3333, 75, 91.6667].map((left, i) => (0, import_react.createElement)("span", { key: i, className: "wire-v w2-b" + (i + 1), style: { left: left + "%", top: 11, height: 11 } })) - ), - (0, import_react.createElement)("div", { className: "org-row org-row-6" }, wb.groups.liubu.map((id) => (0, import_react.createElement)("div", { className: "org-cell", key: id, "data-slot": id }, renderSeatNode(seatById[id])))) - )) - ), - (0, import_react.createElement)("div", { className: "grid" }, (0, import_react.createElement)("div", { className: "detail-col" }, detail, workspace), (0, import_react.createElement)("div", { className: "rail" }, configCard)), - (0, import_react.createElement)("p", { className: "foot-note" }, "数据来自当前项目真实会话 · " + (wb.project.boundCount + " / " + wb.project.seatCount + " 席已启用")) - ); - } - function renderQueuePanel() { - if (!queuePanelOpen) return null; - const query = queueSearch.trim().toLowerCase(); - const filtered = tasks.filter((task) => { - if (!query) return true; - const seatName = SEATS[task.ownerSeatId]?.label || task.ownerSeatId || ""; - const haystack = [task.title, seatName, task.id, task.goal, task.requirement, task.result, taskLabel(task.status), deliveryLabel(task.deliveryState)].filter(Boolean).join(" ").toLowerCase(); - return haystack.includes(query); - }); - const openTask = (task) => { - setQueuePanelOpen(false); - setSelectedTask(task); - }; - return (0, import_react.createElement)( - "div", - { className: "modal-backdrop", onClick: (event) => { - if (event.target === event.currentTarget) setQueuePanelOpen(false); - } }, - (0, import_react.createElement)( - "div", - { className: "modal wide", role: "dialog", "aria-modal": "true", "aria-labelledby": "ssv-queue-title" }, - (0, import_react.createElement)("div", { className: "modal-head" }, (0, import_react.createElement)("h3", { id: "ssv-queue-title" }, "派工队列"), (0, import_react.createElement)("button", { type: "button", className: "modal-close", "aria-label": "关闭", onClick: () => setQueuePanelOpen(false) }, "✕")), - (0, import_react.createElement)( - "div", - { className: "modal-toolbar" }, - (0, import_react.createElement)("label", { className: "search" }, (0, import_react.createElement)(SearchIcon), (0, import_react.createElement)("input", { type: "search", value: queueSearch, placeholder: "搜索派工记录…", "aria-label": "搜索派工队列", onChange: (event) => setQueueSearch(event.target.value) })), - (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: summaryBusy || busy, onClick: summarizeByShangshu }, summaryBusy ? "汇总中…" : "尚书汇总"), - (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: busy, onClick: reloadTasks }, (0, import_react.createElement)(RefreshIcon), "刷新") - ), - (0, import_react.createElement)( - "div", - { className: "queue-table-wrap" }, - (0, import_react.createElement)("div", { className: "table-scroll" }, (0, import_react.createElement)( - "table", - null, - (0, import_react.createElement)("thead", null, (0, import_react.createElement)("tr", null, ["任务", "承办席位", "状态", "结果", "耗时", "派发时间"].map((label) => (0, import_react.createElement)("th", { key: label, scope: "col" }, label)))), - (0, import_react.createElement)("tbody", null, filtered.map((task) => (0, import_react.createElement)( - "tr", - { key: task.id, className: "clickable", tabIndex: 0, onClick: () => openTask(task), onKeyDown: (event) => { - if (event.key === "Enter") openTask(task); - } }, - (0, import_react.createElement)("td", null, (0, import_react.createElement)("span", { className: "task-name" }, task.title), (0, import_react.createElement)("br"), (0, import_react.createElement)("span", { className: "task-id" }, task.id)), - (0, import_react.createElement)("td", null, SEATS[task.ownerSeatId]?.label || task.ownerSeatId || "—"), - (0, import_react.createElement)("td", null, (0, import_react.createElement)("span", { className: "pill " + taskTone(task.status) }, (0, import_react.createElement)("i"), taskLabel(task.status)), task.deliveryState && task.deliveryState !== "none" ? (0, import_react.createElement)("span", { className: "pill " + (task.deliveryState === "unknown" ? "fail" : "idle"), style: { marginLeft: "4px" } }, (0, import_react.createElement)("i"), deliveryLabel(task.deliveryState)) : null), - (0, import_react.createElement)("td", { className: "result-cell" }, task.result ? shortText(task.result, 42) : "—"), - (0, import_react.createElement)("td", { className: "dur" }, taskDurationMs(task) > 0 ? durationText(taskDurationMs(task)) : "—"), - (0, import_react.createElement)("td", { className: "time" }, task.dispatchedAt ? dateText(task.dispatchedAt) : "—") - ))) - )), - (0, import_react.createElement)("p", { className: "foot-note" }, filtered.length === 0 ? "没有匹配的派工记录,换个关键词试试。" : "共 " + filtered.length + " 条派工记录。") - ) - ) - ); - } - function renderMemory() { - const constraints = Array.isArray(memory?.constraints) ? memory.constraints : []; - const acceptance = Array.isArray(memory?.acceptance) ? memory.acceptance : []; - const decisions = Array.isArray(memory?.decisions) ? memory.decisions : []; - const item = (title, meta, body, tone) => (0, import_react.createElement)( - "article", - { className: "review-card", key: title }, - (0, import_react.createElement)("div", { className: "rc-head" }, (0, import_react.createElement)("div", { className: "rc-title" }, title), (0, import_react.createElement)("span", { className: "rc-status " + (tone || "pass") }, (0, import_react.createElement)("i"), "现行")), - (0, import_react.createElement)("div", { className: "rc-meta-row" }, (0, import_react.createElement)("span", { className: "rc-from" }, "项目共识"), (0, import_react.createElement)("span", { className: "rc-meta" }, meta)), - (0, import_react.createElement)("div", { className: "rc-excerpt" }, body || "(暂无)") - ); - return (0, import_react.createElement)( - "div", - { className: "page" }, - renderTopbar("记忆", [ - (0, import_react.createElement)("span", { className: "date" }, (wb.project.name || "项目") + " · 项目共识 v" + (memory?.revision ?? 0)) - ]), - (0, import_react.createElement)( - "div", - { className: "settings-stack" }, - (0, import_react.createElement)( - "section", - { className: "card", "aria-label": "项目共识" }, - (0, import_react.createElement)("h3", null, "项目共识 ", (0, import_react.createElement)("span", { className: "seat-tag" }, "v" + (memory?.revision ?? 0))), - (0, import_react.createElement)( - "div", - { className: "review-list" }, - item("项目目标", "goal", memory?.goal || "尚未填写项目目标", "pass"), - item("硬约束", (constraints.length || 0) + " 条", constraints.join(";"), constraints.length ? "pass" : "idle"), - item("验收标准", (acceptance.length || 0) + " 条", acceptance.join(";"), acceptance.length ? "pass" : "idle"), - ...decisions.slice(-5).map((decision, index) => item(decision.text || "决定 " + (index + 1), decision.recordedAt ? dateText(decision.recordedAt) : "项目记录", decision.status === "active" ? "现行决定" : "已归档", "pass")) - ) - ), - (0, import_react.createElement)( - "details", - { className: "card memory-editor", "aria-label": "编辑项目共识" }, - (0, import_react.createElement)("summary", null, (0, import_react.createElement)("span", null, "编辑项目共识"), (0, import_react.createElement)("span", { className: "seat-tag" }, "可折叠")), - (0, import_react.createElement)( - "div", - { className: "cfg-grid" }, - (0, import_react.createElement)("label", { className: "cfg-row", style: { gridColumn: "1 / -1" } }, "项目目标", (0, import_react.createElement)("textarea", { rows: 3, className: "ssv-textarea", value: memoryDraft.goal, placeholder: "这个项目最终要达成什么", onChange: (event) => setMemoryDraft({ ...memoryDraft, goal: event.target.value }) })), - (0, import_react.createElement)("label", { className: "cfg-row", style: { gridColumn: "1 / -1" } }, "硬约束(每行一条)", (0, import_react.createElement)("textarea", { rows: 3, className: "ssv-textarea", value: memoryDraft.constraints, placeholder: "例如:不能改动线上数据", onChange: (event) => setMemoryDraft({ ...memoryDraft, constraints: event.target.value }) })), - (0, import_react.createElement)("label", { className: "cfg-row", style: { gridColumn: "1 / -1" } }, "验收标准(每行一条)", (0, import_react.createElement)("textarea", { rows: 3, className: "ssv-textarea", value: memoryDraft.acceptance, placeholder: "例如:交付前必须跑完回归测试", onChange: (event) => setMemoryDraft({ ...memoryDraft, acceptance: event.target.value }) })), - (0, import_react.createElement)("label", { className: "cfg-row", style: { gridColumn: "1 / -1" } }, "新增决定(每行一条)", (0, import_react.createElement)("textarea", { rows: 2, className: "ssv-textarea", value: memoryDraft.decisions, placeholder: "例如:先保证稳定性,再考虑样式", onChange: (event) => setMemoryDraft({ ...memoryDraft, decisions: event.target.value }) })) - ), - (0, import_react.createElement)("div", { className: "ws-actions" }, (0, import_react.createElement)("button", { type: "button", className: "btn primary", disabled: busy, onClick: saveMemory }, busy ? "保存中…" : "保存共识")) - ), - (0, import_react.createElement)( - "section", - { className: "card", "aria-label": "成果" }, - (0, import_react.createElement)("h3", null, "成果登记 ", (0, import_react.createElement)("span", { className: "seat-tag" }, String(artifacts.length))), - (0, import_react.createElement)("div", { className: "ws-actions" }, (0, import_react.createElement)("button", { type: "button", className: "btn", onClick: () => setArtifactFormOpen(true) }, (0, import_react.createElement)(PlusIcon), "登记成果")), - artifacts.length === 0 ? (0, import_react.createElement)("p", { className: "empty-note" }, "还没有登记成果。") : (0, import_react.createElement)("ul", { className: "skill-list" }, artifacts.slice(0, 8).map((artifact) => (0, import_react.createElement)("li", { key: artifact.id }, (0, import_react.createElement)("span", { className: "skill-name" }, artifact.title), (0, import_react.createElement)("span", { className: "skill-state bound" }, (0, import_react.createElement)("i"), artifact.path || "已登记")))) - ) - ) - ); - } - function renderSettings() { - return (0, import_react.createElement)( - "div", - { className: "page" }, - renderTopbar("设置"), - (0, import_react.createElement)( - "div", - { className: "settings-stack" }, - (0, import_react.createElement)( - "section", - { className: "card", "aria-label": "项目绑定" }, - (0, import_react.createElement)("h3", null, "项目绑定"), - (0, import_react.createElement)( - "dl", - { className: "kv" }, - (0, import_react.createElement)("dt", null, "当前项目"), - (0, import_react.createElement)("dd", null, wb.project.name || "未命名项目"), - (0, import_react.createElement)("dt", null, "类型"), - (0, import_react.createElement)("dd", null, "主项目"), - (0, import_react.createElement)("dt", null, "席位"), - (0, import_react.createElement)("dd", null, wb.project.seatCount + " 席"), - (0, import_react.createElement)("dt", null, "工作区"), - (0, import_react.createElement)("dd", null, wb.project.workspaceId || "—") - ) - ), - (0, import_react.createElement)( - "section", - { className: "card", "aria-label": "席位开关" }, - (0, import_react.createElement)("h3", null, "席位开关"), - (0, import_react.createElement)("ul", { className: "skill-list" }, SEAT_IDS.map((id) => { - const seat = seatById[id]; - const online = seat.status === "bound"; - return (0, import_react.createElement)( - "li", - { key: id }, - (0, import_react.createElement)("span", { className: "skill-name" }, seat.name + " · " + seat.duty), - (0, import_react.createElement)("span", { className: "skill-state" + (online ? " bound" : "") }, (0, import_react.createElement)("i"), online ? "已上线" : seat.status === "missing" ? "会话缺失" : "未上线"), - (0, import_react.createElement)("button", { type: "button", className: "skill-toggle", disabled: busy, onClick: () => { - if (seat.status === "missing") void rebuildSeat(id); - else if (online) void openSeat(id); - else void enableSeat(id); - } }, seat.status === "missing" ? "重建" : online ? "打开" : "上线") - ); - })) - ), - (0, import_react.createElement)( - "section", - { className: "card", "aria-label": "角色职责" }, - (0, import_react.createElement)("h3", null, "角色职责"), - (0, import_react.createElement)("ul", { className: "skill-list" }, SEAT_IDS.map((id) => (0, import_react.createElement)( - "li", - { key: id }, - (0, import_react.createElement)("span", { className: "skill-name" }, (0, import_react.createElement)("b", null, SEATS[id].label)), - (0, import_react.createElement)("span", { className: "skill-state bound" }, (0, import_react.createElement)("i"), SEATS[id].duty), - (0, import_react.createElement)("span", { className: "rc-meta" }, modelLabelOf(id)) - ))) - ) - ) - ); - } - function renderReviewPanel() { - if (!reviewPanelOpen) return null; - return (0, import_react.createElement)( - "div", - { className: "modal-backdrop", onClick: (event) => { - if (event.target === event.currentTarget) setReviewPanelOpen(false); - } }, - (0, import_react.createElement)( - "div", - { className: "modal wide", role: "dialog", "aria-modal": "true", "aria-labelledby": "ssv-review-title" }, - (0, import_react.createElement)("div", { className: "modal-head" }, (0, import_react.createElement)("h3", { id: "ssv-review-title" }, "待审核 · 门下复核"), (0, import_react.createElement)("button", { type: "button", className: "modal-close", "aria-label": "关闭", onClick: () => setReviewPanelOpen(false) }, "✕")), - (0, import_react.createElement)("p", { className: "foot-note" }, "只读展示当前待门下复核的任务。"), - reviewTasks.length === 0 ? (0, import_react.createElement)("p", { className: "empty-note" }, "当前没有待审核任务。") : (0, import_react.createElement)("div", { className: "review-list" }, reviewTasks.map((task) => (0, import_react.createElement)( - "article", - { className: "review-card", key: task.id }, - (0, import_react.createElement)("div", { className: "rc-head" }, (0, import_react.createElement)("div", { className: "rc-title" }, task.title), (0, import_react.createElement)("span", { className: "rc-status " + taskTone(task.status) }, (0, import_react.createElement)("i"), taskLabel(task.status))), - (0, import_react.createElement)("div", { className: "rc-meta-row" }, (0, import_react.createElement)("span", { className: "rc-from" }, task.id || "—"), (0, import_react.createElement)("span", { className: "rc-meta" }, task.dispatchedAt ? "派发 " + dateText(task.dispatchedAt) : "尚未派发")), - (0, import_react.createElement)(SummaryBlock, { text: task.result || task.goal || task.requirement || "", label: "审核材料", empty: "(暂无内容)", max: 110 }), - (0, import_react.createElement)("div", { className: "rc-actions" }, (0, import_react.createElement)("span", { className: "spacer" }), (0, import_react.createElement)("button", { type: "button", className: "r-open", onClick: () => { - setReviewPanelOpen(false); - setSelectedTask(task); - } }, "查看任务 →")) - ))) - ) - ); - } - function renderDurationPanel() { - if (!durationPanelOpen) return null; - const rows = tasks.map((task) => ({ task, ms: taskDurationMs(task) })).filter((row) => row.ms > 0).sort((a, b) => b.ms - a.ms); - return (0, import_react.createElement)( - "div", - { className: "modal-backdrop", onClick: (event) => { - if (event.target === event.currentTarget) setDurationPanelOpen(false); - } }, - (0, import_react.createElement)( - "div", - { className: "modal wide", role: "dialog", "aria-modal": "true", "aria-labelledby": "ssv-duration-title" }, - (0, import_react.createElement)("div", { className: "modal-head" }, (0, import_react.createElement)("h3", { id: "ssv-duration-title" }, "单任务耗时"), (0, import_react.createElement)("button", { type: "button", className: "modal-close", "aria-label": "关闭", onClick: () => setDurationPanelOpen(false) }, "✕")), - (0, import_react.createElement)("p", { className: "foot-note" }, "按任务从派发到完成的时间累计;进行中任务算到当前时刻。"), - rows.length === 0 ? (0, import_react.createElement)("p", { className: "empty-note" }, "还没有可统计的任务耗时。") : (0, import_react.createElement)("div", { className: "table-card" }, (0, import_react.createElement)("div", { className: "table-scroll" }, (0, import_react.createElement)( - "table", - null, - (0, import_react.createElement)("thead", null, (0, import_react.createElement)("tr", null, ["任务", "承办", "状态", "耗时"].map((label) => (0, import_react.createElement)("th", { key: label, scope: "col" }, label)))), - (0, import_react.createElement)("tbody", null, rows.map((row) => (0, import_react.createElement)( - "tr", - { key: row.task.id }, - (0, import_react.createElement)("td", null, (0, import_react.createElement)("span", { className: "task-name" }, row.task.title)), - (0, import_react.createElement)("td", null, SEATS[row.task.ownerSeatId]?.label || row.task.ownerSeatId || "—"), - (0, import_react.createElement)("td", null, (0, import_react.createElement)("span", { className: "pill " + taskTone(row.task.status) }, (0, import_react.createElement)("i"), taskLabel(row.task.status))), - (0, import_react.createElement)("td", { className: "dur" }, durationText(row.ms)) - ))) - ))) - ) - ); - } - function renderTokenPanel() { - if (!tokenPanelOpen) return null; - return (0, import_react.createElement)( - "div", - { className: "modal-backdrop", onClick: (event) => { - if (event.target === event.currentTarget) setTokenPanelOpen(false); - } }, - (0, import_react.createElement)( - "div", - { className: "modal wide", role: "dialog", "aria-modal": "true", "aria-labelledby": "ssv-token-title" }, - (0, import_react.createElement)("div", { className: "modal-head" }, (0, import_react.createElement)("h3", { id: "ssv-token-title" }, "Token 用量"), (0, import_react.createElement)("button", { type: "button", className: "modal-close", "aria-label": "关闭", onClick: () => setTokenPanelOpen(false) }, "✕")), - (0, import_react.createElement)( - "section", - { className: "stats", style: { marginTop: "16px" }, "aria-label": "Token 统计" }, - (0, import_react.createElement)("div", { className: "stat" }, (0, import_react.createElement)("div", { className: "label" }, "Token 消耗"), (0, import_react.createElement)("div", { className: "big" }, (0, import_react.createElement)("em", null, "—")), (0, import_react.createElement)("div", { className: "foot" }, "待接入宿主 usage 数据")), - (0, import_react.createElement)("div", { className: "stat" }, (0, import_react.createElement)("div", { className: "label" }, "上下文占用"), (0, import_react.createElement)("div", { className: "big" }, (0, import_react.createElement)("em", null, "—")), (0, import_react.createElement)("div", { className: "foot" }, "统计粒度待定:项目 / 会话 / 席位")) - ), - (0, import_react.createElement)( - "section", - { className: "card", style: { marginTop: "18px" }, "aria-label": "Token 接入说明" }, - (0, import_react.createElement)("h3", null, "接入说明"), - (0, import_react.createElement)("p", { className: "foot-note", style: { marginTop: "8px" } }, "当前宿主尚未提供稳定的 usage 数据源,这里先占位,不展示估算值,避免假精确。接入真实用量后会展示 Token 消耗、上下文占用和消耗金额。") - ) - ) - ); - } - function renderArtifactModal() { - if (!artifactFormOpen) return null; - return (0, import_react.createElement)( - "div", - { className: "modal-backdrop", onClick: (event) => { - if (event.target === event.currentTarget) setArtifactFormOpen(false); - } }, - (0, import_react.createElement)( - "div", - { className: "modal", role: "dialog", "aria-modal": "true", "aria-labelledby": "ssv-artifact-title" }, - (0, import_react.createElement)("div", { className: "modal-head" }, (0, import_react.createElement)("h3", { id: "ssv-artifact-title" }, "登记成果"), (0, import_react.createElement)("button", { type: "button", className: "modal-close", "aria-label": "关闭", onClick: () => setArtifactFormOpen(false) }, "✕")), - (0, import_react.createElement)("div", { className: "m-sec" }, (0, import_react.createElement)("span", { className: "t-label" }, "成果名称"), (0, import_react.createElement)("input", { type: "text", value: artifactDraft.title, placeholder: "例如:竞品分析报告 v1", onChange: (event) => setArtifactDraft({ ...artifactDraft, title: event.target.value }) })), - (0, import_react.createElement)("div", { className: "m-sec" }, (0, import_react.createElement)("span", { className: "t-label" }, "文件路径"), (0, import_react.createElement)("input", { type: "text", value: artifactDraft.path, placeholder: "例如:docs/竞品分析.md", onChange: (event) => setArtifactDraft({ ...artifactDraft, path: event.target.value }) })), - (0, import_react.createElement)("div", { className: "m-sec" }, (0, import_react.createElement)("span", { className: "t-label" }, "摘要"), (0, import_react.createElement)("textarea", { rows: 3, value: artifactDraft.summary, placeholder: "这份成果解决了什么、在哪里", onChange: (event) => setArtifactDraft({ ...artifactDraft, summary: event.target.value }) })), - (0, import_react.createElement)("div", { className: "modal-actions" }, (0, import_react.createElement)("button", { type: "button", className: "btn primary", disabled: busy, onClick: addArtifact }, busy ? "提交中…" : "登记"), (0, import_react.createElement)("button", { type: "button", className: "btn", onClick: () => setArtifactFormOpen(false) }, "取消")) - ) - ); - } - function renderTaskDetail() { - if (!selectedTask) return null; - const task = tasks.find((item) => item.id === selectedTask.id) || selectedTask; - const seat = SEATS[task.ownerSeatId]; - const requirement = requirements.find((item) => item.id === task.requirementId && item.revision === task.requirementRevision); - const originalRequirement = task.requirementSnapshot?.originalText || task.requirement || requirement?.originalText; - const taskDescription = task.goal || task.requirement; - const description = taskDescription === originalRequirement ? "" : taskDescription; - const consultations = task.consultations || []; - return (0, import_react.createElement)( - "div", - { className: "modal-backdrop", onClick: (event) => { - if (event.target === event.currentTarget) setSelectedTask(null); - } }, - (0, import_react.createElement)( - "div", - { className: "modal wide", role: "dialog", "aria-modal": "true" }, - (0, import_react.createElement)("div", { className: "modal-head" }, (0, import_react.createElement)("h3", null, task.title), (0, import_react.createElement)("button", { type: "button", className: "modal-close", "aria-label": "关闭", onClick: () => setSelectedTask(null) }, "✕")), - (0, import_react.createElement)("div", { className: "m-from" }, "派工编号:" + (task.id || "—") + " · " + (task.dispatchedAt ? "派发时间 " + dateText(task.dispatchedAt) : "尚未派发")), - originalRequirement ? (0, import_react.createElement)( - "div", - { className: "m-sec" }, - (0, import_react.createElement)("span", { className: "t-label" }, "原始需求"), - (0, import_react.createElement)("p", { className: "task-original-text" }, originalRequirement) - ) : null, - description || !originalRequirement ? (0, import_react.createElement)( - "div", - { className: "m-sec" }, - (0, import_react.createElement)("span", { className: "t-label" }, "任务说明"), - (0, import_react.createElement)("div", { className: "m-rich" }, description ? renderRichText(description) : (0, import_react.createElement)("p", { className: "empty-note" }, "(无任务说明)")) - ) : null, - consultations.length ? (0, import_react.createElement)( - "section", - { className: "m-sec", "aria-label": "会商记录" }, - (0, import_react.createElement)("span", { className: "t-label" }, "会商记录"), - (0, import_react.createElement)("div", { className: "approval-list" }, consultations.map((entry) => (0, import_react.createElement)( - "article", - { className: "approval-item", key: entry.id }, + { className: "frameless-item-head" }, (0, import_react.createElement)( "div", - { className: "req-meta" }, - (0, import_react.createElement)("span", null, (SEATS[entry.fromSeatId]?.label || entry.fromSeatId) + " → " + entry.toSeatIds.map((id) => SEATS[id]?.label || id).join("、")), - (0, import_react.createElement)("span", null, dateText(entry.createdAt)) + { className: "frameless-item-meta" }, + (0, import_react.createElement)("span", { className: "frameless-chip is-pri" }, (0, import_react.createElement)("span", { className: "ss-dot is-primary" }), "项目决定"), + (0, import_react.createElement)("span", { className: "truncate", style: { fontSize: 12, fontWeight: 500 } }, task.title) ), - (0, import_react.createElement)("p", { className: "task-original-text" }, entry.text) - ))) - ) : null, - (0, import_react.createElement)("div", { className: "m-sec" }, (0, import_react.createElement)("span", { className: "t-label" }, "承办与状态"), (0, import_react.createElement)("p", null, "承办席位:" + (seat ? seat.label : task.ownerSeatId) + " · 模型:" + modelLabelOf(task.ownerSeatId) + " · 状态:" + taskLabel(task.status) + (task.deliveryState && task.deliveryState !== "none" ? " · " + deliveryLabel(task.deliveryState) : ""))), - task.workflowBlockage ? (0, import_react.createElement)( - "div", - { className: "m-sec" }, - (0, import_react.createElement)("span", { className: "t-label" }, "当前阻塞"), - (0, import_react.createElement)("p", null, task.workflowBlockage.label + " · " + task.workflowBlockage.reason), - (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: busy, onClick: () => openSeat(task.ownerSeatId) }, "打开" + (seat?.label || "承办席位") + "会话") - ) : null, - (0, import_react.createElement)("div", { className: "m-sec" }, (0, import_react.createElement)("span", { className: "t-label" }, "任务完成情况"), (0, import_react.createElement)("div", { className: "m-rich" }, task.result ? renderRichText(task.result) : (0, import_react.createElement)("p", { className: "empty-note" }, "(暂无结果)"))), - (0, import_react.createElement)("div", { className: "modal-actions" }, (0, import_react.createElement)("button", { type: "button", className: "btn", onClick: () => setSelectedTask(null) }, "关闭")) - ) - ); - } - function renderDeliberations() { - const active = deliberations.find((item) => item.status === "running") || null; - const shownId = delibSelectedId || active?.id || deliberations[0]?.id || null; - const summary = deliberations.find((item) => item.id === shownId) || null; - const full = deliberation && deliberation.id === shownId ? deliberation : null; - const shown = full || summary || null; - const isActive = Boolean(shown && shown.status === "running"); - const seatLabel2 = (id) => SEATS[id] && SEATS[id].label || id || "—"; - const stanceLabel = (stance) => stance === "agree" ? "同意" : stance === "dissent" ? "有分歧" : "未表态"; - const turnLabel = (status) => ({ - waiting: "待叫席", - delivering: "投递中", - delivered: "已叫席", - failed: "叫席失败", - timeout: "未回" - })[status] || "待发言"; - const taskOptions = tasks.filter((task) => task.kind === "workflow" || task.kind === "execution"); - const maxText = shown && shown.maxRounds > 0 ? String(shown.maxRounds) + " 轮" : "不限"; - const missingText = shown && Array.isArray(shown.missing) && shown.missing.length ? "未回:" + shown.missing.map((item) => seatLabel2(item.seatId) + "(第 " + item.round + " 轮 " + (item.reason === "unknown" ? "发送结果未知" : item.reason === "timeout" ? "超时" : "失败") + ")").join(";") : ""; - const startForm = (0, import_react.createElement)( - "section", - { className: "card", "aria-label": "发起议政" }, - (0, import_react.createElement)("h3", null, "发起议政"), - (0, import_react.createElement)("p", { className: "foot-note" }, "三省各派代表,按中书 → 门下 → 尚书轮流发言;后发言者能看到前文。"), - (0, import_react.createElement)( - "label", - { className: "cfg-row", style: { display: "block", marginTop: "10px" } }, - "议题", - (0, import_react.createElement)("textarea", { - rows: 3, - className: "ssv-textarea", - value: delibDraft.topic, - placeholder: "例如:多语言页面首版先做哪些语言?", - onChange: (event) => setDelibDraft((previous) => ({ ...previous, topic: event.target.value })) - }) - ), - (0, import_react.createElement)( - "div", - { className: "cfg-grid", style: { marginTop: "8px" } }, - (0, import_react.createElement)( - "label", - { className: "cfg-row" }, - "关联任务(可选)", - (0, import_react.createElement)( - "select", - { - value: delibDraft.taskId, - onChange: (event) => setDelibDraft((previous) => ({ ...previous, taskId: event.target.value })) - }, - (0, import_react.createElement)("option", { value: "" }, "不关联任务"), - taskOptions.map((task) => (0, import_react.createElement)("option", { key: task.id, value: task.id }, task.id + " · " + task.title)) - ) - ), - (0, import_react.createElement)( - "label", - { className: "cfg-row" }, - "关联需求(可选)", - (0, import_react.createElement)( - "select", - { - value: delibDraft.requirementId, - onChange: (event) => setDelibDraft((previous) => ({ ...previous, requirementId: event.target.value })) - }, - (0, import_react.createElement)("option", { value: "" }, "不关联需求"), - requirements.map((req) => (0, import_react.createElement)("option", { key: req.id, value: req.id }, req.id + " v" + req.revision + " · " + req.title)) - ) - ), - (0, import_react.createElement)( - "label", - { className: "cfg-row" }, - "轮次上限", - (0, import_react.createElement)("input", { - type: "number", - min: 0, - max: 20, - value: delibDraft.maxRounds, - onChange: (event) => setDelibDraft((previous) => ({ ...previous, maxRounds: event.target.value })) - }), - (0, import_react.createElement)("span", { className: "foot-note" }, "默认 3;填 0 表示不限。") - ) - ), - (0, import_react.createElement)( - "div", - { className: "ws-actions" }, - (0, import_react.createElement)( - "button", - { type: "button", className: "btn primary", disabled: delibBusy || Boolean(active), onClick: startDeliberation }, - delibBusy ? "发起中…" : active ? "已有进行中的议政" : "发起议政" - ) - ) - ); - const activeHead = isActive ? (0, import_react.createElement)( - "section", - { className: "card", "aria-label": "当前议政" }, - (0, import_react.createElement)( - "div", - { className: "rc-head" }, - (0, import_react.createElement)("h3", null, shown.topic), - (0, import_react.createElement)("span", { className: "rc-status run" }, (0, import_react.createElement)("i"), "进行中") - ), - (0, import_react.createElement)( - "div", - { className: "req-meta" }, - (0, import_react.createElement)("span", null, "第 " + shown.round + " 轮 / 上限 " + maxText), - (0, import_react.createElement)("span", null, "当前当值:" + (shown.currentSeatLabel || seatLabel2(shown.currentSeatId))), - (0, import_react.createElement)("span", null, "叫席:" + turnLabel(shown.turn && shown.turn.status)), - shown.turn && shown.turn.attempts ? (0, import_react.createElement)("span", null, "第 " + shown.turn.attempts + " 次投递") : null - ), - shown.turn && shown.turn.error ? (0, import_react.createElement)("p", { className: "ssv-banner is-error" }, shown.turn.error) : null, - missingText ? (0, import_react.createElement)("p", { className: "foot-note" }, missingText) : null, - shown.originSessionId ? (0, import_react.createElement)("p", { className: "foot-note" }, "发起会话:" + shown.originSessionId.slice(0, 8)) : null, - shown.turn && ["failed", "timeout"].includes(shown.turn.status) ? (0, import_react.createElement)( - "div", - { className: "ws-actions" }, - (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: delibBusy, onClick: retryDeliberation }, "重试当前席位") - ) : null, - (0, import_react.createElement)( - "div", - { className: "ws-actions", style: { marginTop: "10px" } }, - (0, import_react.createElement)("input", { - type: "text", - value: delibEndNote, - placeholder: "结束或停止说明(可选)", - onChange: (event) => setDelibEndNote(event.target.value), - style: { flex: "1 1 180px" } - }), - (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: delibBusy, onClick: endDeliberation }, "结束并收束"), - (0, import_react.createElement)("button", { - type: "button", - className: "btn", - disabled: delibBusy, - onClick: stopDeliberation, - title: "立刻中断当前席位,不再叫下一位" - }, "立即停止") - ), - (0, import_react.createElement)("p", { className: "foot-note" }, "「结束并收束」按正常流程生成结论;「立即停止」会立刻落状态、中断当前席位,之后不再叫下一位。") - ) : null; - const stoppedHead = shown && shown.status === "stopped" ? (0, import_react.createElement)( - "section", - { className: "card", "aria-label": "已停止的议政" }, - (0, import_react.createElement)( - "div", - { className: "rc-head" }, - (0, import_react.createElement)("h3", null, shown.topic), - (0, import_react.createElement)("span", { className: "rc-status fail" }, (0, import_react.createElement)("i"), "已停止") - ), - (0, import_react.createElement)( - "div", - { className: "req-meta" }, - (0, import_react.createElement)("span", null, "停在第 " + (shown.stoppedTurn?.round ?? shown.round) + " 轮"), - (0, import_react.createElement)("span", null, "停在:" + (shown.stoppedTurn?.seatLabel || seatLabel2(shown.stoppedTurn?.seatId))), - shown.stoppedAt ? (0, import_react.createElement)("span", null, "停止时间:" + new Date(shown.stoppedAt).toLocaleString()) : null - ), - shown.stoppedNote ? (0, import_react.createElement)("p", { className: "foot-note" }, "停止说明:" + shown.stoppedNote) : null, - (0, import_react.createElement)("p", { className: "foot-note" }, "停止后不会再叫下一位;已有发言保留在下方转写。") - ) : null; - const transcript = shown && Array.isArray(shown.speeches) ? shown.speeches : []; - const transcriptBlock = (0, import_react.createElement)( - "section", - { className: "card", "aria-label": "议政转写" }, - (0, import_react.createElement)("h3", null, "议政转写"), - transcript.length === 0 ? (0, import_react.createElement)("p", { className: "empty-note" }, "还没有发言。") : (0, import_react.createElement)("div", { className: "review-list" }, transcript.map((speech) => (0, import_react.createElement)( - "article", - { className: "review-card", key: speech.id }, - (0, import_react.createElement)( - "div", - { className: "rc-head" }, - (0, import_react.createElement)("div", { className: "rc-title" }, seatLabel2(speech.seatId) + " · 第 " + speech.round + " 轮"), - (0, import_react.createElement)( - "span", - { className: "rc-status " + (speech.stance === "agree" ? "done" : speech.stance === "dissent" ? "fail" : "review") }, - (0, import_react.createElement)("i"), - stanceLabel(speech.stance) - ) - ), - (0, import_react.createElement)("p", { className: "card-summary-text", style: { whiteSpace: "pre-wrap" } }, speech.text), - speech.openIssues ? (0, import_react.createElement)("p", { className: "foot-note" }, "未决:" + speech.openIssues) : null, - speech.pending ? (0, import_react.createElement)("p", { className: "foot-note" }, "本席仍有待决问题。") : null - ))) - ); - const conclusionBlock = shown && shown.conclusion ? (0, import_react.createElement)( - "section", - { className: "card", "aria-label": "议政结论" }, - (0, import_react.createElement)("h3", null, "结论"), - (0, import_react.createElement)("p", { className: "card-summary-text", style: { whiteSpace: "pre-wrap" } }, shown.conclusion.text), - (0, import_react.createElement)("p", { className: "foot-note" }, shown.conclusion.needsUserDecision ? "有分歧或未回席位,需要用户决定。" : "三省已一致。") - ) : null; - const history = deliberations.filter((item) => item.status !== "running"); - const historyBlock = (0, import_react.createElement)( - "section", - { className: "card", "aria-label": "历史议政" }, - (0, import_react.createElement)("h3", null, "历史议政"), - history.length === 0 ? (0, import_react.createElement)("p", { className: "empty-note" }, "还没有已收束的议政。") : (0, import_react.createElement)("div", { className: "review-list" }, history.map((item) => (0, import_react.createElement)( - "article", - { - className: "review-card", - key: item.id, - style: { cursor: "pointer" }, - onClick: () => setDelibSelectedId(item.id) - }, - (0, import_react.createElement)( - "div", - { className: "rc-head" }, - (0, import_react.createElement)("div", { className: "rc-title" }, item.topic), - (0, import_react.createElement)("span", { className: "rc-status " + (item.status === "stopped" ? "fail" : "done") }, (0, import_react.createElement)("i"), item.status === "stopped" ? "已停止" : "已收束") - ), - (0, import_react.createElement)("p", { className: "foot-note" }, item.id + " · 第 " + item.round + " 轮 · 发言 " + item.speechCount + " 条" + (item.status === "stopped" && item.stoppedTurn ? " · 停在第 " + item.stoppedTurn.round + " 轮 " + (item.stoppedTurn.seatLabel || seatLabel2(item.stoppedTurn.seatId)) : "")), - item.conclusion ? (0, import_react.createElement)("p", { className: "card-summary-text" }, shortText(item.conclusion.text, 140)) : null - ))) - ); - return (0, import_react.createElement)( - "div", - { className: "page" }, - renderTopbar("三省议政", [ - (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: delibBusy, onClick: () => { - void refreshDeliberations().catch(() => { - }); - } }, "刷新"), - active && shown && shown.id !== active.id ? (0, import_react.createElement)("button", { type: "button", className: "btn primary", onClick: () => setDelibSelectedId(active.id) }, "回到进行中") : null - ]), - startForm, - activeHead, - stoppedHead, - transcriptBlock, - conclusionBlock, - historyBlock - ); - } - function renderChatDeliberations() { - const avatars = view?.project?.avatars ?? {}; - const active = deliberations.find((item) => item.status === "running") || null; - const shownId = delibSelectedId || active?.id || deliberations[0]?.id || null; - const summary = deliberations.find((item) => item.id === shownId) || null; - const full = deliberation && deliberation.id === shownId ? deliberation : null; - const shown = full || summary || null; - const isActive = Boolean(shown && shown.status === "running"); - const currentSeat = isActive ? shown.currentSeatId || shown.turn?.seatId || null : null; - const seatLabel2 = (id) => SEATS[id] && (SEATS[id].name || SEATS[id].label) || id || "—"; - const statusText = !shown ? "还没有议政" : isActive ? "第 " + shown.round + " 轮 · " + (currentSeat ? seatLabel2(currentSeat) + "正在说" : "等待叫席") : shown.status === "stopped" ? "停在第 " + (shown.stoppedTurn?.round ?? shown.round) + " 轮 · " + (shown.stoppedTurn?.seatLabel || seatLabel2(shown.stoppedTurn?.seatId)) : "已收束 · 第 " + shown.round + " 轮"; - const statusTone = isActive ? "run" : shown?.status === "stopped" ? "fail" : "done"; - const statusBar = (0, import_react.createElement)( - "div", - { className: "card", style: { display: "flex", alignItems: "center", gap: 10, padding: "8px 12px", marginBottom: 6 } }, - (0, import_react.createElement)("span", { className: "rc-status " + statusTone }, (0, import_react.createElement)("i"), isActive ? "进行中" : shown?.status === "stopped" ? "已停止" : "已收束"), - (0, import_react.createElement)("span", { style: { fontSize: 13 } }, statusText), - (0, import_react.createElement)("span", { style: { flex: 1 } }), - shown?.id ? (0, import_react.createElement)("span", { className: "foot-note" }, shown.id) : null, - isActive ? (0, import_react.createElement)("button", { - type: "button", - className: "btn", - title: "立刻中断当前席位,不再叫下一位", - style: { height: 24, padding: "0 8px", fontSize: 12 }, - disabled: delibBusy, - onClick: stopDeliberation - }, "停止") : null - ); - const seatRow = (0, import_react.createElement)( - "div", - { style: { display: "flex", gap: 10, alignItems: "center", margin: "2px 0 8px" } }, - DELIB_SEATS.map((seatId) => (0, import_react.createElement)("button", { - key: seatId, - type: "button", - title: "换" + seatLabel2(seatId) + "头像", - style: { - display: "flex", - alignItems: "center", - gap: 6, - background: "none", - border: "none", - cursor: "pointer", - padding: 2, - opacity: !isActive || currentSeat === seatId ? 1 : 0.5 - }, - onClick: () => setAvatarEdit((previous) => previous?.seatId === seatId ? null : { seatId, char: "" }) - }, avatarNode(seatId, avatars, 30, isActive && currentSeat === seatId), (0, import_react.createElement)("span", { style: { fontSize: 12 } }, seatLabel2(seatId)))), - (0, import_react.createElement)("span", { style: { flex: 1 } }), - (0, import_react.createElement)("button", { - type: "button", - className: "btn", - style: { height: 24, padding: "0 8px", fontSize: 12 }, - onClick: () => setDelibSettingsOpen((value) => !value) - }, "设置") - ); - const settings = delibSettingsOpen ? (0, import_react.createElement)( - "div", - { className: "card", style: { padding: 10, marginBottom: 6, display: "flex", gap: 10, flexWrap: "wrap", alignItems: "end" } }, - (0, import_react.createElement)( - "label", - { className: "cfg-row" }, - "轮次上限", - (0, import_react.createElement)("input", { - type: "number", - min: 0, - max: 20, - value: delibDraft.maxRounds, - style: { width: 64 }, - onChange: (event) => setDelibDraft((prev) => ({ ...prev, maxRounds: event.target.value })) - }) - ), - (0, import_react.createElement)( - "label", - { className: "cfg-row" }, - "关联任务", - (0, import_react.createElement)( - "select", - { value: delibDraft.taskId, onChange: (event) => setDelibDraft((prev) => ({ ...prev, taskId: event.target.value })) }, - (0, import_react.createElement)("option", { value: "" }, "不关联"), - tasks.filter((task) => task.kind === "workflow" || task.kind === "execution").map((task) => (0, import_react.createElement)("option", { key: task.id, value: task.id }, task.id + " " + task.title)) - ) - ), - (0, import_react.createElement)( - "label", - { className: "cfg-row" }, - "关联需求", - (0, import_react.createElement)( - "select", - { value: delibDraft.requirementId, onChange: (event) => setDelibDraft((prev) => ({ ...prev, requirementId: event.target.value })) }, - (0, import_react.createElement)("option", { value: "" }, "不关联"), - requirements.map((req) => (0, import_react.createElement)("option", { key: req.id, value: req.id }, req.id + " v" + req.revision + " " + req.title)) - ) - ), - (0, import_react.createElement)("span", { className: "foot-note" }, "默认 3 轮,填 0 表示不限") - ) : null; - const avatarEditor = avatarEdit ? (0, import_react.createElement)( - "div", - { className: "card", style: { padding: 10, marginBottom: 6 } }, - (0, import_react.createElement)( - "div", - { style: { display: "flex", gap: 10, alignItems: "center", flexWrap: "wrap" } }, - avatarNode(avatarEdit.seatId, avatars, 40), - (0, import_react.createElement)( - "label", - { className: "btn", style: { cursor: "pointer" } }, - "选图片", - (0, import_react.createElement)("input", { - type: "file", - accept: "image/png,image/jpeg,image/webp", - style: { display: "none" }, - onChange: (event) => { - const file = event.target.files?.[0]; - if (file) void pickAvatarFile(avatarEdit.seatId, file); - event.target.value = ""; - } - }) - ), - (0, import_react.createElement)("input", { - type: "text", - maxLength: 8, - placeholder: "或填一个字/emoji", - value: avatarEdit.char, - style: { width: 130 }, - onChange: (event) => setAvatarEdit((prev) => ({ ...prev, char: event.target.value })) - }), - (0, import_react.createElement)("button", { type: "button", className: "btn primary", disabled: delibBusy || !avatarEdit.char.trim(), onClick: () => void saveAvatar(avatarEdit.seatId, { char: avatarEdit.char.trim() }) }, "保存字符"), - (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: delibBusy, onClick: () => void saveAvatar(avatarEdit.seatId, { clear: true }) }, "恢复默认"), - (0, import_react.createElement)("span", { style: { flex: 1 } }), - (0, import_react.createElement)("button", { type: "button", className: "btn", onClick: () => setAvatarEdit(null) }, "关闭") - ), - (0, import_react.createElement)("p", { className: "foot-note" }, "图片缩到 256×256 后保存,限 120KB;默认头像沿用席位名。") - ) : null; - const transcript = shown?.speeches ?? []; - const bubbles = transcript.length === 0 ? (0, import_react.createElement)("p", { className: "empty-note", style: { textAlign: "center", padding: "34px 0" } }, "还没开始议政,说一句就能开。") : (0, import_react.createElement)( - "div", - { style: { display: "flex", flexDirection: "column", gap: 12, padding: "6px 2px 10px" } }, - transcript.map((speech) => (0, import_react.createElement)( - "div", - { key: speech.id, style: { display: "flex", gap: 10, alignItems: "flex-start" } }, - avatarNode(speech.seatId, avatars, 32, isActive && currentSeat === speech.seatId), - (0, import_react.createElement)( - "div", - { style: { maxWidth: "78%" } }, + (0, import_react.createElement)("button", { type: "button", className: "frameless-link font-mono-num", onClick: () => setSelectedTask(task) }, task.id) + ), + (0, import_react.createElement)("p", { style: { margin: 0, fontSize: 12, lineHeight: 1.55 } }, decision.question), (0, import_react.createElement)( "div", - { style: { fontSize: 12, color: "#6b7280", marginBottom: 3 } }, - seatLabel2(speech.seatId) + " · 第 " + speech.round + " 轮" + (speech.stance === "dissent" ? " · 有分歧" : speech.pending ? " · 仍有待决" : "") - ), - (0, import_react.createElement)("div", { - style: { - background: speech.seatId === "zhongshu" ? "#eef2ff" : speech.seatId === "menxia" ? "#e6fcf5" : "#fff4e6", - borderRadius: 12, - padding: "9px 12px", - fontSize: 14, - lineHeight: 1.65, - whiteSpace: "pre-wrap" - } - }, speech.text), - speech.openIssues ? (0, import_react.createElement)("div", { className: "foot-note", style: { marginTop: 4 } }, "未决:" + speech.openIssues) : null - ) - )) - ); - const stoppedNote = shown?.status === "stopped" ? (0, import_react.createElement)( - "p", - { className: "foot-note", style: { textAlign: "center", padding: "5px 0 8px" } }, - "停在第 " + (shown.stoppedTurn?.round ?? shown.round) + " 轮 · " + (shown.stoppedTurn?.seatLabel || seatLabel2(shown.stoppedTurn?.seatId)) + ",不会再叫下一位。" + (shown.stoppedNote ? " 说明:" + shown.stoppedNote : "") - ) : null; - const conclusion = shown?.conclusion && !isActive ? (0, import_react.createElement)( - "section", - { className: "card", style: { marginTop: 8 } }, - (0, import_react.createElement)("h3", null, "结论"), - (0, import_react.createElement)("p", { className: "card-summary-text", style: { whiteSpace: "pre-wrap" } }, shown.conclusion.text) - ) : null; - const composer = (0, import_react.createElement)( - "div", - { className: "card", style: { display: "flex", gap: 8, alignItems: "center", marginTop: 8, padding: 8 } }, - (0, import_react.createElement)("input", { - type: "text", - value: delibDraft.topic, - placeholder: isActive ? "这一场还在进行,先看他们说完" : "说一句要三省议的事…", - disabled: Boolean(active), - style: { flex: 1, minWidth: 0 }, - onChange: (event) => setDelibDraft((prev) => ({ ...prev, topic: event.target.value })), - onKeyDown: (event) => { - if (event.key === "Enter" && !active) void startDeliberation(); - } - }), - (0, import_react.createElement)( - "button", - { type: "button", className: "btn primary", disabled: delibBusy || Boolean(active) || !delibDraft.topic.trim(), onClick: startDeliberation }, - delibBusy ? "发起中…" : "发起" + { style: { display: "flex", flexWrap: "wrap", gap: 6 }, role: "group", "aria-label": decision.question }, + (decision.options || []).map((opt) => (0, import_react.createElement)("button", { + key: opt.value, + type: "button", + className: "frameless-btn", + disabled: busy, + onClick: () => void answerDecision(task.id, decision.id, opt.value) + }, opt.label)) + ) + )) ) ); - const runsBlock = agentRuns.length ? (0, import_react.createElement)( - "section", - { className: "card", style: { marginTop: 8 } }, - (0, import_react.createElement)("h3", null, "后台子 Agent"), - (0, import_react.createElement)("div", { className: "review-list" }, agentRuns.map((run) => (0, import_react.createElement)( - "div", - { key: run.id, className: "review-card", style: { display: "flex", alignItems: "center", gap: 8 } }, - (0, import_react.createElement)( - "span", - { className: "rc-title", style: { flex: 1, fontSize: 13 } }, - (run.label || run.seatId) + (run.deliberationId ? " · " + run.deliberationId + " 第 " + run.round + " 轮" : "") + (run.kind === "order" && run.brief ? " · " + shortText(run.brief, 36) : "") - ), - (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: delibBusy, onClick: () => void stopAgentRun(run) }, "停止") - ))) - ) : null; - const history = deliberations.filter((item) => item.status !== "running"); - const historyBlock = history.length ? (0, import_react.createElement)( - "section", - { className: "card", style: { marginTop: 8 } }, - (0, import_react.createElement)("h3", null, "历史议政"), - (0, import_react.createElement)("div", { className: "review-list" }, history.slice(0, 6).map((item) => (0, import_react.createElement)( - "button", - { - key: item.id, - type: "button", - className: "review-card", - style: { textAlign: "left", cursor: "pointer" }, - onClick: () => setDelibSelectedId(item.id) - }, - (0, import_react.createElement)("span", { className: "rc-title" }, item.topic), - (0, import_react.createElement)("span", { className: "foot-note" }, item.id + " · " + (item.status === "stopped" ? "已停止" : "已收束") + " · 发言 " + item.speechCount + " 条") - ))) - ) : null; + } + function renderModelControlsForSeat(seatId, onSaveCallback) { + const rec = seatRecMap[seatId] || {}; + const { modelKey, effort, instructions } = seatDraftState(seatId); + const choiceObj = groupedChoices.find((c) => c.value === modelKey) || null; + const extraChoices = modelKey && !choiceObj ? [{ value: modelKey, label: (rec.model?.model || modelKey) + "(目录未列出)", efforts: effort ? [effort] : [] }, ...groupedChoices] : groupedChoices; + const efforts = choiceObj?.efforts || []; + const configured = rec.configuredModel ?? rec.model ?? null; + const sourceLabel = wb.seats.find((s) => s.id === seatId)?.modelSourceLabel || "未选择"; + const syncStatus = rec.modelSync?.status || null; return (0, import_react.createElement)( "div", - { className: "page" }, - renderTopbar("三省议政", [ - (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: delibBusy, onClick: () => { - void refreshDeliberations().catch(() => { - }); - } }, "刷新") - ]), - statusBar, - seatRow, - settings, - avatarEditor, - (0, import_react.createElement)("div", { className: "card", style: { padding: "2px 10px" } }, bubbles, stoppedNote), - composer, - runsBlock, - conclusion, - historyBlock - ); - } - function renderPage() { - if (phase === "loading") return (0, import_react.createElement)("div", { className: "page" }, (0, import_react.createElement)("p", { className: "empty-note" }, "正在载入工作台…")); - if (phase === "no-workspace") return (0, import_react.createElement)("div", { className: "page" }, (0, import_react.createElement)("p", { className: "empty-note" }, "请先在宿主中选择或建立一个项目工作区,再打开三省六部工作台。")); - if (phase === "error" && !view) return (0, import_react.createElement)("div", { className: "page" }, (0, import_react.createElement)("p", { className: "ssv-banner is-error", role: "alert" }, error || "工作台加载失败"), errorRetryable ? (0, import_react.createElement)("div", { className: "ws-actions" }, (0, import_react.createElement)("button", { type: "button", className: "btn primary", onClick: loadProject }, "重试")) : null); - if (page === "deliberations") return renderChatDeliberations(); - if (tab === "memory") return renderMemory(); - if (tab === "settings") return renderSettings(); - return renderOverview(); - } - return (0, import_react.createElement)( - "div", - { className: "ssv2 ssw-tab-body" }, - (0, import_react.createElement)( - "div", - { className: "main" }, + { style: { display: "flex", flexDirection: "column", gap: 10 } }, (0, import_react.createElement)( "div", - { className: "panel-top" }, - (0, import_react.createElement)("div", { className: "brand" }, (0, import_react.createElement)("span", { className: "seal" }, "三省六部"), (0, import_react.createElement)("span", { className: "sub" }, "DSH 工作台")), - tab !== "overview" || page !== "overview" ? (0, import_react.createElement)( - "div", - { className: "panel-actions" }, - (0, import_react.createElement)("button", { type: "button", className: "btn" + (page === "overview" && tab === "overview" ? " primary" : ""), onClick: () => { - setPage("overview"); - setTab("overview"); - } }, "概览"), - (0, import_react.createElement)("button", { type: "button", className: "btn" + (page === "deliberations" ? " primary" : ""), onClick: () => setPage("deliberations") }, "议政"), - tab !== "overview" ? (0, import_react.createElement)("button", { type: "button", className: "btn", onClick: () => setTab("overview") }, "← 总览") : null - ) : (0, import_react.createElement)( - "div", - { className: "panel-actions" }, - (0, import_react.createElement)("button", { type: "button", className: "btn primary", onClick: () => { - setPage("overview"); - setTab("overview"); - } }, "概览"), - (0, import_react.createElement)("button", { type: "button", className: "btn", onClick: () => setPage("deliberations") }, "议政") + { className: "kv-grid-2" }, + (0, import_react.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4, fontSize: 12 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "主任模型"), + (0, import_react.createElement)( + "select", + { + className: "wb-select", + value: modelKey, + onChange: (e) => { + const nextKey = e.target.value; + const nextChoice = groupedChoices.find((c) => c.value === nextKey); + const nextEffort = nextChoice?.efforts?.includes(effort) ? effort : nextChoice?.efforts?.[0] || ""; + updateSeatDraftModel(seatId, nextKey, nextEffort); + } + }, + (0, import_react.createElement)("option", { value: "" }, UNCHOSEN_MODEL_LABEL), + extraChoices.map((opt) => (0, import_react.createElement)("option", { key: opt.value, value: opt.value }, opt.label)) + ) + ), + (0, import_react.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4, fontSize: 12 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "推理等级"), + (0, import_react.createElement)( + "select", + { + className: "wb-select", + value: effort, + disabled: efforts.length === 0, + onChange: (e) => updateSeatDraftModel(seatId, modelKey, e.target.value) + }, + (0, import_react.createElement)("option", { value: "" }, efforts.length === 0 ? "默认(固定)" : "默认"), + efforts.map((ef) => (0, import_react.createElement)("option", { key: ef, value: ef }, ef)) + ) ) ), - statusBanner, - renderPage(), (0, import_react.createElement)( "div", - { className: "project-dock" }, + { className: "kv-box", style: { display: "flex", flexDirection: "column", gap: 4, fontSize: 12 } }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", gap: 8 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "配置来源"), + (0, import_react.createElement)("span", { className: "ss-pill" + (rec.modelSource === "project" ? " is-primary" : "") }, sourceLabel) + ), + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", gap: 8 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "当前会话模型"), + (0, import_react.createElement)("span", { className: "font-mono-num" }, rec.sessionModel ? rec.sessionModel.provider + "/" + rec.sessionModel.model : configured ? shortModelName(configured) : "未绑定会话") + ), + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", gap: 8 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "同步状态"), + (0, import_react.createElement)( + "span", + { style: { color: syncStatus === "failed" ? "var(--ss-error)" : syncStatus === "synced" ? "var(--ss-success)" : "var(--ss-muted)" } }, + syncStatus === "synced" ? "已同步" : syncStatus === "failed" ? "同步失败" + (rec.modelSync?.error ? " · " + rec.modelSync.error : "") : "待开启或待同步" + ) + ) + ), + (0, import_react.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4, fontSize: 12 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "角色补充说明(仅对本席生效)"), + (0, import_react.createElement)("textarea", { + rows: 3, + className: "wb-textarea", + value: instructions, + placeholder: "追加给该席位的项目级补充约束…", + onChange: (e) => setDraft((prev) => updateDraft(prev, seatId, { instructions: e.target.value })) + }) + ), + (0, import_react.createElement)( + "div", + { style: { display: "flex", flexWrap: "wrap", gap: 8 } }, + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-primary", disabled: busy, onClick: () => void onSaveCallback(seatId) }, busy ? "保存中…" : "保存配置"), + configured ? (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: busy, onClick: () => void setGlobalDefaultFor(seatId) }, "设为全局默认") : null, + rec.modelSource === "project" ? (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: busy, onClick: () => void clearOverrideFor(seatId) }, "恢复继承") : null, + syncStatus === "failed" || syncStatus === "unresolved" ? (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: busy, onClick: () => void retrySyncFor(seatId) }, "重试同步") : null + ) + ); + } + function renderCourtTab() { + const lead = seatById.lead; + const leadTone = seatTone(lead); + const leadSelected = selectedSeatId === "lead"; + const leadLatest = latestTaskOf("lead"); + const filterMatch = (seat) => { + if (seatFilter === "running") return seat.runtimeState === "running"; + if (seatFilter === "attention") return seat.status === "missing" || seat.status === "failed" || seat.modelSyncStatus === "failed" || seat.approvalState === "waiting"; + if (seatFilter === "pending") return seat.status === "pending"; + return true; + }; + const renderSeatCard = (seatId, tier) => { + const seat = seatById[seatId]; + const tone = seatTone(seat); + const selected = selectedSeatId === seatId; + const isLive = activeChatSeatId === seatId; + const dimmed = !filterMatch(seat); + const latest = latestTaskOf(seatId); + const modelShort = shortModelName(seatRecMap[seatId]?.configuredModel ?? seatRecMap[seatId]?.model ?? null); + return (0, import_react.createElement)( + "button", + { + key: seatId, + type: "button", + "aria-pressed": selected, + className: "seat-card" + (tier === "sansheng" ? " is-sansheng" : " is-liubu") + (selected ? " is-selected" : "") + (dimmed ? " is-dimmed" : ""), + onClick: () => selectSeat(seatId) + }, + (0, import_react.createElement)( + "div", + null, + (0, import_react.createElement)( + "div", + { className: "seat-head" }, + (0, import_react.createElement)( + "span", + { className: "seat-title-wrap" }, + (0, import_react.createElement)("span", { className: "seat-name" }, seat.name), + isLive ? (0, import_react.createElement)("span", { className: "seat-live-tag" }, "对话中") : null + ), + (0, import_react.createElement)( + "span", + { className: "seat-status-text" + (tone === "error" ? " is-error" : tone === "success" ? " is-success" : "") }, + (0, import_react.createElement)("span", { className: "ss-dot is-" + tone + (tone === "success" ? " is-pulse" : "") }), + seatStatusText(seat) + ) + ), + (0, import_react.createElement)("div", { className: "seat-duty" }, seat.duty) + ), + (0, import_react.createElement)( + "div", + { className: "seat-footer" }, + (0, import_react.createElement)( + "span", + { className: "seat-task-title", style: { color: latest ? "var(--ss-fg)" : "var(--ss-muted)" } }, + latest ? latest.title : seat.status === "bound" ? "空闲待命" : "点击按需开启" + ), + (0, import_react.createElement)("span", { className: "seat-model-tag hide-narrow" }, modelShort === "未选模型" ? "—" : modelShort) + ) + ); + }; + const sel = wb.selected; + const selSeat = seatById[sel.id]; + const selTone = seatTone(selSeat); + const selTasks = tasks.filter((t) => t.ownerSeatId === sel.id && t.status !== "cancelled").sort((a, b) => Number(b.updatedAt || b.createdAt || 0) - Number(a.updatedAt || a.createdAt || 0)); + const todayCutoff = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0); + const selToday = selTasks.filter((t) => Number(t.createdAt) >= todayCutoff); + const selTodayDone = selToday.filter((t) => t.status === "done"); + const selLatest = selTasks[0] || null; + const actionLabel = sel.status === "bound" ? "开始对话" : sel.status === "missing" ? "重建会话" : "开启「" + sel.name + "」"; + const actionHandler = sel.status === "bound" ? () => void openSeat(sel.id) : sel.status === "missing" ? () => void rebuildSeat(sel.id) : () => void enableSeat(sel.id); + return [ + (0, import_react.createElement)( + "section", + { key: "telemetry", className: "telemetry-strip", "aria-label": "项目运行摘要" }, + (0, import_react.createElement)( + "div", + { className: "telemetry-group" }, + (0, import_react.createElement)( + "span", + { className: "telemetry-item" }, + (0, import_react.createElement)("span", { className: "ss-dot " + (runningSeatsCount > 0 ? "is-success is-pulse" : "is-muted") }), + (0, import_react.createElement)("strong", { className: "font-mono-num" }, wb.project.boundCount + "/10"), + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "在册") + ), + (0, import_react.createElement)( + "button", + { type: "button", onClick: () => { + setTab("flow"); + setFlowSubTab("tasks"); + } }, + (0, import_react.createElement)("strong", { className: "font-mono-num", style: { color: reviewCount > 0 ? "var(--ss-primary)" : "inherit" } }, String(reviewCount)), + " ", + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "待复核") + ), + (0, import_react.createElement)( + "button", + { type: "button", onClick: () => { + setTab("flow"); + setFlowSubTab("queue"); + setQueueSearch("失败"); + } }, + (0, import_react.createElement)("strong", { className: "font-mono-num", style: { color: anomalyCount > 0 ? "var(--ss-error)" : "inherit" } }, String(anomalyCount)), + " ", + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "异常") + ) + ), (0, import_react.createElement)( "button", - { type: "button", className: "proj", "aria-label": "当前项目", onClick: () => setTab("settings") }, - (0, import_react.createElement)("span", { className: "dot" }), - (0, import_react.createElement)("span", null, (0, import_react.createElement)("span", { className: "name" }, wb.project.name || wb.projectTitle || "当前项目"), (0, import_react.createElement)("br"), (0, import_react.createElement)("span", { className: "meta" }, "主项目 · " + wb.project.seatCount + " 席")), - (0, import_react.createElement)("span", { className: "ssv-proj-caret" }, "⌄") + { type: "button", className: "font-mono-num", style: { color: "var(--ss-muted)" }, onClick: () => setDurationModalOpen(true) }, + projectDurationMs > 0 ? durationText(projectDurationMs) : "—" + ) + ), + renderPendingZone(), + (0, import_react.createElement)( + "div", + { key: "split", className: "court-split" }, + (0, import_react.createElement)( + "section", + { style: { display: "flex", flexDirection: "column", gap: 12 }, "aria-label": "十席谱系" }, + (0, import_react.createElement)( + "div", + { className: "court-head" }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 8 } }, + (0, import_react.createElement)("h2", { className: "court-title" }, "十席谱系"), + (0, import_react.createElement)("span", { style: { fontSize: 12, color: "var(--ss-muted)" } }, "点击席位查看详情") + ), + (0, import_react.createElement)( + "div", + { className: "seg-group" }, + [ + { id: "all", label: "全部" }, + { id: "running", label: "运行中" }, + { id: "attention", label: "需关注" }, + { id: "pending", label: "未开启" } + ].map((f) => (0, import_react.createElement)("button", { + key: f.id, + type: "button", + className: "seg-btn" + (seatFilter === f.id ? " is-active" : ""), + onClick: () => setSeatFilter(f.id) + }, f.label)) + ) + ), + (0, import_react.createElement)( + "div", + { className: "lead-card" + (leadSelected ? " is-selected" : "") }, + (0, import_react.createElement)( + "button", + { type: "button", className: "lead-select-btn", onClick: () => selectSeat("lead") }, + (0, import_react.createElement)("span", { className: "lead-seal" }, "相"), + (0, import_react.createElement)( + "div", + { style: { minWidth: 0, flex: "1 1 auto" } }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 8 } }, + (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 15, color: leadSelected ? "var(--ss-primary)" : "var(--ss-fg)" } }, "丞相"), + (0, import_react.createElement)( + "span", + { className: "ss-pill is-" + leadTone }, + (0, import_react.createElement)("span", { className: "ss-dot is-" + leadTone + (leadTone === "success" ? " is-pulse" : "") }), + seatStatusText(lead) + ), + (0, import_react.createElement)("span", { className: "hide-narrow", style: { fontSize: 12, color: "var(--ss-muted)" } }, "总协调 · 需求入口") + ), + (0, import_react.createElement)( + "p", + { className: "truncate", style: { margin: "2px 0 0", fontSize: 12, color: "var(--ss-muted)" } }, + leadLatest ? leadLatest.result || leadLatest.title : SEATS.lead.duty + ) + ) + ), + (0, import_react.createElement)("button", { + type: "button", + className: "wb-btn-outline", + disabled: busy || lead.status === "creating", + onClick: () => lead.status === "bound" ? void openSeat("lead") : void enableSeat("lead") + }, lead.status === "bound" ? "进入对话" : "开启丞相") + ), + (0, import_react.createElement)( + "div", + { style: { display: "flex", flexDirection: "column", gap: 6 } }, + (0, import_react.createElement)("div", { className: "tier-divider" }, (0, import_react.createElement)("strong", null, "三省"), (0, import_react.createElement)("span", null, "中书拟案 → 门下审核 → 尚书调度"), (0, import_react.createElement)("span", { className: "tier-line" })), + (0, import_react.createElement)("div", { className: "sansheng-grid" }, SANSHENG_ORDER.map((id) => renderSeatCard(id, "sansheng"))) + ), + (0, import_react.createElement)( + "div", + { style: { display: "flex", flexDirection: "column", gap: 6 } }, + (0, import_react.createElement)("div", { className: "tier-divider" }, (0, import_react.createElement)("strong", null, "六部"), (0, import_react.createElement)("span", null, "尚书统筹 · 同级并行交付"), (0, import_react.createElement)("span", { className: "tier-line" })), + (0, import_react.createElement)("div", { className: "liubu-grid" }, LIUBU_ORDER.map((id) => renderSeatCard(id, "liubu"))) + ) + ), + (0, import_react.createElement)( + "aside", + { className: "inspector-card", "aria-label": "席位检视面板" }, + (0, import_react.createElement)( + "div", + { className: "inspector-head" }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 } }, + (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 20, color: "var(--ss-primary)", lineHeight: 1 } }, sel.name), + (0, import_react.createElement)("span", { className: "ss-pill is-" + selTone }, seatStatusText(selSeat)), + (0, import_react.createElement)("span", { style: { fontSize: 12, color: "var(--ss-muted)" } }, seatKind(sel.id)) + ), + (0, import_react.createElement)("button", { + type: "button", + className: "wb-btn-primary", + disabled: busy || sel.status === "creating", + onClick: actionHandler + }, ChatIcon(), (0, import_react.createElement)("span", null, actionLabel)) + ), + (0, import_react.createElement)( + "div", + { className: "inspector-subtabs" }, + (0, import_react.createElement)("button", { type: "button", className: "inspector-subtab" + (inspectorTab === "overview" ? " is-active" : ""), onClick: () => setInspectorTab("overview") }, "概览与任务"), + (0, import_react.createElement)( + "button", + { type: "button", className: "inspector-subtab" + (inspectorTab === "config" ? " is-active" : ""), onClick: () => setInspectorTab("config") }, + "模型与指令" + (sel.modelSyncStatus === "failed" ? " · 异常" : "") + ) + ), + (0, import_react.createElement)( + "div", + { className: "inspector-body" }, + inspectorTab === "config" ? renderModelControlsForSeat(sel.id, saveSeatConfigFor) : [ + (0, import_react.createElement)( + "div", + { key: "kv", className: "kv-grid-2" }, + (0, import_react.createElement)( + "div", + { className: "kv-box" }, + (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)" } }, "主任模型"), + (0, import_react.createElement)("div", { className: "font-mono-num truncate", style: { fontWeight: 500, marginTop: 2 } }, sel.modelLabel), + (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)", marginTop: 2 } }, sel.modelSourceLabel) + ), + (0, import_react.createElement)( + "div", + { className: "kv-box" }, + (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)" } }, "会话绑定"), + (0, import_react.createElement)( + "div", + { className: "font-mono-num", style: { fontWeight: 500, marginTop: 2, color: sel.status === "missing" ? "var(--ss-error)" : "var(--ss-fg)" } }, + sel.status === "missing" ? "会话已缺失" : sel.sessionId ? sel.sessionId.slice(0, 10) : "尚未建立" + ), + (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)", marginTop: 2 } }, "本日 " + selToday.length + " 条 · 完 " + selTodayDone.length) + ) + ), + sel.status === "missing" ? (0, import_react.createElement)( + "div", + { key: "miss", className: "wb-alert" }, + (0, import_react.createElement)("span", null, "原会话在宿主中已不存在,重建后保留旧任务历史。"), + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: busy, onClick: () => void rebuildSeat(sel.id) }, "重建会话") + ) : null, + sel.modelSyncStatus === "failed" ? (0, import_react.createElement)( + "div", + { key: "fail", className: "wb-alert" }, + (0, import_react.createElement)("span", null, "模型同步失败:" + (sel.modelSync?.error || "未知原因")), + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: busy, onClick: () => void retrySyncFor(sel.id) }, "重试同步") + ) : null, + (0, import_react.createElement)( + "div", + { key: "resp", style: { borderRadius: 8, border: "1px solid var(--ss-border)", padding: 12, display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react.createElement)("div", { style: { fontWeight: 500, color: "var(--ss-muted)" } }, "最近动态与职责"), + (0, import_react.createElement)("p", { style: { margin: 0, lineHeight: 1.55 } }, selLatest && (selLatest.result || selLatest.note) || sel.responsibility), + selLatest ? (0, import_react.createElement)("p", { style: { margin: "4px 0 0", paddingTop: 6, borderTop: "1px dashed var(--ss-border)", color: "var(--ss-muted)" } }, "职责:" + sel.responsibility) : null + ), + sel.id === "shangshu" ? (0, import_react.createElement)("button", { + key: "ss", + type: "button", + className: "frameless-btn", + style: { width: "100%", padding: "8px 12px", borderRadius: 8 }, + disabled: summaryBusy || busy, + onClick: () => void summarizeByShangshu() + }, summaryBusy ? "正在通知尚书汇总…" : "请尚书汇总当前项目任务进度 →") : null, + sel.id === "lead" ? (0, import_react.createElement)("button", { + key: "reqjump", + type: "button", + className: "frameless-btn", + style: { width: "100%", padding: "8px 12px", borderRadius: 8 }, + onClick: () => { + setTab("flow"); + setFlowSubTab("requirements"); + } + }, "前往「流转 · 需求清单」查看 " + requirements.length + " 条需求 →") : null, + (0, import_react.createElement)( + "div", + { key: "recent", style: { display: "flex", flexDirection: "column", gap: 6 } }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, + (0, import_react.createElement)("span", { style: { fontWeight: 500, color: "var(--ss-muted)" } }, "本席近期任务 (" + selTasks.length + ")"), + selTasks.length > 0 ? (0, import_react.createElement)("button", { type: "button", className: "frameless-link", onClick: () => { + setTab("flow"); + setFlowSubTab("queue"); + } }, "查看全部") : null + ), + selTasks.length === 0 ? (0, import_react.createElement)("div", { className: "wb-empty-box" }, "该席位暂无任务记录。") : selTasks.slice(0, 3).map((t) => { + const tm = TASK_META[t.status] || { label: t.status, tone: "muted" }; + return (0, import_react.createElement)( + "button", + { + key: t.id, + type: "button", + className: "wb-card", + style: { textAlign: "left", padding: 10 }, + onClick: () => setSelectedTask(t) + }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, + (0, import_react.createElement)("span", { className: "truncate", style: { fontWeight: 500 } }, t.title), + (0, import_react.createElement)("span", { className: "ss-pill is-" + tm.tone }, tm.label) + ), + (0, import_react.createElement)( + "p", + { className: "line-clamp-2", style: { margin: 0, color: "var(--ss-muted)" } }, + t.workflowBlockage ? t.workflowBlockage.reason : t.result || t.goal || t.requirement || "(暂无说明)" + ) + ); + }) + ) + ] + ) ) ) + ]; + } + function renderStageStepper(stage) { + const idx = WORKFLOW_STAGES.findIndex((s) => s.id === stage); + return (0, import_react.createElement)( + "div", + { className: "stage-stepper" }, + WORKFLOW_STAGES.map((st, i) => { + const done = idx >= 0 && i < idx; + const cur = idx >= 0 && i === idx; + return (0, import_react.createElement)( + "span", + { key: st.id, style: { display: "inline-flex", alignItems: "center", gap: 4, flexShrink: 0 } }, + (0, import_react.createElement)("span", { className: "stage-step-pill" + (done ? " is-done" : cur ? " is-cur" : "") }, st.label), + i < WORKFLOW_STAGES.length - 1 ? (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)", fontSize: 12 } }, "→") : null + ); + }), + stage === "reconfirm" ? (0, import_react.createElement)("span", { className: "ss-pill is-error" }, "阻塞 · 待重确认") : null + ); + } + function renderFlowTab() { + const wfTasks = tasks.filter((t) => t.kind === "workflow" || t.kind === "execution"); + const deliveries = tasks.filter((t) => t.stage === "delivered" || t.status === "done"); + const q = queueSearch.trim().toLowerCase(); + const filteredQueue = tasks.filter((t) => { + if (!q) return true; + const sName = SEATS[t.ownerSeatId]?.label || ""; + const tmLabel = TASK_META[t.status]?.label || ""; + return [t.id, t.title, sName, tmLabel, t.goal, t.result].filter(Boolean).join(" ").toLowerCase().includes(q); + }); + const subTabs = [ + { id: "tasks", label: "流转任务", count: wfTasks.length }, + { id: "requirements", label: "需求清单", count: requirements.length }, + { id: "queue", label: "派工队列", count: tasks.length }, + { id: "delivery", label: "交付结果", count: deliveries.length } + ]; + let body = null; + if (flowSubTab === "requirements") { + body = requirements.length === 0 ? (0, import_react.createElement)("div", { className: "wb-empty-box" }, "暂无需求条目。与丞相在对话中明确需求后将整理至此。") : (0, import_react.createElement)("div", { style: { display: "flex", flexDirection: "column", gap: 10 } }, requirements.map((req) => { + const rm = REQ_STATUS_META[req.status] || { label: req.status, tone: "muted" }; + return (0, import_react.createElement)( + "article", + { className: "wb-card", key: req.id }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", gap: 8 } }, + (0, import_react.createElement)( + "div", + { style: { minWidth: 0 } }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 8 } }, + (0, import_react.createElement)("span", { className: "font-mono-num", style: { fontWeight: 600, color: "var(--ss-primary)" } }, req.id + " · v" + req.revision), + (0, import_react.createElement)("span", { className: "ss-pill is-" + rm.tone }, rm.label), + req.judgement ? (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "丞相:" + (REQ_JUDGEMENT_LABELS[req.judgement] || req.judgement)) : null + ), + (0, import_react.createElement)("h3", { style: { margin: "4px 0 0", fontSize: 13, fontWeight: 600 } }, req.title) + ), + (0, import_react.createElement)("button", { + type: "button", + className: "wb-btn-outline", + onClick: () => { + try { + void navigator.clipboard?.writeText?.(req.id); + } catch { + } + setNotice("已复制需求编号:" + req.id); + } + }, "复制编号") + ), + req.summary ? (0, import_react.createElement)("p", { style: { margin: 0, lineHeight: 1.55 } }, req.summary) : null, + req.blockedReason ? (0, import_react.createElement)("div", { className: "wb-alert" }, "阻塞:" + req.blockedReason) : null, + (0, import_react.createElement)( + "details", + { style: { borderRadius: 8, background: "var(--ss-subtle)", border: "1px solid var(--ss-border)", padding: "6px 10px" } }, + (0, import_react.createElement)("summary", { style: { cursor: "pointer", color: "var(--ss-muted)", fontWeight: 500 } }, "展开范围、验收标准与待补信息"), + (0, import_react.createElement)( + "dl", + { style: { margin: "8px 0 0", paddingTop: 8, borderTop: "1px solid var(--ss-border)", display: "grid", gap: 6 } }, + (0, import_react.createElement)("div", null, (0, import_react.createElement)("dt", { style: { color: "var(--ss-muted)" } }, "用户原话"), (0, import_react.createElement)("dd", { style: { margin: "2px 0 0" } }, req.originalText || "—")), + (0, import_react.createElement)("div", null, (0, import_react.createElement)("dt", { style: { color: "var(--ss-muted)" } }, "范围"), (0, import_react.createElement)("dd", { style: { margin: "2px 0 0" } }, req.scope || "—")), + (0, import_react.createElement)("div", null, (0, import_react.createElement)("dt", { style: { color: "var(--ss-muted)" } }, "非目标"), (0, import_react.createElement)("dd", { style: { margin: "2px 0 0" } }, req.nonGoals || "—")), + (0, import_react.createElement)("div", null, (0, import_react.createElement)("dt", { style: { color: "var(--ss-muted)" } }, "验收标准"), (0, import_react.createElement)("dd", { style: { margin: "2px 0 0" } }, req.acceptanceCriteria || "—")), + req.risks ? (0, import_react.createElement)("div", null, (0, import_react.createElement)("dt", { style: { color: "var(--ss-muted)" } }, "风险"), (0, import_react.createElement)("dd", { style: { margin: "2px 0 0" } }, req.risks)) : null, + req.missingInfo ? (0, import_react.createElement)("div", null, (0, import_react.createElement)("dt", { style: { color: "var(--ss-muted)" } }, "待补信息"), (0, import_react.createElement)("dd", { style: { margin: "2px 0 0" } }, req.missingInfo)) : null + ) + ) + ); + })); + } else if (flowSubTab === "queue") { + body = (0, import_react.createElement)( + "div", + { className: "wb-card", style: { padding: 0, overflow: "hidden", gap: 0 } }, + (0, import_react.createElement)( + "div", + { style: { padding: 10, borderBottom: "1px solid var(--ss-border)", display: "flex", flexWrap: "wrap", gap: 8, alignItems: "center" } }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 6, flex: "1 1 150px", border: "1px solid var(--ss-border)", borderRadius: 8, background: "var(--ss-bg)", padding: "5px 10px" } }, + SearchIcon(), + (0, import_react.createElement)("input", { + type: "search", + value: queueSearch, + placeholder: "按任务、席位、状态筛选…", + style: { width: "100%", border: 0, background: "transparent", outline: "none", fontSize: 12 }, + onChange: (e) => setQueueSearch(e.target.value) + }) + ), + (0, import_react.createElement)("button", { type: "button", className: "frameless-btn", disabled: summaryBusy || busy, onClick: () => void summarizeByShangshu() }, summaryBusy ? "汇总中…" : "尚书汇总"), + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: busy, onClick: () => void reloadTasks() }, "刷新") + ), + filteredQueue.length === 0 ? (0, import_react.createElement)("div", { style: { padding: 28, textAlign: "center", color: "var(--ss-muted)" } }, "没有匹配的派工记录。") : (0, import_react.createElement)( + "div", + { style: { overflowX: "auto" } }, + (0, import_react.createElement)( + "table", + { className: "queue-table" }, + (0, import_react.createElement)("thead", null, (0, import_react.createElement)( + "tr", + null, + (0, import_react.createElement)("th", null, "任务"), + (0, import_react.createElement)("th", null, "席位"), + (0, import_react.createElement)("th", null, "状态"), + (0, import_react.createElement)("th", { className: "col-dur" }, "耗时"), + (0, import_react.createElement)("th", { className: "col-time" }, "派发时间") + )), + (0, import_react.createElement)("tbody", null, filteredQueue.map((t) => { + const tm = TASK_META[t.status] || { label: t.status, tone: "muted" }; + return (0, import_react.createElement)( + "tr", + { key: t.id, className: "is-click", onClick: () => setSelectedTask(t) }, + (0, import_react.createElement)("td", null, (0, import_react.createElement)("div", { style: { fontWeight: 500 } }, t.title), (0, import_react.createElement)("div", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, t.id)), + (0, import_react.createElement)("td", { className: "font-seal", style: { fontWeight: 700, whiteSpace: "nowrap" } }, SEATS[t.ownerSeatId]?.label || "—"), + (0, import_react.createElement)("td", null, (0, import_react.createElement)("span", { className: "ss-pill is-" + tm.tone }, tm.label)), + (0, import_react.createElement)("td", { className: "col-dur font-mono-num", style: { color: "var(--ss-muted)", whiteSpace: "nowrap" } }, durationText(taskDurationMs(t))), + (0, import_react.createElement)("td", { className: "col-time font-mono-num", style: { color: "var(--ss-muted)", whiteSpace: "nowrap" } }, dateText(t.dispatchedAt)) + ); + })) + ) + ) + ); + } else if (flowSubTab === "delivery") { + body = deliveries.length === 0 ? (0, import_react.createElement)("div", { className: "wb-empty-box" }, "还没有已交付结果。") : (0, import_react.createElement)("div", { style: { display: "flex", flexDirection: "column", gap: 10 } }, deliveries.map((t) => { + const children = tasks.filter((c) => c.parentTaskId === t.id && c.kind === "execution"); + return (0, import_react.createElement)( + "article", + { className: "wb-card", key: t.id }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: 8 } }, + (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 13, fontWeight: 600 } }, t.title), + (0, import_react.createElement)("span", { className: "ss-pill is-success" }, "已交付") + ), + (0, import_react.createElement)( + "div", + { className: "font-mono-num", style: { display: "flex", flexWrap: "wrap", gap: 8, color: "var(--ss-muted)" } }, + (0, import_react.createElement)("span", null, t.id), + (0, import_react.createElement)("span", null, "承办:" + (SEATS[t.ownerSeatId]?.label || "—")), + t.resultSessionId ? (0, import_react.createElement)("span", null, "会话 " + t.resultSessionId.slice(0, 8)) : null, + (0, import_react.createElement)("span", null, "耗时 " + durationText(taskDurationMs(t))) + ), + (0, import_react.createElement)("p", { style: { margin: 0, lineHeight: 1.55, whiteSpace: "pre-wrap" } }, t.deliveryNote || t.result || t.summary || "(暂无交付说明)"), + children.length ? (0, import_react.createElement)( + "div", + { style: { display: "flex", flexDirection: "column", gap: 6, paddingTop: 8, borderTop: "1px dashed var(--ss-border)" } }, + children.map((ch) => (0, import_react.createElement)( + "div", + { key: ch.id, style: { display: "flex", flexWrap: "wrap", gap: 8, alignItems: "center" } }, + (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, SEATS[ch.ownerSeatId]?.label || ch.ownerSeatId), + (0, import_react.createElement)("span", { className: "ss-pill is-" + (TASK_META[ch.status]?.tone || "muted") }, TASK_META[ch.status]?.label || ch.status), + (0, import_react.createElement)("span", { style: { flex: "1 1 120px", color: "var(--ss-muted)" } }, shortText(ch.result || ch.note || "(暂无结果)", 80)), + ch.resultSessionId ? (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, ch.resultSessionId.slice(0, 8)) : null + )) + ) : null + ); + })); + } else { + body = wfTasks.length === 0 ? (0, import_react.createElement)("div", { className: "wb-empty-box" }, "还没有流转任务。丞相下派需求后会出现在这里。") : (0, import_react.createElement)("div", { style: { display: "flex", flexDirection: "column", gap: 10 } }, wfTasks.map((t) => { + const tm = TASK_META[t.status] || { label: t.status, tone: "muted" }; + return (0, import_react.createElement)( + "article", + { + key: t.id, + className: "wb-card", + style: t.workflowBlockage ? { borderColor: "color-mix(in srgb,var(--ss-error) 36%,var(--ss-border))" } : void 0 + }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", gap: 8 } }, + (0, import_react.createElement)( + "div", + { style: { minWidth: 0 } }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: 6 } }, + (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, t.id), + (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, SEATS[t.ownerSeatId]?.label || t.ownerSeatId), + t.requirementId ? (0, import_react.createElement)("span", { className: "ss-pill font-mono-num" }, t.requirementId + " v" + t.requirementRevision) : null, + (0, import_react.createElement)("span", { className: "ss-pill is-" + tm.tone }, tm.label) + ), + (0, import_react.createElement)("h3", { style: { margin: "4px 0 0", fontSize: 13, fontWeight: 600 } }, t.title) + ), + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setSelectedTask(t) }, "查看详情 →") + ), + t.kind === "workflow" ? renderStageStepper(t.stage) : null, + t.workflowBlockage ? (0, import_react.createElement)( + "div", + { className: "wb-alert" }, + (0, import_react.createElement)("span", null, t.workflowBlockage.label + ":" + t.workflowBlockage.reason), + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setSelectedTask(t) }, "处理阻塞") + ) : (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)", lineHeight: 1.55 } }, t.result || t.goal || t.requirement || "(暂无说明)") + ); + })); + } + return [ + (0, import_react.createElement)( + "div", + { key: "subtabs", className: "flow-seg" }, + subTabs.map((st) => (0, import_react.createElement)("button", { + key: st.id, + type: "button", + className: "flow-seg-btn" + (flowSubTab === st.id ? " is-active" : ""), + onClick: () => setFlowSubTab(st.id) + }, st.label + " " + st.count)) + ), + (0, import_react.createElement)("div", { key: "flowbody" }, body) + ]; + } + function renderDeliberationTab() { + const avatars = view?.project?.avatars ?? {}; + const active = deliberations.find((x) => x.status === "running") || null; + const shownId = delibSelectedId || active?.id || deliberations[0]?.id || null; + const summary = deliberations.find((x) => x.id === shownId) || null; + const full = deliberation && deliberation.id === shownId ? deliberation : null; + const shown = full || summary || null; + const isActive = Boolean(shown && shown.status === "running"); + const curSeat = isActive ? shown.currentSeatId || shown.turn?.seatId || null : null; + const speeches = shown?.speeches || []; + return [ + (0, import_react.createElement)( + "section", + { key: "dhead", className: "wb-card" }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", flexWrap: "wrap", alignItems: "center", justifyContent: "space-between", gap: 8 } }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 } }, + (0, import_react.createElement)( + "span", + { className: "ss-pill is-" + (isActive ? "success" : shown?.status === "stopped" ? "error" : "muted") }, + isActive ? "议政进行中" : shown?.status === "stopped" ? "已停止" : shown ? "已收束" : "空闲" + ), + (0, import_react.createElement)( + "span", + { className: "truncate", style: { fontWeight: 500 } }, + shown ? "第 " + shown.round + " / " + (shown.maxRounds > 0 ? shown.maxRounds : "不限") + " 轮" + (curSeat ? " · 当值:" + (SEATS[curSeat]?.label || curSeat) : "") : "发起议题即可启动三省轮流审议" + ) + ), + (0, import_react.createElement)( + "div", + { style: { display: "flex", flexWrap: "wrap", gap: 6 } }, + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setDelibSettingsOpen((v) => !v) }, "议政设置"), + isActive ? [ + (0, import_react.createElement)("button", { key: "end", type: "button", className: "frameless-btn", disabled: delibBusy, onClick: () => void endDeliberation() }, "收束结论"), + (0, import_react.createElement)("button", { key: "stop", type: "button", className: "wb-btn-outline", style: { color: "var(--ss-error)" }, disabled: delibBusy, onClick: () => void stopDeliberation() }, "立即停止") + ] : null + ) + ), + shown ? (0, import_react.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, shown.topic) : null, + (0, import_react.createElement)( + "div", + { style: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: 8 } }, + DELIB_SEATS.map((sid, i) => [ + (0, import_react.createElement)( + "button", + { + key: sid, + type: "button", + title: "点击调整「" + SEATS[sid].label + "」头像", + style: { + display: "inline-flex", + alignItems: "center", + gap: 6, + padding: "5px 8px", + borderRadius: 8, + border: "1px solid " + (curSeat === sid ? "var(--ss-primary)" : "var(--ss-border)"), + background: curSeat === sid ? "color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card))" : "var(--ss-subtle)", + opacity: !isActive || curSeat === sid ? 1 : 0.65 + }, + onClick: () => setAvatarEdit((prev) => prev?.seatId === sid ? null : { seatId: sid, char: "" }) + }, + avatarNode(sid, avatars, 24, curSeat === sid), + (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, SEATS[sid].label), + curSeat === sid ? (0, import_react.createElement)("span", { style: { color: "var(--ss-primary)" } }, "当值") : null + ), + i < 2 ? (0, import_react.createElement)("span", { key: "arr-" + i, style: { color: "var(--ss-muted)" } }, "→") : null + ]), + (0, import_react.createElement)("span", { style: { marginLeft: "auto", color: "var(--ss-muted)" } }, "点击头像可换") + ), + shown?.turn?.error ? (0, import_react.createElement)( + "div", + { className: "wb-alert" }, + (0, import_react.createElement)("span", null, shown.turn.error), + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: delibBusy, onClick: () => void retryDeliberation() }, "重试当前席位") + ) : null, + avatarEdit ? (0, import_react.createElement)( + "div", + { style: { borderRadius: 8, border: "1px solid var(--ss-border)", background: "var(--ss-subtle)", padding: 10, display: "flex", flexWrap: "wrap", alignItems: "center", gap: 8 } }, + avatarNode(avatarEdit.seatId, avatars, 28, false), + (0, import_react.createElement)("span", { style: { fontWeight: 500 } }, SEATS[avatarEdit.seatId].label + "头像:"), + (0, import_react.createElement)( + "label", + { className: "wb-btn-outline", style: { cursor: "pointer" } }, + "选图片", + (0, import_react.createElement)("input", { + type: "file", + accept: "image/png,image/jpeg,image/webp", + style: { display: "none" }, + onChange: (e) => { + const f = e.target.files?.[0]; + if (f) void pickAvatarFile(avatarEdit.seatId, f); + e.target.value = ""; + } + }) + ), + (0, import_react.createElement)("input", { + type: "text", + maxLength: 8, + placeholder: "或填 1 字 / Emoji", + value: avatarEdit.char, + className: "wb-input", + style: { width: 130 }, + onChange: (e) => setAvatarEdit((prev) => ({ ...prev, char: e.target.value })) + }), + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-primary", disabled: delibBusy || !avatarEdit.char.trim(), onClick: () => void saveAvatar(avatarEdit.seatId, { char: avatarEdit.char.trim() }) }, "保存字符"), + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: delibBusy, onClick: () => void saveAvatar(avatarEdit.seatId, { clear: true }) }, "恢复默认"), + (0, import_react.createElement)("button", { type: "button", className: "wb-toast-close", style: { marginLeft: "auto" }, onClick: () => setAvatarEdit(null) }, "关闭") + ) : null, + delibSettingsOpen ? (0, import_react.createElement)( + "div", + { style: { borderRadius: 8, border: "1px solid var(--ss-border)", background: "var(--ss-subtle)", padding: 10, display: "grid", gridTemplateColumns: "repeat(auto-fit,minmax(130px,1fr))", gap: 8 } }, + (0, import_react.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "轮次上限(0 为不限)"), + (0, import_react.createElement)("input", { type: "number", min: 0, max: 20, value: delibDraft.maxRounds, className: "wb-input", onChange: (e) => setDelibDraft((p) => ({ ...p, maxRounds: e.target.value })) }) + ), + (0, import_react.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "关联任务"), + (0, import_react.createElement)( + "select", + { className: "wb-select", value: delibDraft.taskId, onChange: (e) => setDelibDraft((p) => ({ ...p, taskId: e.target.value })) }, + (0, import_react.createElement)("option", { value: "" }, "不关联"), + tasks.map((t) => (0, import_react.createElement)("option", { key: t.id, value: t.id }, t.id + " " + t.title)) + ) + ), + (0, import_react.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "关联需求"), + (0, import_react.createElement)( + "select", + { className: "wb-select", value: delibDraft.requirementId, onChange: (e) => setDelibDraft((p) => ({ ...p, requirementId: e.target.value })) }, + (0, import_react.createElement)("option", { value: "" }, "不关联"), + requirements.map((r) => (0, import_react.createElement)("option", { key: r.id, value: r.id }, r.id + " " + r.title)) + ) + ) + ) : null + ), + (0, import_react.createElement)( + "section", + { key: "transcript", className: "wb-card", "aria-label": "议政转写" }, + speeches.length === 0 ? (0, import_react.createElement)("div", { style: { padding: "28px 0", textAlign: "center", color: "var(--ss-muted)" } }, "尚未开议。在下方输入议题,将按「中书 → 门下 → 尚书」顺序轮流发言。") : speeches.map((sp) => (0, import_react.createElement)( + "div", + { key: sp.id, style: { display: "flex", alignItems: "flex-start", gap: 10 } }, + avatarNode(sp.seatId, avatars, 30, curSeat === sp.seatId), + (0, import_react.createElement)( + "div", + { style: { minWidth: 0, flex: "1 1 auto", display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: 8 } }, + (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, SEATS[sp.seatId]?.label || sp.seatId), + (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, "第 " + sp.round + " 轮"), + (0, import_react.createElement)( + "span", + { className: "ss-pill is-" + (sp.stance === "agree" ? "success" : sp.stance === "dissent" ? "error" : "warning") }, + sp.stance === "agree" ? "赞同" : sp.stance === "dissent" ? "有分歧" : "待决" + ) + ), + (0, import_react.createElement)("div", { className: "speech-bubble speech-" + seatDotTone(sp.seatId) }, sp.text), + sp.openIssues ? (0, import_react.createElement)("div", { style: { color: "var(--ss-error)" } }, "未决:" + sp.openIssues) : null + ) + )), + shown?.conclusion ? (0, import_react.createElement)( + "div", + { style: { borderRadius: 8, border: "1px solid color-mix(in srgb,var(--ss-success) 32%,var(--ss-border))", background: "color-mix(in srgb,var(--ss-success) 7%,var(--ss-card))", padding: 10 } }, + (0, import_react.createElement)("div", { style: { fontWeight: 600, color: "var(--ss-success)" } }, "议政结论"), + (0, import_react.createElement)("p", { style: { margin: "4px 0 0", whiteSpace: "pre-wrap" } }, shown.conclusion.text) + ) : null + ), + (0, import_react.createElement)( + "div", + { key: "composer", className: "wb-card", style: { flexDirection: "row", alignItems: "center", padding: 10 } }, + (0, import_react.createElement)("input", { + type: "text", + value: delibDraft.topic, + disabled: Boolean(active), + placeholder: active ? "当前议政进行中,收束或停止后可发起新议题…" : "输入议题,交由三省轮流审议…", + style: { flex: "1 1 auto", minWidth: 0, border: 0, background: "transparent", outline: "none", padding: "6px 8px", fontSize: 12 }, + onChange: (e) => setDelibDraft((p) => ({ ...p, topic: e.target.value })), + onKeyDown: (e) => { + if (e.key === "Enter" && !active) void startDeliberation(); + } + }), + (0, import_react.createElement)( + "button", + { type: "button", className: "wb-btn-primary", disabled: delibBusy || Boolean(active) || !delibDraft.topic.trim(), onClick: () => void startDeliberation() }, + delibBusy ? "发起中…" : "发起议政" + ) + ), + (0, import_react.createElement)( + "div", + { key: "extras", className: "consensus-grid" }, + (0, import_react.createElement)( + "section", + { className: "wb-card" }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, + (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "后台子 Agent (" + agentRuns.length + ")"), + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "记室 / 主簿 / 接令") + ), + agentRuns.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "当前无运行中的后台子 Agent。") : agentRuns.map((run) => (0, import_react.createElement)( + "div", + { key: run.id, style: { borderRadius: 8, border: "1px solid var(--ss-border)", background: "var(--ss-subtle)", padding: 10, display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, + (0, import_react.createElement)( + "div", + { style: { minWidth: 0 } }, + (0, import_react.createElement)( + "div", + { className: "truncate", style: { fontWeight: 500, display: "flex", alignItems: "center", gap: 6 } }, + (0, import_react.createElement)("span", { className: "ss-dot is-success is-pulse" }), + run.label || run.seatId + ), + run.brief ? (0, import_react.createElement)("div", { className: "truncate", style: { color: "var(--ss-muted)", marginTop: 2 } }, run.brief) : null + ), + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", disabled: delibBusy, onClick: () => void stopAgentRun(run) }, "停止") + )) + ), + (0, import_react.createElement)( + "section", + { className: "wb-card" }, + (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "议政记录 (" + deliberations.length + ")"), + deliberations.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "暂无议政记录。") : deliberations.map((item) => (0, import_react.createElement)( + "button", + { + key: item.id, + type: "button", + className: "wb-card", + style: { + textAlign: "left", + padding: 10, + borderColor: shown?.id === item.id ? "var(--ss-primary)" : "var(--ss-border)", + background: shown?.id === item.id ? "color-mix(in srgb,var(--ss-primary) 6%,var(--ss-card))" : "var(--ss-subtle)" + }, + onClick: () => setDelibSelectedId(item.id) + }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", gap: 8 } }, + (0, import_react.createElement)("span", { className: "truncate", style: { fontWeight: 500 } }, item.topic), + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)", flexShrink: 0 } }, item.status === "running" ? "进行中" : item.status === "stopped" ? "已停止" : "已收束") + ), + (0, import_react.createElement)("div", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, item.id + " · 第 " + item.round + " 轮") + )) + ) + ) + ]; + } + function renderMemoryTab() { + const rev = memory?.revision ?? 0; + const constraints = Array.isArray(memory?.constraints) ? memory.constraints : []; + const acceptance = Array.isArray(memory?.acceptance) ? memory.acceptance : []; + const decisionsList = Array.isArray(memory?.decisions) ? memory.decisions : []; + if (memoryEditing) { + return (0, import_react.createElement)( + "section", + { className: "wb-card" }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, + (0, import_react.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, "编辑项目共识 · 当前 v" + rev), + (0, import_react.createElement)("button", { type: "button", className: "wb-toast-close", onClick: () => setMemoryEditing(false) }, "取消") + ), + (0, import_react.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "项目目标"), + (0, import_react.createElement)("textarea", { rows: 2, className: "wb-textarea", value: memoryDraft.goal, onChange: (e) => setMemoryDraft((m) => ({ ...m, goal: e.target.value })) }) + ), + (0, import_react.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "硬约束(每行一条)"), + (0, import_react.createElement)("textarea", { rows: 4, className: "wb-textarea", value: memoryDraft.constraints, onChange: (e) => setMemoryDraft((m) => ({ ...m, constraints: e.target.value })) }) + ), + (0, import_react.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "验收标准(每行一条)"), + (0, import_react.createElement)("textarea", { rows: 3, className: "wb-textarea", value: memoryDraft.acceptance, onChange: (e) => setMemoryDraft((m) => ({ ...m, acceptance: e.target.value })) }) + ), + (0, import_react.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "追加新决定(每行一条)"), + (0, import_react.createElement)("textarea", { rows: 2, className: "wb-textarea", value: memoryDraft.decisions, placeholder: "可选:记录新增项目级决定", onChange: (e) => setMemoryDraft((m) => ({ ...m, decisions: e.target.value })) }) + ), + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "flex-end", gap: 8 } }, + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setMemoryEditing(false) }, "取消"), + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-primary", disabled: busy, onClick: () => void saveMemory() }, busy ? "保存中…" : "保存为 v" + (rev + 1)) + ) + ); + } + return [ + (0, import_react.createElement)( + "section", + { key: "mhero", className: "wb-card", style: { borderLeft: "3px solid var(--ss-primary)" } }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", flexWrap: "wrap", justifyContent: "space-between", alignItems: "center", gap: 8 } }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 8 } }, + (0, import_react.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, "项目共识"), + (0, import_react.createElement)("span", { className: "ss-pill font-mono-num is-primary" }, "v" + rev) + ), + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setMemoryEditing(true) }, "编辑共识") + ), + (0, import_react.createElement)("p", { style: { margin: 0, lineHeight: 1.6 } }, memory?.goal || "尚未填写项目目标。保存后将自动注入各部门提示词与派工上下文。") + ), + (0, import_react.createElement)( + "div", + { key: "mgrid1", className: "consensus-grid" }, + (0, import_react.createElement)( + "section", + { className: "wb-card" }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, + (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "硬约束"), + (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, constraints.length + " 条") + ), + constraints.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "暂无硬约束。") : (0, import_react.createElement)( + "ul", + { style: { margin: 0, padding: 0, listStyle: "none", display: "flex", flexDirection: "column", gap: 6 } }, + constraints.map((c, idx) => (0, import_react.createElement)( + "li", + { key: idx, style: { display: "flex", gap: 8 } }, + (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-primary)", flexShrink: 0 } }, idx + 1 + "."), + (0, import_react.createElement)("span", { style: { lineHeight: 1.5 } }, c) + )) + ) + ), + (0, import_react.createElement)( + "section", + { className: "wb-card" }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, + (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "验收标准"), + (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, acceptance.length + " 条") + ), + acceptance.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "暂无验收标准。") : (0, import_react.createElement)( + "ul", + { style: { margin: 0, padding: 0, listStyle: "none", display: "flex", flexDirection: "column", gap: 6 } }, + acceptance.map((a, idx) => (0, import_react.createElement)( + "li", + { key: idx, style: { display: "flex", gap: 8 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-success)", flexShrink: 0 } }, "✓"), + (0, import_react.createElement)("span", { style: { lineHeight: 1.5 } }, a) + )) + ) + ) + ), + (0, import_react.createElement)( + "div", + { key: "mgrid2", className: "consensus-grid" }, + (0, import_react.createElement)( + "section", + { className: "wb-card" }, + (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "现行决定 (" + decisionsList.length + ")"), + decisionsList.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "暂无记录。") : decisionsList.slice(-6).map((dec, idx) => (0, import_react.createElement)( + "div", + { key: idx, className: "kv-box" }, + (0, import_react.createElement)("div", null, dec.text), + (0, import_react.createElement)( + "div", + { className: "font-mono-num", style: { color: "var(--ss-muted)", marginTop: 4 } }, + (dec.recordedAt ? dateText(dec.recordedAt) : "项目记录") + " · " + (dec.status === "active" ? "现行" : "已归档") + ) + )) + ), + (0, import_react.createElement)( + "section", + { className: "wb-card" }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, + (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "成果登记 (" + artifacts.length + ")"), + (0, import_react.createElement)("button", { type: "button", className: "frameless-btn", onClick: () => setArtifactModalOpen(true) }, PlusIcon(), " 登记成果") + ), + artifacts.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "还没有登记成果。") : artifacts.map((a) => (0, import_react.createElement)( + "div", + { key: a.id, className: "kv-box" }, + (0, import_react.createElement)("div", { style: { fontWeight: 500 } }, a.title), + a.path ? (0, import_react.createElement)("div", { className: "font-mono-num", style: { color: "var(--ss-primary)", wordBreak: "break-all", marginTop: 2 } }, a.path) : null, + a.summary ? (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)", marginTop: 2 } }, a.summary) : null + )) + ) + ) + ]; + } + function renderConfigTab() { + return [ + (0, import_react.createElement)( + "section", + { key: "binding", className: "wb-card" }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", flexWrap: "wrap", justifyContent: "space-between", alignItems: "center", gap: 8 } }, + (0, import_react.createElement)( + "div", + { style: { minWidth: 0 } }, + (0, import_react.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, "项目绑定与全局默认(R-001)"), + (0, import_react.createElement)( + "p", + { className: "font-mono-num truncate", style: { margin: "2px 0 0", color: "var(--ss-muted)" } }, + (wb.project.path || wb.project.name || "—") + " · " + (wb.project.workspaceId || "—") + ) + ), + (0, import_react.createElement)("span", { className: "ss-pill is-success" }, "项目隔离已生效") + ) + ), + (0, import_react.createElement)( + "section", + { key: "seatlist", className: "wb-card", style: { padding: 0, overflow: "hidden", gap: 0 } }, + (0, import_react.createElement)( + "div", + { style: { padding: "10px 14px", borderBottom: "1px solid var(--ss-border)", display: "flex", flexWrap: "wrap", justifyContent: "space-between", alignItems: "center", gap: 8 } }, + (0, import_react.createElement)("h3", { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, "十席开关与模型配置"), + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "点击任一席位展开配置模型与说明") + ), + (0, import_react.createElement)("div", null, SEAT_IDS.map((id) => { + const seat = seatById[id]; + const tone = seatTone(seat); + const expanded = expandedConfigSeatId === id; + const rec = seatRecMap[id] || {}; + const actLabel = seat.status === "bound" ? "打开" : seat.status === "missing" ? "重建" : "上线"; + const actHandler = seat.status === "bound" ? () => void openSeat(id) : seat.status === "missing" ? () => void rebuildSeat(id) : () => void enableSeat(id); + const configured = rec.configuredModel ?? rec.model ?? null; + const modelShort = shortModelName(configured); + const srcShort = rec.modelSource === "project" ? "项目覆盖" : rec.modelSource === "global" ? "全局默认" : "未设默认"; + return (0, import_react.createElement)( + "div", + { key: id, className: "cfg-row" + (expanded ? " is-open" : "") }, + (0, import_react.createElement)( + "div", + { className: "cfg-row-head" }, + (0, import_react.createElement)( + "button", + { + type: "button", + className: "cfg-row-toggle", + "aria-expanded": expanded, + onClick: () => setExpandedConfigSeatId(expanded ? null : id) + }, + (0, import_react.createElement)("span", { className: "ss-dot is-" + tone }), + (0, import_react.createElement)( + "div", + { className: "cfg-seat-info" }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 } }, + (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 14, flexShrink: 0, color: expanded ? "var(--ss-primary)" : "var(--ss-fg)" } }, seat.name), + (0, import_react.createElement)("span", { className: "truncate", style: { color: "var(--ss-muted)" } }, seat.duty) + ), + (0, import_react.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 6, minWidth: 0 } }, + (0, import_react.createElement)("span", { className: "font-mono-num truncate" }, modelShort), + (0, import_react.createElement)("span", { className: "ss-pill" + (rec.modelSource === "project" ? " is-primary" : "") }, srcShort), + seat.modelSyncStatus === "failed" ? (0, import_react.createElement)("span", { style: { color: "var(--ss-error)", fontWeight: 500, flexShrink: 0 } }, "同步失败") : null + ) + ) + ), + (0, import_react.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 6, paddingRight: 12, flexShrink: 0 } }, + (0, import_react.createElement)("button", { + type: "button", + className: seat.status === "pending" ? "wb-btn-primary" : "wb-btn-outline", + disabled: busy || seat.status === "creating", + onClick: actHandler + }, actLabel), + (0, import_react.createElement)("button", { + type: "button", + "aria-label": "展开配置", + style: { width: 28, height: 28, display: "inline-flex", alignItems: "center", justifyContent: "center", borderRadius: 6, color: "var(--ss-muted)" }, + onClick: () => setExpandedConfigSeatId(expanded ? null : id) + }, ChevronDown(expanded)) + ) + ), + expanded ? (0, import_react.createElement)("div", { className: "cfg-inline-panel" }, renderModelControlsForSeat(id, saveSeatConfigFor)) : null + ); + })) + ) + ]; + } + function renderModals() { + if (selectedTask) { + const liveTask = tasks.find((t) => t.id === selectedTask.id) || selectedTask; + const tm = TASK_META[liveTask.status] || { label: liveTask.status, tone: "muted" }; + const seatLabel2 = SEATS[liveTask.ownerSeatId]?.label || liveTask.ownerSeatId || "—"; + const orig = liveTask.requirementSnapshot?.originalText || liveTask.requirement; + return (0, import_react.createElement)( + "div", + { className: "wb-modal-backdrop", onClick: (e) => { + if (e.target === e.currentTarget) setSelectedTask(null); + } }, + (0, import_react.createElement)( + "div", + { className: "wb-modal", role: "dialog", "aria-modal": "true" }, + (0, import_react.createElement)( + "div", + { className: "wb-modal-head" }, + (0, import_react.createElement)( + "div", + { style: { minWidth: 0 } }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 8, fontSize: 12 } }, + (0, import_react.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, liveTask.id), + (0, import_react.createElement)("span", { className: "ss-pill is-" + tm.tone }, tm.label), + (0, import_react.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, seatLabel2) + ), + (0, import_react.createElement)("h3", { className: "wb-modal-title", style: { marginTop: 4 } }, liveTask.title) + ), + (0, import_react.createElement)("button", { type: "button", className: "wb-modal-close", "aria-label": "关闭", onClick: () => setSelectedTask(null) }, "✕") + ), + (0, import_react.createElement)( + "div", + { className: "wb-modal-body" }, + liveTask.kind === "workflow" ? renderStageStepper(liveTask.stage) : null, + orig ? (0, import_react.createElement)( + "div", + { style: { borderRadius: 8, border: "1px solid color-mix(in srgb,var(--ss-primary) 30%,var(--ss-border))", background: "color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card))", padding: 10 } }, + (0, import_react.createElement)("div", { style: { color: "var(--ss-primary)", fontWeight: 500, marginBottom: 4 } }, "用户原话"), + (0, import_react.createElement)("p", { style: { margin: 0, lineHeight: 1.55 } }, "「" + orig + "」") + ) : null, + (0, import_react.createElement)( + "div", + null, + (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)", fontWeight: 500, marginBottom: 4 } }, "任务说明"), + (0, import_react.createElement)("p", { style: { margin: 0, lineHeight: 1.6, whiteSpace: "pre-wrap" } }, liveTask.goal || "(无任务说明)") + ), + liveTask.workflowBlockage ? (0, import_react.createElement)( + "div", + { className: "wb-alert", style: { flexDirection: "column", alignItems: "flex-start" } }, + (0, import_react.createElement)("div", { style: { fontWeight: 600 } }, "当前阻塞 · " + liveTask.workflowBlockage.label), + (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-fg)" } }, liveTask.workflowBlockage.reason), + (0, import_react.createElement)( + "div", + { style: { display: "flex", flexWrap: "wrap", gap: 8 } }, + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => { + setSelectedTask(null); + void openSeat(liveTask.ownerSeatId); + } }, "打开" + seatLabel2 + "会话"), + liveTask.deliveryState === "unknown" && liveTask.deliveryId ? (0, import_react.createElement)("button", { + type: "button", + className: "wb-btn-primary", + disabled: busy, + onClick: () => void redispatchTask(liveTask) + }, "显式重投此任务") : null + ) + ) : null, + Array.isArray(liveTask.consultations) && liveTask.consultations.length > 0 ? (0, import_react.createElement)( + "div", + { style: { display: "flex", flexDirection: "column", gap: 6 } }, + (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)", fontWeight: 500 } }, "会商记录 (" + liveTask.consultations.length + ")"), + liveTask.consultations.map((c) => (0, import_react.createElement)( + "div", + { key: c.id || c.createdAt, className: "kv-box" }, + (0, import_react.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", gap: 8, color: "var(--ss-muted)", marginBottom: 4 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-fg)", fontWeight: 500 } }, (SEATS[c.fromSeatId]?.label || c.fromSeatId) + " → " + (c.toSeatIds || []).map((x) => SEATS[x]?.label || x).join("、")), + (0, import_react.createElement)("span", { className: "font-mono-num" }, dateText(c.createdAt)) + ), + (0, import_react.createElement)("div", { style: { lineHeight: 1.55 } }, c.text) + )) + ) : null, + (0, import_react.createElement)( + "div", + null, + (0, import_react.createElement)("div", { style: { color: "var(--ss-muted)", fontWeight: 500, marginBottom: 4 } }, "任务完成情况"), + (0, import_react.createElement)("div", { className: "kv-box", style: { whiteSpace: "pre-wrap", lineHeight: 1.6 } }, liveTask.result || liveTask.note || "(尚未回报结果)") + ) + ), + (0, import_react.createElement)( + "div", + { className: "wb-modal-foot" }, + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setSelectedTask(null) }, "关闭") + ) + ) + ); + } + if (durationModalOpen) { + const rows = tasks.map((t) => ({ task: t, ms: taskDurationMs(t) })).filter((r) => r.ms > 0).sort((a, b) => b.ms - a.ms); + return (0, import_react.createElement)( + "div", + { className: "wb-modal-backdrop", onClick: (e) => { + if (e.target === e.currentTarget) setDurationModalOpen(false); + } }, + (0, import_react.createElement)( + "div", + { className: "wb-modal", role: "dialog", "aria-modal": "true" }, + (0, import_react.createElement)( + "div", + { className: "wb-modal-head" }, + (0, import_react.createElement)("h3", { className: "wb-modal-title" }, "任务耗时与用量说明"), + (0, import_react.createElement)("button", { type: "button", className: "wb-modal-close", "aria-label": "关闭", onClick: () => setDurationModalOpen(false) }, "✕") + ), + (0, import_react.createElement)( + "div", + { className: "wb-modal-body" }, + rows.length === 0 ? (0, import_react.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)" } }, "暂无任务耗时记录。") : (0, import_react.createElement)( + "div", + { style: { borderRadius: 8, border: "1px solid var(--ss-border)", overflow: "hidden" } }, + (0, import_react.createElement)( + "table", + { className: "queue-table" }, + (0, import_react.createElement)("thead", null, (0, import_react.createElement)("tr", null, (0, import_react.createElement)("th", null, "任务"), (0, import_react.createElement)("th", null, "承办"), (0, import_react.createElement)("th", { style: { textAlign: "right" } }, "耗时"))), + (0, import_react.createElement)("tbody", null, rows.map((r) => (0, import_react.createElement)( + "tr", + { key: r.task.id }, + (0, import_react.createElement)("td", null, r.task.title), + (0, import_react.createElement)("td", { className: "font-seal", style: { fontWeight: 700 } }, SEATS[r.task.ownerSeatId]?.label || "—"), + (0, import_react.createElement)("td", { className: "font-mono-num", style: { textAlign: "right" } }, durationText(r.ms)) + ))) + ) + ), + (0, import_react.createElement)( + "div", + { className: "kv-box", style: { color: "var(--ss-muted)", lineHeight: 1.6 } }, + (0, import_react.createElement)("strong", { style: { color: "var(--ss-fg)" } }, "关于 Token 与金额统计:"), + "宿主尚未提供稳定 usage 数据源,这里不展示估算或虚构金额,接入真实用量后会在此呈现。" + ) + ) + ) + ); + } + if (artifactModalOpen) { + return (0, import_react.createElement)( + "div", + { className: "wb-modal-backdrop", onClick: (e) => { + if (e.target === e.currentTarget) setArtifactModalOpen(false); + } }, + (0, import_react.createElement)( + "div", + { className: "wb-modal", role: "dialog", "aria-modal": "true" }, + (0, import_react.createElement)( + "div", + { className: "wb-modal-head" }, + (0, import_react.createElement)("h3", { className: "wb-modal-title" }, "登记项目成果"), + (0, import_react.createElement)("button", { type: "button", className: "wb-modal-close", "aria-label": "关闭", onClick: () => setArtifactModalOpen(false) }, "✕") + ), + (0, import_react.createElement)( + "div", + { className: "wb-modal-body" }, + (0, import_react.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "成果名称"), + (0, import_react.createElement)("input", { type: "text", className: "wb-input", value: artifactDraft.title, placeholder: "例如:竞品分析报告 v1", onChange: (e) => setArtifactDraft((p) => ({ ...p, title: e.target.value })) }) + ), + (0, import_react.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "文件路径"), + (0, import_react.createElement)("input", { type: "text", className: "wb-input", value: artifactDraft.path, placeholder: "例如:docs/竞品分析.md", onChange: (e) => setArtifactDraft((p) => ({ ...p, path: e.target.value })) }) + ), + (0, import_react.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react.createElement)("span", { style: { color: "var(--ss-muted)" } }, "摘要"), + (0, import_react.createElement)("textarea", { rows: 3, className: "wb-textarea", value: artifactDraft.summary, placeholder: "这份成果解决了什么、在哪里", onChange: (e) => setArtifactDraft((p) => ({ ...p, summary: e.target.value })) }) + ) + ), + (0, import_react.createElement)( + "div", + { className: "wb-modal-foot" }, + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-outline", onClick: () => setArtifactModalOpen(false) }, "取消"), + (0, import_react.createElement)("button", { type: "button", className: "wb-btn-primary", disabled: busy, onClick: () => void addArtifact() }, busy ? "提交中…" : "登记成果") + ) + ) + ); + } + return null; + } + function renderMainBody() { + if (phase === "loading") return (0, import_react.createElement)("div", { className: "wb-empty-box" }, "正在载入项目工作台…"); + if (phase === "no-workspace") return (0, import_react.createElement)("div", { className: "wb-empty-box" }, "当前会话尚未关联工作区,请在宿主中打开项目文件夹后重试。"); + if (phase === "error" && !view) { + return (0, import_react.createElement)( + "div", + { className: "wb-alert", style: { flexDirection: "column", alignItems: "flex-start" } }, + (0, import_react.createElement)("span", null, error || "工作台加载失败"), + errorRetryable ? (0, import_react.createElement)("button", { type: "button", className: "wb-btn-primary", onClick: () => void loadProject() }, "重试") : null + ); + } + if (tab === "flow") return renderFlowTab(); + if (tab === "deliberation") return renderDeliberationTab(); + if (tab === "memory") return renderMemoryTab(); + if (tab === "config") return renderConfigTab(); + return renderCourtTab(); + } + const navTabs = [ + { id: "court", label: "朝堂", badge: pendingCount > 0 ? String(pendingCount) : null, tone: "primary" }, + { id: "flow", label: "流转", badge: openTasksCount > 0 ? String(openTasksCount) : null, tone: "primary" }, + { id: "deliberation", label: "议政", badge: activeDelib ? "进行中" : null, tone: "success" }, + { id: "memory", label: "共识", badge: (memory?.revision ?? 0) > 0 ? "v" + memory.revision : null, tone: "muted" }, + { id: "config", label: "配置", badge: syncIssues > 0 ? String(syncIssues) : null, tone: "error" } + ]; + const headerDotTone = syncIssues > 0 ? "is-error" : runningSeatsCount > 0 ? "is-success is-pulse" : "is-muted"; + return (0, import_react.createElement)( + "div", + { className: "ssv2 ssw-tab-body", "data-sansheng-sidebar": "1" }, + (0, import_react.createElement)( + "header", + { className: "wb-header" }, + (0, import_react.createElement)( + "div", + { className: "wb-header-row" }, + (0, import_react.createElement)( + "div", + { className: "wb-brand" }, + (0, import_react.createElement)("div", { className: "wb-seal-badge" }, "省"), + (0, import_react.createElement)( + "div", + { style: { minWidth: 0 } }, + (0, import_react.createElement)( + "div", + { className: "wb-brand-title-row" }, + (0, import_react.createElement)("h1", { className: "wb-brand-title" }, "三省六部"), + (0, import_react.createElement)("span", { className: "wb-role-badge hide-narrow" }, "单项目侧栏") + ), + (0, import_react.createElement)( + "p", + { className: "wb-subline" }, + activeChatSeatId ? "固定绑定当前会话项目 · 当前对话:" + (SEATS[activeChatSeatId]?.label || activeChatSeatId) : "固定绑定当前会话项目 · " + wb.project.boundCount + " / " + wb.project.seatCount + " 席已绑定" + ) + ) + ), + (0, import_react.createElement)( + "span", + { className: "wb-proj-pill", title: "已固定绑定当前会话所属项目" }, + (0, import_react.createElement)("span", { className: "ss-dot " + headerDotTone }), + (0, import_react.createElement)("span", { className: "wb-proj-name" }, wb.project.name || wb.projectTitle || "当前项目") + ) + ), + (0, import_react.createElement)( + "nav", + { className: "wb-tabs", role: "tablist", "aria-label": "工作台导航" }, + navTabs.map((t) => (0, import_react.createElement)( + "button", + { + key: t.id, + type: "button", + role: "tab", + "aria-selected": tab === t.id, + className: "wb-tab-btn" + (tab === t.id ? " is-active" : ""), + onClick: () => setTab(t.id) + }, + (0, import_react.createElement)("span", null, t.label), + t.badge ? (0, import_react.createElement)("span", { className: "wb-tab-badge ss-pill is-" + t.tone }, t.badge) : null + )) + ) ), - renderArtifactModal(), - renderTaskDetail(), - renderReviewPanel(), - renderDurationPanel(), - renderQueuePanel(), - renderTokenPanel() + error && view ? (0, import_react.createElement)( + "div", + { className: "wb-toast-wrap" }, + (0, import_react.createElement)( + "div", + { className: "wb-toast-box is-error", role: "alert" }, + (0, import_react.createElement)("span", null, error), + (0, import_react.createElement)("button", { type: "button", className: "wb-toast-close", onClick: () => setError(null) }, "✕") + ) + ) : !error && notice ? (0, import_react.createElement)( + "div", + { className: "wb-toast-wrap" }, + (0, import_react.createElement)( + "div", + { className: "wb-toast-box is-primary", role: "status" }, + (0, import_react.createElement)("span", null, notice), + (0, import_react.createElement)("button", { type: "button", className: "wb-toast-close", onClick: () => setNotice(null) }, "✕") + ) + ) : null, + (0, import_react.createElement)("main", { className: "wb-body" }, renderMainBody()), + (0, import_react.createElement)( + "footer", + { className: "wb-footer" }, + (0, import_react.createElement)( + "span", + { className: "truncate" }, + "项目 " + (wb.project.name || "—") + " · " + wb.project.boundCount + " / " + wb.project.seatCount + " 席已绑定 · 共识 v" + (memory?.revision ?? 0) + ), + (0, import_react.createElement)( + "button", + { type: "button", className: "wb-refresh-btn", disabled: busy, onClick: () => void loadProject() }, + RefreshIcon(), + (0, import_react.createElement)("span", null, "刷新") + ) + ), + renderModals() + ); +} + +// src/client/master-workbench.js +var import_react2 = require("react"); +function smallSvg2(children, props) { + return (0, import_react2.createElement)("svg", { + viewBox: "0 0 24 24", + width: 13, + height: 13, + fill: "none", + stroke: "currentColor", + strokeWidth: 2, + strokeLinecap: "round", + strokeLinejoin: "round", + "aria-hidden": "true", + ...props || {} + }, children); +} +var SearchSvg = (props) => smallSvg2([ + (0, import_react2.createElement)("circle", { key: "c", cx: 11, cy: 11, r: 8 }), + (0, import_react2.createElement)("path", { key: "p", d: "m21 21-4.3-4.3" }) +], props); +var ChevronDownSvg = (props) => smallSvg2([ + (0, import_react2.createElement)("polyline", { key: "p", points: "6 9 12 15 18 9" }) +], props); +var SlidersSvg = () => smallSvg2([ + (0, import_react2.createElement)("path", { key: "p", d: "M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M2 14h4M10 8h4M18 16h4" }) +], { strokeWidth: 1.8 }); +function formatDateTime(ts) { + const n = Number(ts); + if (!Number.isFinite(n) || n <= 0) return "—"; + const d = new Date(n); + const p = (x) => String(x).padStart(2, "0"); + return d.getMonth() + 1 + "-" + p(d.getDate()) + " " + p(d.getHours()) + ":" + p(d.getMinutes()); +} +function stageTone(col) { + if (col === "done" || col === "running") return "success"; + if (col === "review") return "primary"; + return "muted"; +} +function stageTitle(col) { + if (col === "done") return "已交付"; + if (col === "review") return "门下复核"; + if (col === "running") return "六部执行中"; + return "待规划 · 需求池"; +} +function dotToneClass(tone, pulse) { + const cls = "ss-dot is-" + (tone || "muted"); + return pulse ? cls + " is-pulse" : cls; +} +function copyText(text, onDone) { + try { + if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) { + void navigator.clipboard.writeText(text).then(() => onDone(true)).catch(() => onDone(false)); + return; + } + } catch { + } + onDone(false); +} +function MasterWorkbench(props) { + const { getCurrentWorkspace, navigateToSession } = props || {}; + const [loading, setLoading] = (0, import_react2.useState)(true); + const [projects, setProjects] = (0, import_react2.useState)([]); + const [bundles, setBundles] = (0, import_react2.useState)([]); + const [approvals, setApprovals] = (0, import_react2.useState)([]); + const [degradedInfo, setDegradedInfo] = (0, import_react2.useState)(null); + const [modelsCatalog, setModelsCatalog] = (0, import_react2.useState)(null); + const [globalDefaults, setGlobalDefaults] = (0, import_react2.useState)(null); + const [projectFilter, setProjectFilter] = (0, import_react2.useState)("all"); + const [projMenuOpen, setProjMenuOpen] = (0, import_react2.useState)(false); + const [viewMode, setViewMode] = (0, import_react2.useState)("board"); + const [search, setSearch] = (0, import_react2.useState)(""); + const [searchOpen, setSearchOpen] = (0, import_react2.useState)(false); + const [pendingExpanded, setPendingExpanded] = (0, import_react2.useState)(true); + const [drawer, setDrawer] = (0, import_react2.useState)(null); + const [taskTab, setTaskTab] = (0, import_react2.useState)("overview"); + const [expandedGlobalSeatId, setExpandedGlobalSeatId] = (0, import_react2.useState)(null); + const [frameWidth, setFrameWidth] = (0, import_react2.useState)(1280); + const [busy, setBusy] = (0, import_react2.useState)(false); + const [toast, setToast] = (0, import_react2.useState)(null); + const alive = (0, import_react2.useRef)(true); + const rootRef = (0, import_react2.useRef)(null); + const narrowSearchRef = (0, import_react2.useRef)(null); + const toastTimerRef = (0, import_react2.useRef)(null); + const autoOpenedOnce = (0, import_react2.useRef)(false); + const answerVersion = (0, import_react2.useRef)(0); + const showToast = (0, import_react2.useCallback)((text, tone = "primary") => { + setToast({ text, tone }); + if (toastTimerRef.current) clearTimeout(toastTimerRef.current); + toastTimerRef.current = setTimeout(() => { + if (alive.current) setToast(null); + }, 3400); + }, []); + (0, import_react2.useEffect)(() => { + alive.current = true; + return () => { + alive.current = false; + if (toastTimerRef.current) clearTimeout(toastTimerRef.current); + }; + }, []); + const loadAll = (0, import_react2.useCallback)(async ({ silent = false } = {}) => { + const startVer = answerVersion.current; + try { + let listRes = await request("list"); + let projList = Array.isArray(listRes?.projects) ? listRes.projects : []; + if (projList.length === 0 && !autoOpenedOnce.current && typeof getCurrentWorkspace === "function") { + const ws = getCurrentWorkspace(); + if (ws && (ws.workspaceId || ws.path)) { + autoOpenedOnce.current = true; + try { + await request("open", { workspaceId: ws.workspaceId, name: ws.name, path: ws.path }); + listRes = await request("list"); + projList = Array.isArray(listRes?.projects) ? listRes.projects : []; + } catch { + } + } + } + const [modelsRes, globalRes] = await Promise.allSettled([ + request("models"), + request("globalDefaults") + ]); + const detailSettled = await Promise.all(projList.map(async (summary) => { + const [projR, tasksR, reqsR, apprR, artR] = await Promise.allSettled([ + request("project", { projectId: summary.id }), + request("tasks", { projectId: summary.id }), + request("requirements", { projectId: summary.id }), + request("approvals", { projectId: summary.id }), + request("artifacts", { projectId: summary.id }) + ]); + return { summary, projR, tasksR, reqsR, apprR, artR }; + })); + if (!alive.current) return; + if (modelsRes.status === "fulfilled" && modelsRes.value) setModelsCatalog(modelsRes.value); + if (globalRes.status === "fulfilled" && globalRes.value) setGlobalDefaults(globalRes.value); + setBundles((prev) => { + const prevMap = new Map(prev.map((b) => [b.project?.id, b])); + return detailSettled.map(({ summary, projR, tasksR, reqsR, artR }) => { + const old = prevMap.get(summary.id); + const projectObj = projR.status === "fulfilled" ? projR.value?.project ?? projR.value : old?.project ?? { id: summary.id, name: summary.name, status: summary.status, seats: [] }; + const tasks = tasksR.status === "fulfilled" && Array.isArray(tasksR.value?.tasks) ? tasksR.value.tasks : old?.tasks ?? []; + const requirements = reqsR.status === "fulfilled" && Array.isArray(reqsR.value?.requirements) ? reqsR.value.requirements : old?.requirements ?? []; + const artifacts = artR.status === "fulfilled" && Array.isArray(artR.value?.artifacts) ? artR.value.artifacts : old?.artifacts ?? []; + return { project: projectObj, tasks, requirements, artifacts }; + }); + }); + setProjects(projList.map((p, idx) => ({ + ...p, + colorVar: PROJECT_DOT_VARS[idx % PROJECT_DOT_VARS.length] + }))); + if (answerVersion.current === startVer) { + const nextApprovals = []; + let degraded = null; + detailSettled.forEach(({ summary, apprR }, idx) => { + const colorVar = PROJECT_DOT_VARS[idx % PROJECT_DOT_VARS.length]; + if (apprR.status === "fulfilled") { + const st = apprR.value?.status; + if (st?.degraded) degraded = st.reason || "approval-center-degraded"; + const list = Array.isArray(apprR.value?.approvals) ? apprR.value.approvals : []; + for (const entry of list) { + nextApprovals.push({ ...entry, projectId: entry.projectId || summary.id, projectName: summary.name, colorVar }); + } + } else { + degraded = apprR.reason?.message || "审批队列暂不可达"; + } + }); + setApprovals(nextApprovals); + setDegradedInfo(degraded); + } + setLoading(false); + } catch (error) { + if (!alive.current) return; + setLoading(false); + if (!silent) showToast(error?.message || "总台状态加载失败", "error"); + } + }, [getCurrentWorkspace, showToast]); + (0, import_react2.useEffect)(() => { + void loadAll(); + let running = false; + const tick = async () => { + if (running) return; + if (typeof document !== "undefined" && document.visibilityState === "hidden") return; + running = true; + try { + await loadAll({ silent: true }); + } finally { + running = false; + } + }; + const timer = setInterval(() => { + void tick(); + }, 4e3); + const onVis = () => { + if (document.visibilityState === "visible") void tick(); + }; + if (typeof document !== "undefined") document.addEventListener("visibilitychange", onVis); + return () => { + clearInterval(timer); + if (typeof document !== "undefined") document.removeEventListener("visibilitychange", onVis); + }; + }, [loadAll]); + (0, import_react2.useEffect)(() => { + const node = rootRef.current; + if (!node) return void 0; + const sync = (w) => { + if (w > 0) setFrameWidth(w); + }; + if (node.clientWidth > 0) sync(node.clientWidth); + if (typeof ResizeObserver === "undefined") return void 0; + const observer = new ResizeObserver((entries) => { + const w = entries[0]?.contentRect?.width || node.clientWidth; + sync(w); + }); + observer.observe(node); + return () => observer.disconnect(); + }, []); + (0, import_react2.useEffect)(() => { + if (typeof document === "undefined") return void 0; + const onDown = (e) => { + if (projMenuOpen && !e.target.closest?.(".mwb-proj-wrap")) setProjMenuOpen(false); + }; + const onKey = (e) => { + if (e.key !== "Escape") return; + if (projMenuOpen) { + setProjMenuOpen(false); + return; + } + if (searchOpen && frameWidth <= 760) { + setSearchOpen(false); + return; + } + if (drawer) setDrawer(null); + }; + document.addEventListener("mousedown", onDown); + document.addEventListener("keydown", onKey); + return () => { + document.removeEventListener("mousedown", onDown); + document.removeEventListener("keydown", onKey); + }; + }, [projMenuOpen, searchOpen, frameWidth, drawer]); + const projectMetaById = (0, import_react2.useMemo)(() => { + const map = /* @__PURE__ */ new Map(); + bundles.forEach((b, idx) => { + if (b?.project?.id) { + map.set(b.project.id, { + id: b.project.id, + name: b.project.name || b.project.id, + path: b.project.path || b.project.workspaceId || "", + colorVar: PROJECT_DOT_VARS[idx % PROJECT_DOT_VARS.length] + }); + } + }); + return map; + }, [bundles]); + const modelOptions = (0, import_react2.useMemo)(() => collectModelOptions(modelsCatalog), [modelsCatalog]); + const modelChoices = (0, import_react2.useMemo)(() => groupModelChoices(modelOptions), [modelOptions]); + const allItems = (0, import_react2.useMemo)(() => buildMasterItems(bundles, modelOptions), [bundles, modelOptions]); + const visibleItems = (0, import_react2.useMemo)(() => filterMasterItems(allItems, { projectFilter, search }), [allItems, projectFilter, search]); + const pendingEntries = (0, import_react2.useMemo)(() => { + const out = []; + for (const a of approvals) { + if (projectFilter !== "all" && a.projectId !== projectFilter) continue; + out.push({ kind: "approval", data: a }); + } + for (const item of allItems) { + if (projectFilter !== "all" && item.projectId !== projectFilter) continue; + for (const d of item.decisions || []) { + if (d.status === "pending") out.push({ kind: "decision", item, data: d }); + } + } + return out; + }, [approvals, allItems, projectFilter]); + const hasPendingBlock = pendingExpanded && (pendingEntries.length > 0 || Boolean(degradedInfo)); + const layoutMode = computeMasterLayoutMode(frameWidth, hasPendingBlock); + const isNarrow = layoutMode === "list"; + const compactSearch = frameWidth <= 760; + const effectiveProjectMeta = projectFilter !== "all" ? projectMetaById.get(projectFilter) : null; + const activeProjList = (0, import_react2.useMemo)(() => bundles.map((b, idx) => { + const pid = b.project?.id; + const meta = projectMetaById.get(pid); + const activeCnt = allItems.filter((it) => it.projectId === pid && it.col !== "done").length; + const pendCnt = approvals.filter((a) => a.projectId === pid).length + allItems.filter((it) => it.projectId === pid).reduce((acc, it) => acc + (it.decisions || []).filter((d) => d.status === "pending").length, 0); + return { + id: pid, + name: meta?.name || pid, + path: meta?.path || "", + colorVar: meta?.colorVar || PROJECT_DOT_VARS[idx % PROJECT_DOT_VARS.length], + activeCnt, + pendCnt + }; + }), [bundles, projectMetaById, allItems, approvals]); + const totalPendingAll = approvals.length + allItems.reduce((acc, it) => acc + (it.decisions || []).filter((d) => d.status === "pending").length, 0); + const totalActiveAll = allItems.filter((it) => it.col !== "done").length; + const doneItems = (0, import_react2.useMemo)(() => visibleItems.filter((it) => it.col === "done"), [visibleItems]); + async function handleOpenSeat(projectId, seatId) { + if (!projectId || !seatId) return; + const bundle = bundles.find((b) => b.project?.id === projectId); + const seats = bundle?.project?.seats; + const seatRec = Array.isArray(seats) ? seats.find((s) => s.id === seatId) : seats?.[seatId]; + const seatName = SEATS[seatId]?.label || seatId; + setBusy(true); + try { + if (seatRec?.status === "missing") { + await request("rebuildSeat", { projectId, seatId, expectedSessionId: seatRec.sessionId || void 0 }); + showToast("已重建「" + seatName + "」会话(保留历史任务)", "success"); + await loadAll({ silent: true }); + return; + } + if (seatRec?.status !== "bound") { + await request("enableSeat", { projectId, seatId }); + } + const res = await request("openSeat", { projectId, seatId }); + if (res?.sessionId && typeof navigateToSession === "function") { + navigateToSession(res.sessionId); + showToast("已打开「" + seatName + "」会话", "primary"); + } else { + showToast("已就绪「" + seatName + "」独立会话", "success"); + await loadAll({ silent: true }); + } + } catch (error) { + showToast(error?.message || "打开席位会话失败", "error"); + await loadAll({ silent: true }); + } finally { + if (alive.current) setBusy(false); + } + } + async function handleApproval(entry, choice) { + if (!entry || busy) return; + setBusy(true); + try { + answerVersion.current += 1; + await request("approvalAnswer", { + projectId: entry.projectId, + seatId: entry.seatId, + id: entry.id, + sessionId: entry.sessionId, + choice + }); + setApprovals((prev) => prev.filter((a) => !(a.id === entry.id && a.sessionId === entry.sessionId))); + showToast((choice === "allow" ? "已允许「" : "已拒绝「") + (SEATS[entry.seatId]?.label || entry.seatId) + "」工具执行", choice === "allow" ? "success" : "error"); + await loadAll({ silent: true }); + } catch (error) { + showToast(error?.message || "审批应答失败", "error"); + await loadAll({ silent: true }); + } finally { + if (alive.current) setBusy(false); + } + } + async function handleDecision(item, decision, option) { + if (!item || !decision || !option || busy) return; + setBusy(true); + try { + answerVersion.current += 1; + await request("taskDecisionAnswer", { + projectId: item.projectId, + taskId: item.id, + decisionId: decision.id, + value: option.value + }); + setBundles((prev) => prev.map((b) => { + if (b.project?.id !== item.projectId) return b; + return { + ...b, + tasks: (b.tasks || []).map((t) => t.id === item.id && Array.isArray(t.decisions) ? { ...t, decisions: t.decisions.map((d) => d.id === decision.id ? { ...d, status: "answered", answer: option.value } : d) } : t) + }; + })); + showToast("已提交项目决定:" + option.label, "success"); + await loadAll({ silent: true }); + } catch (error) { + showToast(error?.message || "提交决定失败", "error"); + } finally { + if (alive.current) setBusy(false); + } + } + async function handleRedispatch(item) { + const blk = item?.blockage; + if (!item || !blk?.canRedispatch || !blk.deliveryId || busy) return; + const targetTaskId = blk.targetTaskId || item.id; + setBusy(true); + try { + const res = await request("taskRedispatch", { + projectId: item.projectId, + taskId: targetTaskId, + expectedDeliveryId: blk.deliveryId + }); + const st = res?.delivery?.status; + showToast(st === "sent" ? "已显式重投任务「" + targetTaskId + "」并送达会话" : "重投状态:" + (res?.delivery?.reason || st || "已处理"), st === "sent" ? "success" : "primary"); + await loadAll({ silent: true }); + } catch (error) { + showToast(error?.message || "显式重投失败", "error"); + } finally { + if (alive.current) setBusy(false); + } + } + async function handleSetGlobalSeat(seatId, modelObj) { + if (!seatId || busy) return; + setBusy(true); + try { + const res = modelObj ? await request("setGlobalDefault", { seatId, model: modelObj }) : await request("clearGlobalDefault", { seatId }); + if (res?.globalDefaults) setGlobalDefaults(res.globalDefaults); + const appliedCnt = Array.isArray(res?.applied) ? res.applied.length : 0; + const failedCnt = Array.isArray(res?.failed) ? res.failed.length : 0; + const label = SEATS[seatId]?.label || seatId; + if (!modelObj) { + showToast("已清除「" + label + "」全局默认设置" + (appliedCnt ? "(已同步 " + appliedCnt + " 个项目)" : ""), "primary"); + } else { + showToast("已更新「" + label + "」全局默认模型(已同步 " + appliedCnt + " 项" + (failedCnt ? ",失败 " + failedCnt + " 项" : "") + ")", failedCnt ? "error" : "success"); + } + await loadAll({ silent: true }); + } catch (error) { + showToast(error?.message || "全局默认模型保存失败", "error"); + } finally { + if (alive.current) setBusy(false); + } + } + async function handleSeedGlobalDefaults() { + if (busy) return; + const targetProjId = projectFilter !== "all" ? projectFilter : projects[0]?.id ?? void 0; + setBusy(true); + try { + const res = await request("seedGlobalDefaults", targetProjId ? { projectId: targetProjId } : {}); + if (res?.globalDefaults) setGlobalDefaults(res.globalDefaults); + if (res?.seeded) { + showToast("已按项目同步初始化十席全局默认模型", "success"); + } else if (res?.status === "existing") { + showToast("全局默认配置文件已存在,未覆盖当前配置", "primary"); + } else { + showToast("未找到可用的基准项目,请逐席设置或先选择单个项目", "error"); + } + } catch (error) { + showToast(error?.message || "同步初始化全局默认失败", "error"); + } finally { + if (alive.current) setBusy(false); + } + } + function renderPendingZone(fullHeight) { + return (0, import_react2.createElement)( + "section", + { className: "frameless-zone" + (fullHeight ? " is-dock-full" : ""), "aria-label": "待你处理" }, + (0, import_react2.createElement)( + "div", + { className: "frameless-zone-head" }, + (0, import_react2.createElement)( + "div", + { className: "frameless-zone-title-wrap" }, + (0, import_react2.createElement)("span", { className: "ss-dot is-primary is-pulse" }), + (0, import_react2.createElement)("h2", { className: "frameless-zone-title" }, "待你处理"), + (0, import_react2.createElement)("span", { className: "frameless-zone-count" }, String(pendingEntries.length)), + (0, import_react2.createElement)("span", { className: "frameless-zone-sub" }, projectFilter === "all" ? "跨项目" : effectiveProjectMeta?.name || "") + ), + (0, import_react2.createElement)("button", { + type: "button", + className: "wb-toast-close", + onClick: () => setPendingExpanded(false) + }, "收起") + ), + degradedInfo ? (0, import_react2.createElement)( + "div", + { className: "frameless-code", style: { color: "var(--ss-error)" } }, + "部分项目无法获取宿主工具审批队列(" + degradedInfo + "),请在席位会话内使用原生审批卡。" + ) : null, + (0, import_react2.createElement)( + "div", + { className: "frameless-zone-list" + (fullHeight ? " is-scroll" : "") }, + pendingEntries.map((entry) => { + if (entry.kind === "approval") { + const a = entry.data; + return (0, import_react2.createElement)( + "article", + { className: "frameless-item", key: "apr:" + a.sessionId + ":" + a.id }, + (0, import_react2.createElement)( + "div", + { className: "frameless-item-head" }, + (0, import_react2.createElement)( + "span", + { style: { display: "inline-flex", alignItems: "center", gap: 6, minWidth: 0 } }, + (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(" + (a.colorVar || "--ss-primary") + ")", flexShrink: 0 } }), + (0, import_react2.createElement)("span", { className: "font-mono-num truncate", style: { fontSize: 12, fontWeight: 500 } }, a.projectName || a.projectId) + ), + (0, import_react2.createElement)( + "span", + { style: { display: "inline-flex", alignItems: "center", gap: 6, marginLeft: "auto" } }, + (0, import_react2.createElement)("span", { className: "frameless-chip is-err" }, (0, import_react2.createElement)("span", { className: "ss-dot is-error" }), "工具审批"), + (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 13 } }, SEATS[a.seatId]?.label || a.seatId) + ) + ), + (0, import_react2.createElement)( + "div", + { className: "frameless-code" }, + a.tool ? (0, import_react2.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)", marginRight: 6 } }, "[" + a.tool + "]") : null, + a.reason || a.detail?.text || "等待工具授权" + ), + (0, import_react2.createElement)( + "div", + { className: "frameless-actions" }, + (0, import_react2.createElement)("button", { type: "button", className: "frameless-link", disabled: busy, onClick: () => void handleOpenSeat(a.projectId, a.seatId) }, "查看会话 ↗"), + (0, import_react2.createElement)( + "div", + { className: "frameless-btn-group" }, + (0, import_react2.createElement)("button", { type: "button", className: "frameless-btn", disabled: busy, onClick: () => void handleApproval(a, "reject") }, "拒绝"), + (0, import_react2.createElement)("button", { type: "button", className: "frameless-primary-btn", disabled: busy, onClick: () => void handleApproval(a, "allow") }, "允许一次") + ) + ) + ); + } + const d = entry.data; + const it = entry.item; + return (0, import_react2.createElement)( + "article", + { className: "frameless-item", key: "dec:" + it.key + ":" + d.id }, + (0, import_react2.createElement)( + "div", + { className: "frameless-item-head" }, + (0, import_react2.createElement)( + "span", + { style: { display: "inline-flex", alignItems: "center", gap: 6, minWidth: 0 } }, + (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(" + it.projectColorVar + ")", flexShrink: 0 } }), + (0, import_react2.createElement)("span", { className: "font-mono-num truncate", style: { fontSize: 12, fontWeight: 500 } }, it.projectName) + ), + (0, import_react2.createElement)( + "span", + { style: { display: "inline-flex", alignItems: "center", gap: 6, marginLeft: "auto" } }, + (0, import_react2.createElement)("span", { className: "frameless-chip is-pri" }, (0, import_react2.createElement)("span", { className: "ss-dot is-primary" }), "项目决定"), + (0, import_react2.createElement)("button", { type: "button", className: "frameless-link font-mono-num", onClick: () => { + setDrawer({ type: "task", itemKey: it.key }); + setTaskTab("overview"); + } }, it.id + " ↗") + ) + ), + (0, import_react2.createElement)( + "div", + { style: { display: "flex", flexDirection: "column", gap: 3 } }, + (0, import_react2.createElement)("div", { style: { fontSize: 12, fontWeight: 600, color: "var(--ss-fg)" } }, it.title), + (0, import_react2.createElement)("p", { style: { margin: 0, fontSize: 12, color: "var(--ss-muted)", lineHeight: 1.55 } }, d.question) + ), + (0, import_react2.createElement)( + "div", + { style: { display: "flex", flexWrap: "wrap", gap: 6 } }, + (d.options || []).map((opt) => (0, import_react2.createElement)("button", { + key: opt.value, + type: "button", + className: "frameless-btn", + disabled: busy, + onClick: () => void handleDecision(it, d, opt) + }, opt.label)) + ) + ); + }) + ) + ); + } + function renderKanbanCard(item) { + const seat = SEATS[item.seatId]; + const selected = drawer?.type === "task" && drawer.itemKey === item.key; + const isBlocked = Boolean(item.blockage); + const isRun = item.col === "running" && !isBlocked; + const hasPendingDec = (item.decisions || []).some((d) => d.status === "pending"); + const badgeTone = isBlocked ? "error" : isRun ? "success" : "muted"; + return (0, import_react2.createElement)( + "button", + { + key: item.key, + type: "button", + className: "mwb-kanban-card" + (isBlocked ? " is-blocked" : "") + (selected ? " is-selected" : ""), + onClick: () => { + setDrawer({ type: "task", itemKey: item.key }); + setTaskTab("overview"); + } + }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, width: "100%" } }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 6, minWidth: 0 } }, + (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(" + item.projectColorVar + ")", flexShrink: 0 }, title: item.projectName }), + projectFilter === "all" ? [ + (0, import_react2.createElement)("span", { key: "pn", className: "font-mono-num truncate", style: { color: "var(--ss-fg)", fontWeight: 500, fontSize: 12 } }, item.projectName), + (0, import_react2.createElement)("span", { key: "sep", style: { color: "var(--ss-muted)", flexShrink: 0 } }, "·") + ] : null, + (0, import_react2.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)", flexShrink: 0, fontSize: 12 } }, item.id) + ), + (0, import_react2.createElement)( + "span", + { className: "ss-pill is-" + badgeTone }, + (0, import_react2.createElement)("span", { className: dotToneClass(badgeTone, isRun) }), + (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, isBlocked && layoutMode !== "board4" ? "阻塞 · " + (seat?.label || "—") : seat?.label || "—") + ) + ), + (0, import_react2.createElement)("div", { className: "line-clamp-2", style: { fontSize: 12, fontWeight: 600, color: "var(--ss-fg)", lineHeight: 1.45 } }, item.title), + (0, import_react2.createElement)( + "div", + { className: "mwb-card-ticker" + (isBlocked ? " is-blocked" : "") }, + (0, import_react2.createElement)("span", { className: "line-clamp-2" }, item.ticker) + ), + (0, import_react2.createElement)( + "div", + { className: "mwb-card-foot", style: { width: "100%" } }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: "4px 8px" } }, + item.progress ? (0, import_react2.createElement)( + "span", + { className: "font-mono-num", style: { display: "inline-flex", alignItems: "center", gap: 4 } }, + (0, import_react2.createElement)("span", null, item.progress.done + "/" + item.progress.total), + (0, import_react2.createElement)("span", { className: "mwb-progress-track" }, (0, import_react2.createElement)("span", { className: "mwb-progress-fill", style: { width: Math.round(item.progress.done / item.progress.total * 100) + "%" } })) + ) : null, + item.consultations?.length ? (0, import_react2.createElement)("span", null, "会商 " + item.consultations.length) : null, + hasPendingDec ? (0, import_react2.createElement)("span", { style: { color: "var(--ss-primary)", fontWeight: 500 } }, "待决定") : null + ), + (0, import_react2.createElement)( + "div", + { className: "font-mono-num", style: { display: "flex", alignItems: "center", gap: 4, marginLeft: "auto", flexShrink: 0 } }, + (0, import_react2.createElement)("span", null, item.modelLabel), + (0, import_react2.createElement)("span", null, "·"), + (0, import_react2.createElement)("span", null, item.durationText) + ) + ) + ); + } + function renderBoardOrList() { + if (loading && bundles.length === 0) { + return (0, import_react2.createElement)( + "div", + { className: "mwb-list-wrap" }, + (0, import_react2.createElement)("div", { className: "mwb-list-section", style: { padding: 32, textAlign: "center", fontSize: 12, color: "var(--ss-muted)" } }, "正在同步跨项目工作台数据…") + ); + } + const effectiveMode = isNarrow ? "list" : viewMode; + if (effectiveMode === "list") { + const inlinePending = isNarrow && pendingExpanded && (pendingEntries.length > 0 || Boolean(degradedInfo)); + return (0, import_react2.createElement)( + "div", + { className: "mwb-list-wrap" }, + inlinePending ? renderPendingZone(false) : null, + MASTER_ACTIVE_COLUMNS.map((col) => { + const items = sortMasterColumnItems(visibleItems.filter((it) => it.col === col.id)); + const blockedCnt = items.filter((it) => Boolean(it.blockage)).length; + return (0, import_react2.createElement)( + "section", + { className: "mwb-list-section", key: col.id }, + (0, import_react2.createElement)( + "div", + { className: "mwb-list-head" }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 } }, + (0, import_react2.createElement)("span", { className: dotToneClass(col.tone, col.id === "running" && items.length > 0) }), + (0, import_react2.createElement)("span", { style: { fontWeight: 600, color: "var(--ss-fg)" }, className: "truncate" }, col.title), + (0, import_react2.createElement)("span", { className: "ss-pill font-mono-num" }, String(items.length)), + blockedCnt > 0 ? (0, import_react2.createElement)("span", { className: "ss-pill is-error font-mono-num" }, "阻塞 " + blockedCnt) : null + ), + (0, import_react2.createElement)("span", { className: "mwb-hide-compact truncate", style: { color: "var(--ss-muted)" } }, col.subtitle) + ), + items.length === 0 ? (0, import_react2.createElement)("div", { style: { padding: "14px 16px", fontSize: 12, color: "var(--ss-muted)" } }, "当前无任务") : items.map((item) => { + const seat = SEATS[item.seatId]; + const selected = drawer?.type === "task" && drawer.itemKey === item.key; + const isBlocked = Boolean(item.blockage); + const isRun = item.col === "running" && !isBlocked; + const hasPendingDec = (item.decisions || []).some((d) => d.status === "pending"); + const badgeTone = isBlocked ? "error" : isRun ? "success" : "muted"; + return (0, import_react2.createElement)( + "button", + { + key: item.key, + type: "button", + className: "mwb-list-row" + (isBlocked ? " is-blocked" : "") + (selected ? " is-selected" : ""), + onClick: () => { + setDrawer({ type: "task", itemKey: item.key }); + setTaskTab("overview"); + } + }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, width: "100%" } }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 6, minWidth: 0 } }, + (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(" + item.projectColorVar + ")", flexShrink: 0 } }), + projectFilter === "all" ? [ + (0, import_react2.createElement)("span", { key: "pn", className: "font-mono-num truncate", style: { color: "var(--ss-fg)", fontWeight: 500 } }, item.projectName), + (0, import_react2.createElement)("span", { key: "sep", style: { color: "var(--ss-muted)" } }, "·") + ] : null, + (0, import_react2.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)", flexShrink: 0 } }, item.id) + ), + (0, import_react2.createElement)( + "span", + { className: "ss-pill is-" + badgeTone }, + (0, import_react2.createElement)("span", { className: dotToneClass(badgeTone, isRun) }), + (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, isBlocked ? "阻塞 · " + (seat?.label || "—") : seat?.label || "—") + ) + ), + (0, import_react2.createElement)("div", { className: "line-clamp-2", style: { fontWeight: 600, color: "var(--ss-fg)" } }, item.title), + (0, import_react2.createElement)( + "div", + { style: { display: "flex", flexWrap: "wrap", alignItems: "center", justifyContent: "space-between", gap: "4px 12px", width: "100%" } }, + (0, import_react2.createElement)("span", { className: "truncate", style: { minWidth: 0, flex: "1 1 160px", color: isBlocked ? "var(--ss-error)" : "var(--ss-muted)", fontWeight: isBlocked ? 500 : 400 } }, item.ticker), + (0, import_react2.createElement)( + "span", + { className: "font-mono-num", style: { display: "inline-flex", alignItems: "center", gap: 8, color: "var(--ss-muted)", whiteSpace: "nowrap", marginLeft: "auto" } }, + item.progress ? (0, import_react2.createElement)("span", null, item.progress.done + "/" + item.progress.total) : null, + hasPendingDec ? (0, import_react2.createElement)("span", { style: { color: "var(--ss-primary)", fontFamily: "var(--ss-font-ui)", fontWeight: 500 } }, "待决定") : null, + (0, import_react2.createElement)("span", null, item.modelLabel + " · " + item.durationText) + ) + ) + ); + }) + ); + }) + ); + } + const is4Col = layoutMode === "board4"; + const cols = is4Col ? [...MASTER_ACTIVE_COLUMNS, MASTER_BLOCKED_COLUMN] : MASTER_ACTIVE_COLUMNS; + return (0, import_react2.createElement)( + "div", + { className: "mwb-kanban-board" + (is4Col ? " is-cols-4" : "") }, + cols.map((col) => { + const items = is4Col ? col.id === "blocked" ? sortMasterColumnItems(visibleItems.filter((it) => it.col !== "done" && Boolean(it.blockage))) : sortMasterColumnItems(visibleItems.filter((it) => it.col === col.id && !it.blockage)) : sortMasterColumnItems(visibleItems.filter((it) => it.col === col.id)); + const blockedCnt = !is4Col ? items.filter((it) => Boolean(it.blockage)).length : 0; + return (0, import_react2.createElement)( + "section", + { className: "mwb-kanban-col", key: col.id }, + (0, import_react2.createElement)( + "div", + { className: "mwb-kanban-col-head" }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 6 } }, + (0, import_react2.createElement)("span", { className: dotToneClass(col.tone, col.id === "running" && items.length > 0) }), + (0, import_react2.createElement)("h2", { style: { margin: 0, fontSize: 12, fontWeight: 600, color: "var(--ss-fg)" }, className: "truncate" }, col.title), + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 4, marginLeft: "auto", flexShrink: 0 } }, + blockedCnt > 0 ? (0, import_react2.createElement)("span", { className: "ss-pill is-error font-mono-num" }, "阻塞 " + blockedCnt) : null, + (0, import_react2.createElement)("span", { className: "ss-pill font-mono-num" }, String(items.length)) + ) + ), + (0, import_react2.createElement)("div", { className: "truncate", style: { fontSize: 12, color: "var(--ss-muted)", marginTop: 2 } }, col.subtitle) + ), + (0, import_react2.createElement)( + "div", + { className: "mwb-kanban-col-list" }, + items.length === 0 ? (0, import_react2.createElement)("div", { style: { border: "1px dashed var(--ss-border)", borderRadius: 8, padding: "28px 12px", textAlign: "center", fontSize: 12, color: "var(--ss-muted)" } }, "当前无任务") : items.map(renderKanbanCard) + ) + ); + }) + ); + } + function renderDrawer() { + if (!drawer) return null; + if (drawer.type === "task") { + const item = allItems.find((it) => it.key === drawer.itemKey); + if (!item) return null; + const seat = SEATS[item.seatId]; + const tabs = [ + { id: "overview", label: "概览" }, + { id: "subtasks", label: "子项 (" + (item.subtasks?.length || 0) + ")" }, + { id: "consult", label: "会商 (" + (item.consultations?.length || 0) + ")" }, + { id: "artifacts", label: "交付 (" + (item.artifacts?.length || 0) + ")" } + ]; + let tabBody = null; + if (taskTab === "overview") { + tabBody = (0, import_react2.createElement)( + "div", + { style: { display: "flex", flexDirection: "column", gap: 12 } }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, + (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, "当前阶段"), + (0, import_react2.createElement)( + "span", + { className: "ss-pill is-" + stageTone(item.col) }, + (0, import_react2.createElement)("span", { className: dotToneClass(stageTone(item.col), false) }), + stageTitle(item.col) + ) + ), + item.blockage ? (0, import_react2.createElement)( + "div", + { style: { borderRadius: 12, border: "1px solid color-mix(in srgb,var(--ss-error) 34%,var(--ss-border))", background: "color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card))", padding: 12, display: "flex", flexDirection: "column", gap: 8 } }, + (0, import_react2.createElement)("div", { style: { fontWeight: 600, color: "var(--ss-error)" } }, item.blockage.label), + (0, import_react2.createElement)("p", { style: { margin: 0, lineHeight: 1.55 } }, item.blockage.reason), + (0, import_react2.createElement)( + "div", + { style: { display: "flex", flexWrap: "wrap", gap: 8 } }, + item.blockage.canRedispatch ? (0, import_react2.createElement)("button", { + type: "button", + className: "frameless-primary-btn", + disabled: busy, + onClick: () => void handleRedispatch(item) + }, "显式重投并恢复执行") : (0, import_react2.createElement)("button", { + type: "button", + className: "frameless-btn", + disabled: busy, + onClick: () => void handleOpenSeat(item.projectId, item.seatId) + }, "前往「" + (seat?.label || item.seatId) + "」处理") + ) + ) : null, + item.originalText ? (0, import_react2.createElement)( + "div", + { style: { borderRadius: 12, border: "1px solid color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border))", background: "color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card))", padding: 12, display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react2.createElement)("div", { style: { fontWeight: 500, color: "var(--ss-primary)" } }, "用户原话"), + (0, import_react2.createElement)("p", { style: { margin: 0, lineHeight: 1.6 } }, "「" + item.originalText + "」") + ) : null, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react2.createElement)("div", { style: { fontWeight: 500, color: "var(--ss-muted)" } }, "任务说明"), + (0, import_react2.createElement)("p", { style: { margin: 0, lineHeight: 1.6, color: "var(--ss-fg)" } }, item.goal || "—") + ), + (0, import_react2.createElement)( + "div", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react2.createElement)("div", { style: { fontWeight: 500, color: "var(--ss-muted)" } }, "实时进展 / 产出"), + (0, import_react2.createElement)("div", { style: { borderRadius: 12, background: "var(--ss-subtle)", border: "1px solid var(--ss-border)", padding: 12, lineHeight: 1.6, whiteSpace: "pre-wrap" } }, item.result || item.ticker) + ) + ); + } else if (taskTab === "subtasks") { + tabBody = (item.subtasks?.length || 0) === 0 ? (0, import_react2.createElement)("div", { style: { padding: "36px 0", textAlign: "center", color: "var(--ss-muted)" } }, "该任务未拆分部门子项。") : (0, import_react2.createElement)("div", { style: { display: "flex", flexDirection: "column", gap: 8 } }, item.subtasks.map((st) => (0, import_react2.createElement)( + "div", + { + key: st.id, + style: { borderRadius: 12, border: "1px solid var(--ss-border)", background: "var(--ss-subtle)", padding: 12, display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } + }, + (0, import_react2.createElement)( + "div", + { style: { minWidth: 0 } }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 8 } }, + (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700 } }, SEATS[st.seatId]?.label || st.seatId), + (0, import_react2.createElement)( + "span", + { className: "ss-pill is-" + (st.status === "done" ? "success" : st.status === "blocked" ? "error" : st.status === "running" ? "primary" : "muted") }, + st.status === "done" ? "已完成" : st.status === "blocked" ? "阻塞" : st.status === "running" ? "执行中" : "待派" + ) + ), + (0, import_react2.createElement)("div", { style: { fontWeight: 500, marginTop: 4 } }, st.title), + st.result ? (0, import_react2.createElement)("div", { style: { color: "var(--ss-muted)", marginTop: 2 } }, st.result) : null + ), + (0, import_react2.createElement)("button", { type: "button", className: "frameless-link", disabled: busy, onClick: () => void handleOpenSeat(item.projectId, st.seatId) }, "会话 ↗") + ))); + } else if (taskTab === "consult") { + tabBody = (item.consultations?.length || 0) === 0 ? (0, import_react2.createElement)("div", { style: { padding: "36px 0", textAlign: "center", color: "var(--ss-muted)" } }, "暂无部门会商记录。") : (0, import_react2.createElement)("div", { style: { display: "flex", flexDirection: "column", gap: 10 } }, item.consultations.map((c) => (0, import_react2.createElement)( + "div", + { + key: c.id || c.createdAt, + style: { borderRadius: 12, border: "1px solid var(--ss-border)", background: "var(--ss-subtle)", padding: 12, display: "flex", flexDirection: "column", gap: 4 } + }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", justifyContent: "space-between", gap: 8, color: "var(--ss-muted)" } }, + (0, import_react2.createElement)( + "span", + { style: { fontWeight: 500, color: "var(--ss-fg)" } }, + (SEATS[c.fromSeatId]?.label || c.fromSeatId) + " → " + (c.toSeatIds || []).map((x) => SEATS[x]?.label || x).join("、") + ), + (0, import_react2.createElement)("span", { className: "font-mono-num" }, formatDateTime(c.createdAt)) + ), + (0, import_react2.createElement)("p", { style: { margin: 0, lineHeight: 1.55 } }, c.text) + ))); + } else { + tabBody = (item.artifacts?.length || 0) === 0 ? (0, import_react2.createElement)("div", { style: { padding: "36px 0", textAlign: "center", color: "var(--ss-muted)" } }, "尚无关联交付物。") : (0, import_react2.createElement)("div", { style: { display: "flex", flexDirection: "column", gap: 8 } }, item.artifacts.map((art) => (0, import_react2.createElement)( + "div", + { + key: art.id, + style: { borderRadius: 12, border: "1px solid var(--ss-border)", background: "var(--ss-subtle)", padding: "10px 12px", display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } + }, + (0, import_react2.createElement)( + "div", + { style: { minWidth: 0 } }, + (0, import_react2.createElement)("div", { style: { fontWeight: 500 } }, art.title), + art.path ? (0, import_react2.createElement)("div", { className: "font-mono-num", style: { color: "var(--ss-primary)", wordBreak: "break-all" } }, art.path) : null + ), + art.path ? (0, import_react2.createElement)("button", { + type: "button", + className: "frameless-link", + onClick: () => copyText(art.path, (ok) => showToast(ok ? "已复制路径:" + art.path : "请手动选择复制路径", ok ? "success" : "muted")) + }, "复制") : null + ))); + } + return (0, import_react2.createElement)( + "aside", + { className: "mwb-split-drawer", "aria-label": "任务详情抽屉" }, + (0, import_react2.createElement)( + "div", + { className: "mwb-drawer-head" }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, fontSize: 12 } }, + (0, import_react2.createElement)( + "div", + { className: "font-mono-num", style: { display: "flex", alignItems: "center", gap: 6, color: "var(--ss-muted)", minWidth: 0 } }, + drawer.fromDone ? [ + (0, import_react2.createElement)("button", { key: "bk", type: "button", className: "frameless-link", onClick: () => setDrawer({ type: "done" }) }, "← 已交付"), + (0, import_react2.createElement)("span", { key: "sp" }, "/") + ] : null, + (0, import_react2.createElement)("span", null, item.id), + (0, import_react2.createElement)("span", null, "·"), + (0, import_react2.createElement)("span", { className: "truncate" }, item.projectName) + ), + (0, import_react2.createElement)("button", { type: "button", className: "wb-modal-close", "aria-label": "关闭抽屉", onClick: () => setDrawer(null) }, "✕") + ), + (0, import_react2.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600, lineHeight: 1.4 } }, item.title), + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, paddingTop: 2 } }, + (0, import_react2.createElement)( + "span", + { style: { display: "inline-flex", alignItems: "center", gap: 6, fontSize: 12 } }, + (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 14 } }, seat?.label || item.seatId), + (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, seat?.duty || "") + ), + (0, import_react2.createElement)("button", { + type: "button", + className: "frameless-primary-btn", + disabled: busy, + onClick: () => void handleOpenSeat(item.projectId, item.seatId) + }, "打开" + (seat?.label || "席位") + "会话 ↗") + ) + ), + (0, import_react2.createElement)( + "div", + { className: "mwb-drawer-tabs" }, + tabs.map((tb) => (0, import_react2.createElement)("button", { + key: tb.id, + type: "button", + className: "mwb-drawer-tab" + (taskTab === tb.id ? " is-active" : ""), + onClick: () => setTaskTab(tb.id) + }, tb.label)) + ), + (0, import_react2.createElement)("div", { className: "mwb-drawer-body" }, tabBody) + ); + } + if (drawer.type === "done") { + return (0, import_react2.createElement)( + "aside", + { className: "mwb-split-drawer", "aria-label": "已交付归档" }, + (0, import_react2.createElement)( + "div", + { className: "mwb-drawer-head" }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, + (0, import_react2.createElement)( + "div", + null, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", gap: 8 } }, + (0, import_react2.createElement)("span", { className: "ss-dot is-success" }), + (0, import_react2.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, "已交付归档"), + (0, import_react2.createElement)("span", { className: "font-mono-num", style: { fontSize: 12, color: "var(--ss-muted)" } }, String(doneItems.length)) + ), + (0, import_react2.createElement)( + "p", + { style: { margin: "2px 0 0", fontSize: 12, color: "var(--ss-muted)" } }, + projectFilter === "all" ? "跨项目验收通过记录 · 点击查看详情" : "当前项目:" + (effectiveProjectMeta?.name || "") + ) + ), + (0, import_react2.createElement)("button", { type: "button", className: "wb-modal-close", "aria-label": "关闭抽屉", onClick: () => setDrawer(null) }, "✕") + ) + ), + (0, import_react2.createElement)( + "div", + { className: "mwb-drawer-body" }, + doneItems.length === 0 ? (0, import_react2.createElement)("div", { style: { padding: "44px 0", textAlign: "center", color: "var(--ss-muted)" } }, "当前筛选条件下暂无已交付任务") : doneItems.map((item) => (0, import_react2.createElement)( + "button", + { + key: item.key, + type: "button", + className: "mwb-kanban-card", + onClick: () => { + setDrawer({ type: "task", itemKey: item.key, fromDone: true }); + setTaskTab("overview"); + } + }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, width: "100%" } }, + (0, import_react2.createElement)( + "span", + { style: { display: "inline-flex", alignItems: "center", gap: 6, minWidth: 0 } }, + (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(" + item.projectColorVar + ")", flexShrink: 0 } }), + (0, import_react2.createElement)("span", { className: "font-mono-num truncate", style: { fontWeight: 500 } }, item.projectName), + (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, "·"), + (0, import_react2.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)", flexShrink: 0 } }, item.id) + ), + (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700, color: "var(--ss-muted)", flexShrink: 0 } }, SEATS[item.seatId]?.label || "—") + ), + (0, import_react2.createElement)("div", { style: { fontWeight: 600, lineHeight: 1.45 } }, item.title), + (0, import_react2.createElement)("div", { className: "line-clamp-2", style: { color: "var(--ss-muted)", lineHeight: 1.5 } }, item.ticker), + (0, import_react2.createElement)( + "div", + { className: "font-mono-num", style: { display: "flex", justifyContent: "space-between", width: "100%", color: "var(--ss-muted)" } }, + (0, import_react2.createElement)("span", null, item.artifacts?.length ? "交付物 " + item.artifacts.length : "已归档"), + (0, import_react2.createElement)("span", null, item.modelLabel + " · " + item.durationText) + ) + )) + ) + ); + } + if (drawer.type === "settings") { + const groups = [ + { title: "中枢", ids: SEAT_GROUPS.lead }, + { title: "三省", ids: SEAT_GROUPS.sansheng }, + { title: "六部", ids: SEAT_GROUPS.liubu } + ]; + const gSeats = globalDefaults?.seats || {}; + return (0, import_react2.createElement)( + "aside", + { className: "mwb-split-drawer", "aria-label": "全局默认模型配置" }, + (0, import_react2.createElement)( + "div", + { className: "mwb-drawer-head" }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, + (0, import_react2.createElement)( + "div", + null, + (0, import_react2.createElement)("h2", { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, "全局默认模型(R-001)"), + (0, import_react2.createElement)("p", { className: "font-mono-num truncate", style: { margin: "2px 0 0", fontSize: 12, color: "var(--ss-muted)" } }, globalDefaults?.path || "~/.dsh/sansheng-liubu/setting.json") + ), + (0, import_react2.createElement)("button", { type: "button", className: "wb-modal-close", "aria-label": "关闭抽屉", onClick: () => setDrawer(null) }, "✕") + ) + ), + (0, import_react2.createElement)( + "div", + { className: "mwb-drawer-body" }, + (0, import_react2.createElement)("p", { style: { margin: 0, color: "var(--ss-muted)", lineHeight: 1.55 } }, "点击任一席位展开调整;未设项目覆盖的席位自动从此处读取全局默认。"), + groups.map((group) => (0, import_react2.createElement)( + "div", + { key: group.title, style: { display: "flex", flexDirection: "column", gap: 6 } }, + (0, import_react2.createElement)("div", { style: { padding: "0 4px", fontWeight: 500, color: "var(--ss-muted)" } }, group.title), + (0, import_react2.createElement)("div", { className: "mwb-gcfg-group" }, group.ids.map((sid) => { + const meta = SEATS[sid]; + const current = gSeats[sid] || null; + const { modelKey, effort } = modelPartsOf(current); + const choiceObj = modelChoices.find((c) => c.value === modelKey) || null; + const efforts = choiceObj?.efforts || []; + const extraChoices = modelKey && !choiceObj ? [{ value: modelKey, label: current.model + "(目录未列出)", efforts: effort ? [effort] : [] }, ...modelChoices] : modelChoices; + const isOpen = expandedGlobalSeatId === sid; + const previewText = current ? shortModelName(current) : "未设置(回退部署默认)"; + return (0, import_react2.createElement)( + "div", + { key: sid, className: "mwb-gcfg-item" + (isOpen ? " is-open" : "") }, + (0, import_react2.createElement)( + "button", + { + type: "button", + className: "mwb-gcfg-toggle", + "aria-expanded": isOpen, + onClick: () => setExpandedGlobalSeatId(isOpen ? null : sid) + }, + (0, import_react2.createElement)( + "span", + { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 } }, + (0, import_react2.createElement)("span", { className: "font-seal", style: { fontWeight: 700, fontSize: 14, flexShrink: 0 } }, meta.label), + (0, import_react2.createElement)("span", { className: "truncate", style: { color: "var(--ss-muted)" } }, meta.duty) + ), + (0, import_react2.createElement)( + "span", + { style: { display: "flex", alignItems: "center", gap: 8, flexShrink: 0 } }, + (0, import_react2.createElement)("span", { className: "ss-pill font-mono-num", style: { color: current ? "var(--ss-fg)" : "var(--ss-muted)" } }, previewText), + ChevronDownSvg({ style: { color: isOpen ? "var(--ss-primary)" : "var(--ss-muted)", transform: isOpen ? "rotate(180deg)" : "none", transition: "transform 150ms ease" } }) + ) + ), + isOpen ? (0, import_react2.createElement)( + "div", + { className: "mwb-gcfg-body" }, + (0, import_react2.createElement)( + "div", + { style: { display: "grid", gridTemplateColumns: "repeat(auto-fit,minmax(140px,1fr))", gap: 8 } }, + (0, import_react2.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, "主任模型"), + (0, import_react2.createElement)( + "select", + { + className: "wb-select", + disabled: busy, + value: modelKey, + onChange: (e) => { + const nextKey = e.target.value; + const nextChoice = modelChoices.find((c) => c.value === nextKey); + const nextEff = nextChoice?.efforts?.includes(effort) ? effort : nextChoice?.efforts?.[0] || ""; + void handleSetGlobalSeat(sid, modelObjectFromParts(nextKey, nextEff)); + } + }, + (0, import_react2.createElement)("option", { value: "" }, "未设置(回退部署默认)"), + extraChoices.map((opt) => (0, import_react2.createElement)("option", { key: opt.value, value: opt.value }, opt.label)) + ) + ), + (0, import_react2.createElement)( + "label", + { style: { display: "flex", flexDirection: "column", gap: 4 } }, + (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, "推理等级"), + (0, import_react2.createElement)( + "select", + { + className: "wb-select", + disabled: busy || efforts.length === 0, + value: effort, + onChange: (e) => void handleSetGlobalSeat(sid, modelObjectFromParts(modelKey, e.target.value)) + }, + (0, import_react2.createElement)("option", { value: "" }, efforts.length === 0 ? "默认(固定)" : "默认"), + efforts.map((ef) => (0, import_react2.createElement)("option", { key: ef, value: ef }, ef)) + ) + ) + ), + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, + (0, import_react2.createElement)("button", { + type: "button", + className: "frameless-link", + disabled: busy || !current, + style: { color: current ? "var(--ss-error)" : "var(--ss-muted)" }, + onClick: () => void handleSetGlobalSeat(sid, null) + }, "清除全局默认"), + (0, import_react2.createElement)("button", { + type: "button", + className: "frameless-btn", + onClick: () => setExpandedGlobalSeatId(null) + }, "收起") + ) + ) : null + ); + })) + )), + (0, import_react2.createElement)("button", { + type: "button", + className: "frameless-primary-btn", + style: { width: "100%", padding: "9px 12px", borderRadius: 12 }, + disabled: busy, + onClick: () => void handleSeedGlobalDefaults() + }, "按当前项目同步初始化全局默认") + ) + ); + } + return null; + } + return (0, import_react2.createElement)( + "div", + { ref: rootRef, className: "ssmwb", "data-sansheng-master": "1" }, + // 1. 顶部单行指令栏 + 窄栏可展开搜索行 + (0, import_react2.createElement)( + "header", + { className: "mwb-header" }, + (0, import_react2.createElement)( + "div", + { className: "mwb-header-row" }, + (0, import_react2.createElement)( + "div", + { className: "mwb-header-left" }, + (0, import_react2.createElement)( + "div", + { className: "mwb-brand-box" }, + (0, import_react2.createElement)("div", { className: "mwb-brand-seal" }, "省"), + (0, import_react2.createElement)("h1", { className: "mwb-brand-title mwb-hide-compact" }, "三省六部") + ), + (0, import_react2.createElement)("span", { className: "mwb-brand-sep mwb-hide-compact" }, "/"), + (0, import_react2.createElement)( + "div", + { className: "mwb-proj-wrap" }, + (0, import_react2.createElement)( + "button", + { + type: "button", + className: "mwb-proj-trigger" + (projMenuOpen ? " is-open" : ""), + "aria-haspopup": "listbox", + "aria-expanded": projMenuOpen, + onClick: () => setProjMenuOpen((v) => !v) + }, + (0, import_react2.createElement)( + "span", + { style: { display: "inline-flex", alignItems: "center", gap: 6, minWidth: 0, fontWeight: 500 } }, + (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: projectFilter === "all" ? "var(--ss-primary)" : "var(" + (effectiveProjectMeta?.colorVar || "--ss-primary") + ")", flexShrink: 0 } }), + projectFilter === "all" ? [ + (0, import_react2.createElement)("span", { key: "all", className: "truncate" }, "全部项目"), + (0, import_react2.createElement)("span", { key: "cnt", className: "font-mono-num", style: { color: "var(--ss-muted)", fontWeight: 400, flexShrink: 0 } }, String(activeProjList.length)) + ] : (0, import_react2.createElement)("span", { className: "font-mono-num truncate" }, effectiveProjectMeta?.name || projectFilter) + ), + ChevronDownSvg({ style: { color: "var(--ss-muted)", transform: projMenuOpen ? "rotate(180deg)" : "none", transition: "transform 150ms ease", flexShrink: 0 } }) + ), + projMenuOpen ? (0, import_react2.createElement)( + "div", + { className: "mwb-proj-popover", role: "listbox", "aria-label": "切换项目范围" }, + (0, import_react2.createElement)( + "button", + { + type: "button", + className: "mwb-proj-opt" + (projectFilter === "all" ? " is-selected" : ""), + onClick: () => { + setProjectFilter("all"); + setProjMenuOpen(false); + } + }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } }, + (0, import_react2.createElement)( + "span", + { style: { display: "inline-flex", alignItems: "center", gap: 8, fontWeight: projectFilter === "all" ? 600 : 500 } }, + (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(--ss-primary)" } }), + "全部项目" + ), + (0, import_react2.createElement)( + "span", + { className: "font-mono-num", style: { display: "inline-flex", alignItems: "center", gap: 6 } }, + totalPendingAll > 0 ? (0, import_react2.createElement)("span", { className: "frameless-zone-count" }, String(totalPendingAll)) : null, + (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, String(totalActiveAll)), + projectFilter === "all" ? (0, import_react2.createElement)("span", { style: { color: "var(--ss-primary)" } }, "✓") : null + ) + ) + ), + (0, import_react2.createElement)("div", { style: { padding: "6px 10px 4px", borderTop: "1px solid var(--ss-border)", marginTop: 2, fontSize: 12, color: "var(--ss-muted)" } }, "工作区 (" + activeProjList.length + ")"), + (0, import_react2.createElement)( + "div", + { style: { maxHeight: 256, overflowY: "auto", display: "flex", flexDirection: "column", gap: 2 } }, + activeProjList.map((p) => { + const on = projectFilter === p.id; + return (0, import_react2.createElement)( + "button", + { + key: p.id, + type: "button", + className: "mwb-proj-opt" + (on ? " is-selected" : ""), + onClick: () => { + setProjectFilter(p.id); + setProjMenuOpen(false); + } + }, + (0, import_react2.createElement)( + "div", + { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 6 } }, + (0, import_react2.createElement)( + "span", + { style: { display: "inline-flex", alignItems: "center", gap: 8, minWidth: 0 } }, + (0, import_react2.createElement)("span", { style: { width: 8, height: 8, borderRadius: "50%", background: "var(" + p.colorVar + ")", flexShrink: 0 } }), + (0, import_react2.createElement)("span", { className: "font-mono-num truncate", style: { fontWeight: on ? 600 : 500 } }, p.name) + ), + (0, import_react2.createElement)( + "span", + { className: "font-mono-num", style: { display: "inline-flex", alignItems: "center", gap: 6, flexShrink: 0 } }, + p.pendCnt > 0 ? (0, import_react2.createElement)("span", { className: "frameless-zone-count" }, String(p.pendCnt)) : null, + (0, import_react2.createElement)("span", { style: { color: "var(--ss-muted)" } }, String(p.activeCnt)), + on ? (0, import_react2.createElement)("span", { style: { color: "var(--ss-primary)" } }, "✓") : null + ) + ), + p.path ? (0, import_react2.createElement)("div", { className: "font-mono-num truncate", style: { paddingLeft: 16, fontSize: 12, color: "var(--ss-muted)", opacity: 0.85 } }, p.path) : null + ); + }) + ) + ) : null + ), + !isNarrow ? (0, import_react2.createElement)( + "div", + { className: "mwb-view-switch", role: "group", "aria-label": "切换视图" }, + (0, import_react2.createElement)("button", { type: "button", className: "mwb-view-btn" + (viewMode === "board" ? " is-active" : ""), onClick: () => setViewMode("board") }, "看板"), + (0, import_react2.createElement)("button", { type: "button", className: "mwb-view-btn" + (viewMode === "list" ? " is-active" : ""), onClick: () => setViewMode("list") }, "列表") + ) : null + ), + (0, import_react2.createElement)( + "div", + { className: "mwb-header-right" }, + (0, import_react2.createElement)( + "div", + { className: "mwb-search-inline" }, + SearchSvg({ style: { color: "var(--ss-muted)", flexShrink: 0 } }), + (0, import_react2.createElement)("input", { + type: "search", + className: "mwb-search-input", + value: search, + placeholder: "搜索任务、编号、席位…", + onChange: (e) => setSearch(e.target.value) + }) + ), + (0, import_react2.createElement)("button", { + type: "button", + className: "mwb-search-icon-btn" + (searchOpen || search.trim() ? " is-active" : ""), + title: "搜索任务、编号、席位", + "aria-label": "搜索任务", + "aria-expanded": compactSearch && searchOpen, + onClick: () => { + const next = !searchOpen; + setSearchOpen(next); + if (next) setTimeout(() => narrowSearchRef.current?.focus(), 0); + } + }, SearchSvg({ width: 14, height: 14 })), + (pendingEntries.length > 0 || Boolean(degradedInfo)) && !pendingExpanded ? (0, import_react2.createElement)( + "button", + { + type: "button", + className: "mwb-nav-btn is-pending", + onClick: () => { + setPendingExpanded(true); + setDrawer(null); + } + }, + (0, import_react2.createElement)("span", { className: "ss-dot is-primary is-pulse" }), + (0, import_react2.createElement)("span", null, "待处理"), + (0, import_react2.createElement)("span", { className: "font-mono-num", style: { fontWeight: 600 } }, String(pendingEntries.length)) + ) : null, + (0, import_react2.createElement)( + "button", + { + type: "button", + className: "mwb-nav-btn" + (drawer?.type === "done" || drawer?.fromDone ? " is-active" : ""), + onClick: () => setDrawer((d) => d?.type === "done" ? null : { type: "done" }) + }, + (0, import_react2.createElement)("span", { className: "ss-dot is-success" }), + (0, import_react2.createElement)("span", null, "已交付"), + (0, import_react2.createElement)("span", { className: "font-mono-num", style: { color: "var(--ss-muted)" } }, String(doneItems.length)) + ), + (0, import_react2.createElement)( + "button", + { + type: "button", + className: "mwb-nav-btn" + (drawer?.type === "settings" ? " is-active" : ""), + onClick: () => setDrawer((d) => d?.type === "settings" ? null : { type: "settings" }) + }, + SlidersSvg(), + (0, import_react2.createElement)( + "span", + { style: { display: "inline-flex", alignItems: "center" } }, + (0, import_react2.createElement)("span", { className: "mwb-hide-xs" }, "全局"), + (0, import_react2.createElement)("span", null, "配置") + ) + ) + ) + ), + compactSearch && searchOpen ? (0, import_react2.createElement)( + "div", + { className: "mwb-narrow-search-bar" }, + (0, import_react2.createElement)( + "div", + { className: "mwb-narrow-search-input-wrap" }, + SearchSvg({ style: { color: "var(--ss-muted)", flexShrink: 0 } }), + (0, import_react2.createElement)("input", { + ref: narrowSearchRef, + type: "search", + className: "mwb-search-input", + value: search, + placeholder: "搜索任务、编号、席位…", + onChange: (e) => setSearch(e.target.value) + }) + ), + (0, import_react2.createElement)("button", { + type: "button", + className: "mwb-narrow-cancel", + onClick: () => { + setSearch(""); + setSearchOpen(false); + } + }, "取消") + ) : null + ), + // 2. 主区:提示条 + 看板/列表 + 右侧「待你处理」停靠区 + 覆盖式详情/已交付/全局配置抽屉 + (0, import_react2.createElement)( + "div", + { className: "mwb-main" }, + toast ? (0, import_react2.createElement)( + "div", + { className: "wb-toast-wrap" }, + (0, import_react2.createElement)( + "div", + { className: "wb-toast-box is-" + (toast.tone || "primary"), role: toast.tone === "error" ? "alert" : "status" }, + (0, import_react2.createElement)("span", null, toast.text), + (0, import_react2.createElement)("button", { type: "button", className: "wb-toast-close", "aria-label": "关闭提示", onClick: () => setToast(null) }, "✕") + ) + ) : null, + (0, import_react2.createElement)( + "div", + { className: "mwb-workspace" }, + (0, import_react2.createElement)("main", { className: "mwb-board-stage" }, renderBoardOrList()), + !isNarrow && hasPendingBlock ? (0, import_react2.createElement)("aside", { className: "mwb-pending-dock", "aria-label": "待你处理队列" }, renderPendingZone(true)) : null, + renderDrawer() + ) + ) ); } @@ -2722,741 +4626,417 @@ function workspaceForSession(items, sessionId, sessionSummary) { } // src/client/styles.js -var CSS = `.ssv2{ - /* ============ shadcn 式干净后台:平整、利落、高对比 ============ - 侧边栏 + 统计卡 + 表格的标准后台骨架,全页统一平整处理: - 白/浅灰底、1px 细边框、小圆角、无凸凹阴影、无拟物。 - 钴蓝只给选中态、主按钮与关键数字,其余用中性灰阶分层。 */ - - & { - color-scheme: light dark; - --bg: #ffffff; - --sidebar-bg: #fafafa; - --panel: #ffffff; - --panel-line: #e4e4e7; - --muted-bg: #f4f4f5; - --ink: #09090b; - --ink-2: #3f3f46; - --muted: #71717a; - --cobalt: #1e40d8; - --cobalt-ink: #17319f; - --cobalt-soft: rgba(30, 64, 216, .08); - --on-accent: #ffffff; - --ok: #2e7d4f; - --warn: #b06a12; - --bad: #b3372c; - --radius-panel: 8px; - --radius-control: 8px; - --font-ui: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; - --font-seat: "Noto Serif SC", "Songti SC", serif; - --font-num: "IBM Plex Mono", ui-monospace, "SF Mono", monospace; - } - @media (prefers-color-scheme: dark) { - & { - --bg: #09090b; - --sidebar-bg: #0c0c0e; - --panel: #18181b; - --panel-line: #27272a; - --muted-bg: #27272a; - --ink: #fafafa; - --ink-2: #d4d4d8; - --muted: #a1a1aa; - --cobalt: #829cff; - --cobalt-ink: #a9bcff; - --cobalt-soft: rgba(130, 156, 255, .13); - --on-accent: #141a38; - --ok: #5cb582; - --warn: #d99a45; - --bad: #e0705f; - } - } - - * { box-sizing: border-box; } -& { height: 100%; } -& { - margin: 0; - background: var(--bg); - color: var(--ink); - font-family: var(--font-ui); - font-size: 14px; - line-height: 1.55; - -webkit-font-smoothing: antialiased; - } - button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; } - button, [role="button"], select, summary, input:not([type="checkbox"], [type="radio"]) { min-height: 2.25rem; } - :focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; } - .num { font-family: var(--font-num); font-variant-numeric: tabular-nums; } - - /* ================= 布局:工作台占满整页(无文件树栏) ================= */ - .shell { display: block; min-height: 100vh; } - - /* ---------- 面板头部与横向标签页(都在内容区同一平面上) ---------- */ - .panel-top { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; } - .brand { display: flex; align-items: baseline; gap: 9px; } - .brand .seal { - font-family: var(--font-seat); font-weight: 900; font-size: 21px; letter-spacing: .06em; - } - .brand .sub { font-size: 11px; color: var(--muted); letter-spacing: .14em; } - .proj { - margin-left: auto; text-align: left; - display: flex; align-items: center; gap: 10px; - padding: 8px 12px; border-radius: var(--radius-control); - background: var(--panel); border: 1px solid var(--panel-line); - } - .proj:hover { background: var(--muted-bg); } - .proj .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; } - .proj .name { font-weight: 700; font-size: 13.5px; } - .proj .meta { font-size: 11.5px; color: var(--muted); } - .proj svg { margin-left: 4px; color: var(--muted); flex: 0 0 auto; } - - /* 横向标签页:灰槽轨道 + 白色选中块,与分段控件同一语言 */ - .tabs { - margin-top: 18px; display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; - border-radius: var(--radius-control); background: var(--muted-bg); - width: fit-content; max-width: 100%; - } - .tabs a { - display: inline-flex; align-items: center; gap: 8px; - padding: 6px 15px; border-radius: 6px; - color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 13.5px; - min-height: 36px; white-space: nowrap; - } - .tabs a svg { flex: 0 0 auto; opacity: .75; } - .tabs a:hover { color: var(--ink); } - .tabs a.on { - color: var(--cobalt-ink); font-weight: 700; - background: var(--panel); border: 1px solid var(--panel-line); padding: 5px 14px; - } - .tabs a.on svg { opacity: 1; color: var(--cobalt); } - /* ---------- 主区 ---------- */ - .main { min-width: 0; padding: 24px 28px 40px; width: 100%; } - /* ---------- 页签页面:一次只显示一页 ---------- */ - .page[hidden] { display: none; } - .page > .topbar { margin-top: 20px; } - tbody tr.clickable { cursor: pointer; } - .settings-stack { display: flex; flex-direction: column; gap: 20px; margin-top: 20px; } - .topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; } - .topbar h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: .01em; } - .topbar .date { color: var(--muted); font-size: 13px; } - .topbar .spacer { flex: 1; } - .search { - display: flex; align-items: center; gap: 8px; - border-radius: var(--radius-control); border: 1px solid var(--panel-line); background: var(--panel); - padding: 0 12px; flex: 0 1 250px; min-width: 0; - } - .search:focus-within { border-color: var(--cobalt); } - .search svg { color: var(--muted); flex: 0 0 auto; } - .search input { border: 0; background: none; outline: none; width: 100%; color: var(--ink); font: inherit; font-size: 13.5px; } - .search input::placeholder { color: var(--muted); } - .btn { - display: inline-flex; align-items: center; gap: 7px; - padding: 8px 16px; border-radius: var(--radius-control); font-weight: 500; - background: var(--panel); border: 1px solid var(--panel-line); - white-space: nowrap; - } - .btn:hover { background: var(--muted-bg); } - .btn.primary { background: var(--cobalt); border-color: var(--cobalt); color: var(--on-accent); font-weight: 700; } - .btn.primary:hover { background: var(--cobalt-ink); border-color: var(--cobalt-ink); } - /* 页头主按钮位:丞相(派工经丞相下达,点开即向丞相交代任务) */ - .btn-cx { gap: 9px; } - .btn-cx .cx-name { font-family: var(--font-seat); font-weight: 900; font-size: 16px; letter-spacing: .05em; line-height: 1; } - .btn-cx .cx-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(255,255,255,.22); flex: 0 0 auto; } - .btn-cx .cx-dot.idle { background: #d4d4d8; box-shadow: none; } - .btn-cx .cx-state { font-size: 12px; font-weight: 500; opacity: .88; } - .btn-cx.selected { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--cobalt); } - .ws-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; } - .ws-actions .btn { padding: 7px 16px; } - .modal input[type="text"] { - width: 100%; border: 1px solid var(--panel-line); border-radius: var(--radius-control); - background: var(--panel); color: var(--ink); font: inherit; font-size: 13.5px; - padding: 8px 10px; - } - .modal input[type="text"]:focus { border-color: var(--cobalt); outline: none; } - - /* ---------- 统计卡(骨架:平、脆、白) ---------- */ - .stats { - display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; - margin-top: 22px; - } - .stat { - background: var(--panel); border: 1px solid var(--panel-line); - border-radius: var(--radius-panel); padding: 16px 18px 14px; - } - .stat-link { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; } - .stat-link:hover { border-color: var(--cobalt); background: var(--cobalt-soft); } - .stat-link:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; } - .stat .label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; } - .stat .big { font-family: var(--font-num); font-size: 30px; font-weight: 600; line-height: 1.25; margin-top: 2px; } - .stat .big .unit { font-size: 14px; color: var(--muted); font-weight: 400; } - .stat .big em { font-style: normal; color: var(--cobalt); } - .stat .foot { font-size: 12px; color: var(--muted); margin-top: 2px; } - .stat .foot b { color: var(--ink-2); font-weight: 500; } - .spark { display: block; margin-top: 6px; } - - /* ---------- 内容网格 ---------- */ - .grid { - display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 368px); gap: 20px; - margin-top: 20px; align-items: start; - } - .panel-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; } - .panel-head h2 { font-size: 16px; margin: 0; font-weight: 700; } - .panel-head .hint { font-size: 12.5px; color: var(--muted); } - - /* 分段控件:平底灰槽 + 白色选中块 */ - .seg { - margin-left: auto; display: inline-flex; gap: 2px; padding: 3px; - border-radius: var(--radius-control); background: var(--muted-bg); - } - .seg button { padding: 5px 14px; border-radius: 6px; font-size: 13px; color: var(--ink-2); min-height: 32px; } - .seg button:hover { color: var(--ink); } - .seg button.on { background: var(--panel); border: 1px solid var(--panel-line); color: var(--ink); font-weight: 700; padding: 4px 13px; } - - /* ---------- 席位谱系:紧凑对齐 · 宽3排 / 中4排 / 窄5排 ---------- - 三省与六部共用一个整宽块:不再居中定宽 760px(宽屏下两边大片留白), - 改为撑满内容区、与上方统计卡和下方表格左右齐平,两排总宽仍相等、上下对齐成块。 - 所有列宽一律 minmax(0, 1fr):可随容器一路流式收缩。 - 三省恒为一排:尚书居中,中书、门下贴其两侧;六部宽屏 6 列、中屏 3×2、窄屏 2×3。 */ - .org-rows { - --tree-line: #c6c6cd; padding-top: 2px; - --ss-gap: 14px; - --lb-gap: 10px; - max-width: none; margin: 0; width: 100%; min-width: 0; - /* 谱系块自身成为容器:六部排数按本块的实际宽度决定(容器查询), - 不再只看视口——外壳/分栏让呈现宽度与视口不一致时,视口断点永远等不到。 */ - container-type: inline-size; - container-name: orgtree; - } - @media (prefers-color-scheme: dark) { .org-rows { --tree-line: #3d3d44; } } - .org-row { display: grid; gap: var(--lb-gap); min-width: 0; } - .org-row-1 { grid-template-columns: minmax(0, 1fr); } - .org-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--ss-gap); } - .org-row-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } - .org-cell { display: flex; justify-content: center; min-width: 0; } - .org-row-1 .node { width: min(248px, 100%); } - .org-row-3 .node { width: 100%; max-width: none; padding: 15px 18px 13px; } - .org-row-3 .node-name { font-size: 24px; } - .org-row-3 .node-role { font-size: 12.5px; } - .org-row-3 .node-task { font-size: 13px; } - .org-row-3 .node-model { font-size: 12.5px; } - .org-row-6 .node { width: 100%; max-width: none; } - /* 六部节点:撑满整宽后每席约 200px+,字号回到正常档,文字不再截断 */ - .org-row-6 .node { padding: 12px 14px 11px; } - .org-row-6 .node-top { gap: 4px 6px; flex-wrap: wrap; } - .org-row-6 .node-name { font-size: 20px; } - .org-row-6 .status { font-size: 12px; gap: 5px; } - .org-row-6 .node-role { font-size: 12px; margin-top: 3px; } - .org-row-6 .node-task { font-size: 12.5px; margin-top: 6px; } - .org-row-6 .node-model { font-size: 12px; margin-top: 6px; } - .org-row-6 .node-foot { margin-top: 8px; } - /* 排间连线层:竖线对准每列中心,横线贯通,全部横平竖直;高度收紧到 22px */ - .org-wires { position: relative; height: 22px; } - .org-wires .wire-v { position: absolute; width: 1px; background: var(--tree-line); } - .org-wires .wire-h { position: absolute; height: 1px; background: var(--tree-line); } - /* ===== 六部换行:触发依据是谱系块自身的宽度,不是视口 ===== - 根因(旧版):排数只由 @media (max-width:1080px/640px) 两条视口断点控制。 - 在应用外壳里,页面呈现宽度(分栏/嵌入)与视口宽并不总是一致,窗口缩到 - 视口断点之前就停住时,两条断点永远等不到,六张卡只能一味变小、挤在一排。 - 根治:三路同阈值(按谱系块宽:>1180 一排 6 张;≤1180 → 3×2;≤700 → 2×3)—— - ① JS ResizeObserver 实测 .org-rows 宽度写入 data-cols(主路,见脚本); - ② @container 容器查询(CSS 原生同义路);③ @media 视口断点(兜底,数值已 - 按主区左右内边距 56px 换算对齐)。三省在任何档位恒为一排。 */ - /* 中档:六部 3 列 × 2 排,每排总宽仍与三省排同宽对齐 */ - .org-rows[data-cols="3"] { --ss-gap: 10px; --lb-gap: 10px; } - .org-rows[data-cols="3"] .org-row-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } - .org-rows[data-cols="3"] .org-wires-2 .wire-h { left: 16.6667% !important; right: 16.6667% !important; } - .org-rows[data-cols="3"] .org-wires-2 .w2-b1 { left: 16.6667% !important; } - .org-rows[data-cols="3"] .org-wires-2 .w2-b2 { left: 50% !important; } - .org-rows[data-cols="3"] .org-wires-2 .w2-b3 { left: 83.3333% !important; } - .org-rows[data-cols="3"] .org-wires-2 .w2-b4, - .org-rows[data-cols="3"] .org-wires-2 .w2-b5, - .org-rows[data-cols="3"] .org-wires-2 .w2-b6 { display: none; } - @container orgtree (max-width: 1180px) { - .org-row-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } - .org-wires-2 .wire-h { left: 16.6667% !important; right: 16.6667% !important; } - .org-wires-2 .w2-b1 { left: 16.6667% !important; } - .org-wires-2 .w2-b2 { left: 50% !important; } - .org-wires-2 .w2-b3 { left: 83.3333% !important; } - .org-wires-2 .w2-b4, .org-wires-2 .w2-b5, .org-wires-2 .w2-b6 { display: none; } - } - @media (max-width: 1240px) { - .org-row-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } - .org-wires-2 .wire-h { left: 16.6667% !important; right: 16.6667% !important; } - .org-wires-2 .w2-b1 { left: 16.6667% !important; } - .org-wires-2 .w2-b2 { left: 50% !important; } - .org-wires-2 .w2-b3 { left: 83.3333% !important; } - .org-wires-2 .w2-b4, .org-wires-2 .w2-b5, .org-wires-2 .w2-b6 { display: none; } - } - /* 窄档:六部 2 列 × 3 排;三省仍一排;卡片上的「主任模型」行隐藏(配置面板不受影响) */ - .org-rows[data-cols="2"] { --ss-gap: 8px; --lb-gap: 8px; } - .org-rows[data-cols="2"] .org-row-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } - .org-rows[data-cols="2"] .node-model { display: none; } - .org-rows[data-cols="2"] .org-wires-2 .wire-h { left: 25% !important; right: 25% !important; } - .org-rows[data-cols="2"] .org-wires-2 .w2-b1 { left: 25% !important; } - .org-rows[data-cols="2"] .org-wires-2 .w2-b2 { left: 75% !important; } - .org-rows[data-cols="2"] .org-wires-2 .w2-b3, - .org-rows[data-cols="2"] .org-wires-2 .w2-b4, - .org-rows[data-cols="2"] .org-wires-2 .w2-b5, - .org-rows[data-cols="2"] .org-wires-2 .w2-b6 { display: none; } - .org-rows[data-cols="2"] .org-row .node { padding: 9px 9px 8px; } - .org-rows[data-cols="2"] .org-row-3 .node-name { font-size: 18px; } - .org-rows[data-cols="2"] .org-row-6 .node-name { font-size: 17px; } - .org-rows[data-cols="2"] .org-row .status { font-size: 11px; gap: 4px; } - .org-rows[data-cols="2"] .org-row .node-top { gap: 5px; flex-wrap: wrap; } - @container orgtree (max-width: 700px) { - .org-row-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } - .node-model { display: none; } - .org-wires-2 .wire-h { left: 25% !important; right: 25% !important; } - .org-wires-2 .w2-b1 { left: 25% !important; } - .org-wires-2 .w2-b2 { left: 75% !important; } - .org-wires-2 .w2-b3, .org-wires-2 .w2-b4, .org-wires-2 .w2-b5, .org-wires-2 .w2-b6 { display: none; } - .org-row .node { padding: 9px 9px 8px; } - .org-row-3 .node-name { font-size: 18px; } - .org-row-6 .node-name { font-size: 17px; } - .org-row .status { font-size: 11px; gap: 4px; } - } - @media (max-width: 760px) { - .node-model { display: none !important; } - .org-row-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } - .org-wires-2 .wire-h { left: 25% !important; right: 25% !important; } - .org-wires-2 .w2-b1 { left: 25% !important; } - .org-wires-2 .w2-b2 { left: 75% !important; } - .org-wires-2 .w2-b3, .org-wires-2 .w2-b4, .org-wires-2 .w2-b5, .org-wires-2 .w2-b6 { display: none; } - .org-row .node { padding: 9px 9px 8px; } - .org-row-3 .node-name { font-size: 18px; } - .org-row-6 .node-name { font-size: 17px; } - .org-row .status { font-size: 11px; gap: 4px; } - .org-row .node-top { gap: 5px; flex-wrap: wrap; } - } - - .node { - width: 158px; min-width: 0; - border-radius: var(--radius-panel); background: var(--panel); - border: 1px solid var(--panel-line); padding: 11px 13px 10px; - position: relative; z-index: 1; - } - .node-main { min-width: 0; } - .node-role, .node-task { overflow-wrap: break-word; } - .node-model .num { overflow-wrap: anywhere; } - .node:hover { border-color: var(--muted); } - .node.selected { border-color: var(--cobalt); background: var(--cobalt-soft); } - .node.dim { opacity: .28; } - .node-main { display: block; width: 100%; text-align: left; padding: 0; min-height: 0; } - .node-role, .node-task, .node-model { display: block; } - .node-top { display: flex; align-items: center; gap: 8px; } - .node-name { font-family: var(--font-seat); font-weight: 900; font-size: 21px; line-height: 1.1; letter-spacing: .04em; } - .node.selected .node-name { color: var(--cobalt); } - .node.root { width: min(248px, 100%); } - .node.root .node-name { font-size: 25px; } - @media (max-width: 1400px) { - .node { width: 136px; } - .node.root { width: min(248px, 100%); } - } - .node-role { font-size: 11.5px; color: var(--muted); margin-top: 3px; } - .node-task { margin-top: 7px; font-size: 12px; color: var(--ink-2); } - .node-task .t-label { color: var(--muted); font-size: 11px; display: block; } - .node-model { margin-top: 6px; font-size: 11.5px; color: var(--muted); } - .node-model .num { font-size: 11px; } - .node-foot { margin-top: 9px; display: flex; align-items: center; gap: 8px; } - .status { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; } - .status i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; } - .status.run i { background: var(--ok); box-shadow: 0 0 0 3px rgba(46,125,79,.16); } - .status.review i { background: var(--warn); box-shadow: 0 0 0 3px rgba(176,106,18,.16); } - .status.idle i { background: var(--muted); } - .elapsed { font-size: 12px; color: var(--muted); } - - /* ---------- 节点纵向骨架:内容区撑满,已耗时一行钉在卡底 ---------- */ - .node { display: flex; flex-direction: column; } - .node-main { flex: 1 1 auto; display: flex; flex-direction: column; } - .node-foot { margin-top: auto; } - .node-task .task-text { display: block; } - - /* ---------- 席位详情头:标题 + 开始对话主按钮 ---------- */ - .detail-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; } - .detail-head h3 { flex: 1 1 auto; min-width: 140px; margin: 0; overflow-wrap: anywhere; } - .detail-head .btn { flex: 0 0 auto; padding: 7px 16px; } - /* ---------- 会话弹窗:与该席对话 ---------- */ - .chat-log { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; } - .chat-msg { - max-width: 88%; padding: 9px 12px; border-radius: 8px; - font-size: 13.5px; line-height: 1.6; overflow-wrap: anywhere; - } - .chat-msg.seat { background: var(--muted-bg); color: var(--ink-2); align-self: flex-start; } - .chat-msg.me { background: var(--cobalt); color: var(--on-accent); align-self: flex-end; } - .chat-compose { display: flex; gap: 10px; margin-top: 16px; align-items: flex-end; } - .chat-compose textarea { - flex: 1; min-height: 44px; resize: vertical; - border: 1px solid var(--panel-line); border-radius: var(--radius-control); - background: var(--panel); color: var(--ink); font: inherit; font-size: 13.5px; - padding: 8px 10px; - } - .chat-compose textarea:focus { border-color: var(--cobalt); outline: none; } - .chat-compose .btn { flex: 0 0 auto; padding: 8px 18px; } - .chat-card { margin-top: 20px; } - .chat-card .chat-log { margin-top: 0; min-height: 260px; } - .chat-card .m-decided { margin: 12px 0 0; font-size: 13px; color: var(--muted); } - - /* ---------- 六部:六张等高卡,每段单行固定高,卡底已耗时齐平 ---------- */ - .org-row-6 .node { height: 100%; padding: 12px 14px; } - .org-row-6 .node-top { flex-wrap: nowrap; height: 30px; overflow: hidden; } - .org-row-6 .node-name { flex: 0 0 auto; } - .org-row-6 .status { flex: 0 0 auto; } - .org-row-6 .node-role { - white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - height: 20px; line-height: 20px; margin-top: 4px; - } - .org-row-6 .node-task { margin-top: 8px; } - .org-row-6 .node-task .t-label { height: 16px; line-height: 16px; } - .org-row-6 .node-task .task-text { - white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - height: 20px; line-height: 20px; - } - .org-row-6 .node-model { - white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - height: 20px; line-height: 20px; margin-top: 6px; - } - .org-row-6 .node-foot { margin-top: auto; padding-top: 9px; } - .org-row-6 .elapsed { - white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - height: 20px; line-height: 20px; display: block; - } - - /* ---------- 右列:详情 + 复核(骨架面板) ---------- */ - .rail { display: flex; flex-direction: column; gap: 20px; } - .detail-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; } - .card { - background: var(--panel); border: 1px solid var(--panel-line); - border-radius: var(--radius-panel); padding: 18px; - } - .card h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; } - .card h3 .count { - font-family: var(--font-num); font-size: 11.5px; background: var(--cobalt); color: var(--on-accent); - border-radius: 999px; padding: 0 8px; line-height: 19px; - } - .detail-name { font-family: var(--font-seat); font-weight: 900; font-size: 30px; color: var(--cobalt); line-height: 1.15; } - .detail-role { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; } - .kv { display: grid; grid-template-columns: 74px 1fr; row-gap: 8px; font-size: 13px; } - .kv dt { color: var(--muted); } - .kv dd { margin: 0; color: var(--ink); } - .kv dd .sub { color: var(--muted); font-size: 12px; } - .excerpt { - margin-top: 14px; border-top: 1px dashed var(--panel-line); padding-top: 12px; - font-size: 13px; color: var(--ink-2); - } - .excerpt .t-label { color: var(--muted); font-size: 11.5px; display: block; margin-bottom: 4px; } - - /* ---------- 部门配置面板:平表单 + 圆点文字标状态 ---------- */ - .card h3 .seat-tag { color: var(--cobalt); font-family: var(--font-seat); font-weight: 900; font-size: 16px; } - .cfg-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 16px; margin-top: 10px; } - .cfg-row { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); } - .cfg-row select { - border: 1px solid var(--panel-line); border-radius: var(--radius-control); - background: var(--panel); color: var(--ink); font: inherit; font-size: 13.5px; - padding: 7px 10px; width: 100%; - } - .cfg-row select:focus { border-color: var(--cobalt); outline: none; } - .cfg-skills { margin-top: 16px; border-top: 1px dashed var(--panel-line); padding-top: 12px; } - .cfg-skills .t-label { color: var(--muted); font-size: 11.5px; display: block; } - .skill-list { list-style: none; margin: 4px 0 0; padding: 0; } - .skill-list li { - display: flex; align-items: center; gap: 10px; - padding: 8px 0; border-top: 1px solid var(--panel-line); font-size: 13px; - } - .skill-list li:first-child { border-top: 0; padding-top: 4px; } - .skill-list .skill-name { flex: 1; min-width: 0; } - .skill-list .skill-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; } - .skill-list .skill-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; } - .skill-list .skill-state.bound { color: var(--ink); } - .skill-list .skill-state.bound i { background: var(--ok); box-shadow: 0 0 0 3px rgba(46,125,79,.16); } - .skill-toggle { - border: 1px solid var(--panel-line); border-radius: var(--radius-control); - background: var(--panel); padding: 4px 13px; font-size: 12.5px; min-height: 32px; white-space: nowrap; - } - .skill-toggle:hover { background: var(--muted-bg); } - @media (max-width: 640px) { .cfg-grid { grid-template-columns: 1fr; } } - - /* ---------- 工作区条目:一条一卡(门下审核 / 中书方案 / 尚书调度共用同一套) ---------- */ - .review-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; } - .review-card { - background: var(--panel); border: 1px solid var(--panel-line); - border-radius: var(--radius-panel); padding: 14px 16px 12px; - } - .review-card.decided { opacity: .55; } - .rc-head { display: flex; align-items: center; gap: 10px; } - .rc-title { - flex: 1; min-width: 0; font-weight: 700; font-size: 14.5px; color: var(--ink); - white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - } - .rc-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; flex: 0 0 auto; } - .rc-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(176,106,18,.16); flex: 0 0 auto; } - .rc-status.pass i { background: var(--ok); box-shadow: 0 0 0 3px rgba(46,125,79,.16); } - .rc-status.reject i { background: var(--bad); box-shadow: 0 0 0 3px rgba(179,55,44,.14); } - .rc-status.run i { background: var(--cobalt); box-shadow: 0 0 0 3px var(--cobalt-soft); } - .rc-status.idle i { background: var(--muted); box-shadow: none; } - .rc-meta-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; } - .rc-from { - font-size: 11.5px; font-weight: 500; color: var(--ink-2); - background: var(--muted-bg); border-radius: 999px; padding: 1px 9px; line-height: 19px; - white-space: nowrap; - } - .rc-meta { font-size: 12px; color: var(--muted); } - .rc-excerpt { - margin-top: 10px; background: var(--muted-bg); border-radius: 6px; - padding: 9px 11px; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; - display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; - } - .rc-excerpt.expanded { display: block; -webkit-line-clamp: unset; } - /* 定夺后记在卡上的批复理由 / 批语(回传提交席位照此修改) */ - .rc-reason { - margin-top: 10px; background: var(--muted-bg); border-radius: 6px; - padding: 8px 11px; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; - overflow-wrap: anywhere; - } - .rc-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; } - .rc-actions .spacer { flex: 1; } - .rc-actions .btn { padding: 5px 14px; font-size: 13px; min-height: 34px; } - .rc-actions .btn.pass { color: var(--cobalt-ink); font-weight: 700; } - .rc-actions .btn:disabled { opacity: .5; cursor: default; } - .rc-actions .btn:disabled:hover { background: var(--panel); } - .r-open { - display: inline-flex; align-items: center; gap: 4px; - font-size: 13px; font-weight: 500; color: var(--cobalt); padding: 5px 6px; min-height: 34px; - } - .r-open:hover { color: var(--cobalt-ink); text-decoration: underline; } - .empty-note { font-size: 13px; color: var(--muted); padding: 10px 0 2px; } - - /* ---------- 席位工作区:随选中席位切换内容 ---------- */ - .w-kind { - font-size: 11.5px; font-weight: 500; color: var(--cobalt-ink); - background: var(--cobalt-soft); border-radius: 999px; padding: 1px 9px; line-height: 19px; - } - .ws-sec { margin-top: 14px; } - .ws-sec:first-child { margin-top: 6px; } - .ws-sec .t-label { color: var(--muted); font-size: 11.5px; display: block; margin-bottom: 4px; } - .ws-sec p { margin: 0; font-size: 13.5px; color: var(--ink-2); } - /* 方案 / 调度 / 审核条目样式见上方「工作区条目:一条一卡」 */ - - /* ---------- 右列里的配置面板:字段上下排 ---------- */ - .rail .cfg-grid { grid-template-columns: minmax(0, 1fr); } - - /* ---------- 复核弹窗:看清待准奏内容再定夺 ---------- */ - .modal-backdrop { - position: fixed; inset: 0; z-index: 60; - background: rgba(9, 9, 11, .48); - display: flex; align-items: center; justify-content: center; - padding: 18px; - } - .modal-backdrop[hidden] { display: none; } - .modal { - background: var(--panel); color: var(--ink); - border: 1px solid var(--panel-line); border-radius: 12px; - width: min(580px, 100%); max-height: calc(100vh - 36px); overflow-y: auto; - padding: 20px 22px 18px; - } - .modal.wide { width: min(760px, 100%); } - .modal-head { display: flex; align-items: flex-start; gap: 12px; } - .modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; min-width: 0; } - .modal-close { - flex: 0 0 auto; width: 32px; height: 32px; min-height: 32px; - border: 1px solid var(--panel-line); border-radius: var(--radius-control); - display: inline-flex; align-items: center; justify-content: center; font-size: 15px; - } - .modal-close:hover { background: var(--muted-bg); } - .modal .m-from { font-size: 12.5px; color: var(--muted); margin-top: 3px; } - .modal .m-sec { margin-top: 15px; } - .modal .m-sec .t-label { color: var(--muted); font-size: 11.5px; display: block; margin-bottom: 4px; } - .modal .m-sec p { margin: 0; font-size: 13.5px; color: var(--ink-2); } - .modal .m-doubts { list-style: none; margin: 0; padding: 0; } - .modal .m-doubts li { padding: 6px 0 6px 16px; border-top: 1px solid var(--panel-line); font-size: 13.5px; color: var(--ink-2); position: relative; } - .modal .m-doubts li:first-child { border-top: 0; } - .modal .m-doubts li::before { content: ""; position: absolute; left: 2px; top: 14px; width: 5px; height: 5px; border-radius: 50%; background: var(--warn); } - .modal .m-source { - background: var(--muted-bg); border-radius: var(--radius-panel); - padding: 10px 12px; font-size: 13px; color: var(--ink-2); - } - .modal-actions { display: flex; gap: 10px; margin-top: 18px; } - .modal-actions .btn { padding: 7px 18px; } - .modal-actions .btn.pass { color: var(--cobalt-ink); font-weight: 700; } - .modal .m-decided { margin-top: 16px; font-size: 13px; color: var(--muted); } - .modal textarea { - width: 100%; border: 1px solid var(--panel-line); border-radius: var(--radius-control); - background: var(--panel); color: var(--ink); font: inherit; font-size: 13.5px; - padding: 8px 10px; resize: vertical; min-height: 64px; - } - .modal textarea:focus { border-color: var(--cobalt); outline: none; } - .modal .m-err { color: var(--bad); font-size: 12.5px; margin: 6px 0 0; } - .modal .m-err[hidden] { display: none; } - - /* ---------- 表格(骨架:干脆、高对比、无拟物) ---------- */ - .table-card { - margin-top: 20px; background: var(--panel); border: 1px solid var(--panel-line); - border-radius: var(--radius-panel); padding: 18px 18px 8px; - } - .table-scroll { overflow-x: auto; } - table { width: 100%; border-collapse: collapse; font-size: 13.5px; } - thead th { - text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; - padding: 8px 12px; border-bottom: 1px solid var(--panel-line); white-space: nowrap; - } - tbody td { padding: 11px 12px; border-bottom: 1px solid var(--panel-line); vertical-align: middle; } - tbody tr:last-child td { border-bottom: 0; } - tbody tr:hover td { background: var(--cobalt-soft); } - td .task-name { font-weight: 500; } - td .task-id { font-family: var(--font-num); font-size: 11.5px; color: var(--muted); } - .pill { - display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; - border: 1px solid var(--panel-line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; - background: var(--panel); - } - .pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); } - .pill.done i { background: var(--ok); } - .pill.run i { background: var(--cobalt); } - .pill.review i { background: var(--warn); } - .pill.fail i { background: var(--bad); } - td.time, td.dur { font-family: var(--font-num); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; } - td.result-cell { max-width: 260px; min-width: 160px; color: var(--ink-2); font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; } - .foot-note { margin-top: 16px; font-size: 12px; color: var(--muted); } - - /* ---------- 窄屏回落:按工作台自身宽度判断,避免右栏 600px 仍套宽屏网格 ---------- */ - @container ssv2 (max-width: 1180px) { - .grid { grid-template-columns: 1fr; } - .rail { flex-direction: row; align-items: stretch; } - .rail .card { flex: 1; } - .stats { grid-template-columns: repeat(2, 1fr); } - } - @container ssv2 (max-width: 860px) { - .proj { margin-left: 0; } - .tabs { width: 100%; } - .tabs a { flex: 1 1 auto; justify-content: center; } - .rail { flex-direction: column; } - .search { width: 100%; order: 5; } - .stats { grid-template-columns: 1fr 1fr; gap: 10px; } - } - @container ssv2 (max-width: 640px) { - /* 窄栏表格收成四列:藏「耗时」「派发时间」两列,单元格允许换行,不横滚 */ - thead th:nth-child(5), tbody td:nth-child(5), - thead th:nth-child(6), tbody td:nth-child(6) { display: none; } - thead th, tbody td { padding-left: 8px; padding-right: 8px; } - thead th { white-space: normal; } - td .task-name, td .task-id { overflow-wrap: anywhere; } - .pill { padding: 2px 7px; font-size: 11.5px; white-space: normal; } - td.time { white-space: normal; } - } - @media (prefers-reduced-motion: reduce) { - * { transition: none !important; } - } - } - -body[data-ds-dark-theme] .ssv2,html[data-theme=dark] .ssv2,.ssv2[data-ssv-theme=dark]{--bg:#09090b;--sidebar-bg:#0c0c0e;--panel:#18181b;--panel-line:#27272a;--muted-bg:#27272a;--ink:#fafafa;--ink-2:#d4d4d8;--muted:#a1a1aa;--cobalt:#829cff;--cobalt-ink:#a9bcff;--cobalt-soft:rgba(130,156,255,.13);--on-accent:#141a38;--ok:#5cb582;--warn:#d99a45;--bad:#e0705f} - -/* ---------- 宿主接线:右栏 / 浮动面板 / 内嵌条 ---------- */ -.ssw-tab-body{height:100%;min-height:0;display:flex;flex-direction:column;overflow:hidden} +var THEME_VARS_LIGHT = ` + --ss-bg: var(--background, var(--dsw-alias-bg-base, #ffffff)); + --ss-card: var(--card, var(--dsw-alias-bg-layer1, #ffffff)); + --ss-sidebar: var(--sidebar, var(--dsw-alias-bg-layer2, #fafafa)); + --ss-fg: var(--foreground, var(--dsw-alias-label-primary, #09090b)); + --ss-fg2: color-mix(in srgb, var(--ss-fg) 78%, var(--ss-bg)); + --ss-muted: var(--muted-foreground, var(--dsw-alias-label-tertiary, #71717a)); + --ss-placeholder: color-mix(in srgb, var(--ss-muted) 75%, transparent); + --ss-border: var(--border, var(--dsw-alias-border-l1, #e4e4e7)); + --ss-primary: var(--primary, var(--dsw-alias-state-brand-primary, #1e40d8)); + --ss-primary-fg: var(--primary-foreground, #ffffff); + --ss-secondary: var(--secondary, var(--dsw-alias-interactive-bg-hover-solid, #f4f4f5)); + --ss-secondary-fg: var(--secondary-foreground, var(--ss-fg)); + --ss-success: var(--success, #16a34a); + --ss-warning: var(--warning, #d97706); + --ss-error: var(--error, var(--dsw-alias-state-error-primary, #dc2626)); + --ss-link: var(--link, var(--ss-primary)); + --ss-chart-1: var(--chart-1, #4c6ef5); + --ss-chart-2: var(--chart-2, #12b886); + --ss-chart-3: var(--chart-3, #e8590c); + --ss-canvas: color-mix(in srgb, var(--ss-fg) 3%, var(--ss-bg)); + --ss-col: color-mix(in srgb, var(--ss-fg) 3%, var(--ss-bg)); + --ss-subtle: color-mix(in srgb, var(--ss-fg) 3.5%, var(--ss-card)); + --ss-hover: color-mix(in srgb, var(--ss-fg) 5.5%, var(--ss-card)); + --ss-font-ui: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; + --ss-font-seal: "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif; + --ss-font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace; +`; +var THEME_VARS_DARK = ` + --ss-bg: var(--background, var(--dsw-alias-bg-base, #09090b)); + --ss-card: var(--card, var(--dsw-alias-bg-layer1, #18181b)); + --ss-sidebar: var(--sidebar, var(--dsw-alias-bg-layer2, #0c0c0e)); + --ss-fg: var(--foreground, var(--dsw-alias-label-primary, #fafafa)); + --ss-fg2: color-mix(in srgb, var(--ss-fg) 80%, var(--ss-bg)); + --ss-muted: var(--muted-foreground, var(--dsw-alias-label-tertiary, #a1a1aa)); + --ss-placeholder: color-mix(in srgb, var(--ss-muted) 75%, transparent); + --ss-border: var(--border, var(--dsw-alias-border-l1, #27272a)); + --ss-primary: var(--primary, var(--dsw-alias-state-brand-primary, #6b8afd)); + --ss-primary-fg: var(--primary-foreground, #0f172a); + --ss-secondary: var(--secondary, var(--dsw-alias-interactive-bg-hover-solid, #27272a)); + --ss-secondary-fg: var(--secondary-foreground, var(--ss-fg)); + --ss-success: var(--success, #4ade80); + --ss-warning: var(--warning, #fbbf24); + --ss-error: var(--error, var(--dsw-alias-state-error-primary, #f87171)); + --ss-link: var(--link, var(--ss-primary)); + --ss-chart-1: var(--chart-1, #748ffc); + --ss-chart-2: var(--chart-2, #38d9a9); + --ss-chart-3: var(--chart-3, #ff922b); + --ss-canvas: color-mix(in srgb, var(--ss-fg) 2.5%, var(--ss-bg)); + --ss-col: color-mix(in srgb, var(--ss-fg) 3.5%, var(--ss-bg)); + --ss-subtle: color-mix(in srgb, var(--ss-fg) 4.5%, var(--ss-card)); + --ss-hover: color-mix(in srgb, var(--ss-fg) 7%, var(--ss-card)); +`; +var CSS = ` +/* ---------- 宿主接线槽位 ---------- */ +.ssw-tab-body,.ssw-main-panel{height:100%;min-height:0;width:100%;display:flex;flex-direction:column;overflow:hidden} .ssw-tab-title{font-size:12px;font-weight:600} -.ssw-inline-bar{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 14px;background:var(--muted-bg);border-bottom:1px solid var(--panel-line);font-size:12px;color:var(--muted)} -.ssw-link{color:var(--cobalt-ink);font-size:12px;font-weight:500;padding:4px 6px;border-radius:6px} -.ssw-link:hover{background:var(--cobalt-soft)} .ssw-nav-hit{display:inline-flex;align-items:center;justify-content:center;color:inherit;width:100%;height:100%} -.ssw-float{position:fixed;right:14px;bottom:70px;z-index:2147483000;width:min(760px,calc(100vw - 28px));max-height:calc(100vh - 96px);display:flex;flex-direction:column;background:var(--panel,#fff);border:1px solid var(--panel-line,#e4e4e7);border-radius:12px;box-shadow:0 18px 50px -12px rgba(16,24,40,.28),0 4px 12px -2px rgba(16,24,40,.12);overflow:hidden} -.ssw-float>.ssv2{height:100%;min-height:0;overflow:auto} +.ssw-inline-bar{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 14px;background:var(--dsw-alias-bg-layer2,#f4f4f5);border-bottom:1px solid var(--dsw-alias-border-l1,#e4e4e7);font-size:12px} +.ssw-link{color:var(--dsw-alias-state-brand-primary,#1e40d8);font-size:12px;font-weight:500;padding:4px 6px;border-radius:6px} +.ssw-float{position:fixed;right:14px;bottom:70px;z-index:2147483000;width:min(760px,calc(100vw - 28px));max-height:calc(100vh - 96px);display:flex;flex-direction:column;background:var(--dsw-alias-bg-base,#fff);border:1px solid var(--dsw-alias-border-l1,#e4e4e7);border-radius:12px;box-shadow:0 18px 50px -12px rgba(16,24,40,.28);overflow:hidden} -/* ---------- 工作台 v2 工具样式 ---------- */ -.ssv2{height:100%;min-height:0;overflow:auto;background:var(--bg);color:var(--ink);font-family:var(--font-ui)} -.ssv2 .main{min-height:100%;min-width:600px;container-type:inline-size;container-name:ssv2;display:flex;flex-direction:column} -.ssv2 .page{min-height:0;flex:1 0 auto} -.ssv2 .topbar-title{display:flex;align-items:center;gap:12px;min-width:0;flex-wrap:wrap} -.ssv2 .topbar-icons{display:flex;align-items:center;gap:6px} -.ssv2 .icon-btn{width:32px;height:32px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:var(--radius-control);background:transparent;color:var(--muted);cursor:pointer;padding:0} -.ssv2 .icon-btn:hover{background:var(--muted-bg);color:var(--ink);border-color:var(--panel-line)} -.ssv2 .icon-btn:focus-visible{outline:2px solid var(--cobalt);outline-offset:2px} -.ssv2 .project-dock{display:flex;justify-content:flex-end;margin-top:auto;padding-top:22px} -.ssv2 .project-dock .proj{margin-left:0} -.ssv-banner{margin:12px 0 0;padding:9px 12px;border-radius:8px;font-size:12.5px;line-height:1.5;border:1px solid var(--panel-line);background:var(--muted-bg);color:var(--ink-2)} -.ssv-banner.is-error{color:var(--bad);background:color-mix(in srgb, var(--bad) 8%, var(--panel));border-color:color-mix(in srgb, var(--bad) 24%, var(--panel-line))} -.ssv-banner.is-notice{color:var(--cobalt-ink);background:var(--cobalt-soft);border-color:color-mix(in srgb, var(--cobalt) 20%, var(--panel-line))} -.ssv-textarea{width:100%;box-sizing:border-box;border:1px solid var(--panel-line);border-radius:var(--radius-control);background:var(--panel);color:var(--ink);font:inherit;font-size:13px;line-height:1.55;padding:7px 10px;resize:vertical} -.ssv-textarea:focus{border-color:var(--cobalt);outline:none} -.ssv-select{width:100%;border:1px solid var(--panel-line);border-radius:var(--radius-control);background:var(--panel);color:var(--ink);font:inherit;font-size:13.5px;padding:7px 10px} -.ssv-select:focus{border-color:var(--cobalt);outline:none} -.ssv-check{display:flex;align-items:center;gap:8px;margin-top:12px;font-size:13px;color:var(--ink-2);cursor:pointer} -.ssv-check input{accent-color:var(--cobalt);width:15px;height:15px} -.ssv-proj-caret{font-size:15px;color:var(--muted);margin-left:2px} -.ssv2 .ws-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px} -.ssv2 .ws-actions .btn{min-height:34px;padding:5px 12px;font-size:13px} -.ssv2 .skill-list li{gap:8px} -.ssv2 .skill-list .skill-toggle{flex:none} -.ssv2 .card h3 .count{font-family:var(--font-num)} +/* ---------- 双工作台共享主题变量与基础重置 ---------- */ +.ssv2,.ssmwb{ + ${THEME_VARS_LIGHT} + color-scheme: light dark; + color: var(--ss-fg); + font-family: var(--ss-font-ui); + font-size: 14px; + line-height: 1.5; + -webkit-font-smoothing: antialiased; +} +@media (prefers-color-scheme: dark){ + .ssv2,.ssmwb{ ${THEME_VARS_DARK} } +} +body[data-ds-dark-theme] .ssv2, +body[data-ds-dark-theme] .ssmwb, +html[data-theme="dark"] .ssv2, +html[data-theme="dark"] .ssmwb, +.ssv2[data-ssv-theme="dark"], +.ssmwb[data-ssv-theme="dark"]{ + ${THEME_VARS_DARK} +} -/* ---------- 结果摘要 / 展开详情 ---------- */ -.ssv2 .result-summary{margin-top:10px;min-width:0;max-width:100%} -.ssv2 .rs-line{display:flex;flex-direction:column;gap:3px;min-width:0} -.ssv2 .rs-summary{font-size:13px;color:var(--ink);line-height:1.6;overflow-wrap:anywhere;word-break:break-word} -.ssv2 .rs-points{margin:6px 0 0;padding-left:18px;font-size:12.5px;color:var(--ink-2);line-height:1.65} -.ssv2 .rs-points li{margin:2px 0;overflow-wrap:anywhere} -.ssv2 .rs-toggle{margin-top:5px;padding:0;color:var(--cobalt);font-size:12.5px;font-weight:500;min-height:24px;text-align:left} -.ssv2 .rs-detail{margin-top:10px;border-top:1px dashed var(--panel-line);padding-top:10px;font-size:13px;color:var(--ink-2);max-width:100%;overflow:hidden} -.ssv2 .rs-detail p,.ssv2 .rs-detail li,.ssv2 .rs-detail code,.ssv2 .rs-detail pre{overflow-wrap:anywhere;word-break:break-word;white-space:pre-wrap;max-width:100%} -.ssv2 .rs-heading{margin:10px 0 4px;font-size:13px;color:var(--ink);font-weight:700} -.ssv2 .rs-list{margin:4px 0 8px;padding-left:18px} -.ssv2 .rs-code{margin:6px 0;padding:8px 10px;border-radius:6px;background:var(--muted-bg);border:1px solid var(--panel-line);white-space:pre-wrap;overflow-wrap:anywhere} -.ssv2 .rs-path{display:inline-block;padding:1px 4px;border-radius:4px;background:var(--muted-bg);font-family:var(--font-num);font-size:12px} -.ssv2 .result-summary.is-empty{color:var(--muted);font-size:12.5px} -.ssv2 .rs-empty{margin-left:6px;color:var(--muted)} -.ssv2 .ws-hint{margin-top:8px} -/* ---------- 可折叠卡片(部门配置 / 记忆编辑) ---------- */ -.ssv2 details.card>summary{display:flex;align-items:center;gap:8px;cursor:pointer;font-weight:700;font-size:14.5px;list-style:none;min-height:28px} -.ssv2 details.card>summary::-webkit-details-marker{display:none} -.ssv2 details.card>summary::after{content:'⌄';margin-left:auto;color:var(--muted);transition:transform .15s} -.ssv2 details.card[open]>summary::after{transform:rotate(180deg)} -.ssv2 details.card[open]>summary{margin-bottom:8px} -.ssv2 .dept-config-body{padding-top:2px} +.ssv2 *,.ssmwb *{box-sizing:border-box} +.ssv2 button,.ssmwb button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer} +.ssv2 button:disabled,.ssmwb button:disabled{opacity:.5;cursor:default} +.ssv2 input,.ssmwb input,.ssv2 select,.ssmwb select,.ssv2 textarea,.ssmwb textarea{font:inherit;color:var(--ss-fg)} +.ssv2 :focus-visible,.ssmwb :focus-visible{outline:2px solid var(--ss-primary);outline-offset:1px} +.ssv2 ::-webkit-scrollbar,.ssmwb ::-webkit-scrollbar{width:6px;height:6px} +.ssv2 ::-webkit-scrollbar-track,.ssmwb ::-webkit-scrollbar-track{background:transparent} +.ssv2 ::-webkit-scrollbar-thumb,.ssmwb ::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--ss-muted) 30%,transparent);border-radius:999px} -/* ---------- 工作台 v2:顶栏小导航 / 队列与 Token 弹窗 / 卡片摘要 ---------- */ -.ssv2 .panel-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap} -.ssv2 .panel-actions .btn{min-height:32px;padding:5px 11px;font-size:12.5px} -.ssv2 .modal-toolbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-top:16px} -.ssv2 .modal-toolbar .search{flex:1 1 220px} -.ssv2 .queue-table-wrap{margin-top:14px;border-top:1px solid var(--panel-line)} -.ssv2 .queue-table-wrap table{margin-top:4px} -.ssv2 .card-summary{margin-top:8px;min-width:0} -.ssv2 .card-summary .t-label{display:block;color:var(--muted);font-size:11.5px;margin-bottom:3px} -.ssv2 .card-summary-text{margin:0;font-size:12.5px;line-height:1.6;color:var(--ink-2);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere;word-break:break-word} -.ssv2 .card-summary.is-empty .card-summary-text{color:var(--muted)} -.ssv2 .m-rich{margin-top:2px;font-size:13.5px;color:var(--ink-2);max-width:100%;overflow:hidden} -.ssv2 .m-rich p{margin:0 0 6px} -.ssv2 .m-rich p:last-child{margin-bottom:0} -/* ---------- 需求门控工作区 ---------- */ -.ssv2 .req-gate{padding:18px} -.ssv2 .req-gate h3{margin-bottom:6px} -.ssv2 .req-tabs{display:flex;gap:6px;margin:12px 0 14px;border-bottom:1px solid var(--panel-line);padding-bottom:2px} -.ssv2 .req-tab{border:0;background:transparent;color:var(--muted);font-family:var(--font-ui);font-size:13px;padding:7px 10px;border-radius:6px 6px 0 0;cursor:pointer} -.ssv2 .req-tab:hover{background:var(--muted-bg);color:var(--ink)} -.ssv2 .req-tab.is-active{color:var(--cobalt);font-weight:700;box-shadow:inset 0 -2px 0 var(--cobalt)} -.ssv2 .req-list{gap:10px} -.ssv2 .req-card{padding:13px 14px} -.ssv2 .req-meta{display:flex;flex-wrap:wrap;gap:8px 14px;margin:6px 0 8px;color:var(--muted);font-family:var(--font-num);font-size:11px} -.ssv2 .req-details{margin:8px 0;border-top:1px dashed var(--panel-line);padding-top:8px} -.ssv2 .req-details>summary{cursor:pointer;color:var(--ink-2);font-size:12px} -.ssv2 .req-details .kv{margin-top:8px} -.ssv2 .req-children{display:flex;flex-direction:column;gap:6px;margin-top:10px;border-top:1px dashed var(--panel-line);padding-top:8px} -.ssv2 .req-child{display:grid;grid-template-columns:74px auto 1fr;gap:6px 10px;align-items:start;font-size:12px;color:var(--ink-2)} -.ssv2 .req-child-owner{font-family:var(--font-seat);font-weight:700;color:var(--ink)} -.ssv2 .req-child-result{grid-column:1/-1;color:var(--muted);overflow-wrap:anywhere} -.ssv2 .req-child-session{grid-column:1/-1;color:var(--muted);font-family:var(--font-num);font-size:10px;overflow-wrap:anywhere} -/* ---------- 模型来源/同步与集中审批 ---------- */ -.ssv2 .cfg-model-status{margin:10px 0 4px;padding:10px 12px;border:1px solid var(--panel-line);border-radius:8px;background:var(--muted-bg);font-size:12px;line-height:1.7;color:var(--ink-2)} -.ssv2 .cfg-model-status>div{overflow-wrap:anywhere} -.ssv2 .approval-card{margin-top:16px;padding:16px 18px} -.ssv2 .approval-list{display:flex;flex-direction:column;gap:10px;margin-top:10px} -.ssv2 .approval-item{border:1px solid var(--panel-line);border-radius:8px;padding:10px 12px;background:var(--panel)} -.ssv2 .approval-head{display:flex;gap:10px;align-items:center;justify-content:space-between;font-size:12.5px;overflow-wrap:anywhere} -.ssv2 .approval-head>span{flex-shrink:0;max-width:45%;text-align:right} -.ssv2 .approval-item p{margin:6px 0;color:var(--ink-2);font-size:12.5px;line-height:1.6;overflow-wrap:anywhere} -.ssv2 .approval-actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end} -.ssv2 .approval-actions .btn{max-width:100%;white-space:normal;overflow-wrap:anywhere} -.ssv2 .task-original-text{white-space:pre-wrap;overflow-wrap:anywhere} +.ssv2 .font-seal,.ssmwb .font-seal{font-family:var(--ss-font-seal);letter-spacing:.04em} +.ssv2 .font-mono-num,.ssmwb .font-mono-num{font-family:var(--ss-font-mono);font-variant-numeric:tabular-nums} +.ssv2 .truncate,.ssmwb .truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.ssv2 .line-clamp-2,.ssmwb .line-clamp-2{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden} +.ssv2 .wb-select,.ssmwb .wb-select{background:var(--ss-card);color:var(--ss-fg);border:1px solid var(--ss-border);border-radius:8px;padding:6px 10px;font-size:12px;width:100%} + +/* ---------- 语义状态点 / 胶囊 ---------- */ +@keyframes ssvPulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.42;transform:scale(1.24)}} +.ss-dot{width:7px;height:7px;border-radius:50%;flex:0 0 auto;background:var(--ss-muted)} +.ss-dot.is-primary{background:var(--ss-primary)} +.ss-dot.is-success{background:var(--ss-success)} +.ss-dot.is-warning{background:var(--ss-warning)} +.ss-dot.is-error{background:var(--ss-error)} +.ss-dot.is-pulse{animation:ssvPulse 2s ease-in-out infinite} +@media (prefers-reduced-motion: reduce){.ss-dot.is-pulse{animation:none}} + +.ss-pill{display:inline-flex;align-items:center;gap:5px;padding:2px 8px;border-radius:999px;font-size:12px;line-height:1.35;border:1px solid var(--ss-border);background:var(--ss-subtle);color:var(--ss-muted);white-space:nowrap;flex-shrink:0} +.ss-pill.is-primary{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border));color:var(--ss-primary)} +.ss-pill.is-success{background:color-mix(in srgb,var(--ss-success) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-success) 30%,var(--ss-border));color:var(--ss-success)} +.ss-pill.is-warning{background:color-mix(in srgb,var(--ss-fg) 3%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-warning) 36%,var(--ss-border));color:var(--ss-warning)} +.ss-pill.is-error{background:color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-error) 32%,var(--ss-border));color:var(--ss-error)} + +/* ---------- 极致无框「待你处理」样式(无外框浅蓝底 + 独立纯白条目) ---------- */ +.frameless-zone{background:color-mix(in srgb,var(--ss-primary) 8.5%,var(--ss-card));border:0;border-radius:16px;padding:12px;display:flex;flex-direction:column;gap:10px} +.frameless-zone.is-dock-full{flex:1 1 auto;min-height:0} +.frameless-zone-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 4px;flex:none} +.frameless-zone-title-wrap{display:flex;align-items:center;gap:8px;min-width:0} +.frameless-zone-title{font-size:13px;font-weight:600;color:var(--ss-fg);margin:0;white-space:nowrap} +.frameless-zone-count{padding:2px 7px;border-radius:999px;font-size:12px;line-height:1;font-weight:600;background:var(--ss-primary);color:var(--ss-primary-fg);font-family:var(--ss-font-mono);font-variant-numeric:tabular-nums;flex-shrink:0} +.frameless-zone-sub{font-size:12px;color:var(--ss-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.frameless-zone-list{display:flex;flex-direction:column;gap:10px} +.frameless-zone-list.is-scroll{flex:1 1 auto;min-height:0;overflow-y:auto;padding-right:2px} +.frameless-item{background:var(--ss-card);border:0;border-radius:12px;padding:12px 14px;display:flex;flex-direction:column;gap:8px;box-shadow:0 1px 3px color-mix(in srgb,var(--ss-primary) 8%,transparent);transition:box-shadow 150ms ease} +.frameless-item:hover{box-shadow:0 3px 10px -2px color-mix(in srgb,var(--ss-primary) 15%,transparent)} +.frameless-item-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px} +.frameless-item-meta{display:flex;align-items:center;gap:6px;min-width:0} +.frameless-chip{display:inline-flex;align-items:center;gap:5px;padding:2px 8px;border-radius:999px;font-size:12px;font-weight:500;flex-shrink:0} +.frameless-chip.is-err{background:color-mix(in srgb,var(--ss-error) 10%,var(--ss-card));color:var(--ss-error)} +.frameless-chip.is-pri{background:color-mix(in srgb,var(--ss-primary) 10%,var(--ss-card));color:var(--ss-primary)} +.frameless-code{background:color-mix(in srgb,var(--ss-fg) 3.5%,var(--ss-card));border:0;border-radius:8px;padding:7px 10px;font-size:12px;line-height:1.55;color:var(--ss-fg);overflow-wrap:anywhere} +.frameless-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px} +.frameless-btn-group{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-left:auto} +.frameless-btn{background:color-mix(in srgb,var(--ss-fg) 4.5%,var(--ss-card));color:var(--ss-fg);border:0;border-radius:8px;padding:5px 11px;font-size:12px;font-weight:500;transition:background-color 140ms ease,color 140ms ease} +.frameless-btn:hover{background:color-mix(in srgb,var(--ss-primary) 11%,var(--ss-card));color:var(--ss-primary)} +.frameless-primary-btn{background:var(--ss-primary);color:var(--ss-primary-fg);border:0;border-radius:8px;padding:5px 12px;font-size:12px;font-weight:500;transition:opacity 140ms ease} +.frameless-primary-btn:hover{opacity:.9} +.frameless-link{font-size:12px;color:var(--ss-link);flex-shrink:0} +.frameless-link:hover{text-decoration:underline} + +/* ---------- 提示横幅 & 弹窗 ---------- */ +.wb-toast-wrap{flex:none;padding:10px 16px 0} +.wb-toast-box{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 12px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-subtle);font-size:12px} +.wb-toast-box.is-primary{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border));color:var(--ss-primary)} +.wb-toast-box.is-success{background:color-mix(in srgb,var(--ss-success) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-success) 30%,var(--ss-border));color:var(--ss-success)} +.wb-toast-box.is-error{background:color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-error) 32%,var(--ss-border));color:var(--ss-error)} +.wb-toast-close{color:var(--ss-muted);padding:0 4px} +.wb-toast-close:hover{color:var(--ss-fg)} + +.wb-modal-backdrop{position:fixed;inset:0;z-index:60;background:rgba(9,9,11,.46);display:flex;align-items:center;justify-content:center;padding:12px} +.wb-modal{width:min(640px,100%);max-height:86vh;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);overflow:hidden;box-shadow:0 20px 44px -12px rgba(0,0,0,.32)} +.wb-modal-head{padding:12px 16px;border-bottom:1px solid var(--ss-border);display:flex;align-items:flex-start;justify-content:space-between;gap:12px} +.wb-modal-title{margin:0;font-size:14px;font-weight:600;color:var(--ss-fg)} +.wb-modal-close{width:28px;height:28px;border-radius:8px;border:1px solid var(--ss-border);display:inline-flex;align-items:center;justify-content:center;font-size:12px;flex-shrink:0} +.wb-modal-close:hover{background:var(--ss-hover)} +.wb-modal-body{padding:16px;overflow-y:auto;display:flex;flex-direction:column;gap:12px;font-size:12px} +.wb-modal-foot{padding:10px 16px;border-top:1px solid var(--ss-border);display:flex;justify-content:flex-end;gap:8px} + +/* ============================================================================ + 1. BETTER SIDEBAR 单项目工作台 (.ssv2) + ============================================================================ */ +.ssv2{height:100%;min-height:0;width:100%;min-width:0;display:flex;flex-direction:column;overflow:hidden;background:var(--ss-canvas);container-type:inline-size;container-name:wb} +.ssv2 .wb-header{flex:none;position:relative;z-index:20;padding:12px 16px 0;border-bottom:1px solid var(--ss-border);background:var(--ss-card)} +.ssv2 .wb-header-row{display:flex;align-items:center;justify-content:space-between;gap:8px} +.ssv2 .wb-brand{display:flex;align-items:center;gap:8px;min-width:0} +.ssv2 .wb-seal-badge{width:32px;height:32px;border-radius:8px;border:1px solid color-mix(in srgb,var(--ss-primary) 30%,var(--ss-border));background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));display:flex;align-items:center;justify-content:center;flex-shrink:0;font-family:var(--ss-font-seal);font-weight:700;font-size:14px;color:var(--ss-primary)} +.ssv2 .wb-brand-title-row{display:flex;align-items:center;gap:6px;min-width:0} +.ssv2 .wb-brand-title{margin:0;font-family:var(--ss-font-seal);font-size:16px;font-weight:700;line-height:1.25;white-space:nowrap} +.ssv2 .wb-role-badge{padding:2px 6px;border-radius:4px;font-size:12px;line-height:1.1;background:var(--ss-subtle);border:1px solid var(--ss-border);color:var(--ss-muted);flex-shrink:0} +.ssv2 .wb-subline{margin:2px 0 0;font-size:12px;color:var(--ss-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.ssv2 .wb-proj-pill{display:inline-flex;align-items:center;gap:6px;padding:5px 10px;border-radius:8px;background:var(--ss-subtle);border:1px solid var(--ss-border);font-size:12px;max-width:190px;flex-shrink:0} +.ssv2 .wb-proj-name{font-weight:500;color:var(--ss-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap} + +.ssv2 .wb-tabs{display:flex;align-items:center;gap:2px;margin-top:8px;margin-bottom:-1px;overflow-x:auto} +.ssv2 .wb-tab-btn{display:inline-flex;align-items:center;gap:6px;padding:9px 12px;font-size:12px;font-weight:500;white-space:nowrap;border-bottom:2px solid transparent;color:var(--ss-muted);transition:color 140ms ease,border-color 140ms ease} +.ssv2 .wb-tab-btn:hover{color:var(--ss-fg)} +.ssv2 .wb-tab-btn.is-active{border-bottom-color:var(--ss-primary);color:var(--ss-primary);font-weight:600} +.ssv2 .wb-tab-badge{padding:1px 6px;border-radius:999px;font-size:12px;line-height:1.2} + +.ssv2 .wb-body{flex:1 1 auto;min-height:0;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:14px} +.ssv2 .wb-footer{flex:none;padding:8px 16px;border-top:1px solid var(--ss-border);background:var(--ss-sidebar);display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;font-size:12px;color:var(--ss-muted)} +.ssv2 .wb-refresh-btn{display:inline-flex;align-items:center;gap:4px;padding:3px 8px;border-radius:6px;font-size:12px;color:var(--ss-muted)} +.ssv2 .wb-refresh-btn:hover{background:var(--ss-hover);color:var(--ss-fg)} + +.ssv2 .telemetry-strip{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);padding:8px 12px;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;font-size:12px} +.ssv2 .telemetry-group{display:flex;flex-wrap:wrap;align-items:center;gap:12px} +.ssv2 .telemetry-item{display:inline-flex;align-items:center;gap:5px} + +.ssv2 .court-split{display:grid;grid-template-columns:minmax(0,1fr);gap:16px;align-items:start} +@container wb (min-width: 920px){.ssv2 .court-split{grid-template-columns:minmax(0,1.35fr) minmax(300px,0.95fr);gap:18px}} +.ssv2 .court-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px} +.ssv2 .court-title{margin:0;font-size:14px;font-weight:600} +.ssv2 .seg-group{display:inline-flex;align-items:center;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);padding:2px;font-size:12px} +.ssv2 .seg-btn{padding:3px 8px;border-radius:6px;color:var(--ss-muted);transition:background-color 120ms ease,color 120ms ease;white-space:nowrap} +.ssv2 .seg-btn:hover{color:var(--ss-fg)} +.ssv2 .seg-btn.is-active{background:var(--ss-secondary);color:var(--ss-secondary-fg);font-weight:500} + +.ssv2 .lead-card{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);padding:12px;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;transition:border-color 140ms ease} +.ssv2 .lead-card.is-selected{border-color:var(--ss-primary);background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));box-shadow:0 0 0 1px var(--ss-primary)} +.ssv2 .lead-select-btn{display:flex;align-items:center;gap:10px;text-align:left;min-width:0;flex:1 1 auto} +.ssv2 .lead-seal{width:36px;height:36px;border-radius:8px;border:1px solid color-mix(in srgb,var(--ss-primary) 30%,var(--ss-border));background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));display:flex;align-items:center;justify-content:center;font-family:var(--ss-font-seal);font-weight:700;font-size:16px;color:var(--ss-primary);flex-shrink:0} +.ssv2 .wb-btn-outline{padding:6px 10px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);font-size:12px;font-weight:500;transition:border-color 140ms ease,background-color 140ms ease;white-space:nowrap} +.ssv2 .wb-btn-outline:hover{border-color:var(--ss-primary);color:var(--ss-primary)} +.ssv2 .wb-btn-primary{display:inline-flex;align-items:center;gap:6px;padding:6px 12px;border-radius:8px;background:var(--ss-primary);color:var(--ss-primary-fg);font-size:12px;font-weight:500;white-space:nowrap;transition:opacity 140ms ease} +.ssv2 .wb-btn-primary:hover{opacity:.9} + +.ssv2 .tier-divider{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--ss-muted);padding:0 2px} +.ssv2 .tier-divider strong{font-weight:500;color:var(--ss-fg)} +.ssv2 .tier-line{flex:1 1 auto;height:1px;background:var(--ss-border)} + +.ssv2 .sansheng-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px} +.ssv2 .liubu-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px} +.ssv2 .seat-card{text-align:left;width:100%;border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);padding:10px;display:flex;flex-direction:column;justify-content:space-between;gap:6px;transition:border-color 140ms ease,background-color 140ms ease} +.ssv2 .seat-card:hover{border-color:var(--ss-muted)} +.ssv2 .seat-card.is-selected{border-color:var(--ss-primary);background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));box-shadow:0 0 0 1px var(--ss-primary)} +.ssv2 .seat-card.is-dimmed{opacity:.35} +.ssv2 .seat-head{display:flex;align-items:center;justify-content:space-between;gap:6px} +.ssv2 .seat-title-wrap{display:inline-flex;align-items:center;gap:6px;min-width:0} +.ssv2 .seat-name{font-family:var(--ss-font-seal);font-weight:700;font-size:15px;line-height:1.25} +.ssv2 .seat-card.is-sansheng .seat-name{font-size:16px} +.ssv2 .seat-card.is-selected .seat-name{color:var(--ss-primary)} +.ssv2 .seat-live-tag{padding:2px 6px;border-radius:4px;font-size:12px;line-height:1;background:var(--ss-primary);color:var(--ss-primary-fg)} +.ssv2 .seat-status-text{display:inline-flex;align-items:center;gap:4px;font-size:12px;white-space:nowrap;color:var(--ss-muted)} +.ssv2 .seat-status-text.is-error{color:var(--ss-error);font-weight:500} +.ssv2 .seat-status-text.is-success{color:var(--ss-success);font-weight:500} +.ssv2 .seat-duty{font-size:12px;color:var(--ss-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:2px} +.ssv2 .seat-footer{padding-top:6px;border-top:1px solid var(--ss-border);display:flex;align-items:center;justify-content:space-between;gap:6px;min-width:0} +.ssv2 .seat-task-title{font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.ssv2 .seat-model-tag{font-family:var(--ss-font-mono);font-size:12px;color:var(--ss-muted);max-width:92px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex-shrink:0} + +/* 席位检视器 */ +.ssv2 .inspector-card{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);overflow:hidden} +.ssv2 .inspector-head{padding:14px;border-bottom:1px solid var(--ss-border);display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px} +.ssv2 .inspector-subtabs{display:flex;gap:16px;padding:0 14px;border-bottom:1px solid var(--ss-border);background:var(--ss-subtle)} +.ssv2 .inspector-subtab{padding:8px 0;font-size:12px;font-weight:500;border-bottom:2px solid transparent;color:var(--ss-muted)} +.ssv2 .inspector-subtab.is-active{border-bottom-color:var(--ss-primary);color:var(--ss-primary)} +.ssv2 .inspector-body{padding:14px;display:flex;flex-direction:column;gap:12px;font-size:12px} +.ssv2 .kv-grid-2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px} +.ssv2 .kv-box{border-radius:8px;background:var(--ss-subtle);border:1px solid var(--ss-border);padding:10px} +.ssv2 .wb-card{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);padding:14px;display:flex;flex-direction:column;gap:10px;font-size:12px} +.ssv2 .wb-empty-box{border-radius:12px;border:1px dashed var(--ss-border);padding:24px 16px;text-align:center;font-size:12px;color:var(--ss-muted)} +.ssv2 .wb-textarea{width:100%;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-bg);color:var(--ss-fg);padding:8px 10px;font-size:12px;resize:vertical} +.ssv2 .wb-input{width:100%;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-bg);color:var(--ss-fg);padding:7px 10px;font-size:12px} +.ssv2 .wb-alert{border-radius:8px;border:1px solid color-mix(in srgb,var(--ss-error) 32%,var(--ss-border));background:color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card));padding:10px;color:var(--ss-error);display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;font-size:12px} + +/* 流转 / 议政 / 共识 / 配置 */ +.ssv2 .flow-seg{display:inline-flex;flex-wrap:wrap;align-items:center;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);padding:2px;font-size:12px} +.ssv2 .flow-seg-btn{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:6px;color:var(--ss-muted)} +.ssv2 .flow-seg-btn.is-active{background:var(--ss-primary);color:var(--ss-primary-fg);font-weight:500} +.ssv2 .stage-stepper{display:flex;align-items:center;gap:4px;overflow-x:auto;padding:4px 0} +.ssv2 .stage-step-pill{padding:2px 8px;border-radius:999px;font-size:12px;border:1px solid var(--ss-border);background:var(--ss-subtle);color:var(--ss-muted);white-space:nowrap} +.ssv2 .stage-step-pill.is-done{background:color-mix(in srgb,var(--ss-success) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-success) 30%,var(--ss-border));color:var(--ss-success)} +.ssv2 .stage-step-pill.is-cur{background:var(--ss-primary);border-color:var(--ss-primary);color:var(--ss-primary-fg);font-weight:500} + +.ssv2 .queue-table{width:100%;text-align:left;border-collapse:collapse;font-size:12px} +.ssv2 .queue-table th{padding:10px 10px;font-weight:500;color:var(--ss-muted);background:var(--ss-subtle);border-bottom:1px solid var(--ss-border);white-space:nowrap} +.ssv2 .queue-table td{padding:10px 10px;border-bottom:1px solid var(--ss-border);vertical-align:top} +.ssv2 .queue-table tr.is-click{cursor:pointer} +.ssv2 .queue-table tr.is-click:hover td{background:var(--ss-hover)} + +.ssv2 .consensus-grid{display:grid;grid-template-columns:1fr;gap:12px} +@container wb (min-width: 620px){.ssv2 .consensus-grid{grid-template-columns:repeat(2,minmax(0,1fr))}} + +.ssv2 .speech-bubble{border-radius:12px;border:1px solid var(--ss-border);padding:10px 12px;font-size:12px;line-height:1.6;color:var(--ss-fg);background:color-mix(in srgb,var(--ss-fg) 3%,var(--ss-card));white-space:pre-wrap;overflow-wrap:anywhere} +.ssv2 .speech-chart-1{border-left:2.5px solid var(--ss-chart-1)} +.ssv2 .speech-chart-2{border-left:2.5px solid var(--ss-chart-2)} +.ssv2 .speech-chart-3{border-left:2.5px solid var(--ss-chart-3)} + +.ssv2 .cfg-seat-info{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1 1 auto} +@container wb (min-width: 720px){.ssv2 .cfg-seat-info{display:grid;grid-template-columns:minmax(170px,1fr) minmax(220px,1.15fr);align-items:center;gap:12px}} +.ssv2 .cfg-row{border-bottom:1px solid var(--ss-border)} +.ssv2 .cfg-row:last-child{border-bottom:0} +.ssv2 .cfg-row.is-open{background:color-mix(in srgb,var(--ss-primary) 5%,var(--ss-card))} +.ssv2 .cfg-row-head{display:flex;align-items:center;gap:8px;font-size:12px} +.ssv2 .cfg-row-toggle{flex:1 1 auto;min-width:0;text-align:left;display:flex;align-items:center;gap:10px;padding:10px 4px 10px 14px} +.ssv2 .cfg-inline-panel{padding:12px 14px;border-top:1px solid var(--ss-border);background:var(--ss-subtle);display:flex;flex-direction:column;gap:10px;font-size:12px} + +/* Narrow sidebar breakpoints (580px standard -> <=640px, 400px floor -> <=480px) */ +@container wb (max-width: 520px){.ssv2 .col-dur,.ssv2 .col-time{display:none}} +@container wb (max-width: 640px){ + .ssv2 .wb-header{padding-left:14px;padding-right:14px} + .ssv2 .wb-body{padding:12px} + .ssv2 .frameless-zone{padding:10px;border-radius:12px} + .ssv2 .frameless-zone-list{gap:8px} + .ssv2 .frameless-item{padding:10px 12px;gap:8px;border-radius:10px} + .ssv2 .frameless-code{padding:7px 10px} + .ssv2 .hide-narrow{display:none !important} +} +@container wb (max-width: 480px){ + .ssv2 .sansheng-grid{gap:7px} + .ssv2 .liubu-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px} + .ssv2 .wb-header{padding-left:10px;padding-right:10px} + .ssv2 .wb-body{padding:8px} + .ssv2 .wb-tab-btn{padding-left:8px;padding-right:8px} + .ssv2 .frameless-zone{padding:8px;border-radius:11px} + .ssv2 .frameless-zone-list{gap:7px} + .ssv2 .frameless-item{padding:9px 10px;gap:7px;border-radius:9px} + .ssv2 .frameless-code{padding:6px 9px} + .ssv2 .seat-card.is-sansheng .seat-head{flex-direction:column;align-items:flex-start;gap:4px} + .ssv2 .seat-card.is-sansheng .seat-duty,.ssv2 .seat-card.is-sansheng .seat-footer,.ssv2 .seat-card.is-liubu .seat-footer{display:none !important} +} + +/* ============================================================================ + 2. 主工作台跨项目看板总台 (.ssmwb) + ============================================================================ */ +.ssmwb{height:100%;min-height:0;width:100%;min-width:0;display:flex;flex-direction:column;overflow:hidden;background:var(--ss-canvas);container-type:inline-size;container-name:mwb} +.ssmwb .mwb-header{flex:none;position:relative;z-index:40;background:var(--ss-card);border-bottom:1px solid var(--ss-border);padding:10px 16px} +.ssmwb .mwb-header-row{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;flex-wrap:nowrap} +.ssmwb .mwb-header-left{display:flex;align-items:center;gap:8px;min-width:0;flex-wrap:nowrap} +.ssmwb .mwb-header-right{display:flex;align-items:center;gap:6px;margin-left:auto;flex-shrink:0;flex-wrap:nowrap} +.ssmwb .mwb-brand-box{display:flex;align-items:center;gap:8px;flex-shrink:0} +.ssmwb .mwb-brand-seal{width:28px;height:28px;border-radius:8px;background:var(--ss-fg);color:var(--ss-bg);display:flex;align-items:center;justify-content:center;font-family:var(--ss-font-seal);font-weight:700;font-size:12px;line-height:1} +.ssmwb .mwb-brand-title{margin:0;font-family:var(--ss-font-seal);font-size:16px;font-weight:700;line-height:1} +.ssmwb .mwb-brand-sep{color:var(--ss-border);flex-shrink:0} + +.ssmwb .mwb-proj-wrap{position:relative;min-width:0} +.ssmwb .mwb-proj-trigger{display:inline-flex;align-items:center;gap:8px;padding:6px 10px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);font-size:12px;max-width:100%;transition:border-color 140ms ease} +.ssmwb .mwb-proj-trigger:hover,.ssmwb .mwb-proj-trigger.is-open{border-color:var(--ss-primary)} +.ssmwb .mwb-proj-trigger.is-open{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary)} +.ssmwb .mwb-proj-popover{position:absolute;top:calc(100% + 6px);left:0;z-index:45;width:276px;max-width:90vw;border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);box-shadow:0 12px 32px -8px color-mix(in srgb,var(--ss-fg) 20%,transparent);overflow:hidden;padding:6px;display:flex;flex-direction:column;gap:2px} +.ssmwb .mwb-proj-opt{width:100%;text-align:left;padding:8px 10px;border-radius:8px;display:flex;flex-direction:column;gap:2px;font-size:12px;transition:background-color 120ms ease} +.ssmwb .mwb-proj-opt:hover{background:var(--ss-hover)} +.ssmwb .mwb-proj-opt.is-selected{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary)} + +.ssmwb .mwb-view-switch{display:inline-flex;align-items:center;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-subtle);padding:2px;font-size:12px;flex-shrink:0} +.ssmwb .mwb-view-btn{padding:4px 10px;border-radius:6px;color:var(--ss-muted);transition:background-color 120ms ease,color 120ms ease;white-space:nowrap} +.ssmwb .mwb-view-btn.is-active{background:var(--ss-card);color:var(--ss-fg);font-weight:500;box-shadow:0 1px 2px rgba(0,0,0,.08)} + +.ssmwb .mwb-search-inline{display:flex;align-items:center;gap:6px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-bg);padding:5px 10px;width:200px;max-width:100%} +.ssmwb .mwb-search-input{width:100%;border:0;background:transparent;font-size:12px;outline:none;color:var(--ss-fg)} +.ssmwb .mwb-search-icon-btn{display:none;align-items:center;justify-content:center;padding:6px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);color:var(--ss-muted);flex-shrink:0} +.ssmwb .mwb-search-icon-btn:hover,.ssmwb .mwb-search-icon-btn.is-active{border-color:var(--ss-primary)} +.ssmwb .mwb-search-icon-btn.is-active{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary)} +.ssmwb .mwb-narrow-search-bar{margin-top:8px;padding-top:8px;border-top:1px solid var(--ss-border);display:flex;align-items:center;gap:8px;font-size:12px} +.ssmwb .mwb-narrow-search-input-wrap{flex:1 1 auto;min-width:0;display:flex;align-items:center;gap:6px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-bg);padding:6px 10px} +.ssmwb .mwb-narrow-cancel{padding:6px 10px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-subtle);color:var(--ss-muted);flex-shrink:0} +.ssmwb .mwb-narrow-cancel:hover{color:var(--ss-fg)} + +.ssmwb .mwb-nav-btn{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);font-size:12px;flex-shrink:0;white-space:nowrap;transition:border-color 140ms ease} +.ssmwb .mwb-nav-btn:hover{border-color:var(--ss-primary)} +.ssmwb .mwb-nav-btn.is-active{border-color:var(--ss-primary);background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary);font-weight:500} +.ssmwb .mwb-nav-btn.is-pending{border-color:color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border));background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary);font-weight:500} + +.ssmwb .mwb-main{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;overflow:hidden} +.ssmwb .mwb-workspace{flex:1 1 auto;min-height:0;display:flex;position:relative;overflow:hidden} +.ssmwb .mwb-board-stage{flex:1 1 0%;min-width:0;height:100%;overflow:hidden} + +.ssmwb .mwb-kanban-board{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:minmax(0,100%);gap:12px;align-items:start;height:100%;overflow:hidden;padding:14px 16px 18px} +.ssmwb .mwb-kanban-board.is-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))} +.ssmwb .mwb-kanban-col{min-width:0;max-height:100%;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-col);overflow:hidden} +.ssmwb .mwb-kanban-col-head{flex:none;padding:10px 12px;border-bottom:1px solid var(--ss-border)} +.ssmwb .mwb-kanban-col-list{flex:1 1 auto;min-height:0;overflow-y:auto;padding:8px;display:flex;flex-direction:column;gap:8px} +.ssmwb .mwb-kanban-card{width:100%;text-align:left;background:var(--ss-card);border:1px solid var(--ss-border);border-radius:10px;padding:12px;display:flex;flex-direction:column;gap:8px;cursor:pointer;transition:border-color 140ms ease,box-shadow 140ms ease} +.ssmwb .mwb-kanban-card:hover{border-color:color-mix(in srgb,var(--ss-primary) 45%,var(--ss-border));box-shadow:0 4px 12px -6px color-mix(in srgb,var(--ss-fg) 14%,transparent)} +.ssmwb .mwb-kanban-card.is-selected{border-color:var(--ss-primary);box-shadow:0 0 0 1px var(--ss-primary),0 4px 14px -6px color-mix(in srgb,var(--ss-primary) 26%,transparent)} +.ssmwb .mwb-kanban-card.is-blocked{border-color:color-mix(in srgb,var(--ss-error) 55%,var(--ss-border));box-shadow:inset 3px 0 0 0 var(--ss-error)} +.ssmwb .mwb-kanban-card.is-blocked:hover{border-color:var(--ss-error)} +.ssmwb .mwb-card-ticker{border-radius:8px;padding:6px 10px;font-size:12px;line-height:1.45;background:var(--ss-subtle);color:var(--ss-muted)} +.ssmwb .mwb-card-ticker.is-blocked{background:color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card));color:var(--ss-error);font-weight:500} +.ssmwb .mwb-card-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:4px 8px;padding-top:2px;font-size:12px;color:var(--ss-muted)} +.ssmwb .mwb-progress-track{width:24px;height:6px;border-radius:999px;background:var(--ss-border);overflow:hidden;display:inline-block} +.ssmwb .mwb-progress-fill{display:block;height:100%;background:var(--ss-primary)} + +.ssmwb .mwb-list-wrap{height:100%;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px} +.ssmwb .mwb-list-section{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);overflow:hidden} +.ssmwb .mwb-list-head{padding:8px 14px;border-bottom:1px solid var(--ss-border);background:var(--ss-subtle);display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px} +.ssmwb .mwb-list-row{width:100%;text-align:left;padding:10px 14px;display:flex;flex-direction:column;gap:6px;font-size:12px;border-bottom:1px solid var(--ss-border);transition:background-color 120ms ease} +.ssmwb .mwb-list-row:last-child{border-bottom:0} +.ssmwb .mwb-list-row:hover{background:var(--ss-hover)} +.ssmwb .mwb-list-row.is-selected{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card))} +.ssmwb .mwb-list-row.is-blocked{border-left:3px solid var(--ss-error)} + +.ssmwb .mwb-pending-dock{width:344px;flex:0 0 344px;min-height:0;display:flex;flex-direction:column;padding:14px 14px 16px 0} +.ssmwb .mwb-split-drawer{position:absolute;top:0;right:0;bottom:0;z-index:35;width:400px;max-width:100%;border-left:1px solid var(--ss-border);background:var(--ss-card);display:flex;flex-direction:column;min-height:0;box-shadow:-10px 0 28px -10px color-mix(in srgb,var(--ss-fg) 18%,transparent)} +.ssmwb .mwb-drawer-head{flex:none;padding:12px 16px;border-bottom:1px solid var(--ss-border);display:flex;flex-direction:column;gap:8px} +.ssmwb .mwb-drawer-tabs{flex:none;display:flex;gap:16px;padding:0 16px;border-bottom:1px solid var(--ss-border);background:var(--ss-subtle);font-size:12px} +.ssmwb .mwb-drawer-tab{padding:8px 0;font-weight:500;border-bottom:2px solid transparent;color:var(--ss-muted)} +.ssmwb .mwb-drawer-tab.is-active{border-bottom-color:var(--ss-primary);color:var(--ss-primary)} +.ssmwb .mwb-drawer-body{flex:1 1 auto;min-height:0;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px;font-size:12px} + +.ssmwb .mwb-gcfg-group{border-radius:16px;background:var(--ss-subtle);padding:6px;display:flex;flex-direction:column;gap:4px} +.ssmwb .mwb-gcfg-item{border-radius:12px;background:var(--ss-card);border:1px solid transparent;transition:border-color 140ms ease} +.ssmwb .mwb-gcfg-item.is-open{border-color:color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border));box-shadow:0 1px 4px rgba(0,0,0,.06)} +.ssmwb .mwb-gcfg-toggle{width:100%;text-align:left;padding:10px 12px;border-radius:12px;display:flex;align-items:center;justify-content:space-between;gap:8px} +.ssmwb .mwb-gcfg-toggle:hover{background:var(--ss-hover)} +.ssmwb .mwb-gcfg-body{padding:8px 12px 12px;border-top:1px solid var(--ss-border);display:flex;flex-direction:column;gap:10px} + +@container mwb (max-width: 1160px){ + .ssmwb .mwb-pending-dock{width:312px;flex-basis:312px} +} +@container mwb (max-width: 760px){ + .ssmwb .mwb-search-inline{display:none !important} + .ssmwb .mwb-search-icon-btn{display:inline-flex !important} +} +@container mwb (max-width: 580px){ + .ssmwb .mwb-header{padding:8px 10px} + .ssmwb .mwb-list-wrap{padding:10px;gap:10px} + .ssmwb .mwb-hide-compact{display:none !important} + .ssmwb .frameless-zone{padding:9px;border-radius:12px} + .ssmwb .frameless-item{padding:10px 11px;gap:7px;border-radius:10px} + .ssmwb .frameless-code{padding:6px 9px} +} +@container mwb (max-width: 480px){ + .ssmwb .mwb-hide-xs{display:none !important} +} `; // src/client/cards.js -var import_react2 = require("react"); +var import_react3 = require("react"); var COLORS = { line: "var(--dsw-alias-border-l1, rgba(127,127,127,.28))", bg: "var(--dsw-alias-bg-base, transparent)", @@ -3470,10 +5050,10 @@ function errorText(error) { } function SanshengCardRow(props) { const callId = props?.callId || props?.block?.callId || ""; - const [card, setCard] = (0, import_react2.useState)(null); - const [error, setError] = (0, import_react2.useState)(""); - const [busy, setBusy] = (0, import_react2.useState)(""); - (0, import_react2.useEffect)(() => { + const [card, setCard] = (0, import_react3.useState)(null); + const [error, setError] = (0, import_react3.useState)(""); + const [busy, setBusy] = (0, import_react3.useState)(""); + (0, import_react3.useEffect)(() => { if (!callId) return void 0; let alive = true; const load = async () => { @@ -3508,9 +5088,9 @@ function SanshengCardRow(props) { setBusy(""); } }; - if (!callId) return (0, import_react2.createElement)("div", { style: { color: COLORS.muted, fontSize: 13, padding: "4px 0" } }, "卡片缺少调用标识,无法显示。"); + if (!callId) return (0, import_react3.createElement)("div", { style: { color: COLORS.muted, fontSize: 13, padding: "4px 0" } }, "卡片缺少调用标识,无法显示。"); if (!card) { - return (0, import_react2.createElement)( + return (0, import_react3.createElement)( "div", { style: { border: "1px solid " + COLORS.line, borderRadius: 8, padding: "10px 12px", margin: "4px 0", color: COLORS.muted, fontSize: 13 } }, error || "卡片加载中…" @@ -3518,7 +5098,7 @@ function SanshengCardRow(props) { } const answered = card.status === "answered"; const options = Array.isArray(card.options) ? card.options : []; - return (0, import_react2.createElement)( + return (0, import_react3.createElement)( "div", { style: { @@ -3535,10 +5115,10 @@ function SanshengCardRow(props) { "data-sansheng-card": card.id, "data-sansheng-card-status": card.status }, - (0, import_react2.createElement)( + (0, import_react3.createElement)( "div", { style: { display: "flex", alignItems: "center", gap: 8 } }, - (0, import_react2.createElement)("span", { + (0, import_react3.createElement)("span", { style: { fontSize: 11, lineHeight: "18px", @@ -3548,18 +5128,18 @@ function SanshengCardRow(props) { color: COLORS.muted } }, card.kind === "approval" ? "审批" : "需要你回答"), - (0, import_react2.createElement)("strong", { style: { fontSize: 14, color: COLORS.ink } }, card.title) + (0, import_react3.createElement)("strong", { style: { fontSize: 14, color: COLORS.ink } }, card.title) ), - (0, import_react2.createElement)("div", { style: { fontSize: 13, lineHeight: 1.7, color: COLORS.ink, whiteSpace: "pre-wrap" } }, card.body), - card.kind === "approval" && (card.seatLabel || card.tool || card.reason) ? (0, import_react2.createElement)( + (0, import_react3.createElement)("div", { style: { fontSize: 13, lineHeight: 1.7, color: COLORS.ink, whiteSpace: "pre-wrap" } }, card.body), + card.kind === "approval" && (card.seatLabel || card.tool || card.reason) ? (0, import_react3.createElement)( "div", { style: { fontSize: 12, lineHeight: 1.7, color: COLORS.muted, whiteSpace: "pre-wrap" } }, [card.seatLabel ? "申请:" + card.seatLabel : "", card.tool ? "操作:" + card.tool : "", card.reason ? "原因:" + card.reason : ""].filter(Boolean).join("\n") ) : null, - answered ? (0, import_react2.createElement)("div", { style: { fontSize: 13, color: COLORS.ink, fontWeight: 600 } }, "已选择:" + (card.answerLabel || card.answer || "")) : (0, import_react2.createElement)( + answered ? (0, import_react3.createElement)("div", { style: { fontSize: 13, color: COLORS.ink, fontWeight: 600 } }, "已选择:" + (card.answerLabel || card.answer || "")) : (0, import_react3.createElement)( "div", { style: { display: "flex", flexWrap: "wrap", gap: 8 } }, - options.map((option) => (0, import_react2.createElement)("button", { + options.map((option) => (0, import_react3.createElement)("button", { key: option.value, type: "button", disabled: Boolean(busy), @@ -3578,8 +5158,8 @@ function SanshengCardRow(props) { } }, busy === option.value ? "处理中…" : option.label)) ), - error ? (0, import_react2.createElement)("div", { style: { fontSize: 12, color: "var(--dsw-alias-state-error-primary, #b3261e)" } }, error) : null, - answered ? null : (0, import_react2.createElement)("div", { style: { fontSize: 12, color: COLORS.muted } }, "可以在聊天里继续,之后再回来点这张卡。") + error ? (0, import_react3.createElement)("div", { style: { fontSize: 12, color: "var(--dsw-alias-state-error-primary, #b3261e)" } }, error) : null, + answered ? null : (0, import_react3.createElement)("div", { style: { fontSize: 12, color: COLORS.muted } }, "可以在聊天里继续,之后再回来点这张卡。") ); } var cards_default = SanshengCardRow; @@ -3939,8 +5519,7 @@ function install(ctx) { var native_default = { install }; // src/client/index.js -var import_react3 = require("react"); -var import_react_dom = require("react-dom"); +var import_react4 = require("react"); var inject = ["sessions", "workspaces", "uiWorkspace", "uiConversation", "slots", "theme", "layout", "sidebarRightTabs", "sidebarRight"]; var PLUGIN_ID = "dsh-sansheng"; var TAB_KIND = "sansheng-workbench"; @@ -3971,7 +5550,7 @@ function installStyles(doc, tag, text) { return style; } function svgWrap(children, props) { - return (0, import_react3.createElement)("svg", { + return (0, import_react4.createElement)("svg", { viewBox: "0 0 24 24", width: 16, height: 16, @@ -3985,20 +5564,20 @@ function svgWrap(children, props) { }, children); } var TreeIcon = (props) => svgWrap([ - (0, import_react3.createElement)("rect", { key: "a", x: 9, y: 2, width: 6, height: 5, rx: 1 }), - (0, import_react3.createElement)("path", { key: "b", d: "M12 7v5M5 16v-4h14v4" }), - (0, import_react3.createElement)("rect", { key: "c", x: 2, y: 16, width: 6, height: 5, rx: 1 }), - (0, import_react3.createElement)("rect", { key: "d", x: 16, y: 16, width: 6, height: 5, rx: 1 }) + (0, import_react4.createElement)("rect", { key: "a", x: 9, y: 2, width: 6, height: 5, rx: 1 }), + (0, import_react4.createElement)("path", { key: "b", d: "M12 7v5M5 16v-4h14v4" }), + (0, import_react4.createElement)("rect", { key: "c", x: 2, y: 16, width: 6, height: 5, rx: 1 }), + (0, import_react4.createElement)("rect", { key: "d", x: 16, y: 16, width: 6, height: 5, rx: 1 }) ], props); -var CloseIcon = (props) => svgWrap([(0, import_react3.createElement)("path", { key: "p", d: "m6 6 12 12M6 18 18 6" })], props); -var FolderIcon = (props) => svgWrap([(0, import_react3.createElement)("path", { key: "p", d: "M3 7V5a2 2 0 0 1 2-2h5l2 3h7a2 2 0 0 1 2 2v11H3Z" })], props); +var CloseIcon = (props) => svgWrap([(0, import_react4.createElement)("path", { key: "p", d: "m6 6 12 12M6 18 18 6" })], props); +var FolderIcon = (props) => svgWrap([(0, import_react4.createElement)("path", { key: "p", d: "M3 7V5a2 2 0 0 1 2-2h5l2 3h7a2 2 0 0 1 2 2v11H3Z" })], props); var GearIcon = (props) => svgWrap([ - (0, import_react3.createElement)("path", { key: "a", d: "M4 6h16M4 12h16M4 18h16" }), - (0, import_react3.createElement)("circle", { key: "b", cx: 9, cy: 6, r: 2 }), - (0, import_react3.createElement)("circle", { key: "c", cx: 16, cy: 12, r: 2 }), - (0, import_react3.createElement)("circle", { key: "d", cx: 8, cy: 18, r: 2 }) + (0, import_react4.createElement)("path", { key: "a", d: "M4 6h16M4 12h16M4 18h16" }), + (0, import_react4.createElement)("circle", { key: "b", cx: 9, cy: 6, r: 2 }), + (0, import_react4.createElement)("circle", { key: "c", cx: 16, cy: 12, r: 2 }), + (0, import_react4.createElement)("circle", { key: "d", cx: 8, cy: 18, r: 2 }) ], props); -var ChevronIcon = (props) => (0, import_react3.createElement)("svg", { +var ChevronIcon = (props) => (0, import_react4.createElement)("svg", { viewBox: "0 0 24 24", width: 14, height: 14, @@ -4009,7 +5588,7 @@ var ChevronIcon = (props) => (0, import_react3.createElement)("svg", { strokeLinejoin: "round", className: "ssw-chevron", "aria-hidden": "true" -}, (0, import_react3.createElement)("path", { d: "m6 9 6 6 6-6" })); +}, (0, import_react4.createElement)("path", { d: "m6 9 6 6 6-6" })); var SEAT_ICON_PATHS = { lead: ["M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8Z", "M4.5 20c0-3.2 3.4-5 7.5-5s7.5 1.8 7.5 5"], zhongshu: ["M7 3h7l4 4v14H7z", "M14 3v4h4", "M9.5 12h5", "M9.5 16h5"], @@ -4024,7 +5603,7 @@ var SEAT_ICON_PATHS = { }; function SeatIcon(props) { const paths = SEAT_ICON_PATHS[props && props.id] ?? SEAT_ICON_PATHS.lead; - return (0, import_react3.createElement)("svg", { + return (0, import_react4.createElement)("svg", { viewBox: "0 0 24 24", width: 16, height: 16, @@ -4035,7 +5614,7 @@ function SeatIcon(props) { strokeLinejoin: "round", "aria-hidden": "true", className: "ssw-seat-icon" - }, paths.map((d, index) => (0, import_react3.createElement)("path", { key: index, d }))); + }, paths.map((d, index) => (0, import_react4.createElement)("path", { key: index, d }))); } function isFn(value) { return typeof value === "function"; @@ -4139,7 +5718,7 @@ function apply(ctx) { if (items.length === 1) return items[0]; return null; } - function seatRecordOf2(view, id) { + function seatRecordOf(view, id) { const seats = view && view.project ? view.project.seats : null; if (Array.isArray(seats)) return seats.find((seat) => seat && seat.id === id) || null; if (seats && typeof seats === "object") return seats[id] || null; @@ -4327,14 +5906,14 @@ function apply(ctx) { } function SanshengTabBody(props) { const sessionId = props && props.sessionId; - return (0, import_react3.createElement)("div", { + return (0, import_react4.createElement)("div", { className: "ssw-tab-body", "data-session-id": sessionId || void 0, "data-sansheng-right-tab": "native" - }, (0, import_react3.createElement)(SanshengWorkbench, { sessionId })); + }, (0, import_react4.createElement)(SanshengWorkbench, { sessionId })); } function SanshengTabTitle() { - return (0, import_react3.createElement)("span", { className: "ssw-tab-title" }, "三省六部"); + return (0, import_react4.createElement)("span", { className: "ssw-tab-title" }, "三省六部"); } let nativeRightTabWanted = true; let nativeRightTabStop = null; @@ -4429,8 +6008,8 @@ function apply(ctx) { let rightWorkbenchPinned = readRightWorkbenchPinned(); function SanshengWorkbench(props) { const sessionId = props && props.sessionId; - const resolveWorkspace = (0, import_react3.useCallback)(() => workspaceForSessionId(sessionId), [sessionId]); - return (0, import_react3.createElement)(WorkbenchV2, { + const resolveWorkspace = (0, import_react4.useCallback)(() => workspaceForSessionId(sessionId), [sessionId]); + return (0, import_react4.createElement)(WorkbenchV2, { sessionId, onClose: props && props.onClose, resolveWorkspace, @@ -4450,7 +6029,7 @@ function apply(ctx) { tabTypeId: TAB_TYPE_ID, title: "三省六部", description: "十席角色与独立会话的当前项目工作台", - icon: (size) => (0, import_react3.createElement)(TreeIcon, { width: size, height: size }), + icon: (size) => (0, import_react4.createElement)(TreeIcon, { width: size, height: size }), sessionSummary, attachRightTabOpener(fn) { rightTabOpener = isFn(fn) ? fn : null; @@ -4570,43 +6149,11 @@ function apply(ctx) { } function SanshengNavButton(props) { const size = props && typeof props.size === "number" ? props.size : 16; - const [floating, setFloating] = (0, import_react3.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 = (0, import_react3.createElement)( - "div", - { className: "ssw-float", role: "dialog", "aria-label": "三省六部工作台" }, - (0, import_react3.createElement)(SanshengWorkbench, { sessionId: currentSessionId(), onClose: () => setFloating(false) }) - ); - const canPortal = typeof document !== "undefined" && document.body && isFn(import_react_dom.createPortal); - panel = canPortal ? (0, import_react_dom.createPortal)(card, document.body) : card; - } - return (0, import_react3.createElement)( - import_react3.Fragment, - null, - (0, import_react3.createElement)("span", { - className: "ssw-nav-hit", - role: "presentation", - title: "三省六部", - onClick, - onPointerDown: stop, - onMouseDown: stop, - "aria-expanded": floating ? "true" : "false" - }, (0, import_react3.createElement)(TreeIcon, { width: size, height: size })), - panel - ); + return (0, import_react4.createElement)("span", { + className: "ssw-nav-hit", + role: "presentation", + title: "三省六部" + }, (0, import_react4.createElement)(TreeIcon, { width: size, height: size })); } function backToChat() { const layout = get("layout"); @@ -4617,41 +6164,20 @@ function apply(ctx) { } } } - function SanshengNavFallback() { - const [mode, setMode] = (0, import_react3.useState)("pending"); - (0, import_react3.useEffect)(() => { - let opened = false; - try { - opened = openRightWorkbench(currentSessionId()); - } catch { - opened = false; - } - if (opened) { - setMode("docked"); - backToChat(); - return void 0; - } - setMode("inline"); - return void 0; - }, []); - (0, import_react3.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 (0, import_react3.createElement)( + function SanshengMasterPanel() { + return (0, import_react4.createElement)( "div", - { className: "ssw-tab-body" }, - (0, import_react3.createElement)( - "div", - { className: "ssw-inline-bar" }, - (0, import_react3.createElement)("span", null, "工作台 · 内嵌模式"), - (0, import_react3.createElement)("button", { type: "button", className: "ssw-link", onClick: backToChat }, "返回对话") - ), - (0, import_react3.createElement)(SanshengWorkbench, { sessionId: currentSessionId() }) + { className: "ssw-main-panel", "data-sansheng-main": "master-workbench" }, + (0, import_react4.createElement)(MasterWorkbench, { + getWorkspaces: workspaceItems, + getCurrentWorkspace: currentWorkspace, + navigateToSession: (sid) => { + const ok = navigateToSession(sid); + backToChat(); + return ok; + }, + openRightTab: tryOpenRightTab + }) ); } function registerNavEntry() { @@ -4671,7 +6197,7 @@ function apply(ctx) { } }; 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(); diff --git a/sansheng/src/client/index.js b/sansheng/src/client/index.js index c8b5c17..4423ac7 100644 --- a/sansheng/src/client/index.js +++ b/sansheng/src/client/index.js @@ -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() diff --git a/sansheng/src/client/master-model.js b/sansheng/src/client/master-model.js new file mode 100644 index 0000000..7fa786d --- /dev/null +++ b/sansheng/src/client/master-model.js @@ -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) + }) +} diff --git a/sansheng/src/client/master-workbench.js b/sansheng/src/client/master-workbench.js new file mode 100644 index 0000000..5117766 --- /dev/null +++ b/sansheng/src/client/master-workbench.js @@ -0,0 +1,1184 @@ +// 主工作台总台(跨项目任务看板):仅使用 createElement,样式全部来自 styles.js (.ssmwb),数据全走 /api/sansheng。 +import { createElement as h, useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { SEAT_GROUPS, SEATS } from '../shared/roles.js' +import { collectModelOptions } from './workbench.js' +import { request } from './transport.js' +import { + buildMasterItems, + classifyTaskColumn, + computeMasterLayoutMode, + filterMasterItems, + groupModelChoices, + MASTER_ACTIVE_COLUMNS, + MASTER_BLOCKED_COLUMN, + modelObjectFromParts, + modelPartsOf, + PROJECT_DOT_VARS, + shortModelName, + sortMasterColumnItems, +} from './master-model.js' + +function smallSvg(children, props) { + return h('svg', { + viewBox: '0 0 24 24', + width: 13, + height: 13, + fill: 'none', + stroke: 'currentColor', + strokeWidth: 2, + strokeLinecap: 'round', + strokeLinejoin: 'round', + 'aria-hidden': 'true', + ...(props || {}), + }, children) +} + +const SearchSvg = (props) => smallSvg([ + h('circle', { key: 'c', cx: 11, cy: 11, r: 8 }), + h('path', { key: 'p', d: 'm21 21-4.3-4.3' }), +], props) + +const ChevronDownSvg = (props) => smallSvg([ + h('polyline', { key: 'p', points: '6 9 12 15 18 9' }), +], props) + +const SlidersSvg = () => smallSvg([ + h('path', { key: 'p', d: 'M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M2 14h4M10 8h4M18 16h4' }), +], { strokeWidth: 1.8 }) + +function formatDateTime(ts) { + const n = Number(ts) + if (!Number.isFinite(n) || n <= 0) return '—' + const d = new Date(n) + const p = (x) => String(x).padStart(2, '0') + return (d.getMonth() + 1) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) +} + +function stageTone(col) { + if (col === 'done' || col === 'running') return 'success' + if (col === 'review') return 'primary' + return 'muted' +} + +function stageTitle(col) { + if (col === 'done') return '已交付' + if (col === 'review') return '门下复核' + if (col === 'running') return '六部执行中' + return '待规划 · 需求池' +} + +function dotToneClass(tone, pulse) { + const cls = 'ss-dot is-' + (tone || 'muted') + return pulse ? cls + ' is-pulse' : cls +} + +function copyText(text, onDone) { + try { + if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText) { + void navigator.clipboard.writeText(text).then(() => onDone(true)).catch(() => onDone(false)) + return + } + } catch { /* 剪贴板不可用时退回提示 */ } + onDone(false) +} + +export function MasterWorkbench(props) { + const { getCurrentWorkspace, navigateToSession } = props || {} + + const [loading, setLoading] = useState(true) + const [projects, setProjects] = useState([]) + const [bundles, setBundles] = useState([]) + const [approvals, setApprovals] = useState([]) + const [degradedInfo, setDegradedInfo] = useState(null) + const [modelsCatalog, setModelsCatalog] = useState(null) + const [globalDefaults, setGlobalDefaults] = useState(null) + + const [projectFilter, setProjectFilter] = useState('all') + const [projMenuOpen, setProjMenuOpen] = useState(false) + const [viewMode, setViewMode] = useState('board') + const [search, setSearch] = useState('') + const [searchOpen, setSearchOpen] = useState(false) + const [pendingExpanded, setPendingExpanded] = useState(true) + const [drawer, setDrawer] = useState(null) // null | { type: 'task', itemKey, fromDone?: boolean } | { type: 'done' } | { type: 'settings' } + const [taskTab, setTaskTab] = useState('overview') + const [expandedGlobalSeatId, setExpandedGlobalSeatId] = useState(null) + const [frameWidth, setFrameWidth] = useState(1280) + const [busy, setBusy] = useState(false) + const [toast, setToast] = useState(null) + + const alive = useRef(true) + const rootRef = useRef(null) + const narrowSearchRef = useRef(null) + const toastTimerRef = useRef(null) + const autoOpenedOnce = useRef(false) + const answerVersion = useRef(0) + + const showToast = useCallback((text, tone = 'primary') => { + setToast({ text, tone }) + if (toastTimerRef.current) clearTimeout(toastTimerRef.current) + toastTimerRef.current = setTimeout(() => { + if (alive.current) setToast(null) + }, 3400) + }, []) + + useEffect(() => { + alive.current = true + return () => { + alive.current = false + if (toastTimerRef.current) clearTimeout(toastTimerRef.current) + } + }, []) + + const loadAll = useCallback(async ({ silent = false } = {}) => { + const startVer = answerVersion.current + try { + let listRes = await request('list') + let projList = Array.isArray(listRes?.projects) ? listRes.projects : [] + + if (projList.length === 0 && !autoOpenedOnce.current && typeof getCurrentWorkspace === 'function') { + const ws = getCurrentWorkspace() + if (ws && (ws.workspaceId || ws.path)) { + autoOpenedOnce.current = true + try { + await request('open', { workspaceId: ws.workspaceId, name: ws.name, path: ws.path }) + listRes = await request('list') + projList = Array.isArray(listRes?.projects) ? listRes.projects : [] + } catch { /* 工作区尚未可建时不阻断总台渲染 */ } + } + } + + const [modelsRes, globalRes] = await Promise.allSettled([ + request('models'), + request('globalDefaults'), + ]) + + const detailSettled = await Promise.all(projList.map(async (summary) => { + const [projR, tasksR, reqsR, apprR, artR] = await Promise.allSettled([ + request('project', { projectId: summary.id }), + request('tasks', { projectId: summary.id }), + request('requirements', { projectId: summary.id }), + request('approvals', { projectId: summary.id }), + request('artifacts', { projectId: summary.id }), + ]) + return { summary, projR, tasksR, reqsR, apprR, artR } + })) + + if (!alive.current) return + if (modelsRes.status === 'fulfilled' && modelsRes.value) setModelsCatalog(modelsRes.value) + if (globalRes.status === 'fulfilled' && globalRes.value) setGlobalDefaults(globalRes.value) + + setBundles(prev => { + const prevMap = new Map(prev.map(b => [b.project?.id, b])) + return detailSettled.map(({ summary, projR, tasksR, reqsR, artR }) => { + const old = prevMap.get(summary.id) + const projectObj = projR.status === 'fulfilled' + ? (projR.value?.project ?? projR.value) + : (old?.project ?? { id: summary.id, name: summary.name, status: summary.status, seats: [] }) + const tasks = tasksR.status === 'fulfilled' && Array.isArray(tasksR.value?.tasks) + ? tasksR.value.tasks + : (old?.tasks ?? []) + const requirements = reqsR.status === 'fulfilled' && Array.isArray(reqsR.value?.requirements) + ? reqsR.value.requirements + : (old?.requirements ?? []) + const artifacts = artR.status === 'fulfilled' && Array.isArray(artR.value?.artifacts) + ? artR.value.artifacts + : (old?.artifacts ?? []) + return { project: projectObj, tasks, requirements, artifacts } + }) + }) + + setProjects(projList.map((p, idx) => ({ + ...p, + colorVar: PROJECT_DOT_VARS[idx % PROJECT_DOT_VARS.length], + }))) + + if (answerVersion.current === startVer) { + const nextApprovals = [] + let degraded = null + detailSettled.forEach(({ summary, apprR }, idx) => { + const colorVar = PROJECT_DOT_VARS[idx % PROJECT_DOT_VARS.length] + if (apprR.status === 'fulfilled') { + const st = apprR.value?.status + if (st?.degraded) degraded = st.reason || 'approval-center-degraded' + const list = Array.isArray(apprR.value?.approvals) ? apprR.value.approvals : [] + for (const entry of list) { + nextApprovals.push({ ...entry, projectId: entry.projectId || summary.id, projectName: summary.name, colorVar }) + } + } else { + degraded = apprR.reason?.message || '审批队列暂不可达' + } + }) + setApprovals(nextApprovals) + setDegradedInfo(degraded) + } + setLoading(false) + } catch (error) { + if (!alive.current) return + setLoading(false) + if (!silent) showToast(error?.message || '总台状态加载失败', 'error') + } + }, [getCurrentWorkspace, showToast]) + + useEffect(() => { + void loadAll() + let running = false + const tick = async () => { + if (running) return + if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return + running = true + try { await loadAll({ silent: true }) } finally { running = false } + } + const timer = setInterval(() => { void tick() }, 4000) + const onVis = () => { if (document.visibilityState === 'visible') void tick() } + if (typeof document !== 'undefined') document.addEventListener('visibilitychange', onVis) + return () => { + clearInterval(timer) + if (typeof document !== 'undefined') document.removeEventListener('visibilitychange', onVis) + } + }, [loadAll]) + + // 容器宽度观察:动态切换四列 / 三列 / 窄栏自动列表与紧凑搜索图标 + useEffect(() => { + const node = rootRef.current + if (!node) return undefined + const sync = (w) => { if (w > 0) setFrameWidth(w) } + if (node.clientWidth > 0) sync(node.clientWidth) + if (typeof ResizeObserver === 'undefined') return undefined + const observer = new ResizeObserver((entries) => { + const w = entries[0]?.contentRect?.width || node.clientWidth + sync(w) + }) + observer.observe(node) + return () => observer.disconnect() + }, []) + + // 全局 Esc 与点击空白收起项目下拉菜单 + useEffect(() => { + if (typeof document === 'undefined') return undefined + const onDown = (e) => { + if (projMenuOpen && !e.target.closest?.('.mwb-proj-wrap')) setProjMenuOpen(false) + } + const onKey = (e) => { + if (e.key !== 'Escape') return + if (projMenuOpen) { setProjMenuOpen(false); return } + if (searchOpen && frameWidth <= 760) { setSearchOpen(false); return } + if (drawer) setDrawer(null) + } + document.addEventListener('mousedown', onDown) + document.addEventListener('keydown', onKey) + return () => { + document.removeEventListener('mousedown', onDown) + document.removeEventListener('keydown', onKey) + } + }, [projMenuOpen, searchOpen, frameWidth, drawer]) + + const projectMetaById = useMemo(() => { + const map = new Map() + bundles.forEach((b, idx) => { + if (b?.project?.id) { + map.set(b.project.id, { + id: b.project.id, + name: b.project.name || b.project.id, + path: b.project.path || b.project.workspaceId || '', + colorVar: PROJECT_DOT_VARS[idx % PROJECT_DOT_VARS.length], + }) + } + }) + return map + }, [bundles]) + + const modelOptions = useMemo(() => collectModelOptions(modelsCatalog), [modelsCatalog]) + const modelChoices = useMemo(() => groupModelChoices(modelOptions), [modelOptions]) + const allItems = useMemo(() => buildMasterItems(bundles, modelOptions), [bundles, modelOptions]) + const visibleItems = useMemo(() => filterMasterItems(allItems, { projectFilter, search }), [allItems, projectFilter, search]) + + const pendingEntries = useMemo(() => { + const out = [] + for (const a of approvals) { + if (projectFilter !== 'all' && a.projectId !== projectFilter) continue + out.push({ kind: 'approval', data: a }) + } + for (const item of allItems) { + if (projectFilter !== 'all' && item.projectId !== projectFilter) continue + for (const d of item.decisions || []) { + if (d.status === 'pending') out.push({ kind: 'decision', item, data: d }) + } + } + return out + }, [approvals, allItems, projectFilter]) + + const hasPendingBlock = pendingExpanded && (pendingEntries.length > 0 || Boolean(degradedInfo)) + const layoutMode = computeMasterLayoutMode(frameWidth, hasPendingBlock) + const isNarrow = layoutMode === 'list' + const compactSearch = frameWidth <= 760 + + const effectiveProjectMeta = projectFilter !== 'all' ? projectMetaById.get(projectFilter) : null + const activeProjList = useMemo(() => bundles.map((b, idx) => { + const pid = b.project?.id + const meta = projectMetaById.get(pid) + const activeCnt = allItems.filter(it => it.projectId === pid && it.col !== 'done').length + const pendCnt = approvals.filter(a => a.projectId === pid).length + + allItems.filter(it => it.projectId === pid).reduce((acc, it) => acc + (it.decisions || []).filter(d => d.status === 'pending').length, 0) + return { + id: pid, + name: meta?.name || pid, + path: meta?.path || '', + colorVar: meta?.colorVar || PROJECT_DOT_VARS[idx % PROJECT_DOT_VARS.length], + activeCnt, + pendCnt, + } + }), [bundles, projectMetaById, allItems, approvals]) + + const totalPendingAll = approvals.length + allItems.reduce((acc, it) => acc + (it.decisions || []).filter(d => d.status === 'pending').length, 0) + const totalActiveAll = allItems.filter(it => it.col !== 'done').length + const doneItems = useMemo(() => visibleItems.filter(it => it.col === 'done'), [visibleItems]) + + // ---- 真实宿主动作 ---- + async function handleOpenSeat(projectId, seatId) { + if (!projectId || !seatId) return + const bundle = bundles.find(b => b.project?.id === projectId) + const seats = bundle?.project?.seats + const seatRec = Array.isArray(seats) ? seats.find(s => s.id === seatId) : seats?.[seatId] + const seatName = SEATS[seatId]?.label || seatId + setBusy(true) + try { + if (seatRec?.status === 'missing') { + await request('rebuildSeat', { projectId, seatId, expectedSessionId: seatRec.sessionId || undefined }) + showToast('已重建「' + seatName + '」会话(保留历史任务)', 'success') + await loadAll({ silent: true }) + return + } + if (seatRec?.status !== 'bound') { + await request('enableSeat', { projectId, seatId }) + } + const res = await request('openSeat', { projectId, seatId }) + if (res?.sessionId && typeof navigateToSession === 'function') { + navigateToSession(res.sessionId) + showToast('已打开「' + seatName + '」会话', 'primary') + } else { + showToast('已就绪「' + seatName + '」独立会话', 'success') + await loadAll({ silent: true }) + } + } catch (error) { + showToast(error?.message || '打开席位会话失败', 'error') + await loadAll({ silent: true }) + } finally { + if (alive.current) setBusy(false) + } + } + + async function handleApproval(entry, choice) { + if (!entry || busy) return + setBusy(true) + try { + answerVersion.current += 1 + await request('approvalAnswer', { + projectId: entry.projectId, + seatId: entry.seatId, + id: entry.id, + sessionId: entry.sessionId, + choice, + }) + setApprovals(prev => prev.filter(a => !(a.id === entry.id && a.sessionId === entry.sessionId))) + showToast((choice === 'allow' ? '已允许「' : '已拒绝「') + (SEATS[entry.seatId]?.label || entry.seatId) + '」工具执行', choice === 'allow' ? 'success' : 'error') + await loadAll({ silent: true }) + } catch (error) { + showToast(error?.message || '审批应答失败', 'error') + await loadAll({ silent: true }) + } finally { + if (alive.current) setBusy(false) + } + } + + async function handleDecision(item, decision, option) { + if (!item || !decision || !option || busy) return + setBusy(true) + try { + answerVersion.current += 1 + await request('taskDecisionAnswer', { + projectId: item.projectId, + taskId: item.id, + decisionId: decision.id, + value: option.value, + }) + setBundles(prev => prev.map(b => { + if (b.project?.id !== item.projectId) return b + return { + ...b, + tasks: (b.tasks || []).map(t => t.id === item.id && Array.isArray(t.decisions) + ? { ...t, decisions: t.decisions.map(d => d.id === decision.id ? { ...d, status: 'answered', answer: option.value } : d) } + : t), + } + })) + showToast('已提交项目决定:' + option.label, 'success') + await loadAll({ silent: true }) + } catch (error) { + showToast(error?.message || '提交决定失败', 'error') + } finally { + if (alive.current) setBusy(false) + } + } + + async function handleRedispatch(item) { + const blk = item?.blockage + if (!item || !blk?.canRedispatch || !blk.deliveryId || busy) return + const targetTaskId = blk.targetTaskId || item.id + setBusy(true) + try { + const res = await request('taskRedispatch', { + projectId: item.projectId, + taskId: targetTaskId, + expectedDeliveryId: blk.deliveryId, + }) + const st = res?.delivery?.status + showToast(st === 'sent' ? '已显式重投任务「' + targetTaskId + '」并送达会话' : '重投状态:' + (res?.delivery?.reason || st || '已处理'), st === 'sent' ? 'success' : 'primary') + await loadAll({ silent: true }) + } catch (error) { + showToast(error?.message || '显式重投失败', 'error') + } finally { + if (alive.current) setBusy(false) + } + } + + async function handleSetGlobalSeat(seatId, modelObj) { + if (!seatId || busy) return + setBusy(true) + try { + const res = modelObj + ? await request('setGlobalDefault', { seatId, model: modelObj }) + : await request('clearGlobalDefault', { seatId }) + if (res?.globalDefaults) setGlobalDefaults(res.globalDefaults) + const appliedCnt = Array.isArray(res?.applied) ? res.applied.length : 0 + const failedCnt = Array.isArray(res?.failed) ? res.failed.length : 0 + const label = SEATS[seatId]?.label || seatId + if (!modelObj) { + showToast('已清除「' + label + '」全局默认设置' + (appliedCnt ? '(已同步 ' + appliedCnt + ' 个项目)' : ''), 'primary') + } else { + showToast('已更新「' + label + '」全局默认模型(已同步 ' + appliedCnt + ' 项' + (failedCnt ? ',失败 ' + failedCnt + ' 项' : '') + ')', failedCnt ? 'error' : 'success') + } + await loadAll({ silent: true }) + } catch (error) { + showToast(error?.message || '全局默认模型保存失败', 'error') + } finally { + if (alive.current) setBusy(false) + } + } + + async function handleSeedGlobalDefaults() { + if (busy) return + const targetProjId = projectFilter !== 'all' ? projectFilter : (projects[0]?.id ?? undefined) + setBusy(true) + try { + const res = await request('seedGlobalDefaults', targetProjId ? { projectId: targetProjId } : {}) + if (res?.globalDefaults) setGlobalDefaults(res.globalDefaults) + if (res?.seeded) { + showToast('已按项目同步初始化十席全局默认模型', 'success') + } else if (res?.status === 'existing') { + showToast('全局默认配置文件已存在,未覆盖当前配置', 'primary') + } else { + showToast('未找到可用的基准项目,请逐席设置或先选择单个项目', 'error') + } + } catch (error) { + showToast(error?.message || '同步初始化全局默认失败', 'error') + } finally { + if (alive.current) setBusy(false) + } + } + + // ---- UI 渲染块 ---- + function renderPendingZone(fullHeight) { + return h('section', { className: 'frameless-zone' + (fullHeight ? ' is-dock-full' : ''), 'aria-label': '待你处理' }, + h('div', { className: 'frameless-zone-head' }, + h('div', { className: 'frameless-zone-title-wrap' }, + h('span', { className: 'ss-dot is-primary is-pulse' }), + h('h2', { className: 'frameless-zone-title' }, '待你处理'), + h('span', { className: 'frameless-zone-count' }, String(pendingEntries.length)), + h('span', { className: 'frameless-zone-sub' }, projectFilter === 'all' ? '跨项目' : (effectiveProjectMeta?.name || '')), + ), + h('button', { + type: 'button', + className: 'wb-toast-close', + onClick: () => setPendingExpanded(false), + }, '收起'), + ), + degradedInfo ? h('div', { className: 'frameless-code', style: { color: 'var(--ss-error)' } }, + '部分项目无法获取宿主工具审批队列(' + degradedInfo + '),请在席位会话内使用原生审批卡。') : null, + h('div', { className: 'frameless-zone-list' + (fullHeight ? ' is-scroll' : '') }, + pendingEntries.map(entry => { + if (entry.kind === 'approval') { + const a = entry.data + return h('article', { className: 'frameless-item', key: 'apr:' + a.sessionId + ':' + a.id }, + h('div', { className: 'frameless-item-head' }, + h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 6, minWidth: 0 } }, + h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: 'var(' + (a.colorVar || '--ss-primary') + ')', flexShrink: 0 } }), + h('span', { className: 'font-mono-num truncate', style: { fontSize: 12, fontWeight: 500 } }, a.projectName || a.projectId), + ), + h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 6, marginLeft: 'auto' } }, + h('span', { className: 'frameless-chip is-err' }, h('span', { className: 'ss-dot is-error' }), '工具审批'), + h('span', { className: 'font-seal', style: { fontWeight: 700, fontSize: 13 } }, SEATS[a.seatId]?.label || a.seatId), + ), + ), + h('div', { className: 'frameless-code' }, + a.tool ? h('span', { className: 'font-mono-num', style: { color: 'var(--ss-muted)', marginRight: 6 } }, '[' + a.tool + ']') : null, + a.reason || a.detail?.text || '等待工具授权', + ), + h('div', { className: 'frameless-actions' }, + h('button', { type: 'button', className: 'frameless-link', disabled: busy, onClick: () => void handleOpenSeat(a.projectId, a.seatId) }, '查看会话 ↗'), + h('div', { className: 'frameless-btn-group' }, + h('button', { type: 'button', className: 'frameless-btn', disabled: busy, onClick: () => void handleApproval(a, 'reject') }, '拒绝'), + h('button', { type: 'button', className: 'frameless-primary-btn', disabled: busy, onClick: () => void handleApproval(a, 'allow') }, '允许一次'), + ), + ), + ) + } + const d = entry.data + const it = entry.item + return h('article', { className: 'frameless-item', key: 'dec:' + it.key + ':' + d.id }, + h('div', { className: 'frameless-item-head' }, + h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 6, minWidth: 0 } }, + h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: 'var(' + it.projectColorVar + ')', flexShrink: 0 } }), + h('span', { className: 'font-mono-num truncate', style: { fontSize: 12, fontWeight: 500 } }, it.projectName), + ), + h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 6, marginLeft: 'auto' } }, + h('span', { className: 'frameless-chip is-pri' }, h('span', { className: 'ss-dot is-primary' }), '项目决定'), + h('button', { type: 'button', className: 'frameless-link font-mono-num', onClick: () => { setDrawer({ type: 'task', itemKey: it.key }); setTaskTab('overview') } }, it.id + ' ↗'), + ), + ), + h('div', { style: { display: 'flex', flexDirection: 'column', gap: 3 } }, + h('div', { style: { fontSize: 12, fontWeight: 600, color: 'var(--ss-fg)' } }, it.title), + h('p', { style: { margin: 0, fontSize: 12, color: 'var(--ss-muted)', lineHeight: 1.55 } }, d.question), + ), + h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 6 } }, + (d.options || []).map(opt => h('button', { + key: opt.value, + type: 'button', + className: 'frameless-btn', + disabled: busy, + onClick: () => void handleDecision(it, d, opt), + }, opt.label)), + ), + ) + }), + ), + ) + } + + function renderKanbanCard(item) { + const seat = SEATS[item.seatId] + const selected = drawer?.type === 'task' && drawer.itemKey === item.key + const isBlocked = Boolean(item.blockage) + const isRun = item.col === 'running' && !isBlocked + const hasPendingDec = (item.decisions || []).some(d => d.status === 'pending') + const badgeTone = isBlocked ? 'error' : isRun ? 'success' : 'muted' + + return h('button', { + key: item.key, + type: 'button', + className: 'mwb-kanban-card' + (isBlocked ? ' is-blocked' : '') + (selected ? ' is-selected' : ''), + onClick: () => { setDrawer({ type: 'task', itemKey: item.key }); setTaskTab('overview') }, + }, + h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, width: '100%' } }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 } }, + h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: 'var(' + item.projectColorVar + ')', flexShrink: 0 }, title: item.projectName }), + projectFilter === 'all' ? [ + h('span', { key: 'pn', className: 'font-mono-num truncate', style: { color: 'var(--ss-fg)', fontWeight: 500, fontSize: 12 } }, item.projectName), + h('span', { key: 'sep', style: { color: 'var(--ss-muted)', flexShrink: 0 } }, '·'), + ] : null, + h('span', { className: 'font-mono-num', style: { color: 'var(--ss-muted)', flexShrink: 0, fontSize: 12 } }, item.id), + ), + h('span', { className: 'ss-pill is-' + badgeTone }, + h('span', { className: dotToneClass(badgeTone, isRun) }), + h('span', { className: 'font-seal', style: { fontWeight: 700 } }, isBlocked && layoutMode !== 'board4' ? ('阻塞 · ' + (seat?.label || '—')) : (seat?.label || '—')), + ), + ), + h('div', { className: 'line-clamp-2', style: { fontSize: 12, fontWeight: 600, color: 'var(--ss-fg)', lineHeight: 1.45 } }, item.title), + h('div', { className: 'mwb-card-ticker' + (isBlocked ? ' is-blocked' : '') }, + h('span', { className: 'line-clamp-2' }, item.ticker), + ), + h('div', { className: 'mwb-card-foot', style: { width: '100%' } }, + h('div', { style: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: '4px 8px' } }, + item.progress ? h('span', { className: 'font-mono-num', style: { display: 'inline-flex', alignItems: 'center', gap: 4 } }, + h('span', null, item.progress.done + '/' + item.progress.total), + h('span', { className: 'mwb-progress-track' }, h('span', { className: 'mwb-progress-fill', style: { width: Math.round((item.progress.done / item.progress.total) * 100) + '%' } })), + ) : null, + item.consultations?.length ? h('span', null, '会商 ' + item.consultations.length) : null, + hasPendingDec ? h('span', { style: { color: 'var(--ss-primary)', fontWeight: 500 } }, '待决定') : null, + ), + h('div', { className: 'font-mono-num', style: { display: 'flex', alignItems: 'center', gap: 4, marginLeft: 'auto', flexShrink: 0 } }, + h('span', null, item.modelLabel), + h('span', null, '·'), + h('span', null, item.durationText), + ), + ), + ) + } + + function renderBoardOrList() { + if (loading && bundles.length === 0) { + return h('div', { className: 'mwb-list-wrap' }, + h('div', { className: 'mwb-list-section', style: { padding: 32, textAlign: 'center', fontSize: 12, color: 'var(--ss-muted)' } }, '正在同步跨项目工作台数据…'), + ) + } + const effectiveMode = isNarrow ? 'list' : viewMode + if (effectiveMode === 'list') { + const inlinePending = isNarrow && pendingExpanded && (pendingEntries.length > 0 || Boolean(degradedInfo)) + return h('div', { className: 'mwb-list-wrap' }, + inlinePending ? renderPendingZone(false) : null, + MASTER_ACTIVE_COLUMNS.map(col => { + const items = sortMasterColumnItems(visibleItems.filter(it => it.col === col.id)) + const blockedCnt = items.filter(it => Boolean(it.blockage)).length + return h('section', { className: 'mwb-list-section', key: col.id }, + h('div', { className: 'mwb-list-head' }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, minWidth: 0 } }, + h('span', { className: dotToneClass(col.tone, col.id === 'running' && items.length > 0) }), + h('span', { style: { fontWeight: 600, color: 'var(--ss-fg)' }, className: 'truncate' }, col.title), + h('span', { className: 'ss-pill font-mono-num' }, String(items.length)), + blockedCnt > 0 ? h('span', { className: 'ss-pill is-error font-mono-num' }, '阻塞 ' + blockedCnt) : null, + ), + h('span', { className: 'mwb-hide-compact truncate', style: { color: 'var(--ss-muted)' } }, col.subtitle), + ), + items.length === 0 + ? h('div', { style: { padding: '14px 16px', fontSize: 12, color: 'var(--ss-muted)' } }, '当前无任务') + : items.map(item => { + const seat = SEATS[item.seatId] + const selected = drawer?.type === 'task' && drawer.itemKey === item.key + const isBlocked = Boolean(item.blockage) + const isRun = item.col === 'running' && !isBlocked + const hasPendingDec = (item.decisions || []).some(d => d.status === 'pending') + const badgeTone = isBlocked ? 'error' : isRun ? 'success' : 'muted' + return h('button', { + key: item.key, + type: 'button', + className: 'mwb-list-row' + (isBlocked ? ' is-blocked' : '') + (selected ? ' is-selected' : ''), + onClick: () => { setDrawer({ type: 'task', itemKey: item.key }); setTaskTab('overview') }, + }, + h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, width: '100%' } }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 } }, + h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: 'var(' + item.projectColorVar + ')', flexShrink: 0 } }), + projectFilter === 'all' ? [ + h('span', { key: 'pn', className: 'font-mono-num truncate', style: { color: 'var(--ss-fg)', fontWeight: 500 } }, item.projectName), + h('span', { key: 'sep', style: { color: 'var(--ss-muted)' } }, '·'), + ] : null, + h('span', { className: 'font-mono-num', style: { color: 'var(--ss-muted)', flexShrink: 0 } }, item.id), + ), + h('span', { className: 'ss-pill is-' + badgeTone }, + h('span', { className: dotToneClass(badgeTone, isRun) }), + h('span', { className: 'font-seal', style: { fontWeight: 700 } }, isBlocked ? ('阻塞 · ' + (seat?.label || '—')) : (seat?.label || '—')), + ), + ), + h('div', { className: 'line-clamp-2', style: { fontWeight: 600, color: 'var(--ss-fg)' } }, item.title), + h('div', { style: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'space-between', gap: '4px 12px', width: '100%' } }, + h('span', { className: 'truncate', style: { minWidth: 0, flex: '1 1 160px', color: isBlocked ? 'var(--ss-error)' : 'var(--ss-muted)', fontWeight: isBlocked ? 500 : 400 } }, item.ticker), + h('span', { className: 'font-mono-num', style: { display: 'inline-flex', alignItems: 'center', gap: 8, color: 'var(--ss-muted)', whiteSpace: 'nowrap', marginLeft: 'auto' } }, + item.progress ? h('span', null, item.progress.done + '/' + item.progress.total) : null, + hasPendingDec ? h('span', { style: { color: 'var(--ss-primary)', fontFamily: 'var(--ss-font-ui)', fontWeight: 500 } }, '待决定') : null, + h('span', null, item.modelLabel + ' · ' + item.durationText), + ), + ), + ) + }), + ) + }), + ) + } + + const is4Col = layoutMode === 'board4' + const cols = is4Col ? [...MASTER_ACTIVE_COLUMNS, MASTER_BLOCKED_COLUMN] : MASTER_ACTIVE_COLUMNS + return h('div', { className: 'mwb-kanban-board' + (is4Col ? ' is-cols-4' : '') }, + cols.map(col => { + const items = is4Col + ? (col.id === 'blocked' + ? sortMasterColumnItems(visibleItems.filter(it => it.col !== 'done' && Boolean(it.blockage))) + : sortMasterColumnItems(visibleItems.filter(it => it.col === col.id && !it.blockage))) + : sortMasterColumnItems(visibleItems.filter(it => it.col === col.id)) + const blockedCnt = !is4Col ? items.filter(it => Boolean(it.blockage)).length : 0 + return h('section', { className: 'mwb-kanban-col', key: col.id }, + h('div', { className: 'mwb-kanban-col-head' }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 6 } }, + h('span', { className: dotToneClass(col.tone, col.id === 'running' && items.length > 0) }), + h('h2', { style: { margin: 0, fontSize: 12, fontWeight: 600, color: 'var(--ss-fg)' }, className: 'truncate' }, col.title), + h('div', { style: { display: 'flex', alignItems: 'center', gap: 4, marginLeft: 'auto', flexShrink: 0 } }, + blockedCnt > 0 ? h('span', { className: 'ss-pill is-error font-mono-num' }, '阻塞 ' + blockedCnt) : null, + h('span', { className: 'ss-pill font-mono-num' }, String(items.length)), + ), + ), + h('div', { className: 'truncate', style: { fontSize: 12, color: 'var(--ss-muted)', marginTop: 2 } }, col.subtitle), + ), + h('div', { className: 'mwb-kanban-col-list' }, + items.length === 0 + ? h('div', { style: { border: '1px dashed var(--ss-border)', borderRadius: 8, padding: '28px 12px', textAlign: 'center', fontSize: 12, color: 'var(--ss-muted)' } }, '当前无任务') + : items.map(renderKanbanCard), + ), + ) + }), + ) + } + + function renderDrawer() { + if (!drawer) return null + if (drawer.type === 'task') { + const item = allItems.find(it => it.key === drawer.itemKey) + if (!item) return null + const seat = SEATS[item.seatId] + const tabs = [ + { id: 'overview', label: '概览' }, + { id: 'subtasks', label: '子项 (' + (item.subtasks?.length || 0) + ')' }, + { id: 'consult', label: '会商 (' + (item.consultations?.length || 0) + ')' }, + { id: 'artifacts', label: '交付 (' + (item.artifacts?.length || 0) + ')' }, + ] + let tabBody = null + if (taskTab === 'overview') { + tabBody = h('div', { style: { display: 'flex', flexDirection: 'column', gap: 12 } }, + h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '当前阶段'), + h('span', { className: 'ss-pill is-' + stageTone(item.col) }, + h('span', { className: dotToneClass(stageTone(item.col), false) }), + stageTitle(item.col), + ), + ), + item.blockage ? h('div', { style: { borderRadius: 12, border: '1px solid color-mix(in srgb,var(--ss-error) 34%,var(--ss-border))', background: 'color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card))', padding: 12, display: 'flex', flexDirection: 'column', gap: 8 } }, + h('div', { style: { fontWeight: 600, color: 'var(--ss-error)' } }, item.blockage.label), + h('p', { style: { margin: 0, lineHeight: 1.55 } }, item.blockage.reason), + h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 8 } }, + item.blockage.canRedispatch ? h('button', { + type: 'button', + className: 'frameless-primary-btn', + disabled: busy, + onClick: () => void handleRedispatch(item), + }, '显式重投并恢复执行') : h('button', { + type: 'button', + className: 'frameless-btn', + disabled: busy, + onClick: () => void handleOpenSeat(item.projectId, item.seatId), + }, '前往「' + (seat?.label || item.seatId) + '」处理'), + ), + ) : null, + item.originalText ? h('div', { style: { borderRadius: 12, border: '1px solid color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border))', background: 'color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card))', padding: 12, display: 'flex', flexDirection: 'column', gap: 4 } }, + h('div', { style: { fontWeight: 500, color: 'var(--ss-primary)' } }, '用户原话'), + h('p', { style: { margin: 0, lineHeight: 1.6 } }, '「' + item.originalText + '」'), + ) : null, + h('div', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('div', { style: { fontWeight: 500, color: 'var(--ss-muted)' } }, '任务说明'), + h('p', { style: { margin: 0, lineHeight: 1.6, color: 'var(--ss-fg)' } }, item.goal || '—'), + ), + h('div', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('div', { style: { fontWeight: 500, color: 'var(--ss-muted)' } }, '实时进展 / 产出'), + h('div', { style: { borderRadius: 12, background: 'var(--ss-subtle)', border: '1px solid var(--ss-border)', padding: 12, lineHeight: 1.6, whiteSpace: 'pre-wrap' } }, item.result || item.ticker), + ), + ) + } else if (taskTab === 'subtasks') { + tabBody = (item.subtasks?.length || 0) === 0 + ? h('div', { style: { padding: '36px 0', textAlign: 'center', color: 'var(--ss-muted)' } }, '该任务未拆分部门子项。') + : h('div', { style: { display: 'flex', flexDirection: 'column', gap: 8 } }, item.subtasks.map(st => h('div', { + key: st.id, + style: { borderRadius: 12, border: '1px solid var(--ss-border)', background: 'var(--ss-subtle)', padding: 12, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 }, + }, + h('div', { style: { minWidth: 0 } }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } }, + h('span', { className: 'font-seal', style: { fontWeight: 700 } }, SEATS[st.seatId]?.label || st.seatId), + h('span', { className: 'ss-pill is-' + (st.status === 'done' ? 'success' : st.status === 'blocked' ? 'error' : st.status === 'running' ? 'primary' : 'muted') }, + st.status === 'done' ? '已完成' : st.status === 'blocked' ? '阻塞' : st.status === 'running' ? '执行中' : '待派'), + ), + h('div', { style: { fontWeight: 500, marginTop: 4 } }, st.title), + st.result ? h('div', { style: { color: 'var(--ss-muted)', marginTop: 2 } }, st.result) : null, + ), + h('button', { type: 'button', className: 'frameless-link', disabled: busy, onClick: () => void handleOpenSeat(item.projectId, st.seatId) }, '会话 ↗'), + ))) + } else if (taskTab === 'consult') { + tabBody = (item.consultations?.length || 0) === 0 + ? h('div', { style: { padding: '36px 0', textAlign: 'center', color: 'var(--ss-muted)' } }, '暂无部门会商记录。') + : h('div', { style: { display: 'flex', flexDirection: 'column', gap: 10 } }, item.consultations.map(c => h('div', { + key: c.id || c.createdAt, + style: { borderRadius: 12, border: '1px solid var(--ss-border)', background: 'var(--ss-subtle)', padding: 12, display: 'flex', flexDirection: 'column', gap: 4 }, + }, + h('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 8, color: 'var(--ss-muted)' } }, + h('span', { style: { fontWeight: 500, color: 'var(--ss-fg)' } }, + (SEATS[c.fromSeatId]?.label || c.fromSeatId) + ' → ' + (c.toSeatIds || []).map(x => SEATS[x]?.label || x).join('、')), + h('span', { className: 'font-mono-num' }, formatDateTime(c.createdAt)), + ), + h('p', { style: { margin: 0, lineHeight: 1.55 } }, c.text), + ))) + } else { + tabBody = (item.artifacts?.length || 0) === 0 + ? h('div', { style: { padding: '36px 0', textAlign: 'center', color: 'var(--ss-muted)' } }, '尚无关联交付物。') + : h('div', { style: { display: 'flex', flexDirection: 'column', gap: 8 } }, item.artifacts.map(art => h('div', { + key: art.id, + style: { borderRadius: 12, border: '1px solid var(--ss-border)', background: 'var(--ss-subtle)', padding: '10px 12px', display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 }, + }, + h('div', { style: { minWidth: 0 } }, + h('div', { style: { fontWeight: 500 } }, art.title), + art.path ? h('div', { className: 'font-mono-num', style: { color: 'var(--ss-primary)', wordBreak: 'break-all' } }, art.path) : null, + ), + art.path ? h('button', { + type: 'button', + className: 'frameless-link', + onClick: () => copyText(art.path, (ok) => showToast(ok ? '已复制路径:' + art.path : '请手动选择复制路径', ok ? 'success' : 'muted')), + }, '复制') : null, + ))) + } + + return h('aside', { className: 'mwb-split-drawer', 'aria-label': '任务详情抽屉' }, + h('div', { className: 'mwb-drawer-head' }, + h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, fontSize: 12 } }, + h('div', { className: 'font-mono-num', style: { display: 'flex', alignItems: 'center', gap: 6, color: 'var(--ss-muted)', minWidth: 0 } }, + drawer.fromDone ? [ + h('button', { key: 'bk', type: 'button', className: 'frameless-link', onClick: () => setDrawer({ type: 'done' }) }, '← 已交付'), + h('span', { key: 'sp' }, '/'), + ] : null, + h('span', null, item.id), + h('span', null, '·'), + h('span', { className: 'truncate' }, item.projectName), + ), + h('button', { type: 'button', className: 'wb-modal-close', 'aria-label': '关闭抽屉', onClick: () => setDrawer(null) }, '✕'), + ), + h('h2', { style: { margin: 0, fontSize: 14, fontWeight: 600, lineHeight: 1.4 } }, item.title), + h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, paddingTop: 2 } }, + h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 12 } }, + h('span', { className: 'font-seal', style: { fontWeight: 700, fontSize: 14 } }, seat?.label || item.seatId), + h('span', { style: { color: 'var(--ss-muted)' } }, seat?.duty || ''), + ), + h('button', { + type: 'button', + className: 'frameless-primary-btn', + disabled: busy, + onClick: () => void handleOpenSeat(item.projectId, item.seatId), + }, '打开' + (seat?.label || '席位') + '会话 ↗'), + ), + ), + h('div', { className: 'mwb-drawer-tabs' }, + tabs.map(tb => h('button', { + key: tb.id, + type: 'button', + className: 'mwb-drawer-tab' + (taskTab === tb.id ? ' is-active' : ''), + onClick: () => setTaskTab(tb.id), + }, tb.label)), + ), + h('div', { className: 'mwb-drawer-body' }, tabBody), + ) + } + + if (drawer.type === 'done') { + return h('aside', { className: 'mwb-split-drawer', 'aria-label': '已交付归档' }, + h('div', { className: 'mwb-drawer-head' }, + h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 } }, + h('div', null, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } }, + h('span', { className: 'ss-dot is-success' }), + h('h2', { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, '已交付归档'), + h('span', { className: 'font-mono-num', style: { fontSize: 12, color: 'var(--ss-muted)' } }, String(doneItems.length)), + ), + h('p', { style: { margin: '2px 0 0', fontSize: 12, color: 'var(--ss-muted)' } }, + projectFilter === 'all' ? '跨项目验收通过记录 · 点击查看详情' : '当前项目:' + (effectiveProjectMeta?.name || '')), + ), + h('button', { type: 'button', className: 'wb-modal-close', 'aria-label': '关闭抽屉', onClick: () => setDrawer(null) }, '✕'), + ), + ), + h('div', { className: 'mwb-drawer-body' }, + doneItems.length === 0 + ? h('div', { style: { padding: '44px 0', textAlign: 'center', color: 'var(--ss-muted)' } }, '当前筛选条件下暂无已交付任务') + : doneItems.map(item => h('button', { + key: item.key, + type: 'button', + className: 'mwb-kanban-card', + onClick: () => { setDrawer({ type: 'task', itemKey: item.key, fromDone: true }); setTaskTab('overview') }, + }, + h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, width: '100%' } }, + h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 6, minWidth: 0 } }, + h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: 'var(' + item.projectColorVar + ')', flexShrink: 0 } }), + h('span', { className: 'font-mono-num truncate', style: { fontWeight: 500 } }, item.projectName), + h('span', { style: { color: 'var(--ss-muted)' } }, '·'), + h('span', { className: 'font-mono-num', style: { color: 'var(--ss-muted)', flexShrink: 0 } }, item.id), + ), + h('span', { className: 'font-seal', style: { fontWeight: 700, color: 'var(--ss-muted)', flexShrink: 0 } }, SEATS[item.seatId]?.label || '—'), + ), + h('div', { style: { fontWeight: 600, lineHeight: 1.45 } }, item.title), + h('div', { className: 'line-clamp-2', style: { color: 'var(--ss-muted)', lineHeight: 1.5 } }, item.ticker), + h('div', { className: 'font-mono-num', style: { display: 'flex', justifyContent: 'space-between', width: '100%', color: 'var(--ss-muted)' } }, + h('span', null, item.artifacts?.length ? ('交付物 ' + item.artifacts.length) : '已归档'), + h('span', null, item.modelLabel + ' · ' + item.durationText), + ), + )), + ), + ) + } + + if (drawer.type === 'settings') { + const groups = [ + { title: '中枢', ids: SEAT_GROUPS.lead }, + { title: '三省', ids: SEAT_GROUPS.sansheng }, + { title: '六部', ids: SEAT_GROUPS.liubu }, + ] + const gSeats = globalDefaults?.seats || {} + return h('aside', { className: 'mwb-split-drawer', 'aria-label': '全局默认模型配置' }, + h('div', { className: 'mwb-drawer-head' }, + h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 } }, + h('div', null, + h('h2', { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, '全局默认模型(R-001)'), + h('p', { className: 'font-mono-num truncate', style: { margin: '2px 0 0', fontSize: 12, color: 'var(--ss-muted)' } }, globalDefaults?.path || '~/.dsh/sansheng-liubu/setting.json'), + ), + h('button', { type: 'button', className: 'wb-modal-close', 'aria-label': '关闭抽屉', onClick: () => setDrawer(null) }, '✕'), + ), + ), + h('div', { className: 'mwb-drawer-body' }, + h('p', { style: { margin: 0, color: 'var(--ss-muted)', lineHeight: 1.55 } }, '点击任一席位展开调整;未设项目覆盖的席位自动从此处读取全局默认。'), + groups.map(group => h('div', { key: group.title, style: { display: 'flex', flexDirection: 'column', gap: 6 } }, + h('div', { style: { padding: '0 4px', fontWeight: 500, color: 'var(--ss-muted)' } }, group.title), + h('div', { className: 'mwb-gcfg-group' }, group.ids.map(sid => { + const meta = SEATS[sid] + const current = gSeats[sid] || null + const { modelKey, effort } = modelPartsOf(current) + const choiceObj = modelChoices.find(c => c.value === modelKey) || null + const efforts = choiceObj?.efforts || [] + const extraChoices = modelKey && !choiceObj + ? [{ value: modelKey, label: current.model + '(目录未列出)', efforts: effort ? [effort] : [] }, ...modelChoices] + : modelChoices + const isOpen = expandedGlobalSeatId === sid + const previewText = current ? shortModelName(current) : '未设置(回退部署默认)' + return h('div', { key: sid, className: 'mwb-gcfg-item' + (isOpen ? ' is-open' : '') }, + h('button', { + type: 'button', + className: 'mwb-gcfg-toggle', + 'aria-expanded': isOpen, + onClick: () => setExpandedGlobalSeatId(isOpen ? null : sid), + }, + h('span', { style: { display: 'flex', alignItems: 'center', gap: 8, minWidth: 0 } }, + h('span', { className: 'font-seal', style: { fontWeight: 700, fontSize: 14, flexShrink: 0 } }, meta.label), + h('span', { className: 'truncate', style: { color: 'var(--ss-muted)' } }, meta.duty), + ), + h('span', { style: { display: 'flex', alignItems: 'center', gap: 8, flexShrink: 0 } }, + h('span', { className: 'ss-pill font-mono-num', style: { color: current ? 'var(--ss-fg)' : 'var(--ss-muted)' } }, previewText), + ChevronDownSvg({ style: { color: isOpen ? 'var(--ss-primary)' : 'var(--ss-muted)', transform: isOpen ? 'rotate(180deg)' : 'none', transition: 'transform 150ms ease' } }), + ), + ), + isOpen ? h('div', { className: 'mwb-gcfg-body' }, + h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit,minmax(140px,1fr))', gap: 8 } }, + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '主任模型'), + h('select', { + className: 'wb-select', + disabled: busy, + value: modelKey, + onChange: (e) => { + const nextKey = e.target.value + const nextChoice = modelChoices.find(c => c.value === nextKey) + const nextEff = nextChoice?.efforts?.includes(effort) ? effort : (nextChoice?.efforts?.[0] || '') + void handleSetGlobalSeat(sid, modelObjectFromParts(nextKey, nextEff)) + }, + }, + h('option', { value: '' }, '未设置(回退部署默认)'), + extraChoices.map(opt => h('option', { key: opt.value, value: opt.value }, opt.label)), + ), + ), + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '推理等级'), + h('select', { + className: 'wb-select', + disabled: busy || efforts.length === 0, + value: effort, + onChange: (e) => void handleSetGlobalSeat(sid, modelObjectFromParts(modelKey, e.target.value)), + }, + h('option', { value: '' }, efforts.length === 0 ? '默认(固定)' : '默认'), + efforts.map(ef => h('option', { key: ef, value: ef }, ef)), + ), + ), + ), + h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 } }, + h('button', { + type: 'button', + className: 'frameless-link', + disabled: busy || !current, + style: { color: current ? 'var(--ss-error)' : 'var(--ss-muted)' }, + onClick: () => void handleSetGlobalSeat(sid, null), + }, '清除全局默认'), + h('button', { + type: 'button', + className: 'frameless-btn', + onClick: () => setExpandedGlobalSeatId(null), + }, '收起'), + ), + ) : null, + ) + })), + )), + h('button', { + type: 'button', + className: 'frameless-primary-btn', + style: { width: '100%', padding: '9px 12px', borderRadius: 12 }, + disabled: busy, + onClick: () => void handleSeedGlobalDefaults(), + }, '按当前项目同步初始化全局默认'), + ), + ) + } + return null + } + + return h('div', { ref: rootRef, className: 'ssmwb', 'data-sansheng-master': '1' }, + // 1. 顶部单行指令栏 + 窄栏可展开搜索行 + h('header', { className: 'mwb-header' }, + h('div', { className: 'mwb-header-row' }, + h('div', { className: 'mwb-header-left' }, + h('div', { className: 'mwb-brand-box' }, + h('div', { className: 'mwb-brand-seal' }, '省'), + h('h1', { className: 'mwb-brand-title mwb-hide-compact' }, '三省六部'), + ), + h('span', { className: 'mwb-brand-sep mwb-hide-compact' }, '/'), + h('div', { className: 'mwb-proj-wrap' }, + h('button', { + type: 'button', + className: 'mwb-proj-trigger' + (projMenuOpen ? ' is-open' : ''), + 'aria-haspopup': 'listbox', + 'aria-expanded': projMenuOpen, + onClick: () => setProjMenuOpen(v => !v), + }, + h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 6, minWidth: 0, fontWeight: 500 } }, + h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: projectFilter === 'all' ? 'var(--ss-primary)' : 'var(' + (effectiveProjectMeta?.colorVar || '--ss-primary') + ')', flexShrink: 0 } }), + projectFilter === 'all' + ? [ + h('span', { key: 'all', className: 'truncate' }, '全部项目'), + h('span', { key: 'cnt', className: 'font-mono-num', style: { color: 'var(--ss-muted)', fontWeight: 400, flexShrink: 0 } }, String(activeProjList.length)), + ] + : h('span', { className: 'font-mono-num truncate' }, effectiveProjectMeta?.name || projectFilter), + ), + ChevronDownSvg({ style: { color: 'var(--ss-muted)', transform: projMenuOpen ? 'rotate(180deg)' : 'none', transition: 'transform 150ms ease', flexShrink: 0 } }), + ), + projMenuOpen ? h('div', { className: 'mwb-proj-popover', role: 'listbox', 'aria-label': '切换项目范围' }, + h('button', { + type: 'button', + className: 'mwb-proj-opt' + (projectFilter === 'all' ? ' is-selected' : ''), + onClick: () => { setProjectFilter('all'); setProjMenuOpen(false) }, + }, + h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 } }, + h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 8, fontWeight: projectFilter === 'all' ? 600 : 500 } }, + h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: 'var(--ss-primary)' } }), + '全部项目', + ), + h('span', { className: 'font-mono-num', style: { display: 'inline-flex', alignItems: 'center', gap: 6 } }, + totalPendingAll > 0 ? h('span', { className: 'frameless-zone-count' }, String(totalPendingAll)) : null, + h('span', { style: { color: 'var(--ss-muted)' } }, String(totalActiveAll)), + projectFilter === 'all' ? h('span', { style: { color: 'var(--ss-primary)' } }, '✓') : null, + ), + ), + ), + h('div', { style: { padding: '6px 10px 4px', borderTop: '1px solid var(--ss-border)', marginTop: 2, fontSize: 12, color: 'var(--ss-muted)' } }, '工作区 (' + activeProjList.length + ')'), + h('div', { style: { maxHeight: 256, overflowY: 'auto', display: 'flex', flexDirection: 'column', gap: 2 } }, + activeProjList.map(p => { + const on = projectFilter === p.id + return h('button', { + key: p.id, + type: 'button', + className: 'mwb-proj-opt' + (on ? ' is-selected' : ''), + onClick: () => { setProjectFilter(p.id); setProjMenuOpen(false) }, + }, + h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 6 } }, + h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 8, minWidth: 0 } }, + h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: 'var(' + p.colorVar + ')', flexShrink: 0 } }), + h('span', { className: 'font-mono-num truncate', style: { fontWeight: on ? 600 : 500 } }, p.name), + ), + h('span', { className: 'font-mono-num', style: { display: 'inline-flex', alignItems: 'center', gap: 6, flexShrink: 0 } }, + p.pendCnt > 0 ? h('span', { className: 'frameless-zone-count' }, String(p.pendCnt)) : null, + h('span', { style: { color: 'var(--ss-muted)' } }, String(p.activeCnt)), + on ? h('span', { style: { color: 'var(--ss-primary)' } }, '✓') : null, + ), + ), + p.path ? h('div', { className: 'font-mono-num truncate', style: { paddingLeft: 16, fontSize: 12, color: 'var(--ss-muted)', opacity: .85 } }, p.path) : null, + ) + }), + ), + ) : null, + ), + !isNarrow ? h('div', { className: 'mwb-view-switch', role: 'group', 'aria-label': '切换视图' }, + h('button', { type: 'button', className: 'mwb-view-btn' + (viewMode === 'board' ? ' is-active' : ''), onClick: () => setViewMode('board') }, '看板'), + h('button', { type: 'button', className: 'mwb-view-btn' + (viewMode === 'list' ? ' is-active' : ''), onClick: () => setViewMode('list') }, '列表'), + ) : null, + ), + h('div', { className: 'mwb-header-right' }, + h('div', { className: 'mwb-search-inline' }, + SearchSvg({ style: { color: 'var(--ss-muted)', flexShrink: 0 } }), + h('input', { + type: 'search', + className: 'mwb-search-input', + value: search, + placeholder: '搜索任务、编号、席位…', + onChange: (e) => setSearch(e.target.value), + }), + ), + h('button', { + type: 'button', + className: 'mwb-search-icon-btn' + (searchOpen || search.trim() ? ' is-active' : ''), + title: '搜索任务、编号、席位', + 'aria-label': '搜索任务', + 'aria-expanded': compactSearch && searchOpen, + onClick: () => { + const next = !searchOpen + setSearchOpen(next) + if (next) setTimeout(() => narrowSearchRef.current?.focus(), 0) + }, + }, SearchSvg({ width: 14, height: 14 })), + (pendingEntries.length > 0 || Boolean(degradedInfo)) && !pendingExpanded ? h('button', { + type: 'button', + className: 'mwb-nav-btn is-pending', + onClick: () => { setPendingExpanded(true); setDrawer(null) }, + }, + h('span', { className: 'ss-dot is-primary is-pulse' }), + h('span', null, '待处理'), + h('span', { className: 'font-mono-num', style: { fontWeight: 600 } }, String(pendingEntries.length)), + ) : null, + h('button', { + type: 'button', + className: 'mwb-nav-btn' + (drawer?.type === 'done' || drawer?.fromDone ? ' is-active' : ''), + onClick: () => setDrawer(d => d?.type === 'done' ? null : { type: 'done' }), + }, + h('span', { className: 'ss-dot is-success' }), + h('span', null, '已交付'), + h('span', { className: 'font-mono-num', style: { color: 'var(--ss-muted)' } }, String(doneItems.length)), + ), + h('button', { + type: 'button', + className: 'mwb-nav-btn' + (drawer?.type === 'settings' ? ' is-active' : ''), + onClick: () => setDrawer(d => d?.type === 'settings' ? null : { type: 'settings' }), + }, + SlidersSvg(), + h('span', { style: { display: 'inline-flex', alignItems: 'center' } }, + h('span', { className: 'mwb-hide-xs' }, '全局'), + h('span', null, '配置'), + ), + ), + ), + ), + compactSearch && searchOpen ? h('div', { className: 'mwb-narrow-search-bar' }, + h('div', { className: 'mwb-narrow-search-input-wrap' }, + SearchSvg({ style: { color: 'var(--ss-muted)', flexShrink: 0 } }), + h('input', { + ref: narrowSearchRef, + type: 'search', + className: 'mwb-search-input', + value: search, + placeholder: '搜索任务、编号、席位…', + onChange: (e) => setSearch(e.target.value), + }), + ), + h('button', { + type: 'button', + className: 'mwb-narrow-cancel', + onClick: () => { setSearch(''); setSearchOpen(false) }, + }, '取消'), + ) : null, + ), + + // 2. 主区:提示条 + 看板/列表 + 右侧「待你处理」停靠区 + 覆盖式详情/已交付/全局配置抽屉 + h('div', { className: 'mwb-main' }, + toast ? h('div', { className: 'wb-toast-wrap' }, + h('div', { className: 'wb-toast-box is-' + (toast.tone || 'primary'), role: toast.tone === 'error' ? 'alert' : 'status' }, + h('span', null, toast.text), + h('button', { type: 'button', className: 'wb-toast-close', 'aria-label': '关闭提示', onClick: () => setToast(null) }, '✕'), + ), + ) : null, + h('div', { className: 'mwb-workspace' }, + h('main', { className: 'mwb-board-stage' }, renderBoardOrList()), + !isNarrow && hasPendingBlock ? h('aside', { className: 'mwb-pending-dock', 'aria-label': '待你处理队列' }, renderPendingZone(true)) : null, + renderDrawer(), + ), + ), + ) +} diff --git a/sansheng/src/client/styles.js b/sansheng/src/client/styles.js index 0ef27ef..b6b9bce 100644 --- a/sansheng/src/client/styles.js +++ b/sansheng/src/client/styles.js @@ -1,735 +1,413 @@ -// 三省六部工作台样式(v2):设计稿配色 / 排版 + 宿主接线样式。 -// 由 preview/workbench-v2.html 的设计 CSS 生成,使用原生 CSS 嵌套把整张表限制在 .ssv2 作用域内。 +// 三省六部工作台统一样式:覆盖主工作台总台 (.ssmwb) 与 Better Sidebar 单项目工作台 (.ssv2)。 +// 所有样式严格限制在插件容器类名作用域内,映射宿主语义主题变量,绝不引入外部 CDN。 -export const CSS = `.ssv2{ - /* ============ shadcn 式干净后台:平整、利落、高对比 ============ - 侧边栏 + 统计卡 + 表格的标准后台骨架,全页统一平整处理: - 白/浅灰底、1px 细边框、小圆角、无凸凹阴影、无拟物。 - 钴蓝只给选中态、主按钮与关键数字,其余用中性灰阶分层。 */ +const THEME_VARS_LIGHT = ` + --ss-bg: var(--background, var(--dsw-alias-bg-base, #ffffff)); + --ss-card: var(--card, var(--dsw-alias-bg-layer1, #ffffff)); + --ss-sidebar: var(--sidebar, var(--dsw-alias-bg-layer2, #fafafa)); + --ss-fg: var(--foreground, var(--dsw-alias-label-primary, #09090b)); + --ss-fg2: color-mix(in srgb, var(--ss-fg) 78%, var(--ss-bg)); + --ss-muted: var(--muted-foreground, var(--dsw-alias-label-tertiary, #71717a)); + --ss-placeholder: color-mix(in srgb, var(--ss-muted) 75%, transparent); + --ss-border: var(--border, var(--dsw-alias-border-l1, #e4e4e7)); + --ss-primary: var(--primary, var(--dsw-alias-state-brand-primary, #1e40d8)); + --ss-primary-fg: var(--primary-foreground, #ffffff); + --ss-secondary: var(--secondary, var(--dsw-alias-interactive-bg-hover-solid, #f4f4f5)); + --ss-secondary-fg: var(--secondary-foreground, var(--ss-fg)); + --ss-success: var(--success, #16a34a); + --ss-warning: var(--warning, #d97706); + --ss-error: var(--error, var(--dsw-alias-state-error-primary, #dc2626)); + --ss-link: var(--link, var(--ss-primary)); + --ss-chart-1: var(--chart-1, #4c6ef5); + --ss-chart-2: var(--chart-2, #12b886); + --ss-chart-3: var(--chart-3, #e8590c); + --ss-canvas: color-mix(in srgb, var(--ss-fg) 3%, var(--ss-bg)); + --ss-col: color-mix(in srgb, var(--ss-fg) 3%, var(--ss-bg)); + --ss-subtle: color-mix(in srgb, var(--ss-fg) 3.5%, var(--ss-card)); + --ss-hover: color-mix(in srgb, var(--ss-fg) 5.5%, var(--ss-card)); + --ss-font-ui: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; + --ss-font-seal: "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif; + --ss-font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace; +` - & { - color-scheme: light dark; - --bg: #ffffff; - --sidebar-bg: #fafafa; - --panel: #ffffff; - --panel-line: #e4e4e7; - --muted-bg: #f4f4f5; - --ink: #09090b; - --ink-2: #3f3f46; - --muted: #71717a; - --cobalt: #1e40d8; - --cobalt-ink: #17319f; - --cobalt-soft: rgba(30, 64, 216, .08); - --on-accent: #ffffff; - --ok: #2e7d4f; - --warn: #b06a12; - --bad: #b3372c; - --radius-panel: 8px; - --radius-control: 8px; - --font-ui: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; - --font-seat: "Noto Serif SC", "Songti SC", serif; - --font-num: "IBM Plex Mono", ui-monospace, "SF Mono", monospace; - } - @media (prefers-color-scheme: dark) { - & { - --bg: #09090b; - --sidebar-bg: #0c0c0e; - --panel: #18181b; - --panel-line: #27272a; - --muted-bg: #27272a; - --ink: #fafafa; - --ink-2: #d4d4d8; - --muted: #a1a1aa; - --cobalt: #829cff; - --cobalt-ink: #a9bcff; - --cobalt-soft: rgba(130, 156, 255, .13); - --on-accent: #141a38; - --ok: #5cb582; - --warn: #d99a45; - --bad: #e0705f; - } - } +const THEME_VARS_DARK = ` + --ss-bg: var(--background, var(--dsw-alias-bg-base, #09090b)); + --ss-card: var(--card, var(--dsw-alias-bg-layer1, #18181b)); + --ss-sidebar: var(--sidebar, var(--dsw-alias-bg-layer2, #0c0c0e)); + --ss-fg: var(--foreground, var(--dsw-alias-label-primary, #fafafa)); + --ss-fg2: color-mix(in srgb, var(--ss-fg) 80%, var(--ss-bg)); + --ss-muted: var(--muted-foreground, var(--dsw-alias-label-tertiary, #a1a1aa)); + --ss-placeholder: color-mix(in srgb, var(--ss-muted) 75%, transparent); + --ss-border: var(--border, var(--dsw-alias-border-l1, #27272a)); + --ss-primary: var(--primary, var(--dsw-alias-state-brand-primary, #6b8afd)); + --ss-primary-fg: var(--primary-foreground, #0f172a); + --ss-secondary: var(--secondary, var(--dsw-alias-interactive-bg-hover-solid, #27272a)); + --ss-secondary-fg: var(--secondary-foreground, var(--ss-fg)); + --ss-success: var(--success, #4ade80); + --ss-warning: var(--warning, #fbbf24); + --ss-error: var(--error, var(--dsw-alias-state-error-primary, #f87171)); + --ss-link: var(--link, var(--ss-primary)); + --ss-chart-1: var(--chart-1, #748ffc); + --ss-chart-2: var(--chart-2, #38d9a9); + --ss-chart-3: var(--chart-3, #ff922b); + --ss-canvas: color-mix(in srgb, var(--ss-fg) 2.5%, var(--ss-bg)); + --ss-col: color-mix(in srgb, var(--ss-fg) 3.5%, var(--ss-bg)); + --ss-subtle: color-mix(in srgb, var(--ss-fg) 4.5%, var(--ss-card)); + --ss-hover: color-mix(in srgb, var(--ss-fg) 7%, var(--ss-card)); +` - * { box-sizing: border-box; } -& { height: 100%; } -& { - margin: 0; - background: var(--bg); - color: var(--ink); - font-family: var(--font-ui); - font-size: 14px; - line-height: 1.55; - -webkit-font-smoothing: antialiased; - } - button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; } - button, [role="button"], select, summary, input:not([type="checkbox"], [type="radio"]) { min-height: 2.25rem; } - :focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; } - .num { font-family: var(--font-num); font-variant-numeric: tabular-nums; } - - /* ================= 布局:工作台占满整页(无文件树栏) ================= */ - .shell { display: block; min-height: 100vh; } - - /* ---------- 面板头部与横向标签页(都在内容区同一平面上) ---------- */ - .panel-top { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; } - .brand { display: flex; align-items: baseline; gap: 9px; } - .brand .seal { - font-family: var(--font-seat); font-weight: 900; font-size: 21px; letter-spacing: .06em; - } - .brand .sub { font-size: 11px; color: var(--muted); letter-spacing: .14em; } - .proj { - margin-left: auto; text-align: left; - display: flex; align-items: center; gap: 10px; - padding: 8px 12px; border-radius: var(--radius-control); - background: var(--panel); border: 1px solid var(--panel-line); - } - .proj:hover { background: var(--muted-bg); } - .proj .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; } - .proj .name { font-weight: 700; font-size: 13.5px; } - .proj .meta { font-size: 11.5px; color: var(--muted); } - .proj svg { margin-left: 4px; color: var(--muted); flex: 0 0 auto; } - - /* 横向标签页:灰槽轨道 + 白色选中块,与分段控件同一语言 */ - .tabs { - margin-top: 18px; display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; - border-radius: var(--radius-control); background: var(--muted-bg); - width: fit-content; max-width: 100%; - } - .tabs a { - display: inline-flex; align-items: center; gap: 8px; - padding: 6px 15px; border-radius: 6px; - color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 13.5px; - min-height: 36px; white-space: nowrap; - } - .tabs a svg { flex: 0 0 auto; opacity: .75; } - .tabs a:hover { color: var(--ink); } - .tabs a.on { - color: var(--cobalt-ink); font-weight: 700; - background: var(--panel); border: 1px solid var(--panel-line); padding: 5px 14px; - } - .tabs a.on svg { opacity: 1; color: var(--cobalt); } - /* ---------- 主区 ---------- */ - .main { min-width: 0; padding: 24px 28px 40px; width: 100%; } - /* ---------- 页签页面:一次只显示一页 ---------- */ - .page[hidden] { display: none; } - .page > .topbar { margin-top: 20px; } - tbody tr.clickable { cursor: pointer; } - .settings-stack { display: flex; flex-direction: column; gap: 20px; margin-top: 20px; } - .topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; } - .topbar h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: .01em; } - .topbar .date { color: var(--muted); font-size: 13px; } - .topbar .spacer { flex: 1; } - .search { - display: flex; align-items: center; gap: 8px; - border-radius: var(--radius-control); border: 1px solid var(--panel-line); background: var(--panel); - padding: 0 12px; flex: 0 1 250px; min-width: 0; - } - .search:focus-within { border-color: var(--cobalt); } - .search svg { color: var(--muted); flex: 0 0 auto; } - .search input { border: 0; background: none; outline: none; width: 100%; color: var(--ink); font: inherit; font-size: 13.5px; } - .search input::placeholder { color: var(--muted); } - .btn { - display: inline-flex; align-items: center; gap: 7px; - padding: 8px 16px; border-radius: var(--radius-control); font-weight: 500; - background: var(--panel); border: 1px solid var(--panel-line); - white-space: nowrap; - } - .btn:hover { background: var(--muted-bg); } - .btn.primary { background: var(--cobalt); border-color: var(--cobalt); color: var(--on-accent); font-weight: 700; } - .btn.primary:hover { background: var(--cobalt-ink); border-color: var(--cobalt-ink); } - /* 页头主按钮位:丞相(派工经丞相下达,点开即向丞相交代任务) */ - .btn-cx { gap: 9px; } - .btn-cx .cx-name { font-family: var(--font-seat); font-weight: 900; font-size: 16px; letter-spacing: .05em; line-height: 1; } - .btn-cx .cx-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(255,255,255,.22); flex: 0 0 auto; } - .btn-cx .cx-dot.idle { background: #d4d4d8; box-shadow: none; } - .btn-cx .cx-state { font-size: 12px; font-weight: 500; opacity: .88; } - .btn-cx.selected { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--cobalt); } - .ws-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; } - .ws-actions .btn { padding: 7px 16px; } - .modal input[type="text"] { - width: 100%; border: 1px solid var(--panel-line); border-radius: var(--radius-control); - background: var(--panel); color: var(--ink); font: inherit; font-size: 13.5px; - padding: 8px 10px; - } - .modal input[type="text"]:focus { border-color: var(--cobalt); outline: none; } - - /* ---------- 统计卡(骨架:平、脆、白) ---------- */ - .stats { - display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; - margin-top: 22px; - } - .stat { - background: var(--panel); border: 1px solid var(--panel-line); - border-radius: var(--radius-panel); padding: 16px 18px 14px; - } - .stat-link { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; } - .stat-link:hover { border-color: var(--cobalt); background: var(--cobalt-soft); } - .stat-link:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; } - .stat .label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; } - .stat .big { font-family: var(--font-num); font-size: 30px; font-weight: 600; line-height: 1.25; margin-top: 2px; } - .stat .big .unit { font-size: 14px; color: var(--muted); font-weight: 400; } - .stat .big em { font-style: normal; color: var(--cobalt); } - .stat .foot { font-size: 12px; color: var(--muted); margin-top: 2px; } - .stat .foot b { color: var(--ink-2); font-weight: 500; } - .spark { display: block; margin-top: 6px; } - - /* ---------- 内容网格 ---------- */ - .grid { - display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 368px); gap: 20px; - margin-top: 20px; align-items: start; - } - .panel-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; } - .panel-head h2 { font-size: 16px; margin: 0; font-weight: 700; } - .panel-head .hint { font-size: 12.5px; color: var(--muted); } - - /* 分段控件:平底灰槽 + 白色选中块 */ - .seg { - margin-left: auto; display: inline-flex; gap: 2px; padding: 3px; - border-radius: var(--radius-control); background: var(--muted-bg); - } - .seg button { padding: 5px 14px; border-radius: 6px; font-size: 13px; color: var(--ink-2); min-height: 32px; } - .seg button:hover { color: var(--ink); } - .seg button.on { background: var(--panel); border: 1px solid var(--panel-line); color: var(--ink); font-weight: 700; padding: 4px 13px; } - - /* ---------- 席位谱系:紧凑对齐 · 宽3排 / 中4排 / 窄5排 ---------- - 三省与六部共用一个整宽块:不再居中定宽 760px(宽屏下两边大片留白), - 改为撑满内容区、与上方统计卡和下方表格左右齐平,两排总宽仍相等、上下对齐成块。 - 所有列宽一律 minmax(0, 1fr):可随容器一路流式收缩。 - 三省恒为一排:尚书居中,中书、门下贴其两侧;六部宽屏 6 列、中屏 3×2、窄屏 2×3。 */ - .org-rows { - --tree-line: #c6c6cd; padding-top: 2px; - --ss-gap: 14px; - --lb-gap: 10px; - max-width: none; margin: 0; width: 100%; min-width: 0; - /* 谱系块自身成为容器:六部排数按本块的实际宽度决定(容器查询), - 不再只看视口——外壳/分栏让呈现宽度与视口不一致时,视口断点永远等不到。 */ - container-type: inline-size; - container-name: orgtree; - } - @media (prefers-color-scheme: dark) { .org-rows { --tree-line: #3d3d44; } } - .org-row { display: grid; gap: var(--lb-gap); min-width: 0; } - .org-row-1 { grid-template-columns: minmax(0, 1fr); } - .org-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--ss-gap); } - .org-row-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } - .org-cell { display: flex; justify-content: center; min-width: 0; } - .org-row-1 .node { width: min(248px, 100%); } - .org-row-3 .node { width: 100%; max-width: none; padding: 15px 18px 13px; } - .org-row-3 .node-name { font-size: 24px; } - .org-row-3 .node-role { font-size: 12.5px; } - .org-row-3 .node-task { font-size: 13px; } - .org-row-3 .node-model { font-size: 12.5px; } - .org-row-6 .node { width: 100%; max-width: none; } - /* 六部节点:撑满整宽后每席约 200px+,字号回到正常档,文字不再截断 */ - .org-row-6 .node { padding: 12px 14px 11px; } - .org-row-6 .node-top { gap: 4px 6px; flex-wrap: wrap; } - .org-row-6 .node-name { font-size: 20px; } - .org-row-6 .status { font-size: 12px; gap: 5px; } - .org-row-6 .node-role { font-size: 12px; margin-top: 3px; } - .org-row-6 .node-task { font-size: 12.5px; margin-top: 6px; } - .org-row-6 .node-model { font-size: 12px; margin-top: 6px; } - .org-row-6 .node-foot { margin-top: 8px; } - /* 排间连线层:竖线对准每列中心,横线贯通,全部横平竖直;高度收紧到 22px */ - .org-wires { position: relative; height: 22px; } - .org-wires .wire-v { position: absolute; width: 1px; background: var(--tree-line); } - .org-wires .wire-h { position: absolute; height: 1px; background: var(--tree-line); } - /* ===== 六部换行:触发依据是谱系块自身的宽度,不是视口 ===== - 根因(旧版):排数只由 @media (max-width:1080px/640px) 两条视口断点控制。 - 在应用外壳里,页面呈现宽度(分栏/嵌入)与视口宽并不总是一致,窗口缩到 - 视口断点之前就停住时,两条断点永远等不到,六张卡只能一味变小、挤在一排。 - 根治:三路同阈值(按谱系块宽:>1180 一排 6 张;≤1180 → 3×2;≤700 → 2×3)—— - ① JS ResizeObserver 实测 .org-rows 宽度写入 data-cols(主路,见脚本); - ② @container 容器查询(CSS 原生同义路);③ @media 视口断点(兜底,数值已 - 按主区左右内边距 56px 换算对齐)。三省在任何档位恒为一排。 */ - /* 中档:六部 3 列 × 2 排,每排总宽仍与三省排同宽对齐 */ - .org-rows[data-cols="3"] { --ss-gap: 10px; --lb-gap: 10px; } - .org-rows[data-cols="3"] .org-row-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } - .org-rows[data-cols="3"] .org-wires-2 .wire-h { left: 16.6667% !important; right: 16.6667% !important; } - .org-rows[data-cols="3"] .org-wires-2 .w2-b1 { left: 16.6667% !important; } - .org-rows[data-cols="3"] .org-wires-2 .w2-b2 { left: 50% !important; } - .org-rows[data-cols="3"] .org-wires-2 .w2-b3 { left: 83.3333% !important; } - .org-rows[data-cols="3"] .org-wires-2 .w2-b4, - .org-rows[data-cols="3"] .org-wires-2 .w2-b5, - .org-rows[data-cols="3"] .org-wires-2 .w2-b6 { display: none; } - @container orgtree (max-width: 1180px) { - .org-row-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } - .org-wires-2 .wire-h { left: 16.6667% !important; right: 16.6667% !important; } - .org-wires-2 .w2-b1 { left: 16.6667% !important; } - .org-wires-2 .w2-b2 { left: 50% !important; } - .org-wires-2 .w2-b3 { left: 83.3333% !important; } - .org-wires-2 .w2-b4, .org-wires-2 .w2-b5, .org-wires-2 .w2-b6 { display: none; } - } - @media (max-width: 1240px) { - .org-row-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } - .org-wires-2 .wire-h { left: 16.6667% !important; right: 16.6667% !important; } - .org-wires-2 .w2-b1 { left: 16.6667% !important; } - .org-wires-2 .w2-b2 { left: 50% !important; } - .org-wires-2 .w2-b3 { left: 83.3333% !important; } - .org-wires-2 .w2-b4, .org-wires-2 .w2-b5, .org-wires-2 .w2-b6 { display: none; } - } - /* 窄档:六部 2 列 × 3 排;三省仍一排;卡片上的「主任模型」行隐藏(配置面板不受影响) */ - .org-rows[data-cols="2"] { --ss-gap: 8px; --lb-gap: 8px; } - .org-rows[data-cols="2"] .org-row-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } - .org-rows[data-cols="2"] .node-model { display: none; } - .org-rows[data-cols="2"] .org-wires-2 .wire-h { left: 25% !important; right: 25% !important; } - .org-rows[data-cols="2"] .org-wires-2 .w2-b1 { left: 25% !important; } - .org-rows[data-cols="2"] .org-wires-2 .w2-b2 { left: 75% !important; } - .org-rows[data-cols="2"] .org-wires-2 .w2-b3, - .org-rows[data-cols="2"] .org-wires-2 .w2-b4, - .org-rows[data-cols="2"] .org-wires-2 .w2-b5, - .org-rows[data-cols="2"] .org-wires-2 .w2-b6 { display: none; } - .org-rows[data-cols="2"] .org-row .node { padding: 9px 9px 8px; } - .org-rows[data-cols="2"] .org-row-3 .node-name { font-size: 18px; } - .org-rows[data-cols="2"] .org-row-6 .node-name { font-size: 17px; } - .org-rows[data-cols="2"] .org-row .status { font-size: 11px; gap: 4px; } - .org-rows[data-cols="2"] .org-row .node-top { gap: 5px; flex-wrap: wrap; } - @container orgtree (max-width: 700px) { - .org-row-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } - .node-model { display: none; } - .org-wires-2 .wire-h { left: 25% !important; right: 25% !important; } - .org-wires-2 .w2-b1 { left: 25% !important; } - .org-wires-2 .w2-b2 { left: 75% !important; } - .org-wires-2 .w2-b3, .org-wires-2 .w2-b4, .org-wires-2 .w2-b5, .org-wires-2 .w2-b6 { display: none; } - .org-row .node { padding: 9px 9px 8px; } - .org-row-3 .node-name { font-size: 18px; } - .org-row-6 .node-name { font-size: 17px; } - .org-row .status { font-size: 11px; gap: 4px; } - } - @media (max-width: 760px) { - .node-model { display: none !important; } - .org-row-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } - .org-wires-2 .wire-h { left: 25% !important; right: 25% !important; } - .org-wires-2 .w2-b1 { left: 25% !important; } - .org-wires-2 .w2-b2 { left: 75% !important; } - .org-wires-2 .w2-b3, .org-wires-2 .w2-b4, .org-wires-2 .w2-b5, .org-wires-2 .w2-b6 { display: none; } - .org-row .node { padding: 9px 9px 8px; } - .org-row-3 .node-name { font-size: 18px; } - .org-row-6 .node-name { font-size: 17px; } - .org-row .status { font-size: 11px; gap: 4px; } - .org-row .node-top { gap: 5px; flex-wrap: wrap; } - } - - .node { - width: 158px; min-width: 0; - border-radius: var(--radius-panel); background: var(--panel); - border: 1px solid var(--panel-line); padding: 11px 13px 10px; - position: relative; z-index: 1; - } - .node-main { min-width: 0; } - .node-role, .node-task { overflow-wrap: break-word; } - .node-model .num { overflow-wrap: anywhere; } - .node:hover { border-color: var(--muted); } - .node.selected { border-color: var(--cobalt); background: var(--cobalt-soft); } - .node.dim { opacity: .28; } - .node-main { display: block; width: 100%; text-align: left; padding: 0; min-height: 0; } - .node-role, .node-task, .node-model { display: block; } - .node-top { display: flex; align-items: center; gap: 8px; } - .node-name { font-family: var(--font-seat); font-weight: 900; font-size: 21px; line-height: 1.1; letter-spacing: .04em; } - .node.selected .node-name { color: var(--cobalt); } - .node.root { width: min(248px, 100%); } - .node.root .node-name { font-size: 25px; } - @media (max-width: 1400px) { - .node { width: 136px; } - .node.root { width: min(248px, 100%); } - } - .node-role { font-size: 11.5px; color: var(--muted); margin-top: 3px; } - .node-task { margin-top: 7px; font-size: 12px; color: var(--ink-2); } - .node-task .t-label { color: var(--muted); font-size: 11px; display: block; } - .node-model { margin-top: 6px; font-size: 11.5px; color: var(--muted); } - .node-model .num { font-size: 11px; } - .node-foot { margin-top: 9px; display: flex; align-items: center; gap: 8px; } - .status { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; } - .status i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; } - .status.run i { background: var(--ok); box-shadow: 0 0 0 3px rgba(46,125,79,.16); } - .status.review i { background: var(--warn); box-shadow: 0 0 0 3px rgba(176,106,18,.16); } - .status.idle i { background: var(--muted); } - .elapsed { font-size: 12px; color: var(--muted); } - - /* ---------- 节点纵向骨架:内容区撑满,已耗时一行钉在卡底 ---------- */ - .node { display: flex; flex-direction: column; } - .node-main { flex: 1 1 auto; display: flex; flex-direction: column; } - .node-foot { margin-top: auto; } - .node-task .task-text { display: block; } - - /* ---------- 席位详情头:标题 + 开始对话主按钮 ---------- */ - .detail-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; } - .detail-head h3 { flex: 1 1 auto; min-width: 140px; margin: 0; overflow-wrap: anywhere; } - .detail-head .btn { flex: 0 0 auto; padding: 7px 16px; } - /* ---------- 会话弹窗:与该席对话 ---------- */ - .chat-log { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; } - .chat-msg { - max-width: 88%; padding: 9px 12px; border-radius: 8px; - font-size: 13.5px; line-height: 1.6; overflow-wrap: anywhere; - } - .chat-msg.seat { background: var(--muted-bg); color: var(--ink-2); align-self: flex-start; } - .chat-msg.me { background: var(--cobalt); color: var(--on-accent); align-self: flex-end; } - .chat-compose { display: flex; gap: 10px; margin-top: 16px; align-items: flex-end; } - .chat-compose textarea { - flex: 1; min-height: 44px; resize: vertical; - border: 1px solid var(--panel-line); border-radius: var(--radius-control); - background: var(--panel); color: var(--ink); font: inherit; font-size: 13.5px; - padding: 8px 10px; - } - .chat-compose textarea:focus { border-color: var(--cobalt); outline: none; } - .chat-compose .btn { flex: 0 0 auto; padding: 8px 18px; } - .chat-card { margin-top: 20px; } - .chat-card .chat-log { margin-top: 0; min-height: 260px; } - .chat-card .m-decided { margin: 12px 0 0; font-size: 13px; color: var(--muted); } - - /* ---------- 六部:六张等高卡,每段单行固定高,卡底已耗时齐平 ---------- */ - .org-row-6 .node { height: 100%; padding: 12px 14px; } - .org-row-6 .node-top { flex-wrap: nowrap; height: 30px; overflow: hidden; } - .org-row-6 .node-name { flex: 0 0 auto; } - .org-row-6 .status { flex: 0 0 auto; } - .org-row-6 .node-role { - white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - height: 20px; line-height: 20px; margin-top: 4px; - } - .org-row-6 .node-task { margin-top: 8px; } - .org-row-6 .node-task .t-label { height: 16px; line-height: 16px; } - .org-row-6 .node-task .task-text { - white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - height: 20px; line-height: 20px; - } - .org-row-6 .node-model { - white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - height: 20px; line-height: 20px; margin-top: 6px; - } - .org-row-6 .node-foot { margin-top: auto; padding-top: 9px; } - .org-row-6 .elapsed { - white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - height: 20px; line-height: 20px; display: block; - } - - /* ---------- 右列:详情 + 复核(骨架面板) ---------- */ - .rail { display: flex; flex-direction: column; gap: 20px; } - .detail-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; } - .card { - background: var(--panel); border: 1px solid var(--panel-line); - border-radius: var(--radius-panel); padding: 18px; - } - .card h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; } - .card h3 .count { - font-family: var(--font-num); font-size: 11.5px; background: var(--cobalt); color: var(--on-accent); - border-radius: 999px; padding: 0 8px; line-height: 19px; - } - .detail-name { font-family: var(--font-seat); font-weight: 900; font-size: 30px; color: var(--cobalt); line-height: 1.15; } - .detail-role { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; } - .kv { display: grid; grid-template-columns: 74px 1fr; row-gap: 8px; font-size: 13px; } - .kv dt { color: var(--muted); } - .kv dd { margin: 0; color: var(--ink); } - .kv dd .sub { color: var(--muted); font-size: 12px; } - .excerpt { - margin-top: 14px; border-top: 1px dashed var(--panel-line); padding-top: 12px; - font-size: 13px; color: var(--ink-2); - } - .excerpt .t-label { color: var(--muted); font-size: 11.5px; display: block; margin-bottom: 4px; } - - /* ---------- 部门配置面板:平表单 + 圆点文字标状态 ---------- */ - .card h3 .seat-tag { color: var(--cobalt); font-family: var(--font-seat); font-weight: 900; font-size: 16px; } - .cfg-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 16px; margin-top: 10px; } - .cfg-row { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); } - .cfg-row select { - border: 1px solid var(--panel-line); border-radius: var(--radius-control); - background: var(--panel); color: var(--ink); font: inherit; font-size: 13.5px; - padding: 7px 10px; width: 100%; - } - .cfg-row select:focus { border-color: var(--cobalt); outline: none; } - .cfg-skills { margin-top: 16px; border-top: 1px dashed var(--panel-line); padding-top: 12px; } - .cfg-skills .t-label { color: var(--muted); font-size: 11.5px; display: block; } - .skill-list { list-style: none; margin: 4px 0 0; padding: 0; } - .skill-list li { - display: flex; align-items: center; gap: 10px; - padding: 8px 0; border-top: 1px solid var(--panel-line); font-size: 13px; - } - .skill-list li:first-child { border-top: 0; padding-top: 4px; } - .skill-list .skill-name { flex: 1; min-width: 0; } - .skill-list .skill-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; } - .skill-list .skill-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; } - .skill-list .skill-state.bound { color: var(--ink); } - .skill-list .skill-state.bound i { background: var(--ok); box-shadow: 0 0 0 3px rgba(46,125,79,.16); } - .skill-toggle { - border: 1px solid var(--panel-line); border-radius: var(--radius-control); - background: var(--panel); padding: 4px 13px; font-size: 12.5px; min-height: 32px; white-space: nowrap; - } - .skill-toggle:hover { background: var(--muted-bg); } - @media (max-width: 640px) { .cfg-grid { grid-template-columns: 1fr; } } - - /* ---------- 工作区条目:一条一卡(门下审核 / 中书方案 / 尚书调度共用同一套) ---------- */ - .review-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; } - .review-card { - background: var(--panel); border: 1px solid var(--panel-line); - border-radius: var(--radius-panel); padding: 14px 16px 12px; - } - .review-card.decided { opacity: .55; } - .rc-head { display: flex; align-items: center; gap: 10px; } - .rc-title { - flex: 1; min-width: 0; font-weight: 700; font-size: 14.5px; color: var(--ink); - white-space: nowrap; overflow: hidden; text-overflow: ellipsis; - } - .rc-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; flex: 0 0 auto; } - .rc-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(176,106,18,.16); flex: 0 0 auto; } - .rc-status.pass i { background: var(--ok); box-shadow: 0 0 0 3px rgba(46,125,79,.16); } - .rc-status.reject i { background: var(--bad); box-shadow: 0 0 0 3px rgba(179,55,44,.14); } - .rc-status.run i { background: var(--cobalt); box-shadow: 0 0 0 3px var(--cobalt-soft); } - .rc-status.idle i { background: var(--muted); box-shadow: none; } - .rc-meta-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; } - .rc-from { - font-size: 11.5px; font-weight: 500; color: var(--ink-2); - background: var(--muted-bg); border-radius: 999px; padding: 1px 9px; line-height: 19px; - white-space: nowrap; - } - .rc-meta { font-size: 12px; color: var(--muted); } - .rc-excerpt { - margin-top: 10px; background: var(--muted-bg); border-radius: 6px; - padding: 9px 11px; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; - display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; - } - .rc-excerpt.expanded { display: block; -webkit-line-clamp: unset; } - /* 定夺后记在卡上的批复理由 / 批语(回传提交席位照此修改) */ - .rc-reason { - margin-top: 10px; background: var(--muted-bg); border-radius: 6px; - padding: 8px 11px; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; - overflow-wrap: anywhere; - } - .rc-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; } - .rc-actions .spacer { flex: 1; } - .rc-actions .btn { padding: 5px 14px; font-size: 13px; min-height: 34px; } - .rc-actions .btn.pass { color: var(--cobalt-ink); font-weight: 700; } - .rc-actions .btn:disabled { opacity: .5; cursor: default; } - .rc-actions .btn:disabled:hover { background: var(--panel); } - .r-open { - display: inline-flex; align-items: center; gap: 4px; - font-size: 13px; font-weight: 500; color: var(--cobalt); padding: 5px 6px; min-height: 34px; - } - .r-open:hover { color: var(--cobalt-ink); text-decoration: underline; } - .empty-note { font-size: 13px; color: var(--muted); padding: 10px 0 2px; } - - /* ---------- 席位工作区:随选中席位切换内容 ---------- */ - .w-kind { - font-size: 11.5px; font-weight: 500; color: var(--cobalt-ink); - background: var(--cobalt-soft); border-radius: 999px; padding: 1px 9px; line-height: 19px; - } - .ws-sec { margin-top: 14px; } - .ws-sec:first-child { margin-top: 6px; } - .ws-sec .t-label { color: var(--muted); font-size: 11.5px; display: block; margin-bottom: 4px; } - .ws-sec p { margin: 0; font-size: 13.5px; color: var(--ink-2); } - /* 方案 / 调度 / 审核条目样式见上方「工作区条目:一条一卡」 */ - - /* ---------- 右列里的配置面板:字段上下排 ---------- */ - .rail .cfg-grid { grid-template-columns: minmax(0, 1fr); } - - /* ---------- 复核弹窗:看清待准奏内容再定夺 ---------- */ - .modal-backdrop { - position: fixed; inset: 0; z-index: 60; - background: rgba(9, 9, 11, .48); - display: flex; align-items: center; justify-content: center; - padding: 18px; - } - .modal-backdrop[hidden] { display: none; } - .modal { - background: var(--panel); color: var(--ink); - border: 1px solid var(--panel-line); border-radius: 12px; - width: min(580px, 100%); max-height: calc(100vh - 36px); overflow-y: auto; - padding: 20px 22px 18px; - } - .modal.wide { width: min(760px, 100%); } - .modal-head { display: flex; align-items: flex-start; gap: 12px; } - .modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; min-width: 0; } - .modal-close { - flex: 0 0 auto; width: 32px; height: 32px; min-height: 32px; - border: 1px solid var(--panel-line); border-radius: var(--radius-control); - display: inline-flex; align-items: center; justify-content: center; font-size: 15px; - } - .modal-close:hover { background: var(--muted-bg); } - .modal .m-from { font-size: 12.5px; color: var(--muted); margin-top: 3px; } - .modal .m-sec { margin-top: 15px; } - .modal .m-sec .t-label { color: var(--muted); font-size: 11.5px; display: block; margin-bottom: 4px; } - .modal .m-sec p { margin: 0; font-size: 13.5px; color: var(--ink-2); } - .modal .m-doubts { list-style: none; margin: 0; padding: 0; } - .modal .m-doubts li { padding: 6px 0 6px 16px; border-top: 1px solid var(--panel-line); font-size: 13.5px; color: var(--ink-2); position: relative; } - .modal .m-doubts li:first-child { border-top: 0; } - .modal .m-doubts li::before { content: ""; position: absolute; left: 2px; top: 14px; width: 5px; height: 5px; border-radius: 50%; background: var(--warn); } - .modal .m-source { - background: var(--muted-bg); border-radius: var(--radius-panel); - padding: 10px 12px; font-size: 13px; color: var(--ink-2); - } - .modal-actions { display: flex; gap: 10px; margin-top: 18px; } - .modal-actions .btn { padding: 7px 18px; } - .modal-actions .btn.pass { color: var(--cobalt-ink); font-weight: 700; } - .modal .m-decided { margin-top: 16px; font-size: 13px; color: var(--muted); } - .modal textarea { - width: 100%; border: 1px solid var(--panel-line); border-radius: var(--radius-control); - background: var(--panel); color: var(--ink); font: inherit; font-size: 13.5px; - padding: 8px 10px; resize: vertical; min-height: 64px; - } - .modal textarea:focus { border-color: var(--cobalt); outline: none; } - .modal .m-err { color: var(--bad); font-size: 12.5px; margin: 6px 0 0; } - .modal .m-err[hidden] { display: none; } - - /* ---------- 表格(骨架:干脆、高对比、无拟物) ---------- */ - .table-card { - margin-top: 20px; background: var(--panel); border: 1px solid var(--panel-line); - border-radius: var(--radius-panel); padding: 18px 18px 8px; - } - .table-scroll { overflow-x: auto; } - table { width: 100%; border-collapse: collapse; font-size: 13.5px; } - thead th { - text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; - padding: 8px 12px; border-bottom: 1px solid var(--panel-line); white-space: nowrap; - } - tbody td { padding: 11px 12px; border-bottom: 1px solid var(--panel-line); vertical-align: middle; } - tbody tr:last-child td { border-bottom: 0; } - tbody tr:hover td { background: var(--cobalt-soft); } - td .task-name { font-weight: 500; } - td .task-id { font-family: var(--font-num); font-size: 11.5px; color: var(--muted); } - .pill { - display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; - border: 1px solid var(--panel-line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; - background: var(--panel); - } - .pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); } - .pill.done i { background: var(--ok); } - .pill.run i { background: var(--cobalt); } - .pill.review i { background: var(--warn); } - .pill.fail i { background: var(--bad); } - td.time, td.dur { font-family: var(--font-num); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; } - td.result-cell { max-width: 260px; min-width: 160px; color: var(--ink-2); font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; } - .foot-note { margin-top: 16px; font-size: 12px; color: var(--muted); } - - /* ---------- 窄屏回落:按工作台自身宽度判断,避免右栏 600px 仍套宽屏网格 ---------- */ - @container ssv2 (max-width: 1180px) { - .grid { grid-template-columns: 1fr; } - .rail { flex-direction: row; align-items: stretch; } - .rail .card { flex: 1; } - .stats { grid-template-columns: repeat(2, 1fr); } - } - @container ssv2 (max-width: 860px) { - .proj { margin-left: 0; } - .tabs { width: 100%; } - .tabs a { flex: 1 1 auto; justify-content: center; } - .rail { flex-direction: column; } - .search { width: 100%; order: 5; } - .stats { grid-template-columns: 1fr 1fr; gap: 10px; } - } - @container ssv2 (max-width: 640px) { - /* 窄栏表格收成四列:藏「耗时」「派发时间」两列,单元格允许换行,不横滚 */ - thead th:nth-child(5), tbody td:nth-child(5), - thead th:nth-child(6), tbody td:nth-child(6) { display: none; } - thead th, tbody td { padding-left: 8px; padding-right: 8px; } - thead th { white-space: normal; } - td .task-name, td .task-id { overflow-wrap: anywhere; } - .pill { padding: 2px 7px; font-size: 11.5px; white-space: normal; } - td.time { white-space: normal; } - } - @media (prefers-reduced-motion: reduce) { - * { transition: none !important; } - } - } - -body[data-ds-dark-theme] .ssv2,html[data-theme=dark] .ssv2,.ssv2[data-ssv-theme=dark]{--bg:#09090b;--sidebar-bg:#0c0c0e;--panel:#18181b;--panel-line:#27272a;--muted-bg:#27272a;--ink:#fafafa;--ink-2:#d4d4d8;--muted:#a1a1aa;--cobalt:#829cff;--cobalt-ink:#a9bcff;--cobalt-soft:rgba(130,156,255,.13);--on-accent:#141a38;--ok:#5cb582;--warn:#d99a45;--bad:#e0705f} - -/* ---------- 宿主接线:右栏 / 浮动面板 / 内嵌条 ---------- */ -.ssw-tab-body{height:100%;min-height:0;display:flex;flex-direction:column;overflow:hidden} +export const CSS = ` +/* ---------- 宿主接线槽位 ---------- */ +.ssw-tab-body,.ssw-main-panel{height:100%;min-height:0;width:100%;display:flex;flex-direction:column;overflow:hidden} .ssw-tab-title{font-size:12px;font-weight:600} -.ssw-inline-bar{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 14px;background:var(--muted-bg);border-bottom:1px solid var(--panel-line);font-size:12px;color:var(--muted)} -.ssw-link{color:var(--cobalt-ink);font-size:12px;font-weight:500;padding:4px 6px;border-radius:6px} -.ssw-link:hover{background:var(--cobalt-soft)} .ssw-nav-hit{display:inline-flex;align-items:center;justify-content:center;color:inherit;width:100%;height:100%} -.ssw-float{position:fixed;right:14px;bottom:70px;z-index:2147483000;width:min(760px,calc(100vw - 28px));max-height:calc(100vh - 96px);display:flex;flex-direction:column;background:var(--panel,#fff);border:1px solid var(--panel-line,#e4e4e7);border-radius:12px;box-shadow:0 18px 50px -12px rgba(16,24,40,.28),0 4px 12px -2px rgba(16,24,40,.12);overflow:hidden} -.ssw-float>.ssv2{height:100%;min-height:0;overflow:auto} +.ssw-inline-bar{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 14px;background:var(--dsw-alias-bg-layer2,#f4f4f5);border-bottom:1px solid var(--dsw-alias-border-l1,#e4e4e7);font-size:12px} +.ssw-link{color:var(--dsw-alias-state-brand-primary,#1e40d8);font-size:12px;font-weight:500;padding:4px 6px;border-radius:6px} +.ssw-float{position:fixed;right:14px;bottom:70px;z-index:2147483000;width:min(760px,calc(100vw - 28px));max-height:calc(100vh - 96px);display:flex;flex-direction:column;background:var(--dsw-alias-bg-base,#fff);border:1px solid var(--dsw-alias-border-l1,#e4e4e7);border-radius:12px;box-shadow:0 18px 50px -12px rgba(16,24,40,.28);overflow:hidden} -/* ---------- 工作台 v2 工具样式 ---------- */ -.ssv2{height:100%;min-height:0;overflow:auto;background:var(--bg);color:var(--ink);font-family:var(--font-ui)} -.ssv2 .main{min-height:100%;min-width:600px;container-type:inline-size;container-name:ssv2;display:flex;flex-direction:column} -.ssv2 .page{min-height:0;flex:1 0 auto} -.ssv2 .topbar-title{display:flex;align-items:center;gap:12px;min-width:0;flex-wrap:wrap} -.ssv2 .topbar-icons{display:flex;align-items:center;gap:6px} -.ssv2 .icon-btn{width:32px;height:32px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:var(--radius-control);background:transparent;color:var(--muted);cursor:pointer;padding:0} -.ssv2 .icon-btn:hover{background:var(--muted-bg);color:var(--ink);border-color:var(--panel-line)} -.ssv2 .icon-btn:focus-visible{outline:2px solid var(--cobalt);outline-offset:2px} -.ssv2 .project-dock{display:flex;justify-content:flex-end;margin-top:auto;padding-top:22px} -.ssv2 .project-dock .proj{margin-left:0} -.ssv-banner{margin:12px 0 0;padding:9px 12px;border-radius:8px;font-size:12.5px;line-height:1.5;border:1px solid var(--panel-line);background:var(--muted-bg);color:var(--ink-2)} -.ssv-banner.is-error{color:var(--bad);background:color-mix(in srgb, var(--bad) 8%, var(--panel));border-color:color-mix(in srgb, var(--bad) 24%, var(--panel-line))} -.ssv-banner.is-notice{color:var(--cobalt-ink);background:var(--cobalt-soft);border-color:color-mix(in srgb, var(--cobalt) 20%, var(--panel-line))} -.ssv-textarea{width:100%;box-sizing:border-box;border:1px solid var(--panel-line);border-radius:var(--radius-control);background:var(--panel);color:var(--ink);font:inherit;font-size:13px;line-height:1.55;padding:7px 10px;resize:vertical} -.ssv-textarea:focus{border-color:var(--cobalt);outline:none} -.ssv-select{width:100%;border:1px solid var(--panel-line);border-radius:var(--radius-control);background:var(--panel);color:var(--ink);font:inherit;font-size:13.5px;padding:7px 10px} -.ssv-select:focus{border-color:var(--cobalt);outline:none} -.ssv-check{display:flex;align-items:center;gap:8px;margin-top:12px;font-size:13px;color:var(--ink-2);cursor:pointer} -.ssv-check input{accent-color:var(--cobalt);width:15px;height:15px} -.ssv-proj-caret{font-size:15px;color:var(--muted);margin-left:2px} -.ssv2 .ws-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px} -.ssv2 .ws-actions .btn{min-height:34px;padding:5px 12px;font-size:13px} -.ssv2 .skill-list li{gap:8px} -.ssv2 .skill-list .skill-toggle{flex:none} -.ssv2 .card h3 .count{font-family:var(--font-num)} +/* ---------- 双工作台共享主题变量与基础重置 ---------- */ +.ssv2,.ssmwb{ + ${THEME_VARS_LIGHT} + color-scheme: light dark; + color: var(--ss-fg); + font-family: var(--ss-font-ui); + font-size: 14px; + line-height: 1.5; + -webkit-font-smoothing: antialiased; +} +@media (prefers-color-scheme: dark){ + .ssv2,.ssmwb{ ${THEME_VARS_DARK} } +} +body[data-ds-dark-theme] .ssv2, +body[data-ds-dark-theme] .ssmwb, +html[data-theme="dark"] .ssv2, +html[data-theme="dark"] .ssmwb, +.ssv2[data-ssv-theme="dark"], +.ssmwb[data-ssv-theme="dark"]{ + ${THEME_VARS_DARK} +} -/* ---------- 结果摘要 / 展开详情 ---------- */ -.ssv2 .result-summary{margin-top:10px;min-width:0;max-width:100%} -.ssv2 .rs-line{display:flex;flex-direction:column;gap:3px;min-width:0} -.ssv2 .rs-summary{font-size:13px;color:var(--ink);line-height:1.6;overflow-wrap:anywhere;word-break:break-word} -.ssv2 .rs-points{margin:6px 0 0;padding-left:18px;font-size:12.5px;color:var(--ink-2);line-height:1.65} -.ssv2 .rs-points li{margin:2px 0;overflow-wrap:anywhere} -.ssv2 .rs-toggle{margin-top:5px;padding:0;color:var(--cobalt);font-size:12.5px;font-weight:500;min-height:24px;text-align:left} -.ssv2 .rs-detail{margin-top:10px;border-top:1px dashed var(--panel-line);padding-top:10px;font-size:13px;color:var(--ink-2);max-width:100%;overflow:hidden} -.ssv2 .rs-detail p,.ssv2 .rs-detail li,.ssv2 .rs-detail code,.ssv2 .rs-detail pre{overflow-wrap:anywhere;word-break:break-word;white-space:pre-wrap;max-width:100%} -.ssv2 .rs-heading{margin:10px 0 4px;font-size:13px;color:var(--ink);font-weight:700} -.ssv2 .rs-list{margin:4px 0 8px;padding-left:18px} -.ssv2 .rs-code{margin:6px 0;padding:8px 10px;border-radius:6px;background:var(--muted-bg);border:1px solid var(--panel-line);white-space:pre-wrap;overflow-wrap:anywhere} -.ssv2 .rs-path{display:inline-block;padding:1px 4px;border-radius:4px;background:var(--muted-bg);font-family:var(--font-num);font-size:12px} -.ssv2 .result-summary.is-empty{color:var(--muted);font-size:12.5px} -.ssv2 .rs-empty{margin-left:6px;color:var(--muted)} -.ssv2 .ws-hint{margin-top:8px} -/* ---------- 可折叠卡片(部门配置 / 记忆编辑) ---------- */ -.ssv2 details.card>summary{display:flex;align-items:center;gap:8px;cursor:pointer;font-weight:700;font-size:14.5px;list-style:none;min-height:28px} -.ssv2 details.card>summary::-webkit-details-marker{display:none} -.ssv2 details.card>summary::after{content:'⌄';margin-left:auto;color:var(--muted);transition:transform .15s} -.ssv2 details.card[open]>summary::after{transform:rotate(180deg)} -.ssv2 details.card[open]>summary{margin-bottom:8px} -.ssv2 .dept-config-body{padding-top:2px} +.ssv2 *,.ssmwb *{box-sizing:border-box} +.ssv2 button,.ssmwb button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer} +.ssv2 button:disabled,.ssmwb button:disabled{opacity:.5;cursor:default} +.ssv2 input,.ssmwb input,.ssv2 select,.ssmwb select,.ssv2 textarea,.ssmwb textarea{font:inherit;color:var(--ss-fg)} +.ssv2 :focus-visible,.ssmwb :focus-visible{outline:2px solid var(--ss-primary);outline-offset:1px} +.ssv2 ::-webkit-scrollbar,.ssmwb ::-webkit-scrollbar{width:6px;height:6px} +.ssv2 ::-webkit-scrollbar-track,.ssmwb ::-webkit-scrollbar-track{background:transparent} +.ssv2 ::-webkit-scrollbar-thumb,.ssmwb ::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--ss-muted) 30%,transparent);border-radius:999px} -/* ---------- 工作台 v2:顶栏小导航 / 队列与 Token 弹窗 / 卡片摘要 ---------- */ -.ssv2 .panel-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap} -.ssv2 .panel-actions .btn{min-height:32px;padding:5px 11px;font-size:12.5px} -.ssv2 .modal-toolbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-top:16px} -.ssv2 .modal-toolbar .search{flex:1 1 220px} -.ssv2 .queue-table-wrap{margin-top:14px;border-top:1px solid var(--panel-line)} -.ssv2 .queue-table-wrap table{margin-top:4px} -.ssv2 .card-summary{margin-top:8px;min-width:0} -.ssv2 .card-summary .t-label{display:block;color:var(--muted);font-size:11.5px;margin-bottom:3px} -.ssv2 .card-summary-text{margin:0;font-size:12.5px;line-height:1.6;color:var(--ink-2);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere;word-break:break-word} -.ssv2 .card-summary.is-empty .card-summary-text{color:var(--muted)} -.ssv2 .m-rich{margin-top:2px;font-size:13.5px;color:var(--ink-2);max-width:100%;overflow:hidden} -.ssv2 .m-rich p{margin:0 0 6px} -.ssv2 .m-rich p:last-child{margin-bottom:0} -/* ---------- 需求门控工作区 ---------- */ -.ssv2 .req-gate{padding:18px} -.ssv2 .req-gate h3{margin-bottom:6px} -.ssv2 .req-tabs{display:flex;gap:6px;margin:12px 0 14px;border-bottom:1px solid var(--panel-line);padding-bottom:2px} -.ssv2 .req-tab{border:0;background:transparent;color:var(--muted);font-family:var(--font-ui);font-size:13px;padding:7px 10px;border-radius:6px 6px 0 0;cursor:pointer} -.ssv2 .req-tab:hover{background:var(--muted-bg);color:var(--ink)} -.ssv2 .req-tab.is-active{color:var(--cobalt);font-weight:700;box-shadow:inset 0 -2px 0 var(--cobalt)} -.ssv2 .req-list{gap:10px} -.ssv2 .req-card{padding:13px 14px} -.ssv2 .req-meta{display:flex;flex-wrap:wrap;gap:8px 14px;margin:6px 0 8px;color:var(--muted);font-family:var(--font-num);font-size:11px} -.ssv2 .req-details{margin:8px 0;border-top:1px dashed var(--panel-line);padding-top:8px} -.ssv2 .req-details>summary{cursor:pointer;color:var(--ink-2);font-size:12px} -.ssv2 .req-details .kv{margin-top:8px} -.ssv2 .req-children{display:flex;flex-direction:column;gap:6px;margin-top:10px;border-top:1px dashed var(--panel-line);padding-top:8px} -.ssv2 .req-child{display:grid;grid-template-columns:74px auto 1fr;gap:6px 10px;align-items:start;font-size:12px;color:var(--ink-2)} -.ssv2 .req-child-owner{font-family:var(--font-seat);font-weight:700;color:var(--ink)} -.ssv2 .req-child-result{grid-column:1/-1;color:var(--muted);overflow-wrap:anywhere} -.ssv2 .req-child-session{grid-column:1/-1;color:var(--muted);font-family:var(--font-num);font-size:10px;overflow-wrap:anywhere} -/* ---------- 模型来源/同步与集中审批 ---------- */ -.ssv2 .cfg-model-status{margin:10px 0 4px;padding:10px 12px;border:1px solid var(--panel-line);border-radius:8px;background:var(--muted-bg);font-size:12px;line-height:1.7;color:var(--ink-2)} -.ssv2 .cfg-model-status>div{overflow-wrap:anywhere} -.ssv2 .approval-card{margin-top:16px;padding:16px 18px} -.ssv2 .approval-list{display:flex;flex-direction:column;gap:10px;margin-top:10px} -.ssv2 .approval-item{border:1px solid var(--panel-line);border-radius:8px;padding:10px 12px;background:var(--panel)} -.ssv2 .approval-head{display:flex;gap:10px;align-items:center;justify-content:space-between;font-size:12.5px;overflow-wrap:anywhere} -.ssv2 .approval-head>span{flex-shrink:0;max-width:45%;text-align:right} -.ssv2 .approval-item p{margin:6px 0;color:var(--ink-2);font-size:12.5px;line-height:1.6;overflow-wrap:anywhere} -.ssv2 .approval-actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end} -.ssv2 .approval-actions .btn{max-width:100%;white-space:normal;overflow-wrap:anywhere} -.ssv2 .task-original-text{white-space:pre-wrap;overflow-wrap:anywhere} -`; +.ssv2 .font-seal,.ssmwb .font-seal{font-family:var(--ss-font-seal);letter-spacing:.04em} +.ssv2 .font-mono-num,.ssmwb .font-mono-num{font-family:var(--ss-font-mono);font-variant-numeric:tabular-nums} +.ssv2 .truncate,.ssmwb .truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.ssv2 .line-clamp-2,.ssmwb .line-clamp-2{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden} +.ssv2 .wb-select,.ssmwb .wb-select{background:var(--ss-card);color:var(--ss-fg);border:1px solid var(--ss-border);border-radius:8px;padding:6px 10px;font-size:12px;width:100%} + +/* ---------- 语义状态点 / 胶囊 ---------- */ +@keyframes ssvPulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.42;transform:scale(1.24)}} +.ss-dot{width:7px;height:7px;border-radius:50%;flex:0 0 auto;background:var(--ss-muted)} +.ss-dot.is-primary{background:var(--ss-primary)} +.ss-dot.is-success{background:var(--ss-success)} +.ss-dot.is-warning{background:var(--ss-warning)} +.ss-dot.is-error{background:var(--ss-error)} +.ss-dot.is-pulse{animation:ssvPulse 2s ease-in-out infinite} +@media (prefers-reduced-motion: reduce){.ss-dot.is-pulse{animation:none}} + +.ss-pill{display:inline-flex;align-items:center;gap:5px;padding:2px 8px;border-radius:999px;font-size:12px;line-height:1.35;border:1px solid var(--ss-border);background:var(--ss-subtle);color:var(--ss-muted);white-space:nowrap;flex-shrink:0} +.ss-pill.is-primary{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border));color:var(--ss-primary)} +.ss-pill.is-success{background:color-mix(in srgb,var(--ss-success) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-success) 30%,var(--ss-border));color:var(--ss-success)} +.ss-pill.is-warning{background:color-mix(in srgb,var(--ss-fg) 3%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-warning) 36%,var(--ss-border));color:var(--ss-warning)} +.ss-pill.is-error{background:color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-error) 32%,var(--ss-border));color:var(--ss-error)} + +/* ---------- 极致无框「待你处理」样式(无外框浅蓝底 + 独立纯白条目) ---------- */ +.frameless-zone{background:color-mix(in srgb,var(--ss-primary) 8.5%,var(--ss-card));border:0;border-radius:16px;padding:12px;display:flex;flex-direction:column;gap:10px} +.frameless-zone.is-dock-full{flex:1 1 auto;min-height:0} +.frameless-zone-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 4px;flex:none} +.frameless-zone-title-wrap{display:flex;align-items:center;gap:8px;min-width:0} +.frameless-zone-title{font-size:13px;font-weight:600;color:var(--ss-fg);margin:0;white-space:nowrap} +.frameless-zone-count{padding:2px 7px;border-radius:999px;font-size:12px;line-height:1;font-weight:600;background:var(--ss-primary);color:var(--ss-primary-fg);font-family:var(--ss-font-mono);font-variant-numeric:tabular-nums;flex-shrink:0} +.frameless-zone-sub{font-size:12px;color:var(--ss-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.frameless-zone-list{display:flex;flex-direction:column;gap:10px} +.frameless-zone-list.is-scroll{flex:1 1 auto;min-height:0;overflow-y:auto;padding-right:2px} +.frameless-item{background:var(--ss-card);border:0;border-radius:12px;padding:12px 14px;display:flex;flex-direction:column;gap:8px;box-shadow:0 1px 3px color-mix(in srgb,var(--ss-primary) 8%,transparent);transition:box-shadow 150ms ease} +.frameless-item:hover{box-shadow:0 3px 10px -2px color-mix(in srgb,var(--ss-primary) 15%,transparent)} +.frameless-item-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px} +.frameless-item-meta{display:flex;align-items:center;gap:6px;min-width:0} +.frameless-chip{display:inline-flex;align-items:center;gap:5px;padding:2px 8px;border-radius:999px;font-size:12px;font-weight:500;flex-shrink:0} +.frameless-chip.is-err{background:color-mix(in srgb,var(--ss-error) 10%,var(--ss-card));color:var(--ss-error)} +.frameless-chip.is-pri{background:color-mix(in srgb,var(--ss-primary) 10%,var(--ss-card));color:var(--ss-primary)} +.frameless-code{background:color-mix(in srgb,var(--ss-fg) 3.5%,var(--ss-card));border:0;border-radius:8px;padding:7px 10px;font-size:12px;line-height:1.55;color:var(--ss-fg);overflow-wrap:anywhere} +.frameless-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px} +.frameless-btn-group{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-left:auto} +.frameless-btn{background:color-mix(in srgb,var(--ss-fg) 4.5%,var(--ss-card));color:var(--ss-fg);border:0;border-radius:8px;padding:5px 11px;font-size:12px;font-weight:500;transition:background-color 140ms ease,color 140ms ease} +.frameless-btn:hover{background:color-mix(in srgb,var(--ss-primary) 11%,var(--ss-card));color:var(--ss-primary)} +.frameless-primary-btn{background:var(--ss-primary);color:var(--ss-primary-fg);border:0;border-radius:8px;padding:5px 12px;font-size:12px;font-weight:500;transition:opacity 140ms ease} +.frameless-primary-btn:hover{opacity:.9} +.frameless-link{font-size:12px;color:var(--ss-link);flex-shrink:0} +.frameless-link:hover{text-decoration:underline} + +/* ---------- 提示横幅 & 弹窗 ---------- */ +.wb-toast-wrap{flex:none;padding:10px 16px 0} +.wb-toast-box{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 12px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-subtle);font-size:12px} +.wb-toast-box.is-primary{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border));color:var(--ss-primary)} +.wb-toast-box.is-success{background:color-mix(in srgb,var(--ss-success) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-success) 30%,var(--ss-border));color:var(--ss-success)} +.wb-toast-box.is-error{background:color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-error) 32%,var(--ss-border));color:var(--ss-error)} +.wb-toast-close{color:var(--ss-muted);padding:0 4px} +.wb-toast-close:hover{color:var(--ss-fg)} + +.wb-modal-backdrop{position:fixed;inset:0;z-index:60;background:rgba(9,9,11,.46);display:flex;align-items:center;justify-content:center;padding:12px} +.wb-modal{width:min(640px,100%);max-height:86vh;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);overflow:hidden;box-shadow:0 20px 44px -12px rgba(0,0,0,.32)} +.wb-modal-head{padding:12px 16px;border-bottom:1px solid var(--ss-border);display:flex;align-items:flex-start;justify-content:space-between;gap:12px} +.wb-modal-title{margin:0;font-size:14px;font-weight:600;color:var(--ss-fg)} +.wb-modal-close{width:28px;height:28px;border-radius:8px;border:1px solid var(--ss-border);display:inline-flex;align-items:center;justify-content:center;font-size:12px;flex-shrink:0} +.wb-modal-close:hover{background:var(--ss-hover)} +.wb-modal-body{padding:16px;overflow-y:auto;display:flex;flex-direction:column;gap:12px;font-size:12px} +.wb-modal-foot{padding:10px 16px;border-top:1px solid var(--ss-border);display:flex;justify-content:flex-end;gap:8px} + +/* ============================================================================ + 1. BETTER SIDEBAR 单项目工作台 (.ssv2) + ============================================================================ */ +.ssv2{height:100%;min-height:0;width:100%;min-width:0;display:flex;flex-direction:column;overflow:hidden;background:var(--ss-canvas);container-type:inline-size;container-name:wb} +.ssv2 .wb-header{flex:none;position:relative;z-index:20;padding:12px 16px 0;border-bottom:1px solid var(--ss-border);background:var(--ss-card)} +.ssv2 .wb-header-row{display:flex;align-items:center;justify-content:space-between;gap:8px} +.ssv2 .wb-brand{display:flex;align-items:center;gap:8px;min-width:0} +.ssv2 .wb-seal-badge{width:32px;height:32px;border-radius:8px;border:1px solid color-mix(in srgb,var(--ss-primary) 30%,var(--ss-border));background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));display:flex;align-items:center;justify-content:center;flex-shrink:0;font-family:var(--ss-font-seal);font-weight:700;font-size:14px;color:var(--ss-primary)} +.ssv2 .wb-brand-title-row{display:flex;align-items:center;gap:6px;min-width:0} +.ssv2 .wb-brand-title{margin:0;font-family:var(--ss-font-seal);font-size:16px;font-weight:700;line-height:1.25;white-space:nowrap} +.ssv2 .wb-role-badge{padding:2px 6px;border-radius:4px;font-size:12px;line-height:1.1;background:var(--ss-subtle);border:1px solid var(--ss-border);color:var(--ss-muted);flex-shrink:0} +.ssv2 .wb-subline{margin:2px 0 0;font-size:12px;color:var(--ss-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.ssv2 .wb-proj-pill{display:inline-flex;align-items:center;gap:6px;padding:5px 10px;border-radius:8px;background:var(--ss-subtle);border:1px solid var(--ss-border);font-size:12px;max-width:190px;flex-shrink:0} +.ssv2 .wb-proj-name{font-weight:500;color:var(--ss-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap} + +.ssv2 .wb-tabs{display:flex;align-items:center;gap:2px;margin-top:8px;margin-bottom:-1px;overflow-x:auto} +.ssv2 .wb-tab-btn{display:inline-flex;align-items:center;gap:6px;padding:9px 12px;font-size:12px;font-weight:500;white-space:nowrap;border-bottom:2px solid transparent;color:var(--ss-muted);transition:color 140ms ease,border-color 140ms ease} +.ssv2 .wb-tab-btn:hover{color:var(--ss-fg)} +.ssv2 .wb-tab-btn.is-active{border-bottom-color:var(--ss-primary);color:var(--ss-primary);font-weight:600} +.ssv2 .wb-tab-badge{padding:1px 6px;border-radius:999px;font-size:12px;line-height:1.2} + +.ssv2 .wb-body{flex:1 1 auto;min-height:0;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:14px} +.ssv2 .wb-footer{flex:none;padding:8px 16px;border-top:1px solid var(--ss-border);background:var(--ss-sidebar);display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;font-size:12px;color:var(--ss-muted)} +.ssv2 .wb-refresh-btn{display:inline-flex;align-items:center;gap:4px;padding:3px 8px;border-radius:6px;font-size:12px;color:var(--ss-muted)} +.ssv2 .wb-refresh-btn:hover{background:var(--ss-hover);color:var(--ss-fg)} + +.ssv2 .telemetry-strip{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);padding:8px 12px;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;font-size:12px} +.ssv2 .telemetry-group{display:flex;flex-wrap:wrap;align-items:center;gap:12px} +.ssv2 .telemetry-item{display:inline-flex;align-items:center;gap:5px} + +.ssv2 .court-split{display:grid;grid-template-columns:minmax(0,1fr);gap:16px;align-items:start} +@container wb (min-width: 920px){.ssv2 .court-split{grid-template-columns:minmax(0,1.35fr) minmax(300px,0.95fr);gap:18px}} +.ssv2 .court-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px} +.ssv2 .court-title{margin:0;font-size:14px;font-weight:600} +.ssv2 .seg-group{display:inline-flex;align-items:center;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);padding:2px;font-size:12px} +.ssv2 .seg-btn{padding:3px 8px;border-radius:6px;color:var(--ss-muted);transition:background-color 120ms ease,color 120ms ease;white-space:nowrap} +.ssv2 .seg-btn:hover{color:var(--ss-fg)} +.ssv2 .seg-btn.is-active{background:var(--ss-secondary);color:var(--ss-secondary-fg);font-weight:500} + +.ssv2 .lead-card{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);padding:12px;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;transition:border-color 140ms ease} +.ssv2 .lead-card.is-selected{border-color:var(--ss-primary);background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));box-shadow:0 0 0 1px var(--ss-primary)} +.ssv2 .lead-select-btn{display:flex;align-items:center;gap:10px;text-align:left;min-width:0;flex:1 1 auto} +.ssv2 .lead-seal{width:36px;height:36px;border-radius:8px;border:1px solid color-mix(in srgb,var(--ss-primary) 30%,var(--ss-border));background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));display:flex;align-items:center;justify-content:center;font-family:var(--ss-font-seal);font-weight:700;font-size:16px;color:var(--ss-primary);flex-shrink:0} +.ssv2 .wb-btn-outline{padding:6px 10px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);font-size:12px;font-weight:500;transition:border-color 140ms ease,background-color 140ms ease;white-space:nowrap} +.ssv2 .wb-btn-outline:hover{border-color:var(--ss-primary);color:var(--ss-primary)} +.ssv2 .wb-btn-primary{display:inline-flex;align-items:center;gap:6px;padding:6px 12px;border-radius:8px;background:var(--ss-primary);color:var(--ss-primary-fg);font-size:12px;font-weight:500;white-space:nowrap;transition:opacity 140ms ease} +.ssv2 .wb-btn-primary:hover{opacity:.9} + +.ssv2 .tier-divider{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--ss-muted);padding:0 2px} +.ssv2 .tier-divider strong{font-weight:500;color:var(--ss-fg)} +.ssv2 .tier-line{flex:1 1 auto;height:1px;background:var(--ss-border)} + +.ssv2 .sansheng-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px} +.ssv2 .liubu-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px} +.ssv2 .seat-card{text-align:left;width:100%;border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);padding:10px;display:flex;flex-direction:column;justify-content:space-between;gap:6px;transition:border-color 140ms ease,background-color 140ms ease} +.ssv2 .seat-card:hover{border-color:var(--ss-muted)} +.ssv2 .seat-card.is-selected{border-color:var(--ss-primary);background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));box-shadow:0 0 0 1px var(--ss-primary)} +.ssv2 .seat-card.is-dimmed{opacity:.35} +.ssv2 .seat-head{display:flex;align-items:center;justify-content:space-between;gap:6px} +.ssv2 .seat-title-wrap{display:inline-flex;align-items:center;gap:6px;min-width:0} +.ssv2 .seat-name{font-family:var(--ss-font-seal);font-weight:700;font-size:15px;line-height:1.25} +.ssv2 .seat-card.is-sansheng .seat-name{font-size:16px} +.ssv2 .seat-card.is-selected .seat-name{color:var(--ss-primary)} +.ssv2 .seat-live-tag{padding:2px 6px;border-radius:4px;font-size:12px;line-height:1;background:var(--ss-primary);color:var(--ss-primary-fg)} +.ssv2 .seat-status-text{display:inline-flex;align-items:center;gap:4px;font-size:12px;white-space:nowrap;color:var(--ss-muted)} +.ssv2 .seat-status-text.is-error{color:var(--ss-error);font-weight:500} +.ssv2 .seat-status-text.is-success{color:var(--ss-success);font-weight:500} +.ssv2 .seat-duty{font-size:12px;color:var(--ss-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:2px} +.ssv2 .seat-footer{padding-top:6px;border-top:1px solid var(--ss-border);display:flex;align-items:center;justify-content:space-between;gap:6px;min-width:0} +.ssv2 .seat-task-title{font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.ssv2 .seat-model-tag{font-family:var(--ss-font-mono);font-size:12px;color:var(--ss-muted);max-width:92px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex-shrink:0} + +/* 席位检视器 */ +.ssv2 .inspector-card{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);overflow:hidden} +.ssv2 .inspector-head{padding:14px;border-bottom:1px solid var(--ss-border);display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px} +.ssv2 .inspector-subtabs{display:flex;gap:16px;padding:0 14px;border-bottom:1px solid var(--ss-border);background:var(--ss-subtle)} +.ssv2 .inspector-subtab{padding:8px 0;font-size:12px;font-weight:500;border-bottom:2px solid transparent;color:var(--ss-muted)} +.ssv2 .inspector-subtab.is-active{border-bottom-color:var(--ss-primary);color:var(--ss-primary)} +.ssv2 .inspector-body{padding:14px;display:flex;flex-direction:column;gap:12px;font-size:12px} +.ssv2 .kv-grid-2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px} +.ssv2 .kv-box{border-radius:8px;background:var(--ss-subtle);border:1px solid var(--ss-border);padding:10px} +.ssv2 .wb-card{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);padding:14px;display:flex;flex-direction:column;gap:10px;font-size:12px} +.ssv2 .wb-empty-box{border-radius:12px;border:1px dashed var(--ss-border);padding:24px 16px;text-align:center;font-size:12px;color:var(--ss-muted)} +.ssv2 .wb-textarea{width:100%;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-bg);color:var(--ss-fg);padding:8px 10px;font-size:12px;resize:vertical} +.ssv2 .wb-input{width:100%;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-bg);color:var(--ss-fg);padding:7px 10px;font-size:12px} +.ssv2 .wb-alert{border-radius:8px;border:1px solid color-mix(in srgb,var(--ss-error) 32%,var(--ss-border));background:color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card));padding:10px;color:var(--ss-error);display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;font-size:12px} + +/* 流转 / 议政 / 共识 / 配置 */ +.ssv2 .flow-seg{display:inline-flex;flex-wrap:wrap;align-items:center;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);padding:2px;font-size:12px} +.ssv2 .flow-seg-btn{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:6px;color:var(--ss-muted)} +.ssv2 .flow-seg-btn.is-active{background:var(--ss-primary);color:var(--ss-primary-fg);font-weight:500} +.ssv2 .stage-stepper{display:flex;align-items:center;gap:4px;overflow-x:auto;padding:4px 0} +.ssv2 .stage-step-pill{padding:2px 8px;border-radius:999px;font-size:12px;border:1px solid var(--ss-border);background:var(--ss-subtle);color:var(--ss-muted);white-space:nowrap} +.ssv2 .stage-step-pill.is-done{background:color-mix(in srgb,var(--ss-success) 7%,var(--ss-card));border-color:color-mix(in srgb,var(--ss-success) 30%,var(--ss-border));color:var(--ss-success)} +.ssv2 .stage-step-pill.is-cur{background:var(--ss-primary);border-color:var(--ss-primary);color:var(--ss-primary-fg);font-weight:500} + +.ssv2 .queue-table{width:100%;text-align:left;border-collapse:collapse;font-size:12px} +.ssv2 .queue-table th{padding:10px 10px;font-weight:500;color:var(--ss-muted);background:var(--ss-subtle);border-bottom:1px solid var(--ss-border);white-space:nowrap} +.ssv2 .queue-table td{padding:10px 10px;border-bottom:1px solid var(--ss-border);vertical-align:top} +.ssv2 .queue-table tr.is-click{cursor:pointer} +.ssv2 .queue-table tr.is-click:hover td{background:var(--ss-hover)} + +.ssv2 .consensus-grid{display:grid;grid-template-columns:1fr;gap:12px} +@container wb (min-width: 620px){.ssv2 .consensus-grid{grid-template-columns:repeat(2,minmax(0,1fr))}} + +.ssv2 .speech-bubble{border-radius:12px;border:1px solid var(--ss-border);padding:10px 12px;font-size:12px;line-height:1.6;color:var(--ss-fg);background:color-mix(in srgb,var(--ss-fg) 3%,var(--ss-card));white-space:pre-wrap;overflow-wrap:anywhere} +.ssv2 .speech-chart-1{border-left:2.5px solid var(--ss-chart-1)} +.ssv2 .speech-chart-2{border-left:2.5px solid var(--ss-chart-2)} +.ssv2 .speech-chart-3{border-left:2.5px solid var(--ss-chart-3)} + +.ssv2 .cfg-seat-info{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1 1 auto} +@container wb (min-width: 720px){.ssv2 .cfg-seat-info{display:grid;grid-template-columns:minmax(170px,1fr) minmax(220px,1.15fr);align-items:center;gap:12px}} +.ssv2 .cfg-row{border-bottom:1px solid var(--ss-border)} +.ssv2 .cfg-row:last-child{border-bottom:0} +.ssv2 .cfg-row.is-open{background:color-mix(in srgb,var(--ss-primary) 5%,var(--ss-card))} +.ssv2 .cfg-row-head{display:flex;align-items:center;gap:8px;font-size:12px} +.ssv2 .cfg-row-toggle{flex:1 1 auto;min-width:0;text-align:left;display:flex;align-items:center;gap:10px;padding:10px 4px 10px 14px} +.ssv2 .cfg-inline-panel{padding:12px 14px;border-top:1px solid var(--ss-border);background:var(--ss-subtle);display:flex;flex-direction:column;gap:10px;font-size:12px} + +/* Narrow sidebar breakpoints (580px standard -> <=640px, 400px floor -> <=480px) */ +@container wb (max-width: 520px){.ssv2 .col-dur,.ssv2 .col-time{display:none}} +@container wb (max-width: 640px){ + .ssv2 .wb-header{padding-left:14px;padding-right:14px} + .ssv2 .wb-body{padding:12px} + .ssv2 .frameless-zone{padding:10px;border-radius:12px} + .ssv2 .frameless-zone-list{gap:8px} + .ssv2 .frameless-item{padding:10px 12px;gap:8px;border-radius:10px} + .ssv2 .frameless-code{padding:7px 10px} + .ssv2 .hide-narrow{display:none !important} +} +@container wb (max-width: 480px){ + .ssv2 .sansheng-grid{gap:7px} + .ssv2 .liubu-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px} + .ssv2 .wb-header{padding-left:10px;padding-right:10px} + .ssv2 .wb-body{padding:8px} + .ssv2 .wb-tab-btn{padding-left:8px;padding-right:8px} + .ssv2 .frameless-zone{padding:8px;border-radius:11px} + .ssv2 .frameless-zone-list{gap:7px} + .ssv2 .frameless-item{padding:9px 10px;gap:7px;border-radius:9px} + .ssv2 .frameless-code{padding:6px 9px} + .ssv2 .seat-card.is-sansheng .seat-head{flex-direction:column;align-items:flex-start;gap:4px} + .ssv2 .seat-card.is-sansheng .seat-duty,.ssv2 .seat-card.is-sansheng .seat-footer,.ssv2 .seat-card.is-liubu .seat-footer{display:none !important} +} + +/* ============================================================================ + 2. 主工作台跨项目看板总台 (.ssmwb) + ============================================================================ */ +.ssmwb{height:100%;min-height:0;width:100%;min-width:0;display:flex;flex-direction:column;overflow:hidden;background:var(--ss-canvas);container-type:inline-size;container-name:mwb} +.ssmwb .mwb-header{flex:none;position:relative;z-index:40;background:var(--ss-card);border-bottom:1px solid var(--ss-border);padding:10px 16px} +.ssmwb .mwb-header-row{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;flex-wrap:nowrap} +.ssmwb .mwb-header-left{display:flex;align-items:center;gap:8px;min-width:0;flex-wrap:nowrap} +.ssmwb .mwb-header-right{display:flex;align-items:center;gap:6px;margin-left:auto;flex-shrink:0;flex-wrap:nowrap} +.ssmwb .mwb-brand-box{display:flex;align-items:center;gap:8px;flex-shrink:0} +.ssmwb .mwb-brand-seal{width:28px;height:28px;border-radius:8px;background:var(--ss-fg);color:var(--ss-bg);display:flex;align-items:center;justify-content:center;font-family:var(--ss-font-seal);font-weight:700;font-size:12px;line-height:1} +.ssmwb .mwb-brand-title{margin:0;font-family:var(--ss-font-seal);font-size:16px;font-weight:700;line-height:1} +.ssmwb .mwb-brand-sep{color:var(--ss-border);flex-shrink:0} + +.ssmwb .mwb-proj-wrap{position:relative;min-width:0} +.ssmwb .mwb-proj-trigger{display:inline-flex;align-items:center;gap:8px;padding:6px 10px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);font-size:12px;max-width:100%;transition:border-color 140ms ease} +.ssmwb .mwb-proj-trigger:hover,.ssmwb .mwb-proj-trigger.is-open{border-color:var(--ss-primary)} +.ssmwb .mwb-proj-trigger.is-open{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary)} +.ssmwb .mwb-proj-popover{position:absolute;top:calc(100% + 6px);left:0;z-index:45;width:276px;max-width:90vw;border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);box-shadow:0 12px 32px -8px color-mix(in srgb,var(--ss-fg) 20%,transparent);overflow:hidden;padding:6px;display:flex;flex-direction:column;gap:2px} +.ssmwb .mwb-proj-opt{width:100%;text-align:left;padding:8px 10px;border-radius:8px;display:flex;flex-direction:column;gap:2px;font-size:12px;transition:background-color 120ms ease} +.ssmwb .mwb-proj-opt:hover{background:var(--ss-hover)} +.ssmwb .mwb-proj-opt.is-selected{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary)} + +.ssmwb .mwb-view-switch{display:inline-flex;align-items:center;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-subtle);padding:2px;font-size:12px;flex-shrink:0} +.ssmwb .mwb-view-btn{padding:4px 10px;border-radius:6px;color:var(--ss-muted);transition:background-color 120ms ease,color 120ms ease;white-space:nowrap} +.ssmwb .mwb-view-btn.is-active{background:var(--ss-card);color:var(--ss-fg);font-weight:500;box-shadow:0 1px 2px rgba(0,0,0,.08)} + +.ssmwb .mwb-search-inline{display:flex;align-items:center;gap:6px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-bg);padding:5px 10px;width:200px;max-width:100%} +.ssmwb .mwb-search-input{width:100%;border:0;background:transparent;font-size:12px;outline:none;color:var(--ss-fg)} +.ssmwb .mwb-search-icon-btn{display:none;align-items:center;justify-content:center;padding:6px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);color:var(--ss-muted);flex-shrink:0} +.ssmwb .mwb-search-icon-btn:hover,.ssmwb .mwb-search-icon-btn.is-active{border-color:var(--ss-primary)} +.ssmwb .mwb-search-icon-btn.is-active{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary)} +.ssmwb .mwb-narrow-search-bar{margin-top:8px;padding-top:8px;border-top:1px solid var(--ss-border);display:flex;align-items:center;gap:8px;font-size:12px} +.ssmwb .mwb-narrow-search-input-wrap{flex:1 1 auto;min-width:0;display:flex;align-items:center;gap:6px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-bg);padding:6px 10px} +.ssmwb .mwb-narrow-cancel{padding:6px 10px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-subtle);color:var(--ss-muted);flex-shrink:0} +.ssmwb .mwb-narrow-cancel:hover{color:var(--ss-fg)} + +.ssmwb .mwb-nav-btn{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:8px;border:1px solid var(--ss-border);background:var(--ss-card);font-size:12px;flex-shrink:0;white-space:nowrap;transition:border-color 140ms ease} +.ssmwb .mwb-nav-btn:hover{border-color:var(--ss-primary)} +.ssmwb .mwb-nav-btn.is-active{border-color:var(--ss-primary);background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary);font-weight:500} +.ssmwb .mwb-nav-btn.is-pending{border-color:color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border));background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card));color:var(--ss-primary);font-weight:500} + +.ssmwb .mwb-main{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;overflow:hidden} +.ssmwb .mwb-workspace{flex:1 1 auto;min-height:0;display:flex;position:relative;overflow:hidden} +.ssmwb .mwb-board-stage{flex:1 1 0%;min-width:0;height:100%;overflow:hidden} + +.ssmwb .mwb-kanban-board{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:minmax(0,100%);gap:12px;align-items:start;height:100%;overflow:hidden;padding:14px 16px 18px} +.ssmwb .mwb-kanban-board.is-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))} +.ssmwb .mwb-kanban-col{min-width:0;max-height:100%;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-col);overflow:hidden} +.ssmwb .mwb-kanban-col-head{flex:none;padding:10px 12px;border-bottom:1px solid var(--ss-border)} +.ssmwb .mwb-kanban-col-list{flex:1 1 auto;min-height:0;overflow-y:auto;padding:8px;display:flex;flex-direction:column;gap:8px} +.ssmwb .mwb-kanban-card{width:100%;text-align:left;background:var(--ss-card);border:1px solid var(--ss-border);border-radius:10px;padding:12px;display:flex;flex-direction:column;gap:8px;cursor:pointer;transition:border-color 140ms ease,box-shadow 140ms ease} +.ssmwb .mwb-kanban-card:hover{border-color:color-mix(in srgb,var(--ss-primary) 45%,var(--ss-border));box-shadow:0 4px 12px -6px color-mix(in srgb,var(--ss-fg) 14%,transparent)} +.ssmwb .mwb-kanban-card.is-selected{border-color:var(--ss-primary);box-shadow:0 0 0 1px var(--ss-primary),0 4px 14px -6px color-mix(in srgb,var(--ss-primary) 26%,transparent)} +.ssmwb .mwb-kanban-card.is-blocked{border-color:color-mix(in srgb,var(--ss-error) 55%,var(--ss-border));box-shadow:inset 3px 0 0 0 var(--ss-error)} +.ssmwb .mwb-kanban-card.is-blocked:hover{border-color:var(--ss-error)} +.ssmwb .mwb-card-ticker{border-radius:8px;padding:6px 10px;font-size:12px;line-height:1.45;background:var(--ss-subtle);color:var(--ss-muted)} +.ssmwb .mwb-card-ticker.is-blocked{background:color-mix(in srgb,var(--ss-error) 6.5%,var(--ss-card));color:var(--ss-error);font-weight:500} +.ssmwb .mwb-card-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:4px 8px;padding-top:2px;font-size:12px;color:var(--ss-muted)} +.ssmwb .mwb-progress-track{width:24px;height:6px;border-radius:999px;background:var(--ss-border);overflow:hidden;display:inline-block} +.ssmwb .mwb-progress-fill{display:block;height:100%;background:var(--ss-primary)} + +.ssmwb .mwb-list-wrap{height:100%;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px} +.ssmwb .mwb-list-section{border-radius:12px;border:1px solid var(--ss-border);background:var(--ss-card);overflow:hidden} +.ssmwb .mwb-list-head{padding:8px 14px;border-bottom:1px solid var(--ss-border);background:var(--ss-subtle);display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px} +.ssmwb .mwb-list-row{width:100%;text-align:left;padding:10px 14px;display:flex;flex-direction:column;gap:6px;font-size:12px;border-bottom:1px solid var(--ss-border);transition:background-color 120ms ease} +.ssmwb .mwb-list-row:last-child{border-bottom:0} +.ssmwb .mwb-list-row:hover{background:var(--ss-hover)} +.ssmwb .mwb-list-row.is-selected{background:color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card))} +.ssmwb .mwb-list-row.is-blocked{border-left:3px solid var(--ss-error)} + +.ssmwb .mwb-pending-dock{width:344px;flex:0 0 344px;min-height:0;display:flex;flex-direction:column;padding:14px 14px 16px 0} +.ssmwb .mwb-split-drawer{position:absolute;top:0;right:0;bottom:0;z-index:35;width:400px;max-width:100%;border-left:1px solid var(--ss-border);background:var(--ss-card);display:flex;flex-direction:column;min-height:0;box-shadow:-10px 0 28px -10px color-mix(in srgb,var(--ss-fg) 18%,transparent)} +.ssmwb .mwb-drawer-head{flex:none;padding:12px 16px;border-bottom:1px solid var(--ss-border);display:flex;flex-direction:column;gap:8px} +.ssmwb .mwb-drawer-tabs{flex:none;display:flex;gap:16px;padding:0 16px;border-bottom:1px solid var(--ss-border);background:var(--ss-subtle);font-size:12px} +.ssmwb .mwb-drawer-tab{padding:8px 0;font-weight:500;border-bottom:2px solid transparent;color:var(--ss-muted)} +.ssmwb .mwb-drawer-tab.is-active{border-bottom-color:var(--ss-primary);color:var(--ss-primary)} +.ssmwb .mwb-drawer-body{flex:1 1 auto;min-height:0;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px;font-size:12px} + +.ssmwb .mwb-gcfg-group{border-radius:16px;background:var(--ss-subtle);padding:6px;display:flex;flex-direction:column;gap:4px} +.ssmwb .mwb-gcfg-item{border-radius:12px;background:var(--ss-card);border:1px solid transparent;transition:border-color 140ms ease} +.ssmwb .mwb-gcfg-item.is-open{border-color:color-mix(in srgb,var(--ss-primary) 34%,var(--ss-border));box-shadow:0 1px 4px rgba(0,0,0,.06)} +.ssmwb .mwb-gcfg-toggle{width:100%;text-align:left;padding:10px 12px;border-radius:12px;display:flex;align-items:center;justify-content:space-between;gap:8px} +.ssmwb .mwb-gcfg-toggle:hover{background:var(--ss-hover)} +.ssmwb .mwb-gcfg-body{padding:8px 12px 12px;border-top:1px solid var(--ss-border);display:flex;flex-direction:column;gap:10px} + +@container mwb (max-width: 1160px){ + .ssmwb .mwb-pending-dock{width:312px;flex-basis:312px} +} +@container mwb (max-width: 760px){ + .ssmwb .mwb-search-inline{display:none !important} + .ssmwb .mwb-search-icon-btn{display:inline-flex !important} +} +@container mwb (max-width: 580px){ + .ssmwb .mwb-header{padding:8px 10px} + .ssmwb .mwb-list-wrap{padding:10px;gap:10px} + .ssmwb .mwb-hide-compact{display:none !important} + .ssmwb .frameless-zone{padding:9px;border-radius:12px} + .ssmwb .frameless-item{padding:10px 11px;gap:7px;border-radius:10px} + .ssmwb .frameless-code{padding:6px 9px} +} +@container mwb (max-width: 480px){ + .ssmwb .mwb-hide-xs{display:none !important} +} +` diff --git a/sansheng/src/client/workbench-v2.js b/sansheng/src/client/workbench-v2.js index a110064..95e111c 100644 --- a/sansheng/src/client/workbench-v2.js +++ b/sansheng/src/client/workbench-v2.js @@ -1,229 +1,120 @@ -// 三省六部 Web 工作台 v2:按用户提供的静态设计稿落地的真实前端。 -// 只使用 createElement(无 JSX);数据全部来自现有 host API,不伪造示例数据。 +// Better Sidebar / 右侧栏单项目工作台(.ssv2):仅使用 createElement,严格绑定当前会话所属项目,数据全走 /api/sansheng。 import { createElement as h, useCallback, useEffect, useMemo, useRef, useState } from 'react' import { SEAT_IDS, SEATS } from '../shared/roles.js' import { buildWorkbenchView, - findModelOption, - updateDraft, clearDraft, describeModel, + draftOf, + findModelOption, + UNCHOSEN_MODEL_LABEL, + updateDraft, } from './workbench.js' +import { groupModelChoices, modelPartsOf, modelObjectFromParts, shortModelName } from './master-model.js' import { request } from './transport.js' -const TODAY = () => { - const d = new Date() - d.setHours(0, 0, 0, 0) - return d.getTime() +const SANSHENG_ORDER = ['zhongshu', 'menxia', 'shangshu'] +const LIUBU_ORDER = ['libu', 'hubu', 'lipu', 'bingbu', 'xingbu', 'gongbu'] +const DELIB_SEATS = ['zhongshu', 'menxia', 'shangshu'] +const AVATAR_MIME = ['image/png', 'image/jpeg', 'image/webp'] +const AVATAR_MAX_BYTES = 120 * 1024 + +const TASK_META = { + draft: { label: '待派发', tone: 'muted' }, + dispatched: { label: '已派发', tone: 'primary' }, + running: { label: '进行中', tone: 'primary' }, + prepared: { label: '待复核', tone: 'warning' }, + done: { label: '已完成', tone: 'success' }, + cancelled: { label: '已取消', tone: 'muted' }, + failed: { label: '失败', tone: 'error' }, + waiting_user: { label: '待批准', tone: 'warning' }, + returned: { label: '已退回', tone: 'error' }, + reconfirm: { label: '待重确认', tone: 'error' }, } -const TASK_LABELS = { - draft: '待派发', - dispatched: '已派发', - running: '进行中', - prepared: '待复核', - done: '已完成', - cancelled: '已取消', - failed: '失败', - waiting_user: '待用户批准', - returned: '已退回', - reconfirm: '待重新确认', -} -const TASK_TONES = { - draft: 'idle', - dispatched: 'review', - running: 'run', - prepared: 'review', - done: 'done', - cancelled: 'idle', - failed: 'fail', - waiting_user: 'review', - returned: 'fail', - reconfirm: 'fail', -} -const OPEN_STATUS = new Set(['dispatched', 'running', 'prepared']) -const REQ_STATUS_LABELS = { - discussing: '商讨中', - ready: '待下派', - published: '已下派', - returned: '已退回', - cancelled: '已取消', +const REQ_STATUS_META = { + discussing: { label: '商讨中', tone: 'primary' }, + ready: { label: '待下派', tone: 'warning' }, + published: { label: '已下派', tone: 'success' }, + returned: { label: '已退回', tone: 'error' }, + cancelled: { label: '已取消', tone: 'muted' }, } + const REQ_JUDGEMENT_LABELS = { can_do: '可立项', needs_discussion: '需商讨', not_now: '暂不可做', } -const WORKFLOW_STAGE_LABELS = { - zhongshu_draft: '中书拟案', - menxia_review: '门下审核', - awaiting_execution_approval: '待用户批准', - shangshu_dispatch: '尚书调度', - department_exec: '六部执行', - menxia_acceptance: '门下验收', - lead_delivery: '丞相交付', - delivered: '已交付', - reconfirm: '待重新确认', -} -function toneOfSeat(seat) { - if (!seat) return 'idle' - if (seat.runtimeState === 'running') return 'run' - if (seat.runtimeState === 'idle' || seat.runtimeState === 'unknown') return 'idle' - if (seat.status === 'failed' || seat.status === 'missing') return 'fail' - if (seat.status === 'creating') return 'run' - return 'idle' +const WORKFLOW_STAGES = [ + { id: 'zhongshu_draft', label: '中书拟案' }, + { id: 'menxia_review', label: '门下审核' }, + { id: 'awaiting_execution_approval', label: '待批准' }, + { id: 'shangshu_dispatch', label: '尚书调度' }, + { id: 'department_exec', label: '六部执行' }, + { id: 'menxia_acceptance', label: '门下验收' }, + { id: 'delivered', label: '已交付' }, +] + +function smallSvg(paths, size = 14) { + return h('svg', { + viewBox: '0 0 24 24', + width: size, + height: size, + fill: 'none', + stroke: 'currentColor', + strokeWidth: 1.8, + strokeLinecap: 'round', + strokeLinejoin: 'round', + 'aria-hidden': 'true', + }, paths.map((d, idx) => h('path', { key: idx, d }))) } -function seatStateText(seat) { - if (!seat) return '待命' - if (seat.approvalState === 'waiting') return '等待审批' - if (seat.runtimeLabel) return seat.runtimeLabel - if (seat.status === 'bound') return '待命' - if (seat.status === 'creating') return '开启中' - if (seat.status === 'missing') return '会话缺失' - if (seat.status === 'failed') return '创建失败' - return '待命' -} -function taskTone(status) { return TASK_TONES[status] || 'idle' } -function taskLabel(status) { return TASK_LABELS[status] || status || '未知' } -function refreshList(value, previous, projectChanged = false) { - if (Array.isArray(value)) return value - return projectChanged ? [] : previous -} -const DELIVERY_LABELS = { pending: '待发送', sending: '发送中', unknown: '结果未知', accepted: '已接收' } -function deliveryLabel(state) { return DELIVERY_LABELS[state] || '' } +const RefreshIcon = () => smallSvg(['M21 12a9 9 0 1 1-2.64-6.36', 'M21 3v6h-6'], 13) +const ChatIcon = () => smallSvg(['M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'], 13) +const PlusIcon = () => smallSvg(['M12 5v14', 'M5 12h14'], 13) +const SearchIcon = () => h('svg', { + viewBox: '0 0 24 24', width: 14, height: 14, fill: 'none', stroke: 'currentColor', + strokeWidth: 2, strokeLinecap: 'round', 'aria-hidden': 'true', +}, h('circle', { cx: 11, cy: 11, r: 8 }), h('path', { d: 'm21 21-4.3-4.3' })) +const ChevronDown = (open) => h('svg', { + viewBox: '0 0 24 24', width: 14, height: 14, fill: 'none', stroke: 'currentColor', + strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': 'true', + style: { transform: open ? 'rotate(180deg)' : 'none', transition: 'transform 150ms ease' }, +}, h('path', { d: 'm6 9 6 6 6-6' })) function pad2(n) { return String(n).padStart(2, '0') } -function clockText(ts) { - const n = Number(ts) - if (!Number.isFinite(n) || n <= 0) return '—' - const d = new Date(n) - return pad2(d.getHours()) + ':' + pad2(d.getMinutes()) -} function dateText(ts) { const n = Number(ts) if (!Number.isFinite(n) || n <= 0) return '—' const d = new Date(n) - return (d.getMonth() + 1) + '-' + pad2(d.getDate()) + ' ' + clockText(n) + return (d.getMonth() + 1) + '-' + pad2(d.getDate()) + ' ' + pad2(d.getHours()) + ':' + pad2(d.getMinutes()) } function durationText(ms) { const n = Number(ms) if (!Number.isFinite(n) || n <= 0) return '—' - const total = Math.round(n / 1000) - const sec = total % 60 - const min = Math.floor(total / 60) % 60 - const hour = Math.floor(total / 3600) - if (hour > 0) return hour + 'h ' + min + 'm' - if (min > 0) return min + 'm ' + pad2(sec) + 's' - return sec + 's' -} -function dateLabel() { - try { - return new Intl.DateTimeFormat('zh-CN', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }).format(new Date()) - } catch { return '' } + const s = Math.round(n / 1000) + const m = Math.floor(s / 60) % 60 + const hr = Math.floor(s / 3600) + if (hr > 0) return hr + 'h ' + m + 'm' + if (m > 0) return m + 'm ' + pad2(s % 60) + 's' + return s + 's' } function taskDurationMs(task) { if (!task) return 0 - const start = Number(task.dispatchedAt || task.createdAt || 0) + const st = Number(task.dispatchedAt || task.createdAt || 0) const end = task.resultAt ? Number(task.resultAt) : Date.now() - if (!Number.isFinite(start) || !Number.isFinite(end) || start <= 0 || end <= start) return 0 - return end - start + if (!Number.isFinite(st) || !Number.isFinite(end) || st <= 0 || end <= st) return 0 + return end - st } function shortText(text, max) { - const value = String(text || '').replace(/\s+/g, ' ').trim() - if (!value) return '' - return value.length > max ? value.slice(0, max - 1) + '…' : value + const val = String(text || '').replace(/\s+/g, ' ').trim() + if (!val) return '' + return val.length > max ? val.slice(0, max - 1) + '…' : val } -function splitResultText(text) { - const clean = String(text || '').replace(/\r/g, '').trim() - if (!clean) return { summary: '', points: [], hasMore: false } - const lines = clean.split('\n').map(line => line.trim()).filter(Boolean) - const first = lines[0] || '' - let summary = first.replace(/^#{1,6}\s*/, '') - let rest = lines.slice(1) - if (/[。!?!?]/.test(first)) { - const sentences = first.split(/(?<=[。!?!?])/).map(item => item.trim()).filter(Boolean) - if (sentences.length > 0) { - summary = sentences[0] - rest = [...sentences.slice(1), ...lines.slice(1)] - } - } - if (summary.length > 120) summary = summary.slice(0, 119) + '…' - const bullets = rest - .filter(line => /^([-*•]\s+|\d+[.)、]\s+|[一二三四五六七八九十]+、)/.test(line)) - .map(line => line.replace(/^([-*•]\s+|\d+[.)、]\s+|[一二三四五六七八九十]+、)/, '').trim()) - .filter(Boolean) - const source = bullets.length > 0 - ? bullets - : rest.flatMap(line => line.split(/(?<=[。!?!?])/).map(item => item.trim()).filter(Boolean)) - const points = source.slice(0, 3).map(item => shortText(item, 90)) - const covered = summary.length + points.join('').length - return { summary, points, hasMore: clean.length > covered + 12 } +function refreshList(value, prev, projectChanged = false) { + if (Array.isArray(value)) return value + return projectChanged ? [] : prev } -function renderRichText(text) { - const lines = String(text || '').replace(/\r/g, '').split('\n') - const blocks = [] - let list = [] - let code = null - const flushList = () => { - if (list.length === 0) return - blocks.push(h('ul', { className: 'rs-list', key: 'list-' + blocks.length }, list.map((item, index) => h('li', { key: index }, item)))) - list = [] - } - lines.forEach(line => { - const value = line.trim() - if (value.startsWith('```')) { - flushList() - if (code === null) code = [] - else { blocks.push(h('pre', { className: 'rs-code', key: 'code-' + blocks.length }, h('code', null, code.join('\n')))); code = null } - return - } - if (code !== null) { code.push(line); return } - if (!value) { flushList(); return } - if (/^#{1,6}\s+/.test(value)) { - flushList() - blocks.push(h('h4', { className: 'rs-heading', key: 'h-' + blocks.length }, value.replace(/^#{1,6}\s+/, ''))) - return - } - if (/^([-*•]\s+|\d+[.)、]\s+|[一二三四五六七八九十]+、)/.test(value)) { - list.push(value.replace(/^([-*•]\s+|\d+[.)、]\s+|[一二三四五六七八九十]+、)/, '')) - return - } - flushList() - if (/^(?:[A-Za-z]:[\\/]|\/|\.{0,2}\/|[\w.-]+[\\/])/.test(value) && !/\s{2,}/.test(value) && value.length <= 260) { - blocks.push(h('code', { className: 'rs-path', key: 'p-' + blocks.length }, value)) - } else { - blocks.push(h('p', { className: 'rs-para', key: 'p-' + blocks.length }, value)) - } - }) - flushList() - if (code !== null) blocks.push(h('pre', { className: 'rs-code', key: 'code-' + blocks.length }, h('code', null, code.join('\n')))) - return blocks -} - -function SummaryBlock(props) { - const text = String(props && props.text ? props.text : '').trim() - const label = props && props.label ? props.label : '摘要' - const empty = props && props.empty ? props.empty : '(暂无内容)' - const max = props && props.max ? props.max : 120 - return h('div', { className: 'card-summary' + (text ? '' : ' is-empty') }, - label ? h('span', { className: 't-label' }, label) : null, - h('p', { className: 'card-summary-text' }, text ? shortText(text, max) : empty), - ) -} - -function fileIcon(paths, size) { - return h('svg', { viewBox: '0 0 24 24', width: size || 16, height: size || 16, fill: 'none', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': 'true' }, - paths.map((d, i) => h('path', { key: i, d }))) -} -const RefreshIcon = () => fileIcon(['M21 12a9 9 0 1 1-2.64-6.36', 'M21 3v6h-6']) -const ChatIcon = () => fileIcon(['M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z']) -const PlusIcon = () => fileIcon(['M12 5v14', 'M5 12h14']) -const SearchIcon = () => h('svg', { viewBox: '0 0 24 24', width: 15, height: 15, fill: 'none', stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round', 'aria-hidden': 'true' }, h('circle', { cx: 11, cy: 11, r: 8 }), h('path', { d: 'm21 21-4.3-4.3' })) -const ArrowIcon = () => fileIcon(['m9 18 6-6-6-6'], 15) -const BookIcon = () => fileIcon(['M4 19.5A2.5 2.5 0 0 1 6.5 17H20', 'M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z'], 15) -const SlidersIcon = () => fileIcon(['M4 21v-7', 'M4 10V3', 'M12 21v-9', 'M12 8V3', 'M20 21v-5', 'M20 12V3', 'M2 14h4', 'M10 8h4', 'M18 16h4'], 15) - function seatKind(id) { if (id === 'lead') return '总协调' if (id === 'zhongshu') return '方案' @@ -231,62 +122,80 @@ function seatKind(id) { if (id === 'shangshu') return '调度' return '工作' } -function seatRecordOf(view, id) { - const seats = view && view.project ? view.project.seats : null - if (Array.isArray(seats)) return seats.find(seat => seat && seat.id === id) || null - if (seats && typeof seats === 'object') return seats[id] || null - return null +function seatTone(seat) { + if (!seat) return 'muted' + if (seat.status === 'missing' || seat.status === 'failed' || seat.modelSyncStatus === 'failed') return 'error' + if (seat.approvalState === 'waiting') return 'error' + if (seat.runtimeState === 'running' || seat.status === 'creating') return 'success' + return 'muted' } -function fmtModel(rec, options) { - const model = rec ? (rec.configuredModel ?? rec.model) : null - const described = describeModel(model, options) - return described.modelLabel +function seatStatusText(seat) { + if (!seat) return '待命' + if (seat.status === 'missing') return '会话缺失' + if (seat.status === 'failed') return '创建失败' + if (seat.modelSyncStatus === 'failed') return '同步失败' + if (seat.approvalState === 'waiting') return '等待审批' + if (seat.runtimeLabel) return seat.runtimeLabel + if (seat.status === 'bound') return '待命' + if (seat.status === 'creating') return '开启中' + return '未开启' } - -const DELIB_SEATS = ['zhongshu', 'menxia', 'shangshu'] -const AVATAR_MIME = ['image/png', 'image/jpeg', 'image/webp'] -const AVATAR_MAX_BYTES = 120 * 1024 - -function seatTone(seatId) { - return seatId === 'zhongshu' ? '#4c6ef5' : seatId === 'menxia' ? '#12b886' : seatId === 'shangshu' ? '#e8590c' : '#868e96' +function seatChartVar(seatId) { + return seatId === 'zhongshu' ? '--ss-chart-1' : seatId === 'menxia' ? '--ss-chart-2' : '--ss-chart-3' } - -// 默认头像用席位名的第一个字;自定义字符或缩放后的图片优先。 -function avatarNode(seatId, avatars, size = 34, highlight = false) { +function seatDotTone(seatId) { + return seatId === 'zhongshu' ? 'chart-1' : seatId === 'menxia' ? 'chart-2' : 'chart-3' +} +function avatarNode(seatId, avatars, size = 32, activeRing = false) { const custom = avatars?.[seatId] - const ring = highlight ? { boxShadow: '0 0 0 2px ' + seatTone(seatId), borderRadius: '50%' } : {} - if (custom?.type === 'image') { + const colorVar = seatChartVar(seatId) + const ring = activeRing ? { boxShadow: '0 0 0 2px var(' + colorVar + ')' } : {} + if (custom?.type === 'image' && custom.dataUrl) { return h('img', { - src: custom.dataUrl, alt: (SEATS[seatId]?.name ?? seatId) + '头像', width: size, height: size, + src: custom.dataUrl, + alt: (SEATS[seatId]?.label ?? seatId) + '头像', + width: size, + height: size, style: { width: size, height: size, borderRadius: '50%', objectFit: 'cover', flex: '0 0 auto', ...ring }, }) } - const text = custom?.type === 'char' ? custom.char : (SEATS[seatId]?.name ?? seatId).slice(0, 1) + const ch = custom?.type === 'char' ? custom.char : (SEATS[seatId]?.label ?? seatId).slice(0, 1) return h('span', { 'aria-hidden': 'true', + className: 'font-seal', style: { - width: size, height: size, borderRadius: '50%', background: seatTone(seatId), color: '#fff', - display: 'inline-flex', alignItems: 'center', justifyContent: 'center', flex: '0 0 auto', - fontSize: Math.max(12, Math.round(size * 0.42)), fontWeight: 600, ...ring, + width: size, + height: size, + borderRadius: '50%', + background: 'color-mix(in srgb, var(' + colorVar + ') 14%, var(--ss-card))', + border: '1px solid var(' + colorVar + ')', + color: 'var(' + colorVar + ')', + display: 'inline-flex', + alignItems: 'center', + justifyContent: 'center', + flex: '0 0 auto', + fontSize: Math.max(12, Math.round(size * 0.42)), + fontWeight: 700, + ...ring, }, - }, text) + }, ch) } -// 上传图先缩到 256×256 再入库;循环降质量保证 ≤120KB,绝不上传原图。 async function shrinkAvatar(file) { if (!file || !AVATAR_MIME.includes(file.type)) throw new Error('头像只支持 PNG、JPEG 或 WebP 图片') const bitmap = await createImageBitmap(file) try { const side = 256 const canvas = document.createElement('canvas') - canvas.width = side; canvas.height = side + canvas.width = side + canvas.height = side const ctx2d = canvas.getContext('2d') const scale = Math.max(side / bitmap.width, side / bitmap.height) - const width = Math.max(1, Math.round(bitmap.width * scale)) - const height = Math.max(1, Math.round(bitmap.height * scale)) - ctx2d.drawImage(bitmap, Math.round((side - width) / 2), Math.round((side - height) / 2), width, height) - for (const quality of [0.9, 0.8, 0.7, 0.6, 0.5]) { - const dataUrl = canvas.toDataURL('image/jpeg', quality) + const w = Math.max(1, Math.round(bitmap.width * scale)) + const ht = Math.max(1, Math.round(bitmap.height * scale)) + ctx2d.drawImage(bitmap, Math.round((side - w) / 2), Math.round((side - ht) / 2), w, ht) + for (const q of [0.9, 0.8, 0.7, 0.6, 0.5]) { + const dataUrl = canvas.toDataURL('image/jpeg', q) if (Math.floor((dataUrl.length - dataUrl.indexOf(',') - 1) * 3 / 4) <= AVATAR_MAX_BYTES) return dataUrl } throw new Error('图片压缩后仍超过 120KB,请换一张更简单的图片') @@ -297,7 +206,6 @@ async function shrinkAvatar(file) { export function WorkbenchV2(props) { const { - onClose, sessionId, resolveWorkspace, navigateToSession, @@ -317,40 +225,40 @@ export function WorkbenchV2(props) { const saved = typeof getLastSeatId === 'function' ? getLastSeatId() : null return SEAT_IDS.includes(saved) ? saved : SEAT_IDS[0] }) - const [tab, setTab] = useState('overview') + const [tab, setTab] = useState('court') // court | flow | deliberation | memory | config + const [inspectorTab, setInspectorTab] = useState('overview') // overview | config + const [seatFilter, setSeatFilter] = useState('all') // all | running | attention | pending + const [flowSubTab, setFlowSubTab] = useState('tasks') // tasks | requirements | queue | delivery const [queueSearch, setQueueSearch] = useState('') - const [selectedTask, setSelectedTask] = useState(null) - const [reviewPanelOpen, setReviewPanelOpen] = useState(false) - const [durationPanelOpen, setDurationPanelOpen] = useState(false) - const [tokenPanelOpen, setTokenPanelOpen] = useState(false) - const [queuePanelOpen, setQueuePanelOpen] = useState(false) + const [expandedConfigSeatId, setExpandedConfigSeatId] = useState(null) + const [draft, setDraft] = useState({}) const [busy, setBusy] = useState(false) const [summaryBusy, setSummaryBusy] = useState(false) const [memory, setMemory] = useState(null) + const [memoryEditing, setMemoryEditing] = useState(false) const [memoryDraft, setMemoryDraft] = useState({ goal: '', constraints: '', acceptance: '', decisions: '' }) const [tasks, setTasks] = useState([]) const [requirements, setRequirements] = useState([]) - const [approvals, setApprovals] = useState([]) const [pendingApprovals, setPendingApprovals] = useState([]) const [approvalStatus, setApprovalStatus] = useState(null) + const [deliberations, setDeliberations] = useState([]) const [deliberation, setDeliberation] = useState(null) const [delibSelectedId, setDelibSelectedId] = useState(null) const [delibDraft, setDelibDraft] = useState({ topic: '', taskId: '', requirementId: '', maxRounds: '3' }) - const [delibEndNote, setDelibEndNote] = useState('') - const [delibBusy, setDelibBusy] = useState(false) - const [page, setPage] = useState('overview') const [delibSettingsOpen, setDelibSettingsOpen] = useState(false) + const [delibBusy, setDelibBusy] = useState(false) const [avatarEdit, setAvatarEdit] = useState(null) const [agentRuns, setAgentRuns] = useState([]) - const [reqView, setReqView] = useState('requirements') + const [artifacts, setArtifacts] = useState([]) const [artifactDraft, setArtifactDraft] = useState({ title: '', path: '', summary: '' }) - const [artifactFormOpen, setArtifactFormOpen] = useState(false) - const [orgCols, setOrgCols] = useState(6) + const [artifactModalOpen, setArtifactModalOpen] = useState(false) + const [durationModalOpen, setDurationModalOpen] = useState(false) + const [selectedTask, setSelectedTask] = useState(null) + const alive = useRef(true) - const orgRef = useRef(null) const loadedProjectId = useRef(null) const taskAnswerVersion = useRef(0) @@ -360,99 +268,78 @@ export function WorkbenchV2(props) { }, []) const loadProject = useCallback(async () => { - setPhase('loading'); setError(null); setErrorRetryable(true); setNotice(null) + setPhase('loading') + setError(null) + setErrorRetryable(true) + setNotice(null) if (typeof resolveWorkspace !== 'function') { setPhase('no-workspace'); return } const workspace = resolveWorkspace() if (!workspace) { setPhase('no-workspace'); return } try { const projectView = await request('open', { workspaceId: workspace.workspaceId, name: workspace.name, path: workspace.path }) let modelCatalog = null - try { modelCatalog = await request('models') } catch (modelError) { - console.warn('[sansheng] 模型目录加载失败:', modelError && modelError.message ? modelError.message : modelError) - } + try { modelCatalog = await request('models') } catch { /* 模型目录失败时不阻断打开 */ } let memoryData = null - try { memoryData = (await request('memory', { projectId: projectView.project.id })).memory } catch { /* 项目共识尚未建立 */ } + try { memoryData = (await request('memory', { projectId: projectView.project.id })).memory } catch { /* 共识可选 */ } const nextProjectId = projectView.project.id const answerVersion = taskAnswerVersion.current - const [taskRes, artifactRes, requirementData, approvalData] = await Promise.allSettled([ + const [taskRes, artifactRes, requirementRes, approvalRes, delibRes, agentRes] = await Promise.allSettled([ request('tasks', { projectId: nextProjectId }), request('artifacts', { projectId: nextProjectId }), request('requirements', { projectId: nextProjectId }), request('approvals', { projectId: nextProjectId }), + request('deliberations', { projectId: nextProjectId }), + request('agents', { projectId: nextProjectId }), ]) if (!alive.current) return const projectChanged = loadedProjectId.current !== nextProjectId loadedProjectId.current = nextProjectId - setView(projectView); setModels(modelCatalog); setMemory(memoryData) - setMemoryDraft({ goal: memoryData?.goal ?? '', constraints: (memoryData?.constraints ?? []).join('\n'), acceptance: (memoryData?.acceptance ?? []).join('\n'), decisions: '' }) + setView(projectView) + setModels(modelCatalog) + setMemory(memoryData) + setMemoryDraft({ + goal: memoryData?.goal ?? '', + constraints: (memoryData?.constraints ?? []).join('\n'), + acceptance: (memoryData?.acceptance ?? []).join('\n'), + decisions: '', + }) if (projectChanged) { setSelectedTask(null) setDelibSelectedId(null) setDeliberation(null) - setDeliberations([]) + setMemoryEditing(false) + } + if (projectChanged || taskAnswerVersion.current === answerVersion) { + setTasks(prev => refreshList(taskRes.value?.tasks, prev, projectChanged)) + } + setArtifacts(prev => refreshList(artifactRes.value?.artifacts, prev, projectChanged)) + setRequirements(prev => refreshList(requirementRes.value?.requirements, prev, projectChanged)) + setPendingApprovals(prev => refreshList(approvalRes.value?.approvals, prev, projectChanged)) + setApprovalStatus(approvalRes.status === 'fulfilled' ? approvalRes.value?.status ?? null : { available: false, degraded: true }) + const delibList = delibRes.status === 'fulfilled' && Array.isArray(delibRes.value?.deliberations) ? delibRes.value.deliberations : [] + setDeliberations(delibList) + if (agentRes.status === 'fulfilled' && Array.isArray(agentRes.value?.runs)) setAgentRuns(agentRes.value.runs) + const targetDelibId = delibList.find(x => x.status === 'running')?.id || delibList[0]?.id || null + if (targetDelibId) { + try { + const full = await request('deliberation', { projectId: nextProjectId, deliberationId: targetDelibId }) + if (alive.current && loadedProjectId.current === nextProjectId) setDeliberation(full?.deliberation ?? null) + } catch { /* 单场转写读取失败时不阻断工作台 */ } } - if (projectChanged || taskAnswerVersion.current === answerVersion) setTasks(previous => refreshList(taskRes.value?.tasks, previous, projectChanged)) - setArtifacts(previous => refreshList(artifactRes.value?.artifacts, previous, projectChanged)) - setRequirements(previous => refreshList(requirementData.value?.requirements, previous, projectChanged)) - setApprovals(previous => refreshList(requirementData.value?.approvals, previous, projectChanged)) - setPendingApprovals(previous => refreshList(approvalData.value?.approvals, previous, projectChanged)) - setApprovalStatus(approvalData.status === 'fulfilled' ? approvalData.value?.status ?? null : { available: false, degraded: true }) setPhase('ready') } catch (loadError) { if (!alive.current) return - setError(loadError && loadError.message ? loadError.message : '加载失败') - setErrorRetryable(!(loadError && loadError.retryable === false)); setPhase('error') + setError(loadError?.message || '加载失败') + setErrorRetryable(!(loadError && loadError.retryable === false)) + setPhase('error') } }, [resolveWorkspace]) useEffect(() => { void loadProject() }, [loadProject]) - const projectId = view && view.project ? view.project.id : null + const projectId = view?.project?.id || null - // 派工等操作在聊天里发生,工作台没有事件通道;轮询真实接口让队列/席位状态自动跟上。 - // 页面隐藏时跳过;回到前台立即补一次。绝不把轮询结果写进草稿或配置。 - useEffect(() => { - if (!projectId) return undefined - let disposed = false - let running = false - let timer = null - const tick = async () => { - if (disposed || running) return - if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return - running = true - try { - const answerVersion = taskAnswerVersion.current - const [projectRes, taskRes, artifactRes, requirementData, approvalData] = await Promise.allSettled([ - request('project', { projectId }), - request('tasks', { projectId }), - request('artifacts', { projectId }), - request('requirements', { projectId }), - request('approvals', { projectId }), - ]) - if (disposed || !alive.current || loadedProjectId.current !== projectId) return - if (projectRes.value) setView(projectRes.value) - if (taskAnswerVersion.current === answerVersion) setTasks(previous => refreshList(taskRes.value?.tasks, previous)) - setArtifacts(previous => refreshList(artifactRes.value?.artifacts, previous)) - setRequirements(previous => refreshList(requirementData.value?.requirements, previous)) - setApprovals(previous => refreshList(requirementData.value?.approvals, previous)) - setPendingApprovals(previous => refreshList(approvalData.value?.approvals, previous)) - setApprovalStatus(approvalData.status === 'fulfilled' ? approvalData.value?.status ?? null : { available: false, degraded: true }) - } finally { - running = false - } - } - timer = setInterval(tick, 4000) - const onVisibility = () => { if (document.visibilityState === 'visible') void tick() } - document.addEventListener('visibilitychange', onVisibility) - void tick() - return () => { - disposed = true - if (timer !== null) clearInterval(timer) - document.removeEventListener('visibilitychange', onVisibility) - } - }, [projectId]) - - async function refreshDeliberations() { + const refreshDeliberations = useCallback(async () => { if (!projectId) return const [data, agentsData] = await Promise.allSettled([ request('deliberations', { projectId }), @@ -467,139 +354,60 @@ export function WorkbenchV2(props) { const full = await request('deliberation', { projectId, deliberationId: target }) if (!alive.current || loadedProjectId.current !== projectId) return setDeliberation(full?.deliberation ?? null) - } + }, [projectId, delibSelectedId]) useEffect(() => { - if (page !== 'deliberations' || !projectId) return undefined + if (!projectId) return undefined + let disposed = false + let running = false + const tick = async () => { + if (disposed || running) return + if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return + running = true + try { + const answerVer = taskAnswerVersion.current + const [projectRes, taskRes, artifactRes, requirementRes, approvalRes] = await Promise.allSettled([ + request('project', { projectId }), + request('tasks', { projectId }), + request('artifacts', { projectId }), + request('requirements', { projectId }), + request('approvals', { projectId }), + ]) + if (disposed || !alive.current || loadedProjectId.current !== projectId) return + if (projectRes.value) setView(projectRes.value) + if (taskAnswerVersion.current === answerVer) setTasks(prev => refreshList(taskRes.value?.tasks, prev)) + setArtifacts(prev => refreshList(artifactRes.value?.artifacts, prev)) + setRequirements(prev => refreshList(requirementRes.value?.requirements, prev)) + setPendingApprovals(prev => refreshList(approvalRes.value?.approvals, prev)) + setApprovalStatus(approvalRes.status === 'fulfilled' ? approvalRes.value?.status ?? null : { available: false, degraded: true }) + } finally { + running = false + } + } + const timer = setInterval(() => { void tick() }, 4000) + const onVis = () => { if (document.visibilityState === 'visible') void tick() } + if (typeof document !== 'undefined') document.addEventListener('visibilitychange', onVis) + void tick() + return () => { + disposed = true + clearInterval(timer) + if (typeof document !== 'undefined') document.removeEventListener('visibilitychange', onVis) + } + }, [projectId]) + + useEffect(() => { + if (tab !== 'deliberation' || !projectId) return undefined let disposed = false let running = false - let timer = null const tick = async () => { if (disposed || running) return running = true - try { await refreshDeliberations() } catch (error) { - if (!disposed && alive.current) console.warn('[sansheng] 议政刷新失败:', error?.message ?? error) - } finally { running = false } + try { await refreshDeliberations() } catch { /* 轮询容错 */ } finally { running = false } } - timer = setInterval(tick, 1500) + const timer = setInterval(() => { void tick() }, 1500) void tick() - return () => { disposed = true; if (timer !== null) clearInterval(timer) } - }, [page, projectId, delibSelectedId]) - - async function startDeliberation() { - if (!projectId || delibBusy) return - const topic = String(delibDraft.topic || '').trim() - if (!topic) { setError('请先填写议政议题'); return } - setDelibBusy(true); setError(null) - try { - const maxRounds = delibDraft.maxRounds === '' ? 3 : Number(delibDraft.maxRounds) - const data = await request('deliberationStart', { - projectId, - topic, - taskId: delibDraft.taskId || undefined, - requirementId: delibDraft.requirementId || undefined, - maxRounds, - originSessionId: sessionId || undefined, - }) - if (!alive.current || loadedProjectId.current !== projectId) return - setDelibSelectedId(data.deliberation.id) - setDeliberation(data.deliberation) - setDelibDraft(previous => ({ ...previous, topic: '' })) - setNotice(data.receipt?.text || '议政已发起,已叫中书。') - } catch (error) { - if (alive.current) setError(error && error.message ? error.message : '议政发起失败') - } finally { if (alive.current) setDelibBusy(false) } - } - - async function endDeliberation() { - const deliberationId = delibSelectedId || deliberations.find(item => item.status === 'running')?.id - if (!projectId || !deliberationId || delibBusy) return - setDelibBusy(true); setError(null) - try { - await request('deliberationEnd', { projectId, deliberationId, note: delibEndNote.trim() || undefined }) - if (!alive.current || loadedProjectId.current !== projectId) return - setDelibEndNote('') - setNotice('议政已结束,结论已记录。') - await refreshDeliberations() - } catch (error) { - if (alive.current) setError(error && error.message ? error.message : '结束议政失败') - } finally { if (alive.current) setDelibBusy(false) } - } - - async function stopDeliberation() { - const deliberationId = delibSelectedId || deliberations.find(item => item.status === 'running')?.id - if (!projectId || !deliberationId || delibBusy) return - setDelibBusy(true); setError(null) - try { - const data = await request('deliberationStop', { projectId, deliberationId, note: delibEndNote.trim() || undefined }) - if (!alive.current || loadedProjectId.current !== projectId) return - setDelibEndNote('') - setNotice(data.receipt?.text || '议政已停止。') - setDeliberation(data.deliberation) - await refreshDeliberations() - } catch (error) { - if (alive.current) setError(error && error.message ? error.message : '停止议政失败') - } finally { if (alive.current) setDelibBusy(false) } - } - - async function retryDeliberation() { - const deliberationId = delibSelectedId || deliberations.find(item => item.status === 'running')?.id - if (!projectId || !deliberationId || delibBusy) return - setDelibBusy(true); setError(null) - try { - const data = await request('deliberationRetry', { projectId, deliberationId }) - if (!alive.current || loadedProjectId.current !== projectId) return - setDeliberation(data.deliberation) - setNotice(data.delivery?.ok ? '已重试当前席位。' : '重试没有成功,页面会保留当前状态。') - await refreshDeliberations() - } catch (error) { - if (alive.current) setError(error && error.message ? error.message : '重试议政失败') - } finally { if (alive.current) setDelibBusy(false) } - } - - async function saveAvatar(seatId, payload = {}) { - if (!projectId) return - setDelibBusy(true); setError(null) - try { - const data = payload.clear - ? await request('clearAvatar', { projectId, seatId }) - : await request('setAvatar', { projectId, seatId, ...payload }) - if (!alive.current || loadedProjectId.current !== projectId) return - setView(previous => { - if (!previous?.project) return previous - const avatars = { ...(previous.project.avatars ?? {}) } - if (data.avatar) avatars[seatId] = data.avatar - else delete avatars[seatId] - return { ...previous, project: { ...previous.project, avatars } } - }) - setAvatarEdit(null) - setNotice(data.avatar ? '头像已更新。' : '头像已恢复默认。') - } catch (error) { - if (alive.current) setError(error && error.message ? error.message : '保存头像失败') - } finally { if (alive.current) setDelibBusy(false) } - } - - async function pickAvatarFile(seatId, file) { - try { - const dataUrl = await shrinkAvatar(file) - await saveAvatar(seatId, { dataUrl }) - } catch (error) { - if (alive.current) setError(error && error.message ? error.message : '图片处理失败') - } - } - - async function stopAgentRun(run) { - if (!projectId || delibBusy) return - setDelibBusy(true); setError(null) - try { - await request('agentStop', { projectId, runId: run.id, kind: run.kind }) - if (!alive.current || loadedProjectId.current !== projectId) return - setNotice('已停止「' + (run.label || run.seatId || '后台子 Agent') + '」,不会再产生新动作。') - await refreshDeliberations() - } catch (error) { - if (alive.current) setError(error && error.message ? error.message : '停止失败') - } finally { if (alive.current) setDelibBusy(false) } - } + return () => { disposed = true; clearInterval(timer) } + }, [tab, projectId, refreshDeliberations]) useEffect(() => { if (!projectId || !selectionCache) return @@ -614,184 +422,436 @@ export function WorkbenchV2(props) { return map }, [wb.seats]) - useEffect(() => { - const node = orgRef.current - if (!node || typeof ResizeObserver === 'undefined') return undefined - const sync = () => { - const w = node.clientWidth || 0 - setOrgCols(w <= 700 ? 2 : w <= 1180 ? 3 : 6) + const seatRecMap = useMemo(() => { + const raw = view?.project?.seats + const map = {} + if (Array.isArray(raw)) { + for (const s of raw) if (s?.id) map[s.id] = s + } else if (raw && typeof raw === 'object') { + for (const [k, s] of Object.entries(raw)) map[k] = { id: k, ...s } } - sync() - const observer = new ResizeObserver(sync) - observer.observe(node) - return () => observer.disconnect() - }, [phase, tab]) + return map + }, [view]) - function setSeat(id) { + const activeChatSeatId = useMemo(() => { + if (!sessionId) return null + for (const sid of SEAT_IDS) { + if (seatRecMap[sid]?.sessionId === sessionId) return sid + } + return null + }, [seatRecMap, sessionId]) + + const groupedChoices = useMemo(() => groupModelChoices(wb.selected.modelOptions), [wb.selected.modelOptions]) + + function selectSeat(id) { if (!id || id === selectedSeatId) return setSelectedSeatId(id) if (typeof setLastSeatId === 'function') setLastSeatId(id) if (projectId && selectionCache) selectionCache.set(projectId, id) } - function setModelValue(value) { - setDraft(prev => updateDraft(prev, selectedSeatId, { modelValue: value })) - void rememberModel(value, selectedSeatId) - } - function setInstructions(value) { - setDraft(prev => updateDraft(prev, selectedSeatId, { instructions: value })) + function seatDraftState(seatId) { + const seatRec = seatRecMap[seatId] || {} + const dEntry = draftOf(draft, seatId) + let modelValue = '' + if (Object.prototype.hasOwnProperty.call(dEntry, 'modelValue')) { + modelValue = String(dEntry.modelValue || '') + } else if (Object.prototype.hasOwnProperty.call(dEntry, 'model')) { + modelValue = describeModel(dEntry.model, wb.selected.modelOptions).modelValue + } else { + modelValue = describeModel(seatRec.model ?? null, wb.selected.modelOptions).modelValue + } + const parts = modelValue.split('::') + const modelKey = parts[0] && parts[1] ? (parts[0] + '::' + parts[1]) : '' + const effort = parts[2] || '' + const instructions = Object.prototype.hasOwnProperty.call(dEntry, 'instructions') + ? dEntry.instructions + : (typeof seatRec.instructions === 'string' ? seatRec.instructions : '') + return { modelKey, effort, modelValue, instructions } } - function modelFromValue(value) { - const option = findModelOption(wb.selected.modelOptions, value) - if (option) { - return option.reasoningEffort - ? { provider: option.provider, model: option.model, reasoningEffort: option.reasoningEffort } - : { provider: option.provider, model: option.model } - } - const parts = String(value || '').split('::') - if (parts.length >= 2 && parts[0] && parts[1]) { - return parts[2] - ? { provider: parts[0], model: parts[1], reasoningEffort: parts[2] } - : { provider: parts[0], model: parts[1] } - } - return null + function updateSeatDraftModel(seatId, nextKey, nextEffort) { + const val = nextKey ? (nextEffort ? nextKey + '::' + nextEffort : nextKey) : '' + setDraft(prev => updateDraft(prev, seatId, { modelValue: val })) } - async function rememberModel(value, seatId) { - if (!projectId || !value || !seatId) return - const model = modelFromValue(value) - if (!model) return + async function saveSeatConfigFor(seatId) { + if (!projectId) return + const { modelKey, effort, instructions } = seatDraftState(seatId) + const model = modelObjectFromParts(modelKey, effort) + if (!model) { setNotice('请先为当前角色选择模型'); return } + setBusy(true) + setError(null) + setNotice('保存中…') try { - const saved = await request('configure', { projectId, seatId, model }) + await request('configure', { projectId, seatId, model, instructions }) + const next = await request('project', { projectId }) if (!alive.current) return - setView(prev => { - if (!prev || !prev.project) return prev - const seats = Array.isArray(prev.project.seats) - ? prev.project.seats.map(seat => (seat && seat.id === seatId ? { ...seat, ...(saved && saved.seat ? saved.seat : { model }) } : seat)) - : prev.project.seats - return { ...prev, revision: (prev.revision ?? 0) + 1, project: { ...prev.project, seats } } - }) - setNotice('已记住「' + (SEATS[seatId]?.label ?? seatId) + '」的模型') - } catch (error) { - if (alive.current) setNotice(error && error.message ? error.message : '模型记忆失败') + setView(next) + setDraft(prev => clearDraft(prev, seatId)) + setNotice('已保存「' + (SEATS[seatId]?.label || seatId) + '」配置') + } catch (err) { + if (alive.current) setError(err?.message || '保存失败') + } finally { + if (alive.current) setBusy(false) + } + } + + async function setGlobalDefaultFor(seatId) { + if (!projectId) return + const { modelKey, effort } = seatDraftState(seatId) + const configured = seatRecMap[seatId]?.configuredModel ?? seatRecMap[seatId]?.model ?? null + const model = modelObjectFromParts(modelKey, effort) || configured + if (!model) { setNotice('请先为当前角色选择模型'); return } + setBusy(true) + setError(null) + try { + const res = await request('setGlobalDefault', { seatId, model }) + const next = await request('project', { projectId }) + if (!alive.current) return + setView(next) + setNotice('已将「' + (SEATS[seatId]?.label || seatId) + '」设为全局默认;已同步 ' + ((res.applied || []).length) + ' 个项目') + } catch (err) { + if (alive.current) setError(err?.message || '设置全局默认失败') + } finally { + if (alive.current) setBusy(false) + } + } + + async function clearOverrideFor(seatId) { + if (!projectId) return + setBusy(true) + setError(null) + try { + await request('configure', { projectId, seatId, model: null }) + const next = await request('project', { projectId }) + if (!alive.current) return + setView(next) + setDraft(prev => clearDraft(prev, seatId)) + setNotice('「' + (SEATS[seatId]?.label || seatId) + '」已恢复继承全局默认') + } catch (err) { + if (alive.current) setError(err?.message || '恢复继承失败') + } finally { + if (alive.current) setBusy(false) + } + } + + async function retrySyncFor(seatId) { + if (!projectId) return + setBusy(true) + setError(null) + try { + const res = await request('retrySeatModel', { projectId, seatId }) + const next = await request('project', { projectId }) + if (!alive.current) return + setView(next) + setNotice('模型同步状态:' + (res.sync?.status ?? 'unknown')) + } catch (err) { + if (alive.current) setError(err?.message || '重试同步失败') + } finally { + if (alive.current) setBusy(false) } } async function openSeat(seatId) { const seat = seatById[seatId] if (!projectId || !seat) return - if (seat.status === 'missing') { setNotice('「' + seat.name + '」的会话已不存在,点「重建会话」可重新建立'); return } - if (seat.status !== 'bound') { setNotice('「' + seat.name + '」还没开启,先点「开启『' + seat.name + '』」'); return } - setBusy(true); setError(null) + if (seat.status === 'missing') { setNotice('「' + seat.name + '」的会话已缺失,点击「重建会话」可恢复'); return } + if (seat.status !== 'bound') { setNotice('「' + seat.name + '」尚未开启,请先点击开启'); return } + setBusy(true) + setError(null) try { - const result = await request('openSeat', { projectId, seatId }) + const res = await request('openSeat', { projectId, seatId }) if (!alive.current) return - if (!result || !result.sessionId) throw new Error('宿主没有返回会话') - navigateToSession(result.sessionId) - setNotice('已切换到「' + seat.name + '」会话') - } catch (openError) { - if (alive.current) setError(openError && openError.message ? openError.message : '打开会话失败') - if (openError && openError.code === 'sansheng/session-missing') { - try { const next = await request('project', { projectId }); if (alive.current) setView(next) } catch { /* 保留当前视图 */ } + if (!res?.sessionId) throw new Error('宿主没有返回会话') + navigateToSession?.(res.sessionId) + setNotice('已切换到「' + seat.name + '」原生会话') + } catch (err) { + if (alive.current) setError(err?.message || '打开会话失败') + if (err?.code === 'sansheng/session-missing') { + try { const next = await request('project', { projectId }); if (alive.current) setView(next) } catch { /* 忽略 */ } } - } finally { if (alive.current) setBusy(false) } - } - - async function rebuildSeat(seatId) { - const seat = seatById[seatId] - if (!projectId || !seat) return - const rec = seatRecordOf(view, seatId) - setBusy(true); setError(null); setNotice('正在重建「' + seat.name + '」的会话…') - try { - const next = await request('rebuildSeat', { projectId, seatId, expectedSessionId: rec && rec.sessionId ? rec.sessionId : undefined }) - if (!alive.current) return - setView(next); setNotice('已重建「' + seat.name + '」的会话;旧会话历史仍保留') - } catch (rebuildError) { - if (alive.current) setError(rebuildError && rebuildError.message ? rebuildError.message : '重建会话失败') - if (rebuildError && rebuildError.code === 'sansheng/session-conflict') { - try { const next = await request('project', { projectId }); if (alive.current) setView(next) } catch { /* 保留当前视图 */ } - } - } finally { if (alive.current) setBusy(false) } + } finally { + if (alive.current) setBusy(false) + } } async function enableSeat(seatId) { if (!projectId) return const seat = seatById[seatId] - setBusy(true); setError(null); setNotice('正在开启「' + (seat ? seat.name : seatId) + '」…') + setBusy(true) + setError(null) + setNotice('正在开启「' + (seat?.name || seatId) + '」…') try { const next = await request('enableSeat', { projectId, seatId }) if (!alive.current) return - setView(next); setNotice('已开启「' + (seat ? seat.name : seatId) + '」的独立会话') - try { if (typeof openRightTab === 'function') openRightTab() } catch { /* 打开失败不影响开启 */ } - } catch (enableError) { - if (alive.current) setError(enableError && enableError.message ? enableError.message : '开启失败') - } finally { if (alive.current) setBusy(false) } + setView(next) + setNotice('已按需开启「' + (seat?.name || seatId) + '」独立会话') + try { if (typeof openRightTab === 'function') openRightTab() } catch { /* 忽略 */ } + } catch (err) { + if (alive.current) setError(err?.message || '开启失败') + } finally { + if (alive.current) setBusy(false) + } } - async function saveConfig() { - if (!projectId) return - const seatId = wb.selected.id - const value = wb.selected.modelValue - if (!value) { setNotice('请先为当前角色选择模型'); return } - const model = modelFromValue(value) - setBusy(true); setError(null); setNotice('保存中…') + async function rebuildSeat(seatId) { + const seat = seatById[seatId] + if (!projectId || !seat) return + const rec = seatRecMap[seatId] + setBusy(true) + setError(null) + setNotice('正在重建「' + seat.name + '」会话…') try { - await request('configure', { projectId, seatId, model, instructions: wb.selected.instructions }) - const next = await request('project', { projectId }) + const next = await request('rebuildSeat', { + projectId, + seatId, + expectedSessionId: rec?.sessionId || undefined, + }) if (!alive.current) return - setView(next); setDraft(prev => clearDraft(prev, seatId)); setNotice('已保存') - } catch (saveError) { - if (alive.current) setError(saveError && saveError.message ? saveError.message : '保存失败') - } finally { if (alive.current) setBusy(false) } + setView(next) + setNotice('已重建「' + seat.name + '」会话(旧历史保留)') + } catch (err) { + if (alive.current) setError(err?.message || '重建失败') + } finally { + if (alive.current) setBusy(false) + } } - async function setGlobalDefaultForSeat() { - if (!projectId) return - const seatId = wb.selected.id - const model = modelFromValue(wb.selected.modelValue) - if (!model) { setNotice('请先为当前角色选择模型'); return } - if (typeof window !== 'undefined' && typeof window.confirm === 'function' && !window.confirm('把「' + wb.selected.name + '」当前模型设为全局默认?其他未覆盖的项目会继承。')) return - setBusy(true); setError(null) + async function answerApproval(entry, choice) { + if (!projectId || !entry || busy) return + setBusy(true) + setError(null) try { - const result = await request('setGlobalDefault', { seatId, model }) - const next = await request('project', { projectId }) - if (!alive.current) return - setView(next); setNotice('已设为全局默认;继承项目已同步 ' + ((result.applied || []).length) + ' 个') - } catch (error) { if (alive.current) setError(error && error.message ? error.message : '设置全局默认失败') } - finally { if (alive.current) setBusy(false) } + await request('approvalAnswer', { + projectId, + seatId: entry.seatId, + id: entry.id, + sessionId: entry.sessionId, + choice, + }) + const data = await request('approvals', { projectId }) + if (!alive.current || loadedProjectId.current !== projectId) return + setPendingApprovals(prev => refreshList(data?.approvals, prev)) + setApprovalStatus(data?.status ?? null) + setNotice(choice === 'allow' ? '已允许审批' : '已拒绝审批') + } catch (err) { + if (alive.current) setError(err?.message || '审批应答失败') + } finally { + if (alive.current) setBusy(false) + } } - async function clearSeatOverride() { - if (!projectId) return - const seatId = wb.selected.id - setBusy(true); setError(null) + async function answerDecision(taskId, decisionId, value) { + if (!projectId || busy) return + setBusy(true) + setError(null) try { - await request('configure', { projectId, seatId, model: null }) - const next = await request('project', { projectId }) - if (!alive.current) return - setView(next); setDraft(prev => clearDraft(prev, seatId)); setNotice('已恢复继承全局默认') - } catch (error) { if (alive.current) setError(error && error.message ? error.message : '恢复继承失败') } - finally { if (alive.current) setBusy(false) } + await request('taskDecisionAnswer', { projectId, taskId, decisionId, value }) + if (!alive.current || loadedProjectId.current !== projectId) return + taskAnswerVersion.current += 1 + setTasks(prev => prev.map(t => t.id === taskId && Array.isArray(t.decisions) + ? { ...t, decisions: t.decisions.map(d => d.id === decisionId ? { ...d, status: 'answered', answer: value } : d) } + : t)) + setNotice('已提交项目决定') + } catch (err) { + if (alive.current && loadedProjectId.current === projectId) setError(err?.message || '项目决定提交失败') + } finally { + if (alive.current) setBusy(false) + } } - async function retryModelSync() { - if (!projectId) return - setBusy(true); setError(null) + async function redispatchTask(task) { + if (!projectId || !task?.deliveryId || busy) return + setBusy(true) + setError(null) try { - const result = await request('retrySeatModel', { projectId, seatId: wb.selected.id }) - const next = await request('project', { projectId }) + const res = await request('taskRedispatch', { + projectId, + taskId: task.id, + expectedDeliveryId: task.deliveryId, + }) + const nextTasks = await request('tasks', { projectId }) + if (!alive.current || loadedProjectId.current !== projectId) return + setTasks(prev => refreshList(nextTasks?.tasks, prev)) + const updated = nextTasks?.tasks?.find(x => x.id === task.id) + if (updated) setSelectedTask(updated) + setNotice(res?.delivery?.status === 'sent' ? '已显式重投此任务并送达席位会话' : '重投状态:' + (res?.delivery?.reason || res?.delivery?.status || '已处理')) + } catch (err) { + if (alive.current) setError(err?.message || '显式重投失败') + } finally { + if (alive.current) setBusy(false) + } + } + + async function summarizeByShangshu() { + if (!projectId || summaryBusy || busy) return + setSummaryBusy(true) + setError(null) + try { + const res = await request('shangshuSummary', { projectId }) if (!alive.current) return - setView(next); setNotice('模型同步:' + (result.sync?.status ?? 'unknown')) - } catch (error) { if (alive.current) setError(error && error.message ? error.message : '重试同步失败') } - finally { if (alive.current) setBusy(false) } + if (!res?.sessionId) throw new Error('宿主未返回尚书会话') + setNotice('已请尚书汇总当前项目进度,正在前往尚书会话') + navigateToSession?.(res.sessionId) + } catch (err) { + if (alive.current) setError(err?.message || '尚书汇总请求失败') + } finally { + if (alive.current) setSummaryBusy(false) + } + } + + async function reloadTasks() { + if (!projectId) return + try { + const res = await request('tasks', { projectId }) + if (alive.current && loadedProjectId.current === projectId) { + setTasks(prev => refreshList(res?.tasks, prev)) + setNotice('已同步最新派工队列') + } + } catch (err) { + if (alive.current) setNotice(err?.message || '刷新失败') + } + } + + async function startDeliberation() { + if (!projectId || delibBusy) return + const topic = String(delibDraft.topic || '').trim() + if (!topic) { setError('请先填写议政议题'); return } + setDelibBusy(true) + setError(null) + try { + const maxRounds = delibDraft.maxRounds === '' ? 3 : Number(delibDraft.maxRounds) + const data = await request('deliberationStart', { + projectId, + topic, + taskId: delibDraft.taskId || undefined, + requirementId: delibDraft.requirementId || undefined, + maxRounds, + originSessionId: sessionId || undefined, + }) + if (!alive.current || loadedProjectId.current !== projectId) return + setDelibSelectedId(data.deliberation.id) + setDeliberation(data.deliberation) + setDelibDraft(prev => ({ ...prev, topic: '' })) + setNotice(data.receipt?.text || '议政已发起,已叫中书。') + await refreshDeliberations() + } catch (err) { + if (alive.current) setError(err?.message || '发起议政失败') + } finally { + if (alive.current) setDelibBusy(false) + } + } + + async function endDeliberation() { + const did = delibSelectedId || deliberations.find(item => item.status === 'running')?.id + if (!projectId || !did || delibBusy) return + setDelibBusy(true) + setError(null) + try { + await request('deliberationEnd', { projectId, deliberationId: did }) + if (!alive.current) return + setNotice('议政已收束结论') + await refreshDeliberations() + } catch (err) { + if (alive.current) setError(err?.message || '收束议政失败') + } finally { + if (alive.current) setDelibBusy(false) + } + } + + async function stopDeliberation() { + const did = delibSelectedId || deliberations.find(item => item.status === 'running')?.id + if (!projectId || !did || delibBusy) return + setDelibBusy(true) + setError(null) + try { + const data = await request('deliberationStop', { projectId, deliberationId: did }) + if (!alive.current) return + setDeliberation(data.deliberation) + setNotice(data.receipt?.text || '已停止当前议政') + await refreshDeliberations() + } catch (err) { + if (alive.current) setError(err?.message || '停止议政失败') + } finally { + if (alive.current) setDelibBusy(false) + } + } + + async function retryDeliberation() { + const did = delibSelectedId || deliberations.find(item => item.status === 'running')?.id + if (!projectId || !did || delibBusy) return + setDelibBusy(true) + setError(null) + try { + const data = await request('deliberationRetry', { projectId, deliberationId: did }) + if (!alive.current) return + setDeliberation(data.deliberation) + setNotice(data.delivery?.ok ? '已重试当前席位' : '重试未能送达,请查看席位会话') + await refreshDeliberations() + } catch (err) { + if (alive.current) setError(err?.message || '重试席位失败') + } finally { + if (alive.current) setDelibBusy(false) + } + } + + async function saveAvatar(seatId, payload = {}) { + if (!projectId) return + setDelibBusy(true) + setError(null) + try { + const data = payload.clear + ? await request('clearAvatar', { projectId, seatId }) + : await request('setAvatar', { projectId, seatId, ...payload }) + if (!alive.current || loadedProjectId.current !== projectId) return + setView(prev => { + if (!prev?.project) return prev + const avatars = { ...(prev.project.avatars ?? {}) } + if (data.avatar) avatars[seatId] = data.avatar + else delete avatars[seatId] + return { ...prev, project: { ...prev.project, avatars } } + }) + setAvatarEdit(null) + setNotice(data.avatar ? '头像已更新' : '已恢复默认头像') + } catch (err) { + if (alive.current) setError(err?.message || '头像更新失败') + } finally { + if (alive.current) setDelibBusy(false) + } + } + + async function pickAvatarFile(seatId, file) { + try { + const dataUrl = await shrinkAvatar(file) + await saveAvatar(seatId, { dataUrl }) + } catch (err) { + if (alive.current) setError(err?.message || '图片处理失败') + } + } + + async function stopAgentRun(run) { + if (!projectId || delibBusy) return + setDelibBusy(true) + setError(null) + try { + await request('agentStop', { projectId, runId: run.id, kind: run.kind }) + if (!alive.current) return + setNotice('已停止后台子 Agent「' + (run.label || run.seatId) + '」') + await refreshDeliberations() + } catch (err) { + if (alive.current) setError(err?.message || '停止失败') + } finally { + if (alive.current) setDelibBusy(false) + } } async function saveMemory() { - if (!projectId) return - setBusy(true); setError(null); setNotice('保存项目共识…') + if (!projectId || busy) return + setBusy(true) + setError(null) try { - const result = await request('memoryUpdate', { + const res = await request('memoryUpdate', { projectId, expectedRevision: memory?.revision ?? 0, goal: memoryDraft.goal, @@ -801,1040 +861,1167 @@ export function WorkbenchV2(props) { sources: [], }) if (!alive.current) return - setMemory(result.memory) + setMemory(res.memory) + setMemoryEditing(false) setMemoryDraft(prev => ({ ...prev, decisions: '' })) - setNotice('项目共识已保存(v' + result.memory.revision + ')') - } catch (memoryError) { - if (alive.current) setError(memoryError && memoryError.message ? memoryError.message : '保存项目共识失败') - } finally { if (alive.current) setBusy(false) } - } - - async function reloadTasks() { - if (!projectId) return - const answerVersion = taskAnswerVersion.current - try { - const result = await request('tasks', { projectId }) - if (alive.current && loadedProjectId.current === projectId && taskAnswerVersion.current === answerVersion) { - setTasks(previous => refreshList(result?.tasks, previous)) - } - } catch (error) { - if (alive.current && loadedProjectId.current === projectId) setNotice(error && error.message ? error.message : '任务列表刷新失败') + setNotice('项目共识已保存为 v' + res.memory.revision) + } catch (err) { + if (alive.current) setError(err?.message || '保存项目共识失败') + } finally { + if (alive.current) setBusy(false) } } - async function summarizeByShangshu() { - if (!projectId) return - setSummaryBusy(true); setError(null) - try { - const result = await request('shangshuSummary', { projectId }) - if (!alive.current) return - if (!result || !result.sessionId) throw new Error('宿主没有返回尚书会话') - setNotice('已请尚书汇总当前任务,正在打开尚书会话…') - navigateToSession(result.sessionId) - } catch (summaryError) { - if (alive.current) setError(summaryError && summaryError.message ? summaryError.message : '尚书汇总请求失败') - } finally { if (alive.current) setSummaryBusy(false) } - } - async function addArtifact() { - if (!projectId) return + if (!projectId || busy) return const title = artifactDraft.title.trim() if (!title) { setNotice('成果名称不能为空'); return } - setBusy(true); setError(null) + setBusy(true) + setError(null) try { - const result = await request('artifactAdd', { projectId, title, path: artifactDraft.path, summary: artifactDraft.summary }) - setArtifacts(list => [...list, result.artifact]); setArtifactDraft({ title: '', path: '', summary: '' }); setArtifactFormOpen(false); setNotice('成果已登记。') - } catch (error) { - if (alive.current) setError(error && error.message ? error.message : '登记成果失败') - } finally { if (alive.current) setBusy(false) } + const res = await request('artifactAdd', { + projectId, + title, + path: artifactDraft.path.trim(), + summary: artifactDraft.summary.trim(), + }) + if (!alive.current) return + setArtifacts(list => [...list, res.artifact]) + setArtifactDraft({ title: '', path: '', summary: '' }) + setArtifactModalOpen(false) + setNotice('成果已登记') + } catch (err) { + if (alive.current) setError(err?.message || '登记成果失败') + } finally { + if (alive.current) setBusy(false) + } } - const todayStart = TODAY() - const todayTasks = tasks.filter(task => Number(task.createdAt) >= todayStart) - const todayDone = todayTasks.filter(task => task.status === 'done') - const reviewTasks = tasks.filter(task => task.ownerSeatId === 'menxia' && OPEN_STATUS.has(task.status)) - const anomalyTasks = tasks.filter(task => task.workflowBlockage || task.status === 'failed') - const projectDurationMs = tasks.reduce((sum, task) => sum + taskDurationMs(task), 0) + // ---- 派生计数 ---- + const degraded = Boolean(approvalStatus?.degraded) + const toolApprovals = degraded ? [] : pendingApprovals + const decisions = useMemo(() => tasks.flatMap(task => (task.decisions || []) + .filter(d => d.status === 'pending') + .map(decision => ({ task, decision }))), [tasks]) + const pendingCount = toolApprovals.length + decisions.length + const openTasksCount = tasks.filter(t => ['running', 'prepared', 'dispatched', 'failed', 'waiting_user', 'reconfirm'].includes(t.status)).length + const reviewCount = tasks.filter(t => t.ownerSeatId === 'menxia' && ['running', 'prepared', 'dispatched'].includes(t.status)).length + const anomalyCount = tasks.filter(t => t.workflowBlockage || t.status === 'failed' || t.deliveryState === 'unknown').length + + wb.seats.filter(s => s.status === 'missing' || s.modelSyncStatus === 'failed').length + const activeDelib = deliberations.find(d => d.status === 'running') || null + const syncIssues = wb.seats.filter(s => s.modelSyncStatus === 'failed' || s.status === 'missing').length + const projectDurationMs = tasks.reduce((sum, t) => sum + taskDurationMs(t), 0) + const runningSeatsCount = wb.seats.filter(s => s.runtimeState === 'running').length function latestTaskOf(seatId) { - return tasks.filter(task => task.ownerSeatId === seatId).sort((a, b) => Number(b.updatedAt || b.createdAt || 0) - Number(a.updatedAt || a.createdAt || 0))[0] || null + return tasks + .filter(t => t.ownerSeatId === seatId && t.status !== 'cancelled') + .sort((a, b) => Number(b.updatedAt || b.createdAt || 0) - Number(a.updatedAt || a.createdAt || 0))[0] || null } - function tasksOf(seatId) { - return tasks.filter(task => task.ownerSeatId === seatId).sort((a, b) => Number(b.updatedAt || b.createdAt || 0) - Number(a.updatedAt || a.createdAt || 0)) - } - function selectedSeatRecord(id) { return seatRecordOf(view, id) } - function modelLabelOf(id) { return fmtModel(selectedSeatRecord(id), wb.selected.modelOptions) } - const statusBanner = error - ? h('p', { className: 'ssv-banner is-error', role: 'alert' }, error) - : (notice ? h('p', { className: 'ssv-banner is-notice', role: 'status' }, notice) : null) - - function renderTopbar(title, extra) { - const shortcuts = [ - ...(tab === 'overview' - ? [ - h('button', { type: 'button', key: 'memory', className: 'icon-btn', title: '记忆', 'aria-label': '记忆', onClick: () => setTab('memory') }, h(BookIcon)), - h('button', { type: 'button', key: 'settings', className: 'icon-btn', title: '设置', 'aria-label': '设置', onClick: () => setTab('settings') }, h(SlidersIcon)), - ] - : []), - ] - return h('header', { className: 'topbar' }, - h('div', { className: 'topbar-title' }, - h('h1', null, title), - tab === 'overview' ? h('span', { className: 'date' }, dateLabel()) : null, - h('div', { className: 'topbar-icons' }, shortcuts), + function renderPendingZone() { + if (pendingCount === 0 && !degraded) return null + return h('section', { className: 'frameless-zone', 'aria-label': '待你处理' }, + h('div', { className: 'frameless-zone-head' }, + h('div', { className: 'frameless-zone-title-wrap' }, + h('span', { className: 'ss-dot is-primary is-pulse' }), + h('h2', { className: 'frameless-zone-title' }, '待你处理'), + pendingCount > 0 ? h('span', { className: 'frameless-zone-count' }, String(pendingCount)) : null, + ), + h('span', { className: 'frameless-zone-sub' }, '原生审批与决定同步'), + ), + degraded ? h('div', { className: 'frameless-code', style: { color: 'var(--ss-error)' } }, + '工作台暂时无法获取工具审批队列,请在席位原生会话中使用审批卡。' + (approvalStatus?.reason ? '(' + approvalStatus.reason + ')' : '')) : null, + h('div', { className: 'frameless-zone-list' }, + toolApprovals.map(a => h('article', { className: 'frameless-item', key: 'apr:' + a.sessionId + ':' + a.id }, + h('div', { className: 'frameless-item-head' }, + h('div', { className: 'frameless-item-meta' }, + h('span', { className: 'frameless-chip is-err' }, h('span', { className: 'ss-dot is-error' }), '工具审批'), + h('span', { className: 'font-seal', style: { fontWeight: 700, fontSize: 13 } }, SEATS[a.seatId]?.label || a.seatId), + a.tool ? h('span', { className: 'font-mono-num', style: { fontSize: 12, color: 'var(--ss-muted)' } }, a.tool) : null, + ), + h('button', { type: 'button', className: 'frameless-link', disabled: busy, onClick: () => void openSeat(a.seatId) }, '查看会话 →'), + ), + h('div', { className: 'frameless-code' }, a.reason || a.detail?.text || '等待工具授权'), + h('div', { className: 'frameless-btn-group' }, + h('button', { type: 'button', className: 'frameless-btn', disabled: busy, onClick: () => void answerApproval(a, 'reject') }, '拒绝'), + h('button', { type: 'button', className: 'frameless-primary-btn', disabled: busy, onClick: () => void answerApproval(a, 'allow') }, '允许一次'), + ), + )), + decisions.map(({ task, decision }) => h('article', { className: 'frameless-item', key: 'dec:' + task.id + ':' + decision.id }, + h('div', { className: 'frameless-item-head' }, + h('div', { className: 'frameless-item-meta' }, + h('span', { className: 'frameless-chip is-pri' }, h('span', { className: 'ss-dot is-primary' }), '项目决定'), + h('span', { className: 'truncate', style: { fontSize: 12, fontWeight: 500 } }, task.title), + ), + h('button', { type: 'button', className: 'frameless-link font-mono-num', onClick: () => setSelectedTask(task) }, task.id), + ), + h('p', { style: { margin: 0, fontSize: 12, lineHeight: 1.55 } }, decision.question), + h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 6 }, role: 'group', 'aria-label': decision.question }, + (decision.options || []).map(opt => h('button', { + key: opt.value, + type: 'button', + className: 'frameless-btn', + disabled: busy, + onClick: () => void answerDecision(task.id, decision.id, opt.value), + }, opt.label)), + ), + )), ), - h('span', { className: 'spacer' }), - ...(extra || []), ) } - function renderSeatNode(seat) { - const tone = toneOfSeat(seat) - const latest = latestTaskOf(seat.id) - return h('div', { key: seat.id, className: 'node' + (seat.id === selectedSeatId ? ' selected' : ''), 'data-seat': seat.id }, - h('button', { type: 'button', className: 'node-main', onClick: () => setSeat(seat.id), 'aria-pressed': seat.id === selectedSeatId ? 'true' : 'false' }, - h('span', { className: 'node-top' }, h('span', { className: 'node-name' }, seat.name), h('span', { className: 'status ' + tone }, h('i'), seatStateText(seat))), - h('span', { className: 'node-role' }, seat.duty), - h('span', { className: 'node-task' }, h('span', { className: 't-label' }, '当前任务'), h('span', { className: 'task-text' }, latest ? latest.title : '—')), - h('span', { className: 'node-model' }, '主任模型 ', h('span', { className: 'num' }, modelLabelOf(seat.id))), + function renderModelControlsForSeat(seatId, onSaveCallback) { + const rec = seatRecMap[seatId] || {} + const { modelKey, effort, instructions } = seatDraftState(seatId) + const choiceObj = groupedChoices.find(c => c.value === modelKey) || null + const extraChoices = modelKey && !choiceObj + ? [{ value: modelKey, label: (rec.model?.model || modelKey) + '(目录未列出)', efforts: effort ? [effort] : [] }, ...groupedChoices] + : groupedChoices + const efforts = choiceObj?.efforts || [] + const configured = rec.configuredModel ?? rec.model ?? null + const sourceLabel = wb.seats.find(s => s.id === seatId)?.modelSourceLabel || '未选择' + const syncStatus = rec.modelSync?.status || null + + return h('div', { style: { display: 'flex', flexDirection: 'column', gap: 10 } }, + h('div', { className: 'kv-grid-2' }, + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4, fontSize: 12 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '主任模型'), + h('select', { + className: 'wb-select', + value: modelKey, + onChange: (e) => { + const nextKey = e.target.value + const nextChoice = groupedChoices.find(c => c.value === nextKey) + const nextEffort = nextChoice?.efforts?.includes(effort) ? effort : (nextChoice?.efforts?.[0] || '') + updateSeatDraftModel(seatId, nextKey, nextEffort) + }, + }, + h('option', { value: '' }, UNCHOSEN_MODEL_LABEL), + extraChoices.map(opt => h('option', { key: opt.value, value: opt.value }, opt.label)), + ), + ), + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4, fontSize: 12 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '推理等级'), + h('select', { + className: 'wb-select', + value: effort, + disabled: efforts.length === 0, + onChange: (e) => updateSeatDraftModel(seatId, modelKey, e.target.value), + }, + h('option', { value: '' }, efforts.length === 0 ? '默认(固定)' : '默认'), + efforts.map(ef => h('option', { key: ef, value: ef }, ef)), + ), + ), + ), + h('div', { className: 'kv-box', style: { display: 'flex', flexDirection: 'column', gap: 4, fontSize: 12 } }, + h('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 8 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '配置来源'), + h('span', { className: 'ss-pill' + (rec.modelSource === 'project' ? ' is-primary' : '') }, sourceLabel), + ), + h('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 8 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '当前会话模型'), + h('span', { className: 'font-mono-num' }, rec.sessionModel ? (rec.sessionModel.provider + '/' + rec.sessionModel.model) : (configured ? shortModelName(configured) : '未绑定会话')), + ), + h('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 8 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '同步状态'), + h('span', { style: { color: syncStatus === 'failed' ? 'var(--ss-error)' : syncStatus === 'synced' ? 'var(--ss-success)' : 'var(--ss-muted)' } }, + syncStatus === 'synced' ? '已同步' : syncStatus === 'failed' ? ('同步失败' + (rec.modelSync?.error ? ' · ' + rec.modelSync.error : '')) : '待开启或待同步'), + ), + ), + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4, fontSize: 12 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '角色补充说明(仅对本席生效)'), + h('textarea', { + rows: 3, + className: 'wb-textarea', + value: instructions, + placeholder: '追加给该席位的项目级补充约束…', + onChange: (e) => setDraft(prev => updateDraft(prev, seatId, { instructions: e.target.value })), + }), + ), + h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 8 } }, + h('button', { type: 'button', className: 'wb-btn-primary', disabled: busy, onClick: () => void onSaveCallback(seatId) }, busy ? '保存中…' : '保存配置'), + configured ? h('button', { type: 'button', className: 'wb-btn-outline', disabled: busy, onClick: () => void setGlobalDefaultFor(seatId) }, '设为全局默认') : null, + rec.modelSource === 'project' ? h('button', { type: 'button', className: 'wb-btn-outline', disabled: busy, onClick: () => void clearOverrideFor(seatId) }, '恢复继承') : null, + (syncStatus === 'failed' || syncStatus === 'unresolved') ? h('button', { type: 'button', className: 'wb-btn-outline', disabled: busy, onClick: () => void retrySyncFor(seatId) }, '重试同步') : null, ), - h('div', { className: 'node-foot' }, h('span', { className: 'elapsed' }, latest ? taskLabel(latest.status) : (seat.status === 'bound' ? '在线 · 待命' : '未运行 · 待命'))), ) } - function reqTone(status) { - if (status === 'ready' || status === 'published') return 'review' - if (status === 'returned') return 'fail' - if (status === 'cancelled') return 'idle' - return 'run' - } + function renderCourtTab() { + const lead = seatById.lead + const leadTone = seatTone(lead) + const leadSelected = selectedSeatId === 'lead' + const leadLatest = latestTaskOf('lead') - function copyRequirementText(text) { - try { - if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') { - void navigator.clipboard.writeText(text).then(() => setNotice('已复制:' + text)).catch(() => {}) - } - } catch { /* 剪贴板不可用时保留可手动选择文本 */ } - } + const filterMatch = (seat) => { + if (seatFilter === 'running') return seat.runtimeState === 'running' + if (seatFilter === 'attention') return seat.status === 'missing' || seat.status === 'failed' || seat.modelSyncStatus === 'failed' || seat.approvalState === 'waiting' + if (seatFilter === 'pending') return seat.status === 'pending' + return true + } - function renderRequirementGate(selected) { - const views = [ - { id: 'requirements', label: '需求清单' }, - { id: 'flow', label: '流转任务' }, - { id: 'delivery', label: '交付结果' }, + const renderSeatCard = (seatId, tier) => { + const seat = seatById[seatId] + const tone = seatTone(seat) + const selected = selectedSeatId === seatId + const isLive = activeChatSeatId === seatId + const dimmed = !filterMatch(seat) + const latest = latestTaskOf(seatId) + const modelShort = shortModelName(seatRecMap[seatId]?.configuredModel ?? seatRecMap[seatId]?.model ?? null) + return h('button', { + key: seatId, + type: 'button', + 'aria-pressed': selected, + className: 'seat-card' + (tier === 'sansheng' ? ' is-sansheng' : ' is-liubu') + (selected ? ' is-selected' : '') + (dimmed ? ' is-dimmed' : ''), + onClick: () => selectSeat(seatId), + }, + h('div', null, + h('div', { className: 'seat-head' }, + h('span', { className: 'seat-title-wrap' }, + h('span', { className: 'seat-name' }, seat.name), + isLive ? h('span', { className: 'seat-live-tag' }, '对话中') : null, + ), + h('span', { className: 'seat-status-text' + (tone === 'error' ? ' is-error' : tone === 'success' ? ' is-success' : '') }, + h('span', { className: 'ss-dot is-' + tone + (tone === 'success' ? ' is-pulse' : '') }), + seatStatusText(seat), + ), + ), + h('div', { className: 'seat-duty' }, seat.duty), + ), + h('div', { className: 'seat-footer' }, + h('span', { className: 'seat-task-title', style: { color: latest ? 'var(--ss-fg)' : 'var(--ss-muted)' } }, + latest ? latest.title : (seat.status === 'bound' ? '空闲待命' : '点击按需开启')), + h('span', { className: 'seat-model-tag hide-narrow' }, modelShort === '未选模型' ? '—' : modelShort), + ), + ) + } + + const sel = wb.selected + const selSeat = seatById[sel.id] + const selTone = seatTone(selSeat) + const selTasks = tasks.filter(t => t.ownerSeatId === sel.id && t.status !== 'cancelled') + .sort((a, b) => Number(b.updatedAt || b.createdAt || 0) - Number(a.updatedAt || a.createdAt || 0)) + const todayCutoff = new Date().setHours(0, 0, 0, 0) + const selToday = selTasks.filter(t => Number(t.createdAt) >= todayCutoff) + const selTodayDone = selToday.filter(t => t.status === 'done') + const selLatest = selTasks[0] || null + const actionLabel = sel.status === 'bound' ? '开始对话' : sel.status === 'missing' ? '重建会话' : ('开启「' + sel.name + '」') + const actionHandler = sel.status === 'bound' ? () => void openSeat(sel.id) : sel.status === 'missing' ? () => void rebuildSeat(sel.id) : () => void enableSeat(sel.id) + + return [ + h('section', { key: 'telemetry', className: 'telemetry-strip', 'aria-label': '项目运行摘要' }, + h('div', { className: 'telemetry-group' }, + h('span', { className: 'telemetry-item' }, + h('span', { className: 'ss-dot ' + (runningSeatsCount > 0 ? 'is-success is-pulse' : 'is-muted') }), + h('strong', { className: 'font-mono-num' }, wb.project.boundCount + '/10'), + h('span', { style: { color: 'var(--ss-muted)' } }, '在册'), + ), + h('button', { type: 'button', onClick: () => { setTab('flow'); setFlowSubTab('tasks') } }, + h('strong', { className: 'font-mono-num', style: { color: reviewCount > 0 ? 'var(--ss-primary)' : 'inherit' } }, String(reviewCount)), + ' ', + h('span', { style: { color: 'var(--ss-muted)' } }, '待复核'), + ), + h('button', { type: 'button', onClick: () => { setTab('flow'); setFlowSubTab('queue'); setQueueSearch('失败') } }, + h('strong', { className: 'font-mono-num', style: { color: anomalyCount > 0 ? 'var(--ss-error)' : 'inherit' } }, String(anomalyCount)), + ' ', + h('span', { style: { color: 'var(--ss-muted)' } }, '异常'), + ), + ), + h('button', { type: 'button', className: 'font-mono-num', style: { color: 'var(--ss-muted)' }, onClick: () => setDurationModalOpen(true) }, + projectDurationMs > 0 ? durationText(projectDurationMs) : '—'), + ), + renderPendingZone(), + h('div', { key: 'split', className: 'court-split' }, + h('section', { style: { display: 'flex', flexDirection: 'column', gap: 12 }, 'aria-label': '十席谱系' }, + h('div', { className: 'court-head' }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } }, + h('h2', { className: 'court-title' }, '十席谱系'), + h('span', { style: { fontSize: 12, color: 'var(--ss-muted)' } }, '点击席位查看详情'), + ), + h('div', { className: 'seg-group' }, + [ + { id: 'all', label: '全部' }, + { id: 'running', label: '运行中' }, + { id: 'attention', label: '需关注' }, + { id: 'pending', label: '未开启' }, + ].map(f => h('button', { + key: f.id, + type: 'button', + className: 'seg-btn' + (seatFilter === f.id ? ' is-active' : ''), + onClick: () => setSeatFilter(f.id), + }, f.label)), + ), + ), + h('div', { className: 'lead-card' + (leadSelected ? ' is-selected' : '') }, + h('button', { type: 'button', className: 'lead-select-btn', onClick: () => selectSeat('lead') }, + h('span', { className: 'lead-seal' }, '相'), + h('div', { style: { minWidth: 0, flex: '1 1 auto' } }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } }, + h('span', { className: 'font-seal', style: { fontWeight: 700, fontSize: 15, color: leadSelected ? 'var(--ss-primary)' : 'var(--ss-fg)' } }, '丞相'), + h('span', { className: 'ss-pill is-' + leadTone }, + h('span', { className: 'ss-dot is-' + leadTone + (leadTone === 'success' ? ' is-pulse' : '') }), + seatStatusText(lead), + ), + h('span', { className: 'hide-narrow', style: { fontSize: 12, color: 'var(--ss-muted)' } }, '总协调 · 需求入口'), + ), + h('p', { className: 'truncate', style: { margin: '2px 0 0', fontSize: 12, color: 'var(--ss-muted)' } }, + leadLatest ? (leadLatest.result || leadLatest.title) : SEATS.lead.duty), + ), + ), + h('button', { + type: 'button', + className: 'wb-btn-outline', + disabled: busy || lead.status === 'creating', + onClick: () => (lead.status === 'bound' ? void openSeat('lead') : void enableSeat('lead')), + }, lead.status === 'bound' ? '进入对话' : '开启丞相'), + ), + h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6 } }, + h('div', { className: 'tier-divider' }, h('strong', null, '三省'), h('span', null, '中书拟案 → 门下审核 → 尚书调度'), h('span', { className: 'tier-line' })), + h('div', { className: 'sansheng-grid' }, SANSHENG_ORDER.map(id => renderSeatCard(id, 'sansheng'))), + ), + h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6 } }, + h('div', { className: 'tier-divider' }, h('strong', null, '六部'), h('span', null, '尚书统筹 · 同级并行交付'), h('span', { className: 'tier-line' })), + h('div', { className: 'liubu-grid' }, LIUBU_ORDER.map(id => renderSeatCard(id, 'liubu'))), + ), + ), + h('aside', { className: 'inspector-card', 'aria-label': '席位检视面板' }, + h('div', { className: 'inspector-head' }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, minWidth: 0 } }, + h('span', { className: 'font-seal', style: { fontWeight: 700, fontSize: 20, color: 'var(--ss-primary)', lineHeight: 1 } }, sel.name), + h('span', { className: 'ss-pill is-' + selTone }, seatStatusText(selSeat)), + h('span', { style: { fontSize: 12, color: 'var(--ss-muted)' } }, seatKind(sel.id)), + ), + h('button', { + type: 'button', + className: 'wb-btn-primary', + disabled: busy || sel.status === 'creating', + onClick: actionHandler, + }, ChatIcon(), h('span', null, actionLabel)), + ), + h('div', { className: 'inspector-subtabs' }, + h('button', { type: 'button', className: 'inspector-subtab' + (inspectorTab === 'overview' ? ' is-active' : ''), onClick: () => setInspectorTab('overview') }, '概览与任务'), + h('button', { type: 'button', className: 'inspector-subtab' + (inspectorTab === 'config' ? ' is-active' : ''), onClick: () => setInspectorTab('config') }, + '模型与指令' + (sel.modelSyncStatus === 'failed' ? ' · 异常' : '')), + ), + h('div', { className: 'inspector-body' }, + inspectorTab === 'config' + ? renderModelControlsForSeat(sel.id, saveSeatConfigFor) + : [ + h('div', { key: 'kv', className: 'kv-grid-2' }, + h('div', { className: 'kv-box' }, + h('div', { style: { color: 'var(--ss-muted)' } }, '主任模型'), + h('div', { className: 'font-mono-num truncate', style: { fontWeight: 500, marginTop: 2 } }, sel.modelLabel), + h('div', { style: { color: 'var(--ss-muted)', marginTop: 2 } }, sel.modelSourceLabel), + ), + h('div', { className: 'kv-box' }, + h('div', { style: { color: 'var(--ss-muted)' } }, '会话绑定'), + h('div', { className: 'font-mono-num', style: { fontWeight: 500, marginTop: 2, color: sel.status === 'missing' ? 'var(--ss-error)' : 'var(--ss-fg)' } }, + sel.status === 'missing' ? '会话已缺失' : (sel.sessionId ? sel.sessionId.slice(0, 10) : '尚未建立')), + h('div', { style: { color: 'var(--ss-muted)', marginTop: 2 } }, '本日 ' + selToday.length + ' 条 · 完 ' + selTodayDone.length), + ), + ), + sel.status === 'missing' ? h('div', { key: 'miss', className: 'wb-alert' }, + h('span', null, '原会话在宿主中已不存在,重建后保留旧任务历史。'), + h('button', { type: 'button', className: 'wb-btn-outline', disabled: busy, onClick: () => void rebuildSeat(sel.id) }, '重建会话'), + ) : null, + sel.modelSyncStatus === 'failed' ? h('div', { key: 'fail', className: 'wb-alert' }, + h('span', null, '模型同步失败:' + (sel.modelSync?.error || '未知原因')), + h('button', { type: 'button', className: 'wb-btn-outline', disabled: busy, onClick: () => void retrySyncFor(sel.id) }, '重试同步'), + ) : null, + h('div', { key: 'resp', style: { borderRadius: 8, border: '1px solid var(--ss-border)', padding: 12, display: 'flex', flexDirection: 'column', gap: 4 } }, + h('div', { style: { fontWeight: 500, color: 'var(--ss-muted)' } }, '最近动态与职责'), + h('p', { style: { margin: 0, lineHeight: 1.55 } }, (selLatest && (selLatest.result || selLatest.note)) || sel.responsibility), + selLatest ? h('p', { style: { margin: '4px 0 0', paddingTop: 6, borderTop: '1px dashed var(--ss-border)', color: 'var(--ss-muted)' } }, '职责:' + sel.responsibility) : null, + ), + sel.id === 'shangshu' ? h('button', { + key: 'ss', + type: 'button', + className: 'frameless-btn', + style: { width: '100%', padding: '8px 12px', borderRadius: 8 }, + disabled: summaryBusy || busy, + onClick: () => void summarizeByShangshu(), + }, summaryBusy ? '正在通知尚书汇总…' : '请尚书汇总当前项目任务进度 →') : null, + sel.id === 'lead' ? h('button', { + key: 'reqjump', + type: 'button', + className: 'frameless-btn', + style: { width: '100%', padding: '8px 12px', borderRadius: 8 }, + onClick: () => { setTab('flow'); setFlowSubTab('requirements') }, + }, '前往「流转 · 需求清单」查看 ' + requirements.length + ' 条需求 →') : null, + h('div', { key: 'recent', style: { display: 'flex', flexDirection: 'column', gap: 6 } }, + h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } }, + h('span', { style: { fontWeight: 500, color: 'var(--ss-muted)' } }, '本席近期任务 (' + selTasks.length + ')'), + selTasks.length > 0 ? h('button', { type: 'button', className: 'frameless-link', onClick: () => { setTab('flow'); setFlowSubTab('queue') } }, '查看全部') : null, + ), + selTasks.length === 0 + ? h('div', { className: 'wb-empty-box' }, '该席位暂无任务记录。') + : selTasks.slice(0, 3).map(t => { + const tm = TASK_META[t.status] || { label: t.status, tone: 'muted' } + return h('button', { + key: t.id, + type: 'button', + className: 'wb-card', + style: { textAlign: 'left', padding: 10 }, + onClick: () => setSelectedTask(t), + }, + h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 } }, + h('span', { className: 'truncate', style: { fontWeight: 500 } }, t.title), + h('span', { className: 'ss-pill is-' + tm.tone }, tm.label), + ), + h('p', { className: 'line-clamp-2', style: { margin: 0, color: 'var(--ss-muted)' } }, + t.workflowBlockage ? t.workflowBlockage.reason : (t.result || t.goal || t.requirement || '(暂无说明)')), + ) + }), + ), + ], + ), + ), + ), ] - const workflowTasks = tasks.filter(task => task.kind === 'workflow' || task.kind === 'execution') - const deliveryTasks = tasks.filter(task => task.kind === 'workflow' && (task.stage === 'delivered' || task.status === 'done')) - let body - if (reqView === 'flow') { - body = workflowTasks.length - ? h('div', { className: 'review-list req-list' }, workflowTasks.map(task => h('article', { className: 'review-card req-card', key: task.id }, - h('div', { className: 'rc-head' }, - h('div', { className: 'rc-title' }, task.title), - h('span', { className: 'rc-status ' + taskTone(task.status) }, h('i'), taskLabel(task.status)), - ), - h('div', { className: 'req-meta' }, - h('span', null, task.id), - h('span', null, (SEATS[task.ownerSeatId] && SEATS[task.ownerSeatId].label) || task.ownerSeatId || '—'), - h('span', null, WORKFLOW_STAGE_LABELS[task.stage] || task.stage || '—'), - task.requirementId ? h('span', null, task.requirementId + ' v' + task.requirementRevision) : null, - task.approvalId ? h('span', null, task.approvalId) : null, - ), - h(SummaryBlock, { text: task.goal || task.requirement || '', label: '任务说明', empty: '(无任务说明)', max: 110 }), - h(SummaryBlock, { text: task.workflowBlockage ? task.workflowBlockage.label + ' · ' + task.workflowBlockage.reason : (task.result || task.note || task.blockedReason || ''), label: '当前结果 / 阻塞', empty: '(尚未回报)', max: 110 }), - h('div', { className: 'rc-actions' }, h('span', { className: 'spacer' }), h('button', { type: 'button', className: 'r-open', onClick: () => setSelectedTask(task) }, '查看详情 →')), - ))) - : h('p', { className: 'empty-note' }, '还没有流转任务。丞相下派需求后会出现在这里。') - } else if (reqView === 'delivery') { - body = deliveryTasks.length - ? h('div', { className: 'review-list req-list' }, deliveryTasks.map(task => { - const children = tasks.filter(item => item.parentTaskId === task.id && item.kind === 'execution') - return h('article', { className: 'review-card req-card', key: task.id }, - h('div', { className: 'rc-head' }, h('div', { className: 'rc-title' }, task.title), h('span', { className: 'rc-status done' }, h('i'), '已交付')), - h('div', { className: 'req-meta' }, h('span', null, task.requirementId || '—'), h('span', null, 'v' + (task.requirementRevision || '—')), h('span', null, task.id)), - h(SummaryBlock, { text: task.deliveryNote || task.summary || '', label: '交付说明', empty: '(暂无交付说明)', max: 110 }), - children.length ? h('div', { className: 'req-children' }, children.map(child => h('div', { className: 'req-child', key: child.id }, - h('span', { className: 'req-child-owner' }, (SEATS[child.ownerSeatId] && SEATS[child.ownerSeatId].label) || child.ownerSeatId), - h('span', { className: 'rc-status ' + taskTone(child.status) }, h('i'), taskLabel(child.status)), - h('span', { className: 'req-child-result' }, child.result || child.note || '(暂无结果)'), - h('span', { className: 'req-child-session' }, child.resultSessionId ? '结果会话 ' + child.resultSessionId : '尚无结果会话'), - ))) : null, + } + + function renderStageStepper(stage) { + const idx = WORKFLOW_STAGES.findIndex(s => s.id === stage) + return h('div', { className: 'stage-stepper' }, + WORKFLOW_STAGES.map((st, i) => { + const done = idx >= 0 && i < idx + const cur = idx >= 0 && i === idx + return h('span', { key: st.id, style: { display: 'inline-flex', alignItems: 'center', gap: 4, flexShrink: 0 } }, + h('span', { className: 'stage-step-pill' + (done ? ' is-done' : cur ? ' is-cur' : '') }, st.label), + i < WORKFLOW_STAGES.length - 1 ? h('span', { style: { color: 'var(--ss-muted)', fontSize: 12 } }, '→') : null, + ) + }), + stage === 'reconfirm' ? h('span', { className: 'ss-pill is-error' }, '阻塞 · 待重确认') : null, + ) + } + + function renderFlowTab() { + const wfTasks = tasks.filter(t => t.kind === 'workflow' || t.kind === 'execution') + const deliveries = tasks.filter(t => t.stage === 'delivered' || t.status === 'done') + const q = queueSearch.trim().toLowerCase() + const filteredQueue = tasks.filter(t => { + if (!q) return true + const sName = SEATS[t.ownerSeatId]?.label || '' + const tmLabel = TASK_META[t.status]?.label || '' + return [t.id, t.title, sName, tmLabel, t.goal, t.result].filter(Boolean).join(' ').toLowerCase().includes(q) + }) + const subTabs = [ + { id: 'tasks', label: '流转任务', count: wfTasks.length }, + { id: 'requirements', label: '需求清单', count: requirements.length }, + { id: 'queue', label: '派工队列', count: tasks.length }, + { id: 'delivery', label: '交付结果', count: deliveries.length }, + ] + let body = null + if (flowSubTab === 'requirements') { + body = requirements.length === 0 + ? h('div', { className: 'wb-empty-box' }, '暂无需求条目。与丞相在对话中明确需求后将整理至此。') + : h('div', { style: { display: 'flex', flexDirection: 'column', gap: 10 } }, requirements.map(req => { + const rm = REQ_STATUS_META[req.status] || { label: req.status, tone: 'muted' } + return h('article', { className: 'wb-card', key: req.id }, + h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', gap: 8 } }, + h('div', { style: { minWidth: 0 } }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } }, + h('span', { className: 'font-mono-num', style: { fontWeight: 600, color: 'var(--ss-primary)' } }, req.id + ' · v' + req.revision), + h('span', { className: 'ss-pill is-' + rm.tone }, rm.label), + req.judgement ? h('span', { style: { color: 'var(--ss-muted)' } }, '丞相:' + (REQ_JUDGEMENT_LABELS[req.judgement] || req.judgement)) : null, + ), + h('h3', { style: { margin: '4px 0 0', fontSize: 13, fontWeight: 600 } }, req.title), + ), + h('button', { + type: 'button', + className: 'wb-btn-outline', + onClick: () => { + try { void navigator.clipboard?.writeText?.(req.id) } catch { /* 忽略 */ } + setNotice('已复制需求编号:' + req.id) + }, + }, '复制编号'), + ), + req.summary ? h('p', { style: { margin: 0, lineHeight: 1.55 } }, req.summary) : null, + req.blockedReason ? h('div', { className: 'wb-alert' }, '阻塞:' + req.blockedReason) : null, + h('details', { style: { borderRadius: 8, background: 'var(--ss-subtle)', border: '1px solid var(--ss-border)', padding: '6px 10px' } }, + h('summary', { style: { cursor: 'pointer', color: 'var(--ss-muted)', fontWeight: 500 } }, '展开范围、验收标准与待补信息'), + h('dl', { style: { margin: '8px 0 0', paddingTop: 8, borderTop: '1px solid var(--ss-border)', display: 'grid', gap: 6 } }, + h('div', null, h('dt', { style: { color: 'var(--ss-muted)' } }, '用户原话'), h('dd', { style: { margin: '2px 0 0' } }, req.originalText || '—')), + h('div', null, h('dt', { style: { color: 'var(--ss-muted)' } }, '范围'), h('dd', { style: { margin: '2px 0 0' } }, req.scope || '—')), + h('div', null, h('dt', { style: { color: 'var(--ss-muted)' } }, '非目标'), h('dd', { style: { margin: '2px 0 0' } }, req.nonGoals || '—')), + h('div', null, h('dt', { style: { color: 'var(--ss-muted)' } }, '验收标准'), h('dd', { style: { margin: '2px 0 0' } }, req.acceptanceCriteria || '—')), + req.risks ? h('div', null, h('dt', { style: { color: 'var(--ss-muted)' } }, '风险'), h('dd', { style: { margin: '2px 0 0' } }, req.risks)) : null, + req.missingInfo ? h('div', null, h('dt', { style: { color: 'var(--ss-muted)' } }, '待补信息'), h('dd', { style: { margin: '2px 0 0' } }, req.missingInfo)) : null, + ), + ), ) })) - : h('p', { className: 'empty-note' }, '还没有已交付结果。') - } else { - body = requirements.length - ? h('div', { className: 'review-list req-list' }, requirements.map(req => h('article', { className: 'review-card req-card', key: req.id }, - h('div', { className: 'rc-head' }, - h('div', { className: 'rc-title' }, req.id + ' · ' + req.title), - h('span', { className: 'rc-status ' + reqTone(req.status) }, h('i'), REQ_STATUS_LABELS[req.status] || req.status), - ), - h('div', { className: 'req-meta' }, - h('span', null, 'v' + req.revision), - h('span', null, '丞相判断:' + (REQ_JUDGEMENT_LABELS[req.judgement] || req.judgement || '—')), - h('span', null, '当前阻塞:' + (req.blockedReason || '—')), - ), - h(SummaryBlock, { text: req.summary || req.originalText || '', label: '摘要', empty: '(暂无摘要)', max: 110 }), - h(SummaryBlock, { text: req.judgementReason || '', label: '判断理由', empty: '(暂无判断理由)', max: 110 }), - h('details', { className: 'req-details' }, - h('summary', null, '范围、验收与待补信息'), - h('dl', { className: 'kv' }, - h('dt', null, '用户原话'), h('dd', null, req.originalText || '—'), - h('dt', null, '范围'), h('dd', null, req.scope || '—'), - h('dt', null, '非目标'), h('dd', null, req.nonGoals || '—'), - h('dt', null, '验收标准'), h('dd', null, req.acceptanceCriteria || '—'), - h('dt', null, '风险'), h('dd', null, req.risks || '—'), - h('dt', null, '依赖'), h('dd', null, req.dependencies || '—'), - h('dt', null, '待补信息'), h('dd', null, req.missingInfo || '—'), + } else if (flowSubTab === 'queue') { + body = h('div', { className: 'wb-card', style: { padding: 0, overflow: 'hidden', gap: 0 } }, + h('div', { style: { padding: 10, borderBottom: '1px solid var(--ss-border)', display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center' } }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 6, flex: '1 1 150px', border: '1px solid var(--ss-border)', borderRadius: 8, background: 'var(--ss-bg)', padding: '5px 10px' } }, + SearchIcon(), + h('input', { + type: 'search', + value: queueSearch, + placeholder: '按任务、席位、状态筛选…', + style: { width: '100%', border: 0, background: 'transparent', outline: 'none', fontSize: 12 }, + onChange: (e) => setQueueSearch(e.target.value), + }), + ), + h('button', { type: 'button', className: 'frameless-btn', disabled: summaryBusy || busy, onClick: () => void summarizeByShangshu() }, summaryBusy ? '汇总中…' : '尚书汇总'), + h('button', { type: 'button', className: 'wb-btn-outline', disabled: busy, onClick: () => void reloadTasks() }, '刷新'), + ), + filteredQueue.length === 0 + ? h('div', { style: { padding: 28, textAlign: 'center', color: 'var(--ss-muted)' } }, '没有匹配的派工记录。') + : h('div', { style: { overflowX: 'auto' } }, + h('table', { className: 'queue-table' }, + h('thead', null, h('tr', null, + h('th', null, '任务'), + h('th', null, '席位'), + h('th', null, '状态'), + h('th', { className: 'col-dur' }, '耗时'), + h('th', { className: 'col-time' }, '派发时间'), + )), + h('tbody', null, filteredQueue.map(t => { + const tm = TASK_META[t.status] || { label: t.status, tone: 'muted' } + return h('tr', { key: t.id, className: 'is-click', onClick: () => setSelectedTask(t) }, + h('td', null, h('div', { style: { fontWeight: 500 } }, t.title), h('div', { className: 'font-mono-num', style: { color: 'var(--ss-muted)' } }, t.id)), + h('td', { className: 'font-seal', style: { fontWeight: 700, whiteSpace: 'nowrap' } }, SEATS[t.ownerSeatId]?.label || '—'), + h('td', null, h('span', { className: 'ss-pill is-' + tm.tone }, tm.label)), + h('td', { className: 'col-dur font-mono-num', style: { color: 'var(--ss-muted)', whiteSpace: 'nowrap' } }, durationText(taskDurationMs(t))), + h('td', { className: 'col-time font-mono-num', style: { color: 'var(--ss-muted)', whiteSpace: 'nowrap' } }, dateText(t.dispatchedAt)), + ) + })), ), ), - h('div', { className: 'rc-actions' }, - h('button', { type: 'button', className: 'btn', onClick: () => copyRequirementText(req.id) }, '复制条目编号'), - h('span', { className: 'spacer' }), - ), - ))) - : h('p', { className: 'empty-note' }, '还没有需求条目。可以先与丞相讨论。') + ) + } else if (flowSubTab === 'delivery') { + body = deliveries.length === 0 + ? h('div', { className: 'wb-empty-box' }, '还没有已交付结果。') + : h('div', { style: { display: 'flex', flexDirection: 'column', gap: 10 } }, deliveries.map(t => { + const children = tasks.filter(c => c.parentTaskId === t.id && c.kind === 'execution') + return h('article', { className: 'wb-card', key: t.id }, + h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 8 } }, + h('h3', { style: { margin: 0, fontSize: 13, fontWeight: 600 } }, t.title), + h('span', { className: 'ss-pill is-success' }, '已交付'), + ), + h('div', { className: 'font-mono-num', style: { display: 'flex', flexWrap: 'wrap', gap: 8, color: 'var(--ss-muted)' } }, + h('span', null, t.id), + h('span', null, '承办:' + (SEATS[t.ownerSeatId]?.label || '—')), + t.resultSessionId ? h('span', null, '会话 ' + t.resultSessionId.slice(0, 8)) : null, + h('span', null, '耗时 ' + durationText(taskDurationMs(t))), + ), + h('p', { style: { margin: 0, lineHeight: 1.55, whiteSpace: 'pre-wrap' } }, t.deliveryNote || t.result || t.summary || '(暂无交付说明)'), + children.length ? h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6, paddingTop: 8, borderTop: '1px dashed var(--ss-border)' } }, + children.map(ch => h('div', { key: ch.id, style: { display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center' } }, + h('span', { className: 'font-seal', style: { fontWeight: 700 } }, SEATS[ch.ownerSeatId]?.label || ch.ownerSeatId), + h('span', { className: 'ss-pill is-' + (TASK_META[ch.status]?.tone || 'muted') }, TASK_META[ch.status]?.label || ch.status), + h('span', { style: { flex: '1 1 120px', color: 'var(--ss-muted)' } }, shortText(ch.result || ch.note || '(暂无结果)', 80)), + ch.resultSessionId ? h('span', { className: 'font-mono-num', style: { color: 'var(--ss-muted)' } }, ch.resultSessionId.slice(0, 8)) : null, + )), + ) : null, + ) + })) + } else { + body = wfTasks.length === 0 + ? h('div', { className: 'wb-empty-box' }, '还没有流转任务。丞相下派需求后会出现在这里。') + : h('div', { style: { display: 'flex', flexDirection: 'column', gap: 10 } }, wfTasks.map(t => { + const tm = TASK_META[t.status] || { label: t.status, tone: 'muted' } + return h('article', { + key: t.id, + className: 'wb-card', + style: t.workflowBlockage ? { borderColor: 'color-mix(in srgb,var(--ss-error) 36%,var(--ss-border))' } : undefined, + }, + h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', gap: 8 } }, + h('div', { style: { minWidth: 0 } }, + h('div', { style: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 6 } }, + h('span', { className: 'font-mono-num', style: { color: 'var(--ss-muted)' } }, t.id), + h('span', { className: 'font-seal', style: { fontWeight: 700 } }, SEATS[t.ownerSeatId]?.label || t.ownerSeatId), + t.requirementId ? h('span', { className: 'ss-pill font-mono-num' }, t.requirementId + ' v' + t.requirementRevision) : null, + h('span', { className: 'ss-pill is-' + tm.tone }, tm.label), + ), + h('h3', { style: { margin: '4px 0 0', fontSize: 13, fontWeight: 600 } }, t.title), + ), + h('button', { type: 'button', className: 'wb-btn-outline', onClick: () => setSelectedTask(t) }, '查看详情 →'), + ), + t.kind === 'workflow' ? renderStageStepper(t.stage) : null, + t.workflowBlockage + ? h('div', { className: 'wb-alert' }, + h('span', null, t.workflowBlockage.label + ':' + t.workflowBlockage.reason), + h('button', { type: 'button', className: 'wb-btn-outline', onClick: () => setSelectedTask(t) }, '处理阻塞'), + ) + : h('p', { style: { margin: 0, color: 'var(--ss-muted)', lineHeight: 1.55 } }, t.result || t.goal || t.requirement || '(暂无说明)'), + ) + })) } - return h('section', { className: 'card req-gate', 'aria-label': '丞相需求门控' }, - h('h3', null, '需求门控 ', h('span', { className: 'seat-tag' }, selected.name)), - h('p', { className: 'foot-note ws-hint' }, '与丞相商讨后,需求会整理到这里。想推进哪条需求,直接在聊天中告诉丞相下派。中书拟案,门下通过后由尚书安排执行。'), - h('div', { className: 'req-tabs', role: 'tablist' }, views.map(view => h('button', { - key: view.id, type: 'button', role: 'tab', 'aria-selected': reqView === view.id, - className: 'req-tab' + (reqView === view.id ? ' is-active' : ''), - onClick: () => setReqView(view.id), - }, view.label))), - body, - ) - } - async function answerApproval(entry, choice) { - if (!projectId || !entry) return - setBusy(true); setError(null) - try { - await request('approvalAnswer', { projectId, seatId: entry.seatId, id: entry.id, sessionId: entry.sessionId, choice }) - const data = await request('approvals', { projectId }) - if (!alive.current || loadedProjectId.current !== projectId) return - setPendingApprovals(previous => refreshList(data?.approvals, previous)) - setApprovalStatus(data?.status ?? null) - setNotice(choice === 'allow' ? '已允许审批' : '已拒绝审批') - } catch (error) { - if (alive.current) setError(error && error.message ? error.message : '审批应答失败') - } finally { if (alive.current) setBusy(false) } + + return [ + h('div', { key: 'subtabs', className: 'flow-seg' }, + subTabs.map(st => h('button', { + key: st.id, + type: 'button', + className: 'flow-seg-btn' + (flowSubTab === st.id ? ' is-active' : ''), + onClick: () => setFlowSubTab(st.id), + }, st.label + ' ' + st.count)), + ), + h('div', { key: 'flowbody' }, body), + ] } - async function answerDecision(taskId, decisionId, value) { - if (!projectId || busy) return - setBusy(true); setError(null) - try { - await request('taskDecisionAnswer', { projectId, taskId, decisionId, value }) - if (!alive.current || loadedProjectId.current !== projectId) return - taskAnswerVersion.current += 1 - setTasks(previous => previous.map(task => task.id === taskId && Array.isArray(task.decisions) - ? { ...task, decisions: task.decisions.map(decision => decision.id === decisionId - ? { ...decision, status: 'answered', answer: value } - : decision) } - : task)) - setNotice('已提交项目决定') - } catch (error) { - if (alive.current && loadedProjectId.current === projectId) setError(error?.message || '项目决定提交失败') - } finally { if (alive.current) setBusy(false) } - } + function renderDeliberationTab() { + const avatars = view?.project?.avatars ?? {} + const active = deliberations.find(x => x.status === 'running') || null + const shownId = delibSelectedId || active?.id || deliberations[0]?.id || null + const summary = deliberations.find(x => x.id === shownId) || null + const full = deliberation && deliberation.id === shownId ? deliberation : null + const shown = full || summary || null + const isActive = Boolean(shown && shown.status === 'running') + const curSeat = isActive ? (shown.currentSeatId || shown.turn?.seatId || null) : null + const speeches = shown?.speeches || [] - function renderPendingActions() { - const degraded = approvalStatus?.degraded - const toolApprovals = degraded ? [] : pendingApprovals - const decisions = tasks.flatMap(task => (task.decisions || []) - .filter(decision => decision.status === 'pending') - .map(decision => ({ task, decision }))) - const count = toolApprovals.length + decisions.length - if (!count && !degraded) return null - return h('section', { className: 'card approval-card', 'aria-label': '待你处理' }, - h('h3', null, '待你处理 ', count ? h('span', { className: 'seat-tag' }, String(count)) : null), - degraded ? h('p', { className: 'foot-note' }, '工作台暂时无法获取工具审批,请在席位会话中使用原生审批卡。' + (approvalStatus.reason ? '(' + approvalStatus.reason + ')' : '')) : null, - count ? h('div', { className: 'approval-list' }, - toolApprovals.map(entry => h('article', { className: 'approval-item', key: 'tool:' + entry.sessionId + ':' + entry.id }, - h('div', { className: 'approval-head' }, h('strong', null, SEATS[entry.seatId]?.label || entry.seatId), h('span', null, entry.tool || '工具审批')), - h('p', null, entry.reason || entry.detail?.text || '等待审批'), - h('div', { className: 'approval-actions' }, - h('button', { type: 'button', className: 'btn primary', disabled: busy, onClick: () => answerApproval(entry, 'allow') }, '允许一次'), - h('button', { type: 'button', className: 'btn', disabled: busy, onClick: () => answerApproval(entry, 'reject') }, '拒绝'), + return [ + h('section', { key: 'dhead', className: 'wb-card' }, + h('div', { style: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'space-between', gap: 8 } }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, minWidth: 0 } }, + h('span', { className: 'ss-pill is-' + (isActive ? 'success' : shown?.status === 'stopped' ? 'error' : 'muted') }, + isActive ? '议政进行中' : shown?.status === 'stopped' ? '已停止' : shown ? '已收束' : '空闲'), + h('span', { className: 'truncate', style: { fontWeight: 500 } }, + shown ? ('第 ' + shown.round + ' / ' + (shown.maxRounds > 0 ? shown.maxRounds : '不限') + ' 轮' + (curSeat ? ' · 当值:' + (SEATS[curSeat]?.label || curSeat) : '')) : '发起议题即可启动三省轮流审议'), ), - )), - decisions.map(({ task, decision }) => h('article', { className: 'approval-item', key: 'decision:' + task.id + ':' + decision.id }, - h('div', { className: 'approval-head' }, h('strong', null, task.title || task.id), h('span', null, '项目决定')), - h('p', null, decision.question), - h('div', { className: 'approval-actions', role: 'group', 'aria-label': decision.question }, decision.options.map(option => - h('button', { type: 'button', className: 'btn', key: option.value, disabled: busy, onClick: () => answerDecision(task.id, decision.id, option.value) }, option.label), - )), - )), - ) : null, - ) - } + h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 6 } }, + h('button', { type: 'button', className: 'wb-btn-outline', onClick: () => setDelibSettingsOpen(v => !v) }, '议政设置'), + isActive ? [ + h('button', { key: 'end', type: 'button', className: 'frameless-btn', disabled: delibBusy, onClick: () => void endDeliberation() }, '收束结论'), + h('button', { key: 'stop', type: 'button', className: 'wb-btn-outline', style: { color: 'var(--ss-error)' }, disabled: delibBusy, onClick: () => void stopDeliberation() }, '立即停止'), + ] : null, + ), + ), + shown ? h('h2', { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, shown.topic) : null, + h('div', { style: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 8 } }, + DELIB_SEATS.map((sid, i) => [ + h('button', { + key: sid, + type: 'button', + title: '点击调整「' + SEATS[sid].label + '」头像', + style: { + display: 'inline-flex', alignItems: 'center', gap: 6, padding: '5px 8px', borderRadius: 8, + border: '1px solid ' + (curSeat === sid ? 'var(--ss-primary)' : 'var(--ss-border)'), + background: curSeat === sid ? 'color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card))' : 'var(--ss-subtle)', + opacity: !isActive || curSeat === sid ? 1 : 0.65, + }, + onClick: () => setAvatarEdit(prev => prev?.seatId === sid ? null : { seatId: sid, char: '' }), + }, + avatarNode(sid, avatars, 24, curSeat === sid), + h('span', { className: 'font-seal', style: { fontWeight: 700 } }, SEATS[sid].label), + curSeat === sid ? h('span', { style: { color: 'var(--ss-primary)' } }, '当值') : null, + ), + i < 2 ? h('span', { key: 'arr-' + i, style: { color: 'var(--ss-muted)' } }, '→') : null, + ]), + h('span', { style: { marginLeft: 'auto', color: 'var(--ss-muted)' } }, '点击头像可换'), + ), + shown?.turn?.error ? h('div', { className: 'wb-alert' }, + h('span', null, shown.turn.error), + h('button', { type: 'button', className: 'wb-btn-outline', disabled: delibBusy, onClick: () => void retryDeliberation() }, '重试当前席位'), + ) : null, + avatarEdit ? h('div', { style: { borderRadius: 8, border: '1px solid var(--ss-border)', background: 'var(--ss-subtle)', padding: 10, display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 8 } }, + avatarNode(avatarEdit.seatId, avatars, 28, false), + h('span', { style: { fontWeight: 500 } }, SEATS[avatarEdit.seatId].label + '头像:'), + h('label', { className: 'wb-btn-outline', style: { cursor: 'pointer' } }, '选图片', + h('input', { + type: 'file', accept: 'image/png,image/jpeg,image/webp', style: { display: 'none' }, + onChange: (e) => { const f = e.target.files?.[0]; if (f) void pickAvatarFile(avatarEdit.seatId, f); e.target.value = '' }, + }), + ), + h('input', { + type: 'text', maxLength: 8, placeholder: '或填 1 字 / Emoji', value: avatarEdit.char, + className: 'wb-input', style: { width: 130 }, + onChange: (e) => setAvatarEdit(prev => ({ ...prev, char: e.target.value })), + }), + h('button', { type: 'button', className: 'wb-btn-primary', disabled: delibBusy || !avatarEdit.char.trim(), onClick: () => void saveAvatar(avatarEdit.seatId, { char: avatarEdit.char.trim() }) }, '保存字符'), + h('button', { type: 'button', className: 'wb-btn-outline', disabled: delibBusy, onClick: () => void saveAvatar(avatarEdit.seatId, { clear: true }) }, '恢复默认'), + h('button', { type: 'button', className: 'wb-toast-close', style: { marginLeft: 'auto' }, onClick: () => setAvatarEdit(null) }, '关闭'), + ) : null, + delibSettingsOpen ? h('div', { style: { borderRadius: 8, border: '1px solid var(--ss-border)', background: 'var(--ss-subtle)', padding: 10, display: 'grid', gridTemplateColumns: 'repeat(auto-fit,minmax(130px,1fr))', gap: 8 } }, + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '轮次上限(0 为不限)'), + h('input', { type: 'number', min: 0, max: 20, value: delibDraft.maxRounds, className: 'wb-input', onChange: (e) => setDelibDraft(p => ({ ...p, maxRounds: e.target.value })) }), + ), + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '关联任务'), + h('select', { className: 'wb-select', value: delibDraft.taskId, onChange: (e) => setDelibDraft(p => ({ ...p, taskId: e.target.value })) }, + h('option', { value: '' }, '不关联'), + tasks.map(t => h('option', { key: t.id, value: t.id }, t.id + ' ' + t.title)), + ), + ), + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '关联需求'), + h('select', { className: 'wb-select', value: delibDraft.requirementId, onChange: (e) => setDelibDraft(p => ({ ...p, requirementId: e.target.value })) }, + h('option', { value: '' }, '不关联'), + requirements.map(r => h('option', { key: r.id, value: r.id }, r.id + ' ' + r.title)), + ), + ), + ) : null, + ), - function renderOverview() { - const stats = [ - h('button', { type: 'button', className: 'stat stat-link', key: 'cost', onClick: () => setTokenPanelOpen(true) }, - h('div', { className: 'label' }, '消耗金额'), - h('div', { className: 'big' }, h('em', null, '—'), h('span', { className: 'unit' }, '元')), - h('div', { className: 'foot' }, 'Token 统计待接入'), + h('section', { key: 'transcript', className: 'wb-card', 'aria-label': '议政转写' }, + speeches.length === 0 + ? h('div', { style: { padding: '28px 0', textAlign: 'center', color: 'var(--ss-muted)' } }, '尚未开议。在下方输入议题,将按「中书 → 门下 → 尚书」顺序轮流发言。') + : speeches.map(sp => h('div', { key: sp.id, style: { display: 'flex', alignItems: 'flex-start', gap: 10 } }, + avatarNode(sp.seatId, avatars, 30, curSeat === sp.seatId), + h('div', { style: { minWidth: 0, flex: '1 1 auto', display: 'flex', flexDirection: 'column', gap: 4 } }, + h('div', { style: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 8 } }, + h('span', { className: 'font-seal', style: { fontWeight: 700 } }, SEATS[sp.seatId]?.label || sp.seatId), + h('span', { className: 'font-mono-num', style: { color: 'var(--ss-muted)' } }, '第 ' + sp.round + ' 轮'), + h('span', { className: 'ss-pill is-' + (sp.stance === 'agree' ? 'success' : sp.stance === 'dissent' ? 'error' : 'warning') }, + sp.stance === 'agree' ? '赞同' : sp.stance === 'dissent' ? '有分歧' : '待决'), + ), + h('div', { className: 'speech-bubble speech-' + seatDotTone(sp.seatId) }, sp.text), + sp.openIssues ? h('div', { style: { color: 'var(--ss-error)' } }, '未决:' + sp.openIssues) : null, + ), + )), + shown?.conclusion ? h('div', { style: { borderRadius: 8, border: '1px solid color-mix(in srgb,var(--ss-success) 32%,var(--ss-border))', background: 'color-mix(in srgb,var(--ss-success) 7%,var(--ss-card))', padding: 10 } }, + h('div', { style: { fontWeight: 600, color: 'var(--ss-success)' } }, '议政结论'), + h('p', { style: { margin: '4px 0 0', whiteSpace: 'pre-wrap' } }, shown.conclusion.text), + ) : null, ), - h('button', { type: 'button', className: 'stat stat-link', key: 'duration', onClick: () => setDurationPanelOpen(true) }, - h('div', { className: 'label' }, '消耗时间'), - h('div', { className: 'big' }, projectDurationMs > 0 ? durationText(projectDurationMs) : '—'), - h('div', { className: 'foot' }, '按任务单程累计'), + + h('div', { key: 'composer', className: 'wb-card', style: { flexDirection: 'row', alignItems: 'center', padding: 10 } }, + h('input', { + type: 'text', + value: delibDraft.topic, + disabled: Boolean(active), + placeholder: active ? '当前议政进行中,收束或停止后可发起新议题…' : '输入议题,交由三省轮流审议…', + style: { flex: '1 1 auto', minWidth: 0, border: 0, background: 'transparent', outline: 'none', padding: '6px 8px', fontSize: 12 }, + onChange: (e) => setDelibDraft(p => ({ ...p, topic: e.target.value })), + onKeyDown: (e) => { if (e.key === 'Enter' && !active) void startDeliberation() }, + }), + h('button', { type: 'button', className: 'wb-btn-primary', disabled: delibBusy || Boolean(active) || !delibDraft.topic.trim(), onClick: () => void startDeliberation() }, + delibBusy ? '发起中…' : '发起议政'), ), - h('button', { type: 'button', className: 'stat stat-link', key: 'review', onClick: () => setReviewPanelOpen(true) }, - h('div', { className: 'label' }, '待审核'), - h('div', { className: 'big' }, h('em', null, String(reviewTasks.length)), ' ', h('span', { className: 'unit' }, '件')), - h('div', { className: 'foot' }, '待门下复核'), - ), - h('button', { type: 'button', className: 'stat stat-link', key: 'anomaly', onClick: () => { setQueueSearch('失败'); setQueuePanelOpen(true) } }, - h('div', { className: 'label' }, '异常 / 失败'), - h('div', { className: 'big' }, h('em', null, String(anomalyTasks.length)), ' ', h('span', { className: 'unit' }, '条')), - h('div', { className: 'foot' }, '失败或投递失败'), + + h('div', { key: 'extras', className: 'consensus-grid' }, + h('section', { className: 'wb-card' }, + h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } }, + h('h3', { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, '后台子 Agent (' + agentRuns.length + ')'), + h('span', { style: { color: 'var(--ss-muted)' } }, '记室 / 主簿 / 接令'), + ), + agentRuns.length === 0 + ? h('p', { style: { margin: 0, color: 'var(--ss-muted)' } }, '当前无运行中的后台子 Agent。') + : agentRuns.map(run => h('div', { key: run.id, style: { borderRadius: 8, border: '1px solid var(--ss-border)', background: 'var(--ss-subtle)', padding: 10, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 } }, + h('div', { style: { minWidth: 0 } }, + h('div', { className: 'truncate', style: { fontWeight: 500, display: 'flex', alignItems: 'center', gap: 6 } }, + h('span', { className: 'ss-dot is-success is-pulse' }), + run.label || run.seatId, + ), + run.brief ? h('div', { className: 'truncate', style: { color: 'var(--ss-muted)', marginTop: 2 } }, run.brief) : null, + ), + h('button', { type: 'button', className: 'wb-btn-outline', disabled: delibBusy, onClick: () => void stopAgentRun(run) }, '停止'), + )), + ), + h('section', { className: 'wb-card' }, + h('h3', { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, '议政记录 (' + deliberations.length + ')'), + deliberations.length === 0 + ? h('p', { style: { margin: 0, color: 'var(--ss-muted)' } }, '暂无议政记录。') + : deliberations.map(item => h('button', { + key: item.id, + type: 'button', + className: 'wb-card', + style: { + textAlign: 'left', padding: 10, + borderColor: shown?.id === item.id ? 'var(--ss-primary)' : 'var(--ss-border)', + background: shown?.id === item.id ? 'color-mix(in srgb,var(--ss-primary) 6%,var(--ss-card))' : 'var(--ss-subtle)', + }, + onClick: () => setDelibSelectedId(item.id), + }, + h('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 8 } }, + h('span', { className: 'truncate', style: { fontWeight: 500 } }, item.topic), + h('span', { style: { color: 'var(--ss-muted)', flexShrink: 0 } }, item.status === 'running' ? '进行中' : item.status === 'stopped' ? '已停止' : '已收束'), + ), + h('div', { className: 'font-mono-num', style: { color: 'var(--ss-muted)' } }, item.id + ' · 第 ' + item.round + ' 轮'), + )), + ), ), ] - - const selected = wb.selected - const selectedLatest = latestTaskOf(selected.id) - const selectedTasks = tasksOf(selected.id) - const selectedToday = todayTasks.filter(task => task.ownerSeatId === selected.id) - const selectedDone = selectedToday.filter(task => task.status === 'done') - const excerpt = (selectedLatest && (selectedLatest.result || selectedLatest.note)) || selected.responsibility - const actionLabel = selected.status === 'bound' ? '开始对话' : (selected.status === 'missing' ? '重建会话' : '开启「' + selected.name + '」') - const action = selected.status === 'bound' ? () => openSeat(selected.id) : (selected.status === 'missing' ? () => rebuildSeat(selected.id) : () => enableSeat(selected.id)) - - const detail = h('section', { className: 'card', 'aria-label': '席位详情' }, - h('div', { className: 'detail-head' }, h('h3', null, '席位详情'), h('button', { type: 'button', className: 'btn primary', disabled: busy || selected.status === 'creating', onClick: action }, h(ChatIcon), actionLabel)), - h('div', { className: 'detail-name' }, selected.name), - h('div', { className: 'detail-role' }, selected.duty + ' · ' + selected.statusLabel), - h('dl', { className: 'kv' }, - h('dt', null, '主任模型'), h('dd', null, selected.modelLabel), - h('dt', null, '当前任务'), h('dd', null, selectedLatest ? selectedLatest.title : '—'), - h('dt', null, '本日派工'), h('dd', null, selectedToday.length + ' 条 · 完成 ' + selectedDone.length), - h('dt', null, '最近会话'), h('dd', null, selected.sessionId ? '已绑定 · ' + selected.sessionId.slice(0, 8) : '尚未建立'), - ), - h('div', { className: 'excerpt' }, h(SummaryBlock, { text: excerpt, label: '最近产出', empty: '(暂无产出)', max: 110 })), - ) - - const workspace = selected.id === 'lead' - ? renderRequirementGate(selected) - : h('section', { className: 'card', 'aria-label': '席位工作区' }, - h('h3', null, '席位工作区 ', h('span', { className: 'seat-tag' }, selected.name), ' ', h('span', { className: 'w-kind' }, seatKind(selected.id))), - selected.id === 'shangshu' - ? h('div', { className: 'ws-actions' }, h('button', { type: 'button', className: 'btn primary', disabled: summaryBusy || busy, onClick: summarizeByShangshu }, summaryBusy ? '汇总中…' : '尚书汇总当前任务')) - : null, - h('p', { className: 'foot-note ws-hint' }, '需求请先在聊天中与丞相商讨,再直接告诉丞相下派。中书拟案,门下通过后由尚书向六部派工。'), - selectedTasks.length === 0 - ? h('p', { className: 'empty-note' }, '该席位还没有任务记录。') - : h('div', { className: 'review-list' }, selectedTasks.slice(0, 3).map(task => h('article', { className: 'review-card', key: task.id }, - h('div', { className: 'rc-head' }, h('div', { className: 'rc-title' }, task.title), h('span', { className: 'rc-status ' + taskTone(task.status) }, h('i'), taskLabel(task.status))), - h(SummaryBlock, { text: task.goal || task.requirement || '', label: '任务说明', empty: '(无任务说明)', max: 110 }), - h(SummaryBlock, { text: task.result || taskLabel(task.status), label: '任务完成情况', empty: '(暂无结果)', max: 110 }), - h('div', { className: 'rc-actions' }, h('span', { className: 'spacer' }), - h('button', { type: 'button', className: 'r-open', onClick: () => setSelectedTask(task) }, '查看详情 →'), - ), - ))), - ) - - const modelChoices = [] - const seenModels = new Set() - for (const option of selected.modelOptions) { - const key = option.provider + '::' + option.model - if (seenModels.has(key)) continue - seenModels.add(key) - modelChoices.push({ value: key, label: option.model, provider: option.provider, model: option.model }) - } - const valueParts = String(selected.modelValue || '').split('::') - const currentProvider = valueParts[0] || '' - const currentModel = valueParts[1] || '' - const currentModelValue = currentProvider && currentModel ? currentProvider + '::' + currentModel : '' - if (currentModelValue && !seenModels.has(currentModelValue)) { - modelChoices.unshift({ value: currentModelValue, label: currentModel, provider: currentProvider, model: currentModel }) - } - const effortChoices = [] - for (const option of selected.modelOptions) { - if (option.provider !== currentProvider || option.model !== currentModel || !option.reasoningEffort) continue - if (!effortChoices.includes(option.reasoningEffort)) effortChoices.push(option.reasoningEffort) - } - const currentEffort = valueParts[2] || '' - if (currentEffort && !effortChoices.includes(currentEffort)) effortChoices.unshift(currentEffort) - const configCard = h('details', { className: 'card dept-config-card', 'aria-label': '部门配置' }, - h('summary', null, h('span', null, '部门配置'), h('span', { className: 'seat-tag' }, selected.name)), - h('div', { className: 'dept-config-body' }, - h('div', { className: 'cfg-grid' }, - h('label', { className: 'cfg-row' }, '主任模型', h('select', { value: currentModelValue, onChange: event => setModelValue(event.target.value) }, - h('option', { value: '' }, '请选择模型'), - modelChoices.map(option => h('option', { key: option.value, value: option.value }, option.label)), - )), - h('label', { className: 'cfg-row' }, '推理等级', h('select', { - value: currentEffort, - disabled: effortChoices.length === 0, - title: effortChoices.length === 0 ? '当前模型目录未提供可调推理等级' : undefined, - onChange: event => setModelValue(event.target.value ? currentProvider + '::' + currentModel + '::' + event.target.value : currentModelValue), - }, - effortChoices.length === 0 - ? h('option', { value: '' }, '默认(模型固定)') - : [h('option', { key: 'default', value: '' }, '默认'), ...effortChoices.map(effort => h('option', { key: effort, value: effort }, effort))], - )), - h('label', { className: 'cfg-row', style: { gridColumn: '1 / -1' } }, '角色补充说明', h('textarea', { - rows: 3, className: 'ssv-textarea', value: selected.instructions, placeholder: '仅对该席位追加的补充说明', - onChange: event => setInstructions(event.target.value), - })), - ), - h('div', { className: 'cfg-model-status' }, - h('div', null, '配置来源:' + selected.modelSourceLabel), - h('div', null, '当前会话模型:' + (selected.sessionModel ? (selected.sessionModel.provider + '/' + selected.sessionModel.model) : '未知')), - h('div', null, '同步状态:' + (selected.modelStatus || '未同步') + (selected.modelSync && selected.modelSync.error ? '(' + selected.modelSync.error + ')' : '')), - ), - h('div', { className: 'cfg-skills' }, h('span', { className: 't-label' }, '技能绑定'), - h('ul', { className: 'skill-list' }, - h('li', null, h('span', { className: 'skill-name' }, '真实会话绑定'), h('span', { className: 'skill-state' + (selected.status === 'bound' ? ' bound' : '') }, h('i'), selected.status === 'bound' ? '已绑定' : '未绑定')), - h('li', null, h('span', { className: 'skill-name' }, '工作台派工工具'), h('span', { className: 'skill-state' + (selected.status === 'bound' ? ' bound' : '') }, h('i'), selected.status === 'bound' ? '可用' : '待开启')), - h('li', null, h('span', { className: 'skill-name' }, '职责'), h('span', { className: 'skill-state bound' }, h('i'), selected.duty)), - )), - h('div', { className: 'ws-actions' }, - h('button', { type: 'button', className: 'btn primary', disabled: busy, onClick: saveConfig }, busy ? '保存中…' : '保存配置'), - selected.status === 'bound' && selected.configuredModel ? h('button', { type: 'button', className: 'btn', disabled: busy, onClick: setGlobalDefaultForSeat }, '设为全局默认') : null, - selected.modelSource === 'project' ? h('button', { type: 'button', className: 'btn', disabled: busy, onClick: clearSeatOverride }, '恢复继承全局默认') : null, - selected.modelSyncStatus === 'failed' || selected.modelSyncStatus === 'unresolved' ? h('button', { type: 'button', className: 'btn', disabled: busy, onClick: retryModelSync }, '重试同步') : null, - selected.status !== 'bound' ? h('button', { type: 'button', className: 'btn', disabled: busy, onClick: action }, actionLabel) : null, - ), - ), - ) - - return h('div', { className: 'page' }, - renderTopbar('总览', [ - h('button', { type: 'button', className: 'btn primary btn-cx', onClick: () => { setSeat('lead'); if (seatById.lead.status === 'bound') void openSeat('lead'); else setTab('settings') } }, - h('span', { className: 'cx-name' }, '丞相'), h('span', { className: 'cx-dot', 'aria-hidden': 'true' }), h('span', { className: 'cx-state' }, seatStateText(seatById.lead))), - ]), - h('section', { className: 'stats', 'aria-label': '关键指标' }, stats), - renderPendingActions(), - h('section', { 'aria-label': '席位谱系', style: { marginTop: '22px' } }, - h('div', { className: 'panel-head' }, h('h2', null, '席位谱系')), - h('div', { id: 'orgTree', ref: orgRef }, h('div', { className: 'org-rows', 'data-cols': String(orgCols) }, - h('div', { className: 'org-row org-row-3' }, wb.groups.sansheng.map(id => h('div', { className: 'org-cell', key: id, 'data-slot': id }, renderSeatNode(seatById[id])))), - h('div', { className: 'org-wires org-wires-2', 'aria-hidden': 'true' }, - h('span', { className: 'wire-v', style: { left: '50%', top: 0, height: 11 } }), - h('span', { className: 'wire-h', style: { left: '8.3333%', right: '8.3333%', top: 11 } }), - ...[8.3333, 25, 41.6667, 58.3333, 75, 91.6667].map((left, i) => h('span', { key: i, className: 'wire-v w2-b' + (i + 1), style: { left: left + '%', top: 11, height: 11 } }))), - h('div', { className: 'org-row org-row-6' }, wb.groups.liubu.map(id => h('div', { className: 'org-cell', key: id, 'data-slot': id }, renderSeatNode(seatById[id])))), - )), - ), - h('div', { className: 'grid' }, h('div', { className: 'detail-col' }, detail, workspace), h('div', { className: 'rail' }, configCard)), - h('p', { className: 'foot-note' }, '数据来自当前项目真实会话 · ' + (wb.project.boundCount + ' / ' + wb.project.seatCount + ' 席已启用')), - ) } - function renderQueuePanel() { - if (!queuePanelOpen) return null - const query = queueSearch.trim().toLowerCase() - const filtered = tasks.filter(task => { - if (!query) return true - const seatName = SEATS[task.ownerSeatId]?.label || task.ownerSeatId || '' - const haystack = [task.title, seatName, task.id, task.goal, task.requirement, task.result, taskLabel(task.status), deliveryLabel(task.deliveryState)].filter(Boolean).join(' ').toLowerCase() - return haystack.includes(query) - }) - const openTask = task => { setQueuePanelOpen(false); setSelectedTask(task) } - return h('div', { className: 'modal-backdrop', onClick: event => { if (event.target === event.currentTarget) setQueuePanelOpen(false) } }, - h('div', { className: 'modal wide', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': 'ssv-queue-title' }, - h('div', { className: 'modal-head' }, h('h3', { id: 'ssv-queue-title' }, '派工队列'), h('button', { type: 'button', className: 'modal-close', 'aria-label': '关闭', onClick: () => setQueuePanelOpen(false) }, '✕')), - h('div', { className: 'modal-toolbar' }, - h('label', { className: 'search' }, h(SearchIcon), h('input', { type: 'search', value: queueSearch, placeholder: '搜索派工记录…', 'aria-label': '搜索派工队列', onChange: event => setQueueSearch(event.target.value) })), - h('button', { type: 'button', className: 'btn', disabled: summaryBusy || busy, onClick: summarizeByShangshu }, summaryBusy ? '汇总中…' : '尚书汇总'), - h('button', { type: 'button', className: 'btn', disabled: busy, onClick: reloadTasks }, h(RefreshIcon), '刷新'), - ), - h('div', { className: 'queue-table-wrap' }, - h('div', { className: 'table-scroll' }, h('table', null, - h('thead', null, h('tr', null, ['任务', '承办席位', '状态', '结果', '耗时', '派发时间'].map(label => h('th', { key: label, scope: 'col' }, label)))), - h('tbody', null, filtered.map(task => h('tr', { key: task.id, className: 'clickable', tabIndex: 0, onClick: () => openTask(task), onKeyDown: event => { if (event.key === 'Enter') openTask(task) } }, - h('td', null, h('span', { className: 'task-name' }, task.title), h('br'), h('span', { className: 'task-id' }, task.id)), - h('td', null, SEATS[task.ownerSeatId]?.label || task.ownerSeatId || '—'), - h('td', null, h('span', { className: 'pill ' + taskTone(task.status) }, h('i'), taskLabel(task.status)), task.deliveryState && task.deliveryState !== 'none' ? h('span', { className: 'pill ' + (task.deliveryState === 'unknown' ? 'fail' : 'idle'), style: { marginLeft: '4px' } }, h('i'), deliveryLabel(task.deliveryState)) : null), - h('td', { className: 'result-cell' }, task.result ? shortText(task.result, 42) : '—'), - h('td', { className: 'dur' }, taskDurationMs(task) > 0 ? durationText(taskDurationMs(task)) : '—'), - h('td', { className: 'time' }, task.dispatchedAt ? dateText(task.dispatchedAt) : '—'), - ))), - )), - h('p', { className: 'foot-note' }, filtered.length === 0 ? '没有匹配的派工记录,换个关键词试试。' : '共 ' + filtered.length + ' 条派工记录。'), - ), - )) - } - - function renderMemory() { + function renderMemoryTab() { + const rev = memory?.revision ?? 0 const constraints = Array.isArray(memory?.constraints) ? memory.constraints : [] const acceptance = Array.isArray(memory?.acceptance) ? memory.acceptance : [] - const decisions = Array.isArray(memory?.decisions) ? memory.decisions : [] - const item = (title, meta, body, tone) => h('article', { className: 'review-card', key: title }, - h('div', { className: 'rc-head' }, h('div', { className: 'rc-title' }, title), h('span', { className: 'rc-status ' + (tone || 'pass') }, h('i'), '现行')), - h('div', { className: 'rc-meta-row' }, h('span', { className: 'rc-from' }, '项目共识'), h('span', { className: 'rc-meta' }, meta)), - h('div', { className: 'rc-excerpt' }, body || '(暂无)'), - ) - return h('div', { className: 'page' }, - renderTopbar('记忆', [ - h('span', { className: 'date' }, (wb.project.name || '项目') + ' · 项目共识 v' + (memory?.revision ?? 0)), - ]), - h('div', { className: 'settings-stack' }, - h('section', { className: 'card', 'aria-label': '项目共识' }, - h('h3', null, '项目共识 ', h('span', { className: 'seat-tag' }, 'v' + (memory?.revision ?? 0))), - h('div', { className: 'review-list' }, - item('项目目标', 'goal', memory?.goal || '尚未填写项目目标', 'pass'), - item('硬约束', (constraints.length || 0) + ' 条', constraints.join(';'), constraints.length ? 'pass' : 'idle'), - item('验收标准', (acceptance.length || 0) + ' 条', acceptance.join(';'), acceptance.length ? 'pass' : 'idle'), - ...decisions.slice(-5).map((decision, index) => item(decision.text || ('决定 ' + (index + 1)), decision.recordedAt ? dateText(decision.recordedAt) : '项目记录', decision.status === 'active' ? '现行决定' : '已归档', 'pass')), + const decisionsList = Array.isArray(memory?.decisions) ? memory.decisions : [] + + if (memoryEditing) { + return h('section', { className: 'wb-card' }, + h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } }, + h('h2', { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, '编辑项目共识 · 当前 v' + rev), + h('button', { type: 'button', className: 'wb-toast-close', onClick: () => setMemoryEditing(false) }, '取消'), + ), + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '项目目标'), + h('textarea', { rows: 2, className: 'wb-textarea', value: memoryDraft.goal, onChange: (e) => setMemoryDraft(m => ({ ...m, goal: e.target.value })) }), + ), + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '硬约束(每行一条)'), + h('textarea', { rows: 4, className: 'wb-textarea', value: memoryDraft.constraints, onChange: (e) => setMemoryDraft(m => ({ ...m, constraints: e.target.value })) }), + ), + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '验收标准(每行一条)'), + h('textarea', { rows: 3, className: 'wb-textarea', value: memoryDraft.acceptance, onChange: (e) => setMemoryDraft(m => ({ ...m, acceptance: e.target.value })) }), + ), + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '追加新决定(每行一条)'), + h('textarea', { rows: 2, className: 'wb-textarea', value: memoryDraft.decisions, placeholder: '可选:记录新增项目级决定', onChange: (e) => setMemoryDraft(m => ({ ...m, decisions: e.target.value })) }), + ), + h('div', { style: { display: 'flex', justifyContent: 'flex-end', gap: 8 } }, + h('button', { type: 'button', className: 'wb-btn-outline', onClick: () => setMemoryEditing(false) }, '取消'), + h('button', { type: 'button', className: 'wb-btn-primary', disabled: busy, onClick: () => void saveMemory() }, busy ? '保存中…' : ('保存为 v' + (rev + 1))), + ), + ) + } + + return [ + h('section', { key: 'mhero', className: 'wb-card', style: { borderLeft: '3px solid var(--ss-primary)' } }, + h('div', { style: { display: 'flex', flexWrap: 'wrap', justifyContent: 'space-between', alignItems: 'center', gap: 8 } }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } }, + h('h2', { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, '项目共识'), + h('span', { className: 'ss-pill font-mono-num is-primary' }, 'v' + rev), ), + h('button', { type: 'button', className: 'wb-btn-outline', onClick: () => setMemoryEditing(true) }, '编辑共识'), ), - h('details', { className: 'card memory-editor', 'aria-label': '编辑项目共识' }, - h('summary', null, h('span', null, '编辑项目共识'), h('span', { className: 'seat-tag' }, '可折叠')), - h('div', { className: 'cfg-grid' }, - h('label', { className: 'cfg-row', style: { gridColumn: '1 / -1' } }, '项目目标', h('textarea', { rows: 3, className: 'ssv-textarea', value: memoryDraft.goal, placeholder: '这个项目最终要达成什么', onChange: event => setMemoryDraft({ ...memoryDraft, goal: event.target.value }) })), - h('label', { className: 'cfg-row', style: { gridColumn: '1 / -1' } }, '硬约束(每行一条)', h('textarea', { rows: 3, className: 'ssv-textarea', value: memoryDraft.constraints, placeholder: '例如:不能改动线上数据', onChange: event => setMemoryDraft({ ...memoryDraft, constraints: event.target.value }) })), - h('label', { className: 'cfg-row', style: { gridColumn: '1 / -1' } }, '验收标准(每行一条)', h('textarea', { rows: 3, className: 'ssv-textarea', value: memoryDraft.acceptance, placeholder: '例如:交付前必须跑完回归测试', onChange: event => setMemoryDraft({ ...memoryDraft, acceptance: event.target.value }) })), - h('label', { className: 'cfg-row', style: { gridColumn: '1 / -1' } }, '新增决定(每行一条)', h('textarea', { rows: 2, className: 'ssv-textarea', value: memoryDraft.decisions, placeholder: '例如:先保证稳定性,再考虑样式', onChange: event => setMemoryDraft({ ...memoryDraft, decisions: event.target.value }) })), + h('p', { style: { margin: 0, lineHeight: 1.6 } }, memory?.goal || '尚未填写项目目标。保存后将自动注入各部门提示词与派工上下文。'), + ), + h('div', { key: 'mgrid1', className: 'consensus-grid' }, + h('section', { className: 'wb-card' }, + h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } }, + h('h3', { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, '硬约束'), + h('span', { className: 'font-mono-num', style: { color: 'var(--ss-muted)' } }, constraints.length + ' 条'), ), - h('div', { className: 'ws-actions' }, h('button', { type: 'button', className: 'btn primary', disabled: busy, onClick: saveMemory }, busy ? '保存中…' : '保存共识')), + constraints.length === 0 + ? h('p', { style: { margin: 0, color: 'var(--ss-muted)' } }, '暂无硬约束。') + : h('ul', { style: { margin: 0, padding: 0, listStyle: 'none', display: 'flex', flexDirection: 'column', gap: 6 } }, + constraints.map((c, idx) => h('li', { key: idx, style: { display: 'flex', gap: 8 } }, + h('span', { className: 'font-mono-num', style: { color: 'var(--ss-primary)', flexShrink: 0 } }, (idx + 1) + '.'), + h('span', { style: { lineHeight: 1.5 } }, c), + )), + ), ), - h('section', { className: 'card', 'aria-label': '成果' }, - h('h3', null, '成果登记 ', h('span', { className: 'seat-tag' }, String(artifacts.length))), - h('div', { className: 'ws-actions' }, h('button', { type: 'button', className: 'btn', onClick: () => setArtifactFormOpen(true) }, h(PlusIcon), '登记成果')), - artifacts.length === 0 ? h('p', { className: 'empty-note' }, '还没有登记成果。') : h('ul', { className: 'skill-list' }, artifacts.slice(0, 8).map(artifact => h('li', { key: artifact.id }, h('span', { className: 'skill-name' }, artifact.title), h('span', { className: 'skill-state bound' }, h('i'), artifact.path || '已登记')))), - ), - ), - ) - } - - function renderSettings() { - return h('div', { className: 'page' }, - renderTopbar('设置'), - h('div', { className: 'settings-stack' }, - h('section', { className: 'card', 'aria-label': '项目绑定' }, - h('h3', null, '项目绑定'), - h('dl', { className: 'kv' }, - h('dt', null, '当前项目'), h('dd', null, wb.project.name || '未命名项目'), - h('dt', null, '类型'), h('dd', null, '主项目'), - h('dt', null, '席位'), h('dd', null, wb.project.seatCount + ' 席'), - h('dt', null, '工作区'), h('dd', null, wb.project.workspaceId || '—'), + h('section', { className: 'wb-card' }, + h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } }, + h('h3', { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, '验收标准'), + h('span', { className: 'font-mono-num', style: { color: 'var(--ss-muted)' } }, acceptance.length + ' 条'), ), - ), - h('section', { className: 'card', 'aria-label': '席位开关' }, - h('h3', null, '席位开关'), - h('ul', { className: 'skill-list' }, SEAT_IDS.map(id => { - const seat = seatById[id] - const online = seat.status === 'bound' - return h('li', { key: id }, - h('span', { className: 'skill-name' }, seat.name + ' · ' + seat.duty), - h('span', { className: 'skill-state' + (online ? ' bound' : '') }, h('i'), online ? '已上线' : (seat.status === 'missing' ? '会话缺失' : '未上线')), - h('button', { type: 'button', className: 'skill-toggle', disabled: busy, onClick: () => { if (seat.status === 'missing') void rebuildSeat(id); else if (online) void openSeat(id); else void enableSeat(id) } }, seat.status === 'missing' ? '重建' : (online ? '打开' : '上线')), - ) - })), - ), - h('section', { className: 'card', 'aria-label': '角色职责' }, - h('h3', null, '角色职责'), - h('ul', { className: 'skill-list' }, SEAT_IDS.map(id => h('li', { key: id }, - h('span', { className: 'skill-name' }, h('b', null, SEATS[id].label)), - h('span', { className: 'skill-state bound' }, h('i'), SEATS[id].duty), - h('span', { className: 'rc-meta' }, modelLabelOf(id)), - ))), + acceptance.length === 0 + ? h('p', { style: { margin: 0, color: 'var(--ss-muted)' } }, '暂无验收标准。') + : h('ul', { style: { margin: 0, padding: 0, listStyle: 'none', display: 'flex', flexDirection: 'column', gap: 6 } }, + acceptance.map((a, idx) => h('li', { key: idx, style: { display: 'flex', gap: 8 } }, + h('span', { style: { color: 'var(--ss-success)', flexShrink: 0 } }, '✓'), + h('span', { style: { lineHeight: 1.5 } }, a), + )), + ), ), ), - ) - } - - function renderReviewPanel() { - if (!reviewPanelOpen) return null - return h('div', { className: 'modal-backdrop', onClick: event => { if (event.target === event.currentTarget) setReviewPanelOpen(false) } }, - h('div', { className: 'modal wide', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': 'ssv-review-title' }, - h('div', { className: 'modal-head' }, h('h3', { id: 'ssv-review-title' }, '待审核 · 门下复核'), h('button', { type: 'button', className: 'modal-close', 'aria-label': '关闭', onClick: () => setReviewPanelOpen(false) }, '✕')), - h('p', { className: 'foot-note' }, '只读展示当前待门下复核的任务。'), - reviewTasks.length === 0 - ? h('p', { className: 'empty-note' }, '当前没有待审核任务。') - : h('div', { className: 'review-list' }, reviewTasks.map(task => h('article', { className: 'review-card', key: task.id }, - h('div', { className: 'rc-head' }, h('div', { className: 'rc-title' }, task.title), h('span', { className: 'rc-status ' + taskTone(task.status) }, h('i'), taskLabel(task.status))), - h('div', { className: 'rc-meta-row' }, h('span', { className: 'rc-from' }, task.id || '—'), h('span', { className: 'rc-meta' }, task.dispatchedAt ? '派发 ' + dateText(task.dispatchedAt) : '尚未派发')), - h(SummaryBlock, { text: task.result || task.goal || task.requirement || '', label: '审核材料', empty: '(暂无内容)', max: 110 }), - h('div', { className: 'rc-actions' }, h('span', { className: 'spacer' }), h('button', { type: 'button', className: 'r-open', onClick: () => { setReviewPanelOpen(false); setSelectedTask(task) } }, '查看任务 →')), - ))), - ), - ) - } - - function renderDurationPanel() { - if (!durationPanelOpen) return null - const rows = tasks.map(task => ({ task, ms: taskDurationMs(task) })).filter(row => row.ms > 0).sort((a, b) => b.ms - a.ms) - return h('div', { className: 'modal-backdrop', onClick: event => { if (event.target === event.currentTarget) setDurationPanelOpen(false) } }, - h('div', { className: 'modal wide', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': 'ssv-duration-title' }, - h('div', { className: 'modal-head' }, h('h3', { id: 'ssv-duration-title' }, '单任务耗时'), h('button', { type: 'button', className: 'modal-close', 'aria-label': '关闭', onClick: () => setDurationPanelOpen(false) }, '✕')), - h('p', { className: 'foot-note' }, '按任务从派发到完成的时间累计;进行中任务算到当前时刻。'), - rows.length === 0 - ? h('p', { className: 'empty-note' }, '还没有可统计的任务耗时。') - : h('div', { className: 'table-card' }, h('div', { className: 'table-scroll' }, h('table', null, - h('thead', null, h('tr', null, ['任务', '承办', '状态', '耗时'].map(label => h('th', { key: label, scope: 'col' }, label)))), - h('tbody', null, rows.map(row => h('tr', { key: row.task.id }, - h('td', null, h('span', { className: 'task-name' }, row.task.title)), - h('td', null, SEATS[row.task.ownerSeatId]?.label || row.task.ownerSeatId || '—'), - h('td', null, h('span', { className: 'pill ' + taskTone(row.task.status) }, h('i'), taskLabel(row.task.status))), - h('td', { className: 'dur' }, durationText(row.ms)), - ))), - ))), - ), - ) - } - - function renderTokenPanel() { - if (!tokenPanelOpen) return null - return h('div', { className: 'modal-backdrop', onClick: event => { if (event.target === event.currentTarget) setTokenPanelOpen(false) } }, - h('div', { className: 'modal wide', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': 'ssv-token-title' }, - h('div', { className: 'modal-head' }, h('h3', { id: 'ssv-token-title' }, 'Token 用量'), h('button', { type: 'button', className: 'modal-close', 'aria-label': '关闭', onClick: () => setTokenPanelOpen(false) }, '✕')), - h('section', { className: 'stats', style: { marginTop: '16px' }, 'aria-label': 'Token 统计' }, - h('div', { className: 'stat' }, h('div', { className: 'label' }, 'Token 消耗'), h('div', { className: 'big' }, h('em', null, '—')), h('div', { className: 'foot' }, '待接入宿主 usage 数据')), - h('div', { className: 'stat' }, h('div', { className: 'label' }, '上下文占用'), h('div', { className: 'big' }, h('em', null, '—')), h('div', { className: 'foot' }, '统计粒度待定:项目 / 会话 / 席位')), + h('div', { key: 'mgrid2', className: 'consensus-grid' }, + h('section', { className: 'wb-card' }, + h('h3', { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, '现行决定 (' + decisionsList.length + ')'), + decisionsList.length === 0 + ? h('p', { style: { margin: 0, color: 'var(--ss-muted)' } }, '暂无记录。') + : decisionsList.slice(-6).map((dec, idx) => h('div', { key: idx, className: 'kv-box' }, + h('div', null, dec.text), + h('div', { className: 'font-mono-num', style: { color: 'var(--ss-muted)', marginTop: 4 } }, + (dec.recordedAt ? dateText(dec.recordedAt) : '项目记录') + ' · ' + (dec.status === 'active' ? '现行' : '已归档')), + )), ), - h('section', { className: 'card', style: { marginTop: '18px' }, 'aria-label': 'Token 接入说明' }, - h('h3', null, '接入说明'), - h('p', { className: 'foot-note', style: { marginTop: '8px' } }, '当前宿主尚未提供稳定的 usage 数据源,这里先占位,不展示估算值,避免假精确。接入真实用量后会展示 Token 消耗、上下文占用和消耗金额。'), + h('section', { className: 'wb-card' }, + h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } }, + h('h3', { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, '成果登记 (' + artifacts.length + ')'), + h('button', { type: 'button', className: 'frameless-btn', onClick: () => setArtifactModalOpen(true) }, PlusIcon(), ' 登记成果'), + ), + artifacts.length === 0 + ? h('p', { style: { margin: 0, color: 'var(--ss-muted)' } }, '还没有登记成果。') + : artifacts.map(a => h('div', { key: a.id, className: 'kv-box' }, + h('div', { style: { fontWeight: 500 } }, a.title), + a.path ? h('div', { className: 'font-mono-num', style: { color: 'var(--ss-primary)', wordBreak: 'break-all', marginTop: 2 } }, a.path) : null, + a.summary ? h('div', { style: { color: 'var(--ss-muted)', marginTop: 2 } }, a.summary) : null, + )), ), - )) - } - - function renderArtifactModal() { - if (!artifactFormOpen) return null - return h('div', { className: 'modal-backdrop', onClick: event => { if (event.target === event.currentTarget) setArtifactFormOpen(false) } }, - h('div', { className: 'modal', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': 'ssv-artifact-title' }, - h('div', { className: 'modal-head' }, h('h3', { id: 'ssv-artifact-title' }, '登记成果'), h('button', { type: 'button', className: 'modal-close', 'aria-label': '关闭', onClick: () => setArtifactFormOpen(false) }, '✕')), - h('div', { className: 'm-sec' }, h('span', { className: 't-label' }, '成果名称'), h('input', { type: 'text', value: artifactDraft.title, placeholder: '例如:竞品分析报告 v1', onChange: event => setArtifactDraft({ ...artifactDraft, title: event.target.value }) })), - h('div', { className: 'm-sec' }, h('span', { className: 't-label' }, '文件路径'), h('input', { type: 'text', value: artifactDraft.path, placeholder: '例如:docs/竞品分析.md', onChange: event => setArtifactDraft({ ...artifactDraft, path: event.target.value }) })), - h('div', { className: 'm-sec' }, h('span', { className: 't-label' }, '摘要'), h('textarea', { rows: 3, value: artifactDraft.summary, placeholder: '这份成果解决了什么、在哪里', onChange: event => setArtifactDraft({ ...artifactDraft, summary: event.target.value }) })), - h('div', { className: 'modal-actions' }, h('button', { type: 'button', className: 'btn primary', disabled: busy, onClick: addArtifact }, busy ? '提交中…' : '登记'), h('button', { type: 'button', className: 'btn', onClick: () => setArtifactFormOpen(false) }, '取消')), ), - ) + ] } - function renderTaskDetail() { - if (!selectedTask) return null - const task = tasks.find(item => item.id === selectedTask.id) || selectedTask - const seat = SEATS[task.ownerSeatId] - const requirement = requirements.find(item => item.id === task.requirementId && item.revision === task.requirementRevision) - const originalRequirement = task.requirementSnapshot?.originalText || task.requirement || requirement?.originalText - const taskDescription = task.goal || task.requirement - const description = taskDescription === originalRequirement ? '' : taskDescription - const consultations = task.consultations || [] - return h('div', { className: 'modal-backdrop', onClick: event => { if (event.target === event.currentTarget) setSelectedTask(null) } }, - h('div', { className: 'modal wide', role: 'dialog', 'aria-modal': 'true' }, - h('div', { className: 'modal-head' }, h('h3', null, task.title), h('button', { type: 'button', className: 'modal-close', 'aria-label': '关闭', onClick: () => setSelectedTask(null) }, '✕')), - h('div', { className: 'm-from' }, '派工编号:' + (task.id || '—') + ' · ' + (task.dispatchedAt ? '派发时间 ' + dateText(task.dispatchedAt) : '尚未派发')), - originalRequirement ? h('div', { className: 'm-sec' }, - h('span', { className: 't-label' }, '原始需求'), - h('p', { className: 'task-original-text' }, originalRequirement), - ) : null, - description || !originalRequirement ? h('div', { className: 'm-sec' }, - h('span', { className: 't-label' }, '任务说明'), - h('div', { className: 'm-rich' }, description ? renderRichText(description) : h('p', { className: 'empty-note' }, '(无任务说明)')), - ) : null, - consultations.length ? h('section', { className: 'm-sec', 'aria-label': '会商记录' }, - h('span', { className: 't-label' }, '会商记录'), - h('div', { className: 'approval-list' }, consultations.map(entry => h('article', { className: 'approval-item', key: entry.id }, - h('div', { className: 'req-meta' }, - h('span', null, (SEATS[entry.fromSeatId]?.label || entry.fromSeatId) + ' → ' + entry.toSeatIds.map(id => SEATS[id]?.label || id).join('、')), - h('span', null, dateText(entry.createdAt)), + function renderConfigTab() { + return [ + h('section', { key: 'binding', className: 'wb-card' }, + h('div', { style: { display: 'flex', flexWrap: 'wrap', justifyContent: 'space-between', alignItems: 'center', gap: 8 } }, + h('div', { style: { minWidth: 0 } }, + h('h2', { style: { margin: 0, fontSize: 14, fontWeight: 600 } }, '项目绑定与全局默认(R-001)'), + h('p', { className: 'font-mono-num truncate', style: { margin: '2px 0 0', color: 'var(--ss-muted)' } }, + (wb.project.path || wb.project.name || '—') + ' · ' + (wb.project.workspaceId || '—')), + ), + h('span', { className: 'ss-pill is-success' }, '项目隔离已生效'), + ), + ), + h('section', { key: 'seatlist', className: 'wb-card', style: { padding: 0, overflow: 'hidden', gap: 0 } }, + h('div', { style: { padding: '10px 14px', borderBottom: '1px solid var(--ss-border)', display: 'flex', flexWrap: 'wrap', justifyContent: 'space-between', alignItems: 'center', gap: 8 } }, + h('h3', { style: { margin: 0, fontSize: 12, fontWeight: 600 } }, '十席开关与模型配置'), + h('span', { style: { color: 'var(--ss-muted)' } }, '点击任一席位展开配置模型与说明'), + ), + h('div', null, SEAT_IDS.map(id => { + const seat = seatById[id] + const tone = seatTone(seat) + const expanded = expandedConfigSeatId === id + const rec = seatRecMap[id] || {} + const actLabel = seat.status === 'bound' ? '打开' : seat.status === 'missing' ? '重建' : '上线' + const actHandler = seat.status === 'bound' ? () => void openSeat(id) : seat.status === 'missing' ? () => void rebuildSeat(id) : () => void enableSeat(id) + const configured = rec.configuredModel ?? rec.model ?? null + const modelShort = shortModelName(configured) + const srcShort = rec.modelSource === 'project' ? '项目覆盖' : rec.modelSource === 'global' ? '全局默认' : '未设默认' + return h('div', { key: id, className: 'cfg-row' + (expanded ? ' is-open' : '') }, + h('div', { className: 'cfg-row-head' }, + h('button', { + type: 'button', + className: 'cfg-row-toggle', + 'aria-expanded': expanded, + onClick: () => setExpandedConfigSeatId(expanded ? null : id), + }, + h('span', { className: 'ss-dot is-' + tone }), + h('div', { className: 'cfg-seat-info' }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, minWidth: 0 } }, + h('span', { className: 'font-seal', style: { fontWeight: 700, fontSize: 14, flexShrink: 0, color: expanded ? 'var(--ss-primary)' : 'var(--ss-fg)' } }, seat.name), + h('span', { className: 'truncate', style: { color: 'var(--ss-muted)' } }, seat.duty), + ), + h('div', { style: { display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 } }, + h('span', { className: 'font-mono-num truncate' }, modelShort), + h('span', { className: 'ss-pill' + (rec.modelSource === 'project' ? ' is-primary' : '') }, srcShort), + seat.modelSyncStatus === 'failed' ? h('span', { style: { color: 'var(--ss-error)', fontWeight: 500, flexShrink: 0 } }, '同步失败') : null, + ), + ), + ), + h('div', { style: { display: 'flex', alignItems: 'center', gap: 6, paddingRight: 12, flexShrink: 0 } }, + h('button', { + type: 'button', + className: seat.status === 'pending' ? 'wb-btn-primary' : 'wb-btn-outline', + disabled: busy || seat.status === 'creating', + onClick: actHandler, + }, actLabel), + h('button', { + type: 'button', + 'aria-label': '展开配置', + style: { width: 28, height: 28, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', borderRadius: 6, color: 'var(--ss-muted)' }, + onClick: () => setExpandedConfigSeatId(expanded ? null : id), + }, ChevronDown(expanded)), + ), ), - h('p', { className: 'task-original-text' }, entry.text), - ))), - ) : null, - h('div', { className: 'm-sec' }, h('span', { className: 't-label' }, '承办与状态'), h('p', null, '承办席位:' + (seat ? seat.label : task.ownerSeatId) + ' · 模型:' + modelLabelOf(task.ownerSeatId) + ' · 状态:' + taskLabel(task.status) + (task.deliveryState && task.deliveryState !== 'none' ? ' · ' + deliveryLabel(task.deliveryState) : ''))), - task.workflowBlockage ? h('div', { className: 'm-sec' }, - h('span', { className: 't-label' }, '当前阻塞'), - h('p', null, task.workflowBlockage.label + ' · ' + task.workflowBlockage.reason), - h('button', { type: 'button', className: 'btn', disabled: busy, onClick: () => openSeat(task.ownerSeatId) }, '打开' + (seat?.label || '承办席位') + '会话'), - ) : null, - h('div', { className: 'm-sec' }, h('span', { className: 't-label' }, '任务完成情况'), h('div', { className: 'm-rich' }, task.result ? renderRichText(task.result) : h('p', { className: 'empty-note' }, '(暂无结果)'))), - h('div', { className: 'modal-actions' }, h('button', { type: 'button', className: 'btn', onClick: () => setSelectedTask(null) }, '关闭')), + expanded ? h('div', { className: 'cfg-inline-panel' }, renderModelControlsForSeat(id, saveSeatConfigFor)) : null, + ) + })), ), - ) + ] } - function renderDeliberations() { - const active = deliberations.find(item => item.status === 'running') || null - const shownId = delibSelectedId || active?.id || deliberations[0]?.id || null - const summary = deliberations.find(item => item.id === shownId) || null - const full = deliberation && deliberation.id === shownId ? deliberation : null - const shown = full || summary || null - const isActive = Boolean(shown && shown.status === 'running') - const seatLabel = id => (SEATS[id] && SEATS[id].label) || id || '—' - const stanceLabel = stance => stance === 'agree' ? '同意' : (stance === 'dissent' ? '有分歧' : '未表态') - const turnLabel = status => ({ - waiting: '待叫席', delivering: '投递中', delivered: '已叫席', failed: '叫席失败', timeout: '未回', - }[status] || '待发言') - const taskOptions = tasks.filter(task => task.kind === 'workflow' || task.kind === 'execution') - const maxText = shown && shown.maxRounds > 0 ? String(shown.maxRounds) + ' 轮' : '不限' - const missingText = shown && Array.isArray(shown.missing) && shown.missing.length - ? '未回:' + shown.missing.map(item => seatLabel(item.seatId) + '(第 ' + item.round + ' 轮 ' - + (item.reason === 'unknown' ? '发送结果未知' : item.reason === 'timeout' ? '超时' : '失败') + ')').join(';') - : '' - - const startForm = h('section', { className: 'card', 'aria-label': '发起议政' }, - h('h3', null, '发起议政'), - h('p', { className: 'foot-note' }, '三省各派代表,按中书 → 门下 → 尚书轮流发言;后发言者能看到前文。'), - h('label', { className: 'cfg-row', style: { display: 'block', marginTop: '10px' } }, '议题', - h('textarea', { - rows: 3, className: 'ssv-textarea', value: delibDraft.topic, - placeholder: '例如:多语言页面首版先做哪些语言?', - onChange: event => setDelibDraft(previous => ({ ...previous, topic: event.target.value })), - }), - ), - h('div', { className: 'cfg-grid', style: { marginTop: '8px' } }, - h('label', { className: 'cfg-row' }, '关联任务(可选)', - h('select', { - value: delibDraft.taskId, - onChange: event => setDelibDraft(previous => ({ ...previous, taskId: event.target.value })), - }, - h('option', { value: '' }, '不关联任务'), - taskOptions.map(task => h('option', { key: task.id, value: task.id }, task.id + ' · ' + task.title)), - ), - ), - h('label', { className: 'cfg-row' }, '关联需求(可选)', - h('select', { - value: delibDraft.requirementId, - onChange: event => setDelibDraft(previous => ({ ...previous, requirementId: event.target.value })), - }, - h('option', { value: '' }, '不关联需求'), - requirements.map(req => h('option', { key: req.id, value: req.id }, req.id + ' v' + req.revision + ' · ' + req.title)), - ), - ), - h('label', { className: 'cfg-row' }, '轮次上限', - h('input', { - type: 'number', min: 0, max: 20, value: delibDraft.maxRounds, - onChange: event => setDelibDraft(previous => ({ ...previous, maxRounds: event.target.value })), - }), - h('span', { className: 'foot-note' }, '默认 3;填 0 表示不限。'), - ), - ), - h('div', { className: 'ws-actions' }, - h('button', { type: 'button', className: 'btn primary', disabled: delibBusy || Boolean(active), onClick: startDeliberation }, - delibBusy ? '发起中…' : (active ? '已有进行中的议政' : '发起议政')), - ), - ) - - const activeHead = isActive - ? h('section', { className: 'card', 'aria-label': '当前议政' }, - h('div', { className: 'rc-head' }, - h('h3', null, shown.topic), - h('span', { className: 'rc-status run' }, h('i'), '进行中'), - ), - h('div', { className: 'req-meta' }, - h('span', null, '第 ' + shown.round + ' 轮 / 上限 ' + maxText), - h('span', null, '当前当值:' + (shown.currentSeatLabel || seatLabel(shown.currentSeatId))), - h('span', null, '叫席:' + turnLabel(shown.turn && shown.turn.status)), - shown.turn && shown.turn.attempts ? h('span', null, '第 ' + shown.turn.attempts + ' 次投递') : null, - ), - shown.turn && shown.turn.error ? h('p', { className: 'ssv-banner is-error' }, shown.turn.error) : null, - missingText ? h('p', { className: 'foot-note' }, missingText) : null, - shown.originSessionId ? h('p', { className: 'foot-note' }, '发起会话:' + shown.originSessionId.slice(0, 8)) : null, - shown.turn && ['failed', 'timeout'].includes(shown.turn.status) - ? h('div', { className: 'ws-actions' }, - h('button', { type: 'button', className: 'btn', disabled: delibBusy, onClick: retryDeliberation }, '重试当前席位'), - ) - : null, - h('div', { className: 'ws-actions', style: { marginTop: '10px' } }, - h('input', { - type: 'text', value: delibEndNote, placeholder: '结束或停止说明(可选)', - onChange: event => setDelibEndNote(event.target.value), - style: { flex: '1 1 180px' }, - }), - h('button', { type: 'button', className: 'btn', disabled: delibBusy, onClick: endDeliberation }, '结束并收束'), - h('button', { - type: 'button', className: 'btn', disabled: delibBusy, onClick: stopDeliberation, - title: '立刻中断当前席位,不再叫下一位', - }, '立即停止'), - ), - h('p', { className: 'foot-note' }, '「结束并收束」按正常流程生成结论;「立即停止」会立刻落状态、中断当前席位,之后不再叫下一位。'), - ) - : null - - const stoppedHead = shown && shown.status === 'stopped' - ? h('section', { className: 'card', 'aria-label': '已停止的议政' }, - h('div', { className: 'rc-head' }, - h('h3', null, shown.topic), - h('span', { className: 'rc-status fail' }, h('i'), '已停止'), - ), - h('div', { className: 'req-meta' }, - h('span', null, '停在第 ' + (shown.stoppedTurn?.round ?? shown.round) + ' 轮'), - h('span', null, '停在:' + (shown.stoppedTurn?.seatLabel || seatLabel(shown.stoppedTurn?.seatId))), - shown.stoppedAt ? h('span', null, '停止时间:' + new Date(shown.stoppedAt).toLocaleString()) : null, - ), - shown.stoppedNote ? h('p', { className: 'foot-note' }, '停止说明:' + shown.stoppedNote) : null, - h('p', { className: 'foot-note' }, '停止后不会再叫下一位;已有发言保留在下方转写。'), - ) - : null - - const transcript = shown && Array.isArray(shown.speeches) ? shown.speeches : [] - const transcriptBlock = h('section', { className: 'card', 'aria-label': '议政转写' }, - h('h3', null, '议政转写'), - transcript.length === 0 - ? h('p', { className: 'empty-note' }, '还没有发言。') - : h('div', { className: 'review-list' }, transcript.map(speech => h('article', { className: 'review-card', key: speech.id }, - h('div', { className: 'rc-head' }, - h('div', { className: 'rc-title' }, seatLabel(speech.seatId) + ' · 第 ' + speech.round + ' 轮'), - h('span', { className: 'rc-status ' + (speech.stance === 'agree' ? 'done' : speech.stance === 'dissent' ? 'fail' : 'review') }, - h('i'), stanceLabel(speech.stance)), + function renderModals() { + if (selectedTask) { + const liveTask = tasks.find(t => t.id === selectedTask.id) || selectedTask + const tm = TASK_META[liveTask.status] || { label: liveTask.status, tone: 'muted' } + const seatLabel = SEATS[liveTask.ownerSeatId]?.label || liveTask.ownerSeatId || '—' + const orig = liveTask.requirementSnapshot?.originalText || liveTask.requirement + return h('div', { className: 'wb-modal-backdrop', onClick: (e) => { if (e.target === e.currentTarget) setSelectedTask(null) } }, + h('div', { className: 'wb-modal', role: 'dialog', 'aria-modal': 'true' }, + h('div', { className: 'wb-modal-head' }, + h('div', { style: { minWidth: 0 } }, + h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, fontSize: 12 } }, + h('span', { className: 'font-mono-num', style: { color: 'var(--ss-muted)' } }, liveTask.id), + h('span', { className: 'ss-pill is-' + tm.tone }, tm.label), + h('span', { className: 'font-seal', style: { fontWeight: 700 } }, seatLabel), + ), + h('h3', { className: 'wb-modal-title', style: { marginTop: 4 } }, liveTask.title), ), - h('p', { className: 'card-summary-text', style: { whiteSpace: 'pre-wrap' } }, speech.text), - speech.openIssues ? h('p', { className: 'foot-note' }, '未决:' + speech.openIssues) : null, - speech.pending ? h('p', { className: 'foot-note' }, '本席仍有待决问题。') : null, - ))), - ) - - const conclusionBlock = shown && shown.conclusion - ? h('section', { className: 'card', 'aria-label': '议政结论' }, - h('h3', null, '结论'), - h('p', { className: 'card-summary-text', style: { whiteSpace: 'pre-wrap' } }, shown.conclusion.text), - h('p', { className: 'foot-note' }, shown.conclusion.needsUserDecision ? '有分歧或未回席位,需要用户决定。' : '三省已一致。'), - ) - : null - - const history = deliberations.filter(item => item.status !== 'running') - const historyBlock = h('section', { className: 'card', 'aria-label': '历史议政' }, - h('h3', null, '历史议政'), - history.length === 0 - ? h('p', { className: 'empty-note' }, '还没有已收束的议政。') - : h('div', { className: 'review-list' }, history.map(item => h('article', { - className: 'review-card', key: item.id, style: { cursor: 'pointer' }, - onClick: () => setDelibSelectedId(item.id), - }, - h('div', { className: 'rc-head' }, - h('div', { className: 'rc-title' }, item.topic), - h('span', { className: 'rc-status ' + (item.status === 'stopped' ? 'fail' : 'done') }, h('i'), item.status === 'stopped' ? '已停止' : '已收束'), + h('button', { type: 'button', className: 'wb-modal-close', 'aria-label': '关闭', onClick: () => setSelectedTask(null) }, '✕'), + ), + h('div', { className: 'wb-modal-body' }, + liveTask.kind === 'workflow' ? renderStageStepper(liveTask.stage) : null, + orig ? h('div', { style: { borderRadius: 8, border: '1px solid color-mix(in srgb,var(--ss-primary) 30%,var(--ss-border))', background: 'color-mix(in srgb,var(--ss-primary) 7%,var(--ss-card))', padding: 10 } }, + h('div', { style: { color: 'var(--ss-primary)', fontWeight: 500, marginBottom: 4 } }, '用户原话'), + h('p', { style: { margin: 0, lineHeight: 1.55 } }, '「' + orig + '」'), + ) : null, + h('div', null, + h('div', { style: { color: 'var(--ss-muted)', fontWeight: 500, marginBottom: 4 } }, '任务说明'), + h('p', { style: { margin: 0, lineHeight: 1.6, whiteSpace: 'pre-wrap' } }, liveTask.goal || '(无任务说明)'), ), - h('p', { className: 'foot-note' }, item.id + ' · 第 ' + item.round + ' 轮 · 发言 ' + item.speechCount + ' 条' - + (item.status === 'stopped' && item.stoppedTurn ? ' · 停在第 ' + item.stoppedTurn.round + ' 轮 ' + (item.stoppedTurn.seatLabel || seatLabel(item.stoppedTurn.seatId)) : '')), - item.conclusion ? h('p', { className: 'card-summary-text' }, shortText(item.conclusion.text, 140)) : null, - ))), - ) + liveTask.workflowBlockage ? h('div', { className: 'wb-alert', style: { flexDirection: 'column', alignItems: 'flex-start' } }, + h('div', { style: { fontWeight: 600 } }, '当前阻塞 · ' + liveTask.workflowBlockage.label), + h('p', { style: { margin: 0, color: 'var(--ss-fg)' } }, liveTask.workflowBlockage.reason), + h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 8 } }, + h('button', { type: 'button', className: 'wb-btn-outline', onClick: () => { setSelectedTask(null); void openSeat(liveTask.ownerSeatId) } }, '打开' + seatLabel + '会话'), + liveTask.deliveryState === 'unknown' && liveTask.deliveryId ? h('button', { + type: 'button', className: 'wb-btn-primary', disabled: busy, + onClick: () => void redispatchTask(liveTask), + }, '显式重投此任务') : null, + ), + ) : null, + Array.isArray(liveTask.consultations) && liveTask.consultations.length > 0 ? h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6 } }, + h('div', { style: { color: 'var(--ss-muted)', fontWeight: 500 } }, '会商记录 (' + liveTask.consultations.length + ')'), + liveTask.consultations.map(c => h('div', { key: c.id || c.createdAt, className: 'kv-box' }, + h('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 8, color: 'var(--ss-muted)', marginBottom: 4 } }, + h('span', { style: { color: 'var(--ss-fg)', fontWeight: 500 } }, (SEATS[c.fromSeatId]?.label || c.fromSeatId) + ' → ' + (c.toSeatIds || []).map(x => SEATS[x]?.label || x).join('、')), + h('span', { className: 'font-mono-num' }, dateText(c.createdAt)), + ), + h('div', { style: { lineHeight: 1.55 } }, c.text), + )), + ) : null, + h('div', null, + h('div', { style: { color: 'var(--ss-muted)', fontWeight: 500, marginBottom: 4 } }, '任务完成情况'), + h('div', { className: 'kv-box', style: { whiteSpace: 'pre-wrap', lineHeight: 1.6 } }, liveTask.result || liveTask.note || '(尚未回报结果)'), + ), + ), + h('div', { className: 'wb-modal-foot' }, + h('button', { type: 'button', className: 'wb-btn-outline', onClick: () => setSelectedTask(null) }, '关闭'), + ), + ), + ) + } - return h('div', { className: 'page' }, - renderTopbar('三省议政', [ - h('button', { type: 'button', className: 'btn', disabled: delibBusy, onClick: () => { void refreshDeliberations().catch(() => {}) } }, '刷新'), - active && shown && shown.id !== active.id - ? h('button', { type: 'button', className: 'btn primary', onClick: () => setDelibSelectedId(active.id) }, '回到进行中') - : null, - ]), - startForm, - activeHead, - stoppedHead, - transcriptBlock, - conclusionBlock, - historyBlock, - ) + if (durationModalOpen) { + const rows = tasks.map(t => ({ task: t, ms: taskDurationMs(t) })).filter(r => r.ms > 0).sort((a, b) => b.ms - a.ms) + return h('div', { className: 'wb-modal-backdrop', onClick: (e) => { if (e.target === e.currentTarget) setDurationModalOpen(false) } }, + h('div', { className: 'wb-modal', role: 'dialog', 'aria-modal': 'true' }, + h('div', { className: 'wb-modal-head' }, + h('h3', { className: 'wb-modal-title' }, '任务耗时与用量说明'), + h('button', { type: 'button', className: 'wb-modal-close', 'aria-label': '关闭', onClick: () => setDurationModalOpen(false) }, '✕'), + ), + h('div', { className: 'wb-modal-body' }, + rows.length === 0 + ? h('p', { style: { margin: 0, color: 'var(--ss-muted)' } }, '暂无任务耗时记录。') + : h('div', { style: { borderRadius: 8, border: '1px solid var(--ss-border)', overflow: 'hidden' } }, + h('table', { className: 'queue-table' }, + h('thead', null, h('tr', null, h('th', null, '任务'), h('th', null, '承办'), h('th', { style: { textAlign: 'right' } }, '耗时'))), + h('tbody', null, rows.map(r => h('tr', { key: r.task.id }, + h('td', null, r.task.title), + h('td', { className: 'font-seal', style: { fontWeight: 700 } }, SEATS[r.task.ownerSeatId]?.label || '—'), + h('td', { className: 'font-mono-num', style: { textAlign: 'right' } }, durationText(r.ms)), + ))), + ), + ), + h('div', { className: 'kv-box', style: { color: 'var(--ss-muted)', lineHeight: 1.6 } }, + h('strong', { style: { color: 'var(--ss-fg)' } }, '关于 Token 与金额统计:'), + '宿主尚未提供稳定 usage 数据源,这里不展示估算或虚构金额,接入真实用量后会在此呈现。'), + ), + ), + ) + } + + if (artifactModalOpen) { + return h('div', { className: 'wb-modal-backdrop', onClick: (e) => { if (e.target === e.currentTarget) setArtifactModalOpen(false) } }, + h('div', { className: 'wb-modal', role: 'dialog', 'aria-modal': 'true' }, + h('div', { className: 'wb-modal-head' }, + h('h3', { className: 'wb-modal-title' }, '登记项目成果'), + h('button', { type: 'button', className: 'wb-modal-close', 'aria-label': '关闭', onClick: () => setArtifactModalOpen(false) }, '✕'), + ), + h('div', { className: 'wb-modal-body' }, + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '成果名称'), + h('input', { type: 'text', className: 'wb-input', value: artifactDraft.title, placeholder: '例如:竞品分析报告 v1', onChange: (e) => setArtifactDraft(p => ({ ...p, title: e.target.value })) }), + ), + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '文件路径'), + h('input', { type: 'text', className: 'wb-input', value: artifactDraft.path, placeholder: '例如:docs/竞品分析.md', onChange: (e) => setArtifactDraft(p => ({ ...p, path: e.target.value })) }), + ), + h('label', { style: { display: 'flex', flexDirection: 'column', gap: 4 } }, + h('span', { style: { color: 'var(--ss-muted)' } }, '摘要'), + h('textarea', { rows: 3, className: 'wb-textarea', value: artifactDraft.summary, placeholder: '这份成果解决了什么、在哪里', onChange: (e) => setArtifactDraft(p => ({ ...p, summary: e.target.value })) }), + ), + ), + h('div', { className: 'wb-modal-foot' }, + h('button', { type: 'button', className: 'wb-btn-outline', onClick: () => setArtifactModalOpen(false) }, '取消'), + h('button', { type: 'button', className: 'wb-btn-primary', disabled: busy, onClick: () => void addArtifact() }, busy ? '提交中…' : '登记成果'), + ), + ), + ) + } + return null } - function renderChatDeliberations() { - const avatars = view?.project?.avatars ?? {} - const active = deliberations.find(item => item.status === 'running') || null - const shownId = delibSelectedId || active?.id || deliberations[0]?.id || null - const summary = deliberations.find(item => item.id === shownId) || null - const full = deliberation && deliberation.id === shownId ? deliberation : null - const shown = full || summary || null - const isActive = Boolean(shown && shown.status === 'running') - const currentSeat = isActive ? (shown.currentSeatId || shown.turn?.seatId || null) : null - const seatLabel = id => (SEATS[id] && (SEATS[id].name || SEATS[id].label)) || id || '—' - const statusText = !shown ? '还没有议政' : isActive - ? '第 ' + shown.round + ' 轮 · ' + (currentSeat ? seatLabel(currentSeat) + '正在说' : '等待叫席') - : shown.status === 'stopped' - ? '停在第 ' + (shown.stoppedTurn?.round ?? shown.round) + ' 轮 · ' + (shown.stoppedTurn?.seatLabel || seatLabel(shown.stoppedTurn?.seatId)) - : '已收束 · 第 ' + shown.round + ' 轮' - const statusTone = isActive ? 'run' : shown?.status === 'stopped' ? 'fail' : 'done' + function renderMainBody() { + if (phase === 'loading') return h('div', { className: 'wb-empty-box' }, '正在载入项目工作台…') + if (phase === 'no-workspace') return h('div', { className: 'wb-empty-box' }, '当前会话尚未关联工作区,请在宿主中打开项目文件夹后重试。') + if (phase === 'error' && !view) { + return h('div', { className: 'wb-alert', style: { flexDirection: 'column', alignItems: 'flex-start' } }, + h('span', null, error || '工作台加载失败'), + errorRetryable ? h('button', { type: 'button', className: 'wb-btn-primary', onClick: () => void loadProject() }, '重试') : null, + ) + } + if (tab === 'flow') return renderFlowTab() + if (tab === 'deliberation') return renderDeliberationTab() + if (tab === 'memory') return renderMemoryTab() + if (tab === 'config') return renderConfigTab() + return renderCourtTab() + } - const statusBar = h('div', { className: 'card', style: { display: 'flex', alignItems: 'center', gap: 10, padding: '8px 12px', marginBottom: 6 } }, - h('span', { className: 'rc-status ' + statusTone }, h('i'), isActive ? '进行中' : shown?.status === 'stopped' ? '已停止' : '已收束'), - h('span', { style: { fontSize: 13 } }, statusText), - h('span', { style: { flex: 1 } }), - shown?.id ? h('span', { className: 'foot-note' }, shown.id) : null, - isActive ? h('button', { - type: 'button', className: 'btn', title: '立刻中断当前席位,不再叫下一位', - style: { height: 24, padding: '0 8px', fontSize: 12 }, disabled: delibBusy, onClick: stopDeliberation, - }, '停止') : null, - ) + const navTabs = [ + { id: 'court', label: '朝堂', badge: pendingCount > 0 ? String(pendingCount) : null, tone: 'primary' }, + { id: 'flow', label: '流转', badge: openTasksCount > 0 ? String(openTasksCount) : null, tone: 'primary' }, + { id: 'deliberation', label: '议政', badge: activeDelib ? '进行中' : null, tone: 'success' }, + { id: 'memory', label: '共识', badge: (memory?.revision ?? 0) > 0 ? ('v' + memory.revision) : null, tone: 'muted' }, + { id: 'config', label: '配置', badge: syncIssues > 0 ? String(syncIssues) : null, tone: 'error' }, + ] - const seatRow = h('div', { style: { display: 'flex', gap: 10, alignItems: 'center', margin: '2px 0 8px' } }, - DELIB_SEATS.map(seatId => h('button', { - key: seatId, type: 'button', title: '换' + seatLabel(seatId) + '头像', - style: { - display: 'flex', alignItems: 'center', gap: 6, background: 'none', border: 'none', cursor: 'pointer', padding: 2, - opacity: !isActive || currentSeat === seatId ? 1 : 0.5, + const headerDotTone = syncIssues > 0 ? 'is-error' : runningSeatsCount > 0 ? 'is-success is-pulse' : 'is-muted' + + return h('div', { className: 'ssv2 ssw-tab-body', 'data-sansheng-sidebar': '1' }, + h('header', { className: 'wb-header' }, + h('div', { className: 'wb-header-row' }, + h('div', { className: 'wb-brand' }, + h('div', { className: 'wb-seal-badge' }, '省'), + h('div', { style: { minWidth: 0 } }, + h('div', { className: 'wb-brand-title-row' }, + h('h1', { className: 'wb-brand-title' }, '三省六部'), + h('span', { className: 'wb-role-badge hide-narrow' }, '单项目侧栏'), + ), + h('p', { className: 'wb-subline' }, + activeChatSeatId + ? ('固定绑定当前会话项目 · 当前对话:' + (SEATS[activeChatSeatId]?.label || activeChatSeatId)) + : ('固定绑定当前会话项目 · ' + wb.project.boundCount + ' / ' + wb.project.seatCount + ' 席已绑定')), + ), + ), + h('span', { className: 'wb-proj-pill', title: '已固定绑定当前会话所属项目' }, + h('span', { className: 'ss-dot ' + headerDotTone }), + h('span', { className: 'wb-proj-name' }, wb.project.name || wb.projectTitle || '当前项目'), + ), + ), + h('nav', { className: 'wb-tabs', role: 'tablist', 'aria-label': '工作台导航' }, + navTabs.map(t => h('button', { + key: t.id, + type: 'button', + role: 'tab', + 'aria-selected': tab === t.id, + className: 'wb-tab-btn' + (tab === t.id ? ' is-active' : ''), + onClick: () => setTab(t.id), }, - onClick: () => setAvatarEdit(previous => previous?.seatId === seatId ? null : { seatId, char: '' }), - }, avatarNode(seatId, avatars, 30, isActive && currentSeat === seatId), h('span', { style: { fontSize: 12 } }, seatLabel(seatId)))), - h('span', { style: { flex: 1 } }), - h('button', { - type: 'button', className: 'btn', style: { height: 24, padding: '0 8px', fontSize: 12 }, - onClick: () => setDelibSettingsOpen(value => !value), - }, '设置'), - ) - - const settings = delibSettingsOpen ? h('div', { className: 'card', style: { padding: 10, marginBottom: 6, display: 'flex', gap: 10, flexWrap: 'wrap', alignItems: 'end' } }, - h('label', { className: 'cfg-row' }, '轮次上限', - h('input', { - type: 'number', min: 0, max: 20, value: delibDraft.maxRounds, style: { width: 64 }, - onChange: event => setDelibDraft(prev => ({ ...prev, maxRounds: event.target.value })), - }), - ), - h('label', { className: 'cfg-row' }, '关联任务', - h('select', { value: delibDraft.taskId, onChange: event => setDelibDraft(prev => ({ ...prev, taskId: event.target.value })) }, - h('option', { value: '' }, '不关联'), - tasks.filter(task => task.kind === 'workflow' || task.kind === 'execution').map(task => h('option', { key: task.id, value: task.id }, task.id + ' ' + task.title)), - ), - ), - h('label', { className: 'cfg-row' }, '关联需求', - h('select', { value: delibDraft.requirementId, onChange: event => setDelibDraft(prev => ({ ...prev, requirementId: event.target.value })) }, - h('option', { value: '' }, '不关联'), - requirements.map(req => h('option', { key: req.id, value: req.id }, req.id + ' v' + req.revision + ' ' + req.title)), - ), - ), - h('span', { className: 'foot-note' }, '默认 3 轮,填 0 表示不限'), - ) : null - - const avatarEditor = avatarEdit ? h('div', { className: 'card', style: { padding: 10, marginBottom: 6 } }, - h('div', { style: { display: 'flex', gap: 10, alignItems: 'center', flexWrap: 'wrap' } }, - avatarNode(avatarEdit.seatId, avatars, 40), - h('label', { className: 'btn', style: { cursor: 'pointer' } }, '选图片', - h('input', { - type: 'file', accept: 'image/png,image/jpeg,image/webp', style: { display: 'none' }, - onChange: event => { const file = event.target.files?.[0]; if (file) void pickAvatarFile(avatarEdit.seatId, file); event.target.value = '' }, - }), - ), - h('input', { - type: 'text', maxLength: 8, placeholder: '或填一个字/emoji', value: avatarEdit.char, style: { width: 130 }, - onChange: event => setAvatarEdit(prev => ({ ...prev, char: event.target.value })), - }), - h('button', { type: 'button', className: 'btn primary', disabled: delibBusy || !avatarEdit.char.trim(), onClick: () => void saveAvatar(avatarEdit.seatId, { char: avatarEdit.char.trim() }) }, '保存字符'), - h('button', { type: 'button', className: 'btn', disabled: delibBusy, onClick: () => void saveAvatar(avatarEdit.seatId, { clear: true }) }, '恢复默认'), - h('span', { style: { flex: 1 } }), - h('button', { type: 'button', className: 'btn', onClick: () => setAvatarEdit(null) }, '关闭'), - ), - h('p', { className: 'foot-note' }, '图片缩到 256×256 后保存,限 120KB;默认头像沿用席位名。'), - ) : null - - const transcript = shown?.speeches ?? [] - const bubbles = transcript.length === 0 - ? h('p', { className: 'empty-note', style: { textAlign: 'center', padding: '34px 0' } }, '还没开始议政,说一句就能开。') - : h('div', { style: { display: 'flex', flexDirection: 'column', gap: 12, padding: '6px 2px 10px' } }, - transcript.map(speech => h('div', { key: speech.id, style: { display: 'flex', gap: 10, alignItems: 'flex-start' } }, - avatarNode(speech.seatId, avatars, 32, isActive && currentSeat === speech.seatId), - h('div', { style: { maxWidth: '78%' } }, - h('div', { style: { fontSize: 12, color: '#6b7280', marginBottom: 3 } }, - seatLabel(speech.seatId) + ' · 第 ' + speech.round + ' 轮' - + (speech.stance === 'dissent' ? ' · 有分歧' : speech.pending ? ' · 仍有待决' : '')), - h('div', { - style: { - background: speech.seatId === 'zhongshu' ? '#eef2ff' : speech.seatId === 'menxia' ? '#e6fcf5' : '#fff4e6', - borderRadius: 12, padding: '9px 12px', fontSize: 14, lineHeight: 1.65, whiteSpace: 'pre-wrap', - }, - }, speech.text), - speech.openIssues ? h('div', { className: 'foot-note', style: { marginTop: 4 } }, '未决:' + speech.openIssues) : null, - ), - )), - ) - const stoppedNote = shown?.status === 'stopped' - ? h('p', { className: 'foot-note', style: { textAlign: 'center', padding: '5px 0 8px' } }, - '停在第 ' + (shown.stoppedTurn?.round ?? shown.round) + ' 轮 · ' + (shown.stoppedTurn?.seatLabel || seatLabel(shown.stoppedTurn?.seatId)) - + ',不会再叫下一位。' + (shown.stoppedNote ? ' 说明:' + shown.stoppedNote : '')) - : null - const conclusion = shown?.conclusion && !isActive - ? h('section', { className: 'card', style: { marginTop: 8 } }, - h('h3', null, '结论'), - h('p', { className: 'card-summary-text', style: { whiteSpace: 'pre-wrap' } }, shown.conclusion.text), - ) - : null - - const composer = h('div', { className: 'card', style: { display: 'flex', gap: 8, alignItems: 'center', marginTop: 8, padding: 8 } }, - h('input', { - type: 'text', value: delibDraft.topic, placeholder: isActive ? '这一场还在进行,先看他们说完' : '说一句要三省议的事…', - disabled: Boolean(active), style: { flex: 1, minWidth: 0 }, - onChange: event => setDelibDraft(prev => ({ ...prev, topic: event.target.value })), - onKeyDown: event => { if (event.key === 'Enter' && !active) void startDeliberation() }, - }), - h('button', { type: 'button', className: 'btn primary', disabled: delibBusy || Boolean(active) || !delibDraft.topic.trim(), onClick: startDeliberation }, - delibBusy ? '发起中…' : '发起'), - ) - - const runsBlock = agentRuns.length - ? h('section', { className: 'card', style: { marginTop: 8 } }, - h('h3', null, '后台子 Agent'), - h('div', { className: 'review-list' }, agentRuns.map(run => h('div', { key: run.id, className: 'review-card', style: { display: 'flex', alignItems: 'center', gap: 8 } }, - h('span', { className: 'rc-title', style: { flex: 1, fontSize: 13 } }, - (run.label || run.seatId) + (run.deliberationId ? ' · ' + run.deliberationId + ' 第 ' + run.round + ' 轮' : '') - + (run.kind === 'order' && run.brief ? ' · ' + shortText(run.brief, 36) : '')), - h('button', { type: 'button', className: 'btn', disabled: delibBusy, onClick: () => void stopAgentRun(run) }, '停止'), - ))), - ) - : null - - const history = deliberations.filter(item => item.status !== 'running') - const historyBlock = history.length - ? h('section', { className: 'card', style: { marginTop: 8 } }, - h('h3', null, '历史议政'), - h('div', { className: 'review-list' }, history.slice(0, 6).map(item => h('button', { - key: item.id, type: 'button', className: 'review-card', style: { textAlign: 'left', cursor: 'pointer' }, - onClick: () => setDelibSelectedId(item.id), - }, - h('span', { className: 'rc-title' }, item.topic), - h('span', { className: 'foot-note' }, item.id + ' · ' + (item.status === 'stopped' ? '已停止' : '已收束') + ' · 发言 ' + item.speechCount + ' 条'), - ))), - ) - : null - - return h('div', { className: 'page' }, - renderTopbar('三省议政', [ - h('button', { type: 'button', className: 'btn', disabled: delibBusy, onClick: () => { void refreshDeliberations().catch(() => {}) } }, '刷新'), - ]), - statusBar, - seatRow, - settings, - avatarEditor, - h('div', { className: 'card', style: { padding: '2px 10px' } }, bubbles, stoppedNote), - composer, - runsBlock, - conclusion, - historyBlock, - ) - } - - function renderPage() { - if (phase === 'loading') return h('div', { className: 'page' }, h('p', { className: 'empty-note' }, '正在载入工作台…')) - if (phase === 'no-workspace') return h('div', { className: 'page' }, h('p', { className: 'empty-note' }, '请先在宿主中选择或建立一个项目工作区,再打开三省六部工作台。')) - if (phase === 'error' && !view) return h('div', { className: 'page' }, h('p', { className: 'ssv-banner is-error', role: 'alert' }, error || '工作台加载失败'), errorRetryable ? h('div', { className: 'ws-actions' }, h('button', { type: 'button', className: 'btn primary', onClick: loadProject }, '重试')) : null) - if (page === 'deliberations') return renderChatDeliberations() - if (tab === 'memory') return renderMemory() - if (tab === 'settings') return renderSettings() - return renderOverview() - } - - return h('div', { className: 'ssv2 ssw-tab-body' }, - h('div', { className: 'main' }, - h('div', { className: 'panel-top' }, - h('div', { className: 'brand' }, h('span', { className: 'seal' }, '三省六部'), h('span', { className: 'sub' }, 'DSH 工作台')), - tab !== 'overview' || page !== 'overview' ? h('div', { className: 'panel-actions' }, - h('button', { type: 'button', className: 'btn' + (page === 'overview' && tab === 'overview' ? ' primary' : ''), onClick: () => { setPage('overview'); setTab('overview') } }, '概览'), - h('button', { type: 'button', className: 'btn' + (page === 'deliberations' ? ' primary' : ''), onClick: () => setPage('deliberations') }, '议政'), - tab !== 'overview' ? h('button', { type: 'button', className: 'btn', onClick: () => setTab('overview') }, '← 总览') : null, - ) : h('div', { className: 'panel-actions' }, - h('button', { type: 'button', className: 'btn primary', onClick: () => { setPage('overview'); setTab('overview') } }, '概览'), - h('button', { type: 'button', className: 'btn', onClick: () => setPage('deliberations') }, '议政'), - ), - ), - statusBanner, - renderPage(), - h('div', { className: 'project-dock' }, - h('button', { type: 'button', className: 'proj', 'aria-label': '当前项目', onClick: () => setTab('settings') }, - h('span', { className: 'dot' }), - h('span', null, h('span', { className: 'name' }, wb.project.name || wb.projectTitle || '当前项目'), h('br'), h('span', { className: 'meta' }, '主项目 · ' + wb.project.seatCount + ' 席')), - h('span', { className: 'ssv-proj-caret' }, '⌄')), + h('span', null, t.label), + t.badge ? h('span', { className: 'wb-tab-badge ss-pill is-' + t.tone }, t.badge) : null, + )), ), ), - renderArtifactModal(), - renderTaskDetail(), - renderReviewPanel(), - renderDurationPanel(), - renderQueuePanel(), - renderTokenPanel(), + + error && view ? h('div', { className: 'wb-toast-wrap' }, + h('div', { className: 'wb-toast-box is-error', role: 'alert' }, + h('span', null, error), + h('button', { type: 'button', className: 'wb-toast-close', onClick: () => setError(null) }, '✕'), + ), + ) : (!error && notice ? h('div', { className: 'wb-toast-wrap' }, + h('div', { className: 'wb-toast-box is-primary', role: 'status' }, + h('span', null, notice), + h('button', { type: 'button', className: 'wb-toast-close', onClick: () => setNotice(null) }, '✕'), + ), + ) : null), + + h('main', { className: 'wb-body' }, renderMainBody()), + + h('footer', { className: 'wb-footer' }, + h('span', { className: 'truncate' }, + '项目 ' + (wb.project.name || '—') + ' · ' + wb.project.boundCount + ' / ' + wb.project.seatCount + ' 席已绑定 · 共识 v' + (memory?.revision ?? 0)), + h('button', { type: 'button', className: 'wb-refresh-btn', disabled: busy, onClick: () => void loadProject() }, + RefreshIcon(), + h('span', null, '刷新'), + ), + ), + + renderModals(), ) } diff --git a/sansheng/test/master-model.test.js b/sansheng/test/master-model.test.js new file mode 100644 index 0000000..9bbdc16 --- /dev/null +++ b/sansheng/test/master-model.test.js @@ -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/) +})