Repository navigation
feat: implement drive-style file management and related features - #784
Conversation
- Introduced a new file management system with a dedicated file handler. - Added routes for file operations including listing, downloading, and managing files and folders. - Created a file trash purger to permanently delete files after a retention period. - Updated database schema to support file management, including new tables for file folders, stars, and recents. - Implemented triggers and functions for automatic folder creation and file classification based on storage keys. - Enhanced IAM policies to include new file management actions. - Updated integration tests to account for new file management features and ensure legacy compatibility.
There was a problem hiding this comment.
Important
Two lifetime problems in the trash pipeline need a decision before merge: deleting a file from the manager (or letting the 30-day purger run) silently detaches it from live annotations and tasks, and the backfill creates trashed rows the purger can never reach.
Approach: sound — putting the manager on the existing files table with a classifying trigger leaves every existing upload path untouched and collapses folders and files into one file_items list; the cost is that the manager now owns the lifetime of rows other features still reference, which is where the findings below concentrate.
Reviewed changes — the whole PR: migration 000093, the file domain/repository/service, handler, router gates and IAM, the trash purger, the web Files UI, the task-attachment and BlockNote integrations, i18n, docs and the e2e spec.
- Schema and migration — new
filescolumns,file_folders,file_stars,file_recents, thefile_itemsview, the classification/backfill triggers and the rewrite of existing roles. - Backend —
filedomandFileRepository(reads through the view,scopeClauseeverywhere),filesvcwith scope checks, presigned upload/download, trash/restore/purge, and the hourly leader-locked purger wired intobootstrap. - HTTP and IAM — shared handlers per scope,
require.Project(files:*)/require.Global(files:*)onfile/*, the ungated-but-filtered/files/roots, newapierrcodes and presenter mappings, default role policies. - Web UI — Files page with grid/list, breadcrumbs, desktop drop and in-app drag-move, move/rename/confirm dialogs, details sheet, lazy preview overlay, batched upload queue with folder creation.
- Integrations — task attachments previewing in place, BlockNote file panel (upload / pick from project Files / embed) with
files://URIs, inline media preview across a description. - Tests and docs — service tests, Postgres repository tests for classification and the trash lifecycle, route-coverage and authz test updates, a full e2e spec, and the product design doc.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
…es, and annotation screenshots - Added new confirmation messages for deleting managed files in Russian, Vietnamese, and Simplified Chinese. - Updated the files API to include logic for determining if a file should be permanently deleted instead of moved to trash. - Enhanced the file management documentation to reflect the new deletion behavior and UI changes. - Modified the file service to handle the deletion of files referenced by tasks, documents, and annotations correctly. - Created integration tests to ensure the correct behavior of file deletion and role grants after migration.
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound — the new commit replaces the delayed, silent detachment of referenced files with an explicit delete-for-good plus a confirmation that names the owner, and it closes each of the lifetime and permission holes raised in the previous review.
Reviewed changes — the delta since the prior pullfrog review at ecb7450d (commit 5913b8a6, 21 files).
- Added
Node.DeletedForGood()and routed task attachments, document files and annotation screenshots throughdeleteReferencedFile(unlink, then purge the row and its bytes), leaving plain uploads and folders on the trash path. - Replaced the task-attachment-only confirmation with
deleteManagedcopy for documents and annotations, mirrored across all nine locales. - Unified every trash entry point in
files-page.tsxthroughtrashNodes, which filters system folders and scopes the caller cannot write. - Guarded the task-attachment trigger and the migration backfill with
folder_id IS NOT NULL, so no row stamped as trashed can fall outsidefile_items. - Restricted the docs→files role mirror to Allow statements confined to
project/…, so a*resource never derives the generalfile/*scope. - Added migration integration tests for the role matrix and the trigger predicate, an e2e delete-for-good case, and brought the design doc in line with the shipped API.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
…ty and size reporting
There was a problem hiding this comment.
ℹ️ No critical issues — one minor scalability suggestion inline.
Approach: sound — the commit folds rename and move into a single validated Update, verifies the uploaded object before marking it uploaded, and forces active content to download; each change closes a real gap without adding a parallel mechanism.
Reviewed changes — the delta since the prior pullfrog review at 5913b8a6 (commit 62aaf8d3, 8 files).
- Rename/move unified —
Service.Updatevalidates the name, lock state, destination and self/descendant move before either write, so a rejected move no longer leaves a rename applied; the handler delegates to it. - Upload integrity —
CompleteUploadchecks the object through a new optionalobjectStatter(S3Client.StatObject) and rejects the upload when the bytes are missing or their size differs from the declared one (ErrUploadNotComplete→ 409). - Active content —
DownloadURLforcesContent-Disposition: attachmentfor HTML/XHTML/SVG/XML/JS/CSS content types and the same file extensions, so none of them render from the storage origin. - Trash pipeline — restore treats a missing parent folder as trashed (
COALESCE(..., TRUE)),purgeTxunlinks task attachments inside the delete transaction (replacingUnlinkTaskAttachment), and the purger continues past a failing root and joins the errors. - Roots paging —
/files/rootswalks every project page instead of stopping at 10 000, and000093addsidx_files_project. - Tests — new service tests for the object/size check and the active-content predicate; the referenced-file test no longer expects a separate unlink.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound — the commit closes the remaining scalability note by batching every /files/roots scope check through AuthorizeMany, so the request costs one grants lookup regardless of project count.
Reviewed changes — the delta since the prior pullfrog review at 62aaf8d3 (commit a3d906c5, 1 file).
- Batched
/files/rootsauthorization —Rootsbuilds oneiam.Queryfor the general scope plus one per project and evaluates them through a newallowedhelper, which type-assertsiam.Checkerto anAuthorizeManyinterface and keeps the per-queryAuthorizefallback for checkers that only implementChecker. Queries stay in the same order as the response, so theallowed[0]/allowed[i+1]indexing matches the existing root construction. - Deny-on-unknown preserved — an
AuthorizeManyerror aborts the request as before, a nil checker still returnsiam.ErrNotConfigured, and a result slice shorter than the query slice leaves the remaining entries false rather than panicking.
Verified with go build of internal/transport/http/handler and internal/platform/authz/iam on this commit.
The earlier ℹ️ thread on the per-project grants lookups is addressed; replied and resolved.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
Secondary text and hairlines were faded well past readability. The base tokens were fine on their own (muted text 4.7:1 on white), but components layered heavy opacity on top: ~380 uses of muted text at /30-/60 rendered at roughly 1.5-2.3:1, and borders at /10-/30 were close to invisible (1.04-1.12:1). Tokens (index.css): - --muted-foreground: #737373 -> #5f5f5f (light, 6.4:1), #888888 -> #a0a0a0 (dark, 7.6:1) - --border/--input: #d4d4d4 -> #c8c8c8 (light), #2a2a2a -> #3a3a3a (dark) - --sidebar-border: #e8e8e8 -> #dedede (light), #1e1e1e -> #2a2a2a (dark) Opacity floors across components (mechanical sweep): - text-muted-foreground /30-/60 -> /90 (>= 4.5:1 on background, muted and secondary surfaces in both themes; /85 would still fail at 4.48:1), /70-/90 -> full strength, so two tiers remain - text-sidebar-foreground /30-/50 -> /60 (4.94:1 light, 6.53:1 dark); the sidebar has its own foreground token - border/divide/ring/bg-border /10-/35 -> /50, /40 -> /60; Gantt gridlines /12 -> /30 so they stay lighter than row dividers. The dashed row dividers from Paca-AI#785 are left as tuned. The Gantt drag tests located groups by a border class; they now use a `data-gantt-group` attribute so styling changes don't break them. Rebuilt on current master (after Paca-AI#784, Paca-AI#785-Paca-AI#787, Paca-AI#789) so the new file-management components get the same treatment. Co-Authored-By: Claude Opus 5.5 <[email protected]>

Summary
Adds a Drive-style file manager. Every uploaded file (user uploads, task attachments, document files, annotation screenshots) can be browsed, previewed, downloaded and organised in folders, in a project scope and a general (workspace) scope. Each project gets default folders for the files the product creates itself, and a global Files page lists everything the caller may read, with each project shown as a folder.
Design notes:
docs/product/file-management.md.Data model (migration
000093_file_management.sql)file_folderstable. The existingfilestable becomes the manageable item and gainsproject_id(NULL = general scope),folder_id,sourceand trash columns. Names are not unique within a folder.file_itemspresents folders and uploaded files as one list, so listing, search, sort and paging are a single query.projects, backfilled for existing ones):Task attachments(one subfolder per task, e.g.PACA-12),Document files,Annotation screenshots. They are locked: no rename, move or delete, and nothing can be created or moved into them.BEFORE INSERTtrigger onfilesclassifies a new row from its storage-key prefix and, for tasks and docs, resolves the project and folder. The existing upload services are unchanged. Screenshots get their folder when an annotation references them. Existing rows are backfilled.file_items, so it is left alone).files:read/files:writeto existing roles (see Permissions), because seeding never rewrites the policy of a role that already exists.avatar_keycolumns and the upload row is deleted.Backend
domain/file,service/file, Postgres repository, DTOs andFileHandler./projects/{projectId}/files/...and/files/...(shared handlers): list/search, breadcrumb, folders, rename/move, trash, restore, permanent delete, presigned upload (single and multipart), download URL, stars, recents, trash list.GET /files/rootslists the general folder plus every project the caller may read.deleted_aton a folder and its subtree, so restore brings back exactly that subtree. AFileTrashPurgerworker deletes items and their objects after 30 days.Permissions
files:readandfiles:write. Project routes are gated on the project; the general scope uses the new platform rootfile/*(mirrored in the web role editor codec and the role-policy skill).files:read, Editor and Admin get both. PlatformADMINgets both on the general scope. PlatformUSERgets neither, because the actions apply to every file in a scope.ADMINby name, and any other role that grantsdocs:read/docs:writein an Allow statement confined to projects gets the matching files action. A statement that can matchfile/*(resource*) is left alone.Web
@eternalheart/react-file-preview, loaded lazily; the PDF worker is served from our own origin. Previous/next across a folder.files://{project}/{file}).BlockNote fixes
slashMenu={false}).Upgrade notes
000093locally (it created afile_nodestable), the runner will not re-run the file: dropfile_nodes,file_stars,file_recentsand thefile_nodes_*triggers/functions and delete itsschema_migrationsrow before starting the API.000093_…files.Testing
tsc -band biome clean.tests/files/file-manager.spec.ts(default folders and sidebar, folders/upload/preview/star/trash/restore, task attachment mirroring and deletion, task attachment, inline image and file block preview, picking from Files, dark-mode hover) andtests/ux/blocknote-add-block-menu.spec.ts(the "+" menu in the document, description and comment editors: mouse, keyboard, dismiss).masterand are unrelated:TestSeedPlatformRoles_ReconcilesMigratedRoles,TestWriteDocumentAtPath_DocDeletedBeforeRowLockIsPathChanged,TestGitStore_ChangeRequestsAndTaskLinks,TestPluginManifestActionsMigration,TestProjectRoleResourcesMigration,TestRolesAssignMigration,TestRolesAPI_EndToEnd,TestServiceAccountsAPI_EndToEndandTestIAMMigrationKeyMapping.Known limitations