From 643676afd98dc540af22c2e51bceab3e1e1f65a5 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Tue, 15 Sep 2026 10:28:24 +0800 Subject: [PATCH] Add distinctive emojis for special actions in Hose human opinions --- src/domains/hose/flow.test.ts | 26 ++++++------ src/domains/hose/flow.ts | 80 ++++++++++++++++++++++++++++------- 2 files changed, 78 insertions(+), 28 deletions(-) diff --git a/src/domains/hose/flow.test.ts b/src/domains/hose/flow.test.ts index c161b13..23e1414 100644 --- a/src/domains/hose/flow.test.ts +++ b/src/domains/hose/flow.test.ts @@ -790,7 +790,7 @@ describe("Hose Flow Domain", () => { const r1 = aligned.get("run-1")!; expect(r1.eHumanAction).toBe("审批驳回"); expect(r1.eHumanComment).toBe( - "主管B: 发票不全缺少总经理审批,退回修改\n↳ 驳回至: 提交人\n↳ 重新提交后由主管B继续审批" + "主管B ❌: 发票不全缺少总经理审批,退回修改\n↳ 驳回至: 提交人\n↳ 重新提交后由主管B继续审批" ); expect(r1.operator?.name).toBe("主管B"); expect(r1.auditDrift).toBe(false); @@ -908,7 +908,7 @@ describe("Hose Flow Domain", () => { const r1 = aligned.get("run-retracted")!; expect(r1.eHumanAction).toBe("已撤回"); - expect(r1.eHumanComment).toBe("提交人(刘佳琼): 单据撤回"); + expect(r1.eHumanComment).toBe("提交人(刘佳琼) ↩️: 单据撤回"); expect(r1.auditDrift).toBe(false); const r2 = aligned.get("run-active")!; @@ -956,12 +956,12 @@ describe("Hose Flow Domain", () => { // 1. Agree nodes present with sequence numbers expect(r.eHumanComment).toContain("1. 上级主管(张舒): 同意"); expect(r.eHumanComment).toContain("2. 财务助理(熊雪倩): 同意"); - expect(r.eHumanComment).toContain("3. 部门主管(张舒): 自动同意"); + expect(r.eHumanComment).toContain("3. 部门主管(张舒) 🤖: 自动同意"); // 2. Duplicate comment deduplicated (appears only once) - const matches = r.eHumanComment.match(/高思琦: ETA2026年家庭日费用报销/g); + const matches = r.eHumanComment.match(/高思琦 💬: ETA2026年家庭日费用报销/g); expect(matches?.length).toBe(1); // 3. freeflow.pay mapped to 支付成功 - expect(r.eHumanComment).toContain("5. 高思琦: 支付成功"); + expect(r.eHumanComment).toContain("5. 高思琦 💰: 支付成功"); // 4. freeflow.carbonCopy omitted expect(r.eHumanComment).not.toContain("freeflow.carbonCopy"); expect(r.eHumanComment).not.toContain("抄送单据"); @@ -1062,7 +1062,7 @@ describe("Hose Flow Domain", () => { expect(r.eHumanAction).toBe("审批驳回"); // Node prefix resolved from熊雪倩's approval node in history: 财务助理(熊雪倩): 修改附件 expect(r.eHumanComment).toBe( - "财务助理(熊雪倩): 修改附件\n↳ 驳回至: 提交人\n↳ 重新提交后由熊雪倩继续审批" + "财务助理(熊雪倩) ❌: 修改附件\n↳ 驳回至: 提交人\n↳ 重新提交后由熊雪倩继续审批" ); expect(r.auditDrift).toBe(false); expect(r.operator?.name).toBe("熊雪倩"); @@ -1122,7 +1122,7 @@ describe("Hose Flow Domain", () => { const r = aligned.get("run-2307")!; expect(r.eHumanAction).toBe("审批驳回"); expect(r.eHumanComment).toBe( - "财务经理(周晚容): 修改\n↳ 驳回至: 财务助理(熊雪倩)\n↳ 重新提交后由周晚容继续审批" + "财务经理(周晚容) ❌: 修改\n↳ 驳回至: 财务助理(熊雪倩)\n↳ 重新提交后由周晚容继续审批" ); expect(r.operator?.name).toBe("周晚容"); }); @@ -1168,7 +1168,7 @@ describe("Hose Flow Domain", () => { const r = aligned.get("run-2144")!; expect(r.eHumanAction).toBe("已支付 (中途修改)"); expect(r.eHumanComment).toBe( - "2. 财务助理(熊雪倩): 修改了单据\n1. 上级主管(孙麓): 同意\n3. 财务助理(熊雪倩): 同意\n4. 董事长(甘戈): 同意\n5. 财务经理(周晚容): 同意\n6. CFO(张舒): 同意\n7. 高思琦: 支付成功" + "2. 财务助理(熊雪倩) ✏️: 修改了单据\n1. 上级主管(孙麓): 同意\n3. 财务助理(熊雪倩): 同意\n4. 董事长(甘戈): 同意\n5. 财务经理(周晚容): 同意\n6. CFO(张舒): 同意\n7. 高思琦 💰: 支付成功" ); }); }); @@ -1245,7 +1245,7 @@ describe("Hose Flow Domain", () => { ] ); expect(res1.comment).toBe( - "财务助理(熊雪倩): 修改附件\n↳ 驳回至: 提交人\n↳ 重新提交后由熊雪倩继续审批" + "财务助理(熊雪倩) ❌: 修改附件\n↳ 驳回至: 提交人\n↳ 重新提交后由熊雪倩继续审批" ); expect(res1.operator?.name).toBe("熊雪倩"); @@ -1258,7 +1258,7 @@ describe("Hose Flow Domain", () => { } as any ); expect(res2.comment).toBe( - "财务经理(周晚容): 单据超标缺少说明\n↳ 驳回至: 提交人\n↳ 重新提交后由周晚容继续审批" + "财务经理(周晚容) ❌: 单据超标缺少说明\n↳ 驳回至: 提交人\n↳ 重新提交后由周晚容继续审批" ); const res3 = formatRejectionComment( @@ -1318,7 +1318,7 @@ describe("Hose Flow Domain", () => { const r1 = aligned.get("run-round-1")!; expect(r1.eHumanAction).toBe("已撤回"); expect(r1.eHumanComment).toBe( - "1. 费用类型是研发费(宁艳楠): 同意\n2. 提交人(袁锦): 单据撤回" + "1. 费用类型是研发费(宁艳楠): 同意\n2. 提交人(袁锦) ↩️: 单据撤回" ); expect(r1.eHumanComment).not.toContain("合思审批节点"); expect(r1.eHumanComment).not.toContain("审批驳回"); @@ -1326,7 +1326,7 @@ describe("Hose Flow Domain", () => { const r2 = aligned.get("run-round-2")!; expect(r2.eHumanAction).toBe("已支付"); expect(r2.eHumanComment).toBe( - "1. 费用类型是研发费(宁艳楠): 同意\n2. 财务经理(周晚容): 同意\n3. 高思琦: 支付成功" + "1. 费用类型是研发费(宁艳楠): 同意\n2. 财务经理(周晚容): 同意\n3. 高思琦 💰: 支付成功" ); }); @@ -1369,7 +1369,7 @@ describe("Hose Flow Domain", () => { // Must NOT be falsely labeled as "已支付" just because Hose is currently paid! expect(r.eHumanAction).toBe("审批驳回"); expect(r.eHumanComment).toBe( - "财务审批(李四): 发票模糊\n↳ 驳回至: 提交人\n↳ 重新提交后由李四继续审批" + "财务审批(李四) ❌: 发票模糊\n↳ 驳回至: 提交人\n↳ 重新提交后由李四继续审批" ); expect(r.auditDrift).toBe(false); }); diff --git a/src/domains/hose/flow.ts b/src/domains/hose/flow.ts index 79664bc..6aaef8b 100644 --- a/src/domains/hose/flow.ts +++ b/src/domains/hose/flow.ts @@ -912,7 +912,53 @@ export function formatHumanOpinionLines(events: HoseFlowTimelineEntry[]): string } } - const line = `${nodePrefix}: ${comment}`; + let emoji = ""; + if (ev.rawAction === "flow.modify" || ev.action === "修改了单据" || ev.isModification || comment === "修改了单据") { + emoji = "✏️"; + } else if ( + ev.rawAction === "freeflow.autoAgree" || + ev.action === "自动同意" || + comment === "自动同意" || + ev.automatic + ) { + emoji = "🤖"; + } else if (ev.rawAction === "freeflow.retract" || ev.action === "单据撤回" || comment === "单据撤回") { + emoji = "↩️"; + } else if ( + ev.rawAction === "freeflow.reject" || + ev.action === "审批驳回" || + ev.rawAction === "freeflow.back" || + ev.action === "审批退回" || + comment === "驳回" || + comment === "退回修改" + ) { + emoji = "❌"; + } else if ( + (ev.rawAction === "freeflow.pay" || ev.action === "支付成功" || ev.action === "支付完成") && + (comment === "支付成功" || comment === "支付完成" || !comment) + ) { + emoji = "💰"; + } else if ( + ev.rawAction === "freeflow.addnode" || + ev.action?.includes("加签") || + ev.action?.includes("转交") || + ev.action?.includes("转办") || + comment?.includes("转交") || + comment?.includes("加签") + ) { + emoji = "🔀"; + } else if ( + ev.rawAction === "freeflow.paying" || + ev.rawAction === "freeflow.comment" || + ev.action === "发表评论" || + ev.action === "添加评论" || + (ev.rawAction === "freeflow.pay" && comment !== "支付成功") + ) { + emoji = "💬"; + } + + const emojiPrefix = emoji ? ` ${emoji}` : ""; + const line = `${nodePrefix}${emojiPrefix}: ${comment}`; if (lines.length === 0 || lines[lines.length - 1] !== line) { lines.push(line); } @@ -1007,19 +1053,23 @@ export function formatRejectionComment( (mar as any)?.rejectComment || "修改"; - let mainLine = rawComment; + let cleanComment = rawComment; + if (cleanComment.includes(":")) { + const parts = cleanComment.split(":"); + if (parts.length > 1) { + cleanComment = parts.slice(1).join(":").trim(); + } + } + + let mainLine = cleanComment; if (rawNodeName && opName) { - if (!rawComment.startsWith(`${rawNodeName}(${opName}):`)) { - mainLine = `${rawNodeName}(${opName}): ${rawComment}`; - } + mainLine = `${rawNodeName}(${opName}) ❌: ${cleanComment}`; } else if (opName) { - if (!rawComment.startsWith(`${opName}:`)) { - mainLine = `${opName}: ${rawComment}`; - } + mainLine = `${opName} ❌: ${cleanComment}`; } else if (rawNodeName) { - if (!rawComment.startsWith(`${rawNodeName}:`)) { - mainLine = `${rawNodeName}: ${rawComment}`; - } + mainLine = `${rawNodeName} ❌: ${cleanComment}`; + } else { + mainLine = cleanComment; } // Target node & operator @@ -1363,14 +1413,14 @@ export function alignApprovalRunsWithHoseFlow( if (!operator && ev.operator) operator = ev.operator; } if (retractEvent && !opinionLines.some((l) => l.includes("单据撤回"))) { - opinionLines.push(`提交人(${retractEvent.operator?.name || "提交人"}): 单据撤回`); + opinionLines.push(`提交人(${retractEvent.operator?.name || "提交人"}) ↩️: 单据撤回`); } eHumanComment = opinionLines.length > 1 ? formatNumberedHumanOpinions(opinionLines, [], "forward") : opinionLines.length === 1 ? opinionLines[0]! - : (retractEvent ? `提交人(${retractEvent.operator?.name || "提交人"}): 单据撤回` : "单据已撤回"); + : (retractEvent ? `提交人(${retractEvent.operator?.name || "提交人"}) ↩️: 单据撤回` : "单据已撤回"); } else { eHumanAction = "已修改重提"; const opinionLines = formatHumanOpinionLines(subsequentHumanEvents); @@ -1448,14 +1498,14 @@ export function alignApprovalRunsWithHoseFlow( if (!operator && ev.operator) operator = ev.operator; } if (retractEvent && !opinionLines.some((l) => l.includes("单据撤回"))) { - opinionLines.push(`提交人(${retractEvent.operator?.name || "提交人"}): 单据撤回`); + opinionLines.push(`提交人(${retractEvent.operator?.name || "提交人"}) ↩️: 单据撤回`); } eHumanComment = opinionLines.length > 1 ? formatNumberedHumanOpinions(opinionLines, [], "forward") : opinionLines.length === 1 ? opinionLines[0]! - : "单据已撤回"; + : (retractEvent ? `提交人(${retractEvent.operator?.name || "提交人"}) ↩️: 单据撤回` : "单据已撤回"); } else if (isFlowRejected || (!flow && isRunRejectedInSeal)) { // No rejectEvent in this run's window, but the current Hose flow state is rejected. eHumanAction = "审批驳回";