[codex] Add Codex autostart ensure fallback - #8
Conversation
Refined review of PR #8 (codex/auto-start-proxy-port-fallback) with 2 must-fix, 2 should-fix, and 1 note. No code changes — review only. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Code Review — PR #8 Autostart Ensure Fallback전체 리뷰 결과: Must Fix (2)1.
// 현재 (불필요):
const { saveConfig: save } = await import("./config");
save(config);
// 수정안:
saveConfig(config);2.
// 현재:
await syncModelsToCodex(config.port).catch(() => {});
// 수정안 — 최소한 stderr 경고:
await syncModelsToCodex(config.port).catch(e => {
console.error(`⚠️ Model sync skipped: ${e instanceof Error ? e.message : String(e)}`);
});Should Fix (2)3. 4. Note5. 포트 선점 TOCTOU — Positives
|
Squash of PR #8 — centralizes startup logic into `ocx ensure`, adds port fallback when busy, `codexAutoStart` dashboard toggle, and `ocx uninstall` for clean removal. Co-Authored-By: 이완우 <Ingwannu@users.noreply.github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- server.ts: remove redundant dynamic import of saveConfig, use static import - cli.ts: log sync failures in handleEnsure instead of silent catch - Dashboard.tsx: set error state on autostart toggle save failure Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Review Applied ✅코드 리뷰 완료 후 아래 수정사항을 Must Fix (적용 완료)
Should Fix (적용 완료) 관련 커밋:
|
Keep Windows CI green after PR #8 by skipping the POSIX execution-only test on Windows while retaining Windows shim assertions.
…p audit BLOCKER fixes: - outbound.ts: detached pump pattern for SSE streaming — frames now reach the client as they arrive instead of buffering until upstream EOF; cancel calls reader.cancel() instead of the locked stream (#1) - system-env.ts: transactional launchctl injection with incremental tracking and rollback on mid-flight failure (#2) MAJOR fixes: - system-env.ts: POSIX single-quote escaping for all user-controlled values in the generated shell file, preventing command injection (#3) - system-env.ts: exported applySystemEnvToggle for runtime ON/OFF lifecycle (#7) - claude-messages.ts: 120s hard timeout on native passthrough upstream fetch using AbortSignal.timeout, returning Anthropic 504 on expiry (#4) - management-api.ts: reject non-plain-object PUT bodies (null, array, primitive) with 400; strict validation for blockedSkills, tierModels, modelMap, and autoCompactWindow (integer, range 100k-1M) (#5, #6) - management-api.ts: call applySystemEnvToggle after systemEnv config toggle (#7) - cli/claude.ts: override stale loopback ANTHROPIC_BASE_URL with live port; warn on gateway-cache and agent-sync failures instead of swallowing (#8, #10) - gateway-cache.ts: distinguish discovery failure (keep cache) from authoritative empty success (write {models:[]}) (#9) Test fixes: updated assertions for single-quote shell escaping, empty cache semantics, validation messages, incremental tracking writes, and PUT response shape.
What changed
ocx ensure, which starts the proxy if needed and refreshes Codex config/model cache before Codex runs.ocx ensureon everycodexlaunch instead of duplicating start/status/cache logic in shell scripts.codexAutoStartas an enabled-by-default setting, exposes it through/api/settings, and adds a dashboard toggle to disable it.ocx initoffer Codex shim installation by default while still avoiding npm postinstall mutation.ocx uninstallto stop the proxy, remove any installed service, remove the Codex shim, restore native Codex config/catalog/history, and delete~/.opencodexbefore package removal.Why
If the proxy is not already running, Codex CLI/App sessions can start with stale config/cache or fail until the user manually starts opencodex. Centralizing startup in
ocx ensuremakes CLI/App autostart consistent and lets the proxy recover from port conflicts without requiring users to edit config by hand.The full uninstall command also makes cleanup explicit: users can restore native Codex and remove opencodex local state before running their package-manager uninstall.
Validation
bun test testsbun run typecheckcd gui && bun run build