From 7c9cb5abd3a6e4c4dfc6a0dc87778475fa84ce58 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Mon, 6 Jul 2026 13:05:29 +0530 Subject: [PATCH] refactor(sidebar): update AllChatsSidebar styling and folder type validation - Enhanced padding and gap in AllChatsSidebar for improved layout consistency. - Adjusted skeleton and button sizes for better usability in chat components. - Refactored folder type validation to ensure search_space_id is set based on workspace_id when missing. --- .../layout/ui/sidebar/AllChatsSidebar.tsx | 20 +++++++++---------- surfsense_web/contracts/types/folder.types.ts | 12 ++++++++++- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/surfsense_web/components/layout/ui/sidebar/AllChatsSidebar.tsx b/surfsense_web/components/layout/ui/sidebar/AllChatsSidebar.tsx index db528b13a..ae5dac223 100644 --- a/surfsense_web/components/layout/ui/sidebar/AllChatsSidebar.tsx +++ b/surfsense_web/components/layout/ui/sidebar/AllChatsSidebar.tsx @@ -307,10 +307,10 @@ function AllChatsContent({ searchSpaceId, className }: AllChatsContentProps) { {[75, 90, 55, 80, 65, 85].map((titleWidth) => (
- +
))} @@ -346,10 +346,10 @@ function AllChatsContent({ searchSpaceId, className }: AllChatsContentProps) { onTouchMove={longPressHandlers.onTouchMove} disabled={isBusy} className={cn( - "h-auto w-full justify-start gap-2 overflow-hidden px-2 py-1.5 text-left font-normal", + "h-auto w-full justify-start gap-2.5 overflow-hidden px-3 py-2.5 text-left text-base font-normal", "group-hover/item:bg-accent group-hover/item:text-accent-foreground", "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", - thread.visibility === "SEARCH_SPACE" && "pr-9", + thread.visibility === "SEARCH_SPACE" && "pr-10", isActive && "bg-accent text-accent-foreground", isBusy && "opacity-50 pointer-events-none" )} @@ -367,10 +367,10 @@ function AllChatsContent({ searchSpaceId, className }: AllChatsContentProps) { onFocus={() => prefetchChatThread(thread.id)} disabled={isBusy} className={cn( - "h-auto w-full justify-start gap-2 overflow-hidden px-2 py-1.5 text-left font-normal", + "h-auto w-full justify-start gap-2.5 overflow-hidden px-3 py-2.5 text-left text-base font-normal", "group-hover/item:bg-accent group-hover/item:text-accent-foreground", "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", - thread.visibility === "SEARCH_SPACE" && "pr-9", + thread.visibility === "SEARCH_SPACE" && "pr-10", isActive && "bg-accent text-accent-foreground", isBusy && "opacity-50 pointer-events-none" )} @@ -390,7 +390,7 @@ function AllChatsContent({ searchSpaceId, className }: AllChatsContentProps) {
-
+
{thread.visibility === "SEARCH_SPACE" ? ( ) : ( - + )} {t("more_options") || "More options"} diff --git a/surfsense_web/contracts/types/folder.types.ts b/surfsense_web/contracts/types/folder.types.ts index 8a9696a1f..0f7afd48b 100644 --- a/surfsense_web/contracts/types/folder.types.ts +++ b/surfsense_web/contracts/types/folder.types.ts @@ -1,6 +1,6 @@ import { z } from "zod"; -export const folder = z.object({ +const folderBase = z.object({ id: z.number(), name: z.string(), position: z.string(), @@ -12,6 +12,16 @@ export const folder = z.object({ metadata: z.record(z.string(), z.any()).nullable().optional(), }); +export const folder = z.preprocess((value) => { + if (typeof value === "object" && value !== null && !Array.isArray(value)) { + const record = value as Record; + if (record.search_space_id === undefined && record.workspace_id !== undefined) { + return { ...record, search_space_id: record.workspace_id }; + } + } + return value; +}, folderBase); + export const folderCreateRequest = z.object({ name: z.string().min(1).max(255), parent_id: z.number().nullable().optional(),