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(sessions): show basename for Windows attachments

Zhao Dengfeng83ecbbb543cd
diff --git a/packages/maker-shared/src/__tests__/sessionList.test.ts b/packages/maker-shared/src/__tests__/sessionList.test.ts
index b4ba98ca6a..d221df9b16 100644
--- a/packages/maker-shared/src/__tests__/sessionList.test.ts
+++ b/packages/maker-shared/src/__tests__/sessionList.test.ts
@@ -873,6 +873,16 @@ describe('sessionList', () => {
expect(sections[0].data[0].messagePreview).not.toContain('{');
});
+ it('shows only the basename for Windows attachment paths in session previews', () => {
+ const messagePreviewIndex = buildSessionMessagePreviewIndex(['windows-file'], () => [
+ message('windows-file', 'm1', 'user', {
+ files: [{ path: 'C:\\work\\report.pdf' }],
+ }, '2026-01-01T00:01:00.000Z'),
+ ]);
+
+ expect(messagePreviewIndex.get('windows-file')).toBe('附件 report.pdf');
+ });
+
it('never leaks hidden synthetic trigger prompts into session previews', () => {
// 桌面「失败后继续」的隐藏续跑 prompt(带 [UI_ACTION_TRIGGER] 前缀)常是会话
// 最后一条 user 行:预览必须回落到上一条可见消息,而不是把裸英文指令亮出来。
diff --git a/packages/maker-shared/src/sessionList.ts b/packages/maker-shared/src/sessionList.ts
index b54829b5b4..4a557c94e3 100644
--- a/packages/maker-shared/src/sessionList.ts
+++ b/packages/maker-shared/src/sessionList.ts
@@ -1148,7 +1148,7 @@ function contentRefName(value: unknown): string | null {
const record = value as Record<string, unknown>;
for (const key of ['name', 'originalName', 'fileName', 'path', 'url']) {
const item = record[key];
- if (typeof item === 'string' && item.trim()) return item.trim().split('/').pop() ?? item.trim();
+ if (typeof item === 'string' && item.trim()) return item.trim().split(/[\\/]/).pop() ?? item.trim();
}
return null;
}