|
3 | 3 | */ |
4 | 4 | import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime"; |
5 | 5 | import { CodexAppServerRpcError, type CodexAppServerClient } from "./client.js"; |
6 | | -import { |
7 | | - clearSharedCodexAppServerClientIfCurrent, |
8 | | - clearSharedCodexAppServerClientIfCurrentAndUnclaimed, |
9 | | - retireSharedCodexAppServerClientIfCurrent, |
10 | | -} from "./shared-client.js"; |
| 6 | +import { retireSharedCodexAppServerClientIfCurrent } from "./shared-client.js"; |
11 | 7 | import { getCodexAppServerTurnRouter } from "./turn-router.js"; |
12 | 8 |
|
13 | 9 | /** Timeout for best-effort app-server turn interruption during cleanup. */ |
@@ -72,30 +68,12 @@ export async function closeCodexStartupClientBestEffort( |
72 | 68 | if (!client) { |
73 | 69 | return; |
74 | 70 | } |
75 | | - const unclaimedSharedClient = clearSharedCodexAppServerClientIfCurrentAndUnclaimed(client); |
76 | | - if (unclaimedSharedClient.closed) { |
77 | | - await closeClientAndWaitIfAvailable(client); |
78 | | - return; |
79 | | - } |
80 | | - if (unclaimedSharedClient.found) { |
81 | | - const retired = retireSharedCodexAppServerClientIfCurrent(client); |
82 | | - if (retired?.closed) { |
83 | | - await closeClientAndWaitIfAvailable(client); |
84 | | - } |
85 | | - return; |
86 | | - } |
87 | 71 | const retiredSharedClient = retireSharedCodexAppServerClientIfCurrent(client); |
88 | | - if (retiredSharedClient) { |
89 | | - if (retiredSharedClient.closed) { |
90 | | - await closeClientAndWaitIfAvailable(client); |
91 | | - } |
92 | | - return; |
93 | | - } |
94 | | - if (clearSharedCodexAppServerClientIfCurrent(client)) { |
| 72 | + // Detached entries retain every ordinary and native lease; only isolated or |
| 73 | + // already-closed shared clients may be joined without aborting sibling turns. |
| 74 | + if (!retiredSharedClient || retiredSharedClient.closed) { |
95 | 75 | await closeClientAndWaitIfAvailable(client); |
96 | | - return; |
97 | 76 | } |
98 | | - await closeClientAndWaitIfAvailable(client); |
99 | 77 | } |
100 | 78 |
|
101 | 79 | /** Sends a bounded turn interrupt and waits for Codex to confirm terminal abort handling. */ |
|
0 commit comments