Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

📁 feat: Edit Projects in a Dialog and Pick Files From the Your Files Dialog (#16643)

Marco Beretta8e9a1722fcc9
diff --git a/client/src/components/Chat/Input/Composer/Catalog.tsx b/client/src/components/Chat/Input/Composer/Catalog.tsx
index af5c22774b..20d727539e 100644
--- a/client/src/components/Chat/Input/Composer/Catalog.tsx
+++ b/client/src/components/Chat/Input/Composer/Catalog.tsx
@@ -1,4 +1,4 @@
-import React, { useRef, useMemo, useState, useEffect } from 'react';
+import React, { useId, useRef, useMemo, useState, useEffect } from 'react';
import {
Input,
Label,
@@ -141,6 +141,72 @@ function EntryGrid({
);
}
+interface CatalogContentProps {
+ title: string;
+ searchLabel: string;
+ search: string;
+ onSearchChange: (value: string) => void;
+ filterLabel: string;
+ viewOptions: Array<{ value: string; label: string }>;
+ view: string;
+ onViewChange: (value: string) => void;
+ children: React.ReactNode;
+}
+
+/** The catalog dialog's body: a title, then a search field and view filter
+ * pinned above a scrolling grid. Shared by every "Show all" catalog and by
+ * other pickers over the same cards, so they read as one dialog. */
+export function CatalogContent({
+ title,
+ searchLabel,
+ search,
+ onSearchChange,
+ filterLabel,
+ viewOptions,
+ view,
+ onViewChange,
+ children,
+}: CatalogContentProps) {
+ const viewLabelId = useId();
+ return (
+ <OGDialogContent className="flex h-[80vh] max-h-[720px] w-11/12 max-w-[960px] flex-col overflow-hidden">
+ <div className="flex h-full min-h-0 min-w-0 flex-col gap-3">
+ <OGDialogTitle>{title}</OGDialogTitle>
+ <OGDialogDescription className="sr-only">{searchLabel}</OGDialogDescription>
+ {/* Reaches into the dialog's right padding so the scrollbar sits at the
+ edge, and pads the content back so the cards keep their inset. The
+ controls ride inside it as a sticky header, so they share the cards'
+ exact width whether the scrollbar takes space or overlays; the small
+ left inset keeps the search field's focus ring from being clipped. */}
+ <div className="-mr-5 -ml-1 min-h-0 flex-1 overflow-y-auto pr-5 pl-1">
+ <div className="bg-surface-dialog sticky top-0 z-10 flex flex-wrap items-center gap-2 pt-1 pb-3">
+ <div className="min-w-0 flex-1">
+ <Input
+ type="search"
+ value={search}
+ onChange={(event) => onSearchChange(event.target.value)}
+ placeholder={searchLabel}
+ aria-label={searchLabel}
+ />
+ </div>
+ <Label id={viewLabelId} className="sr-only">
+ {filterLabel}
+ </Label>
+ <Radio
+ wrap
+ options={viewOptions}
+ value={view}
+ onChange={onViewChange}
+ aria-labelledby={viewLabelId}
+ />
+ </div>
+ {children}
+ </div>
+ </div>
+ </OGDialogContent>
+ );
+}
+
interface CatalogProps {
section: CatalogSection | null;
onClose: () => void;
@@ -220,49 +286,24 @@ export default function Catalog({
}}
>
{current != null && (
- <OGDialogContent className="flex h-[80vh] max-h-[720px] w-11/12 max-w-[960px] flex-col overflow-hidden">
- <div className="flex h-full min-h-0 min-w-0 flex-col gap-3">
- <OGDialogTitle>{localize(TITLE[current])}</OGDialogTitle>
- <OGDialogDescription className="sr-only">
- {localize(SEARCH[current])}
- </OGDialogDescription>
- {/* Reaches into the dialog's right padding so the scrollbar sits at the
- edge, and pads the content back so the cards keep their inset. The
- controls ride inside it as a sticky header, so they share the cards'
- exact width whether the scrollbar takes space or overlays; the small
- left inset keeps the search field's focus ring from being clipped. */}
- <div className="-mr-5 -ml-1 min-h-0 flex-1 overflow-y-auto pr-5 pl-1">
- <div className="bg-surface-dialog sticky top-0 z-10 flex flex-wrap items-center gap-2 pt-1 pb-3">
- <div className="min-w-0 flex-1">
- <Input
- type="search"
- value={search}
- onChange={(event) => setSearch(event.target.value)}
- placeholder={localize(SEARCH[current])}
- aria-label={localize(SEARCH[current])}
- />
- </div>
- <Label id="composer-catalog-view-label" className="sr-only">
- {localize(FILTER[current])}
- </Label>
- <Radio
- wrap
- options={viewOptions}
- value={current === 'files' ? fileView : view}
- onChange={(value) =>
- current === 'files' ? setFileView(value as FileView) : setView(value as View)
- }
- aria-labelledby="composer-catalog-view-label"
- />
- </div>
- {current === 'files' ? (
- <FileGrid query={query} view={fileView} onAttach={onAttach} />
- ) : (
- <EntryGrid section={current} entries={entries} query={query} view={view} />
- )}
- </div>
- </div>
- </OGDialogContent>
+ <CatalogContent
+ title={localize(TITLE[current])}
+ searchLabel={localize(SEARCH[current])}
+ search={search}
+ onSearchChange={setSearch}
+ filterLabel={localize(FILTER[current])}
+ viewOptions={viewOptions}
+ view={current === 'files' ? fileView : view}
+ onViewChange={(value) =>
+ current === 'files' ? setFileView(value as FileView) : setView(value as View)
+ }
+ >
+ {current === 'files' ? (
+ <FileGrid query={query} view={fileView} onAttach={onAttach} />
+ ) : (
+ <EntryGrid section={current} entries={entries} query={query} view={view} />
+ )}
+ </CatalogContent>
)}
</OGDialog>
);
diff --git a/client/src/components/Chat/Input/Composer/Files.tsx b/client/src/components/Chat/Input/Composer/Files.tsx
index 6dde9fbccd..3561d476f5 100644
--- a/client/src/components/Chat/Input/Composer/Files.tsx
+++ b/client/src/components/Chat/Input/Composer/Files.tsx
@@ -23,6 +23,8 @@ export const FILE_VIEWS: Array<{ value: FileView; labelKey: TranslationKeys }> =
{ value: 'documents', labelKey: 'com_ui_composer_files_documents' },
];
+const NO_FILES: TFile[] = [];
+
const isImage = (file: TFile) => file.type?.startsWith('image/') === true;
/** Images, audio and video are media; everything else is a document. */
@@ -85,12 +87,13 @@ interface FileCardProps {
file: TFile;
onAttach: (file: TFile) => void;
onPreview: (file: TFile, trigger: HTMLButtonElement) => void;
+ disabled?: boolean;
}
/** Laid out like the skill and MCP cards: the card is the attach action, and
* the corner holds the one secondary action, previewing, where they keep the
* favourite star. */
-const FileCard = memo(function FileCard({ file, onAttach, onPreview }: FileCardProps) {
+const FileCard = memo(function FileCard({ file, onAttach, onPreview, disabled }: FileCardProps) {
const localize = useLocalize();
const name = file.filename ?? '';
const details = [
@@ -104,7 +107,8 @@ const FileCard = memo(function FileCard({ file, onAttach, onPreview }: FileCardP
<button
type="button"
onClick={() => onAttach(file)}
- className="focus-visible:ring-ring-primary flex h-full w-full cursor-pointer flex-col gap-2 rounded-2xl p-4 text-left focus:outline-hidden focus-visible:ring-2"
+ disabled={disabled}
+ className="focus-visible:ring-ring-primary flex h-full w-full cursor-pointer flex-col gap-2 rounded-2xl p-4 text-left focus:outline-hidden focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-50"
>
<span className="flex w-full min-w-0 items-start gap-3">
<Thumbnail file={file} />
@@ -137,10 +141,12 @@ function EmptyState({
loading,
failed,
onRetry,
+ text,
}: {
loading: boolean;
failed: boolean;
onRetry: () => void;
+ text?: string;
}) {
const localize = useLocalize();
if (loading) {
@@ -168,22 +174,47 @@ function EmptyState({
return (
<div role="status" className="flex flex-col items-center justify-center py-16 text-center">
<Search className="text-text-tertiary size-8 opacity-40" aria-hidden="true" />
- <p className="text-text-secondary mt-3 text-sm">{localize('com_ui_composer_no_results')}</p>
+ <p className="text-text-secondary mt-3 text-sm">
+ {text ?? localize('com_ui_composer_no_results')}
+ </p>
</div>
);
}
+/** Files from somewhere other than the user's whole library, such as a
+ * server-filtered list of the files a project can take. */
+export interface FileGridSource {
+ files: TFile[];
+ isLoading: boolean;
+ isError: boolean;
+ refetch: () => void;
+}
+
interface FileGridProps {
query: string;
view: FileView;
onAttach: (file: TFile) => void;
+ source?: FileGridSource;
+ disabled?: boolean;
+ emptyText?: string;
}
/** The user's files as cards, filtered by name and kind, with a preview for
* anything the message viewers can show. */
-export default function FileGrid({ query, view, onAttach }: FileGridProps) {
+export default function FileGrid({
+ query,
+ view,
+ onAttach,
+ source,
+ disabled,
+ emptyText,
+}: FileGridProps) {
const localize = useLocalize();
- const { data: files = [], isLoading, isError, refetch } = useGetFiles<TFile[]>();
+ const library = useGetFiles<TFile[]>({ enabled: source == null });
+ const files = source?.files ?? library.data ?? NO_FILES;
+ const isLoading = source?.isLoading ?? library.isLoading;
+ const isError = source?.isError ?? library.isError;
+ const refetch = source?.refetch ?? library.refetch;
const [previewing, setPreviewing] = useState<TFile | null>(null);
/** The Preview button that opened the viewer, where focus returns on close. */
const previewTriggerRef = useRef<HTMLButtonElement | null>(null);
@@ -279,18 +310,31 @@ export default function FileGrid({ query, view, onAttach }: FileGridProps) {
loading={isLoading}
failed={isError && files.length === 0}
onRetry={() => void refetch()}
+ text={emptyText}
/>
) : (
- <ul
- className="grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3"
- aria-label={localize('com_ui_composer_files')}
- >
- {visible.map((file) => (
- <li key={file.file_id}>
- <FileCard file={file} onAttach={onAttach} onPreview={openPreview} />
- </li>
- ))}
- </ul>
+ <>
+ {/* Announces how many files the search and view leave, without making the
+ interactive cards themselves a live region. */}
+ <p className="sr-only" role="status" aria-live="polite">
+ {localize('com_ui_search_results_count', { count: visible.length })}
+ </p>
+ <ul
+ className="grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3"
+ aria-label={localize('com_ui_composer_files')}
+ >
+ {visible.map((file) => (
+ <li key={file.file_id}>
+ <FileCard
+ file={file}
+ onAttach={onAttach}
+ onPreview={openPreview}
+ disabled={disabled}
+ />
+ </li>
+ ))}
+ </ul>
+ </>
)}
<DialogImage
isOpen={previewKind === 'image' && imageUrl != null}
diff --git a/client/src/components/Conversations/ProjectsSection.tsx b/client/src/components/Conversations/ProjectsSection.tsx
index 8c7618dfd2..f154348278 100644
--- a/client/src/components/Conversations/ProjectsSection.tsx
+++ b/client/src/components/Conversations/ProjectsSection.tsx
@@ -41,6 +41,7 @@ import {
} from '~/data-provider';
import ProjectCreateDialog from '~/components/Projects/ProjectCreateDialog';
import ProjectDeleteDialog from '~/components/Projects/ProjectDeleteDialog';
+import ProjectEditDialog from '~/components/Projects/ProjectEditDialog';
import { useLocalize, useLocalStorage, useNewConvo } from '~/hooks';
import { clearMessagesCache, cn, rowActionClasses } from '~/utils';
import { Collapse } from '~/components/ui';
@@ -187,7 +188,17 @@ const ProjectItem = memo(
const menuId = useId();
const [expanded, setExpanded] = useState(defaultExpanded);
const [isMenuOpen, setIsMenuOpen] = useState(false);
+ /** The dialog items keep the menu open so it does not steal focus from the
+ * dialog mounting beside it; closing the dialog closes the menu too. */
+ const closeMenuWith = (setOpen: (open: boolean) => void, open: boolean) => {
+ setOpen(open);
+ if (!open) {
+ setIsMenuOpen(false);
+ }
+ };
const [isDeleteOpen, setIsDeleteOpen] = useState(false);
+ const [isEditOpen, setIsEditOpen] = useState(false);
+ const editMenuRef = useRef<HTMLButtonElement>(null);
const deleteMenuRef = useRef<HTMLButtonElement>(null);
const projectChatPath = `/c/${Constants.NEW_CONVO}?projectId=${encodeURIComponent(project._id)}`;
@@ -271,10 +282,10 @@ const ProjectItem = memo(
id: `${menuId}-rename`,
label: localize('com_ui_edit_project'),
icon: <Pencil className="text-text-secondary size-4" aria-hidden="true" />,
- onClick: () => {
- navigate(`/projects/${encodeURIComponent(project._id)}?edit=1`);
- toggleNav();
- },
+ onClick: () => setIsEditOpen(true),
+ hideOnClick: false,
+ ref: editMenuRef,
+ render: (props) => <button {...props} />,
},
{
id: `${menuId}-delete`,
@@ -286,7 +297,7 @@ const ProjectItem = memo(
render: (props) => <button {...props} />,
},
],
- [localize, menuId, navigate, openProject, project._id, toggleNav],
+ [localize, menuId, openProject],
);
return (
@@ -365,9 +376,15 @@ const ProjectItem = memo(
onShowAll={openProject}
/>
</Collapse>
+ <ProjectEditDialog
+ open={isEditOpen}
+ onOpenChange={(open) => closeMenuWith(setIsEditOpen, open)}
+ project={project}
+ triggerRef={editMenuRef}
+ />
<ProjectDeleteDialog
open={isDeleteOpen}
- onOpenChange={setIsDeleteOpen}
+ onOpenChange={(open) => closeMenuWith(setIsDeleteOpen, open)}
project={project}
triggerRef={deleteMenuRef}
/>
diff --git a/client/src/components/Projects/ProjectChatOptions.tsx b/client/src/components/Projects/ProjectChatOptions.tsx
index 205612c45f..06d33d57a0 100644
--- a/client/src/components/Projects/ProjectChatOptions.tsx
+++ b/client/src/components/Projects/ProjectChatOptions.tsx
@@ -1,7 +1,7 @@
import { memo, useId, useMemo, useRef, useState } from 'react';
import * as Ariakit from '@ariakit/react';
import { Ellipsis, FolderInput, FolderX, Trash2 } from 'lucide-react';
-import { DropdownPopup, Spinner, useToastContext } from '@librechat/client';
+import { Spinner, DropdownPopup, buttonVariants, useToastContext } from '@librechat/client';
import type { TConversation } from 'librechat-data-provider';
import type { MenuItemProps } from '~/common';
import ProjectButton from '~/components/Conversations/ConvoOptions/ProjectButton';
@@ -112,10 +112,9 @@ function ProjectChatOptions({ conversation, isMenuOpen, setIsMenuOpen }: Project
ref={menuButtonRef}
aria-label={localize('com_nav_convo_menu_options')}
className={cn(
- 'text-text-secondary flex h-8 w-8 shrink-0 items-center justify-center rounded-full outline-hidden transition-colors',
- 'hover:bg-surface-hover hover:text-text-primary',
- 'focus-visible:ring-text-primary focus-visible:ring-2 focus-visible:ring-inset',
- isMenuOpen && 'bg-surface-hover text-text-primary',
+ buttonVariants({ variant: 'row-action', size: 'icon-sm' }),
+ 'text-text-secondary rounded-lg',
+ isMenuOpen && 'bg-surface-hover-alt text-text-primary',
)}
>
<Ellipsis className="h-4 w-4" aria-hidden="true" />
diff --git a/client/src/components/Projects/ProjectEditDialog.tsx b/client/src/components/Projects/ProjectEditDialog.tsx
new file mode 100644
index 0000000000..db458a0288
--- /dev/null
+++ b/client/src/components/Projects/ProjectEditDialog.tsx
@@ -0,0 +1,68 @@
+import { useRef } from 'react';
+import { OGDialog, OGDialogTitle, OGDialogHeader, OGDialogContent } from '@librechat/client';
+import type { TChatProject } from 'librechat-data-provider';
+import type { ComponentProps } from 'react';
+import { useUpdateProjectMutation } from '~/data-provider';
+import ProjectEditor from './ProjectEditor';
+import { useLocalize } from '~/hooks';
+
+type ProjectEditDialogProps = {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ project: TChatProject;
+ triggerRef?: ComponentProps<typeof OGDialog>['triggerRef'];
+};
+
+export default function ProjectEditDialog({
+ open,
+ onOpenChange,
+ project,
+ triggerRef,
+}: ProjectEditDialogProps) {
+ const localize = useLocalize();
+ /** Owned here, so a save in flight settles with its toast; the dialog stays open meanwhile. */
+ const updateProject = useUpdateProjectMutation();
+ const savingRef = useRef(false);
+ /** Read at event time: the submit marks the ref before the loading state renders. */
+ const isBusy = () => savingRef.current || updateProject.isLoading;
+ return (
+ <OGDialog
+ open={open}
+ onOpenChange={(next) => {
+ if (next || !isBusy()) {
+ onOpenChange(next);
+ }
+ }}
+ triggerRef={triggerRef}
+ >
+ <OGDialogContent
+ className="w-11/12 max-w-md"
+ showCloseButton={false}
+ onEscapeKeyDown={(event) => {
+ if (isBusy()) {
+ event.preventDefault();
+ }
+ }}
+ onInteractOutside={(event) => {
+ if (isBusy()) {
+ event.preventDefault();
+ }
+ }}
+ >
+ <OGDialogHeader>
+ <OGDialogTitle>{localize('com_ui_edit_project')}</OGDialogTitle>
+ </OGDialogHeader>
+ {/* Mounted per opening so the form starts from the saved project. */}
+ {open ? (
+ <ProjectEditor
+ project={project}
+ layout="dialog"
+ updateProject={updateProject}
+ savingRef={savingRef}
+ onDone={() => onOpenChange(false)}
+ />
+ ) : null}
+ </OGDialogContent>
+ </OGDialog>
+ );
+}
diff --git a/client/src/components/Projects/ProjectEditor.tsx b/client/src/components/Projects/ProjectEditor.tsx
index effd120ede..93f58c61fc 100644
--- a/client/src/components/Projects/ProjectEditor.tsx
+++ b/client/src/components/Projects/ProjectEditor.tsx
@@ -16,9 +16,15 @@ import { cn } from '~/utils';
export type ProjectEditorProps = {
project: TChatProject;
onDone: () => void;
- layout?: 'workspace' | 'card';
+ layout?: 'workspace' | 'dialog';
inputRef?: RefObject<HTMLInputElement>;
initialField?: 'name' | 'description';
+ /** A host that outlives the editor, such as a dialog, passes its own mutation so the
+ * save settles (and reports) even if the editor unmounts first. */
+ updateProject?: ReturnType<typeof useUpdateProjectMutation>;
+ /** Set from the moment a save is submitted until it settles; a host reads it to refuse
+ * dismissal before the mutation's own loading state has rendered. */
+ savingRef?: MutableRefObject<boolean>;
};
type ProjectEditorForm = {
@@ -32,14 +38,18 @@ export default function ProjectEditor({
layout = 'workspace',
inputRef,
initialField = 'name',
+ updateProject: hostUpdateProject,
+ savingRef,
}: ProjectEditorProps) {
const localize = useLocalize();
- const updateProject = useUpdateProjectMutation();
+ const ownUpdateProject = useUpdateProjectMutation();
+ const updateProject = hostUpdateProject ?? ownUpdateProject;
const { data: startupConfig } = useGetStartupConfig();
const descriptionLimit =
startupConfig?.projects?.maxDescriptionLength ?? MAX_CHAT_PROJECT_DESCRIPTION_LENGTH;
const { showToast } = useToastContext();
- const isSavingRef = useRef(false);
+ const ownSavingRef = useRef(false);
+ const isSavingRef = savingRef ?? ownSavingRef;
const nameInputRef = useRef<HTMLInputElement | null>(null);
const {
register,
@@ -73,6 +83,8 @@ export default function ProjectEditor({
});
const isBusy = updateProject.isLoading;
const isWorkspace = layout === 'workspace';
+ const labelClassName = isWorkspace ? 'sr-only' : undefined;
+ const buttonSize = isWorkspace ? 'sm' : 'default';
const nameId = `project-editor-${project._id}-name`;
const descriptionId = `project-editor-${project._id}-description`;
const nameErrorId = `${nameId}-error`;
@@ -170,22 +182,19 @@ export default function ProjectEditor({
'min-w-0',
isWorkspace
? 'grid grid-cols-[auto_minmax(0,1fr)] items-start gap-x-3 gap-y-3'
- : 'flex flex-col gap-3',
+ : 'flex flex-col gap-4',
)}
>
- <span
- className={cn(
- 'text-text-secondary flex shrink-0 items-center justify-center',
- isWorkspace
- ? 'bg-surface-secondary size-12 rounded-2xl'
- : 'bg-surface-tertiary h-11 w-11 rounded-xl',
- )}
- aria-hidden="true"
- >
- <Folder className={isWorkspace ? 'size-6' : 'size-5'} aria-hidden="true" />
- </span>
- <div className="w-full min-w-0">
- <Label htmlFor={nameId} className="sr-only">
+ {isWorkspace ? (
+ <span
+ className="bg-surface-secondary text-text-secondary flex size-12 shrink-0 items-center justify-center rounded-2xl"
+ aria-hidden="true"
+ >
+ <Folder className="size-6" aria-hidden="true" />
+ </span>
+ ) : null}
+ <div className={cn('w-full min-w-0', !isWorkspace && 'space-y-2')}>
+ <Label htmlFor={nameId} className={labelClassName}>
{localize('com_ui_project_name')}
</Label>
<Input
@@ -197,7 +206,7 @@ export default function ProjectEditor({
maxLength={MAX_CHAT_PROJECT_NAME_LENGTH}
aria-invalid={errors.name ? 'true' : 'false'}
aria-describedby={errors.name ? nameErrorId : undefined}
- variant={isWorkspace ? 'title' : 'title-sm'}
+ variant={isWorkspace ? 'title' : undefined}
className="w-full max-w-full min-w-0 overflow-hidden wrap-anywhere"
/>
{errors.name ? (
@@ -206,9 +215,12 @@ export default function ProjectEditor({
</p>
) : null}
</div>
- <div className={cn('w-full min-w-0', isWorkspace && 'col-span-2')}>
- <Label htmlFor={descriptionId} className="sr-only">
- {localize('com_ui_description')} {localize('com_ui_optional')}
+ <div className={cn('w-full min-w-0', isWorkspace ? 'col-span-2' : 'space-y-2')}>
+ <Label htmlFor={descriptionId} className={labelClassName}>
+ {localize('com_ui_description')}{' '}
+ <span className={cn(!isWorkspace && 'text-text-secondary font-normal')}>
+ {localize('com_ui_optional')}
+ </span>
</Label>
<Textarea
{...descriptionRegistration}
@@ -221,7 +233,7 @@ export default function ProjectEditor({
variant="transparent"
className={cn(
'w-full max-w-full min-w-0 resize-none overflow-y-auto wrap-anywhere',
- isWorkspace ? 'h-24 max-h-32' : 'h-20 max-h-24',
+ isWorkspace ? 'h-24 max-h-32' : 'h-24 max-h-40',
)}
/>
{errors.description ? (
@@ -231,14 +243,20 @@ export default function ProjectEditor({
) : null}
</div>
</div>
- <div className="flex min-w-0 justify-end gap-2">
- <Button type="button" variant="outline" size="sm" onClick={onDone} disabled={isBusy}>
+ <div className={cn('flex min-w-0 justify-end', isWorkspace ? 'gap-2' : 'gap-4 pt-2')}>
+ <Button
+ type="button"
+ variant="outline"
+ size={buttonSize}
+ onClick={onDone}
+ disabled={isBusy}
+ >
{localize('com_ui_cancel')}
</Button>
<Button
type="submit"
variant="submit"
- size="sm"
+ size={buttonSize}
disabled={isBusy}
aria-label={localize('com_ui_save')}
>
diff --git a/client/src/components/Projects/ProjectResources.spec.tsx b/client/src/components/Projects/ProjectResources.spec.tsx
index 0ce8f4469c..9a380fe9c8 100644
--- a/client/src/components/Projects/ProjectResources.spec.tsx
+++ b/client/src/components/Projects/ProjectResources.spec.tsx
@@ -1,4 +1,7 @@
+import { useState } from 'react';
+import { RecoilRoot } from 'recoil';
import userEvent from '@testing-library/user-event';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
import type { TChatProjectFile, TFile, TFileUpload } from 'librechat-data-provider';
import type * as ClientModule from '@librechat/client';
@@ -34,13 +37,10 @@ jest.mock('@librechat/client', () => {
const React = jest.requireActual<typeof ReactModule>('react');
const actual = jest.requireActual<typeof ClientModule>('@librechat/client');
return {
+ ...actual,
Spinner: () => React.createElement('span', { 'aria-hidden': true }),
Alert: ({ children, role }: React.HTMLAttributes<HTMLDivElement>) =>
React.createElement('div', { role }, children),
- Button: actual.Button,
- DropdownPopup: actual.DropdownPopup,
- EmptyState: actual.EmptyState,
- Input: actual.Input,
FileUpload: React.forwardRef<
HTMLInputElement,
{ children: ReactNode; handleFileChange: React.ChangeEventHandler<HTMLInputElement> }
@@ -65,12 +65,15 @@ jest.mock('@librechat/client', () => {
React.createElement('div', null, children),
OGDialogTitle: ({ children }: { children: ReactNode }) =>
React.createElement('h2', null, children),
+ OGDialogDescription: ({ children }: { children: ReactNode }) =>
+ React.createElement('p', null, children),
TooltipAnchor: ({ render }: { render: ReactNode }) => render,
useToastContext: () => ({ showToast: mockShowToast }),
};
});
jest.mock('~/data-provider', () => ({
+ ...jest.requireActual('~/data-provider'),
useProjectFilesQuery: () => mockProjectQueryState,
useProjectAvailableFilesInfiniteQuery: () => mockAvailableFilesState,
useUploadFileMutation: () => ({ mutateAsync: mockUploadMutateAsync, isLoading: false }),
@@ -83,6 +86,8 @@ jest.mock('~/hooks', () => ({
useAgentCapabilities: () => ({ fileSearchEnabled: true }),
useGetAgentsConfig: () => ({ agentsConfig: { capabilities: ['file_search'] } }),
useHasAccess: () => mockCanUseFileSearch(),
+ useAuthContext: () => ({ user: { id: 'user-1' } }),
+ useToolFavorites: () => ({ favoriteKeys: new Set(), toggle: jest.fn() }),
useLocalize: () => (key: string, options?: { count?: number; name?: string }) => {
const translations: Record<string, string> = {
com_error_files_upload: 'An error occurred while uploading the file.',
@@ -116,6 +121,15 @@ jest.mock('~/hooks', () => ({
},
}));
+function Providers({ children }: { children: ReactNode }) {
+ const [client] = useState(() => new QueryClient());
+ return (
+ <QueryClientProvider client={client}>
+ <RecoilRoot>{children}</RecoilRoot>
+ </QueryClientProvider>
+ );
+}
+
const project = { _id: 'project-1', fileCount: 0 };
const uploadedFile = {
file_id: 'canonical-file-id',
@@ -128,7 +142,7 @@ const uploadedFile = {
} as unknown as TFileUpload;
function renderResources() {
- return render(<ProjectResources project={project} />);
+ return render(<ProjectResources project={project} />, { wrapper: Providers });
}
describe('ProjectResources', () => {
@@ -211,7 +225,7 @@ describe('ProjectResources', () => {
() => new Promise<TFileUpload>((resolve) => (finishFirstUpload = resolve)),
)
.mockResolvedValueOnce({ ...uploadedFile, file_id: 'second-canonical-id' });
- render(<ProjectResources project={{ ...project, fileCount: 48 }} />);
+ render(<ProjectResources project={{ ...project, fileCount: 48 }} />, { wrapper: Providers });
const input = screen.getByTestId('project-upload-input');
fireEvent.change(input, {
target: {
@@ -299,11 +313,203 @@ describe('ProjectResources', () => {
await user.click(screen.getByRole('menuitem', { name: 'Choose an existing file' }));
expect(await screen.findByText('No eligible indexed files')).toBeInTheDocument();
- await user.type(screen.getByRole('textbox', { name: 'Search files' }), 'invoice');
+ await user.type(screen.getByRole('searchbox', { name: 'Search files' }), 'invoice');
+ expect(await screen.findByText('No results match your search')).toBeInTheDocument();
+ expect(screen.queryByText('No eligible indexed files')).not.toBeInTheDocument();
+ });
+
+ it('reads an empty category view as a filtered result, not an empty library', async () => {
+ mockAvailableFilesState = {
+ ...mockAvailableFilesState,
+ data: {
+ pages: [{ files: [{ ...uploadedFile, file_id: 'doc-id' }] as TFile[], nextCursor: null }],
+ },
+ };
+ renderResources();
+ const user = userEvent.setup();
+ await user.click(screen.getByRole('button', { name: 'Add files' }));
+ await user.click(screen.getByRole('menuitem', { name: 'Choose an existing file' }));
+ await user.click(await screen.findByRole('radio', { name: 'com_ui_composer_files_images' }));
+
expect(await screen.findByText('No results match your search')).toBeInTheDocument();
expect(screen.queryByText('No eligible indexed files')).not.toBeInTheDocument();
});
+ it('retries the page that failed, keeping the files already loaded', async () => {
+ const firstPage = {
+ files: [{ ...uploadedFile, file_id: 'first-id', filename: 'first.txt' }] as TFile[],
+ nextCursor: null,
+ };
+ /* The next page fails: the query reports its error from then on. */
+ const fetchNextPage = jest.fn(async () => {
+ mockAvailableFilesState = { ...mockAvailableFilesState, isError: true };
+ return { isError: true };
+ });
+ mockAvailableFilesState = {
+ ...mockAvailableFilesState,
+ data: { pages: [firstPage] },
+ hasNextPage: true,
+ fetchNextPage,
+ };
+ renderResources();
+ const user = userEvent.setup();
+ await user.click(screen.getByRole('button', { name: 'Add files' }));
+ await user.click(screen.getByRole('menuitem', { name: 'Choose an existing file' }));
+ await user.click(await screen.findByRole('button', { name: 'Load more' }));
+
+ expect(await screen.findByRole('alert')).toHaveTextContent('Could not load project files');
+ expect(screen.getByRole('button', { name: /first.txt/ })).toBeInTheDocument();
+ await user.click(screen.getByRole('button', { name: 'Retry' }));
+ expect(fetchNextPage).toHaveBeenCalledTimes(2);
+ expect(mockRefetch).not.toHaveBeenCalled();
+ });
+
+ it('forgets a page failure once the query recovers', async () => {
+ const fetchNextPage = jest.fn(async () => {
+ mockAvailableFilesState = { ...mockAvailableFilesState, isError: true };
+ return { isError: true };
+ });
+ mockAvailableFilesState = {
+ ...mockAvailableFilesState,
+ data: {
+ pages: [
+ {
+ files: [{ ...uploadedFile, file_id: 'first-id', filename: 'first.txt' }] as TFile[],
+ nextCursor: null,
+ },
+ ],
+ },
+ hasNextPage: true,
+ fetchNextPage,
+ };
+ const view = renderResources();
+ const user = userEvent.setup();
+ await user.click(screen.getByRole('button', { name: 'Add files' }));
+ await user.click(screen.getByRole('menuitem', { name: 'Choose an existing file' }));
+ await user.click(await screen.findByRole('button', { name: 'Load more' }));
+ expect(await screen.findByRole('alert')).toBeInTheDocument();
+
+ /* The query recovers, then a refresh of the listed files fails. */
+ mockAvailableFilesState = { ...mockAvailableFilesState, isError: false };
+ view.rerender(<ProjectResources project={project} />);
+ await screen.findByRole('button', { name: 'Load more' });
+ mockAvailableFilesState = { ...mockAvailableFilesState, isError: true };
+ view.rerender(<ProjectResources project={project} />);
+
+ await user.click(await screen.findByRole('button', { name: 'Retry' }));
+ expect(mockRefetch).toHaveBeenCalled();
+ expect(fetchNextPage).toHaveBeenCalledTimes(1);
+ });
+
+ it('keeps the current search page failure when an earlier page request settles later', async () => {
+ const settles: Array<(result: { isError: boolean }) => void> = [];
+ const fetchNextPage = jest.fn(
+ () =>
+ new Promise<{ isError: boolean }>((resolve) => {
+ settles.push(resolve);
+ }),
+ );
+ mockAvailableFilesState = {
+ ...mockAvailableFilesState,
+ data: {
+ pages: [
+ {
+ files: [{ ...uploadedFile, file_id: 'first-id', filename: 'first.txt' }] as TFile[],
+ nextCursor: null,
+ },
+ ],
+ },
+ hasNextPage: true,
+ fetchNextPage,
+ };
+ const view = renderResources();
+ const user = userEvent.setup();
+ await user.click(screen.getByRole('button', { name: 'Add files' }));
+ await user.click(screen.getByRole('menuitem', { name: 'Choose an existing file' }));
+ await user.click(await screen.findByRole('button', { name: 'Load more' }));
+ await user.type(screen.getByRole('searchbox', { name: 'Search files' }), 'first');
+ await user.click(screen.getByRole('button', { name: 'Load more' }));
+ expect(fetchNextPage).toHaveBeenCalledTimes(2);
+
+ /* The current search's page fails, then the earlier search's request succeeds. */
+ mockAvailableFilesState = { ...mockAvailableFilesState, isError: true };
+ settles[1]({ isError: true });
+ await Promise.resolve();
+ settles[0]({ isError: false });
+ await Promise.resolve();
+ view.rerender(<ProjectResources project={project} />);
+
+ await user.click(await screen.findByRole('button', { name: 'Retry' }));
+ expect(fetchNextPage).toHaveBeenCalledTimes(3);
+ expect(mockRefetch).not.toHaveBeenCalled();
+ });
+
+ it('keeps a search page failure after visiting another search', async () => {
+ const fetchNextPage = jest.fn(async () => {
+ mockAvailableFilesState = { ...mockAvailableFilesState, isError: true };
+ return { isError: true };
+ });
+ mockAvailableFilesState = {
+ ...mockAvailableFilesState,
+ data: {
+ pages: [
+ {
+ files: [{ ...uploadedFile, file_id: 'first-id', filename: 'first.txt' }] as TFile[],
+ nextCursor: null,
+ },
+ ],
+ },
+ hasNextPage: true,
+ fetchNextPage,
+ };
+ const view = renderResources();
+ const user = userEvent.setup();
+ await user.click(screen.getByRole('button', { name: 'Add files' }));
+ await user.click(screen.getByRole('menuitem', { name: 'Choose an existing file' }));
+ await user.click(await screen.findByRole('button', { name: 'Load more' }));
+ expect(await screen.findByRole('alert')).toBeInTheDocument();
+
+ /* Another search loads fine; coming back finds the first search's page still missing. */
+ const search = screen.getByRole('searchbox', { name: 'Search files' });
+ await user.type(search, 'other');
+ mockAvailableFilesState = { ...mockAvailableFilesState, isError: false };
+ view.rerender(<ProjectResources project={project} />);
+ /* Back on the first search, whose query still reports the failed page. */
+ mockAvailableFilesState = { ...mockAvailableFilesState, isError: true };
+ await user.clear(search);
+ view.rerender(<ProjectResources project={project} />);
+
+ await user.click(await screen.findByRole('button', { name: 'Retry' }));
+ expect(fetchNextPage).toHaveBeenCalledTimes(2);
+ expect(mockRefetch).not.toHaveBeenCalled();
+ });
+
+ it('refetches the listed files when a refresh of them fails', async () => {
+ const fetchNextPage = jest.fn();
+ mockAvailableFilesState = {
+ ...mockAvailableFilesState,
+ data: {
+ pages: [
+ {
+ files: [{ ...uploadedFile, file_id: 'first-id', filename: 'first.txt' }] as TFile[],
+ nextCursor: null,
+ },
+ ],
+ },
+ hasNextPage: true,
+ fetchNextPage,
+ isError: true,
+ };
+ renderResources();
+ const user = userEvent.setup();
+ await user.click(screen.getByRole('button', { name: 'Add files' }));
+ await user.click(screen.getByRole('menuitem', { name: 'Choose an existing file' }));
+
+ await user.click(await screen.findByRole('button', { name: 'Retry' }));
+ expect(mockRefetch).toHaveBeenCalled();
+ expect(fetchNextPage).not.toHaveBeenCalled();
+ });
+
it('names the file limit when attaching an existing file to a full project', async () => {
mockAddMutateAsync.mockRejectedValueOnce({
message: 'unsafe association detail',
diff --git a/client/src/components/Projects/ProjectResources.tsx b/client/src/components/Projects/ProjectResources.tsx
index 10ff50cf0b..6f3ce2c965 100644
--- a/client/src/components/Projects/ProjectResources.tsx
+++ b/client/src/components/Projects/ProjectResources.tsx
@@ -14,30 +14,27 @@ import {
Upload,
X,
} from 'lucide-react';
-import {
- defaultAgentCapabilities,
- EToolResources,
- FileContext,
- MAX_CHAT_PROJECT_FILES,
- PermissionTypes,
- Permissions,
-} from 'librechat-data-provider';
import {
Alert,
Button,
DropdownPopup,
EmptyState,
FileUpload,
- Input,
OGDialog,
- OGDialogContent,
- OGDialogHeader,
- OGDialogTitle,
Spinner,
TooltipAnchor,
useToastContext,
} from '@librechat/client';
+import {
+ defaultAgentCapabilities,
+ EToolResources,
+ FileContext,
+ MAX_CHAT_PROJECT_FILES,
+ PermissionTypes,
+ Permissions,
+} from 'librechat-data-provider';
import type { TChatProjectFile, TError, TFile, TFileUpload } from 'librechat-data-provider';
+import type { FileView } from '~/components/Chat/Input/Composer/Files';
import {
useAddProjectFileMutation,
useGetStartupConfig,
@@ -47,8 +44,9 @@ import {
useUploadFileMutation,
} from '~/data-provider';
import { useAgentCapabilities, useGetAgentsConfig, useHasAccess, useLocalize } from '~/hooks';
+import FileGrid, { FILE_VIEWS } from '~/components/Chat/Input/Composer/Files';
+import { CatalogContent } from '~/components/Chat/Input/Composer/Catalog';
import { NotificationSeverity, type LocalizeFunction } from '~/common';
-import { formatFileSize } from '~/utils';
type ProjectResourcesProps = {
project: { _id: string; fileCount?: number };
};
@@ -114,6 +112,11 @@ export default function ProjectResources({ project }: ProjectResourcesProps) {
const [isPickerOpen, setIsPickerOpen] = useState(false);
const [pickerSearch, setPickerSearch] = useState('');
const deferredPickerSearch = useDeferredValue(pickerSearch);
+ const [pickerView, setPickerView] = useState<FileView>('all');
+ const fileViewOptions = useMemo(
+ () => FILE_VIEWS.map((option) => ({ value: option.value, label: localize(option.labelKey) })),
+ [localize],
+ );
const [uploading, setUploading] = useState<UploadState[]>([]);
const pendingUploadIdsRef = useRef(new Set<string>());
const optimisticAttachedIdsRef = useRef(new Set<string>());
@@ -150,6 +153,34 @@ export default function ProjectResources({ project }: ProjectResourcesProps) {
fetchNextPage,
refetch: refetchFiles,
} = availableFilesQuery;
+ /** The projects and searches whose last error came from loading a further page, so Retry
+ * fetches that page again rather than refetching what is already listed. Each query
+ * keeps its own marker until that same query recovers. */
+ const pageQueryKey = `${project._id}\u0000${deferredPickerSearch}`;
+ const [failedPageKeys, setFailedPageKeys] = useState<ReadonlySet<string>>(() => new Set());
+ const nextPageFailed = failedPageKeys.has(pageQueryKey);
+ if (nextPageFailed && !isFilesError) {
+ const next = new Set(failedPageKeys);
+ next.delete(pageQueryKey);
+ setFailedPageKeys(next);
+ }
+ const loadNextPage = () => {
+ const requestKey = pageQueryKey;
+ void fetchNextPage().then((result) =>
+ setFailedPageKeys((previous) => {
+ if (result.isError === previous.has(requestKey)) {
+ return previous;
+ }
+ const next = new Set(previous);
+ if (result.isError) {
+ next.add(requestKey);
+ } else {
+ next.delete(requestKey);
+ }
+ return next;
+ }),
+ );
+ };
const uploadFile = useUploadFileMutation();
const addFile = useAddProjectFileMutation();
const removeFile = useRemoveProjectFileMutation();
@@ -204,12 +235,14 @@ export default function ProjectResources({ project }: ProjectResourcesProps) {
]);
useEffect(() => {
setPickerSearch('');
+ setPickerView('all');
}, [project._id]);
const addExistingFile = async (fileId: string) => {
try {
await addFile.mutateAsync({ projectId: project._id, file_id: fileId });
setIsPickerOpen(false);
+ setIsFileMenuOpen(false);
} catch (error: unknown) {
showToast({
message: getAssociationErrorMessage(error, localize, projectFileLimit),
@@ -548,92 +581,79 @@ export default function ProjectResources({ project }: ProjectResourcesProps) {
</>
)}
- <OGDialog open={isPickerOpen} onOpenChange={setIsPickerOpen} triggerRef={pickerMenuRef}>
- <OGDialogContent className="w-11/12 max-w-lg" showCloseButton={true}>
- <OGDialogHeader>
- <OGDialogTitle>{localize('com_ui_project_choose_file')}</OGDialogTitle>
- </OGDialogHeader>
- <label className="sr-only" htmlFor="project-file-search">
- {localize('com_ui_search_files')}
- </label>
- <Input
- id="project-file-search"
- value={pickerSearch}
- onChange={(event) => setPickerSearch(event.target.value)}
- placeholder={localize('com_ui_search_files')}
- aria-label={localize('com_ui_search_files')}
- />
- <div
- className="mt-3 max-h-80 space-y-2 overflow-y-auto"
- role="region"
- aria-live="polite"
- aria-label={localize('com_ui_project_choose_file')}
+ <OGDialog
+ open={isPickerOpen}
+ onOpenChange={(open) => {
+ setIsPickerOpen(open);
+ if (!open) {
+ setIsFileMenuOpen(false);
+ }
+ }}
+ triggerRef={pickerMenuRef}
+ >
+ {isPickerOpen ? (
+ <CatalogContent
+ title={localize('com_ui_project_choose_file')}
+ searchLabel={localize('com_ui_search_files')}
+ search={pickerSearch}
+ onSearchChange={setPickerSearch}
+ filterLabel={localize('com_ui_composer_files_filter')}
+ viewOptions={fileViewOptions}
+ view={pickerView}
+ onViewChange={(value) => setPickerView(value as FileView)}
>
- {(isFilesLoading || isFetchingNextPage) && (
- <div role="status" className="text-text-secondary flex justify-center py-6">
- <Spinner className="size-4" />
- <span className="sr-only">{localize('com_ui_loading')}</span>
- </div>
- )}
- {isFilesError && (
- <Alert variant="error" role="alert">
- {localize('com_ui_project_files_error')}
- <Button type="button" variant="outline" size="sm" onClick={() => refetchFiles()}>
+ <FileGrid
+ query={deferredPickerSearch.trim().toLowerCase()}
+ view={pickerView}
+ onAttach={(file) => void addExistingFile(file.file_id)}
+ source={{
+ files: availableFiles,
+ /* A further page can still hold a match for the current search or view. */
+ isLoading: isFilesLoading || isFetchingNextPage,
+ isError: isFilesError,
+ refetch: () => void refetchFiles(),
+ }}
+ disabled={addFile.isLoading || !hasFileCapacity}
+ emptyText={
+ deferredPickerSearch || pickerView !== 'all'
+ ? localize('com_ui_no_search_results')
+ : localize('com_ui_project_no_eligible_files')
+ }
+ />
+ {/* A later page that fails keeps the loaded cards; the grid only shows
+ its own retry while nothing has loaded. */}
+ {isFilesError && availableFiles.length > 0 && (
+ <Alert
+ variant="error"
+ icon={false}
+ role="alert"
+ className="mt-3 flex items-center justify-between"
+ >
+ <span>{localize('com_ui_project_files_error')}</span>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ disabled={isFetchingNextPage}
+ onClick={() => (nextPageFailed ? loadNextPage() : void refetchFiles())}
+ >
{localize('com_ui_retry')}
</Button>
</Alert>
)}
- {!isFilesLoading &&
- !isFilesError &&
- !isFetchingNextPage &&
- !availableFiles.length &&
- !hasNextPage && (
- <p className="text-text-secondary py-6 text-center text-sm">
- {deferredPickerSearch
- ? localize('com_ui_no_search_results')
- : localize('com_ui_project_no_eligible_files')}
- </p>
- )}
- {!isFilesLoading && !isFilesError && availableFiles.length > 0 && (
- <ul className="space-y-2">
- {availableFiles.map((file) => (
- <li key={file.file_id}>
- <Button
- type="button"
- variant="outline"
- size="row"
- className="w-full"
- onClick={() => void addExistingFile(file.file_id)}
- disabled={addFile.isLoading || !hasFileCapacity}
- >
- <Paperclip
- className="text-text-secondary size-4 shrink-0"
- aria-hidden="true"
- />
- <span className="text-text-primary min-w-0 flex-1 truncate text-sm">
- {file.filename}
- </span>
- <span className="text-text-secondary shrink-0 text-xs">
- {formatFileSize(file.bytes)}
- </span>
- </Button>
- </li>
- ))}
- </ul>
- )}
{!isFilesLoading && !isFilesError && hasNextPage && (
<Button
type="button"
variant="outline"
- className="w-full"
- onClick={() => void fetchNextPage()}
+ className="mt-3 w-full"
+ onClick={loadNextPage}
disabled={isFetchingNextPage}
>
{isFetchingNextPage ? localize('com_ui_loading') : localize('com_ui_load_more')}
</Button>
)}
- </div>
- </OGDialogContent>
+ </CatalogContent>
+ ) : null}
</OGDialog>
</section>
);
diff --git a/client/src/components/Projects/ProjectWorkspace.tsx b/client/src/components/Projects/ProjectWorkspace.tsx
index 7deb0943da..b9b0af087d 100644
--- a/client/src/components/Projects/ProjectWorkspace.tsx
+++ b/client/src/components/Projects/ProjectWorkspace.tsx
@@ -184,7 +184,7 @@ export default function ProjectWorkspace() {
if (isProjectLoading) {
return (
- <div className="bg-presentation text-text-primary flex h-full items-center justify-center">
+ <div className="bg-surface-primary-alt text-text-primary flex h-full items-center justify-center">
<Spinner />
</div>
);
@@ -192,7 +192,7 @@ export default function ProjectWorkspace() {
if (!project) {
return (
- <div className="bg-presentation flex h-full flex-col items-center justify-center gap-3 px-6 text-center">
+ <div className="bg-surface-primary-alt flex h-full flex-col items-center justify-center gap-3 px-6 text-center">
<p className="text-text-secondary text-sm">{localize('com_ui_project_not_found')}</p>
<Button type="button" variant="outline" size="sm" onClick={() => navigate('/projects')}>
{localize('com_ui_all_projects')}
@@ -363,8 +363,8 @@ export default function ProjectWorkspace() {
) : null;
return (
- <main className="bg-presentation text-text-primary flex h-full min-h-0 min-w-0 flex-col">
- <header className="border-border-light bg-presentation sticky top-0 z-10 border-b">
+ <main className="bg-surface-primary-alt text-text-primary flex h-full min-h-0 min-w-0 flex-col">
+ <header className="border-border-light bg-surface-primary-alt sticky top-0 z-10 border-b">
<div className="flex h-14 w-full items-center gap-2 px-4 md:h-16 md:px-6">
{isSmallScreen ? <OpenSidebar className="size-9 shrink-0" /> : null}
<Button
diff --git a/client/src/components/Projects/ProjectsNavBar.tsx b/client/src/components/Projects/ProjectsNavBar.tsx
index 715384f001..d65db21447 100644
--- a/client/src/components/Projects/ProjectsNavBar.tsx
+++ b/client/src/components/Projects/ProjectsNavBar.tsx
@@ -13,7 +13,7 @@ export default function ProjectsNavBar({ onCreate, search, onSearchChange }: Pro
const localize = useLocalize();
const isSmallScreen = useMediaQuery('(max-width: 768px)');
return (
- <header className="border-border-light bg-presentation sticky top-0 z-10 border-b">
+ <header className="border-border-light bg-surface-primary-alt sticky top-0 z-10 border-b">
<div className="flex min-h-14 w-full flex-wrap items-center gap-2 px-4 py-2.5 md:min-h-16 md:flex-nowrap md:px-6">
{isSmallScreen ? <OpenSidebar className="size-9 shrink-0" /> : null}
<h1 className="sr-only">{localize('com_ui_projects')}</h1>
@@ -23,7 +23,6 @@ export default function ProjectsNavBar({ onCreate, search, onSearchChange }: Pro
value={search}
onChange={(event) => onSearchChange(event.target.value)}
label={localize('com_ui_search_projects')}
- surface="presentation"
containerClassName="order-last w-full min-w-0 md:order-none md:w-auto md:max-w-md md:flex-1"
/>
<div className="ml-auto flex shrink-0 items-center gap-2">
diff --git a/client/src/components/Projects/ProjectsView.tsx b/client/src/components/Projects/ProjectsView.tsx
index 5e978755c1..a6e31c197a 100644
--- a/client/src/components/Projects/ProjectsView.tsx
+++ b/client/src/components/Projects/ProjectsView.tsx
@@ -2,16 +2,16 @@ import { useCallback, useDeferredValue, useEffect, useId, useMemo, useRef, useSt
import * as Ariakit from '@ariakit/react';
import { useNavigate, useSearchParams } from 'react-router-dom';
import { Ellipsis, Folder, FolderPlus, Pencil, Trash2 } from 'lucide-react';
-import { Button, DropdownPopup, Skeleton, Spinner } from '@librechat/client';
+import { Button, Spinner, Skeleton, DropdownPopup, buttonVariants } from '@librechat/client';
import type { TChatProject } from 'librechat-data-provider';
import type { ProjectSort } from './ProjectsSortMenu';
import type { MenuItemProps } from '~/common';
import { useProjectsInfiniteQuery } from '~/data-provider';
import ProjectCreateDialog from './ProjectCreateDialog';
import ProjectDeleteDialog from './ProjectDeleteDialog';
+import ProjectEditDialog from './ProjectEditDialog';
import ProjectsSortMenu from './ProjectsSortMenu';
import ProjectsNavBar from './ProjectsNavBar';
-import ProjectEditor from './ProjectEditor';
import { useLocalize } from '~/hooks';
import { cn } from '~/utils';
@@ -36,10 +36,17 @@ function ProjectCard({
}) {
const localize = useLocalize();
const menuId = useId();
- const navigationButtonRef = useRef<HTMLButtonElement>(null);
- const inputRef = useRef<HTMLInputElement>(null);
+ const editMenuRef = useRef<HTMLButtonElement>(null);
const deleteMenuRef = useRef<HTMLButtonElement>(null);
const [isMenuOpen, setIsMenuOpen] = useState(false);
+ /** The dialog items keep the menu open so it does not steal focus from the
+ * dialog mounting beside it; closing the dialog closes the menu too. */
+ const closeMenuWith = (setOpen: (open: boolean) => void, open: boolean) => {
+ setOpen(open);
+ if (!open) {
+ setIsMenuOpen(false);
+ }
+ };
const [isEditOpen, setIsEditOpen] = useState(false);
const [isDeleteOpen, setIsDeleteOpen] = useState(false);
const activity = formatActivity(project);
@@ -50,6 +57,9 @@ function ProjectCard({
label: localize('com_ui_edit_project'),
icon: <Pencil className="text-text-secondary size-4" aria-hidden="true" />,
onClick: () => setIsEditOpen(true),
+ hideOnClick: false,
+ ref: editMenuRef,
+ render: (props) => <button {...props} />,
},
{
id: `${menuId}-delete`,
@@ -69,67 +79,50 @@ function ProjectCard({
className={cn(
'group/project border-border-light bg-surface-secondary relative flex min-h-[9.5rem] max-w-full min-w-0 flex-col rounded-2xl border',
'hover:bg-surface-hover transition-colors duration-150 ease-out',
+ isMenuOpen && 'bg-surface-hover',
)}
>
- {isEditOpen ? (
- <div className="min-w-0 p-4 pr-12">
- <ProjectEditor
- project={project}
- layout="card"
- inputRef={inputRef}
- onDone={() => {
- setIsEditOpen(false);
- requestAnimationFrame(() => navigationButtonRef.current?.focus());
- }}
- />
- </div>
- ) : (
- <Button
- ref={navigationButtonRef}
- type="button"
- variant="card"
- size="tile"
- className="min-h-[9.5rem] w-full max-w-full min-w-0 flex-1 flex-col items-stretch"
- onClick={() => onOpen(project._id)}
- >
- <span className="bg-surface-tertiary text-text-secondary group-hover/project:text-text-primary flex h-11 w-11 shrink-0 items-center justify-center rounded-xl transition-colors">
- <Folder className="h-5 w-5" aria-hidden="true" />
+ <Button
+ type="button"
+ variant="card"
+ size="tile"
+ className="min-h-[9.5rem] w-full max-w-full min-w-0 flex-1 flex-col items-stretch"
+ onClick={() => onOpen(project._id)}
+ >
+ <span className="bg-surface-tertiary text-text-secondary group-hover/project:text-text-primary flex h-11 w-11 shrink-0 items-center justify-center rounded-xl transition-colors">
+ <Folder className="h-5 w-5" aria-hidden="true" />
+ </span>
+ <span className="text-text-primary mt-3 line-clamp-2 max-w-full min-w-0 text-base font-semibold tracking-tight wrap-anywhere md:line-clamp-1">
+ {project.name}
+ </span>
+ {project.description ? (
+ <span className="text-text-secondary mt-1 line-clamp-2 max-w-full min-w-0 text-sm leading-relaxed text-pretty wrap-anywhere">
+ {project.description}
</span>
- <span className="text-text-primary mt-3 line-clamp-2 max-w-full min-w-0 text-base font-semibold tracking-tight wrap-anywhere md:line-clamp-1">
- {project.name}
+ ) : null}
+ <span className="text-text-secondary mt-auto flex max-w-full min-w-0 items-center gap-2 pt-4 text-xs tabular-nums">
+ <span>
+ {project.conversationCount === 1
+ ? localize('com_ui_project_chat_count_single')
+ : localize('com_ui_project_chat_count', {
+ count: project.conversationCount,
+ })}
</span>
- {project.description ? (
- <span className="text-text-secondary mt-1 line-clamp-2 max-w-full min-w-0 text-sm leading-relaxed text-pretty wrap-anywhere">
- {project.description}
- </span>
+ {activity ? (
+ <>
+ <span aria-hidden="true">·</span>
+ <time dateTime={project.lastConversationAt ?? project.updatedAt ?? project.createdAt}>
+ {activity}
+ </time>
+ </>
) : null}
- <span className="text-text-secondary mt-auto flex max-w-full min-w-0 items-center gap-2 pt-4 text-xs tabular-nums">
- <span>
- {project.conversationCount === 1
- ? localize('com_ui_project_chat_count_single')
- : localize('com_ui_project_chat_count', {
- count: project.conversationCount,
- })}
- </span>
- {activity ? (
- <>
- <span aria-hidden="true">·</span>
- <time
- dateTime={project.lastConversationAt ?? project.updatedAt ?? project.createdAt}
- >
- {activity}
- </time>
- </>
- ) : null}
- </span>
- </Button>
- )}
+ </span>
+ </Button>
<div className="absolute top-2 right-2">
<DropdownPopup
portal={true}
focusLoop={true}
unmountOnHide={true}
- finalFocus={isEditOpen ? inputRef : undefined}
menuId={menuId}
isOpen={isMenuOpen}
setIsOpen={setIsMenuOpen}
@@ -139,10 +132,9 @@ function ProjectCard({
<Ariakit.MenuButton
aria-label={localize('com_ui_more_options')}
className={cn(
- 'text-text-secondary flex h-8 w-8 items-center justify-center rounded-lg outline-hidden transition-colors',
- 'hover:bg-surface-tertiary hover:text-text-primary',
- 'focus-visible:ring-text-primary focus-visible:ring-2',
- isMenuOpen && 'bg-surface-tertiary text-text-primary',
+ buttonVariants({ variant: 'row-action', size: 'icon-sm' }),
+ 'text-text-secondary rounded-lg',
+ isMenuOpen && 'bg-surface-hover-alt text-text-primary',
)}
>
<Ellipsis className="h-4 w-4" aria-hidden="true" />
@@ -151,9 +143,15 @@ function ProjectCard({
items={menuItems}
/>
</div>
+ <ProjectEditDialog
+ open={isEditOpen}
+ onOpenChange={(open) => closeMenuWith(setIsEditOpen, open)}
+ project={project}
+ triggerRef={editMenuRef}
+ />
<ProjectDeleteDialog
open={isDeleteOpen}
- onOpenChange={setIsDeleteOpen}
+ onOpenChange={(open) => closeMenuWith(setIsDeleteOpen, open)}
project={project}
triggerRef={deleteMenuRef}
/>
diff --git a/e2e/specs/mock/projects.spec.ts b/e2e/specs/mock/projects.spec.ts
index 725599e48b..e9d637ba6a 100644
--- a/e2e/specs/mock/projects.spec.ts
+++ b/e2e/specs/mock/projects.spec.ts
@@ -73,7 +73,9 @@ test.describe('chat projects', () => {
await expect(page.getByRole('button', { name }).first()).toBeVisible();
});
- test('hands keyboard focus from the file menu to the picker and back', async ({ page }) => {
+ test('hands keyboard focus from the file menu to the picker and back @scenario:project-picker-keyboard-focus-round-trip', async ({
+ page,
+ }) => {
await page.route(
(url) => url.pathname === '/api/config',
async (route) => {
@@ -94,10 +96,10 @@ test.describe('chat projects', () => {
await page.keyboard.press('Enter');
const picker = page.getByRole('dialog');
await expect(picker.locator(':focus')).toHaveCount(1);
+ /* Closing the picker closes the menu that opened it, so focus returns to the menu button. */
await page.keyboard.press('Escape');
await expect(picker).toBeHidden();
- await expect(page.getByRole('menuitem', { name: 'Choose from your files' })).toBeFocused();
- await page.keyboard.press('Escape');
+ await expect(page.getByRole('menu')).toHaveCount(0);
await expect(addFiles).toBeFocused();
});
diff --git a/e2e/specs/mock/scenarios/project-files-ui.spec.ts b/e2e/specs/mock/scenarios/project-files-ui.spec.ts
index 85fe6de738..10c068dc52 100644
--- a/e2e/specs/mock/scenarios/project-files-ui.spec.ts
+++ b/e2e/specs/mock/scenarios/project-files-ui.spec.ts
@@ -319,22 +319,23 @@ test.describe('project file workspace UI', () => {
await page.reload({ waitUntil: 'domcontentloaded' });
const picker = await openExistingFilePicker(page);
- const results = picker.getByRole('region', { name: 'Choose from your files', exact: true });
+ const results = picker.getByRole('list', { name: 'Your files', exact: true });
const recentName = seeded.filenames[20];
if (!recentName) {
throw new Error('Expected a recent seeded file for the picker page');
}
const recentRow = results.getByRole('listitem').filter({ hasText: recentName });
await expect(recentRow).toBeVisible();
- await expect(recentRow.getByRole('button')).toHaveAccessibleName(
- new RegExp(`${escapeRegExp(recentName)}\\s+2\\.0 KB`),
+ /* The card names the file, then its type and size. */
+ await expect(recentRow.getByRole('button').first()).toHaveAccessibleName(
+ new RegExp(`^${escapeRegExp(recentName)}.*\\bKB\\b`),
);
- const search = picker.getByRole('textbox', { name: 'Search files', exact: true });
+ const search = picker.getByRole('searchbox', { name: 'Search files', exact: true });
await search.fill(targetName.slice(0, -4));
const targetRow = results.getByRole('listitem').filter({ hasText: targetName });
await expect(targetRow).toHaveCount(1);
- await expect(targetRow.getByRole('button')).toHaveAccessibleName(
+ await expect(targetRow.getByRole('button').first()).toHaveAccessibleName(
new RegExp(escapeRegExp(targetName)),
);
await expect(results.getByRole('listitem').filter({ hasText: recentName })).toHaveCount(0);
diff --git a/e2e/specs/mock/scenarios/projects-dialogs.spec.ts b/e2e/specs/mock/scenarios/projects-dialogs.spec.ts
new file mode 100644
index 0000000000..9f01f72493
--- /dev/null
+++ b/e2e/specs/mock/scenarios/projects-dialogs.spec.ts
@@ -0,0 +1,310 @@
+import { randomUUID } from 'crypto';
+import { expect, test } from '@playwright/test';
+import type { Locator, Page, Route } from '@playwright/test';
+import { FileContext } from 'librechat-data-provider';
+import { escapeRegExp, getAccessToken, uniqueName, NEW_CHAT_PATH } from '../helpers';
+import { requestResult } from '../content-filters.helpers';
+
+type Project = { id: string; name: string };
+
+const createdProjects: Array<{ id: string; token: string }> = [];
+
+/** Creates a project through the API (201) and loads the app so the page has a session. */
+async function createProject(page: Page, prefix: string): Promise<Project> {
+ await page.goto('/projects', { timeout: 10000 });
+ const token = await getAccessToken(page);
+ const name = uniqueName(prefix);
+ const result = await requestResult(page.request, {
+ path: '/api/projects',
+ token,
+ method: 'POST',
+ data: { name },
+ });
+ expect(result.status, result.text).toBe(201);
+ const body = result.body as { _id?: string; id?: string };
+ const id = body._id ?? body.id;
+ expect(id).toBeTruthy();
+ createdProjects.push({ id: id as string, token });
+ return { id: id as string, name };
+}
+
+test.afterEach(async ({ page }) => {
+ const projects = createdProjects.splice(0);
+ for (const project of projects) {
+ try {
+ await page.request.delete(`/api/projects/${encodeURIComponent(project.id)}`, {
+ headers: { Authorization: `Bearer ${project.token}` },
+ });
+ } catch {
+ // The project name is unique per test, so a missed cleanup cannot collide.
+ }
+ }
+});
+
+/** The Files region and its "Choose from your files" item need RAG on. */
+async function enableRag(page: Page) {
+ await page.route(
+ (url) => url.pathname === '/api/config',
+ async (route) => {
+ const response = await route.fetch();
+ await route.fulfill({ response, json: { ...(await response.json()), ragEnabled: true } });
+ },
+ );
+}
+
+const availablePath = (projectId: string) => `/api/projects/${projectId}/files/available`;
+
+function fileFixture(filename: string, type: string) {
+ const fileId = randomUUID();
+ const now = new Date().toISOString();
+ return {
+ user: 'e2e-user',
+ file_id: fileId,
+ filename,
+ filepath: `/uploads/${fileId}`,
+ bytes: 2048,
+ object: 'file',
+ type,
+ embedded: true,
+ context: FileContext.message_attachment,
+ source: 'local',
+ usage: 0,
+ createdAt: now,
+ updatedAt: now,
+ };
+}
+
+async function fulfillJson(route: Route, status: number, json: unknown) {
+ await route.fulfill({ status, contentType: 'application/json', body: JSON.stringify(json) });
+}
+
+async function openPicker(page: Page): Promise<Locator> {
+ await page.getByRole('button', { name: 'Add files', exact: true }).click();
+ await page.getByRole('menuitem', { name: 'Choose from your files' }).click();
+ const picker = page.getByRole('dialog', { name: 'Choose from your files' });
+ await expect(picker).toBeVisible();
+ return picker;
+}
+
+test.describe('project dialogs', () => {
+ test('Edit project opens a dialog, saves, and restores focus on Escape @scenario:project-edit-opens-dialog', async ({
+ page,
+ }) => {
+ const project = await createProject(page, 'E2E Edit Dialog');
+ await page.goto('/projects', { timeout: 10000 });
+ const card = page.locator('article').filter({ hasText: project.name });
+ await expect(card).toBeVisible();
+
+ const trigger = card.getByRole('button', { name: 'More options', exact: true });
+ await trigger.click();
+ await page.getByRole('menuitem', { name: 'Edit project', exact: true }).click();
+
+ const dialog = page.getByRole('dialog', { name: 'Edit project' });
+ await expect(dialog).toBeVisible();
+ const nameInput = dialog.getByRole('textbox', { name: 'Project name', exact: true });
+ await expect(nameInput).toBeFocused();
+ await expect(nameInput).toHaveValue(project.name);
+
+ const renamed = `${project.name} renamed`;
+ await nameInput.fill(renamed);
+ await dialog.getByRole('button', { name: 'Save', exact: true }).click();
+ await expect(dialog).toBeHidden();
+ await expect(page.locator('article').filter({ hasText: renamed })).toBeVisible();
+
+ // Second open: Escape closes the dialog without saving and leaves nothing open.
+ const renamedCard = page.locator('article').filter({ hasText: renamed });
+ const renamedTrigger = renamedCard.getByRole('button', {
+ name: 'More options',
+ exact: true,
+ });
+ await renamedTrigger.click();
+ await page.getByRole('menuitem', { name: 'Edit project', exact: true }).click();
+ await expect(dialog).toBeVisible();
+ await page.keyboard.press('Escape');
+ await expect(dialog).toBeHidden();
+ await expect(page.getByRole('menu')).toHaveCount(0);
+ await expect(renamedTrigger).toBeFocused();
+ });
+
+ test('a pending save keeps the Edit project dialog open and reports a failure @scenario:project-edit-dialog-holds-while-saving', async ({
+ page,
+ }) => {
+ const project = await createProject(page, 'E2E Edit Saving');
+ let releaseSave: () => void = () => undefined;
+ const saveHeld = new Promise<void>((resolve) => {
+ releaseSave = resolve;
+ });
+ await page.route(
+ (url) => url.pathname === `/api/projects/${project.id}`,
+ async (route) => {
+ if (route.request().method() !== 'PATCH') {
+ await route.fallback();
+ return;
+ }
+ await saveHeld;
+ await fulfillJson(route, 500, { error: 'save failed' });
+ },
+ );
+ await page.goto('/projects', { timeout: 10000 });
+ const card = page.locator('article').filter({ hasText: project.name });
+ await card.getByRole('button', { name: 'More options', exact: true }).click();
+ await page.getByRole('menuitem', { name: 'Edit project', exact: true }).click();
+
+ const dialog = page.getByRole('dialog', { name: 'Edit project' });
+ const nameInput = dialog.getByRole('textbox', { name: 'Project name', exact: true });
+ const draft = `${project.name} draft`;
+ await nameInput.fill(draft);
+ await dialog.getByRole('button', { name: 'Save', exact: true }).click();
+
+ /* Neither Escape nor a backdrop click dismisses the dialog while the save is pending. */
+ await page.keyboard.press('Escape');
+ await page.mouse.click(5, 5);
+ await expect(dialog).toBeVisible();
+
+ releaseSave();
+ await expect(page.getByText('Failed to rename project', { exact: true })).toBeVisible();
+ await expect(dialog).toBeVisible();
+ await expect(nameInput).toHaveValue(draft);
+ });
+
+ test('a filter with no matches shows the search empty state @scenario:project-picker-filtered-empty-state', async ({
+ page,
+ }) => {
+ const project = await createProject(page, 'E2E Picker Filter');
+ await enableRag(page);
+ await page.route(
+ (url) => url.pathname === availablePath(project.id),
+ (route) =>
+ fulfillJson(route, 200, {
+ files: [fileFixture('only-document.txt', 'text/plain')],
+ nextCursor: null,
+ }),
+ );
+ await page.goto(`/projects/${project.id}`, { timeout: 10000 });
+ await expect(
+ page.getByRole('heading', { name: new RegExp(escapeRegExp(project.name)) }),
+ ).toBeVisible();
+
+ const picker = await openPicker(page);
+ await expect(picker.getByText('only-document.txt')).toBeVisible();
+ /* The result count is announced politely while cards are listed. */
+ await expect(picker.getByRole('status').filter({ hasText: 'results found' })).toHaveText(
+ '1 results found',
+ );
+ await picker.getByRole('radio', { name: 'Images', exact: true }).click();
+ await expect(picker.getByText('No results match your search')).toBeVisible();
+ await expect(picker.getByText('only-document.txt')).toHaveCount(0);
+ await expect(picker.getByText('No searchable files available', { exact: false })).toHaveCount(
+ 0,
+ );
+ });
+
+ test('a failed later page keeps loaded files and retries @scenario:project-picker-page-failure-keeps-files', async ({
+ page,
+ }) => {
+ const project = await createProject(page, 'E2E Picker Pages');
+ await enableRag(page);
+ const first = fileFixture('first-page-file.txt', 'text/plain');
+ const second = fileFixture('second-page-file.txt', 'text/plain');
+ let failSecondPage = true;
+ await page.route(
+ (url) => url.pathname === availablePath(project.id),
+ (route) => {
+ const cursor = new URL(route.request().url()).searchParams.get('cursor');
+ if (!cursor) {
+ return fulfillJson(route, 200, { files: [first], nextCursor: 'page-2' });
+ }
+ if (failSecondPage) {
+ return fulfillJson(route, 500, { message: 'second page failed' });
+ }
+ return fulfillJson(route, 200, { files: [second], nextCursor: null });
+ },
+ );
+ await page.goto(`/projects/${project.id}`, { timeout: 10000 });
+ await expect(
+ page.getByRole('heading', { name: new RegExp(escapeRegExp(project.name)) }),
+ ).toBeVisible();
+
+ const picker = await openPicker(page);
+ await expect(picker.getByText('first-page-file.txt')).toBeVisible();
+ await picker.getByRole('button', { name: 'Load more', exact: true }).click();
+
+ const alert = picker.getByRole('alert').filter({ hasText: 'Could not load project files' });
+ await expect(alert).toBeVisible({ timeout: 20000 });
+ await expect(picker.getByText('first-page-file.txt')).toBeVisible();
+
+ failSecondPage = false;
+ await alert.getByRole('button', { name: 'Retry', exact: true }).click();
+ await expect(picker.getByText('second-page-file.txt')).toBeVisible();
+ await expect(picker.getByText('first-page-file.txt')).toBeVisible();
+ await expect(alert).toBeHidden();
+ });
+
+ test('closing the picker leaves no add-files menu open @scenario:project-picker-close-closes-menu', async ({
+ page,
+ }) => {
+ const project = await createProject(page, 'E2E Picker Close');
+ await enableRag(page);
+ await page.route(
+ (url) => url.pathname === availablePath(project.id),
+ (route) =>
+ fulfillJson(route, 200, {
+ files: [fileFixture('close-check.txt', 'text/plain')],
+ nextCursor: null,
+ }),
+ );
+ await page.goto(`/projects/${project.id}`, { timeout: 10000 });
+ await expect(
+ page.getByRole('heading', { name: new RegExp(escapeRegExp(project.name)) }),
+ ).toBeVisible();
+
+ const picker = await openPicker(page);
+ await page.keyboard.press('Escape');
+ await expect(picker).toBeHidden();
+ await expect(page.getByRole('menu')).toHaveCount(0);
+ await expect(page.getByRole('menuitem', { name: 'Choose from your files' })).toHaveCount(0);
+ const addFiles = page.getByRole('button', { name: 'Add files', exact: true });
+ await expect(addFiles).toHaveAttribute('aria-expanded', 'false');
+ /* With the menu gone, focus returns to the button that opened it. */
+ await expect(addFiles).toBeFocused();
+ });
+
+ test('project pages share the chat landing background @scenario:project-pages-match-landing-background', async ({
+ page,
+ }) => {
+ const project = await createProject(page, 'E2E Project Background');
+
+ /** The first non-transparent background at or above the main landmark, since the
+ * landing's surface is painted by a wrapper around `<main>`. */
+ const surfaceColor = (target: Page) =>
+ target
+ .getByRole('main')
+ .first()
+ .evaluate((element) => {
+ let node: HTMLElement | null = element as HTMLElement;
+ while (node) {
+ const color = getComputedStyle(node).backgroundColor;
+ if (color !== 'rgba(0, 0, 0, 0)' && color !== 'transparent') {
+ return color;
+ }
+ node = node.parentElement;
+ }
+ return 'transparent';
+ });
+
+ await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
+ await expect(page.getByRole('main').first()).toBeVisible();
+ const landing = await surfaceColor(page);
+ expect(landing).not.toBe('transparent');
+
+ await page.goto(`/projects/${project.id}`, { timeout: 10000 });
+ await expect(
+ page.getByRole('heading', { name: new RegExp(escapeRegExp(project.name)) }),
+ ).toBeVisible();
+ expect(await surfaceColor(page)).toBe(landing);
+
+ await page.goto('/projects', { timeout: 10000 });
+ await expect(page.locator('article').filter({ hasText: project.name })).toBeVisible();
+ expect(await surfaceColor(page)).toBe(landing);
+ });
+});