收敛树命令与投影切换
This commit is contained in:
@@ -4511,6 +4511,37 @@ fn create_command_wire(
|
||||
}
|
||||
}
|
||||
|
||||
async fn load_tree_move_preflight_data(
|
||||
state: &AppState,
|
||||
context: &RequestContext,
|
||||
workspace_id: &str,
|
||||
) -> Result<Value, WebError> {
|
||||
let spec = ProjectionSnapshotSpec {
|
||||
workspace_id,
|
||||
root_node_id: None,
|
||||
depth: Some(99),
|
||||
projection: KernelProjectionKind::SidebarTree,
|
||||
query: None,
|
||||
max_results: None,
|
||||
};
|
||||
let snapshot = load_projection_snapshot(state.config(), context, &spec)
|
||||
.await
|
||||
.map_err(|error| {
|
||||
WebError::bad_gateway_code(
|
||||
"tree_move_preflight_snapshot_failed",
|
||||
format!("移动前排序快照加载失败: {}", error.message()),
|
||||
)
|
||||
.with_context(context)
|
||||
.with_header("x-error-phase", "tree_move_preflight_snapshot")
|
||||
})?;
|
||||
let documents = snapshot
|
||||
.dataset
|
||||
.get("documents")
|
||||
.cloned()
|
||||
.unwrap_or_else(|| json!([]));
|
||||
Ok(json!({ "documents": documents }))
|
||||
}
|
||||
|
||||
async fn resolve_tree_create_workspace_id(
|
||||
state: &AppState,
|
||||
context: &RequestContext,
|
||||
@@ -4671,7 +4702,12 @@ pub async fn tree_command(
|
||||
_ => resolve_effective_workspace_id(&context, requested_workspace_id, true)?
|
||||
.expect("workspace_required 已确保存在"),
|
||||
};
|
||||
let command_wire = create_command_wire(&context, &effective_workspace_id, request)?;
|
||||
let needs_move_preflight = matches!(&request, TreeCommandRequest::Move { .. });
|
||||
let mut command_wire = create_command_wire(&context, &effective_workspace_id, request)?;
|
||||
if needs_move_preflight {
|
||||
command_wire.preflight_data =
|
||||
Some(load_tree_move_preflight_data(&state, &context, &effective_workspace_id).await?);
|
||||
}
|
||||
let execution = execute_runtime_command_via_convex_with_artifacts(
|
||||
state.config(),
|
||||
&context,
|
||||
|
||||
Reference in New Issue
Block a user