MCPcopy Create free account
hub / github.com/RioArisk/claudecode_api_RemoteControl / handleUploadStatus

Function handleUploadStatus

app/src/modules/image-upload.js:68–101  ·  view source on GitHub ↗
(m)

Source from the content-addressed store, hash-verified

66}
67
68export function handleUploadStatus(m) {
69 const currentImage = pendingImage;
70 if (currentImage && m.uploadId === currentImage.uploadId) {
71 if (Number.isFinite(m.totalBytes) && m.totalBytes > 0) currentImage.totalBytes = m.totalBytes;
72 if (Number.isFinite(m.receivedBytes)) currentImage.uploadedBytes = m.receivedBytes;
73 const totalBytes = currentImage.totalBytes || 0;
74 if (totalBytes > 0 && Number.isFinite(currentImage.uploadedBytes)) {
75 currentImage.progress = Math.max(0, Math.min(1, currentImage.uploadedBytes / totalBytes));
76 }
77 if (m.status === 'ready_for_chunks' || m.status === 'uploading') currentImage.status = 'uploading';
78 else if (m.status === 'uploaded') {
79 currentImage.status = 'uploaded';
80 currentImage.progress = 1;
81 } else if (m.status === 'submitted') {
82 currentImage.status = 'submitted';
83 currentImage.progress = 1;
84 } else if (m.status === 'error' || m.status === 'aborted') {
85 currentImage.status = 'failed';
86 }
87 updateImagePreviewUi();
88 }
89
90 const waiter = S.uploadWaiters.get(m.uploadId);
91 if (!waiter) return;
92 if (m.status === 'error' || m.status === 'aborted') {
93 S.uploadWaiters.delete(m.uploadId);
94 waiter.reject(new Error(m.message || 'Image upload failed'));
95 return;
96 }
97 if (!waiter.expectedStatuses.has(m.status)) return;
98 if (waiter.matchFn && !waiter.matchFn(m)) return;
99 S.uploadWaiters.delete(m.uploadId);
100 waiter.resolve(m);
101}
102
103export function clearPendingImage({ abortUpload = true } = {}) {
104 const currentImage = pendingImage;

Callers 1

connectFunction · 0.90

Calls 1

updateImagePreviewUiFunction · 0.70

Tested by

no test coverage detected