Q32: documents and knowledge appear in global search

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-08 06:33:00 -04:00
1 parent 5c8233d258
commit cb464c3ee4
5 files changed
+58

No files matched your search

+20
View File
@@ -88,6 +88,8 @@ export class SearchService {
...this.providerDocs(orgId),
...this.socialDocs(orgId),
...this.scheduledPostDocs(orgId),
...this.documentDocs(orgId),
...this.knowledgeDocs(orgId),
];
}
@@ -156,6 +158,24 @@ export class SearchService {
return rows.map((row) => doc("scheduled_post", row.id, createTitle(row.body_md), row.body_md, { type: "Social", state: row.state, account: row.social_account_id }));
}
private documentDocs(orgId: string): SearchDoc[] {
const rows = this.db.prepare("select id, title, doc_type, status, content from documents where org_id = ?").all(orgId) as Array<{ id: string; title: string; doc_type: string; status: string; content: string }>;
return rows.map((row) => doc("document", row.id, row.title, row.content, { type: "Library", kind: row.doc_type, status: row.status }));
}
private knowledgeDocs(orgId: string): SearchDoc[] {
const rows = this.db.prepare("select id, topic, category, content, scope_type, superseded_by, valid_until from knowledge_entries where org_id = ?").all(orgId) as Array<{
id: string; topic: string; category: string; content: string; scope_type: string; superseded_by: string | null; valid_until: string | null;
}>;
const now = new Date().toISOString();
return rows.map((row) => doc("knowledge", row.id, row.topic, row.content, {
type: "Library",
category: row.category,
scope: row.scope_type,
state: row.superseded_by ? "superseded" : row.valid_until && row.valid_until <= now ? "expired" : "active",
}));
}
private canRead(orgId: string, employeeId: string, entityType: SearchEntityType, entityId: string): boolean {
if (entityType === "chat_space") return this.canReadSpace(entityId, employeeId);
if (entityType === "chat_message") return this.canReadMessage(orgId, entityId, employeeId);
+1
View File
@@ -27,6 +27,7 @@ export const zh: Record<string, string> = {
"Advance": "推进",
"Advanced": "高级",
"Integrations": "集成密钥",
"Document": "文档",
"Applies to": "适用范围",
"Category": "类别",
"Content": "内容",
+3
View File
@@ -21,6 +21,8 @@ const LABELS: Record<SearchEntityType, string> = {
provider: t("Provider"),
social_account: t("Social"),
scheduled_post: t("Post"),
document: t("Document"),
knowledge: t("Knowledge"),
};
export function SearchDialog({
@@ -142,6 +144,7 @@ function routeFor(entityType: SearchEntityType): RouteId {
if (entityType === "file") return "files";
if (entityType === "provider") return "settings";
if (entityType === "social_account" || entityType === "scheduled_post") return "connectors";
if (entityType === "document" || entityType === "knowledge") return "library";
return "work";
}
+2
View File
@@ -12,6 +12,8 @@ export const SEARCH_ENTITY_TYPES = [
"provider",
"social_account",
"scheduled_post",
"document",
"knowledge",
] as const;
export type SearchEntityType = (typeof SEARCH_ENTITY_TYPES)[number];