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:
@@ -1,9 +1,15 @@
|
||||
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 } from "@/lib/documents/bridge";
|
||||
import { executeRustBridgeTool } from "@/lib/documents/rust-runtime";
|
||||
import {
|
||||
buildDocumentBridgeContextWithActor,
|
||||
buildDocumentCommandEnvelope,
|
||||
documentBridgeErrorResponse,
|
||||
} from "@/lib/documents/bridge";
|
||||
import {
|
||||
executeRustBridgeMutationTransport,
|
||||
resolveRustBridgeCommandPlan,
|
||||
} from "@/lib/documents/rust-runtime";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -13,39 +19,47 @@ interface EmptyTrashPayload {
|
||||
|
||||
export async function POST(request: Request) {
|
||||
if (isConvexEnabled()) {
|
||||
const { client } = await getAuthedConvexClient();
|
||||
const { auth, client } = await getAuthedConvexClient();
|
||||
const { workspaceId }: EmptyTrashPayload = await request.json().catch(() => ({}));
|
||||
if (!workspaceId) {
|
||||
return NextResponse.json({ error: "缺少 workspaceId" }, { status: 400 });
|
||||
}
|
||||
|
||||
const context = buildDocumentBridgeContextWithActor({
|
||||
request,
|
||||
actor: {
|
||||
actorType: "service",
|
||||
actorId: "mindmap-trash-empty",
|
||||
sessionId: null,
|
||||
},
|
||||
workspaceId,
|
||||
source: {
|
||||
channel: "mindmap-trash-route",
|
||||
client: "wolai-frontend",
|
||||
},
|
||||
});
|
||||
await executeRustBridgeTool({
|
||||
context,
|
||||
toolName: "mindmap_empty_trash",
|
||||
invocationKind: "command",
|
||||
args: { workspaceId },
|
||||
data: { workspaceId, source: "mindmap-trash-empty" },
|
||||
mode: "result",
|
||||
});
|
||||
|
||||
try {
|
||||
const result = await client.mutation(api.mindmaps.emptyTrashByWorkspace, { workspaceId });
|
||||
const context = buildDocumentBridgeContextWithActor({
|
||||
request,
|
||||
actor: {
|
||||
actorType: "user",
|
||||
actorId: auth.userId,
|
||||
sessionId: null,
|
||||
},
|
||||
workspaceId,
|
||||
source: {
|
||||
channel: "mindmap-trash-route",
|
||||
client: "wolai-frontend",
|
||||
},
|
||||
});
|
||||
const envelope = buildDocumentCommandEnvelope({
|
||||
name: "mindmaps.emptyTrashByWorkspace",
|
||||
payload: { workspaceId },
|
||||
context,
|
||||
target: {
|
||||
workspaceId,
|
||||
},
|
||||
reason: "mindmap-trash:empty",
|
||||
refs: ["task-047", "mindmap-trash"],
|
||||
});
|
||||
const plan = await resolveRustBridgeCommandPlan({ context, envelope });
|
||||
const result = await executeRustBridgeMutationTransport<{
|
||||
ok?: boolean;
|
||||
deletedCount?: number;
|
||||
}>({
|
||||
client,
|
||||
plan,
|
||||
});
|
||||
return NextResponse.json({ ok: true, removed: result?.deletedCount ?? 0 });
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: (error as Error).message }, { status: 400 });
|
||||
return documentBridgeErrorResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user