fix(chat): allow all files in attachment picker

This commit is contained in:
mesalogo
2026-10-12 14:25:39 +08:00
parent 6694aa141e
commit 4edc34c625
3 changed files with 4 additions and 40 deletions
@@ -14,7 +14,7 @@ Main。IPC 先验证可信 sender,再使用共享 `contextImportFilesSchema`
没有本地路径的截图沿用 `context.addPastedImage`;无路径的非图片文件和混有无路径项目
的本地文件批次显示可处理的错误,不静默丢弃项目。
`ContextManager.selectFiles` 只负责文件对话框,再调用与粘贴共用的 `importFiles`。
`ContextManager.selectFiles` 打开不按文件类型过滤的多选文件对话框,再调用与粘贴共用的 `importFiles`。
这个方法完成路径规范化、格式及大小检查、文本读取、图片转换、文档解析与上下文暂存。
任一文件失败时删除本批次已经暂存的项目,保留之前的附件。文件系统错误不向 Renderer
暴露绝对路径。
+2 -18
View File
@@ -514,11 +514,7 @@ describe('ContextManager', () => {
})
expect(showOpenDialog).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
filters: expect.arrayContaining([
expect.objectContaining({ name: '图片' })
])
})
{ properties: ['openFile', 'multiSelections'] }
)
})
@@ -555,19 +551,7 @@ describe('ContextManager', () => {
})
expect(showOpenDialog).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
filters: expect.arrayContaining([
expect.objectContaining({
name: 'PDF 和 Office 文档',
extensions: expect.arrayContaining([
'docx',
'pdf',
'pptx',
'xlsx'
])
})
])
})
{ properties: ['openFile', 'multiSelections'] }
)
expect(onProgress.mock.calls.map(([progress]) => { const { operationId, ...rest } = progress; expect(operationId).toEqual(expect.any(String)); return rest })).toEqual([
{
+1 -21
View File
@@ -329,27 +329,7 @@ export class ContextManager {
conversationId?: string
): Promise<ContextAttachment[]> {
const result = await dialog.showOpenDialog(window, {
properties: ['openFile', 'multiSelections'],
filters: [
{
name: '文本、代码和配置文件',
extensions: [...supportedExtensions].map((extension) =>
extension.slice(1)
)
},
{
name: '图片',
extensions: [...supportedImageExtensions].map((extension) =>
extension.slice(1)
)
},
{
name: 'PDF 和 Office 文档',
extensions: [...supportedDocumentExtensions].map((extension) =>
extension.slice(1)
)
}
]
properties: ['openFile', 'multiSelections']
})
if (result.canceled) {
return []