fix: allow deleting system default sync channel with immediate heal

Remove hard ban that returned 400 with no UI feedback; delete then Ensure+rebinding, and show confirm/toast on SyncPage.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
whm
2026-08-06 09:03:41 +08:00
parent 362dcee242
commit 75622a728e
4 changed files with 56 additions and 16 deletions

View File

@@ -586,9 +586,35 @@ export function SyncPage(props: {
<Button
size="small"
danger
onClick={async () => {
await deleteSyncChannel(session, r.id);
await refresh();
onClick={() => {
Modal.confirm({
title: `删除通道「${r.name || r.id}」?`,
content: r.is_system_default
? "这是公司默认同步通道。删除后将自动重建并重挂库绑定,账号落点不会丢失。"
: "删除后,仍挂在此通道上的绑定会自动改挂公司默认同步通道。",
okText: "确认删除",
okType: "danger",
cancelText: "取消",
onOk: async () => {
setBusy(true);
try {
const res = await deleteSyncChannel(session, r.id);
if (res.heal_error) {
message.warning(`通道已删,自愈未完成:${res.heal_error}`);
} else if (res.recreated_default) {
message.success("已删除;公司默认同步通道已自动重建并重挂绑定");
} else {
message.success("已删除");
}
await refresh();
} catch (e: any) {
message.error(e.message || String(e));
throw e;
} finally {
setBusy(false);
}
},
});
}}
>

View File

@@ -869,6 +869,8 @@ export type SyncChannel = {
pk_columns: Record<string, string>;
/** 绑定智能体:模块/库归属对照 */
agent_id?: number;
/** 公司默认同步通道Z12 */
is_system_default?: boolean;
/** 绑定已发布模块 slug */
app_slug?: string;
last_error?: string;
@@ -966,6 +968,16 @@ export async function deleteSyncChannel(session: Session, id: string) {
});
const data = await readJson(res);
throwIfBad(res, data, "delete sync channel failed");
return data as {
ok?: boolean;
deleted_id?: string;
was_system_default?: boolean;
recreated_default?: boolean;
channel_id?: string;
bindings_fixed?: number;
agents_fixed?: number;
heal_error?: string;
};
}
export async function testSyncEndpoints(