MCPcopy Index your code
hub / github.com/21st-dev/1code / processQueue

Function processQueue

src/renderer/features/agents/components/queue-processor.tsx:37–185  ·  view source on GitHub ↗
(subChatId: string)

Source from the content-addressed store, hash-verified

35 useEffect(() => {
36 // Function to process queue for a specific sub-chat
37 const processQueue = async (subChatId: string) => {
38 // Check if already processing this sub-chat
39 if (processingRef.current.has(subChatId)) {
40 return
41 }
42
43 // Check streaming status
44 const status = useStreamingStatusStore.getState().getStatus(subChatId)
45 if (status !== "ready") {
46 return
47 }
48
49 // Get queue for this sub-chat
50 const queue = useMessageQueueStore.getState().queues[subChatId] || []
51 if (queue.length === 0) {
52 return
53 }
54
55 // Get the Chat object from agentChatStore
56 const chat = agentChatStore.get(subChatId)
57 if (!chat) {
58 return
59 }
60
61 // Mark as processing
62 processingRef.current.add(subChatId)
63
64 // Pop the first item from queue (atomic operation)
65 const item = useMessageQueueStore.getState().popItem(subChatId, queue[0].id)
66 if (!item) {
67 processingRef.current.delete(subChatId)
68 return
69 }
70
71 try {
72 // Build message parts from queued item
73 const parts: any[] = [
74 ...(item.images || []).map((img) => ({
75 type: "data-image" as const,
76 data: {
77 url: img.url,
78 mediaType: img.mediaType,
79 filename: img.filename,
80 base64Data: img.base64Data,
81 },
82 })),
83 ...(item.files || []).map((f) => ({
84 type: "data-file" as const,
85 data: {
86 url: f.url,
87 mediaType: f.mediaType,
88 filename: f.filename,
89 size: f.size,
90 },
91 })),
92 ]
93
94 // Expand text contexts, diff text contexts, and pasted texts as mention tokens

Callers 1

scheduleProcessingFunction · 0.85

Calls 10

utf8ToBase64Function · 0.90
trackMessageSentFunction · 0.90
setLoadingFunction · 0.90
clearLoadingFunction · 0.90
getStatusMethod · 0.80
setStatusMethod · 0.80
hasMethod · 0.45
getMethod · 0.45
deleteMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected