Repository navigation
feat: unify documentation and file management - #801
Conversation
- Introduced a new migration to unify documentation folders into the file management system, allowing documents to be stored alongside files. - Updated the API to reflect changes in folder and document handling, ensuring that documents are treated as files within the file manager. - Enhanced route coverage tests to include new file documentation gates. - Modified the router to accommodate new file area checks and documentation routes. - Implemented changes in the file handler to support the new structure and ensure proper authorization checks. - Added end-to-end tests to verify the integration of documentation within the file management API. - Updated existing tests to reflect changes in document handling, including soft deletion and restoration processes.
There was a problem hiding this comment.
Important
Two things should be fixed before merge: the Files folder listing (and Relations) returns documents that a per-document Deny hides from the docs tree, and a backslash in a Documentation folder name now fails with a 500. A third, narrower authorization gap for trashed documents is noted inline.
Approach: sound — the writable doc_folders view plus kind='doc' rows in file_items keeps every existing docs query, the by-path/MCP contracts and the change feed working while making Files the single folder tree; the one place the abstraction leaks is where document rows reach Files responses without the caller's document scope.
Reviewed changes — the full 68-file diff at 05e9e62, including the migration, repository/service, HTTP/IAM and web changes, plus the new tests.
- Migration
000096— movesdoc_foldersintofile_foldersunder a locked per-projectdocumentationfolder behind a writabledoc_foldersview; addsposition/area/created_by_member,documents.trashed_at, the doc branch andareainfile_items, and moves the folder change-feed triggers, with folder deletes now trashing the subtree. - Files backend — documents and documentation folders are read-only for rename/move; trash/restore/purge handle
kind='doc'andtrashed_at(counter first, one stamp for a subtree, content erased but tombstone kept on purge); addsFileNodeArea,Relations,RecordOpen. - HTTP/IAM —
RequireFileDocsAreaadds the docs action to project file routes (both ends of a move,doc/<id>for a document), doc-scope filtering for search/starred/recent/trash,GET /docs/{id}/markdown, and the route-coverage table. - Web — Documentation and its documents appear in Files (open in the editor, rename/move through the docs API, star/trash/restore through Files), Markdown uploads into Documentation become documents, relations show in Details, the docs sidebar lists folder files, and
PathBreadcrumbis shared with the docs editor.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the incremental commit 4d43947 since the prior review at 05e9e62, covering the three prior findings and their tests.
- Document scope on folder browsing and relations —
docRowsClausefilterskind='doc'rows in the parent branch, andRelationsnow runs under the caller's document scope with the handler attachingdocScoped; new PG tests cover scoped browse and relations. - Folder name validation —
docdom.ValidFolderNamerejects empty/whitespace and/or\, and is used bycreateFolder,updateFolderand the by-path folder creation, so a backslash returnsErrFolderNameInvalid(400) instead of a 500. - Trashed document authorization — the
docattribute loader now resolves documents wheredeleted_at IS NULL OR trashed_at IS NOT NULL, so restore/permanent-delete from Files can be authorized on the document; a plain soft-delete still does not resolve. New loader test covers both.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — one minor timing issue inline in the new spec.
Reviewed changes — the new Playwright spec added in 71a6e52, read against the web implementation and the API it drives.
- New e2e spec —
apps/e2e/tests/files/documentation-in-files.spec.tscovers the Documentation tree in Files, New-document scoping, Markdown upload conversion, Markdown download, rename/move, star/recent/search, document and folder trash/restore, the locked Documentation folder, the shared editor breadcrumb, and files in the docs sidebar.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the incremental commit 770c434 since the prior review at 71a6e52, which closes the one open finding from that review.
- Download timing — the editor spec now waits for the loaded document title in the breadcrumb before clicking, and
DocumentPanedisables the Download as Markdown button untildocresolves, so the filename can no longer fall back toUntitled.md.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
…oved folder handling and migration tests
There was a problem hiding this comment.
ℹ️ No critical issues — the delta is sound; one documentation inconsistency inline.
Reviewed changes — the incremental commit e09025a since the prior review at 770c434: the relations tasks:read gate, the migration's slash sanitization, a new Postgres test, and the design doc's known-limits section.
- Relations gate —
mountFileRoutesnow takes atasksReadgate (require.Project(iam.ActionTasksRead)) applied toGET /nodes/{nodeId}/relations, closing the task title/key exposure for roles withouttasks:read; the general scope passesnil, where the service already returns empty relations. - Folder-name sanitization — the migration replaces both
/and\before inserting intofile_folders, so a legacy name with a slash can no longer failchk_file_folders_name; the migration test coversQ1/Q2and the row count. - Unscoped lists and nested restore — a new PG test pins that Starred/Recent/Trash leave docs-area nodes out without a document scope, and that a docs folder restored under a still-trashed parent returns to the top of Documentation with
area='docs'. - Known limits — documents the folder-trash permission tradeoff, the unindexed relations content scan, the
doc_foldersfull-row update requirement, and the newtasks:readrequirement.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Summary
Documentation and Files are now one folder tree. A documentation folder is a folder of the project's Files under a locked Documentation folder, and a document is the Markdown file
<title>.mdin it, with the file features (rename, move, star, recents, search, trash, download). Implements #795.Design and decisions:
docs/product/unified-documentation-files.md.What changes for users
<title>.md(Files, docs sidebar, editor header). A.mdor.markdownfile uploaded or dropped into Documentation becomes a document, including inside dropped folders; a leading# headingbecomes the title.PathBreadcrumb: the docs look, ancestors that open their folder, drop targets for move-by-drag, and a "…" menu for long paths.Behaviour changes to know about
DELETE /docs/{id}andDELETE /docs/folders/{id}also go to the trash and are restorable from Files.docs:read|writeto look or change, on the document itself when the node is one, so per-document Deny rules apply).How it works
000096_documentation_in_files.sql.file_folders(same ids) under a per-projectdocumentationsystem folder.file_foldersgainsposition,area(docsfor the subtree) andcreated_by_member.doc_foldersstays as an updatable view over the subtree (INSTEAD OFtriggers), so the docs code, the IAM loaders and the MCP mirror are unchanged. The change-feed trigger moves tofile_folders.documents.trashed_atmarks restorable deletions;deleted_atstays the soft-delete and the feed's tombstone. Documents deleted before this, and notes removed with a view, are not in the trash and are never purged. Purging erases a document's content and snapshots and keeps the tombstone.file_itemsgains thedockind (<title>.md,text/markdown) andarea.schema_migrationsentries replaced (or to be recreated).RequireFileDocsAreaadds the docs action wherever a file route names a node (URL, query or body) in Documentation, for both ends of a move.GET /projects/{id}/docs/{docId}/markdownrenders withdocdom.RenderMarkdown, shared with the project zip export. Upload conversion is in the web app with BlockNote's own parser, so a raw API upload of a.mdstays a plain file.GET /files/nodes/{id}/relations,POST /files/nodes/{id}/open,GET /docs/{id}/markdown.Not in this PR
doc_foldersview (the docs repository still reads it).Testing
files_docs_test.go) covering the tree, Markdown download, star/recent/search, rename and trash/restore. Existing doc e2e tests updated for the new folder-delete behaviour.tsc -band biome clean; unit tests for Markdown import and the breadcrumb; all nine locales updated.apps/e2e/tests/files; three checks were updated for the breadcrumb) and a manual pass in the browser.