Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 项目搜索的大小写折叠不受系统区域影响

zqchris540aabde7d61
diff --git a/apps/desktop/src/renderer/components/new-chat/FolderPickerPopover.tsx b/apps/desktop/src/renderer/components/new-chat/FolderPickerPopover.tsx
index 14808070e3..7ee9e2ddf0 100644
--- a/apps/desktop/src/renderer/components/new-chat/FolderPickerPopover.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/FolderPickerPopover.tsx
@@ -71,11 +71,11 @@ export function filterFolderPickerOptions(
options: readonly FolderPickerOption[],
query: string,
): readonly FolderPickerOption[] {
- const needle = query.trim().toLocaleLowerCase();
+ const needle = query.trim().toLowerCase();
if (!needle) return options;
return options.filter((option) =>
[option.name, option.description, option.path].some((field) =>
- field?.toLocaleLowerCase().includes(needle),
+ field?.toLowerCase().includes(needle),
),
);
}
diff --git a/apps/desktop/src/renderer/components/new-chat/__tests__/FolderPickerPopoverSearch.test.tsx b/apps/desktop/src/renderer/components/new-chat/__tests__/FolderPickerPopoverSearch.test.tsx
index e37950508d..15daff621d 100644
--- a/apps/desktop/src/renderer/components/new-chat/__tests__/FolderPickerPopoverSearch.test.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/__tests__/FolderPickerPopoverSearch.test.tsx
@@ -58,6 +58,22 @@ describe('filterFolderPickerOptions', () => {
]);
expect(filterFolderPickerOptions(manyProjects, '')).toBe(manyProjects);
});
+
+ it('folds case the same way regardless of the system locale', () => {
+ // 模拟土耳其语区域:按区域折叠时 I → ı,ASCII 项目名会搜不到。
+ const turkish = vi.spyOn(String.prototype, 'toLocaleLowerCase').mockImplementation(function (
+ this: string,
+ ) {
+ return this.replace(/I/g, 'ı').toLowerCase();
+ });
+ try {
+ expect(filterFolderPickerOptions([project('INVOICE')], 'invoice').map((p) => p.name)).toEqual(
+ ['INVOICE'],
+ );
+ } finally {
+ turkish.mockRestore();
+ }
+ });
});
describe('FolderPickerPopover project search', () => {