Improve local evidence search and AI capabilities
This commit is contained in:
@@ -16,6 +16,7 @@ pub struct FileTreeRenderRow {
|
||||
pub asset_id: Option<String>,
|
||||
pub relative_path: Option<String>,
|
||||
pub object_identity: Option<String>,
|
||||
pub index_status: Option<String>,
|
||||
pub selected: bool,
|
||||
}
|
||||
|
||||
@@ -90,8 +91,13 @@ fn render_filetree_row(
|
||||
_ => "",
|
||||
};
|
||||
let owner_document_id = row.document_id.as_deref().unwrap_or_default();
|
||||
let index_status_attr = row
|
||||
.index_status
|
||||
.as_deref()
|
||||
.map(|status| format!(r#" data-index-status="{}""#, escape_html(status)))
|
||||
.unwrap_or_default();
|
||||
html.push_str(&format!(
|
||||
r#"<li class="tree-node" data-node-id="{node_id}"><div class="tree-row" role="treeitem" aria-level="{aria_level}" aria-expanded="{expanded_attr}" data-rust-rendered-row="filetree" data-testid="{test_id}" data-row-id="{row_id}" data-row-kind="{row_kind}" data-node-id="{node_id}"{parent_attr} data-document-id="{document_id}" data-doc-id="{document_id}" data-owner-document-id="{owner_document_id}" data-asset-id="{asset_id}" data-local-relative-path="{relative_path}" data-object-identity="{object_identity}" data-shell-mode="filetree" data-selected="{selected}" data-active="false" draggable="true">{toggle_html}<span class="tree-kind-badge" data-kind="{icon_kind}" aria-hidden="true"></span><button type="button" class="tree-link" data-rust-action="open" data-row-id="{row_id}" data-document-id="{document_id}" data-owner-document-id="{owner_document_id}" data-asset-id="{asset_id}" data-local-relative-path="{relative_path}" title="{title}"><span class="tree-link-title" title="{title}">{title}</span></button><div class="tree-actions">{create_action_html}<button type="button" class="tree-action" data-testid="filetree-action-menu" data-rust-action="menu" data-row-id="{row_id}" aria-label="更多操作">…</button></div></div>"#,
|
||||
r#"<li class="tree-node" data-node-id="{node_id}"><div class="tree-row" role="treeitem" aria-level="{aria_level}" aria-expanded="{expanded_attr}" data-rust-rendered-row="filetree" data-testid="{test_id}" data-row-id="{row_id}" data-row-kind="{row_kind}" data-node-id="{node_id}"{parent_attr} data-document-id="{document_id}" data-doc-id="{document_id}" data-owner-document-id="{owner_document_id}" data-asset-id="{asset_id}" data-local-relative-path="{relative_path}" data-object-identity="{object_identity}"{index_status_attr} data-shell-mode="filetree" data-selected="{selected}" data-active="false" draggable="true">{toggle_html}<span class="tree-kind-badge" data-kind="{icon_kind}" aria-hidden="true"></span><button type="button" class="tree-link" data-rust-action="open" data-row-id="{row_id}" data-document-id="{document_id}" data-owner-document-id="{owner_document_id}" data-asset-id="{asset_id}" data-local-relative-path="{relative_path}" title="{title}"><span class="tree-link-title" title="{title}">{title}</span></button><div class="tree-actions">{create_action_html}<button type="button" class="tree-action" data-testid="filetree-action-menu" data-rust-action="menu" data-row-id="{row_id}" aria-label="更多操作">…</button></div></div>"#,
|
||||
node_id = escape_html(&row.node_id),
|
||||
aria_level = row.depth + 1,
|
||||
expanded_attr = if row.expandable && row.expanded { "true" } else { "false" },
|
||||
@@ -104,6 +110,7 @@ fn render_filetree_row(
|
||||
asset_id = escape_html(row.asset_id.as_deref().unwrap_or_default()),
|
||||
relative_path = escape_html(row.relative_path.as_deref().unwrap_or_default()),
|
||||
object_identity = escape_html(row.object_identity.as_deref().unwrap_or_default()),
|
||||
index_status_attr = index_status_attr,
|
||||
selected = row.selected,
|
||||
toggle_html = toggle_html,
|
||||
icon_kind = escape_html(&row.icon_kind),
|
||||
@@ -182,6 +189,7 @@ mod tests {
|
||||
object_identity: Some(
|
||||
r#"{"objectKind":"page","documentId":"page_root","blockId":null,"assetId":null}"#.into(),
|
||||
),
|
||||
index_status: None,
|
||||
selected: true,
|
||||
},
|
||||
FileTreeRenderRow {
|
||||
@@ -200,6 +208,7 @@ mod tests {
|
||||
object_identity: Some(
|
||||
r#"{"objectKind":"mindmap","documentId":"page_root","blockId":null,"assetId":"mind_1"}"#.into(),
|
||||
),
|
||||
index_status: None,
|
||||
selected: false,
|
||||
},
|
||||
],
|
||||
@@ -241,6 +250,7 @@ mod tests {
|
||||
asset_id: None,
|
||||
relative_path: Some("docs".into()),
|
||||
object_identity: None,
|
||||
index_status: None,
|
||||
selected: false,
|
||||
},
|
||||
FileTreeRenderRow {
|
||||
@@ -257,6 +267,7 @@ mod tests {
|
||||
asset_id: None,
|
||||
relative_path: Some("docs/README.md".into()),
|
||||
object_identity: None,
|
||||
index_status: None,
|
||||
selected: false,
|
||||
},
|
||||
],
|
||||
@@ -286,11 +297,13 @@ mod tests {
|
||||
asset_id: None,
|
||||
relative_path: Some("design/03-rust-web".into()),
|
||||
object_identity: None,
|
||||
index_status: Some("indexed".into()),
|
||||
selected: false,
|
||||
}],
|
||||
});
|
||||
|
||||
assert!(html.contains(r#"data-local-relative-path="design/03-rust-web""#));
|
||||
assert!(html.contains(r#"data-index-status="indexed""#));
|
||||
assert!(html.contains(r#"<button type="button" class="tree-link""#));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user