()
| 4221 | } |
| 4222 | |
| 4223 | async function activateCodexDesktopApp() { |
| 4224 | if (!await isCodexDesktopAppRunning()) { |
| 4225 | return startCodexDesktopApp(); |
| 4226 | } |
| 4227 | |
| 4228 | await runCommand("/usr/bin/open", ["-a", "Codex"], { timeout: 12000, allowFailure: true }); |
| 4229 | await runCommand("/usr/bin/osascript", ["-e", 'tell application "Codex" to activate'], { timeout: 12000, allowFailure: true }); |
| 4230 | await sleep(1200); |
| 4231 | const quota = await readLatestCodexQuotaSnapshot().catch(() => state.maintenance.codex.quota); |
| 4232 | if (quota) state.maintenance.codex.quota = quota; |
| 4233 | return { |
| 4234 | ok: true, |
| 4235 | summary: "Codex desktop activated", |
| 4236 | reply: quota |
| 4237 | ? `Codex 已切到前台。\n\n${formatCodexQuotaDetail("实时额度:", quota)}` |
| 4238 | : "Codex 已切到前台。" |
| 4239 | }; |
| 4240 | } |
| 4241 | |
| 4242 | async function startCodexDesktopApp() { |
| 4243 | if (await isCodexDesktopAppRunning()) { |
no test coverage detected