Fix run cancellation and live activity stability

This commit is contained in:
wuyang6
2026-05-14 12:23:53 +08:00
parent 105d287ebd
commit 22960c5e02
6 changed files with 117 additions and 43 deletions
@@ -860,7 +860,11 @@ const ComposerAction: FC = () => {
includePending: true,
includeActive: true,
});
const [runtimeCancelling, setRuntimeCancelling] = useState(false);
const cancelSessionId = replayedRun.sessionId ?? currentSessionId;
useEffect(() => {
if (!runtimeRunning) setRuntimeCancelling(false);
}, [runtimeRunning]);
return (
<div className="aui-composer-action-wrapper relative flex items-center justify-between">
<div className="flex items-center gap-1">
@@ -890,12 +894,15 @@ const ComposerAction: FC = () => {
size="icon"
className="aui-composer-cancel size-8 rounded-full"
aria-label="Stop generating"
disabled={!cancelSessionId}
disabled={!cancelSessionId || runtimeCancelling}
onClick={() => {
if (!cancelSessionId) return;
void cancelLatestRun(cancelSessionId, replayedRun.runId).catch(
() => undefined,
);
setRuntimeCancelling(true);
void cancelLatestRun(cancelSessionId, replayedRun.runId)
.catch(() => undefined)
.finally(() => {
window.setTimeout(() => setRuntimeCancelling(false), 1200);
});
}}
>
<SquareIcon className="aui-composer-cancel-icon size-3 fill-current" />