| ... | @@ -3917,7 +3917,9 @@ describe("CodexAdapterV2 post-settle continuation", () => { | ... | @@ -3917,7 +3917,9 @@ describe("CodexAdapterV2 post-settle continuation", () => { |
| 3917 | ), | 3917 | ), |
| 3918 | ); | 3918 | ); |
| 3919 | | 3919 | |
| 3920 | const backgroundStopCases = [true, false, "still_running"] as const; | 3920 | // "thread_unloaded": the thread was settled, so T3 unsubscribed and Codex |
| | 3921 | // unloaded it (killing its terminals) before Stop arrived. |
| | 3922 | const backgroundStopCases = [true, false, "still_running", "thread_unloaded"] as const; |
| 3921 | const makeBackgroundStopTranscript = (terminated: (typeof backgroundStopCases)[number]) => { | 3923 | const makeBackgroundStopTranscript = (terminated: (typeof backgroundStopCases)[number]) => { |
| 3922 | const stillRunning = terminated === "still_running"; | 3924 | const stillRunning = terminated === "still_running"; |
| 3923 | return makeCodexReplayTranscript({ | 3925 | return makeCodexReplayTranscript({ |
| ... | @@ -3936,9 +3938,15 @@ describe("CodexAdapterV2 post-settle continuation", () => { | ... | @@ -3936,9 +3938,15 @@ describe("CodexAdapterV2 post-settle continuation", () => { |
| 3936 | { | 3938 | { |
| 3937 | type: "emit_inbound", | 3939 | type: "emit_inbound", |
| 3938 | label: "terminate-background-command", | 3940 | label: "terminate-background-command", |
| 3939 | frame: { id: 4, result: { terminated: terminated === true } }, | 3941 | frame: |
| | 3942 | terminated === "thread_unloaded" |
| | 3943 | ? { |
| | 3944 | id: 4, |
| | 3945 | error: { code: -32600, message: `thread not found: ${BG_NATIVE_THREAD}` }, |
| | 3946 | } |
| | 3947 | : { id: 4, result: { terminated: terminated === true } }, |
| 3940 | }, | 3948 | }, |
| 3941 | ...(terminated !== true | 3949 | ...(terminated === false || stillRunning |
| 3942 | ? [ | 3950 | ? [ |
| 3943 | { | 3951 | { |
| 3944 | type: "expect_outbound" as const, | 3952 | type: "expect_outbound" as const, |