🗂️ fix: Keep Project Chats Out of Chats by Default and Space Project Rows (#16755)

* fix: Keep Project Chats Out of Chats by Default and Space Project Rows

* test: Update Chat Filter Menu Scenario for Project Chats Off by Default
This commit is contained in:
Marco Beretta 2026-10-05 00:54:09 +02:00 • committed by GitHub
parent 6301b90bf9
commit 4e55d64ceb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 38 additions and 38 deletions

View file

@ -370,12 +370,14 @@ const ProjectItem = memo(
</div>
</div>
<Collapse open={expanded} className="pl-2">
<ProjectChatsInline
projectId={project._id}
expanded={expanded}
toggleNav={toggleNav}
onShowAll={openProject}
/>
<div className="pt-1">
<ProjectChatsInline
projectId={project._id}
expanded={expanded}
toggleNav={toggleNav}
onShowAll={openProject}
/>
</div>
</Collapse>
<ProjectEditDialog
open={isEditOpen}

View file

@ -33,17 +33,17 @@ describe('showProjectChatsAtom', () => {
localStorage.clear();
});
it('lists project chats under Chats by default', () => {
expect(createStore().get(showProjectChatsAtom)).toBe(true);
it('keeps project chats out of Chats by default', () => {
expect(createStore().get(showProjectChatsAtom)).toBe(false);
});
it('counts hiding them as one change the menu badge and Reset own', () => {
it('counts listing them as one change the menu badge and Reset own', () => {
const store = createStore();
store.set(showProjectChatsAtom, false);
store.set(showProjectChatsAtom, true);
expect(store.get(chatFilterCountAtom)).toBe(1);
store.set(resetChatFiltersAtom);
expect(store.get(showProjectChatsAtom)).toBe(true);
expect(store.get(showProjectChatsAtom)).toBe(false);
expect(store.get(chatFilterCountAtom)).toBe(0);
});
@ -59,12 +59,12 @@ describe('showProjectChatsAtom', () => {
return value as boolean;
};
it('keeps the choice to hide them across visits', () => {
expect(onNextVisit(false)).toBe(false);
it('keeps the choice to list them across visits', () => {
expect(onNextVisit(true)).toBe(true);
});
it('reads a stored value that is not a boolean as the default', () => {
expect(onNextVisit('no')).toBe(true);
expect(onNextVisit('yes')).toBe(false);
});
});

View file

@ -66,13 +66,13 @@ export const chatSortAtom = atom(
},
);
const storedShowProjectChatsAtom = createStorageAtom<boolean>('chatListShowProjectChats', true);
const storedShowProjectChatsAtom = createStorageAtom<boolean>('chatListShowProjectChats', false);
/** 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. */
/** Whether chats filed in a project also list under Chats. Off by default, so a chat is
* shown once, under its project. A display preference, so it is kept like the sort;
* anything but an explicit `true` reads as the default. */
export const showProjectChatsAtom = atom(
(get) => get(storedShowProjectChatsAtom) !== false,
(get) => get(storedShowProjectChatsAtom) === true,
(_get, set, next: boolean) => {
set(storedShowProjectChatsAtom, next);
},
@ -93,7 +93,7 @@ export const chatFilterCountAtom = atom((get) => {
if (sort.field !== DEFAULT_CHAT_SORT.field || sort.direction !== DEFAULT_CHAT_SORT.direction) {
count += 1;
}
if (!get(showProjectChatsAtom)) {
if (get(showProjectChatsAtom)) {
count += 1;
}
return count;
@ -103,7 +103,7 @@ export const resetChatFiltersAtom = atom(null, (_get, set) => {
set(chatFilterStatusAtom, 'active');
set(chatFilterTagsAtom, []);
set(storedChatSortAtom, DEFAULT_CHAT_SORT);
set(storedShowProjectChatsAtom, true);
set(storedShowProjectChatsAtom, false);
});
/**

View file

@ -70,9 +70,9 @@ 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;
/** 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
/** By default each project chat shows only under its project. Turning the preference on
* lists it under Chats too, badged with its folder, for users who look for recent work
* there first. 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. */

View file

@ -310,32 +310,30 @@ describe('ConversationsSection project chats', () => {
});
afterEach(() => {
act(() => getDefaultStore().set(showProjectChatsAtom, true));
act(() => getDefaultStore().set(showProjectChatsAtom, false));
});
/** 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 () => {
/** A project chat is shown only under its project, not twice, unless the user opts in. */
it('asks only for chats that belong to no project by default', async () => {
renderSection();
await settleRenders();
expect(mockListParams).toHaveBeenCalled();
expect(mockListParams.mock.calls.at(-1)?.[0]).toMatchObject({ projectId: undefined });
expect(mockListParams.mock.calls.at(-1)?.[0]).toMatchObject({ projectId: 'unassigned' });
});
/** 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));
/** Turned on, a chat filed in a project is listed under Chats too, with its folder badge. */
it('lists project chats under Chats once they are shown', async () => {
act(() => getDefaultStore().set(showProjectChatsAtom, true));
renderSection();
await settleRenders();
expect(mockListParams.mock.calls.at(-1)?.[0]).toMatchObject({ projectId: 'unassigned' });
expect(mockListParams.mock.calls.at(-1)?.[0]).toMatchObject({ projectId: undefined });
});
/** 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<SearchState>;
function SearchController() {
@ -388,7 +386,7 @@ describe('ConversationsSection empty Chats wording', () => {
});
afterEach(() => {
act(() => getDefaultStore().set(showProjectChatsAtom, true));
act(() => getDefaultStore().set(showProjectChatsAtom, false));
});
it('calls the account empty only once its projects have loaded and there are none', async () => {

View file

@ -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 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 ({
test('a project chat is left to its project by default, is listed in Chats with its folder 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).getByTestId('convo-project-badge')).toBeVisible();
await expect(chatsRow(page, inProject)).toHaveCount(0);
const projectRow = page.getByRole('button', { name: projectName }).first();
if ((await projectRow.getAttribute('aria-expanded')) !== 'true') {
@ -270,7 +270,7 @@ test.describe('chat list properties menu', () => {
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, inProject).getByTestId('convo-project-badge')).toBeVisible();
await expect(chatsRow(page, unassigned)).toBeVisible();
await expect(trigger(page)).toHaveAttribute('aria-label', 'Filters active: 1');