Skip to content

Commit f2864f6

Browse files
yiliang114qwencoder
andcommitted
fix(serve): preserve live cancellation reattachment
Skip ownerless cancellation settlement while the original Turn still runs, so a cold Java attachment can reattach passively and cancel that owner. Co-authored-by: Qwen-Coder <[email protected]>
1 parent 2748c36 commit f2864f6

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎packages/cli/src/serve/hosted-harness-session.test.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6874,7 +6874,7 @@ describe('Hosted Harness no-tool session', () => {
68746874
await headers(supertest(server).delete(`/session/${SESSION_ID}`));
68756875
});
68766876

6877-
it('reports an aborted turn as cancelled to the Java event projector', async () => {
6877+
it('reports an aborted live turn as cancelled after a Java-style cold reattach', async () => {
68786878
const log = vi
68796879
.spyOn(stdio, 'writeStderrLineSafe')
68806880
.mockImplementation(() => {});
@@ -6902,9 +6902,19 @@ describe('Hosted Harness no-tool session', () => {
69026902
.send({ prompt, promptId: PROMPT_ID, payloadDigest });
69036903
expect(admitted.status).toBe(202);
69046904
await vi.waitFor(() => expect(state.model).toHaveBeenCalledTimes(1));
6905+
const reattached = await headers(
6906+
supertest(server).post(`/session/${SESSION_ID}/load`),
6907+
).send({
6908+
managedSessionStore: store(),
6909+
passiveManagedRuntimeRecovery: true,
6910+
driveRuntimeRecovery: false,
6911+
cancellationTakeover: true,
6912+
});
6913+
expect(reattached.status).toBe(200);
6914+
expect(reattached.body.clientId).toBe(created.body.clientId);
69056915
const cancelled = await headers(
69066916
supertest(server).post(`/session/${SESSION_ID}/cancel`),
6907-
).set('X-Qwen-Client-Id', created.body.clientId as string);
6917+
).set('X-Qwen-Client-Id', reattached.body.clientId as string);
69086918
expect(cancelled.status).toBe(204);
69096919
await vi.waitFor(
69106920
async () => {

‎packages/cli/src/serve/hosted-harness-session.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,7 @@ export function registerHostedHarnessSessionRoutes(
18981898
// exactly as on the first load.
18991899
if (
19001900
!resident.hooks &&
1901+
resident.active === undefined &&
19011902
(passiveRecovery || driveRecovery) &&
19021903
body?.['cancellationTakeover'] === true
19031904
) {

0 commit comments

Comments
 (0)