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
@@ -979,10 +979,6 @@ function summarizeLiveRunEvents(
if (event.type === "run_started") {
lines.push("后端已开始执行本轮任务。");
}
if (event.type === "content_delta" && event.delta) {
const note = event.delta.trim();
if (note && !isNoisyLiveDelta(note)) lines.push(note);
}
if (event.type === "tool_start") {
const stageNote =
typeof event.assistant_content === "string"
@@ -610,10 +610,6 @@ function summarizeRunEvents(runStatus: ClawActiveRunStatus) {
if (event.type === "run_started") {
lines.push("后端已开始执行本轮任务。");
}
if (event.type === "content_delta" && event.delta) {
const note = event.delta.trim();
if (note && !isNoisyLiveDelta(note)) lines.push(note);
}
if (event.type === "tool_start") {
const stageNote =
typeof event.assistant_content === "string"
@@ -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" />