-
+ {/* Status sits on the avatar so the row's trailing edge stays free for its badges
+ and menu. The ring is 34px around the 20px icon: offset by half the difference. */}
+
+
+ {isGenerating && (
+
+ )}
+ {isUnseen && !isGenerating && (
+ /* `ConvoLink`'s aria-label carries the text equivalent of the ring and the dot. */
+
+ )}
+
)}
- {isUnseen && (
- /* `ConvoLink`'s aria-label carries the text equivalent, so the dot itself stays
- decorative rather than announcing a second time outside the row's button. */
-
- )}
{isSharedBadgeVisible && (
)}
diff --git a/client/src/components/Conversations/ConvoLink.tsx b/client/src/components/Conversations/ConvoLink.tsx
index 5150f3b20a..fb6c1a6ee3 100644
--- a/client/src/components/Conversations/ConvoLink.tsx
+++ b/client/src/components/Conversations/ConvoLink.tsx
@@ -9,6 +9,8 @@ interface ConvoLinkProps {
isHovered: boolean;
isSharedBadgeVisible: boolean;
isUnseen: boolean;
+ /** The avatar's ring is decorative, so the label carries the running state. */
+ isGenerating?: boolean;
title: string | null;
onRename: () => void;
isSmallScreen: boolean;
@@ -42,6 +44,7 @@ const ConvoLink: React.FC
= ({
isHovered,
isSharedBadgeVisible,
isUnseen,
+ isGenerating = false,
title,
onRename,
isSmallScreen,
@@ -131,7 +134,7 @@ const ConvoLink: React.FC = ({
= ({
})
: localize('com_ui_conversation_label', {
title: title || localize('com_ui_untitled'),
- })) + (isUnseen ? `, ${localize('com_ui_unread')}` : '')
+ })) +
+ (isGenerating ? `, ${localize('com_ui_generating')}` : '') +
+ (isUnseen && !isGenerating ? `, ${localize('com_ui_unread')}` : '')
}
>
{children}
{
).toBeInTheDocument();
const rows = screen.getAllByTestId('convo');
expect(rows.map((row) => row.textContent)).toEqual(['Project chat', 'Idle chat']);
- expect(rows.map((row) => row.getAttribute('data-project-badge'))).toEqual(['true', 'false']);
+ /* Project chats list under Chats too, so every row may badge; the row draws it only
+ for a chat that is filed in a project. */
+ expect(rows.map((row) => row.getAttribute('data-project-badge'))).toEqual(['true', 'true']);
});
it('fetches nothing under a sort that has no Running group', () => {
diff --git a/client/src/components/Conversations/__tests__/Convo.status.spec.tsx b/client/src/components/Conversations/__tests__/Convo.status.spec.tsx
new file mode 100644
index 0000000000..d24dfaca01
--- /dev/null
+++ b/client/src/components/Conversations/__tests__/Convo.status.spec.tsx
@@ -0,0 +1,142 @@
+import { DndProvider } from 'react-dnd';
+import { HTML5Backend } from 'react-dnd-html5-backend';
+import { render, screen, fireEvent } from '@testing-library/react';
+import type { TConversation } from 'librechat-data-provider';
+
+let mockIsUnseen = false;
+
+jest.mock('@librechat/client', () => ({
+ useMediaQuery: () => false,
+ useToastContext: () => ({ showToast: jest.fn() }),
+ Spinner: ({ className }: { className?: string }) => (
+
+ ),
+ Button: ({ children, ...props }: React.ComponentProps<'button'>) => (
+ {children}
+ ),
+}));
+
+jest.mock('~/hooks', () => ({
+ useLocalize: () => (key: string) => key,
+ useNavigateToConvo: () => ({ navigateToConvo: jest.fn() }),
+ useShiftKey: () => false,
+}));
+
+jest.mock('~/data-provider', () => ({
+ useGetStartupConfig: () => ({ data: { sharedLinksEnabled: false } }),
+ useUpdateConversationMutation: () => ({ mutateAsync: jest.fn() }),
+ usePinConversationMutation: () => ({ mutate: jest.fn() }),
+ useProjectName: () => 'Scheduling',
+}));
+
+jest.mock('react-router-dom', () => ({
+ useParams: () => ({ conversationId: 'other-convo' }),
+}));
+
+jest.mock('recoil', () => ({
+ useRecoilValue: () => [],
+}));
+
+jest.mock('~/store', () => ({
+ __esModule: true,
+ default: { allConversationsSelector: 'allConversationsSelector' },
+}));
+
+jest.mock('~/utils', () => ({
+ cn: (...classes: unknown[]) => classes.filter(Boolean).join(' '),
+ logger: { error: jest.fn() },
+ setDocumentTitle: jest.fn(),
+ isConversationUnseen: () => mockIsUnseen,
+}));
+
+jest.mock('../ConvoOptions', () => ({
+ ConvoOptions: () =>
,
+}));
+
+jest.mock('../ConversationEndpointIcon', () => ({
+ __esModule: true,
+ default: () =>
,
+}));
+
+jest.mock('../RenameForm', () => ({
+ __esModule: true,
+ default: () => ,
+}));
+
+import Conversation from '../Convo';
+
+const conversation = {
+ conversationId: 'convo-1',
+ title: 'Tool Approval UI',
+} as TConversation;
+
+const renderRow = (props: { isGenerating?: boolean; convo?: TConversation } = {}) =>
+ render(
+
+
+ ,
+ );
+
+const rowButton = () => screen.getByRole('button', { name: /^com_ui_conversation_label/ });
+const unreadDot = (container: HTMLElement) =>
+ container.querySelector('span[aria-hidden="true"].bg-status-info');
+
+describe('Conversation row status', () => {
+ beforeEach(() => {
+ mockIsUnseen = false;
+ });
+
+ it('rings the avatar while running and keeps the row menu reachable', () => {
+ renderRow({ isGenerating: true });
+
+ const ring = screen.getByTestId('status-ring');
+ expect(rowButton()).toContainElement(ring);
+ expect(rowButton()).toHaveAccessibleName('com_ui_conversation_label, com_ui_generating');
+ /* The trailing slot used to hold the spinner in place of the menu, so a running chat
+ could not be renamed or archived from the list. */
+ fireEvent.mouseEnter(screen.getByTestId('convo-item'));
+ expect(screen.getByTestId('convo-options')).toBeInTheDocument();
+ });
+
+ it('marks an unseen reply on the avatar and in the title weight', () => {
+ mockIsUnseen = true;
+ const { container } = renderRow();
+
+ const dot = unreadDot(container);
+ expect(dot).not.toBeNull();
+ expect(rowButton()).toContainElement(dot as HTMLElement);
+ expect(rowButton()).toHaveAccessibleName('com_ui_conversation_label, com_ui_unread');
+ expect(screen.getByText('Tool Approval UI').parentElement).toHaveClass('font-semibold');
+ });
+
+ it('shows only the ring when a chat with an unseen reply runs again', () => {
+ mockIsUnseen = true;
+ const { container } = renderRow({ isGenerating: true });
+
+ expect(screen.getByTestId('status-ring')).toBeInTheDocument();
+ expect(unreadDot(container)).toBeNull();
+ expect(rowButton()).toHaveAccessibleName('com_ui_conversation_label, com_ui_generating');
+ expect(screen.getByText('Tool Approval UI').parentElement).not.toHaveClass('font-semibold');
+ });
+
+ it('draws no status on an idle, read chat', () => {
+ const { container } = renderRow();
+
+ expect(screen.queryByTestId('status-ring')).not.toBeInTheDocument();
+ expect(unreadDot(container)).toBeNull();
+ expect(rowButton()).toHaveAccessibleName('com_ui_conversation_label');
+ });
+
+ it('names the project of a filed chat listed under Chats', () => {
+ renderRow({ convo: { ...conversation, chatProjectId: 'project-1' } as TConversation });
+
+ expect(screen.getByTestId('convo-project-badge')).toHaveAttribute('title', 'com_ui_in_project');
+ expect(rowButton()).toHaveAccessibleDescription('com_ui_in_project');
+ });
+});
diff --git a/client/src/components/Conversations/__tests__/DateLabel.test.tsx b/client/src/components/Conversations/__tests__/DateLabel.test.tsx
index 439a20d8d6..59d5cff3bc 100644
--- a/client/src/components/Conversations/__tests__/DateLabel.test.tsx
+++ b/client/src/components/Conversations/__tests__/DateLabel.test.tsx
@@ -4,12 +4,14 @@ import '@testing-library/jest-dom/extend-expect';
import { DateLabel } from '../Conversations';
jest.mock('~/hooks', () => ({
- useLocalize: () => (key: string, params?: Record) => {
+ useLocalize: () => (key: string, params?: Record) => {
const translations: Record = {
com_a11y_chats_date_section: `Chats from ${params?.date ?? ''}`,
com_a11y_chats_alpha_section: `Chats with titles starting with ${params?.letter ?? ''}`,
- com_a11y_chats_running_section: 'Running chats',
+ com_a11y_chats_running_section: `${params?.count} running chats`,
+ com_a11y_chats_finished_section: `${params?.count} finished chats with unread replies`,
com_ui_running_chats: 'Running',
+ com_ui_finished_chats: 'Finished',
com_ui_date_today: 'Today',
com_ui_date_yesterday: 'Yesterday',
com_ui_date_previous_7_days: 'Previous 7 days',
@@ -24,13 +26,25 @@ describe('DateLabel', () => {
expect(screen.getByRole('heading', { level: 2, name: 'Chats from Today' })).toBeInTheDocument();
});
- it('announces the running group without describing it as a date', () => {
- render( );
- expect(screen.getByRole('heading', { level: 2, name: 'Running chats' })).toHaveTextContent(
- 'Running',
+ it('announces the running group with its count, not as a date', () => {
+ render( );
+ expect(screen.getByRole('heading', { level: 2, name: '4 running chats' })).toHaveTextContent(
+ 'Running · 4',
);
});
+ it('announces the finished group with its count', () => {
+ render( );
+ expect(
+ screen.getByRole('heading', { level: 2, name: '2 finished chats with unread replies' }),
+ ).toHaveTextContent('Finished · 2');
+ });
+
+ it('leaves the count off date groups', () => {
+ render( );
+ expect(screen.getByRole('heading', { level: 2 })).toHaveTextContent(/^Today$/);
+ });
+
it('uses the alphabetical accessible name for title groups', () => {
render( );
expect(
diff --git a/client/src/components/Conversations/__tests__/chatFilters.spec.ts b/client/src/components/Conversations/__tests__/chatFilters.spec.ts
index a61ea659c3..a7ee0c252a 100644
--- a/client/src/components/Conversations/__tests__/chatFilters.spec.ts
+++ b/client/src/components/Conversations/__tests__/chatFilters.spec.ts
@@ -4,7 +4,9 @@ import {
chatFilterCountAtom,
chatFilterStatusAtom,
chatFilterTagsAtom,
+ resetChatFiltersAtom,
selectableBookmarks,
+ showProjectChatsAtom,
} from '../chatFilters';
describe('chatFilterCountAtom', () => {
@@ -26,6 +28,46 @@ describe('chatFilterCountAtom', () => {
});
});
+describe('showProjectChatsAtom', () => {
+ afterEach(() => {
+ localStorage.clear();
+ });
+
+ it('lists project chats under Chats by default', () => {
+ expect(createStore().get(showProjectChatsAtom)).toBe(true);
+ });
+
+ it('counts hiding them as one change the menu badge and Reset own', () => {
+ const store = createStore();
+ store.set(showProjectChatsAtom, false);
+ expect(store.get(chatFilterCountAtom)).toBe(1);
+
+ store.set(resetChatFiltersAtom);
+ expect(store.get(showProjectChatsAtom)).toBe(true);
+ expect(store.get(chatFilterCountAtom)).toBe(0);
+ });
+
+ /** Storage is read once, when the module loads, which is what a new visit does. */
+ const onNextVisit = (stored: unknown): boolean => {
+ localStorage.setItem('chatListShowProjectChats', JSON.stringify(stored));
+ let value: boolean | undefined;
+ jest.isolateModules(() => {
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
+ const filters = require('../chatFilters') as typeof import('../chatFilters');
+ value = createStore().get(filters.showProjectChatsAtom);
+ });
+ return value as boolean;
+ };
+
+ it('keeps the choice to hide them across visits', () => {
+ expect(onNextVisit(false)).toBe(false);
+ });
+
+ it('reads a stored value that is not a boolean as the default', () => {
+ expect(onNextVisit('no')).toBe(true);
+ });
+});
+
describe('selectableBookmarks', () => {
const tag = (name: string, count: number): TConversationTag => ({
_id: name,
diff --git a/client/src/components/Conversations/__tests__/running.spec.ts b/client/src/components/Conversations/__tests__/running.spec.ts
index 544b6d7a6a..396bd642e5 100644
--- a/client/src/components/Conversations/__tests__/running.spec.ts
+++ b/client/src/components/Conversations/__tests__/running.spec.ts
@@ -3,7 +3,8 @@ import type { ConversationGroupOptions } from '~/utils/convos';
import {
unlistedRunningIds,
RUNNING_CHATS_GROUP,
- groupConversationsWithRunning as partitionGroups,
+ FINISHED_CHATS_GROUP,
+ groupConversationsByStatus as partitionGroups,
} from '../running';
import { groupConversations } from '~/utils/convos';
@@ -26,7 +27,7 @@ const groupConversationsWithRunning = (
options: ConversationGroupOptions,
) => partitionGroups(groupConversations(conversations, options), activeJobIds, options);
-describe('groupConversationsWithRunning', () => {
+describe('groupConversationsByStatus', () => {
it('returns the same date groups when the polled jobs do not affect loaded rows', () => {
const dated = groupConversations([convo('idle', 1)], newestFirst);
expect(partitionGroups(dated, new Set(), newestFirst)).toBe(dated);
@@ -196,3 +197,76 @@ describe('running chats the loaded rows do not hold', () => {
expect(partitionGroups(dated, new Set(['in-project']), options, unlisted)).toBe(dated);
});
});
+
+describe('groupConversationsByStatus finished chats', () => {
+ const replied = (
+ conversationId: string,
+ daysAgo: number,
+ read: Partial = {},
+ ): TConversation =>
+ ({
+ ...convo(conversationId, daysAgo),
+ lastResponseAt: new Date(Date.now() - daysAgo * 86_400_000).toISOString(),
+ ...read,
+ }) as TConversation;
+
+ it('lists a reply that arrived unseen under Finished, after Running and before the dates', () => {
+ const newest = convo('newest', 0);
+ const running = convo('running', 1);
+ const unseen = replied('unseen', 3);
+ const seen = replied('seen', 2, { lastSeenAt: new Date().toISOString() });
+ const groups = groupConversationsWithRunning(
+ [newest, running, seen, unseen],
+ new Set(['running']),
+ newestFirst,
+ );
+
+ expect(groups[0]).toEqual([RUNNING_CHATS_GROUP, [running]]);
+ expect(groups[1]).toEqual([FINISHED_CHATS_GROUP, [unseen]]);
+ expect(ids(groups)).toEqual(['running', 'unseen', 'newest', 'seen']);
+ });
+
+ it('shows Finished with no chat running', () => {
+ const groups = groupConversationsWithRunning(
+ [convo('newest', 0), replied('unseen', 2)],
+ new Set(),
+ newestFirst,
+ );
+
+ expect(groups.map(([name]) => name)[0]).toBe(FINISHED_CHATS_GROUP);
+ expect(ids(groups)).toEqual(['unseen', 'newest']);
+ });
+
+ it('keeps a running chat under Running even while its previous reply is unseen', () => {
+ const groups = groupConversationsWithRunning(
+ [replied('busy', 1)],
+ new Set(['busy']),
+ newestFirst,
+ );
+
+ expect(groups).toEqual([
+ [RUNNING_CHATS_GROUP, [expect.objectContaining({ conversationId: 'busy' })]],
+ ]);
+ });
+
+ it('leaves a chat marked unread by hand in its date group', () => {
+ const manual = replied('manual', 1, { lastResponseIsManual: true });
+ const dated = groupConversations([manual], newestFirst);
+
+ expect(partitionGroups(dated, new Set(), newestFirst)).toBe(dated);
+ });
+
+ it.each([
+ { field: 'updatedAt' as const, direction: 'asc' as const },
+ { field: 'title' as const, direction: 'asc' as const },
+ ])('keeps unseen chats in place under the $field $direction order', (options) => {
+ const dated = groupConversations([replied('unseen', 1), convo('other', 0)], options);
+ expect(partitionGroups(dated, new Set(), options)).toBe(dated);
+ });
+
+ it('keeps unseen chats in place when the list includes pins', () => {
+ const options = { ...newestFirst, includePinned: true };
+ const dated = groupConversations([replied('unseen', 1)], options);
+ expect(partitionGroups(dated, new Set(), options)).toBe(dated);
+ });
+});
diff --git a/client/src/components/Conversations/chatFilters.ts b/client/src/components/Conversations/chatFilters.ts
index b4770235e0..71fd8cb055 100644
--- a/client/src/components/Conversations/chatFilters.ts
+++ b/client/src/components/Conversations/chatFilters.ts
@@ -66,6 +66,18 @@ export const chatSortAtom = atom(
},
);
+const storedShowProjectChatsAtom = createStorageAtom('chatListShowProjectChats', true);
+
+/** Whether chats filed in a project also list under Chats, where recent work is looked
+ * for first. A display preference, so it is kept like the sort; anything but an explicit
+ * `false` reads as the default. */
+export const showProjectChatsAtom = atom(
+ (get) => get(storedShowProjectChatsAtom) !== false,
+ (_get, set, next: boolean) => {
+ set(storedShowProjectChatsAtom, next);
+ },
+);
+
/** Read by conversation rows to offer restoring instead of archiving. */
export const isArchivedChatViewAtom = atom((get) => get(chatFilterStatusAtom) === 'archived');
@@ -81,6 +93,9 @@ export const chatFilterCountAtom = atom((get) => {
if (sort.field !== DEFAULT_CHAT_SORT.field || sort.direction !== DEFAULT_CHAT_SORT.direction) {
count += 1;
}
+ if (!get(showProjectChatsAtom)) {
+ count += 1;
+ }
return count;
});
@@ -88,6 +103,7 @@ export const resetChatFiltersAtom = atom(null, (_get, set) => {
set(chatFilterStatusAtom, 'active');
set(chatFilterTagsAtom, []);
set(storedChatSortAtom, DEFAULT_CHAT_SORT);
+ set(storedShowProjectChatsAtom, true);
});
/**
diff --git a/client/src/components/Conversations/running.ts b/client/src/components/Conversations/running.ts
index 3198dac069..563d7e9c5a 100644
--- a/client/src/components/Conversations/running.ts
+++ b/client/src/components/Conversations/running.ts
@@ -1,21 +1,28 @@
import type { TConversation, GroupedConversations } from 'librechat-data-provider';
import type { ConversationGroupOptions } from '~/utils/convos';
import { isTemporaryConversation } from '~/utils/conversation';
+import { isConversationUnseen } from '~/utils/convos';
export const RUNNING_CHATS_GROUP = 'com_ui_running_chats';
+export const FINISHED_CHATS_GROUP = 'com_ui_finished_chats';
+
+/** Groups that hold chats by what they are doing rather than by date; their headings
+ * carry a count. */
+export const isStatusGroup = (groupName: string): boolean =>
+ groupName === RUNNING_CHATS_GROUP || groupName === FINISHED_CHATS_GROUP;
const noUnlistedIds: string[] = [];
-function showsRunningGroup(
- activeJobIds: ReadonlySet,
- options: ConversationGroupOptions,
-): boolean {
- return (
- !options.includePinned &&
- options.field === 'updatedAt' &&
- options.direction === 'desc' &&
- activeJobIds.size > 0
- );
+/** Status groups only make sense over the newest-first list: under any other order a
+ * chat lifted to the top would read as the first by title or by creation. */
+function showsStatusGroups(options: ConversationGroupOptions): boolean {
+ return !options.includePinned && options.field === 'updatedAt' && options.direction === 'desc';
+}
+
+/** A reply that landed while the user was elsewhere. "Mark as unread" sets the same
+ * stamp as a reminder, not as a finished run, so that chat keeps its date. */
+function isFinishedUnseen(conversation: TConversation): boolean {
+ return conversation.lastResponseIsManual !== true && isConversationUnseen(conversation);
}
function newestFirst(a: TConversation, b: TConversation): number {
@@ -44,20 +51,23 @@ export function unlistedRunningIds(
/**
* Partition the existing server-ordered groups without re-sorting them on every job update.
- * `unlisted` adds running chats those groups never held, so the Running group lists every
- * running chat; the date groups are still built only from the rows they were given.
+ * Running chats lead; chats whose reply arrived unseen follow as Finished, so a run that
+ * ends while the user is elsewhere stays near the top until it is opened. `unlisted` adds
+ * running chats those groups never held, so the Running group lists every running chat;
+ * the date groups are still built only from the rows they were given.
*/
-export function groupConversationsWithRunning(
+export function groupConversationsByStatus(
groups: GroupedConversations,
activeJobIds: ReadonlySet,
options: ConversationGroupOptions,
unlisted: readonly TConversation[] = [],
): GroupedConversations {
- if (!showsRunningGroup(activeJobIds, options)) {
+ if (!showsStatusGroups(options)) {
return groups;
}
const running: TConversation[] = [];
+ const finished: TConversation[] = [];
const runningIds = new Set();
const remaining: GroupedConversations = [];
for (const [groupName, conversations] of groups) {
@@ -67,6 +77,8 @@ export function groupConversationsWithRunning(
if (id && activeJobIds.has(id)) {
running.push(conversation);
runningIds.add(id);
+ } else if (isFinishedUnseen(conversation)) {
+ finished.push(conversation);
} else {
idle.push(conversation);
}
@@ -76,24 +88,35 @@ export function groupConversationsWithRunning(
}
}
- const added = unlisted.filter((conversation) => {
- const id = conversation.conversationId;
- if (
- !id ||
- conversation.isArchived === true ||
- isTemporaryConversation(conversation) ||
- !activeJobIds.has(id) ||
- runningIds.has(id)
- ) {
- return false;
- }
- runningIds.add(id);
- return true;
- });
+ const added =
+ activeJobIds.size === 0
+ ? []
+ : unlisted.filter((conversation) => {
+ const id = conversation.conversationId;
+ if (
+ !id ||
+ conversation.isArchived === true ||
+ isTemporaryConversation(conversation) ||
+ !activeJobIds.has(id) ||
+ runningIds.has(id)
+ ) {
+ return false;
+ }
+ runningIds.add(id);
+ return true;
+ });
- if (running.length === 0 && added.length === 0) {
+ if (running.length === 0 && finished.length === 0 && added.length === 0) {
return groups;
}
- const runningGroup = added.length === 0 ? running : [...running, ...added].sort(newestFirst);
- return [[RUNNING_CHATS_GROUP, runningGroup], ...(running.length === 0 ? groups : remaining)];
+ const statusGroups: GroupedConversations = [];
+ if (running.length > 0 || added.length > 0) {
+ const runningGroup = added.length === 0 ? running : [...running, ...added].sort(newestFirst);
+ statusGroups.push([RUNNING_CHATS_GROUP, runningGroup]);
+ }
+ if (finished.length > 0) {
+ statusGroups.push([FINISHED_CHATS_GROUP, finished]);
+ }
+ const pulled = running.length > 0 || finished.length > 0;
+ return [...statusGroups, ...(pulled ? remaining : groups)];
}
diff --git a/client/src/components/UnifiedSidebar/ConversationsSection.tsx b/client/src/components/UnifiedSidebar/ConversationsSection.tsx
index 65664eae21..ebd67adafa 100644
--- a/client/src/components/UnifiedSidebar/ConversationsSection.tsx
+++ b/client/src/components/UnifiedSidebar/ConversationsSection.tsx
@@ -15,6 +15,7 @@ import {
chatFilterTagsAtom,
chatSortAtom,
isArchivedChatViewAtom,
+ showProjectChatsAtom,
} from '~/components/Conversations/chatFilters';
import {
useLocalize,
@@ -47,6 +48,7 @@ const ConversationsSection = memo(() => {
const tags = useAtomValue(chatFilterTagsAtom);
const sort = useAtomValue(chatSortAtom);
const isArchivedView = useAtomValue(isArchivedChatViewAtom);
+ const showProjectChats = useAtomValue(showProjectChatsAtom);
/** Date, endpoint and attachment facets, already shaped as list parameters. */
const facetParams = useAtomValue(chatFacetParamsAtom);
/** Keeps the date facets' midnight anchor advancing while the list is mounted. */
@@ -67,13 +69,17 @@ const ConversationsSection = memo(() => {
* projects are loading or failed to load, an empty Chats list claims no more than
* that nothing sits outside a project. */
const hasProjects = !projectsLoaded || (projectsData?.pages[0]?.projects?.length ?? 0) > 0;
- /** A chat that belongs to a project is shown under that project, not twice. Search and
- * the archived view stay whole: both are places the user goes to find something, and a
- * project chat that appears in neither list nor result would have no way back. So does
- * a list whose projects failed to load, which would otherwise hide every project chat
- * behind a section that cannot show them. */
+ /** Project chats list under Chats too, badged with their folder, because Chats is where
+ * recent work is looked for first. Turning that off shows each one only under its
+ * project. Search and the archived view stay whole either way: both are places the user
+ * goes to find something, and a project chat that appears in neither list nor result
+ * would have no way back. So does a list whose projects failed to load, which would
+ * otherwise hide every project chat behind a section that cannot show them. */
const scopeToUnassigned =
- !isArchivedView && !search.debouncedQuery && !(projectsFailed && projectsData == null);
+ !showProjectChats &&
+ !isArchivedView &&
+ !search.debouncedQuery &&
+ !(projectsFailed && projectsData == null);
const {
data,
diff --git a/client/src/components/UnifiedSidebar/__tests__/ConversationsSection.spec.tsx b/client/src/components/UnifiedSidebar/__tests__/ConversationsSection.spec.tsx
index b7701396e1..2fb4665037 100644
--- a/client/src/components/UnifiedSidebar/__tests__/ConversationsSection.spec.tsx
+++ b/client/src/components/UnifiedSidebar/__tests__/ConversationsSection.spec.tsx
@@ -1,4 +1,5 @@
import React from 'react';
+import { getDefaultStore } from 'jotai';
import { DndProvider } from 'react-dnd';
import { BrowserRouter } from 'react-router-dom';
import { HTML5Backend } from 'react-dnd-html5-backend';
@@ -180,6 +181,7 @@ jest.mock('~/components/Nav/Favorites/FavoriteItem', () => ({
default: () =>
,
}));
+import { showProjectChatsAtom } from '~/components/Conversations/chatFilters';
import ConversationsSection from '../ConversationsSection';
import store from '~/store';
@@ -307,19 +309,33 @@ describe('ConversationsSection project chats', () => {
mockListParams.mockClear();
});
- /** A chat that belongs to a project is shown under that project. Listing it in
- * Chats as well puts the same conversation in two places in one sidebar. */
- it('asks only for chats that belong to no project', async () => {
+ afterEach(() => {
+ act(() => getDefaultStore().set(showProjectChatsAtom, true));
+ });
+
+ /** Chats is where recent work is looked for first, so a chat filed in a project is
+ * listed there too, carrying its folder badge. */
+ it('lists project chats under Chats by default', async () => {
renderSection();
await settleRenders();
expect(mockListParams).toHaveBeenCalled();
+ expect(mockListParams.mock.calls.at(-1)?.[0]).toMatchObject({ projectId: undefined });
+ });
+
+ /** Turned off, a project chat is shown only under its project, not twice. */
+ it('asks only for chats that belong to no project once project chats are hidden', async () => {
+ act(() => getDefaultStore().set(showProjectChatsAtom, false));
+ renderSection();
+ await settleRenders();
+
expect(mockListParams.mock.calls.at(-1)?.[0]).toMatchObject({ projectId: 'unassigned' });
});
/** Searching is how a chat is found, and Projects is not rendered while a search
* is on: excluding project chats there would make them unreachable. */
it('searches across every chat, project or not', async () => {
+ act(() => getDefaultStore().set(showProjectChatsAtom, false));
let setSearch: SetterOrUpdater;
function SearchController() {
@@ -363,9 +379,16 @@ describe('ConversationsSection empty Chats wording', () => {
(mockConversationsRender.mock.calls.at(-1)?.[0] as { accountHasProjects?: boolean })
.accountHasProjects;
+ /** The empty wording only distinguishes an empty account while Chats leaves project
+ * chats to their projects. */
beforeEach(() => {
mockConversationsRender.mockClear();
mockUseProjectsInfiniteQuery.mockReset();
+ act(() => getDefaultStore().set(showProjectChatsAtom, false));
+ });
+
+ afterEach(() => {
+ act(() => getDefaultStore().set(showProjectChatsAtom, true));
});
it('calls the account empty only once its projects have loaded and there are none', async () => {
diff --git a/client/src/data-provider/Projects/queries.ts b/client/src/data-provider/Projects/queries.ts
index 37de0add31..ed5fb688ec 100644
--- a/client/src/data-provider/Projects/queries.ts
+++ b/client/src/data-provider/Projects/queries.ts
@@ -1,5 +1,5 @@
import { dataService, QueryKeys } from 'librechat-data-provider';
-import { useInfiniteQuery, useQuery } from '@tanstack/react-query';
+import { useInfiniteQuery, useQuery, useQueryClient } from '@tanstack/react-query';
import type {
ProjectAvailableFilesParams,
ProjectAvailableFilesResponse,
@@ -9,6 +9,7 @@ import type {
TChatProjectFile,
} from 'librechat-data-provider';
import type {
+ InfiniteData,
UseInfiniteQueryOptions,
QueryObserverResult,
UseQueryOptions,
@@ -54,6 +55,32 @@ export const useProjectQuery = (
},
);
};
+/**
+ * A project's name for a row that only carries its id. The sidebar already holds the
+ * recent projects, so a name found there costs no request; only a project past that
+ * list is fetched, once per id. A record written by id (a rename) still wins.
+ */
+export const useProjectName = (projectId?: string | null): string | undefined => {
+ const queryClient = useQueryClient();
+ let listedName: string | undefined;
+ if (projectId) {
+ for (const [, data] of queryClient.getQueriesData>([
+ QueryKeys.projects,
+ ])) {
+ for (const page of data?.pages ?? []) {
+ listedName = page?.projects?.find((project) => project._id === projectId)?.name;
+ if (listedName != null) {
+ break;
+ }
+ }
+ if (listedName != null) {
+ break;
+ }
+ }
+ }
+ const { data: project } = useProjectQuery(projectId, { enabled: listedName == null });
+ return project?.name ?? listedName;
+};
export const useProjectFilesQuery = (
projectId?: string | null,
config?: UseQueryOptions,
diff --git a/client/src/data-provider/__tests__/projectName.spec.tsx b/client/src/data-provider/__tests__/projectName.spec.tsx
new file mode 100644
index 0000000000..39e7c4dc55
--- /dev/null
+++ b/client/src/data-provider/__tests__/projectName.spec.tsx
@@ -0,0 +1,80 @@
+import { QueryKeys, dataService } from 'librechat-data-provider';
+import { renderHook, waitFor, act } from '@testing-library/react';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+import type { ProjectListResponse, TChatProject } from 'librechat-data-provider';
+import type { InfiniteData } from '@tanstack/react-query';
+import type { ReactNode } from 'react';
+import { useProjectName } from '../Projects';
+
+jest.mock('librechat-data-provider', () => {
+ const actual = jest.requireActual('librechat-data-provider');
+ return {
+ ...actual,
+ dataService: { ...actual.dataService, getProjectById: jest.fn() },
+ };
+});
+
+const getProjectById = dataService.getProjectById as jest.MockedFunction<
+ typeof dataService.getProjectById
+>;
+
+const project = (id: string, name: string) =>
+ ({ _id: id, name, conversationCount: 1 }) as TChatProject;
+
+const renderName = (queryClient: QueryClient, projectId: string) =>
+ renderHook(() => useProjectName(projectId), {
+ wrapper: ({ children }: { children: ReactNode }) => (
+ {children}
+ ),
+ });
+
+const seedList = (queryClient: QueryClient, projects: TChatProject[]) =>
+ queryClient.setQueryData>(
+ [QueryKeys.projects, { sortBy: 'lastConversationAt', sortDirection: 'desc', limit: 25 }],
+ { pages: [{ projects, nextCursor: null } as ProjectListResponse], pageParams: [undefined] },
+ );
+
+describe('useProjectName', () => {
+ let queryClient: QueryClient;
+
+ beforeEach(() => {
+ jest.resetAllMocks();
+ queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+ });
+
+ afterEach(() => {
+ queryClient.clear();
+ });
+
+ /* Every project chat under Chats carries a badge; a request per project would turn the
+ list into a burst of reads the sidebar's own project list already answers. */
+ it('names a project the sidebar has listed without asking the server', () => {
+ seedList(queryClient, [project('p1', 'Scheduling'), project('p2', 'Subagents')]);
+ const { result } = renderName(queryClient, 'p2');
+
+ expect(result.current).toBe('Subagents');
+ expect(getProjectById).not.toHaveBeenCalled();
+ });
+
+ it('fetches a project past the listed ones', async () => {
+ seedList(queryClient, [project('p1', 'Scheduling')]);
+ getProjectById.mockResolvedValue(project('p9', 'Speed Chess'));
+ const { result } = renderName(queryClient, 'p9');
+
+ await waitFor(() => expect(result.current).toBe('Speed Chess'));
+ expect(getProjectById).toHaveBeenCalledTimes(1);
+ expect(getProjectById).toHaveBeenCalledWith('p9');
+ });
+
+ it('prefers a record written by id, such as a rename', async () => {
+ seedList(queryClient, [project('p1', 'Scheduling')]);
+ const { result } = renderName(queryClient, 'p1');
+
+ act(() => {
+ queryClient.setQueryData([QueryKeys.project, 'p1'], project('p1', 'Cron jobs'));
+ });
+
+ await waitFor(() => expect(result.current).toBe('Cron jobs'));
+ expect(getProjectById).not.toHaveBeenCalled();
+ });
+});
diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.json
index f2a690778d..ca5b75f9ce 100644
--- a/client/src/locales/en/translation.json
+++ b/client/src/locales/en/translation.json
@@ -152,7 +152,10 @@
"com_a11y_ai_composing": "The AI is still composing.",
"com_a11y_chats_date_section": "Chats from {{date}}",
"com_a11y_chats_alpha_section": "Chats with titles starting with {{letter}}",
- "com_a11y_chats_running_section": "Running chats",
+ "com_a11y_chats_running_section": "{{count}} running chats",
+ "com_a11y_chats_running_section_one": "1 running chat",
+ "com_a11y_chats_finished_section": "{{count}} finished chats with unread replies",
+ "com_a11y_chats_finished_section_one": "1 finished chat with an unread reply",
"com_a11y_end": "The AI has finished their reply.",
"com_a11y_selected": "selected",
"com_a11y_start": "The AI has started their reply.",
@@ -2394,6 +2397,7 @@
"com_ui_run_code_error": "There was an error running the code",
"com_ui_running": "Running...",
"com_ui_running_chats": "Running",
+ "com_ui_finished_chats": "Finished",
"com_ui_running_command": "Running command",
"com_ui_preparing_n_actions": "Preparing {{0}} actions",
"com_ui_preparing_one_action": "Preparing 1 action",
@@ -2604,6 +2608,7 @@
"com_ui_shared_link_bulk_delete_success": "Successfully deleted shared links",
"com_ui_shared_link_delete_success": "Successfully deleted shared link",
"com_ui_shared_only": "Shared only",
+ "com_ui_show_project_chats": "Show project chats",
"com_ui_shared_link_manage_access": "Manage Access",
"com_ui_shared_link_not_found": "Shared link not found",
"com_ui_shared_link_updated": "This shared link was updated. Reloading the latest version, then try again",
diff --git a/e2e/specs/mock/scenarios/chat-filter-menu.spec.ts b/e2e/specs/mock/scenarios/chat-filter-menu.spec.ts
index 2ce99aabaf..c9a9930af6 100644
--- a/e2e/specs/mock/scenarios/chat-filter-menu.spec.ts
+++ b/e2e/specs/mock/scenarios/chat-filter-menu.spec.ts
@@ -238,7 +238,7 @@ test.describe('chat list properties menu', () => {
await expect(trigger(page)).toHaveAttribute('aria-label', 'Filters active: 2');
});
- test('a project chat is listed under its project, not in Chats, and stays reachable from the archive @scenario:project-chat-listed-under-project-only', async ({
+ test('a project chat is listed in Chats with its folder and under its project, hides from Chats on request, and stays reachable from the archive @scenario:project-chat-listed-in-chats-and-project', async ({
page,
}) => {
const projectName = `Menu project ${randomUUID().slice(0, 8)}`;
@@ -255,7 +255,7 @@ test.describe('chat list properties menu', () => {
await showSidebar(page);
await expect(chatsRow(page, unassigned)).toBeVisible();
- await expect(chatsRow(page, inProject)).toHaveCount(0);
+ await expect(chatsRow(page, inProject).getByTestId('convo-project-badge')).toBeVisible();
const projectRow = page.getByRole('button', { name: projectName }).first();
if ((await projectRow.getAttribute('aria-expanded')) !== 'true') {
@@ -267,6 +267,13 @@ test.describe('chat list properties menu', () => {
}),
).toBeVisible();
+ await trigger(page).click();
+ await page.getByRole('menuitemcheckbox', { name: 'Show project chats' }).click();
+ await closeMenus(page);
+ await expect(chatsRow(page, inProject)).toHaveCount(0);
+ await expect(chatsRow(page, unassigned)).toBeVisible();
+ await expect(trigger(page)).toHaveAttribute('aria-label', 'Filters active: 1');
+
await trigger(page).click();
await page.getByTestId('chat-filter-show').click();
await page.getByRole('menuitemradio', { name: 'Archived chats' }).click();
diff --git a/packages/client/src/svgs/Spinner.tsx b/packages/client/src/svgs/Spinner.tsx
index 2a9db21da0..2d123e7ed8 100644
--- a/packages/client/src/svgs/Spinner.tsx
+++ b/packages/client/src/svgs/Spinner.tsx
@@ -8,6 +8,8 @@ interface SpinnerProps {
color?: string;
bgOpacity?: number;
speed?: number;
+ /** Stroke width in viewBox units (the box is 40 wide); thinner reads as a quieter ring. */
+ strokeWidth?: number;
}
/**
@@ -24,6 +26,7 @@ export default function Spinner({
color = 'currentColor',
bgOpacity = 0.1,
speed = 0.75,
+ strokeWidth = 5,
}: SpinnerProps): JSX.Element {
const cssVars = {
'--spinner-speed': `${speed}s`,
@@ -46,7 +49,7 @@ export default function Spinner({
cy="20"
r="14.5"
pathLength="100"
- strokeWidth="5"
+ strokeWidth={strokeWidth}
fill="none"
stroke={color}
strokeOpacity={bgOpacity}
@@ -56,7 +59,7 @@ export default function Spinner({
cy="20"
r="14.5"
pathLength="100"
- strokeWidth="5"
+ strokeWidth={strokeWidth}
fill="none"
stroke={color}
strokeDasharray="25 75"