feat: 发布 1.1.14

回退清队列会等 updateQueue 结束,条目已经不在时不再把宿主打成未处理异常。兜底回退按钮记下时间,轮询不会把同一次回退再打开一遍。开放回合切在最后一个已闭合回合,不再多丢上一轮;等不到结束仍然直接失败。

同时写入 1.1.13 之后已在 master 上的修复:bash 超时补丁不再每次启动多补一个 0,正式版追上的测试版不再列出,phase-1 不再清空 runtime context。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-09-23 14:51:22 +08:00
1 parent 6a3f89da8d
commit 318b3e3db3
6 files changed
+106 -21

No files matched your search

+16 -7
View File
@@ -6,6 +6,10 @@ function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
function ignoreSettled(value) {
Promise.resolve(value).catch(() => {});
}
function errorText(err) {
if (!err) return "回退失败";
if (typeof err === "string") return err;
@@ -149,11 +153,16 @@ export function planRewind(events) {
return { ok: false, error: "没有可回退的上一句" };
}
const text = userTextFromEvent(lastUser);
if (turnEnds.length >= 2) {
const open = lastOpenTurn(list);
const fromOpenTurn = Boolean(open && lastUser.seq >= open.seq);
// 开放回合的那句还没进历史,切在最后一个已闭合 turn/end。
// 已闭合的上一句要整轮拿掉,所以再往前一个 end。
const cutIndex = fromOpenTurn ? turnEnds.length - 1 : turnEnds.length - 2;
if (cutIndex >= 0) {
return {
ok: true,
mode: "fork",
atSeq: turnEnds[turnEnds.length - 2].seq,
atSeq: turnEnds[cutIndex].seq,
text,
};
}
@@ -301,7 +310,7 @@ async function disarmRewoundSession(ctx, sessionId) {
const disarmOnce = async () => {
const agent = getAgent(ctx, sessionId);
try { agent?.inbox?.clear?.(); } catch { /* ignore */ }
try { agent?.cancel?.({ kind: "user" }, { keepInbox: false }); } catch { /* ignore */ }
try { ignoreSettled(agent?.cancel?.({ kind: "user" }, { keepInbox: false })); } catch { /* ignore */ }
const ids = [];
try {
@@ -319,7 +328,7 @@ async function disarmRewoundSession(ctx, sessionId) {
if (!id || seen.has(id)) continue;
seen.add(id);
try {
controller?.updateQueue?.({
await controller?.updateQueue?.({
sessionId,
itemId: id,
action: { kind: "remove" },
@@ -329,7 +338,7 @@ async function disarmRewoundSession(ctx, sessionId) {
try { agent?.inbox?.clear?.(); } catch { /* ignore */ }
if (agent?.status === "running") {
try { agent.cancel({ kind: "user" }, { keepInbox: false }); } catch { /* ignore */ }
try { ignoreSettled(agent.cancel({ kind: "user" }, { keepInbox: false })); } catch { /* ignore */ }
}
};
@@ -380,7 +389,7 @@ async function resolveMainSession(ctx, sessionId) {
async function rewindOneSession(ctx, controller, sessionId) {
let log = await readSessionLog(ctx, sessionId);
if (lastOpenTurn(log.events)) {
try { controller.cancel?.({ sessionId }); } catch { /* ignore */ }
try { ignoreSettled(controller.cancel?.({ sessionId })); } catch { /* ignore */ }
log = await waitTurnClosed(ctx, sessionId);
}
const plan = planRewind(log.events);
@@ -438,7 +447,7 @@ export async function applyRewind(ctx, sessionId, mode) {
if (action === "round") {
const target = await resolveMainSession(ctx, sessionId);
if (sessionId !== target.sessionId) {
try { controller.cancel?.({ sessionId }); } catch { /* ignore */ }
try { ignoreSettled(controller.cancel?.({ sessionId })); } catch { /* ignore */ }
}
const result = await rewindOneSession(ctx, controller, target.sessionId);
if (!result.ok) return result;