Fix CursorAdapter: route native events to per-thread log and drain pending requests on exit

- Pass context.session.threadId instead of null to nativeEventLogger.write()
  so native events are logged to per-thread segment files, matching CodexAdapter.
- Reject all pending requests in the child process exit handler before cleanup,
  preventing 120s hangs when the process exits unexpectedly.

Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
Cursor AgentandJulius Marminge committed 2026-03-06 04:18:47 +00:00
1 parent 93132a2063
commit 68b256ee89
1 file changed
+7 -1
@@ -830,7 +830,7 @@ function makeCursorAdapter(options?: CursorAdapterLiveOptions) {
payload: message,
},
},
null,
context.session.threadId,
),
);
} catch {
@@ -1063,6 +1063,12 @@ function makeCursorAdapter(options?: CursorAdapterLiveOptions) {
}
Effect.runFork(
Effect.gen(function* () {
for (const pending of context.pending.values()) {
clearTimeout(pending.timeout);
pending.reject(new Error("Cursor ACP process exited unexpectedly."));
}
context.pending.clear();
if (context.turnState) {
yield* completeTurn(
context,