fix(ui): clear stale pending ACP connection after terminal recovery failure (#10552)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Mark Xian
2026-07-22 08:04:38 +08:00
committed by GitHub
parent 3065c9701f
commit 3405ad510a
2 changed files with 26 additions and 0 deletions
@@ -136,6 +136,29 @@ describe('ACP connection ownership', () => {
expect(getAcpUrl).toHaveBeenCalledOnce();
});
it('does not cache terminal recovery failures across caller retries', async () => {
const { getAcpClient } = await import('../acpConnection');
await getAcpClient();
const getAcpUrl = vi
.fn()
.mockRejectedValue(
new Error(`Error invoking remote method 'get-acp-url': ${GOOSE_SERVE_EXITED_USER_MESSAGE}`)
);
window.electron.getAcpUrl = getAcpUrl;
sdk.instances[0].resolveClosed();
await Promise.resolve();
const failedRecovery = expect(getAcpClient()).rejects.toThrow(GOOSE_SERVE_EXITED_USER_MESSAGE);
await vi.advanceTimersByTimeAsync(250);
await failedRecovery;
await expect(getAcpClient()).rejects.toThrow(GOOSE_SERVE_EXITED_USER_MESSAGE);
expect(getAcpUrl).toHaveBeenCalledTimes(2);
expect(sdk.instances).toHaveLength(1);
});
it('reconnects immediately after system resume', async () => {
const { getAcpClient, reconnectAcpAfterSystemResume } = await import('../acpConnection');
await getAcpClient();
+3
View File
@@ -96,6 +96,9 @@ function recoverConnection(immediate: boolean): void {
}
},
() => {
if (pendingConnection === recoveryAttempt) {
pendingConnection = null;
}
if (generation === connectionGeneration) {
setRecovering(false);
}