MCPcopy Create free account
hub / github.com/WJX20/claude-code / getQueuedCommandAttachments

Function getQueuedCommandAttachments

src/utils/attachments.ts:1047–1084  ·  view source on GitHub ↗
(
  queuedCommands: QueuedCommand[],
)

Source from the content-addressed store, hash-verified

1045const INLINE_NOTIFICATION_MODES = new Set(['prompt', 'task-notification'])
1046
1047export async function getQueuedCommandAttachments(
1048 queuedCommands: QueuedCommand[],
1049): Promise<Attachment[]> {
1050 if (!queuedCommands) {
1051 return []
1052 }
1053 // Include both 'prompt' and 'task-notification' commands as attachments.
1054 // During proactive agentic loops, task-notification commands would otherwise
1055 // stay in the queue permanently (useQueueProcessor can't run while a query
1056 // is active), causing hasPendingNotifications() to return true and Sleep to
1057 // wake immediately with 0ms duration in an infinite loop.
1058 const filtered = queuedCommands.filter(_ =>
1059 INLINE_NOTIFICATION_MODES.has(_.mode),
1060 )
1061 return Promise.all(
1062 filtered.map(async _ => {
1063 const imageBlocks = await buildImageContentBlocks(_.pastedContents)
1064 let prompt: string | Array<ContentBlockParam> = _.value
1065 if (imageBlocks.length > 0) {
1066 // Build content block array with text + images so the model sees them
1067 const textValue =
1068 typeof _.value === 'string'
1069 ? _.value
1070 : extractTextContent(_.value, '\n')
1071 prompt = [{ type: 'text' as const, text: textValue }, ...imageBlocks]
1072 }
1073 return {
1074 type: 'queued_command' as const,
1075 prompt,
1076 source_uuid: _.uuid,
1077 imagePasteIds: getImagePasteIds(_.pastedContents),
1078 commandMode: _.mode,
1079 origin: _.origin,
1080 isMeta: _.isMeta,
1081 }
1082 }),
1083 )
1084}
1085
1086export function getAgentPendingMessageAttachments(
1087 toolUseContext: ToolUseContext,

Callers 2

getAttachmentsFunction · 0.85
REPLFunction · 0.85

Calls 4

buildImageContentBlocksFunction · 0.85
extractTextContentFunction · 0.85
getImagePasteIdsFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected