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): 重启确认不再误报插件动作,并限制伙伴姓名

shenjiacheng537e0cb12391
diff --git a/apps/desktop/src/main/__tests__/relaunchBusyActivityIpcBoundary.test.ts b/apps/desktop/src/main/__tests__/relaunchBusyActivityIpcBoundary.test.ts
index e62124fa92..09863f66c7 100644
--- a/apps/desktop/src/main/__tests__/relaunchBusyActivityIpcBoundary.test.ts
+++ b/apps/desktop/src/main/__tests__/relaunchBusyActivityIpcBoundary.test.ts
@@ -226,7 +226,7 @@ describe('relaunch blocking summary', () => {
anyCindySlotJobRunning: () => true,
anyPiSubagentRunning: () => true,
listClaudeBackgroundSessions: () => ['claude-session'],
- anyGhostSessionBusy: () => true,
+ anyGhostSessionBusy: () => false,
}), {
describeTurns: async () => {
h.turnReads += 1;
@@ -254,6 +254,37 @@ describe('relaunch blocking summary', () => {
expect(JSON.stringify(h.log.info.mock.calls)).not.toContain('Cindy');
});
+
+ it('does not call an unspecified plugin action a generation', async () => {
+ registerRelaunchBusyActivityIpc(sources({
+ anyGhostSessionBusy: () => true,
+ anyBackgroundBashRunning: () => true,
+ }));
+ const handler = h.handlers.get(RELAUNCH_BLOCKING_SUMMARY_CHANNEL)!;
+ await expect(handler(fakeEvent)).resolves.toEqual({
+ busy: true,
+ categories: [],
+ companionNames: [],
+ });
+ const booleanHandler = h.handlers.get(RELAUNCH_BLOCKING_ACTIVITY_CHANNEL)!;
+ await expect(booleanHandler(fakeEvent)).resolves.toBe(true);
+ });
+
+ it('drops teammate names once listing them would hide the restart choice', async () => {
+ registerRelaunchBusyActivityIpc(sources({ anySessionInTurn: () => true }), {
+ describeTurns: async () => ({
+ companions: [{ name: 'Ada' }, { name: 'Bea' }, { name: 'Cleo' }, { name: 'Dora' }],
+ conversation: false,
+ }),
+ });
+ const handler = h.handlers.get(RELAUNCH_BLOCKING_SUMMARY_CHANNEL)!;
+ await expect(handler(fakeEvent)).resolves.toEqual({
+ busy: true,
+ categories: ['companion'],
+ companionNames: [],
+ });
+ });
+
it('reports a scheduled run when that is the activity', async () => {
registerRelaunchBusyActivityIpc(sources({
anySchedulerRunRunning: async () => true,
diff --git a/apps/desktop/src/renderer/__tests__/updateBannerRelaunchEntry.test.tsx b/apps/desktop/src/renderer/__tests__/updateBannerRelaunchEntry.test.tsx
index cf9f4affd9..f1457f7043 100644
--- a/apps/desktop/src/renderer/__tests__/updateBannerRelaunchEntry.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/updateBannerRelaunchEntry.test.tsx
@@ -569,6 +569,10 @@ describe('formatRelaunchActivityHint builds a complete sentence', () => {
categories: ['companion', 'conversation', 'background-command'],
companionNames: [],
})).toBe("Restarting will interrupt a teammate's reply, a chat in progress, and a background command.");
+ expect(formatRelaunchActivityHint(t, {
+ categories: ['companion'],
+ companionNames: ['Ada', 'Bea', 'Cleo', 'Dora'],
+ })).toBe("Restarting will interrupt a teammate's reply.");
});
it('says in Japanese that the restart will interrupt the activity', () => {
diff --git a/apps/desktop/src/shared/relaunchActivitySummary.ts b/apps/desktop/src/shared/relaunchActivitySummary.ts
index a5ff40bcf5..f552148cd0 100644
--- a/apps/desktop/src/shared/relaunchActivitySummary.ts
+++ b/apps/desktop/src/shared/relaunchActivitySummary.ts
@@ -19,7 +19,7 @@ export type RelaunchActivityCategory = (typeof RELAUNCH_ACTIVITY_CATEGORIES)[num
const REASON_CATEGORY: Record<string, RelaunchActivityCategory> = {
'background-bash': 'background-command',
'scheduler-run-running': 'scheduled-task',
- 'ghost-background-activity': 'generation',
+ // 插件后台活动也覆盖发邮件、取消等非生成动作,分不清时不能写成生成任务。
'cindy-slot-async-job': 'generation',
'pi-subagent': 'subtask',
'claude-background-activity': 'subtask',
@@ -41,6 +41,8 @@ export interface RelaunchActivitySummary {
}
const MAX_COMPANION_NAME_LENGTH = 40;
+/** 侧栏确认没有独立滚动区。再多就只说伙伴类别,避免姓名把按钮挤出窗口。 */
+const MAX_LISTED_COMPANION_NAMES = 3;
const COMPANION_NAME_PATTERN = /^[\p{L}\p{N}][\p{L}\p{N} ._'’-]{0,39}$/u;
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -81,7 +83,8 @@ export function summarizeRelaunchActivity(
}
if (turns.companions.length > 0) found.add('companion');
if (turns.conversation) found.add('conversation');
- const unnamed = turns.companions.some((companion) => safeCompanionDisplayName(companion.name) == null);
+ const unnamed = turns.companions.length > MAX_LISTED_COMPANION_NAMES
+ || turns.companions.some((companion) => safeCompanionDisplayName(companion.name) == null);
companionNames = unnamed
? []
: turns.companions.flatMap((companion) => {
@@ -170,7 +173,9 @@ export function classifyRelaunchTurnRows(
}
conversation = true;
}
- if (unnamedCompanion) return { companions: [{ name: null }], conversation };
+ if (unnamedCompanion || named.length > MAX_LISTED_COMPANION_NAMES) {
+ return { companions: [{ name: null }], conversation };
+ }
return { companions: named, conversation };
}
@@ -203,7 +208,8 @@ export function formatRelaunchActivityHint(
): string | null {
if (!summary || summary.categories.length === 0) return null;
const parts = summary.categories.map((category) => {
- if (category !== 'companion' || summary.companionNames.length === 0) {
+ if (category !== 'companion' || summary.companionNames.length === 0
+ || summary.companionNames.length > MAX_LISTED_COMPANION_NAMES) {
return translate(CATEGORY_KEYS[category]);
}
const names = joinLocalized(summary.companionNames, (key) => translate(key), {
@@ -242,7 +248,7 @@ export function normalizeRelaunchActivitySummary(value: unknown): {
if (!safe) return { busy: record.busy, categories, companionNames: [] };
if (!companionNames.includes(safe)) companionNames.push(safe);
}
- if (!categories.includes('companion')) {
+ if (!categories.includes('companion') || companionNames.length > MAX_LISTED_COMPANION_NAMES) {
return { busy: record.busy, categories, companionNames: [] };
}
return { busy: record.busy, categories, companionNames };