fix(workbench): 优化右栏布局与统计交互
This commit is contained in:
parent
1ba2f249ac
commit
710c59cea4
|
|
@ -448,6 +448,116 @@ function dateLabel() {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
function taskDurationMs(task) {
|
||||
if (!task) return 0;
|
||||
const start = 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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 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 ResultSummary(props) {
|
||||
const [expanded, setExpanded] = (0, import_react.useState)(false);
|
||||
const text = String(props && props.text ? props.text : "").trim();
|
||||
const label = props && props.label ? props.label : "摘要";
|
||||
const empty = props && props.empty ? props.empty : "(暂无内容)";
|
||||
if (!text) {
|
||||
return (0, import_react.createElement)(
|
||||
"div",
|
||||
{ className: "result-summary is-empty" },
|
||||
label ? (0, import_react.createElement)("span", { className: "t-label" }, label) : null,
|
||||
(0, import_react.createElement)("span", { className: "rs-empty" }, empty)
|
||||
);
|
||||
}
|
||||
const parsed = splitResultText(text);
|
||||
return (0, import_react.createElement)(
|
||||
"div",
|
||||
{ className: "result-summary" + (expanded ? " is-expanded" : "") },
|
||||
(0, import_react.createElement)(
|
||||
"div",
|
||||
{ className: "rs-line" },
|
||||
label ? (0, import_react.createElement)("span", { className: "t-label" }, label) : null,
|
||||
(0, import_react.createElement)("span", { className: "rs-summary" }, parsed.summary)
|
||||
),
|
||||
parsed.points.length > 0 ? (0, import_react.createElement)("ul", { className: "rs-points" }, parsed.points.map((point, index) => (0, import_react.createElement)("li", { key: index }, point))) : null,
|
||||
parsed.hasMore || parsed.points.length > 0 || text.includes("\n") ? (0, import_react.createElement)("button", { type: "button", className: "rs-toggle", onClick: () => setExpanded((value) => !value), "aria-expanded": expanded ? "true" : "false" }, expanded ? "收起详情" : "展开详情") : null,
|
||||
expanded ? (0, import_react.createElement)("div", { className: "rs-detail" }, renderRichText(text)) : null
|
||||
);
|
||||
}
|
||||
function fileIcon(paths, size) {
|
||||
return (0, import_react.createElement)(
|
||||
"svg",
|
||||
|
|
@ -498,11 +608,10 @@ function WorkbenchV2(props) {
|
|||
return SEAT_IDS.includes(saved) ? saved : SEAT_IDS[0];
|
||||
});
|
||||
const [tab, setTab] = (0, import_react.useState)("overview");
|
||||
const [seatFilter, setSeatFilter] = (0, import_react.useState)("all");
|
||||
const [queueFilter, setQueueFilter] = (0, import_react.useState)("all");
|
||||
const [queueSearch, setQueueSearch] = (0, import_react.useState)("");
|
||||
const [selectedTask, setSelectedTask] = (0, import_react.useState)(null);
|
||||
const [taskForm, setTaskForm] = (0, import_react.useState)(null);
|
||||
const [reviewPanelOpen, setReviewPanelOpen] = (0, import_react.useState)(false);
|
||||
const [durationPanelOpen, setDurationPanelOpen] = (0, import_react.useState)(false);
|
||||
const [draft, setDraft] = (0, import_react.useState)({});
|
||||
const [busy, setBusy] = (0, import_react.useState)(false);
|
||||
const [summaryBusy, setSummaryBusy] = (0, import_react.useState)(false);
|
||||
|
|
@ -720,22 +829,6 @@ function WorkbenchV2(props) {
|
|||
if (alive.current) setBusy(false);
|
||||
}
|
||||
}
|
||||
async function enableAllSeats() {
|
||||
if (!projectId) return;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
setNotice("正在启用十席…");
|
||||
try {
|
||||
const next = await request("enable", { projectId });
|
||||
if (!alive.current) return;
|
||||
setView(next);
|
||||
setNotice("十席已启用(建立独立会话,不自动运行模型)");
|
||||
} 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;
|
||||
|
|
@ -795,61 +888,6 @@ function WorkbenchV2(props) {
|
|||
if (alive.current) setNotice(error2 && error2.message ? error2.message : "任务列表刷新失败");
|
||||
}
|
||||
}
|
||||
function openTaskForm(ownerSeatId) {
|
||||
setTaskForm({ ownerSeatId: ownerSeatId || "gongbu", title: "", goal: "", dispatchNow: true });
|
||||
}
|
||||
async function submitTaskForm() {
|
||||
if (!projectId || !taskForm) return;
|
||||
const title = taskForm.title.trim();
|
||||
if (!title) {
|
||||
setNotice("任务标题不能为空");
|
||||
return;
|
||||
}
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const created = await request("taskCreate", { projectId, title, goal: taskForm.goal, ownerSeatId: taskForm.ownerSeatId });
|
||||
const task = created && created.task ? created.task : null;
|
||||
if (taskForm.dispatchNow && task && task.id) {
|
||||
const delivered = await request("taskDispatch", { projectId, taskId: task.id });
|
||||
setNotice(delivered && delivered.delivered ? "已派工到「" + (SEATS[taskForm.ownerSeatId]?.label ?? "") + "」会话。" : "任务已记录,但宿主未直接送达。");
|
||||
} else setNotice("已存为草稿;可在任务详情中点「派工」。");
|
||||
setTaskForm(null);
|
||||
await reloadTasks();
|
||||
} catch (error2) {
|
||||
if (alive.current) setError(error2 && error2.message ? error2.message : "新建任务失败");
|
||||
} finally {
|
||||
if (alive.current) setBusy(false);
|
||||
}
|
||||
}
|
||||
async function dispatchTask(taskId) {
|
||||
if (!projectId) return;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const result = await request("taskDispatch", { projectId, taskId });
|
||||
await reloadTasks();
|
||||
setNotice(result && result.delivered ? "已派工到该部门会话。" : "已记录为待执行(当前宿主暂不支持直接发送)。");
|
||||
} catch (error2) {
|
||||
if (alive.current) setError(error2 && error2.message ? error2.message : "派工失败");
|
||||
} finally {
|
||||
if (alive.current) setBusy(false);
|
||||
}
|
||||
}
|
||||
async function cancelTask(taskId) {
|
||||
if (!projectId) return;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
await request("taskCancel", { projectId, taskId });
|
||||
await reloadTasks();
|
||||
setNotice("任务已取消。");
|
||||
} catch (error2) {
|
||||
if (alive.current) setError(error2 && error2.message ? error2.message : "取消失败");
|
||||
} finally {
|
||||
if (alive.current) setBusy(false);
|
||||
}
|
||||
}
|
||||
async function summarizeByShangshu() {
|
||||
if (!projectId) return;
|
||||
setSummaryBusy(true);
|
||||
|
|
@ -890,13 +928,9 @@ function WorkbenchV2(props) {
|
|||
const todayStart = TODAY();
|
||||
const todayTasks = tasks.filter((task) => Number(task.createdAt) >= todayStart);
|
||||
const todayDone = todayTasks.filter((task) => task.status === "done");
|
||||
const todayRunning = todayTasks.filter((task) => task.status === "running" || task.status === "dispatched");
|
||||
const todayDraft = todayTasks.filter((task) => task.status === "draft");
|
||||
const reviewTasks = tasks.filter((task) => task.ownerSeatId === "menxia" && OPEN_STATUS.has(task.status));
|
||||
const runningSeats = wb.seats.filter((seat) => seat.status === "bound" || seat.status === "creating").length;
|
||||
const waitingSeats = wb.seats.filter((seat) => seat.status === "pending").length;
|
||||
const durations = todayDone.map((task) => Number(task.resultAt) - Number(task.createdAt)).filter((ms) => Number.isFinite(ms) && ms > 0);
|
||||
const avgMs = durations.length ? durations.reduce((a, b) => a + b, 0) / durations.length : null;
|
||||
const anomalyTasks = tasks.filter((task) => task.status === "failed" || task.deliveryState === "failed");
|
||||
const projectDurationMs = tasks.reduce((sum, task) => sum + taskDurationMs(task), 0);
|
||||
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;
|
||||
}
|
||||
|
|
@ -925,6 +959,7 @@ function WorkbenchV2(props) {
|
|||
{ id: "overview", label: "总览", icon: ["M3 3h7v9H3z", "M14 3h7v5h-7z", "M14 12h7v9h-7z", "M3 16h7v5H3z"] },
|
||||
{ id: "queue", label: "派工队列", icon: ["m22 2-7 20-4-9-9-4Z", "M22 2 11 13"] },
|
||||
{ id: "memory", label: "记忆", icon: ["M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"] },
|
||||
{ id: "token", label: "Token 用量", icon: ["M12 2v20", "M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"] },
|
||||
{ id: "settings", label: "设置", icon: ["M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z", "M12 12a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"] }
|
||||
];
|
||||
return (0, import_react.createElement)(
|
||||
|
|
@ -945,10 +980,9 @@ function WorkbenchV2(props) {
|
|||
function renderSeatNode(seat) {
|
||||
const tone = toneOfSeat(seat);
|
||||
const latest = latestTaskOf(seat.id);
|
||||
const dim = seatFilter !== "all" && tone !== seatFilter;
|
||||
return (0, import_react.createElement)(
|
||||
"div",
|
||||
{ key: seat.id, className: "node" + (seat.id === selectedSeatId ? " selected" : "") + (dim ? " dim" : ""), "data-seat": seat.id },
|
||||
{ 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" },
|
||||
|
|
@ -963,32 +997,35 @@ function WorkbenchV2(props) {
|
|||
function renderOverview() {
|
||||
const stats = [
|
||||
(0, import_react.createElement)(
|
||||
"div",
|
||||
{ className: "stat", key: "running" },
|
||||
(0, import_react.createElement)("div", { className: "label" }, "运行中席位"),
|
||||
(0, import_react.createElement)("div", { className: "big" }, (0, import_react.createElement)("em", null, String(runningSeats)), (0, import_react.createElement)("span", { className: "unit" }, " / " + wb.project.seatCount + " 席")),
|
||||
(0, import_react.createElement)("div", { className: "foot" }, "待命 ", (0, import_react.createElement)("b", null, String(waitingSeats)), " · 待复核 ", (0, import_react.createElement)("b", null, String(reviewTasks.length)))
|
||||
"button",
|
||||
{ type: "button", className: "stat stat-link", key: "cost", onClick: () => setTab("token") },
|
||||
(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)(
|
||||
"div",
|
||||
{ className: "stat", key: "today" },
|
||||
(0, import_react.createElement)("div", { className: "label" }, "今日派工"),
|
||||
(0, import_react.createElement)("div", { className: "big" }, String(todayTasks.length), " ", (0, import_react.createElement)("span", { className: "unit" }, "条")),
|
||||
(0, import_react.createElement)("div", { className: "foot" }, "已完成 ", (0, import_react.createElement)("b", null, String(todayDone.length)), " · 进行中 ", (0, import_react.createElement)("b", null, String(todayRunning.length)), " · 待派发 ", (0, import_react.createElement)("b", null, String(todayDraft.length)))
|
||||
"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)(
|
||||
"div",
|
||||
{ className: "stat", key: "review" },
|
||||
(0, import_react.createElement)("div", { className: "label" }, "待门下复核"),
|
||||
"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)("div", { className: "foot" }, "待门下复核")
|
||||
),
|
||||
(0, import_react.createElement)(
|
||||
"div",
|
||||
{ className: "stat", key: "avg" },
|
||||
(0, import_react.createElement)("div", { className: "label" }, "今日平均单程耗时"),
|
||||
(0, import_react.createElement)("div", { className: "big" }, avgMs ? durationText(avgMs) : "—"),
|
||||
(0, import_react.createElement)("div", { className: "foot" }, todayDone.length ? "按 " + todayDone.length + " 条已完成任务计算" : "今日暂无完成记录")
|
||||
"button",
|
||||
{ type: "button", className: "stat stat-link", key: "anomaly", onClick: () => {
|
||||
setQueueSearch("失败");
|
||||
setTab("queue");
|
||||
} },
|
||||
(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;
|
||||
|
|
@ -1017,26 +1054,25 @@ function WorkbenchV2(props) {
|
|||
(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)("span", { className: "t-label" }, "最近产出摘录"), (0, import_react.createElement)("span", null, excerpt))
|
||||
(0, import_react.createElement)("div", { className: "excerpt" }, (0, import_react.createElement)(ResultSummary, { text: excerpt, label: "最近产出摘录", empty: "(暂无产出)" }))
|
||||
);
|
||||
const workspace = (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,
|
||||
selected.id === "lead" ? (0, import_react.createElement)("div", { className: "ws-actions" }, (0, import_react.createElement)("button", { type: "button", className: "btn primary", onClick: () => openTaskForm("lead") }, (0, import_react.createElement)(PlusIcon), "向丞相下达")) : (0, import_react.createElement)("div", { className: "ws-actions" }, (0, import_react.createElement)("button", { type: "button", className: "btn", onClick: () => openTaskForm(selected.id) }, (0, import_react.createElement)(PlusIcon), "新建派工到" + selected.name)),
|
||||
(0, import_react.createElement)("p", { className: "foot-note ws-hint" }, "派工请在聊天中通过 sansheng_dispatch_task 下达;工作台只查看任务与结果。"),
|
||||
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)("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)("div", { className: "rc-excerpt" }, task.goal || task.requirement || "(无任务说明)"),
|
||||
(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)(ResultSummary, { text: task.goal || task.requirement || "", label: "任务说明", empty: "(无任务说明)" }),
|
||||
(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) }, "查看详情 →"),
|
||||
task.status === "draft" ? (0, import_react.createElement)("button", { type: "button", className: "btn primary", disabled: busy, onClick: () => dispatchTask(task.id) }, "派工") : null
|
||||
(0, import_react.createElement)("button", { type: "button", className: "r-open", onClick: () => setSelectedTask(task) }, "查看详情 →")
|
||||
)
|
||||
)))
|
||||
);
|
||||
|
|
@ -1063,54 +1099,57 @@ function WorkbenchV2(props) {
|
|||
const currentEffort = valueParts[2] || "";
|
||||
if (currentEffort && !effortChoices.includes(currentEffort)) effortChoices.unshift(currentEffort);
|
||||
const configCard = (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)),
|
||||
"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: "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-skills" },
|
||||
(0, import_react.createElement)("span", { className: "t-label" }, "技能绑定"),
|
||||
{ className: "dept-config-body" },
|
||||
(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))
|
||||
"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-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" ? (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: busy, onClick: action }, actionLabel) : null
|
||||
)
|
||||
),
|
||||
(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" ? (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: busy, onClick: action }, actionLabel) : null,
|
||||
(0, import_react.createElement)("button", { type: "button", className: "btn", disabled: busy, onClick: enableAllSeats }, "启用十席")
|
||||
)
|
||||
);
|
||||
return (0, import_react.createElement)(
|
||||
|
|
@ -1134,23 +1173,7 @@ function WorkbenchV2(props) {
|
|||
(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",
|
||||
{ className: "seg", role: "tablist", "aria-label": "按状态筛选席位" },
|
||||
[["all", "全部"], ["run", "运行中"], ["review", "待复核"], ["idle", "待命"]].map(([id, label]) => (0, import_react.createElement)("button", {
|
||||
key: id,
|
||||
type: "button",
|
||||
className: seatFilter === id ? "on" : "",
|
||||
role: "tab",
|
||||
"aria-selected": seatFilter === id ? "true" : "false",
|
||||
onClick: () => setSeatFilter(id)
|
||||
}, label))
|
||||
)
|
||||
),
|
||||
(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) },
|
||||
|
|
@ -1172,38 +1195,26 @@ function WorkbenchV2(props) {
|
|||
function renderQueue() {
|
||||
const query = queueSearch.trim().toLowerCase();
|
||||
const filtered = tasks.filter((task) => {
|
||||
const tone = taskTone(task.status);
|
||||
if (queueFilter !== "all" && tone !== queueFilter) return false;
|
||||
if (!query) return true;
|
||||
const seatName = SEATS[task.ownerSeatId]?.label || task.ownerSeatId || "";
|
||||
return (task.title + " " + seatName + " " + (task.id || "") + " " + (task.goal || "")).toLowerCase().includes(query);
|
||||
const haystack = [task.title, seatName, task.id, task.goal, task.requirement, task.result, taskLabel(task.status), task.deliveryState === "failed" ? "投递失败" : ""].filter(Boolean).join(" ").toLowerCase();
|
||||
return haystack.includes(query);
|
||||
});
|
||||
return (0, import_react.createElement)(
|
||||
"div",
|
||||
{ className: "page" },
|
||||
renderTopbar("派工队列", [
|
||||
(0, import_react.createElement)("button", { type: "button", className: "btn", disabled: summaryBusy || busy, onClick: summarizeByShangshu }, summaryBusy ? "汇总中…" : "尚书汇总"),
|
||||
(0, import_react.createElement)("button", { type: "button", className: "btn primary", onClick: () => openTaskForm("gongbu") }, (0, import_react.createElement)(PlusIcon), "新建派工"),
|
||||
(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: busy, onClick: reloadTasks }, (0, import_react.createElement)(RefreshIcon), "刷新"),
|
||||
(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)(
|
||||
"div",
|
||||
{ className: "seg", role: "tablist", "aria-label": "按状态筛选派工", style: { marginTop: "16px", marginLeft: 0 } },
|
||||
[["all", "全部"], ["run", "进行中"], ["review", "待复核"], ["done", "已完成"], ["fail", "失败"]].map(([id, label]) => (0, import_react.createElement)("button", {
|
||||
key: id,
|
||||
type: "button",
|
||||
className: queueFilter === id ? "on" : "",
|
||||
"aria-selected": queueFilter === id ? "true" : "false",
|
||||
onClick: () => setQueueFilter(id)
|
||||
}, label))
|
||||
),
|
||||
(0, import_react.createElement)(
|
||||
"section",
|
||||
{ className: "table-card", "aria-label": "派工队列" },
|
||||
{ className: "table-card", "aria-label": "派工队列", style: { marginTop: "18px" } },
|
||||
(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)("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: () => setSelectedTask(task), onKeyDown: (event) => {
|
||||
|
|
@ -1211,13 +1222,13 @@ function WorkbenchV2(props) {
|
|||
} },
|
||||
(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", { className: "num" }, modelLabelOf(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))),
|
||||
(0, import_react.createElement)("td", { className: "dur" }, task.resultAt && task.createdAt ? durationText(Number(task.resultAt) - Number(task.createdAt)) : "—"),
|
||||
(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 === "failed" ? (0, import_react.createElement)("span", { className: "pill fail", style: { marginLeft: "4px" } }, (0, import_react.createElement)("i"), "投递失败") : 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) : "—")
|
||||
)))
|
||||
)),
|
||||
filtered.length === 0 ? (0, import_react.createElement)("p", { className: "foot-note" }, "没有匹配的派工记录,换个关键词或状态试试。") : null
|
||||
filtered.length === 0 ? (0, import_react.createElement)("p", { className: "foot-note" }, "没有匹配的派工记录,换个关键词试试。") : null
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -1238,48 +1249,40 @@ function WorkbenchV2(props) {
|
|||
renderTopbar("记忆", [(0, import_react.createElement)("span", { className: "date" }, (wb.project.name || "项目") + " · 项目共识 v" + (memory?.revision ?? 0))]),
|
||||
(0, import_react.createElement)(
|
||||
"div",
|
||||
{ className: "grid" },
|
||||
{ className: "settings-stack" },
|
||||
(0, import_react.createElement)(
|
||||
"div",
|
||||
{ className: "detail-col" },
|
||||
"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)(
|
||||
"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)(
|
||||
"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 || "已登记"))))
|
||||
"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)(
|
||||
"div",
|
||||
{ className: "rail" },
|
||||
"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)(
|
||||
"section",
|
||||
{ className: "card", "aria-label": "编辑项目共识" },
|
||||
(0, import_react.createElement)("h3", null, "编辑项目共识"),
|
||||
(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 ? "保存中…" : "保存共识"))
|
||||
)
|
||||
"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 || "已登记"))))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
@ -1307,8 +1310,7 @@ function WorkbenchV2(props) {
|
|||
(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)("div", { className: "ws-actions" }, (0, import_react.createElement)("button", { type: "button", className: "btn primary", disabled: busy, onClick: enableAllSeats }, "启用十席"))
|
||||
)
|
||||
),
|
||||
(0, import_react.createElement)(
|
||||
"section",
|
||||
|
|
@ -1345,24 +1347,77 @@ function WorkbenchV2(props) {
|
|||
)
|
||||
);
|
||||
}
|
||||
function renderTaskModal() {
|
||||
if (!taskForm) return null;
|
||||
const seat = SEATS[taskForm.ownerSeatId];
|
||||
function renderReviewPanel() {
|
||||
if (!reviewPanelOpen) return null;
|
||||
return (0, import_react.createElement)(
|
||||
"div",
|
||||
{ className: "modal-backdrop", onClick: (event) => {
|
||||
if (event.target === event.currentTarget) setTaskForm(null);
|
||||
if (event.target === event.currentTarget) setReviewPanelOpen(false);
|
||||
} },
|
||||
(0, import_react.createElement)(
|
||||
"div",
|
||||
{ className: "modal", role: "dialog", "aria-modal": "true", "aria-labelledby": "ssv-task-title" },
|
||||
(0, import_react.createElement)("div", { className: "modal-head" }, (0, import_react.createElement)("h3", { id: "ssv-task-title" }, taskForm.ownerSeatId === "lead" ? "向丞相下达" : "新建派工"), (0, import_react.createElement)("button", { type: "button", className: "modal-close", "aria-label": "关闭", onClick: () => setTaskForm(null) }, "✕")),
|
||||
(0, import_react.createElement)("div", { className: "m-from" }, (seat ? seat.label : taskForm.ownerSeatId) + " · " + (seat ? seat.duty : "") + " · " + modelLabelOf(taskForm.ownerSeatId)),
|
||||
(0, import_react.createElement)("div", { className: "m-sec" }, (0, import_react.createElement)("span", { className: "t-label" }, "承办席位"), (0, import_react.createElement)("select", { value: taskForm.ownerSeatId, onChange: (event) => setTaskForm({ ...taskForm, ownerSeatId: event.target.value }), className: "ssv-select" }, SEAT_IDS.map((id) => (0, import_react.createElement)("option", { key: id, value: id }, SEATS[id].label + " · " + SEATS[id].duty)))),
|
||||
(0, import_react.createElement)("div", { className: "m-sec" }, (0, import_react.createElement)("span", { className: "t-label" }, "任务标题"), (0, import_react.createElement)("input", { type: "text", value: taskForm.title, placeholder: "例如:整理本周文献日报要点", onChange: (event) => setTaskForm({ ...taskForm, title: 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: 4, value: taskForm.goal, placeholder: "把要办的事、背景和期望产出写清楚…", onChange: (event) => setTaskForm({ ...taskForm, goal: event.target.value }) })),
|
||||
(0, import_react.createElement)("label", { className: "ssv-check" }, (0, import_react.createElement)("input", { type: "checkbox", checked: taskForm.dispatchNow, onChange: (event) => setTaskForm({ ...taskForm, dispatchNow: event.target.checked }) }), " 创建后立即派工到该席位"),
|
||||
(0, import_react.createElement)("div", { className: "modal-actions" }, (0, import_react.createElement)("button", { type: "button", className: "btn primary", disabled: busy, onClick: submitTaskForm }, busy ? "提交中…" : "提交"), (0, import_react.createElement)("button", { type: "button", className: "btn", onClick: () => setTaskForm(null) }, "取消"))
|
||||
{ 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)(ResultSummary, { text: task.result || task.goal || task.requirement || "", label: "审核材料", empty: "(暂无内容)" }),
|
||||
(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 renderToken() {
|
||||
return (0, import_react.createElement)(
|
||||
"div",
|
||||
{ className: "page" },
|
||||
renderTopbar("Token 用量"),
|
||||
(0, import_react.createElement)(
|
||||
"section",
|
||||
{ className: "stats", "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: "22px" }, "aria-label": "Token 接入说明" },
|
||||
(0, import_react.createElement)("h3", null, "接入说明"),
|
||||
(0, import_react.createElement)("p", { className: "foot-note" }, "当前宿主尚未提供稳定的 usage 数据源,本页先占位,不展示估算值,避免假精确。接入真实用量后会在这里展示 Token 消耗、上下文占用和消耗金额。")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -1395,25 +1450,13 @@ function WorkbenchV2(props) {
|
|||
} },
|
||||
(0, import_react.createElement)(
|
||||
"div",
|
||||
{ className: "modal", role: "dialog", "aria-modal": "true" },
|
||||
{ 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) : "尚未派发")),
|
||||
(0, import_react.createElement)("div", { className: "m-sec" }, (0, import_react.createElement)("span", { className: "t-label" }, "派工说明"), (0, import_react.createElement)("p", null, task.goal || task.requirement || "(无任务说明)")),
|
||||
(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.result ? (0, import_react.createElement)("div", { className: "m-sec" }, (0, import_react.createElement)("span", { className: "t-label" }, "结果"), (0, import_react.createElement)("p", null, task.result)) : null,
|
||||
(0, import_react.createElement)(
|
||||
"div",
|
||||
{ className: "modal-actions" },
|
||||
task.status === "draft" ? (0, import_react.createElement)("button", { type: "button", className: "btn primary", disabled: busy, onClick: () => {
|
||||
void dispatchTask(task.id);
|
||||
setSelectedTask(null);
|
||||
} }, "派工") : null,
|
||||
task.status === "draft" || task.status === "dispatched" || task.status === "running" ? (0, import_react.createElement)("button", { type: "button", className: "btn", disabled: busy, onClick: () => {
|
||||
void cancelTask(task.id);
|
||||
setSelectedTask(null);
|
||||
} }, "取消任务") : null,
|
||||
(0, import_react.createElement)("button", { type: "button", className: "btn", onClick: () => setSelectedTask(null) }, "关闭")
|
||||
)
|
||||
(0, import_react.createElement)("div", { className: "m-sec" }, (0, import_react.createElement)("span", { className: "t-label" }, "派工说明"), (0, import_react.createElement)(ResultSummary, { text: task.goal || task.requirement || "", label: "任务摘要", empty: "(无任务说明)" })),
|
||||
(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 === "failed" ? " · 投递失败" : ""))),
|
||||
(0, import_react.createElement)("div", { className: "m-sec" }, (0, import_react.createElement)("span", { className: "t-label" }, "结果"), (0, import_react.createElement)(ResultSummary, { text: task.result || "", label: "结果摘要", empty: "(暂无结果)" })),
|
||||
(0, import_react.createElement)("div", { className: "modal-actions" }, (0, import_react.createElement)("button", { type: "button", className: "btn", onClick: () => setSelectedTask(null) }, "关闭"))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -1423,6 +1466,7 @@ function WorkbenchV2(props) {
|
|||
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 (tab === "queue") return renderQueue();
|
||||
if (tab === "memory") return renderMemory();
|
||||
if (tab === "token") return renderToken();
|
||||
if (tab === "settings") return renderSettings();
|
||||
return renderOverview();
|
||||
}
|
||||
|
|
@ -1448,9 +1492,10 @@ function WorkbenchV2(props) {
|
|||
statusBanner,
|
||||
renderPage()
|
||||
),
|
||||
renderTaskModal(),
|
||||
renderArtifactModal(),
|
||||
renderTaskDetail()
|
||||
renderTaskDetail(),
|
||||
renderReviewPanel(),
|
||||
renderDurationPanel()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1615,6 +1660,9 @@ var CSS = `.ssv2{
|
|||
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; }
|
||||
|
|
@ -1801,8 +1849,8 @@ var CSS = `.ssv2{
|
|||
.node-task .task-text { display: block; }
|
||||
|
||||
/* ---------- 席位详情头:标题 + 开始对话主按钮 ---------- */
|
||||
.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
|
||||
.detail-head h3 { flex: 1; min-width: 0; margin: 0; }
|
||||
.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; }
|
||||
|
|
@ -1982,6 +2030,7 @@ var CSS = `.ssv2{
|
|||
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 {
|
||||
|
|
@ -2042,28 +2091,28 @@ var CSS = `.ssv2{
|
|||
.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); }
|
||||
|
||||
/* ---------- 窄屏回落(只保证不横滚;席位排数由谱系自己的断点管) ---------- */
|
||||
@media (max-width: 1180px) {
|
||||
/* ---------- 窄屏回落:按工作台自身宽度判断,避免右栏 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); }
|
||||
}
|
||||
@media (max-width: 860px) {
|
||||
@container ssv2 (max-width: 860px) {
|
||||
.proj { margin-left: 0; }
|
||||
.tabs { width: 100%; }
|
||||
.tabs a { flex: 1 1 auto; justify-content: center; }
|
||||
.main { padding: 14px 16px 32px; }
|
||||
.rail { flex-direction: column; }
|
||||
.search { width: 100%; order: 5; }
|
||||
.stats { grid-template-columns: 1fr 1fr; gap: 10px; }
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
/* 手机上表格收成四列:藏「模型」「耗时」两列,单元格允许换行,不横滚 */
|
||||
thead th:nth-child(3), tbody td:nth-child(3),
|
||||
thead th:nth-child(5), tbody td:nth-child(5) { display: none; }
|
||||
@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; }
|
||||
|
|
@ -2089,7 +2138,7 @@ body[data-ds-dark-theme] .ssv2,html[data-theme=dark] .ssv2,.ssv2[data-ssv-theme=
|
|||
|
||||
/* ---------- 工作台 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%}
|
||||
.ssv2 .main{min-height:100%;min-width:600px;container-type:inline-size;container-name:ssv2}
|
||||
.ssv2 .page{min-height: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))}
|
||||
|
|
@ -2106,6 +2155,30 @@ body[data-ds-dark-theme] .ssv2,html[data-theme=dark] .ssv2,.ssv2[data-ssv-theme=
|
|||
.ssv2 .skill-list li{gap:8px}
|
||||
.ssv2 .skill-list .skill-toggle{flex:none}
|
||||
.ssv2 .card h3 .count{font-family:var(--font-num)}
|
||||
|
||||
/* ---------- 结果摘要 / 展开详情 ---------- */
|
||||
.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}
|
||||
`;
|
||||
|
||||
// src/native/panel.js
|
||||
|
|
@ -2715,29 +2788,61 @@ function apply(ctx) {
|
|||
}
|
||||
return currentSessionId();
|
||||
}
|
||||
function activeRightTabId() {
|
||||
const right = get("sidebarRight");
|
||||
if (!right || !isFn(right.active)) return null;
|
||||
try {
|
||||
const record = right.active();
|
||||
if (!record) return null;
|
||||
if (typeof record === "string") return record;
|
||||
return record.id || record.tabId || null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function findRightWorkbenchTab() {
|
||||
const right = get("sidebarRight");
|
||||
if (!right || !isFn(right.openTabs?.getSnapshot)) return null;
|
||||
try {
|
||||
const rows = right.openTabs.getSnapshot();
|
||||
const sessionId = rightMountedSessionId();
|
||||
return (Array.isArray(rows) ? rows : []).find((item) => item && item.kind === TAB_KIND && (!sessionId || item.sessionId === sessionId)) || null;
|
||||
const matches = (Array.isArray(rows) ? rows : []).filter((item) => item && item.kind === TAB_KIND && (!sessionId || item.sessionId === sessionId));
|
||||
if (matches.length === 0) return null;
|
||||
const activeId = activeRightTabId();
|
||||
return matches.find((item) => item.tabId === activeId) || matches[0];
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function revealRightTab() {
|
||||
const right = get("sidebarRight");
|
||||
if (!right) return;
|
||||
if (!right) return false;
|
||||
try {
|
||||
const row = findRightWorkbenchTab();
|
||||
if (row && isFn(right.focus)) right.focus(row.tabId);
|
||||
if (!row) return false;
|
||||
const activeId = activeRightTabId();
|
||||
if (activeId !== row.tabId && isFn(right.focus)) right.focus(row.tabId);
|
||||
if (isFn(right.isExpanded) && !right.isExpanded() && isFn(right.toggleExpanded)) right.toggleExpanded();
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.warn("[sansheng] 展开右侧栏失败:", error && error.message ? error.message : error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function scheduleRevealRightTab() {
|
||||
for (const delay of [120, 420]) {
|
||||
setTimeout(() => {
|
||||
if (!rightWorkbenchPinned) return;
|
||||
revealRightTab();
|
||||
}, delay);
|
||||
}
|
||||
}
|
||||
function tryOpenRightTab() {
|
||||
const existing = findRightWorkbenchTab();
|
||||
if (existing) {
|
||||
revealRightTab();
|
||||
return true;
|
||||
}
|
||||
const bs = get("betterSidebar");
|
||||
if (bs && isFn(bs.openTab)) {
|
||||
try {
|
||||
|
|
@ -2745,7 +2850,7 @@ function apply(ctx) {
|
|||
const sessionId = snap && typeof snap === "object" ? snap.sessionId : void 0;
|
||||
if (!sessionId) return false;
|
||||
bs.openTab({ type: TAB_KIND, title: "三省六部" });
|
||||
for (const delay of [200, 600, 1200]) setTimeout(revealRightTab, delay);
|
||||
scheduleRevealRightTab();
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.warn("[sansheng] better-sidebar 打开失败,改用宿主接口:", error && error.message ? error.message : error);
|
||||
|
|
@ -2754,16 +2859,14 @@ function apply(ctx) {
|
|||
const right = get("sidebarRight");
|
||||
if (!right || !isFn(right.openTab)) return false;
|
||||
if (!ensureRightTab()) return false;
|
||||
if (!findRightWorkbenchTab()) {
|
||||
try {
|
||||
right.openTab(TAB_KIND);
|
||||
} catch (error) {
|
||||
console.warn("[sansheng] 打开右侧标签失败,改用浮动面板:", error && error.message ? error.message : error);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
right.openTab(TAB_KIND);
|
||||
} catch (error) {
|
||||
console.warn("[sansheng] 打开右侧标签失败,改用浮动面板:", error && error.message ? error.message : error);
|
||||
return false;
|
||||
}
|
||||
revealRightTab();
|
||||
for (const delay of [150, 500, 1200]) setTimeout(revealRightTab, delay);
|
||||
scheduleRevealRightTab();
|
||||
return true;
|
||||
}
|
||||
function SanshengTabBody() {
|
||||
|
|
@ -2905,20 +3008,25 @@ function apply(ctx) {
|
|||
function installRightDockPinning() {
|
||||
const right = get("sidebarRight");
|
||||
if (!right || !isFn(right.mounted?.subscribe)) return;
|
||||
let timer = null;
|
||||
const ensure = () => {
|
||||
timer = null;
|
||||
if (!rightWorkbenchPinned) return;
|
||||
try {
|
||||
if (findRightWorkbenchTab()) revealRightTab();
|
||||
else openRightWorkbench();
|
||||
} catch {
|
||||
}
|
||||
};
|
||||
const stop = right.mounted.subscribe(() => {
|
||||
if (!rightWorkbenchPinned) return;
|
||||
for (const delay of [80, 240, 700]) {
|
||||
setTimeout(() => {
|
||||
if (!rightWorkbenchPinned) return;
|
||||
try {
|
||||
if (!findRightWorkbenchTab()) openRightWorkbench();
|
||||
else revealRightTab();
|
||||
} catch {
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
if (timer !== null) clearTimeout(timer);
|
||||
timer = setTimeout(ensure, 60);
|
||||
});
|
||||
if (isFn(ctx.effect)) ctx.effect(() => {
|
||||
if (timer !== null) clearTimeout(timer);
|
||||
stop();
|
||||
});
|
||||
if (isFn(ctx.effect)) ctx.effect(() => stop);
|
||||
}
|
||||
function SanshengNavButton(props) {
|
||||
const size = props && typeof props.size === "number" ? props.size : 16;
|
||||
|
|
|
|||
|
|
@ -236,28 +236,61 @@ export function apply(ctx) {
|
|||
return currentSessionId()
|
||||
}
|
||||
|
||||
function activeRightTabId() {
|
||||
const right = get('sidebarRight')
|
||||
if (!right || !isFn(right.active)) return null
|
||||
try {
|
||||
const record = right.active()
|
||||
if (!record) return null
|
||||
if (typeof record === 'string') return record
|
||||
return record.id || record.tabId || null
|
||||
} catch { return null }
|
||||
}
|
||||
|
||||
function findRightWorkbenchTab() {
|
||||
const right = get('sidebarRight')
|
||||
if (!right || !isFn(right.openTabs?.getSnapshot)) return null
|
||||
try {
|
||||
const rows = right.openTabs.getSnapshot()
|
||||
const sessionId = rightMountedSessionId()
|
||||
return (Array.isArray(rows) ? rows : []).find(item => item && item.kind === TAB_KIND && (!sessionId || item.sessionId === sessionId)) || null
|
||||
const matches = (Array.isArray(rows) ? rows : []).filter(item => item && item.kind === TAB_KIND && (!sessionId || item.sessionId === sessionId))
|
||||
if (matches.length === 0) return null
|
||||
const activeId = activeRightTabId()
|
||||
return matches.find(item => item.tabId === activeId) || matches[0]
|
||||
} catch { return null }
|
||||
}
|
||||
|
||||
// 只在“还没有这个会话的工作台标签”时打开;已有标签只做必要的聚焦/展开,
|
||||
// 已处于目标状态时一律不动作,避免切换会话时重复 openTab/focus 造成整块刷新。
|
||||
function revealRightTab() {
|
||||
const right = get('sidebarRight')
|
||||
if (!right) return
|
||||
if (!right) return false
|
||||
try {
|
||||
const row = findRightWorkbenchTab()
|
||||
if (row && isFn(right.focus)) right.focus(row.tabId)
|
||||
if (!row) return false
|
||||
const activeId = activeRightTabId()
|
||||
if (activeId !== row.tabId && isFn(right.focus)) right.focus(row.tabId)
|
||||
if (isFn(right.isExpanded) && !right.isExpanded() && isFn(right.toggleExpanded)) right.toggleExpanded()
|
||||
return true
|
||||
} catch (error) {
|
||||
console.warn('[sansheng] 展开右侧栏失败:', error && error.message ? error.message : error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 单次补聚焦只用于“标签异步落位”的短窗口;每次先确认标签真的存在,绝不在已有标签时重复 openTab。
|
||||
function scheduleRevealRightTab() {
|
||||
for (const delay of [120, 420]) {
|
||||
setTimeout(() => {
|
||||
if (!rightWorkbenchPinned) return
|
||||
revealRightTab()
|
||||
}, delay)
|
||||
}
|
||||
}
|
||||
|
||||
function tryOpenRightTab() {
|
||||
const existing = findRightWorkbenchTab()
|
||||
if (existing) { revealRightTab(); return true }
|
||||
// 桌面版右栏由 dsh-better-sidebar 接管:它自己的 openTab 会排队等待会话面板挂载,
|
||||
// 主区正被切走时也不会丢;直接调宿主 sidebarRight 反而会因“没有挂载的会话面板”失败。
|
||||
const bs = get('betterSidebar')
|
||||
|
|
@ -267,7 +300,7 @@ export function apply(ctx) {
|
|||
const sessionId = snap && typeof snap === 'object' ? snap.sessionId : undefined
|
||||
if (!sessionId) return false
|
||||
bs.openTab({ type: TAB_KIND, title: '三省六部' })
|
||||
for (const delay of [200, 600, 1200]) setTimeout(revealRightTab, delay)
|
||||
scheduleRevealRightTab()
|
||||
return true
|
||||
} catch (error) {
|
||||
console.warn('[sansheng] better-sidebar 打开失败,改用宿主接口:', error && error.message ? error.message : error)
|
||||
|
|
@ -276,16 +309,12 @@ export function apply(ctx) {
|
|||
const right = get('sidebarRight')
|
||||
if (!right || !isFn(right.openTab)) return false
|
||||
if (!ensureRightTab()) return false
|
||||
if (!findRightWorkbenchTab()) {
|
||||
try { right.openTab(TAB_KIND) } catch (error) {
|
||||
console.warn('[sansheng] 打开右侧标签失败,改用浮动面板:', error && error.message ? error.message : error)
|
||||
return false
|
||||
}
|
||||
try { right.openTab(TAB_KIND) } catch (error) {
|
||||
console.warn('[sansheng] 打开右侧标签失败,改用浮动面板:', error && error.message ? error.message : error)
|
||||
return false
|
||||
}
|
||||
// 右栏(尤其 better-sidebar 的原生面)是异步落位的,不能同步看不到就当失败,
|
||||
// 否则会误退成主区渲染、把中间聊天顶掉。这里先乐观返回,再多次补一次聚焦/展开。
|
||||
revealRightTab()
|
||||
for (const delay of [150, 500, 1200]) setTimeout(revealRightTab, delay)
|
||||
scheduleRevealRightTab()
|
||||
return true
|
||||
}
|
||||
function SanshengTabBody() {
|
||||
|
|
@ -395,22 +424,31 @@ export function apply(ctx) {
|
|||
}
|
||||
|
||||
// 右侧栏按会话保存布局;切换部门打开新会话后,把固定工作台重新挂到新会话。
|
||||
// 只做一次“缺标签才打开、已有标签才聚焦”的幂等动作;不再对每次 mounted 连打三枪,
|
||||
// 否则每次打开会话都会重复 openTab/focus/expand,看起来像整块刷新。
|
||||
function installRightDockPinning() {
|
||||
const right = get('sidebarRight')
|
||||
if (!right || !isFn(right.mounted?.subscribe)) return
|
||||
let timer = null
|
||||
const ensure = () => {
|
||||
timer = null
|
||||
if (!rightWorkbenchPinned) return
|
||||
try {
|
||||
if (findRightWorkbenchTab()) revealRightTab()
|
||||
else openRightWorkbench()
|
||||
} catch { /* 会话尚未挂载时,等下一次 mounted 或用户再次点击 */ }
|
||||
}
|
||||
const stop = right.mounted.subscribe(() => {
|
||||
if (!rightWorkbenchPinned) return
|
||||
for (const delay of [80, 240, 700]) {
|
||||
setTimeout(() => {
|
||||
if (!rightWorkbenchPinned) return
|
||||
try {
|
||||
if (!findRightWorkbenchTab()) openRightWorkbench()
|
||||
else revealRightTab()
|
||||
} catch { /* 会话尚未挂载时下次再试 */ }
|
||||
}, delay)
|
||||
}
|
||||
if (timer !== null) clearTimeout(timer)
|
||||
// 会话切换时 mounted 先变、侧栏 seat 在同一轮 React 渲染中才 mint store;
|
||||
// 等一拍再动作,足够避开“store 尚未创建”的抛错,又不会重复打开。
|
||||
timer = setTimeout(ensure, 60)
|
||||
})
|
||||
if (isFn(ctx.effect)) ctx.effect(() => {
|
||||
if (timer !== null) clearTimeout(timer)
|
||||
stop()
|
||||
})
|
||||
if (isFn(ctx.effect)) ctx.effect(() => stop)
|
||||
}
|
||||
|
||||
// 导航行内容(宿主只把这里当图标渲染,标签由宿主按 label() 画)。
|
||||
|
|
|
|||
|
|
@ -161,6 +161,9 @@ export const CSS = `.ssv2{
|
|||
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; }
|
||||
|
|
@ -347,8 +350,8 @@ export const CSS = `.ssv2{
|
|||
.node-task .task-text { display: block; }
|
||||
|
||||
/* ---------- 席位详情头:标题 + 开始对话主按钮 ---------- */
|
||||
.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
|
||||
.detail-head h3 { flex: 1; min-width: 0; margin: 0; }
|
||||
.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; }
|
||||
|
|
@ -528,6 +531,7 @@ export const CSS = `.ssv2{
|
|||
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 {
|
||||
|
|
@ -588,28 +592,28 @@ export const CSS = `.ssv2{
|
|||
.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); }
|
||||
|
||||
/* ---------- 窄屏回落(只保证不横滚;席位排数由谱系自己的断点管) ---------- */
|
||||
@media (max-width: 1180px) {
|
||||
/* ---------- 窄屏回落:按工作台自身宽度判断,避免右栏 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); }
|
||||
}
|
||||
@media (max-width: 860px) {
|
||||
@container ssv2 (max-width: 860px) {
|
||||
.proj { margin-left: 0; }
|
||||
.tabs { width: 100%; }
|
||||
.tabs a { flex: 1 1 auto; justify-content: center; }
|
||||
.main { padding: 14px 16px 32px; }
|
||||
.rail { flex-direction: column; }
|
||||
.search { width: 100%; order: 5; }
|
||||
.stats { grid-template-columns: 1fr 1fr; gap: 10px; }
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
/* 手机上表格收成四列:藏「模型」「耗时」两列,单元格允许换行,不横滚 */
|
||||
thead th:nth-child(3), tbody td:nth-child(3),
|
||||
thead th:nth-child(5), tbody td:nth-child(5) { display: none; }
|
||||
@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; }
|
||||
|
|
@ -635,7 +639,7 @@ body[data-ds-dark-theme] .ssv2,html[data-theme=dark] .ssv2,.ssv2[data-ssv-theme=
|
|||
|
||||
/* ---------- 工作台 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%}
|
||||
.ssv2 .main{min-height:100%;min-width:600px;container-type:inline-size;container-name:ssv2}
|
||||
.ssv2 .page{min-height: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))}
|
||||
|
|
@ -652,4 +656,28 @@ body[data-ds-dark-theme] .ssv2,html[data-theme=dark] .ssv2,.ssv2[data-ssv-theme=
|
|||
.ssv2 .skill-list li{gap:8px}
|
||||
.ssv2 .skill-list .skill-toggle{flex:none}
|
||||
.ssv2 .card h3 .count{font-family:var(--font-num)}
|
||||
|
||||
/* ---------- 结果摘要 / 展开详情 ---------- */
|
||||
.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}
|
||||
`;
|
||||
|
|
|
|||
|
|
@ -83,6 +83,108 @@ function dateLabel() {
|
|||
return new Intl.DateTimeFormat('zh-CN', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }).format(new Date())
|
||||
} catch { return '' }
|
||||
}
|
||||
function taskDurationMs(task) {
|
||||
if (!task) return 0
|
||||
const start = 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
|
||||
}
|
||||
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
|
||||
}
|
||||
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 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 ResultSummary(props) {
|
||||
const [expanded, setExpanded] = useState(false)
|
||||
const text = String(props && props.text ? props.text : '').trim()
|
||||
const label = props && props.label ? props.label : '摘要'
|
||||
const empty = props && props.empty ? props.empty : '(暂无内容)'
|
||||
if (!text) {
|
||||
return h('div', { className: 'result-summary is-empty' },
|
||||
label ? h('span', { className: 't-label' }, label) : null,
|
||||
h('span', { className: 'rs-empty' }, empty))
|
||||
}
|
||||
const parsed = splitResultText(text)
|
||||
return h('div', { className: 'result-summary' + (expanded ? ' is-expanded' : '') },
|
||||
h('div', { className: 'rs-line' },
|
||||
label ? h('span', { className: 't-label' }, label) : null,
|
||||
h('span', { className: 'rs-summary' }, parsed.summary)),
|
||||
parsed.points.length > 0 ? h('ul', { className: 'rs-points' }, parsed.points.map((point, index) => h('li', { key: index }, point))) : null,
|
||||
parsed.hasMore || parsed.points.length > 0 || text.includes('\n')
|
||||
? h('button', { type: 'button', className: 'rs-toggle', onClick: () => setExpanded(value => !value), 'aria-expanded': expanded ? 'true' : 'false' }, expanded ? '收起详情' : '展开详情')
|
||||
: null,
|
||||
expanded ? h('div', { className: 'rs-detail' }, renderRichText(text)) : null,
|
||||
)
|
||||
}
|
||||
|
||||
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 })))
|
||||
|
|
@ -133,11 +235,10 @@ export function WorkbenchV2(props) {
|
|||
return SEAT_IDS.includes(saved) ? saved : SEAT_IDS[0]
|
||||
})
|
||||
const [tab, setTab] = useState('overview')
|
||||
const [seatFilter, setSeatFilter] = useState('all')
|
||||
const [queueFilter, setQueueFilter] = useState('all')
|
||||
const [queueSearch, setQueueSearch] = useState('')
|
||||
const [selectedTask, setSelectedTask] = useState(null)
|
||||
const [taskForm, setTaskForm] = useState(null)
|
||||
const [reviewPanelOpen, setReviewPanelOpen] = useState(false)
|
||||
const [durationPanelOpen, setDurationPanelOpen] = useState(false)
|
||||
const [draft, setDraft] = useState({})
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [summaryBusy, setSummaryBusy] = useState(false)
|
||||
|
|
@ -317,18 +418,6 @@ export function WorkbenchV2(props) {
|
|||
} finally { if (alive.current) setBusy(false) }
|
||||
}
|
||||
|
||||
async function enableAllSeats() {
|
||||
if (!projectId) return
|
||||
setBusy(true); setError(null); setNotice('正在启用十席…')
|
||||
try {
|
||||
const next = await request('enable', { projectId })
|
||||
if (!alive.current) return
|
||||
setView(next); setNotice('十席已启用(建立独立会话,不自动运行模型)')
|
||||
} 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
|
||||
|
|
@ -378,50 +467,6 @@ export function WorkbenchV2(props) {
|
|||
}
|
||||
}
|
||||
|
||||
function openTaskForm(ownerSeatId) {
|
||||
setTaskForm({ ownerSeatId: ownerSeatId || 'gongbu', title: '', goal: '', dispatchNow: true })
|
||||
}
|
||||
async function submitTaskForm() {
|
||||
if (!projectId || !taskForm) return
|
||||
const title = taskForm.title.trim()
|
||||
if (!title) { setNotice('任务标题不能为空'); return }
|
||||
setBusy(true); setError(null)
|
||||
try {
|
||||
const created = await request('taskCreate', { projectId, title, goal: taskForm.goal, ownerSeatId: taskForm.ownerSeatId })
|
||||
const task = created && created.task ? created.task : null
|
||||
if (taskForm.dispatchNow && task && task.id) {
|
||||
const delivered = await request('taskDispatch', { projectId, taskId: task.id })
|
||||
setNotice(delivered && delivered.delivered ? '已派工到「' + (SEATS[taskForm.ownerSeatId]?.label ?? '') + '」会话。' : '任务已记录,但宿主未直接送达。')
|
||||
} else setNotice('已存为草稿;可在任务详情中点「派工」。')
|
||||
setTaskForm(null); await reloadTasks()
|
||||
} catch (error) {
|
||||
if (alive.current) setError(error && error.message ? error.message : '新建任务失败')
|
||||
} finally { if (alive.current) setBusy(false) }
|
||||
}
|
||||
|
||||
async function dispatchTask(taskId) {
|
||||
if (!projectId) return
|
||||
setBusy(true); setError(null)
|
||||
try {
|
||||
const result = await request('taskDispatch', { projectId, taskId })
|
||||
await reloadTasks()
|
||||
setNotice(result && result.delivered ? '已派工到该部门会话。' : '已记录为待执行(当前宿主暂不支持直接发送)。')
|
||||
} catch (error) {
|
||||
if (alive.current) setError(error && error.message ? error.message : '派工失败')
|
||||
} finally { if (alive.current) setBusy(false) }
|
||||
}
|
||||
|
||||
async function cancelTask(taskId) {
|
||||
if (!projectId) return
|
||||
setBusy(true); setError(null)
|
||||
try {
|
||||
await request('taskCancel', { projectId, taskId })
|
||||
await reloadTasks(); setNotice('任务已取消。')
|
||||
} catch (error) {
|
||||
if (alive.current) setError(error && error.message ? error.message : '取消失败')
|
||||
} finally { if (alive.current) setBusy(false) }
|
||||
}
|
||||
|
||||
async function summarizeByShangshu() {
|
||||
if (!projectId) return
|
||||
setSummaryBusy(true); setError(null)
|
||||
|
|
@ -452,13 +497,9 @@ export function WorkbenchV2(props) {
|
|||
const todayStart = TODAY()
|
||||
const todayTasks = tasks.filter(task => Number(task.createdAt) >= todayStart)
|
||||
const todayDone = todayTasks.filter(task => task.status === 'done')
|
||||
const todayRunning = todayTasks.filter(task => task.status === 'running' || task.status === 'dispatched')
|
||||
const todayDraft = todayTasks.filter(task => task.status === 'draft')
|
||||
const reviewTasks = tasks.filter(task => task.ownerSeatId === 'menxia' && OPEN_STATUS.has(task.status))
|
||||
const runningSeats = wb.seats.filter(seat => seat.status === 'bound' || seat.status === 'creating').length
|
||||
const waitingSeats = wb.seats.filter(seat => seat.status === 'pending').length
|
||||
const durations = todayDone.map(task => Number(task.resultAt) - Number(task.createdAt)).filter(ms => Number.isFinite(ms) && ms > 0)
|
||||
const avgMs = durations.length ? durations.reduce((a, b) => a + b, 0) / durations.length : null
|
||||
const anomalyTasks = tasks.filter(task => task.status === 'failed' || task.deliveryState === 'failed')
|
||||
const projectDurationMs = tasks.reduce((sum, task) => sum + taskDurationMs(task), 0)
|
||||
|
||||
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
|
||||
|
|
@ -487,6 +528,7 @@ export function WorkbenchV2(props) {
|
|||
{ id: 'overview', label: '总览', icon: ['M3 3h7v9H3z', 'M14 3h7v5h-7z', 'M14 12h7v9h-7z', 'M3 16h7v5H3z'] },
|
||||
{ id: 'queue', label: '派工队列', icon: ['m22 2-7 20-4-9-9-4Z', 'M22 2 11 13'] },
|
||||
{ id: 'memory', label: '记忆', icon: ['M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'] },
|
||||
{ id: 'token', label: 'Token 用量', icon: ['M12 2v20', 'M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6'] },
|
||||
{ id: 'settings', label: '设置', icon: ['M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z', 'M12 12a3 3 0 1 0 0-6 3 3 0 0 0 0 6z'] },
|
||||
]
|
||||
return h('nav', { className: 'tabs', 'aria-label': '工作台导航' },
|
||||
|
|
@ -500,8 +542,7 @@ export function WorkbenchV2(props) {
|
|||
function renderSeatNode(seat) {
|
||||
const tone = toneOfSeat(seat)
|
||||
const latest = latestTaskOf(seat.id)
|
||||
const dim = seatFilter !== 'all' && tone !== seatFilter
|
||||
return h('div', { key: seat.id, className: 'node' + (seat.id === selectedSeatId ? ' selected' : '') + (dim ? ' dim' : ''), 'data-seat': 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),
|
||||
|
|
@ -514,25 +555,25 @@ export function WorkbenchV2(props) {
|
|||
|
||||
function renderOverview() {
|
||||
const stats = [
|
||||
h('div', { className: 'stat', key: 'running' },
|
||||
h('div', { className: 'label' }, '运行中席位'),
|
||||
h('div', { className: 'big' }, h('em', null, String(runningSeats)), h('span', { className: 'unit' }, ' / ' + wb.project.seatCount + ' 席')),
|
||||
h('div', { className: 'foot' }, '待命 ', h('b', null, String(waitingSeats)), ' · 待复核 ', h('b', null, String(reviewTasks.length))),
|
||||
h('button', { type: 'button', className: 'stat stat-link', key: 'cost', onClick: () => setTab('token') },
|
||||
h('div', { className: 'label' }, '消耗金额'),
|
||||
h('div', { className: 'big' }, h('em', null, '—'), h('span', { className: 'unit' }, '元')),
|
||||
h('div', { className: 'foot' }, 'Token 统计待接入'),
|
||||
),
|
||||
h('div', { className: 'stat', key: 'today' },
|
||||
h('div', { className: 'label' }, '今日派工'),
|
||||
h('div', { className: 'big' }, String(todayTasks.length), ' ', h('span', { className: 'unit' }, '条')),
|
||||
h('div', { className: 'foot' }, '已完成 ', h('b', null, String(todayDone.length)), ' · 进行中 ', h('b', null, String(todayRunning.length)), ' · 待派发 ', h('b', null, String(todayDraft.length))),
|
||||
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', { className: 'stat', key: 'review' },
|
||||
h('div', { className: 'label' }, '待门下复核'),
|
||||
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('div', { className: 'foot' }, '待门下复核'),
|
||||
),
|
||||
h('div', { className: 'stat', key: 'avg' },
|
||||
h('div', { className: 'label' }, '今日平均单程耗时'),
|
||||
h('div', { className: 'big' }, avgMs ? durationText(avgMs) : '—'),
|
||||
h('div', { className: 'foot' }, todayDone.length ? '按 ' + todayDone.length + ' 条已完成任务计算' : '今日暂无完成记录'),
|
||||
h('button', { type: 'button', className: 'stat stat-link', key: 'anomaly', onClick: () => { setQueueSearch('失败'); setTab('queue') } },
|
||||
h('div', { className: 'label' }, '异常 / 失败'),
|
||||
h('div', { className: 'big' }, h('em', null, String(anomalyTasks.length)), ' ', h('span', { className: 'unit' }, '条')),
|
||||
h('div', { className: 'foot' }, '失败或投递失败'),
|
||||
),
|
||||
]
|
||||
|
||||
|
|
@ -555,7 +596,7 @@ export function WorkbenchV2(props) {
|
|||
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('span', { className: 't-label' }, '最近产出摘录'), h('span', null, excerpt)),
|
||||
h('div', { className: 'excerpt' }, h(ResultSummary, { text: excerpt, label: '最近产出摘录', empty: '(暂无产出)' })),
|
||||
)
|
||||
|
||||
const workspace = h('section', { className: 'card', 'aria-label': '席位工作区' },
|
||||
|
|
@ -563,18 +604,15 @@ export function WorkbenchV2(props) {
|
|||
selected.id === 'shangshu'
|
||||
? h('div', { className: 'ws-actions' }, h('button', { type: 'button', className: 'btn primary', disabled: summaryBusy || busy, onClick: summarizeByShangshu }, summaryBusy ? '汇总中…' : '尚书汇总当前任务'))
|
||||
: null,
|
||||
selected.id === 'lead'
|
||||
? h('div', { className: 'ws-actions' }, h('button', { type: 'button', className: 'btn primary', onClick: () => openTaskForm('lead') }, h(PlusIcon), '向丞相下达'))
|
||||
: h('div', { className: 'ws-actions' }, h('button', { type: 'button', className: 'btn', onClick: () => openTaskForm(selected.id) }, h(PlusIcon), '新建派工到' + selected.name)),
|
||||
h('p', { className: 'foot-note ws-hint' }, '派工请在聊天中通过 sansheng_dispatch_task 下达;工作台只查看任务与结果。'),
|
||||
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('div', { className: 'rc-meta-row' }, h('span', { className: 'rc-from' }, task.id), h('span', { className: 'rc-meta' }, task.dispatchedAt ? '派发 ' + dateText(task.dispatchedAt) : '尚未派发')),
|
||||
h('div', { className: 'rc-excerpt' }, task.goal || task.requirement || '(无任务说明)'),
|
||||
h('div', { className: 'rc-meta-row' }, h('span', { className: 'rc-from' }, task.id || '—'), h('span', { className: 'rc-meta' }, task.dispatchedAt ? '派发 ' + dateText(task.dispatchedAt) : '尚未派发')),
|
||||
h(ResultSummary, { text: task.goal || task.requirement || '', label: '任务说明', empty: '(无任务说明)' }),
|
||||
h('div', { className: 'rc-actions' }, h('span', { className: 'spacer' }),
|
||||
h('button', { type: 'button', className: 'r-open', onClick: () => setSelectedTask(task) }, '查看详情 →'),
|
||||
task.status === 'draft' ? h('button', { type: 'button', className: 'btn primary', disabled: busy, onClick: () => dispatchTask(task.id) }, '派工') : null,
|
||||
),
|
||||
))),
|
||||
)
|
||||
|
|
@ -601,38 +639,39 @@ export function WorkbenchV2(props) {
|
|||
}
|
||||
const currentEffort = valueParts[2] || ''
|
||||
if (currentEffort && !effortChoices.includes(currentEffort)) effortChoices.unshift(currentEffort)
|
||||
const configCard = h('section', { className: 'card', 'aria-label': '部门配置' },
|
||||
h('h3', null, '部门配置 ', h('span', { className: 'seat-tag' }, selected.name)),
|
||||
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-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' ? h('button', { type: 'button', className: 'btn', disabled: busy, onClick: action }, actionLabel) : null,
|
||||
h('button', { type: 'button', className: 'btn', disabled: busy, onClick: enableAllSeats }, '启用十席'),
|
||||
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-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' ? h('button', { type: 'button', className: 'btn', disabled: busy, onClick: action }, actionLabel) : null,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -644,11 +683,7 @@ export function WorkbenchV2(props) {
|
|||
]),
|
||||
h('section', { className: 'stats', 'aria-label': '关键指标' }, stats),
|
||||
h('section', { 'aria-label': '席位谱系', style: { marginTop: '22px' } },
|
||||
h('div', { className: 'panel-head' }, h('h2', null, '席位谱系'),
|
||||
h('div', { className: 'seg', role: 'tablist', 'aria-label': '按状态筛选席位' },
|
||||
[['all', '全部'], ['run', '运行中'], ['review', '待复核'], ['idle', '待命']].map(([id, label]) => h('button', {
|
||||
key: id, type: 'button', className: seatFilter === id ? 'on' : '', role: 'tab', 'aria-selected': seatFilter === id ? 'true' : 'false', onClick: () => setSeatFilter(id),
|
||||
}, label)))),
|
||||
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' },
|
||||
|
|
@ -666,35 +701,30 @@ export function WorkbenchV2(props) {
|
|||
function renderQueue() {
|
||||
const query = queueSearch.trim().toLowerCase()
|
||||
const filtered = tasks.filter(task => {
|
||||
const tone = taskTone(task.status)
|
||||
if (queueFilter !== 'all' && tone !== queueFilter) return false
|
||||
if (!query) return true
|
||||
const seatName = SEATS[task.ownerSeatId]?.label || task.ownerSeatId || ''
|
||||
return (task.title + ' ' + seatName + ' ' + (task.id || '') + ' ' + (task.goal || '')).toLowerCase().includes(query)
|
||||
const haystack = [task.title, seatName, task.id, task.goal, task.requirement, task.result, taskLabel(task.status), task.deliveryState === 'failed' ? '投递失败' : ''].filter(Boolean).join(' ').toLowerCase()
|
||||
return haystack.includes(query)
|
||||
})
|
||||
return h('div', { className: 'page' },
|
||||
renderTopbar('派工队列', [
|
||||
h('button', { type: 'button', className: 'btn', disabled: summaryBusy || busy, onClick: summarizeByShangshu }, summaryBusy ? '汇总中…' : '尚书汇总'),
|
||||
h('button', { type: 'button', className: 'btn primary', onClick: () => openTaskForm('gongbu') }, h(PlusIcon), '新建派工'),
|
||||
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: busy, onClick: reloadTasks }, h(RefreshIcon), '刷新'),
|
||||
h('label', { className: 'search' }, h(SearchIcon), h('input', { type: 'search', value: queueSearch, placeholder: '搜索派工记录…', 'aria-label': '搜索派工队列', onChange: event => setQueueSearch(event.target.value) })),
|
||||
]),
|
||||
h('div', { className: 'seg', role: 'tablist', 'aria-label': '按状态筛选派工', style: { marginTop: '16px', marginLeft: 0 } },
|
||||
[['all', '全部'], ['run', '进行中'], ['review', '待复核'], ['done', '已完成'], ['fail', '失败']].map(([id, label]) => h('button', {
|
||||
key: id, type: 'button', className: queueFilter === id ? 'on' : '', 'aria-selected': queueFilter === id ? 'true' : 'false', onClick: () => setQueueFilter(id),
|
||||
}, label))),
|
||||
h('section', { className: 'table-card', 'aria-label': '派工队列' },
|
||||
h('section', { className: 'table-card', 'aria-label': '派工队列', style: { marginTop: '18px' } },
|
||||
h('div', { className: 'table-scroll' }, h('table', null,
|
||||
h('thead', null, h('tr', null, ['任务', '承办席位', '模型', '状态', '耗时', '派发时间'].map(label => h('th', { key: label, scope: 'col' }, label)))),
|
||||
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: () => setSelectedTask(task), onKeyDown: event => { if (event.key === 'Enter') setSelectedTask(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', { className: 'num' }, modelLabelOf(task.ownerSeatId)),
|
||||
h('td', null, h('span', { className: 'pill ' + taskTone(task.status) }, h('i'), taskLabel(task.status))),
|
||||
h('td', { className: 'dur' }, task.resultAt && task.createdAt ? durationText(Number(task.resultAt) - Number(task.createdAt)) : '—'),
|
||||
h('td', null, h('span', { className: 'pill ' + taskTone(task.status) }, h('i'), taskLabel(task.status)), task.deliveryState === 'failed' ? h('span', { className: 'pill fail', style: { marginLeft: '4px' } }, h('i'), '投递失败') : 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) : '—'),
|
||||
))),
|
||||
)),
|
||||
filtered.length === 0 ? h('p', { className: 'foot-note' }, '没有匹配的派工记录,换个关键词或状态试试。') : null,
|
||||
filtered.length === 0 ? h('p', { className: 'foot-note' }, '没有匹配的派工记录,换个关键词试试。') : null,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -710,34 +740,30 @@ export function WorkbenchV2(props) {
|
|||
)
|
||||
return h('div', { className: 'page' },
|
||||
renderTopbar('记忆', [h('span', { className: 'date' }, (wb.project.name || '项目') + ' · 项目共识 v' + (memory?.revision ?? 0))]),
|
||||
h('div', { className: 'grid' },
|
||||
h('div', { className: 'detail-col' },
|
||||
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')),
|
||||
),
|
||||
),
|
||||
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 || '已登记')))),
|
||||
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')),
|
||||
),
|
||||
),
|
||||
h('div', { className: 'rail' },
|
||||
h('section', { className: 'card', 'aria-label': '编辑项目共识' },
|
||||
h('h3', null, '编辑项目共识'),
|
||||
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('div', { className: 'ws-actions' }, h('button', { type: 'button', className: 'btn primary', disabled: busy, onClick: saveMemory }, busy ? '保存中…' : '保存共识')),
|
||||
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('div', { className: 'ws-actions' }, h('button', { type: 'button', className: 'btn primary', disabled: busy, onClick: saveMemory }, busy ? '保存中…' : '保存共识')),
|
||||
),
|
||||
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 || '已登记')))),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
@ -755,7 +781,6 @@ export function WorkbenchV2(props) {
|
|||
h('dt', null, '席位'), h('dd', null, wb.project.seatCount + ' 席'),
|
||||
h('dt', null, '工作区'), h('dd', null, wb.project.workspaceId || '—'),
|
||||
),
|
||||
h('div', { className: 'ws-actions' }, h('button', { type: 'button', className: 'btn primary', disabled: busy, onClick: enableAllSeats }, '启用十席')),
|
||||
),
|
||||
h('section', { className: 'card', 'aria-label': '席位开关' },
|
||||
h('h3', null, '席位开关'),
|
||||
|
|
@ -781,18 +806,56 @@ export function WorkbenchV2(props) {
|
|||
)
|
||||
}
|
||||
|
||||
function renderTaskModal() {
|
||||
if (!taskForm) return null
|
||||
const seat = SEATS[taskForm.ownerSeatId]
|
||||
return h('div', { className: 'modal-backdrop', onClick: event => { if (event.target === event.currentTarget) setTaskForm(null) } },
|
||||
h('div', { className: 'modal', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': 'ssv-task-title' },
|
||||
h('div', { className: 'modal-head' }, h('h3', { id: 'ssv-task-title' }, taskForm.ownerSeatId === 'lead' ? '向丞相下达' : '新建派工'), h('button', { type: 'button', className: 'modal-close', 'aria-label': '关闭', onClick: () => setTaskForm(null) }, '✕')),
|
||||
h('div', { className: 'm-from' }, (seat ? seat.label : taskForm.ownerSeatId) + ' · ' + (seat ? seat.duty : '') + ' · ' + modelLabelOf(taskForm.ownerSeatId)),
|
||||
h('div', { className: 'm-sec' }, h('span', { className: 't-label' }, '承办席位'), h('select', { value: taskForm.ownerSeatId, onChange: event => setTaskForm({ ...taskForm, ownerSeatId: event.target.value }), className: 'ssv-select' }, SEAT_IDS.map(id => h('option', { key: id, value: id }, SEATS[id].label + ' · ' + SEATS[id].duty)))),
|
||||
h('div', { className: 'm-sec' }, h('span', { className: 't-label' }, '任务标题'), h('input', { type: 'text', value: taskForm.title, placeholder: '例如:整理本周文献日报要点', onChange: event => setTaskForm({ ...taskForm, title: event.target.value }) })),
|
||||
h('div', { className: 'm-sec' }, h('span', { className: 't-label' }, '任务说明'), h('textarea', { rows: 4, value: taskForm.goal, placeholder: '把要办的事、背景和期望产出写清楚…', onChange: event => setTaskForm({ ...taskForm, goal: event.target.value }) })),
|
||||
h('label', { className: 'ssv-check' }, h('input', { type: 'checkbox', checked: taskForm.dispatchNow, onChange: event => setTaskForm({ ...taskForm, dispatchNow: event.target.checked }) }), ' 创建后立即派工到该席位'),
|
||||
h('div', { className: 'modal-actions' }, h('button', { type: 'button', className: 'btn primary', disabled: busy, onClick: submitTaskForm }, busy ? '提交中…' : '提交'), h('button', { type: 'button', className: 'btn', onClick: () => setTaskForm(null) }, '取消')),
|
||||
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(ResultSummary, { text: task.result || task.goal || task.requirement || '', label: '审核材料', empty: '(暂无内容)' }),
|
||||
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 renderToken() {
|
||||
return h('div', { className: 'page' },
|
||||
renderTopbar('Token 用量'),
|
||||
h('section', { className: 'stats', '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('section', { className: 'card', style: { marginTop: '22px' }, 'aria-label': 'Token 接入说明' },
|
||||
h('h3', null, '接入说明'),
|
||||
h('p', { className: 'foot-note' }, '当前宿主尚未提供稳定的 usage 数据源,本页先占位,不展示估算值,避免假精确。接入真实用量后会在这里展示 Token 消耗、上下文占用和消耗金额。'),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -815,17 +878,13 @@ export function WorkbenchV2(props) {
|
|||
const task = selectedTask
|
||||
const seat = SEATS[task.ownerSeatId]
|
||||
return h('div', { className: 'modal-backdrop', onClick: event => { if (event.target === event.currentTarget) setSelectedTask(null) } },
|
||||
h('div', { className: 'modal', role: 'dialog', 'aria-modal': 'true' },
|
||||
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) : '尚未派发')),
|
||||
h('div', { className: 'm-sec' }, h('span', { className: 't-label' }, '派工说明'), h('p', null, task.goal || task.requirement || '(无任务说明)')),
|
||||
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.result ? h('div', { className: 'm-sec' }, h('span', { className: 't-label' }, '结果'), h('p', null, task.result)) : null,
|
||||
h('div', { className: 'modal-actions' },
|
||||
task.status === 'draft' ? h('button', { type: 'button', className: 'btn primary', disabled: busy, onClick: () => { void dispatchTask(task.id); setSelectedTask(null) } }, '派工') : null,
|
||||
task.status === 'draft' || task.status === 'dispatched' || task.status === 'running' ? h('button', { type: 'button', className: 'btn', disabled: busy, onClick: () => { void cancelTask(task.id); setSelectedTask(null) } }, '取消任务') : null,
|
||||
h('button', { type: 'button', className: 'btn', onClick: () => setSelectedTask(null) }, '关闭'),
|
||||
),
|
||||
h('div', { className: 'm-sec' }, h('span', { className: 't-label' }, '派工说明'), h(ResultSummary, { text: task.goal || task.requirement || '', label: '任务摘要', empty: '(无任务说明)' })),
|
||||
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 === 'failed' ? ' · 投递失败' : ''))),
|
||||
h('div', { className: 'm-sec' }, h('span', { className: 't-label' }, '结果'), h(ResultSummary, { text: task.result || '', label: '结果摘要', empty: '(暂无结果)' })),
|
||||
h('div', { className: 'modal-actions' }, h('button', { type: 'button', className: 'btn', onClick: () => setSelectedTask(null) }, '关闭')),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -836,6 +895,7 @@ export function WorkbenchV2(props) {
|
|||
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 (tab === 'queue') return renderQueue()
|
||||
if (tab === 'memory') return renderMemory()
|
||||
if (tab === 'token') return renderToken()
|
||||
if (tab === 'settings') return renderSettings()
|
||||
return renderOverview()
|
||||
}
|
||||
|
|
@ -853,8 +913,9 @@ export function WorkbenchV2(props) {
|
|||
statusBanner,
|
||||
renderPage(),
|
||||
),
|
||||
renderTaskModal(),
|
||||
renderArtifactModal(),
|
||||
renderTaskDetail(),
|
||||
renderReviewPanel(),
|
||||
renderDurationPanel(),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue