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(bot-group): require a running current step in sidebar

ethereal493d73e88a4a1d
diff --git a/packages/maker-shared/src/__tests__/botGroupPresentation.test.ts b/packages/maker-shared/src/__tests__/botGroupPresentation.test.ts
index 369b205c93..10def62854 100644
--- a/packages/maker-shared/src/__tests__/botGroupPresentation.test.ts
+++ b/packages/maker-shared/src/__tests__/botGroupPresentation.test.ts
@@ -9,10 +9,11 @@ import {
mergeBotGroupMessages,
projectBotGroupExecutionFailures,
botGroupExecutionFailureBatches,
+ botGroupSidebarPlanPreview,
chatGroupMembership,
botGroupNewMessageCount,
} from '../botGroupPresentation.js';
-import { chatGroupTalkRouteKey, groupLaneOfRouteKey, isChatOnlyGroupLane, BOT_GROUP_RUNTIME_FAILURE_CODES, readBotGroupExecutionFailure, type BotGroupErrorCode, type BotGroupExecutionFailureView, type BotGroupMemberView, type BotGroupMessageView, type BotGroupNoticeCode, type BotGroupPlanView } from '../botGroupChat.js';
+import { chatGroupTalkRouteKey, groupLaneOfRouteKey, isChatOnlyGroupLane, BOT_GROUP_RUNTIME_FAILURE_CODES, readBotGroupExecutionFailure, type BotGroupErrorCode, type BotGroupExecutionFailureView, type BotGroupMemberView, type BotGroupMessageView, type BotGroupNoticeCode, type BotGroupOpenPlanSummary, type BotGroupPlanStepStatus, type BotGroupPlanView, type BotGroupSummary } from '../botGroupChat.js';
// Unit: history browsing needs an actionable count; old-page loads and repeated pushes are not arrivals.
it('counts only new messages from other people and companions below the observed tail', () => {
@@ -104,8 +105,8 @@ describe('public failure snapshot decoder', () => {
code, planId: 'plan', updatedAt: Date.parse(row.updated_at) });
expect(JSON.stringify(view)).not.toContain(row.detail);
});
- it.each([{ status: 'running' }, { conversation_id: 'foreign' }, { epoch: NaN }, { epoch: -1 }, { source_message_id: null }])
- ('rejects inapplicable or malformed execution rows: %j', invalid => {
+ it.each([{ status: 'running' }, { conversation_id: 'foreign' }, { epoch: NaN }, { epoch: -1 }, { source_message_id: null }])(
+ 'rejects inapplicable or malformed execution rows: %j', invalid => {
expect(readBotGroupExecutionFailure({ ...row, ...invalid }, 'room')).toBeNull();
});
it('uses a fixed fallback for unknown categories and drops invalid timestamps', () => {
@@ -124,6 +125,37 @@ const plan = (overrides: Partial<BotGroupPlanView> = {}): BotGroupPlanView => ({
...overrides,
});
+// Test value
+// - Production entry and observable result: botGroupSidebarPlanPreview() chooses the running
+// sidebar strip, a terminal step label, or the latest-message fallback.
+// - Bug / rule basis: #7084; the plan-level running status must not outlive its current step.
+// - Existing coverage gap: composer and follow-up tests exist, but no sidebar preview branch did.
+// - Minimal failing input: a running open plan whose current step is no longer running; unit tier.
+describe('sidebar plan activity follows the current step', () => {
+ const summary = (
+ status: BotGroupOpenPlanSummary['status'],
+ currentStepStatus: BotGroupPlanStepStatus | null,
+ ): BotGroupSummary => ({
+ members: [{ botId: 'a', name: 'A' }],
+ planningBotId: null,
+ organizerBotId: 'a',
+ openPlan: {
+ id: 'p1', status, currentStep: 0, stepCount: 2, currentBotName: 'A', currentStepStatus,
+ },
+ } as BotGroupSummary);
+
+ it.each([
+ ['running', 'running', { kind: 'running', botName: 'A', step: 1, total: 2 }],
+ ['running', 'done', { kind: 'step-done', botName: 'A' }],
+ ['running', 'failed', { kind: 'step-failed', botName: 'A' }],
+ ['running', 'pending', null],
+ ['waiting', 'done', { kind: 'step-done', botName: 'A' }],
+ ['waiting', 'failed', { kind: 'step-failed', botName: 'A' }],
+ ] as const)('maps plan %s with %s current step', (status, currentStepStatus, expected) => {
+ expect(botGroupSidebarPlanPreview(summary(status, currentStepStatus))).toEqual(expected);
+ });
+});
+
describe('bot group copy variants (shared by desktop and phone)', () => {
it('speaks about a step for member notices inside a plan', () => {
expect(botGroupNoticeVariant('member-joined', false)).toBe('memberJoined');
diff --git a/packages/maker-shared/src/botGroupPresentation.ts b/packages/maker-shared/src/botGroupPresentation.ts
index f5abb1e34c..c2ac7400b7 100644
--- a/packages/maker-shared/src/botGroupPresentation.ts
+++ b/packages/maker-shared/src/botGroupPresentation.ts
@@ -341,7 +341,7 @@ export function botGroupSidebarPlanPreview(group: BotGroupSummary): BotGroupSide
const plan = group.openPlan;
if (!plan) return null;
const botName = plan.currentBotName?.trim() ?? '';
- if (plan.status === 'running') {
+ if (plan.status === 'running' && plan.currentStepStatus === 'running') {
return {
kind: 'running',
botName,
@@ -350,10 +350,10 @@ export function botGroupSidebarPlanPreview(group: BotGroupSummary): BotGroupSide
};
}
if (plan.status === 'proposed') return { kind: 'proposed', organizerName: memberName(group.organizerBotId) };
- if (plan.status === 'waiting') {
+ if (plan.status === 'waiting' || plan.status === 'running') {
if (botName && plan.currentStepStatus === 'done') return { kind: 'step-done', botName };
if (botName && plan.currentStepStatus === 'failed') return { kind: 'step-failed', botName };
- return { kind: 'waiting' };
+ if (plan.status === 'waiting') return { kind: 'waiting' };
}
return null;
}