From 8a5fca70666be2a9c937b6e55aa4ed0d0d14e277 Mon Sep 17 00:00:00 2001 From: Gautam25Raj Date: Wed, 27 May 2026 00:44:24 +0530 Subject: [PATCH 1/2] feat: update session caching and improve document counts handling --- apps/server/src/middleware/auth.ts | 4 +- apps/server/src/utils/authCache.ts | 6 +- .../(dashboard)/components/OverviewHome.tsx | 4 +- .../documents/useDocumentsWorkspace.ts | 2 +- .../(dashboard)/documents/workspace.tsx | 10 ++- apps/studio/app/(main)/(dashboard)/error.tsx | 6 +- packages/ui/src/components/ui/Modal.tsx | 84 ++++++++++++++++++- 7 files changed, 106 insertions(+), 10 deletions(-) diff --git a/apps/server/src/middleware/auth.ts b/apps/server/src/middleware/auth.ts index 6792481..547d901 100644 --- a/apps/server/src/middleware/auth.ts +++ b/apps/server/src/middleware/auth.ts @@ -1,6 +1,7 @@ import { NextFunction, Request, Response } from "express"; import { ApiError } from "#utils/errors"; +import { config } from "#config"; import { convertNodeHeadersToWebHeaders, getSessionFromRequestHeaders } from "#auth/index"; @@ -63,8 +64,7 @@ export async function getSessionUserFromRequest(req: Request): Promise { const cacheKey = getSessionCacheKey(cookieHeader); + if (cacheKey) { await cacheDel(cacheKey); } diff --git a/apps/studio/app/(main)/(dashboard)/components/OverviewHome.tsx b/apps/studio/app/(main)/(dashboard)/components/OverviewHome.tsx index 403f8e0..dcc2212 100644 --- a/apps/studio/app/(main)/(dashboard)/components/OverviewHome.tsx +++ b/apps/studio/app/(main)/(dashboard)/components/OverviewHome.tsx @@ -38,9 +38,11 @@ const OverviewHome = () => { () => DOCUMENT_LIBRARY_SERVER_SNAPSHOT, ); - const totalCount = snapshot.counts.RESUME + snapshot.counts.COVER_LETTER; + const totalCount = Object.values(snapshot.counts).reduce((sum, count) => sum + count, 0); + const resumeCount = snapshot.counts.RESUME; const coverLetterCount = snapshot.counts.COVER_LETTER; + const recentDocs = snapshot.docs.slice(0, 6); return ( diff --git a/apps/studio/app/(main)/(dashboard)/documents/useDocumentsWorkspace.ts b/apps/studio/app/(main)/(dashboard)/documents/useDocumentsWorkspace.ts index 4801bbc..524dd76 100644 --- a/apps/studio/app/(main)/(dashboard)/documents/useDocumentsWorkspace.ts +++ b/apps/studio/app/(main)/(dashboard)/documents/useDocumentsWorkspace.ts @@ -49,7 +49,7 @@ export function useDocumentsWorkspace() { ); const { docs, counts } = snapshot; - const totalCount = counts.RESUME + counts.COVER_LETTER; + const totalCount = Object.values(counts).reduce((sum, count) => sum + count, 0); const bump = useCallback(() => setRefreshKey((key) => key + 1), []); diff --git a/apps/studio/app/(main)/(dashboard)/documents/workspace.tsx b/apps/studio/app/(main)/(dashboard)/documents/workspace.tsx index 52b8c3c..517e29b 100644 --- a/apps/studio/app/(main)/(dashboard)/documents/workspace.tsx +++ b/apps/studio/app/(main)/(dashboard)/documents/workspace.tsx @@ -9,6 +9,9 @@ import SyncDetailsModal from "@/components/modals/SyncDetailsModal"; import ShareDocumentModal from "@/components/modals/ShareDocumentModal"; import RenameDocumentModal from "@/components/modals/RenameDocumentModal"; +import { DOCUMENT_TYPES } from "@/features/documents/core/document-types"; +import { getDocumentDefinition } from "@/features/documents/core/registry"; + import { DocumentListRow } from "./components/DocumentListRow"; import { IconToggle } from "./components/DocumentWorkspaceControls"; import { DocumentPreviewCard } from "./components/DocumentPreviewCard"; @@ -87,8 +90,11 @@ export default function DocumentsWorkspace() { className="h-10 w-auto min-w-36 rounded-xl px-3 shadow-none" > - - + {DOCUMENT_TYPES.map((type) => ( + + ))}