fix(channelbridge): IM 发送过滤 action/narration + <p>拆多气泡 + 0.5-2s 间隔
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

把回复转发给 IM 适配器(sendReply)时剥掉 <action>/<narration> 动作/内心独白(Web 端
才渲染灰斜体,IM 只能收纯文本),并按 <p> 段落拆成多条气泡分别发送;多气泡发送间隔
随机 0.5~2s(仅 IM,Web 前端不延迟)。新增 sanitize.go stripNarration/splitBubbles/
bubbleGap + 测试。
This commit is contained in:
Aska committed 2026-09-07 17:50:56 +08:00
1 parent dcb0b33954
commit 5a0c1e2fd1
11 files changed
+790 -12

No files matched your search

@@ -0,0 +1,58 @@
import { useCallback, useState } from "react";
import {
adminChannelOpen,
adminChannelClose,
adminDeleteChannelAccount,
} from "../../../lib/api";
import { useAuditStore } from "../../audit";
/** Shared connect/disconnect/delete actions + busy/error/notice state, reused by
* the list page and each adapter detail page. `reload` re-fetches the channel
* list after a mutation. */
export function useChannelActions(reload: () => void) {
const log = useAuditStore((s) => s.log);
const [busy, setBusy] = useState<string | null>(null);
const [error, setError] = useState<string | null>(null);
const [notice, setNotice] = useState<string | null>(null);
const toggle = useCallback(
(name: string, connect: boolean) => {
setBusy(name);
setError(null);
const call = connect ? adminChannelOpen(name) : adminChannelClose(name);
call
.then(() => {
log(connect ? "channel.open" : "channel.close", "ok");
reload();
})
.catch((e: unknown) => {
log(connect ? "channel.open" : "channel.close", "error");
setError(e instanceof Error ? e.message : `${connect ? "连接" : "断开"}失败`);
})
.finally(() => setBusy(null));
},
[reload, log],
);
const del = useCallback(
(platform: string, id: string) => {
setBusy("__del__" + id);
setError(null);
setNotice(null);
adminDeleteChannelAccount(platform, id)
.then(() => {
log("channel.delete", "ok");
setNotice(`已删除账号 ${id} 并热更新 ${platform}`);
reload();
})
.catch((e: unknown) => {
log("channel.delete", "error");
setError(e instanceof Error ? e.message : "删除渠道账号失败");
})
.finally(() => setBusy(null));
},
[reload, log],
);
return { busy, setBusy, error, setError, notice, setNotice, toggle, del };
}