chore: biome lint

This commit is contained in:
DESKTOP-RTLN3BA\$punk 2025-12-19 15:38:39 -08:00
parent b4b53b6625
commit b5a6321eb4
8 changed files with 79 additions and 46 deletions

View file

@ -56,7 +56,7 @@ export function AppSidebarProvider({
const { data: chats, error: chatError, isLoading: isLoadingChats } = useAtomValue(chatsAtom);
const [{ isPending: isDeletingChat, mutateAsync: deleteChat, error: deleteError }] =
useAtom(deleteChatMutationAtom);
// Editor state for handling unsaved changes
const hasUnsavedEditorChanges = useAtomValue(hasUnsavedEditorChangesAtom);
const setPendingNavigation = useSetAtom(pendingEditorNavigationAtom);
@ -97,7 +97,11 @@ export function AppSidebarProvider({
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
const [chatToDelete, setChatToDelete] = useState<{ id: number; name: string } | null>(null);
const [showDeleteNoteDialog, setShowDeleteNoteDialog] = useState(false);
const [noteToDelete, setNoteToDelete] = useState<{ id: number; name: string; search_space_id: number } | null>(null);
const [noteToDelete, setNoteToDelete] = useState<{
id: number;
name: string;
search_space_id: number;
} | null>(null);
const [isDeletingNote, setIsDeletingNote] = useState(false);
const [isClient, setIsClient] = useState(false);
@ -230,7 +234,11 @@ export function AppSidebarProvider({
name: "Delete",
icon: "Trash2",
onClick: () => {
setNoteToDelete({ id: note.id, name: note.title, search_space_id: note.search_space_id });
setNoteToDelete({
id: note.id,
name: note.title,
search_space_id: note.search_space_id,
});
setShowDeleteNoteDialog(true);
},
},
@ -241,7 +249,7 @@ export function AppSidebarProvider({
// Handle add note - check for unsaved changes first
const handleAddNote = useCallback(() => {
const newNoteUrl = `/dashboard/${searchSpaceId}/editor/new`;
if (hasUnsavedEditorChanges) {
// Set pending navigation - the editor will show the unsaved changes dialog
setPendingNavigation(newNoteUrl);

View file

@ -34,11 +34,7 @@ interface AllChatsSidebarProps {
searchSpaceId: string;
}
export function AllChatsSidebar({
open,
onOpenChange,
searchSpaceId,
}: AllChatsSidebarProps) {
export function AllChatsSidebar({ open, onOpenChange, searchSpaceId }: AllChatsSidebarProps) {
const t = useTranslations("sidebar");
const router = useRouter();
const queryClient = useQueryClient();
@ -99,7 +95,7 @@ export function AllChatsSidebar({
// Filter and sort chats based on search query (client-side filtering)
const chats = useMemo(() => {
const allChats = chatsData ?? [];
// Sort chats by created_at (most recent first)
const sortedChats = [...allChats].sort((a, b) => {
const dateA = new Date(a.created_at).getTime();
@ -111,9 +107,7 @@ export function AllChatsSidebar({
return sortedChats;
}
const query = debouncedSearchQuery.toLowerCase();
return sortedChats.filter((chat) =>
chat.title.toLowerCase().includes(query)
);
return sortedChats.filter((chat) => chat.title.toLowerCase().includes(query));
}, [chatsData, debouncedSearchQuery]);
const isSearchMode = !!debouncedSearchQuery;
@ -190,7 +184,10 @@ export function AllChatsSidebar({
</button>
</TooltipTrigger>
<TooltipContent side="right">
<p>{t("created") || "Created"}: {format(new Date(chat.created_at), "MMM d, yyyy 'at' h:mm a")}</p>
<p>
{t("created") || "Created"}:{" "}
{format(new Date(chat.created_at), "MMM d, yyyy 'at' h:mm a")}
</p>
</TooltipContent>
</Tooltip>
@ -242,9 +239,7 @@ export function AllChatsSidebar({
) : (
<div className="text-center py-8">
<MessageCircleMore className="h-12 w-12 mx-auto text-muted-foreground/50 mb-3" />
<p className="text-sm text-muted-foreground">
{t("no_chats") || "No chats yet"}
</p>
<p className="text-sm text-muted-foreground">{t("no_chats") || "No chats yet"}</p>
<p className="text-xs text-muted-foreground/70 mt-1">
{t("start_new_chat_hint") || "Start a new chat from the researcher"}
</p>

View file

@ -125,8 +125,14 @@ export function AllNotesSidebar({
// Transform and sort notes data - handle both regular notes and search results
const notes = useMemo(() => {
let notesList: { id: number; title: string; search_space_id: number; created_at: string; updated_at?: string | null }[];
let notesList: {
id: number;
title: string;
search_space_id: number;
created_at: string;
updated_at?: string | null;
}[];
if (isSearchMode && searchData?.items) {
notesList = searchData.items.map((doc) => ({
id: doc.id,
@ -224,9 +230,15 @@ export function AllNotesSidebar({
</TooltipTrigger>
<TooltipContent side="right">
<div className="space-y-1">
<p>{t("created") || "Created"}: {format(new Date(note.created_at), "MMM d, yyyy 'at' h:mm a")}</p>
<p>
{t("created") || "Created"}:{" "}
{format(new Date(note.created_at), "MMM d, yyyy 'at' h:mm a")}
</p>
{note.updated_at && (
<p>{t("updated") || "Updated"}: {format(new Date(note.updated_at), "MMM d, yyyy 'at' h:mm a")}</p>
<p>
{t("updated") || "Updated"}:{" "}
{format(new Date(note.updated_at), "MMM d, yyyy 'at' h:mm a")}
</p>
)}
</div>
</TooltipContent>

View file

@ -446,22 +446,22 @@ export const AppSidebar = memo(function AppSidebar({
</SidebarMenu>
</SidebarHeader>
<SidebarContent className="gap-1">
<NavMain items={processedNavMain} onSourcesExpandedChange={setIsSourcesExpanded} />
<SidebarContent className="gap-1">
<NavMain items={processedNavMain} onSourcesExpandedChange={setIsSourcesExpanded} />
<NavChats
chats={processedRecentChats}
searchSpaceId={searchSpaceId}
isSourcesExpanded={isSourcesExpanded}
/>
<NavChats
chats={processedRecentChats}
searchSpaceId={searchSpaceId}
isSourcesExpanded={isSourcesExpanded}
/>
<NavNotes
notes={processedRecentNotes}
onAddNote={onAddNote}
searchSpaceId={searchSpaceId}
isSourcesExpanded={isSourcesExpanded}
/>
</SidebarContent>
<NavNotes
notes={processedRecentNotes}
onAddNote={onAddNote}
searchSpaceId={searchSpaceId}
isSourcesExpanded={isSourcesExpanded}
/>
</SidebarContent>
<SidebarFooter>
{pageUsage && (
<PageUsageDisplay pagesUsed={pageUsage.pagesUsed} pagesLimit={pageUsage.pagesLimit} />

View file

@ -3,8 +3,8 @@
import {
ChevronRight,
FolderOpen,
type LucideIcon,
Loader2,
type LucideIcon,
MessageCircleMore,
MoreHorizontal,
RefreshCw,
@ -63,7 +63,12 @@ const actionIconMap: Record<string, LucideIcon> = {
RefreshCw,
};
export function NavChats({ chats, defaultOpen = true, searchSpaceId, isSourcesExpanded = false }: NavChatsProps) {
export function NavChats({
chats,
defaultOpen = true,
searchSpaceId,
isSourcesExpanded = false,
}: NavChatsProps) {
const t = useTranslations("sidebar");
const router = useRouter();
const isMobile = useIsMobile();
@ -174,7 +179,9 @@ export function NavChats({ chats, defaultOpen = true, searchSpaceId, isSourcesEx
) : (
<MoreHorizontal className="h-3.5 w-3.5" />
)}
<span className="sr-only">{t("more_options") || "More options"}</span>
<span className="sr-only">
{t("more_options") || "More options"}
</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" side="right" className="w-40">

View file

@ -63,7 +63,13 @@ const actionIconMap: Record<string, LucideIcon> = {
MoreHorizontal,
};
export function NavNotes({ notes, onAddNote, defaultOpen = true, searchSpaceId, isSourcesExpanded = false }: NavNotesProps) {
export function NavNotes({
notes,
onAddNote,
defaultOpen = true,
searchSpaceId,
isSourcesExpanded = false,
}: NavNotesProps) {
const t = useTranslations("sidebar");
const router = useRouter();
const isMobile = useIsMobile();
@ -188,7 +194,9 @@ export function NavNotes({ notes, onAddNote, defaultOpen = true, searchSpaceId,
) : (
<MoreHorizontal className="h-3.5 w-3.5" />
)}
<span className="sr-only">{t("more_options") || "More options"}</span>
<span className="sr-only">
{t("more_options") || "More options"}
</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" side="right" className="w-40">