fix(cli): report stale binding clears accurately (#114926)

Co-authored-by: Alix-007 <li.long15@xydigit.com>
This commit is contained in:
Peter Steinberger
2026-08-09 05:55:21 -07:00
committed by GitHub
parent dfbc95e4ea
commit 4ade409cf2
2 changed files with 16 additions and 2 deletions
@@ -1314,6 +1314,17 @@ describe("CLI attempt execution", () => {
);
await replaceSessionEntry({ sessionKey, storePath }, concurrentEntry);
sessionStore[sessionKey] = concurrentEntry;
const clearBeforeFreshRetry = runArgs.onBeforeFreshCliSessionRetry;
expect(clearBeforeFreshRetry).toBeTypeOf("function");
await expect(
(
clearBeforeFreshRetry as (params: {
provider: string;
reason: "timeout";
sessionId: string;
}) => Promise<boolean>
)({ provider: "claude-cli", reason: "timeout", sessionId: forkedCliSessionId }),
).resolves.toBe(false);
throw recoveryError;
});
+5 -2
View File
@@ -337,6 +337,7 @@ export async function clearCliSessionInStore(params: {
return undefined;
}
let didClear = false;
const persisted = await patchSessionEntry(
{
storePath,
@@ -358,14 +359,16 @@ export async function clearCliSessionInStore(params: {
const next = { ...currentEntry };
clearCliSession(next, provider);
next.updatedAt = Date.now();
didClear = true;
return next;
},
{ fallbackEntry: entry },
);
if (persisted) {
if (persisted && didClear) {
sessionStore[sessionKey] = persisted;
return persisted;
}
return persisted ?? undefined;
return undefined;
}
/** Clears the one-shot fork marker before the resumed CLI process starts. */