feat(KnowledgeBase): add document viewer, download, metadata, and sorting#721
feat(KnowledgeBase): add document viewer, download, metadata, and sorting#721bravosierra99 wants to merge 1 commit into
Conversation
|
Thanks @bravosierra99 — the feature itself (view + download + metadata columns for KB files) is solid and genuinely useful. Good security posture too (path-traversal guards, restricting viewable types to text, no actions on system-owned docs). One problem though: your branch is significantly behind current GitHub is marking it DIRTY/CONFLICTING as a result, and there's no practical way to review this until the noise is separated from the signal. Could you rebase onto current
Cleanest path is usually to create a new branch off current Appreciate the work — want to get this one landed, just need the diff manageable first. |
f2bc3cb to
226c130
Compare
226c130 to
146af92
Compare
|
I rebased again, and pushed some updates... I think my testing wasn't quite on exactly what was in the PR. It should be up to date from now and I did some quick sanity checking of the functionality. There should be no remaining conflicts. Let me know if this works for you @chriscrosstalk |
jakeaturner
left a comment
There was a problem hiding this comment.
@bravosierra99 great stuff here - just a couple quick changes and this will be ready to merge. Thanks for the contribution!
| return fileName.split('.').at(-1)?.toLowerCase() ?? '' | ||
| } | ||
|
|
||
| function formatBytes(bytes: number | null): string { |
There was a problem hiding this comment.
Existing formatBytes utility available from ~/lib/util -- import from there for DRY
| * Only serves files within the uploads directory (path-traversal safe). | ||
| * Returns null if the file is outside the uploads dir, doesn't exist, or is binary. | ||
| */ | ||
| public async readFileContent(source: string): Promise<{ content: string; extension: string; fileName: string } | null> { |
There was a problem hiding this comment.
Good baseline for path traversal protection but technically still allows reading from anywhere in the app directory (process.cwd()). We should follow pattern from docs_service or even similar check in rag_service for tighter scoping and consistency
146af92 to
a84fd7e
Compare
|
updates made. |
…ting Rebuilt on top of dev's RFC Crosstalk-Solutions#883 state-machine UI rather than the now-defunct StoredFile shape: - Extend StoredFileInfo with fileName/size/uploadedAt/isUserUpload - Populate metadata from on-disk stats in RagService.getStoredFiles - Add fileSourceSchema validator + getFileContent/downloadFile endpoints scoped to the uploads directory only (tighter than the original PR — matches docs_service traversal pattern) - KnowledgeBaseModal: sortable Size and Uploaded columns; View/Download buttons on upload-bucket rows; new FileViewerModal for in-browser text preview. Bucket grouping preserved — sort applies within each bucket. - Use formatBytes from ~/lib/util rather than redefining
a84fd7e to
51ea98e
Compare
|
▎ @jakeaturner heads up — I force-pushed this branch with a full rebuild on current dev rather than a |
|
Thanks @bravosierra99 — the file viewer/download piece here is still very much wanted (it's the core of #952). Heads up though: this branch predates the Knowledge Base ingestion rework that shipped in v1.32.0, and there's significant overlap. On current Could you rebase onto current |
Adds view, download, and metadata improvements to the Knowledge Base stored files table.
Changes
Backend (
rag_controller.ts,rag_service.ts,rag.ts,routes.ts,types/rag.ts)getStoredFilesnow returnsStoredFile[]withfileName,size,uploadedAt, andisUserUploadinstead ofstring[]GET /api/rag/files/content— serves text file contents for inline viewing; restricted to text extensions, path-traversal safe (app directory only)GET /api/rag/files/download— serves file as attachment; same path guardFrontend (
KnowledgeBaseModal.tsx,api.ts)Files changed
admin/app/controllers/rag_controller.tsadmin/app/services/rag_service.tsadmin/app/validators/rag.tsadmin/start/routes.tsadmin/types/rag.tsadmin/inertia/components/chat/KnowledgeBaseModal.tsxadmin/inertia/lib/api.ts