({
attachment,
addMargin,
verbose,
isTranscriptMode
}: Props)
| 34 | isTranscriptMode?: boolean; |
| 35 | }; |
| 36 | export function AttachmentMessage({ |
| 37 | attachment, |
| 38 | addMargin, |
| 39 | verbose, |
| 40 | isTranscriptMode |
| 41 | }: Props): React.ReactNode { |
| 42 | const bg = useSelectedMessageBg(); |
| 43 | // Hoisted to mount-time — per-message component, re-renders on every scroll. |
| 44 | const isDemoEnv = feature('EXPERIMENTAL_SKILL_SEARCH') ? |
| 45 | // biome-ignore lint/correctness/useHookAtTopLevel: feature() is a compile-time constant |
| 46 | useMemo(() => isEnvTruthy(process.env.IS_DEMO), []) : false; |
| 47 | // Handle teammate_mailbox BEFORE switch |
| 48 | if (isAgentSwarmsEnabled() && attachment.type === 'teammate_mailbox') { |
| 49 | // Filter out idle notifications BEFORE counting - they are hidden in the UI |
| 50 | // so showing them in the count would be confusing ("2 messages in mailbox:" with nothing shown) |
| 51 | const visibleMessages = attachment.messages.filter(msg => { |
| 52 | if (isShutdownApproved(msg.text)) { |
| 53 | return false; |
| 54 | } |
| 55 | try { |
| 56 | const parsed = jsonParse(msg.text); |
| 57 | return parsed?.type !== 'idle_notification' && parsed?.type !== 'teammate_terminated'; |
| 58 | } catch { |
| 59 | return true; // Non-JSON messages are visible |
| 60 | } |
| 61 | }); |
| 62 | if (visibleMessages.length === 0) { |
| 63 | return null; |
| 64 | } |
| 65 | return <Box flexDirection="column"> |
| 66 | {visibleMessages.map((msg_0, idx) => { |
| 67 | // Try to parse as JSON for task_assignment messages |
| 68 | let parsedMsg: { |
| 69 | type?: string; |
| 70 | taskId?: string; |
| 71 | subject?: string; |
| 72 | assignedBy?: string; |
| 73 | } | null = null; |
| 74 | try { |
| 75 | parsedMsg = jsonParse(msg_0.text); |
| 76 | } catch { |
| 77 | // Not JSON, treat as plain text |
| 78 | } |
| 79 | if (parsedMsg?.type === 'task_assignment') { |
| 80 | return <Box key={idx} paddingLeft={2}> |
| 81 | <Text>{BLACK_CIRCLE} </Text> |
| 82 | <Text>Task assigned: </Text> |
| 83 | <Text bold>#{parsedMsg.taskId}</Text> |
| 84 | <Text> - {parsedMsg.subject}</Text> |
| 85 | <Text dimColor> (from {parsedMsg.assignedBy || msg_0.from})</Text> |
| 86 | </Box>; |
| 87 | } |
| 88 | |
| 89 | // Note: idle_notification messages already filtered out above |
| 90 | |
| 91 | // Try to render as plan approval message (request or response) |
| 92 | const planApprovalElement = tryRenderPlanApprovalMessage(msg_0.text, msg_0.from); |
| 93 | if (planApprovalElement) { |
nothing calls this directly
no test coverage detected