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(im): 将 Discord 私聊归入对话分组 (#1739)

nanacoe4912caaf225
diff --git a/apps/desktop/src/main/im/discord/__tests__/discordAdapter.test.ts b/apps/desktop/src/main/im/discord/__tests__/discordAdapter.test.ts
index 8734f9cc9e..f0533a5191 100644
--- a/apps/desktop/src/main/im/discord/__tests__/discordAdapter.test.ts
+++ b/apps/desktop/src/main/im/discord/__tests__/discordAdapter.test.ts
@@ -45,6 +45,7 @@ describe('discord ImChannelAdapter characterization', () => {
it('channel / source are discord and the adapter is not thread scoped', () => {
expect(adapter.channel).toBe('discord');
expect(adapter.sessions.source).toBe('discord');
+ expect(adapter.sessions.workspaceKind).toBe('dialogue');
expect(adapter.threadScoped).toBeUndefined();
});
diff --git a/apps/desktop/src/main/im/discord/adapter.ts b/apps/desktop/src/main/im/discord/adapter.ts
index 75f33f4fdf..ea08fedc42 100644
--- a/apps/desktop/src/main/im/discord/adapter.ts
+++ b/apps/desktop/src/main/im/discord/adapter.ts
@@ -36,6 +36,10 @@ export function buildDiscordAdapter(
sessionIdFor: (appId, userId) => `discord_${appId}_${userId}`,
defaultTitle: (userId) => `Discord · ${userId.slice(-6)}`,
generatedTitlePrefix: 'Discord · ',
+ // Discord personal DMs use Cindy-managed working directories just like
+ // Feishu/Telegram DMs. Keep them in the global "dialogue" bucket instead
+ // of making `discord-{appId}` look like a user project.
+ workspaceKind: 'dialogue',
ensureWorkingDir,
extraInsertColumns: (appId, userId) => ({
imBotContextId: appId,
diff --git a/apps/desktop/src/main/im/index.ts b/apps/desktop/src/main/im/index.ts
index 0c434fa531..d643afb5ee 100644
--- a/apps/desktop/src/main/im/index.ts
+++ b/apps/desktop/src/main/im/index.ts
@@ -419,6 +419,20 @@ async function initializeImConnection(): Promise<void> {
const msg = err instanceof Error ? err.message : String(err);
log.warn(`feishu sessions workspaceKind backfill failed (non-fatal): ${msg}`);
}
+ // Discord personal DM sessions use the same managed dialogue bucket as
+ // Feishu/Telegram. Older Discord rows were created before the adapter
+ // declared workspaceKind='dialogue' and otherwise remain grouped under the
+ // synthetic `discord-{appId}` working directory. Idempotent and deliberately
+ // does not bump updatedAt, so the migration does not reorder the sidebar.
+ try {
+ await getDbClient()
+ .drizzle.update(sessions)
+ .set({ workspaceKind: 'dialogue' })
+ .where(and(eq(sessions.source, 'discord'), ne(sessions.workspaceKind, 'dialogue')));
+ } catch (err) {
+ const msg = err instanceof Error ? err.message : String(err);
+ log.warn(`discord sessions workspaceKind backfill failed (non-fatal): ${msg}`);
+ }
// 存量 feishu 会话的旧默认标题 `飞书 · {后6位}` 迁到新风格 `[飞书·DM] {后6位}`。
try {
await getDbClient()