feat(project): add recent viewed files section to project folder tree (#348)

* feat(project): add recent viewed files section to project folder tree

* feat(webui): disable toolbar buttons and context menu in recents page

* test(core): optimize recents cap test execution time

* feat(webui): show hint text in recents page top toolbar

* feat(webui): rename recents section to Recently Viewed

* refactor(core): consolidate recents methods into AssetService

* fix(api): forward pagination parameters in folder children endpoint (#349)

* fix(project-recents): scope views and disable recents mutations

* fix(api): allow recent views in demo mode

* fix(api): limit demo recent view exception to post
This commit is contained in:
Yiling-J
2026-08-25 18:51:24 +08:00
committed by GitHub
parent 470a4bd6f7
commit 1d9268b224
50 changed files with 3883 additions and 301 deletions
@@ -0,0 +1,28 @@
-- CreateTable
CREATE TABLE "recent_file_items" (
"id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"project_id" TEXT NOT NULL,
"asset_id" TEXT NOT NULL,
"viewed_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "recent_file_items_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "recent_file_items_user_id_project_id_viewed_at_idx" ON "recent_file_items"("user_id", "project_id", "viewed_at" DESC);
-- CreateIndex
CREATE INDEX "recent_file_items_asset_id_idx" ON "recent_file_items"("asset_id");
-- CreateIndex
CREATE UNIQUE INDEX "recent_file_items_user_id_project_id_asset_id_key" ON "recent_file_items"("user_id", "project_id", "asset_id");
-- AddForeignKey
ALTER TABLE "recent_file_items" ADD CONSTRAINT "recent_file_items_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "recent_file_items" ADD CONSTRAINT "recent_file_items_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "recent_file_items" ADD CONSTRAINT "recent_file_items_asset_id_fkey" FOREIGN KEY ("asset_id") REFERENCES "assets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+22 -2
View File
@@ -236,8 +236,9 @@ model User {
kanbanTasksReported KanbanTask[] @relation("KanbanTaskReporter")
kanbanTasksAssigned KanbanTask[] @relation("KanbanTaskAssignee")
kanbanGoalsCreated KanbanGoal[] @relation("UserToKanbanGoal")
kanbanTaskComments KanbanTaskComment[]
kanbanTaskEvents KanbanTaskEvent[]
kanbanTaskComments KanbanTaskComment[]
kanbanTaskEvents KanbanTaskEvent[]
recentFiles RecentFileItem[]
@@map("users")
}
@@ -414,6 +415,7 @@ model Project {
collections Collection[] @relation("ProjectToCollection")
auditLogs AuditLog[] @relation("ProjectToAuditLog")
kanbanTasks KanbanTask[] @relation("ProjectToKanbanTask")
recentFiles RecentFileItem[]
@@map("projects")
@@index([createdAt])
@@ -564,6 +566,7 @@ model Asset {
agentMd AssetAgentMd? @relation("AssetToAgentMd")
kanbanTargetTasks KanbanTask[] @relation("KanbanTaskTargetFolder")
kanbanTasks KanbanTaskAsset[]
recentFiles RecentFileItem[]
@@map("assets")
@@index([type])
@@ -1273,5 +1276,22 @@ model KanbanTaskEvent {
@@map("kanban_task_events")
}
model RecentFileItem {
id String @id @default(ulid())
userId String @map("user_id")
projectId String @map("project_id")
assetId String @map("asset_id")
viewedAt DateTime @default(now()) @map("viewed_at")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
asset Asset @relation(fields: [assetId], references: [id], onDelete: Cascade)
@@unique([userId, projectId, assetId], name: "userIdProjectIdAssetId")
@@index([userId, projectId, viewedAt(sort: Desc)])
@@index([assetId])
@@map("recent_file_items")
}