Skip to content

feat: unify documentation and file management - #801

Merged
pikann merged 6 commits into
masterfrom
feature/unify-documentation-and-file-management
Nov 20, 2026
Merged

pikann merged 6 commits into
masterfrom
feature/unify-documentation-and-file-management

Conversation

@pikann

@pikann pikann commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

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>.md in 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

  • Files shows Documentation. The Documentation folder, its subfolders and its documents appear in Files (grid and list). A document opens in the docs editor. New inside Documentation offers Document, New folder and the uploads.
  • Files in documentation folders (the issue): upload into a folder from the docs sidebar (or drag in Files), or move an existing project file in. A file lives in one folder, so there are no copies. Preview, download, details (task and document relationships), move and trash work from the docs sidebar too.
  • Documents behave like files. Rename, move, star, Recent, search, details and trash from Files. A trashed document or folder (with its subfolders, documents and files) restores together from the Files trash, with the same 30-day retention.
  • Markdown in and out. Download any document as <title>.md (Files, docs sidebar, editor header). A .md or .markdown file uploaded or dropped into Documentation becomes a document, including inside dropped folders; a leading # heading becomes the title.
  • One breadcrumb. The docs editor and the Files page share 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

  • Deleting a documentation folder trashes it with everything in it. Before, its documents moved to the top of the docs tree. The change feed (and so the MCP mirror) now reports those documents as deletions. DELETE /docs/{id} and DELETE /docs/folders/{id} also go to the trash and are restorable from Files.
  • Files search, Starred, Recent and Trash include documents the caller may read (their document scope is applied inside the query). With no scope, Documentation stays out of those lists.
  • Anything in Documentation needs the docs permission as well as the files one (docs:read|write to look or change, on the document itself when the node is one, so per-document Deny rules apply).

How it works

  • One migration, 000096_documentation_in_files.sql.
    • Documentation folders move into file_folders (same ids) under a per-project documentation system folder. file_folders gains position, area (docs for the subtree) and created_by_member.
    • doc_folders stays as an updatable view over the subtree (INSTEAD OF triggers), so the docs code, the IAM loaders and the MCP mirror are unchanged. The change-feed trigger moves to file_folders.
    • documents.trashed_at marks restorable deletions; deleted_at stays 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_items gains the doc kind (<title>.md, text/markdown) and area.
    • It is one-way. Databases that applied earlier drafts of this work need their schema_migrations entries replaced (or to be recreated).
  • Authorization stays in the router. RequireFileDocsArea adds the docs action wherever a file route names a node (URL, query or body) in Documentation, for both ends of a move.
  • Documents are renamed and moved through the docs API (its gates and folder rules apply); the file routes refuse to rename, move or download a document.
  • Markdown. GET /projects/{id}/docs/{docId}/markdown renders with docdom.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 .md stays a plain file.
  • New endpoints: GET /files/nodes/{id}/relations, POST /files/nodes/{id}/open, GET /docs/{id}/markdown.

Not in this PR

  • Retiring the doc_folders view (the docs repository still reads it).
  • Sidebar folders and documents on the unified listing (they need manual order and cursor paging); only files moved to it.
  • A Recent entry when a document is opened from the docs sidebar.

Testing

  • Go: unit and service tests; new Postgres tests for the folder merge, area triggers, document items, document-scope lists, trash/restore/purge and relations; migration upgrade test on legacy data; middleware tests for the gate; API e2e (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.
  • Web: tsc -b and biome clean; unit tests for Markdown import and the breadcrumb; all nine locales updated.
  • Also failing without these changes (checked with them stashed), so unrelated: the by-path row-lock test, the git store test, the role-seeding test, and six IAM/roles integration tests.
  • Not run: the Playwright specs (apps/e2e/tests/files; three checks were updated for the breadcrumb) and a manual pass in the browser.

- 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.
@pikann pikann linked an issue Nov 20, 2026 that may be closed by this pull request

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 — moves doc_folders into file_folders under a locked per-project documentation folder behind a writable doc_folders view; adds position/area/created_by_member, documents.trashed_at, the doc branch and area in file_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' and trashed_at (counter first, one stamp for a subtree, content erased but tombstone kept on purge); adds FileNodeArea, Relations, RecordOpen.
  • HTTP/IAM — RequireFileDocsArea adds 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 PathBreadcrumb is shared with the docs editor.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 — docRowsClause filters kind='doc' rows in the parent branch, and Relations now runs under the caller's document scope with the handler attaching docScoped; new PG tests cover scoped browse and relations.
  • Folder name validation — docdom.ValidFolderName rejects empty/whitespace and / or \, and is used by createFolder, updateFolder and the by-path folder creation, so a backslash returns ErrFolderNameInvalid (400) instead of a 500.
  • Trashed document authorization — the doc attribute loader now resolves documents where deleted_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.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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.ts covers 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 DocumentPane disables the Download as Markdown button until doc resolves, so the filename can no longer fall back to Untitled.md.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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 — mountFileRoutes now takes a tasksRead gate (require.Project(iam.ActionTasksRead)) applied to GET /nodes/{nodeId}/relations, closing the task title/key exposure for roles without tasks:read; the general scope passes nil, where the service already returns empty relations.
  • Folder-name sanitization — the migration replaces both / and \ before inserting into file_folders, so a legacy name with a slash can no longer fail chk_file_folders_name; the migration test covers Q1/Q2 and 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_folders full-row update requirement, and the new tasks:read requirement.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pikann
pikann merged commit 0445c61 into master Nov 20, 2026
8 checks passed
@pikann
pikann deleted the feature/unify-documentation-and-file-management branch November 20, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: allow files inside user-created Documentation folders

1 participant