feat: 提交 task-045 至 task-058 收口产物

- 收口 rust final closure checklist,推进页面/块系统/Mindmap/CLI/AI tools 到最终 cutover 状态

- 按 ai-frontend-simplification-plan-v1 接入 Hermes bridge,合并 AI 面板并清理旧前端编排残留

- 补充 harness 任务与进度记录,加入 CLI smoke 夹具/脚本,并修正文档页 bridge SSR 自请求回退逻辑
This commit is contained in:
lix-2026
2026-04-16 15:24:37 +08:00
parent 98db79b301
commit 2ff10fa86c
47 changed files with 6494 additions and 2674 deletions
@@ -1,7 +1,6 @@
import { NextResponse } from "next/server";
import { isConvexEnabled } from "@/lib/convex/enabled";
import { getAuthedConvexClient } from "@/lib/convex/route";
import { api } from "@/lib/convex/api";
import { buildMindmapRouteMeta } from "@/lib/mindmap/mindmapRouteMeta";
import {
buildDocumentBridgeContextWithActor,
@@ -172,7 +171,43 @@ export async function DELETE(
if (isConvexEnabled()) {
const { auth, client } = await getAuthedConvexClient();
try {
const result = await client.mutation(api.mindmaps.softDelete, { docId, mindmapId });
const context = buildDocumentBridgeContextWithActor({
request,
actor: {
actorType: "user",
actorId: auth.userId,
sessionId: null,
},
workspaceId: null,
source: {
channel: "mindmap-route",
client: "wolai-frontend",
},
});
const envelope = buildDocumentCommandEnvelope({
name: "mindmaps.delete",
payload: {
documentId: docId,
mindmapId,
},
context,
target: {
workspaceId: null,
pageId: docId,
blockId: mindmapId,
},
reason: "mindmap-route:delete",
refs: ["task-047", "mindmap-route"],
});
const plan = await resolveRustBridgeCommandPlan({ context, envelope });
const result = await executeRustBridgeMutationTransport<{
ok?: boolean;
workspace_id?: string | null;
deleted_at?: string | null;
}>({
client,
plan,
});
return NextResponse.json({
...(result ?? { ok: true }),
meta: {
@@ -186,7 +221,7 @@ export async function DELETE(
},
});
} catch (error) {
return NextResponse.json({ error: (error as Error).message }, { status: 400 });
return documentBridgeErrorResponse(error);
}
}
@@ -207,19 +242,43 @@ export async function PATCH(
}
try {
if (action === "purge") {
const result = await client.mutation(api.mindmaps.purge, { docId, mindmapId });
return NextResponse.json({
...(result ?? { ok: true }),
meta: buildMindmapRouteMeta(request, {
workspaceId: result?.workspace_id ?? null,
documentId: docId,
mindmapId,
ownerUserId: auth.userId,
}),
});
}
const result = await client.mutation(api.mindmaps.restore, { docId, mindmapId });
const context = buildDocumentBridgeContextWithActor({
request,
actor: {
actorType: "user",
actorId: auth.userId,
sessionId: null,
},
workspaceId: null,
source: {
channel: "mindmap-route",
client: "wolai-frontend",
},
});
const envelope = buildDocumentCommandEnvelope({
name: action === "purge" ? "mindmaps.purge" : "mindmaps.restore",
payload: {
documentId: docId,
mindmapId,
},
context,
target: {
workspaceId: null,
pageId: docId,
blockId: mindmapId,
},
reason: `mindmap-route:${action}`,
refs: ["task-047", "mindmap-route"],
});
const plan = await resolveRustBridgeCommandPlan({ context, envelope });
const result = await executeRustBridgeMutationTransport<{
ok?: boolean;
workspace_id?: string | null;
updated_at?: string | null;
}>({
client,
plan,
});
return NextResponse.json({
...(result ?? { ok: true }),
meta: {
@@ -229,13 +288,11 @@ export async function PATCH(
mindmapId,
ownerUserId: auth.userId,
}),
updatedAt: result?.updated_at ?? null,
updatedAt: action === "restore" ? result?.updated_at ?? null : null,
},
});
} catch (error) {
const msg = (error as Error).message ?? "操作失败";
const status = msg.includes("未找到") ? 404 : 400;
return NextResponse.json({ error: msg }, { status });
return documentBridgeErrorResponse(error);
}
}
@@ -1,7 +1,6 @@
import { NextResponse } from "next/server";
import { isConvexEnabled } from "@/lib/convex/enabled";
import { getAuthedConvexClient } from "@/lib/convex/route";
import { api } from "@/lib/convex/api";
import {
buildDocumentBridgeContextWithActor,
buildDocumentCommandEnvelope,
@@ -179,19 +178,59 @@ export async function DELETE(
if (isConvexEnabled()) {
const { auth, client } = await getAuthedConvexClient();
const mindmapId = `legacy-${docId}`;
const result = await client.mutation(api.mindmaps.softDelete, { docId, mindmapId });
return NextResponse.json({
...(result ?? { ok: true }),
meta: {
...buildMindmapRouteMeta(request, {
workspaceId: result?.workspace_id ?? null,
try {
const context = buildDocumentBridgeContextWithActor({
request,
actor: {
actorType: "user",
actorId: auth.userId,
sessionId: null,
},
workspaceId: null,
source: {
channel: "mindmap-route",
client: "wolai-frontend",
},
});
const envelope = buildDocumentCommandEnvelope({
name: "mindmaps.delete",
payload: {
documentId: docId,
mindmapId,
ownerUserId: auth.userId,
}),
deletedAt: result?.deleted_at ?? null,
},
});
},
context,
target: {
workspaceId: null,
pageId: docId,
blockId: mindmapId,
},
reason: "mindmap-route:delete",
refs: ["task-047", "mindmap-route"],
});
const plan = await resolveRustBridgeCommandPlan({ context, envelope });
const result = await executeRustBridgeMutationTransport<{
ok?: boolean;
workspace_id?: string | null;
deleted_at?: string | null;
}>({
client,
plan,
});
return NextResponse.json({
...(result ?? { ok: true }),
meta: {
...buildMindmapRouteMeta(request, {
workspaceId: result?.workspace_id ?? null,
documentId: docId,
mindmapId,
ownerUserId: auth.userId,
}),
deletedAt: result?.deleted_at ?? null,
},
});
} catch (error) {
return documentBridgeErrorResponse(error);
}
}
return NextResponse.json({ error: "当前仅支持 Convex 模式" }, { status: 501 });