MCPcopy
hub / github.com/CodebuffAI/codebuff / addPendingImageWithError

Function addPendingImageWithError

cli/src/utils/pending-attachments.ts:142–167  ·  view source on GitHub ↗
(
  imagePath: string,
  note: string,
)

Source from the content-addressed store, hash-verified

140 * Error images are automatically removed after AUTO_REMOVE_ERROR_DELAY_MS.
141 */
142export function addPendingImageWithError(
143 imagePath: string,
144 note: string,
145): void {
146 const filename = path.basename(imagePath)
147 useChatStore.getState().addPendingImage({
148 path: imagePath,
149 filename,
150 status: 'error',
151 note,
152 })
153
154 // Clear any existing timer for this path (shouldn't happen, but be safe)
155 const existingTimer = errorImageTimers.get(imagePath)
156 if (existingTimer) {
157 clearTimeout(existingTimer)
158 }
159
160 // Auto-remove error images after a delay
161 const timer = setTimeout(() => {
162 errorImageTimers.delete(imagePath)
163 useChatStore.getState().removePendingImage(imagePath)
164 }, AUTO_REMOVE_ERROR_DELAY_MS)
165
166 errorImageTimers.set(imagePath, timer)
167}
168
169/**
170 * Clear the auto-remove timer for an error image.

Callers 2

validateAndAddImageFunction · 0.85

Calls 4

setTimeoutFunction · 0.85
deleteMethod · 0.80
setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected