feat: 收口 tree-first graph 主链与前端测试修复
This commit is contained in:
@@ -6,14 +6,16 @@ use crate::routes::command_support::{
|
||||
read_optional_non_empty,
|
||||
};
|
||||
use crate::routes::query_support::{
|
||||
execute_runtime_query_against_data, fetch_query_data_via_convex, resolve_effective_workspace_id,
|
||||
resolve_effective_workspace_id,
|
||||
};
|
||||
use crate::routes::snapshot_support::{
|
||||
load_projection_snapshot, ProjectionSnapshotSpec,
|
||||
};
|
||||
use axum::extract::{Extension, Query, State};
|
||||
use axum::http::{header, HeaderValue, StatusCode};
|
||||
use axum::response::{Html, IntoResponse, Response};
|
||||
use axum::Json;
|
||||
use bridge_runtime::RuntimeCommandEnvelopeWire;
|
||||
use bridge_runtime::RuntimeQueryEnvelopeWire;
|
||||
use core_protocol::KernelProjectionKind;
|
||||
use serde::Deserialize;
|
||||
use serde_json::{json, Value};
|
||||
@@ -73,39 +75,6 @@ pub enum TreeCommandRequest {
|
||||
},
|
||||
}
|
||||
|
||||
fn tree_projection_query(
|
||||
workspace_id: &str,
|
||||
root_node_id: Option<&str>,
|
||||
depth: Option<u32>,
|
||||
mode: &str,
|
||||
) -> RuntimeQueryEnvelopeWire {
|
||||
RuntimeQueryEnvelopeWire {
|
||||
name: "kernel.project_view".into(),
|
||||
payload: json!({
|
||||
"projection": if mode == "filetree" {
|
||||
KernelProjectionKind::FileTree
|
||||
} else {
|
||||
KernelProjectionKind::PageTree
|
||||
},
|
||||
"workspaceId": workspace_id,
|
||||
"rootNodeId": root_node_id,
|
||||
"depth": depth,
|
||||
"includeEdges": true,
|
||||
"includeContent": false,
|
||||
"nodeTypes": ["page"],
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
fn sidebar_dataset_query(workspace_id: &str) -> RuntimeQueryEnvelopeWire {
|
||||
RuntimeQueryEnvelopeWire {
|
||||
name: "sidebar.dataset.list".into(),
|
||||
payload: json!({
|
||||
"workspaceId": workspace_id,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
fn escape_html(input: &str) -> String {
|
||||
input
|
||||
.replace('&', "&")
|
||||
@@ -1918,24 +1887,21 @@ pub async fn tree_shell(
|
||||
let mode = normalize_tree_mode(query.mode.as_deref());
|
||||
let allow_root_pick = normalize_bool_flag(query.allow_root_pick.as_deref(), false);
|
||||
let exclude_ids = parse_exclude_ids(query.exclude_ids.as_deref());
|
||||
let dataset = fetch_query_data_via_convex(
|
||||
let snapshot = load_projection_snapshot(
|
||||
state.config(),
|
||||
&effective_context,
|
||||
Some(&effective_workspace_id),
|
||||
sidebar_dataset_query(&effective_workspace_id),
|
||||
&ProjectionSnapshotSpec {
|
||||
workspace_id: &effective_workspace_id,
|
||||
root_node_id: query.root_node_id.as_deref(),
|
||||
depth: query.depth,
|
||||
projection: if mode == "filetree" {
|
||||
KernelProjectionKind::FileTree
|
||||
} else {
|
||||
KernelProjectionKind::PageTree
|
||||
},
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
let projection = execute_runtime_query_against_data(
|
||||
&effective_context,
|
||||
Some(&effective_workspace_id),
|
||||
tree_projection_query(
|
||||
&effective_workspace_id,
|
||||
query.root_node_id.as_deref(),
|
||||
query.depth,
|
||||
mode,
|
||||
),
|
||||
dataset.clone(),
|
||||
)?;
|
||||
let html = build_tree_shell_html(
|
||||
&effective_workspace_id,
|
||||
query.root_node_id.as_deref(),
|
||||
@@ -1943,11 +1909,11 @@ pub async fn tree_shell(
|
||||
&normalize_channel(query.channel),
|
||||
query.host.as_deref(),
|
||||
&effective_context,
|
||||
&projection,
|
||||
&snapshot.projection,
|
||||
mode,
|
||||
allow_root_pick,
|
||||
&exclude_ids,
|
||||
&dataset,
|
||||
&snapshot.dataset,
|
||||
);
|
||||
let mut response = Html(html).into_response();
|
||||
response
|
||||
|
||||
Reference in New Issue
Block a user