mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-25 05:07:05 +00:00
fix(cursor): stop acknowledging soft steers that an abort cancels (#2229)
Abort sends session/cancel, and ACP answers the pending soft-steer session/prompt with stopReason "cancelled". The completion handler ignored the stopReason and acknowledged the row as steered, so a message Cursor may never have run was shown as delivered. Surface the stopReason from beginSoftSteerPrompt. On "cancelled" the row is held as indeterminate (the same path a transport failure takes), because Cursor may or may not have folded it into the cancelled turn: the user resolves it with Retry or Cancel instead of a silent claim or an automatic re-run after Stop. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ba7494c5b5
commit
b4be7c2d93
@@ -18,7 +18,7 @@ const harness = vi.hoisted(() => ({
|
||||
promptCalls: 0,
|
||||
prompts: [] as unknown[][],
|
||||
deferPrompt: null as Promise<void> | null,
|
||||
deferSoftSteer: null as Promise<void> | null,
|
||||
deferSoftSteer: null as Promise<string | null | void> | null,
|
||||
softSteerDispatchError: null as Error | null,
|
||||
deferSoftSteerDispatch: null as Promise<void> | null,
|
||||
promptErrors: [] as Error[],
|
||||
@@ -613,6 +613,37 @@ describe('cursorAcpRemoteLauncher', () => {
|
||||
await runPromise;
|
||||
});
|
||||
|
||||
it('holds a soft steer that an abort cancels for explicit resolution', async () => {
|
||||
let releasePrompt!: () => void;
|
||||
let finishSoftSteer!: (stopReason: string) => void;
|
||||
harness.deferPrompt = new Promise((resolve) => { releasePrompt = resolve; });
|
||||
harness.deferSoftSteer = new Promise((resolve) => { finishSoftSteer = resolve; });
|
||||
const session = makeSession(null, false);
|
||||
const mode = { permissionMode: 'default' } as EnhancedMode;
|
||||
session.queue.push('first', mode, 'first');
|
||||
|
||||
const runPromise = cursorAcpRemoteLauncher(session);
|
||||
await vi.waitFor(() => expect(harness.promptCalls).toBe(1));
|
||||
const handlers = (session.client as unknown as {
|
||||
rpcHandlerManager: { handlers: Map<string, (payload?: unknown) => Promise<unknown>> };
|
||||
}).rpcHandlerManager.handlers;
|
||||
|
||||
session.queue.push('soft steer', mode, 'steer');
|
||||
await expect(handlers.get(RPC_METHODS.SteerQueuedMessage)!({ localId: 'steer' }))
|
||||
.resolves.toEqual({ steered: true });
|
||||
harness.deferPrompt = null;
|
||||
releasePrompt();
|
||||
const abort = handlers.get(RPC_METHODS.Abort)!();
|
||||
finishSoftSteer('cancelled');
|
||||
await abort;
|
||||
|
||||
await vi.waitFor(() => expect(session.client.emitSteerIndeterminate).toHaveBeenCalledWith(['steer']));
|
||||
expect(session.client.emitMessagesConsumed).not.toHaveBeenCalledWith(['steer'], { steered: true });
|
||||
|
||||
session.queue.close();
|
||||
await runPromise;
|
||||
});
|
||||
|
||||
it('does not hang teardown while a soft steer completion is unresolved', async () => {
|
||||
let releasePrompt!: () => void;
|
||||
harness.deferPrompt = new Promise((resolve) => { releasePrompt = resolve; });
|
||||
|
||||
Reference in New Issue
Block a user