Spaces:
Running
Running
fix progress bar
Browse files- wasm-demo.js +10 -7
wasm-demo.js
CHANGED
@@ -283,6 +283,15 @@ async function pollTaskStatus(currentTaskId, currentUid) {
|
|
283 |
} else if (statusData.status === 'processing' || statusData.status === 'running') {
|
284 |
userMessage = 'Processing your request...';
|
285 |
showComputing = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
} else if (statusData.status === 'success' || statusData.status === 'completed') {
|
287 |
userMessage = 'Processing complete!';
|
288 |
// Set progress to 100% and clear timer
|
@@ -393,11 +402,10 @@ $('btnSend').onclick = async () => {
|
|
393 |
show('encIcon', false);
|
394 |
show('spin', true);
|
395 |
show('processingNote', true);
|
396 |
-
show('progressContainer',
|
397 |
$('progressBar').style.width = '0%'; // Reset progress bar
|
398 |
$('srvStatus').textContent = 'Sending encrypted data...';
|
399 |
$('srvComputing').hidden = true; // Ensure it's hidden initially
|
400 |
-
window.taskStartTime = performance.now();
|
401 |
window.expectedDuration = currentTokenCount * 30 * 1000; // Convert to milliseconds
|
402 |
|
403 |
// Clear any existing progress timer
|
@@ -429,11 +437,6 @@ $('btnSend').onclick = async () => {
|
|
429 |
taskId = newTaskId;
|
430 |
console.log('[Main] Task submitted to server. Task ID:', taskId);
|
431 |
$('srvStatus').textContent = 'Request submitted. Checking status...';
|
432 |
-
|
433 |
-
// Start progress bar updates
|
434 |
-
if (!progressTimer) {
|
435 |
-
progressTimer = setInterval(updateProgressBar, 1000);
|
436 |
-
}
|
437 |
|
438 |
pollTaskStatus(taskId, sessionUid).then(finalStatus => {
|
439 |
if (finalStatus && (finalStatus.status === 'success' || finalStatus.status === 'completed')) {
|
|
|
283 |
} else if (statusData.status === 'processing' || statusData.status === 'running') {
|
284 |
userMessage = 'Processing your request...';
|
285 |
showComputing = true;
|
286 |
+
|
287 |
+
// Start progress bar when processing actually begins
|
288 |
+
show('progressContainer', true);
|
289 |
+
if (!window.taskStartTime) {
|
290 |
+
window.taskStartTime = performance.now(); // Set start time when processing begins
|
291 |
+
}
|
292 |
+
if (!progressTimer) {
|
293 |
+
progressTimer = setInterval(updateProgressBar, 1000);
|
294 |
+
}
|
295 |
} else if (statusData.status === 'success' || statusData.status === 'completed') {
|
296 |
userMessage = 'Processing complete!';
|
297 |
// Set progress to 100% and clear timer
|
|
|
402 |
show('encIcon', false);
|
403 |
show('spin', true);
|
404 |
show('processingNote', true);
|
405 |
+
show('progressContainer', false); // Hide initially, show when processing starts
|
406 |
$('progressBar').style.width = '0%'; // Reset progress bar
|
407 |
$('srvStatus').textContent = 'Sending encrypted data...';
|
408 |
$('srvComputing').hidden = true; // Ensure it's hidden initially
|
|
|
409 |
window.expectedDuration = currentTokenCount * 30 * 1000; // Convert to milliseconds
|
410 |
|
411 |
// Clear any existing progress timer
|
|
|
437 |
taskId = newTaskId;
|
438 |
console.log('[Main] Task submitted to server. Task ID:', taskId);
|
439 |
$('srvStatus').textContent = 'Request submitted. Checking status...';
|
|
|
|
|
|
|
|
|
|
|
440 |
|
441 |
pollTaskStatus(taskId, sessionUid).then(finalStatus => {
|
442 |
if (finalStatus && (finalStatus.status === 'success' || finalStatus.status === 'completed')) {
|