Spaces:
Sleeping
Sleeping
fixed stop button issues
Browse files- web/src/App.tsx +8 -3
web/src/App.tsx
CHANGED
|
@@ -1200,13 +1200,18 @@ function App() {
|
|
| 1200 |
)
|
| 1201 |
);
|
| 1202 |
} finally {
|
| 1203 |
-
//
|
| 1204 |
-
|
|
|
|
|
|
|
|
|
|
| 1205 |
setIsLoading(false);
|
| 1206 |
setIsGenerating(false);
|
| 1207 |
-
setResponseComplete(true);
|
| 1208 |
setStatusMessage('');
|
| 1209 |
abortControllerRef.current = null;
|
|
|
|
|
|
|
|
|
|
| 1210 |
}
|
| 1211 |
}
|
| 1212 |
};
|
|
|
|
| 1200 |
)
|
| 1201 |
);
|
| 1202 |
} finally {
|
| 1203 |
+
// Always clean up loading state for this request — even on abort.
|
| 1204 |
+
// handleStopGeneration schedules the same updates synchronously, but
|
| 1205 |
+
// React state updates are async; clearing here as well guarantees the
|
| 1206 |
+
// UI unlocks regardless of timing so the user can send a new message.
|
| 1207 |
+
if (myRequestId === requestIdRef.current) {
|
| 1208 |
setIsLoading(false);
|
| 1209 |
setIsGenerating(false);
|
|
|
|
| 1210 |
setStatusMessage('');
|
| 1211 |
abortControllerRef.current = null;
|
| 1212 |
+
if (!wasAborted) {
|
| 1213 |
+
setResponseComplete(true);
|
| 1214 |
+
}
|
| 1215 |
}
|
| 1216 |
}
|
| 1217 |
};
|