feat: enhance team provisioning and message preview handling
- Updated TeamProvisioningService to include subagent type in spawn messages for clarity. - Improved member registration checks to account for suffixed names, enhancing error handling. - Refactored SubagentRecentMessagesPreview to strip agent-only blocks from messages, improving display clarity. - Adjusted tests to reflect changes in message formatting and member provisioning logic.
This commit is contained in:
parent
cba10b8ad4
commit
6798c4b9e7
3 changed files with 27 additions and 8 deletions
|
|
@ -35,7 +35,7 @@ import { isLeadAgentType, isLeadMember } from '@shared/utils/leadDetection';
|
|||
import { createLogger } from '@shared/utils/logger';
|
||||
import { formatTaskDisplayLabel } from '@shared/utils/taskIdentity';
|
||||
import { parseAllTeammateMessages } from '@shared/utils/teammateMessageParser';
|
||||
import { createCliAutoSuffixNameGuard } from '@shared/utils/teamMemberName';
|
||||
import { createCliAutoSuffixNameGuard, parseNumericSuffixName } from '@shared/utils/teamMemberName';
|
||||
import { extractToolPreview, formatToolSummaryFromCalls } from '@shared/utils/toolSummary';
|
||||
import * as agentTeamsControllerModule from 'agent-teams-controller';
|
||||
import { spawn, type ChildProcess } from 'child_process';
|
||||
|
|
@ -597,7 +597,7 @@ export function buildAddMemberSpawnMessage(
|
|||
if (!isMemberBriefingBootstrapEnabled()) {
|
||||
return (
|
||||
`A new teammate "${member.name}"${roleHint} has been added to the team. ` +
|
||||
`Please spawn them immediately using the Task tool with team_name="${teamName}" and name="${member.name}".${workflowHint}`
|
||||
`Please spawn them immediately using the Task tool with team_name="${teamName}", name="${member.name}", and subagent_type="general-purpose".${workflowHint}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -4247,11 +4247,17 @@ export class TeamProvisioningService {
|
|||
|
||||
// Flag any expected member not found in config.json (excluding the lead)
|
||||
for (const expected of run.expectedMembers) {
|
||||
// Check exact name or CLI-suffixed variant (e.g., "alice-2" for "alice")
|
||||
if (registeredNames.has(expected)) continue;
|
||||
const hasSuffixed = [...registeredNames].some((name) => {
|
||||
const parsed = parseNumericSuffixName(name);
|
||||
return parsed !== null && parsed.suffix >= 2 && parsed.base === expected;
|
||||
});
|
||||
if (hasSuffixed) continue;
|
||||
|
||||
// Skip if already in a terminal status (e.g., previously set 'error')
|
||||
// Skip if already in a terminal or positive status
|
||||
const current = run.memberSpawnStatuses.get(expected);
|
||||
if (current?.status === 'error') continue;
|
||||
if (current?.status === 'error' || current?.status === 'online') continue;
|
||||
|
||||
logger.warn(
|
||||
`[${run.teamName}] Member "${expected}" not found in config.json members after provisioning`
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { useState } from 'react';
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
import { MarkdownViewer } from '@renderer/components/chat/viewers/MarkdownViewer';
|
||||
import { displayMemberName } from '@renderer/utils/memberHelpers';
|
||||
import { stripAgentBlocks } from '@shared/constants/agentBlocks';
|
||||
import { format } from 'date-fns';
|
||||
import { ChevronDown, ChevronUp } from 'lucide-react';
|
||||
|
||||
|
|
@ -39,7 +40,19 @@ export const SubagentRecentMessagesPreview = ({
|
|||
}: SubagentRecentMessagesPreviewProps): React.JSX.Element | null => {
|
||||
const [expandedAll, setExpandedAll] = useState(false);
|
||||
|
||||
if (!messages.length) return null;
|
||||
// Strip agent-only blocks from message content before display
|
||||
const cleanMessages = useMemo(
|
||||
() =>
|
||||
messages
|
||||
.map((m) => {
|
||||
const cleaned = stripAgentBlocks(m.content);
|
||||
return cleaned !== m.content ? { ...m, content: cleaned } : m;
|
||||
})
|
||||
.filter((m) => m.content.trim().length > 0),
|
||||
[messages]
|
||||
);
|
||||
|
||||
if (!cleanMessages.length) return null;
|
||||
|
||||
return (
|
||||
<div className="mb-3 rounded-md border border-[var(--color-border)] bg-[var(--color-surface)] p-2">
|
||||
|
|
@ -50,7 +63,7 @@ export const SubagentRecentMessagesPreview = ({
|
|||
</div>
|
||||
|
||||
<div className={`${expandedAll ? 'max-h-none' : 'max-h-[200px]'} overflow-y-auto pr-1`}>
|
||||
{messages.map((m, index) => (
|
||||
{cleanMessages.map((m, index) => (
|
||||
<div
|
||||
key={m.id}
|
||||
className="rounded px-2 py-1.5"
|
||||
|
|
|
|||
|
|
@ -547,7 +547,7 @@ describe('ipc teams handlers', () => {
|
|||
expect(result.success).toBe(true);
|
||||
expect(provisioningService.sendMessageToTeam).toHaveBeenCalledWith(
|
||||
'my-team',
|
||||
expect.stringContaining('Please spawn them immediately using the Task tool with team_name="my-team" and name="alice".')
|
||||
expect.stringContaining('Please spawn them immediately using the Task tool with team_name="my-team", name="alice", and subagent_type="general-purpose".')
|
||||
);
|
||||
expect(provisioningService.sendMessageToTeam).not.toHaveBeenCalledWith(
|
||||
'my-team',
|
||||
|
|
|
|||
Loading…
Reference in a new issue