GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #15 from lidge-jun/dev · agentHits/opencodex@2ce93db

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • devlog/210_pr8-autostart-ensure-review
    • 00_plan.md
    • 10_review.md
    • 20_apply-plan.md
  • gui/src
    • i18n
      • en.ts
      • ko.ts
      • zh.ts
    • pages
      • Dashboard.tsx
    • styles.css
  • src
    • adapters
      • openai-chat.ts
    • cli.ts
    • server.ts
  • tests
    • reasoning-effort.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎devlog/210_pr8-autostart-ensure-review/00_plan.md‎

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# 210 — PR #8 Code Review: Autostart Ensure Fallback
2+
3+
## Summary
4+
5+
PR #8 (`codex/auto-start-proxy-port-fallback`)의 코드리뷰 결과를 정리하고,
6+
리파인된 피드백을 PR 코멘트로 제출한다. 직접 코드 수정은 하지 않는다.
7+
8+
## Deliverables
9+
10+
| # | Type | Path | Description |
11+
|---|------|------|-------------|
12+
| 1 | NEW | `devlog/210_pr8-autostart-ensure-review/00_plan.md` | 이 파일 |
13+
| 2 | NEW | `devlog/210_pr8-autostart-ensure-review/10_review.md` | 리파인된 리뷰 결과 |
14+
| 3 | — | PR #8 comment | gh pr review로 코멘트 작성 |
15+
16+
## Steps
17+
18+
1. 앞서 수행한 리뷰 결과를 검증 및 리파인하여 `10_review.md` 작성
19+
2. dev 브랜치에 커밋 + 푸시
20+
3. `gh pr comment 8`으로 리뷰 코멘트 게시
Collapse file

‎devlog/210_pr8-autostart-ensure-review/10_review.md‎

Copy file name to clipboard
+99Lines changed: 99 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# PR #8 Code Review — Autostart Ensure Fallback
2+
3+
> PR: https://github.com/lidge-jun/opencodex/pull/8
4+
> Author: 이완우 (Ingwannu)
5+
> Reviewed: 2026-06-21
6+
> Status: Draft / +450 -53 / 19 files
7+
8+
## 변경 요약
9+
10+
shim 스크립트의 인라인 bash 로직(30줄+)을 `ocx ensure` 단일 명령어로 통합.
11+
포트 충돌 시 자동 fallback, `codexAutoStart` 대시보드 토글, `ocx uninstall` 일괄 정리 추가.
12+
13+
## 수정 필요 (Must Fix)
14+
15+
### 1. server.ts — 불필요한 dynamic import
16+
17+
`src/server.ts`의 `/api/settings` PUT 핸들러에서 `saveConfig`를 dynamic import로 다시 불러오고 있으나,
18+
파일 상단에 이미 static import 되어 있음.
19+
20+
```typescript
21+
// PR 현재 (line ~654):
22+
const { saveConfig: save } = await import("./config");
23+
save(config);
24+
25+
// 수정안:
26+
saveConfig(config);
27+
```
28+
29+
`saveConfig`는 같은 파일 line 16에서 `import { ..., saveConfig, ... } from "./config"`로 이미 가져옴.
30+
dynamic import는 불필요한 런타임 비용 + 코드 혼동을 유발함.
31+
32+
### 2. handleEnsure — sync 실패 무음 처리
33+
34+
`src/cli.ts`의 `handleEnsure()` 내 두 곳에서 `syncModelsToCodex().catch(() => {})`로
35+
에러를 완전히 삼키고 있음.
36+
37+
```typescript
38+
// line ~388:
39+
await syncModelsToCodex(config.port).catch(() => {});
40+
41+
// line ~406:
42+
await syncModelsToCodex(config.port ?? port).catch(() => {});
43+
```
44+
45+
`ensure`는 "프록시가 준비되었음을 보장"하는 명령어인데, 모델 sync가 실패하면
46+
Codex가 stale 캐시로 동작할 수 있음. 최소한 stderr 경고를 찍어야 디버깅 가능:
47+
48+
```typescript
49+
await syncModelsToCodex(config.port).catch(e => {
50+
console.error(`⚠️ Model sync skipped: ${e instanceof Error ? e.message : String(e)}`);
51+
});
52+
```
53+
54+
## 개선 권장 (Should Fix)
55+
56+
### 3. Dashboard 토글 실패 시 에러 미표시
57+
58+
`gui/src/pages/Dashboard.tsx`의 `toggleCodexAutoStart` catch 블록에서
59+
토글을 조용히 원복만 하고 사용자에게 에러를 알리지 않음.
60+
61+
```typescript
62+
} catch {
63+
setSettings(prev => prev ? { ...prev, codexAutoStart: !next } : prev);
64+
// ← 에러 toast나 상태 표시 없음
65+
}
66+
```
67+
68+
네트워크 오류나 서버 다운 시 사용자는 토글이 왜 안 먹히는지 알 수 없음.
69+
70+
### 4. uninstall/startup-prompt 테스트가 소스 문자열 매칭
71+
72+
`tests/uninstall.test.ts`와 `tests/startup-prompt.test.ts`의 일부 테스트가
73+
소스 파일을 텍스트로 읽어서 함수명/문자열 포함 여부만 확인:
74+
75+
```typescript
76+
expect(cli).toContain("async function handleUninstall()");
77+
expect(cli).toContain("uninstallServiceIfInstalled");
78+
```
79+
80+
리팩토링(함수명 변경, 추출)하면 기능은 그대로인데 테스트가 깨짐.
81+
`ports.test.ts`처럼 실제 동작을 테스트하는 방식이 더 견고함.
82+
83+
## 참고 (Note)
84+
85+
### 5. 포트 선점 경쟁 조건 (TOCTOU)
86+
87+
`src/ports.ts`의 `findAvailablePort`가 포트를 확인한 뒤 서버를 닫고 포트 번호를 반환.
88+
`startServer()`가 실제로 bind하기 전에 다른 프로세스가 끼어들 수 있음.
89+
이는 포트 검사의 본질적 한계이므로 blocking은 아니나,
90+
`startServer` 내부에서 `EADDRINUSE` 발생 시 재시도 로직이 있으면 더 안전함.
91+
92+
## 긍정 포인트
93+
94+
- shim 스크립트 간소화가 핵심 성과 — bash/batch 30줄 → `ensure` 1줄
95+
- 죽은 PID 감지 후 자동 정리 (기존: 에러 내고 종료)
96+
- `waitForProxy`가 매 루프마다 config를 다시 읽어서 자식 프로세스의 포트 변경 반영
97+
- `uninstallServiceIfInstalled` — 서비스 없어도 process.exit 안 하는 quiet helper
98+
- i18n 3개 언어(en/ko/zh) 모두 업데이트
99+
- `codexAutoStart` 기본값 `!== false`로 안전한 opt-out 패턴
Collapse file

‎devlog/210_pr8-autostart-ensure-review/20_apply-plan.md‎

Copy file name to clipboard
+27Lines changed: 27 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# 210-20 — PR #8 코드 적용 + 리뷰 수정 계획
2+
3+
## 전략
4+
5+
1. PR #8의 2개 커밋을 dev에 squash cherry-pick (기여자 Co-Authored-By 유지)
6+
2. 리뷰 지적 4건 수정을 별도 커밋으로 적용
7+
8+
## 수정 사항
9+
10+
### Fix 1: server.ts — 불필요한 dynamic import 제거
11+
- `/api/settings` PUT 핸들러에서 `await import("./config")` 제거
12+
- 이미 static import된 `saveConfig` 직접 사용
13+
14+
### Fix 2: cli.ts — handleEnsure sync 실패 로깅
15+
- `.catch(() => {})` → `.catch(e => console.error(...))`
16+
- 2곳 모두 적용
17+
18+
### Fix 3: Dashboard.tsx — 토글 실패 시 에러 표시
19+
- catch 블록에 `setError(true)` 또는 console.error 추가
20+
21+
### Fix 4: (optional) uninstall.test.ts — 문자열 매칭 테스트 개선 메모
22+
- 현재 단계에서는 메모만 (기능 테스트로 전환은 후속 작업)
23+
24+
## 커밋 계획
25+
26+
1. `feat: squash PR #8 — Codex autostart ensure fallback` (Co-Authored-By: 이완우)
27+
2. `fix: address PR #8 review — dynamic import, sync logging, toggle error`
Collapse file

‎gui/src/i18n/en.ts‎

Copy file name to clipboardExpand all lines: gui/src/i18n/en.ts
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ export const en = {
4141
"dash.stopping": "Stopping…",
4242
"dash.codexAutoStart": "Start opencodex with Codex",
4343
"dash.codexAutoStartHint": "When enabled, the Codex shim runs ocx ensure before every Codex CLI/App launch. Disable this to leave Codex untouched.",
44+
"dash.searchModel": "Search sidecar model",
45+
"dash.searchModelHint": "Model used for web_search on non-OpenAI routed models. Requires ChatGPT login.",
46+
"dash.searchReasoning": "Search reasoning effort",
47+
"dash.visionModel": "Vision sidecar model",
48+
"dash.visionModelHint": "Model used to describe images for text-only routed models. Requires ChatGPT login.",
49+
"dash.sidecarSaved": "Sidecar settings saved. Applied on the next request.",
50+
"dash.sidecarSaveFailed": "Failed to save sidecar settings.",
4451

4552
// providers
4653
"prov.subtitle": "Configure the upstream providers opencodex routes into Codex. Log in with an account, add a provider, or edit the raw config.",
Collapse file

‎gui/src/i18n/ko.ts‎

Copy file name to clipboardExpand all lines: gui/src/i18n/ko.ts
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ export const ko: Record<TKey, string> = {
4141
"dash.stopping": "중지 중…",
4242
"dash.codexAutoStart": "Codex 실행 시 opencodex 시작",
4343
"dash.codexAutoStartHint": "켜져 있으면 Codex CLI/App 실행 전 shim이 ocx ensure를 실행합니다. 끄면 Codex를 건드리지 않습니다.",
44+
"dash.searchModel": "서치 사이드카 모델",
45+
"dash.searchModelHint": "비-OpenAI 라우팅 모델의 web_search에 사용되는 모델입니다. ChatGPT 로그인 필요.",
46+
"dash.searchReasoning": "서치 추론 강도",
47+
"dash.visionModel": "비전 사이드카 모델",
48+
"dash.visionModelHint": "텍스트 전용 라우팅 모델에 이미지를 설명하는 데 사용되는 모델입니다. ChatGPT 로그인 필요.",
49+
"dash.sidecarSaved": "사이드카 설정이 저장됐습니다. 다음 요청부터 적용됩니다.",
50+
"dash.sidecarSaveFailed": "사이드카 설정 저장에 실패했습니다.",
4451

4552
// providers
4653
"prov.subtitle": "opencodex가 Codex로 라우팅하는 업스트림 프로바이더를 설정합니다. 계정으로 로그인하거나, 프로바이더를 추가하거나, 원본 설정을 편집하세요.",
Collapse file

‎gui/src/i18n/zh.ts‎

Copy file name to clipboardExpand all lines: gui/src/i18n/zh.ts
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ export const zh: Record<TKey, string> = {
4141
"dash.stopping": "正在停止…",
4242
"dash.codexAutoStart": "随 Codex 启动 opencodex",
4343
"dash.codexAutoStartHint": "启用后,Codex shim 会在每次 Codex CLI/App 启动前运行 ocx ensure。关闭后不会改动 Codex。",
44+
"dash.searchModel": "搜索附属模型",
45+
"dash.searchModelHint": "用于非 OpenAI 路由模型的 web_search 的模型。需要 ChatGPT 登录。",
46+
"dash.searchReasoning": "搜索推理强度",
47+
"dash.visionModel": "视觉附属模型",
48+
"dash.visionModelHint": "为纯文本路由模型描述图像的模型。需要 ChatGPT 登录。",
49+
"dash.sidecarSaved": "附属设置已保存。将在下一个请求时生效。",
50+
"dash.sidecarSaveFailed": "保存附属设置失败。",
4451

4552
// providers
4653
"prov.subtitle": "配置 opencodex 路由到 Codex 的上游提供方。使用账户登录、添加提供方,或编辑原始配置。",
Collapse file

‎gui/src/pages/Dashboard.tsx‎

Copy file name to clipboardExpand all lines: gui/src/pages/Dashboard.tsx
+66-1Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,36 @@ interface HealthData { status: string; version: string; uptime: number }
66
interface ProviderInfo { name: string; adapter: string; baseUrl: string; defaultModel?: string; hasApiKey: boolean }
77
interface ModelInfo { id: string; provider: string; owned_by?: string }
88
interface SettingsData { codexAutoStart: boolean; port: number; hostname: string }
9+
interface SidecarData { webSearch: { model: string; reasoning: string }; vision: { model: string } }
10+
11+
const SIDECAR_MODELS = ["gpt-5.4-mini", "gpt-5.4", "gpt-5.5", "gpt-5.3-codex-spark"];
12+
const REASONING_LEVELS = ["low", "medium", "high"];
913

1014
export default function Dashboard({ apiBase }: { apiBase: string }) {
1115
const t = useT();
1216
const [health, setHealth] = useState<HealthData | null>(null);
1317
const [providers, setProviders] = useState<ProviderInfo[]>([]);
1418
const [models, setModels] = useState<ModelInfo[]>([]);
1519
const [settings, setSettings] = useState<SettingsData | null>(null);
20+
const [sidecar, setSidecar] = useState<SidecarData | null>(null);
21+
const [sidecarSaving, setSidecarSaving] = useState(false);
1622
const [modelsLoading, setModelsLoading] = useState(false);
1723
const [settingsSaving, setSettingsSaving] = useState(false);
1824
const [error, setError] = useState(false);
1925

2026
useEffect(() => {
2127
const fetchData = async () => {
2228
try {
23-
const [hRes, pRes, sRes] = await Promise.all([
29+
const [hRes, pRes, sRes, scRes] = await Promise.all([
2430
fetch(`${apiBase}/healthz`),
2531
fetch(`${apiBase}/api/providers`),
2632
fetch(`${apiBase}/api/settings`),
33+
fetch(`${apiBase}/api/sidecar-settings`),
2734
]);
2835
setHealth(await hRes.json());
2936
setProviders(await pRes.json());
3037
setSettings(await sRes.json());
38+
setSidecar(await scRes.json());
3139
setError(false);
3240
} catch {
3341
setError(true);
@@ -66,6 +74,30 @@ export default function Dashboard({ apiBase }: { apiBase: string }) {
6674

6775
const online = health?.status === "ok";
6876

77+
const saveSidecar = async (patch: Partial<SidecarData>) => {
78+
if (!sidecar || sidecarSaving) return;
79+
const next = {
80+
webSearch: { ...sidecar.webSearch, ...patch.webSearch },
81+
vision: { ...sidecar.vision, ...patch.vision },
82+
};
83+
setSidecarSaving(true);
84+
setSidecar(next);
85+
try {
86+
const res = await fetch(`${apiBase}/api/sidecar-settings`, {
87+
method: "PUT",
88+
headers: { "Content-Type": "application/json" },
89+
body: JSON.stringify(next),
90+
});
91+
if (!res.ok) throw new Error("save failed");
92+
const data = await res.json();
93+
setSidecar({ webSearch: data.webSearch, vision: data.vision });
94+
} catch {
95+
setSidecar(sidecar);
96+
} finally {
97+
setSidecarSaving(false);
98+
}
99+
};
100+
69101
const toggleCodexAutoStart = async () => {
70102
if (!settings || settingsSaving) return;
71103
const next = !settings.codexAutoStart;
@@ -82,6 +114,7 @@ export default function Dashboard({ apiBase }: { apiBase: string }) {
82114
setSettings(prev => prev ? { ...prev, codexAutoStart: data.codexAutoStart } : prev);
83115
} catch {
84116
setSettings(prev => prev ? { ...prev, codexAutoStart: !next } : prev);
117+
setError(true);
85118
} finally {
86119
setSettingsSaving(false);
87120
}
@@ -122,6 +155,38 @@ export default function Dashboard({ apiBase }: { apiBase: string }) {
122155
</div>
123156
</div>
124157

158+
<div className="panel" style={{ marginBottom: 12 }}>
159+
<div className="spread" style={{ alignItems: "flex-start" }}>
160+
<div style={{ flex: 1 }}>
161+
<div style={{ fontWeight: 650 }}>{t("dash.searchModel")}</div>
162+
<div className="muted" style={{ fontSize: 13, marginTop: 3 }}>{t("dash.searchModelHint")}</div>
163+
</div>
164+
<div style={{ display: "flex", gap: 8 }}>
165+
<select className="select-sm" value={sidecar?.webSearch.model ?? "gpt-5.4-mini"} disabled={!sidecar || sidecarSaving}
166+
onChange={e => saveSidecar({ webSearch: { model: e.target.value, reasoning: sidecar!.webSearch.reasoning } })}>
167+
{SIDECAR_MODELS.map(m => <option key={m} value={m}>{m}</option>)}
168+
</select>
169+
<select className="select-sm" value={sidecar?.webSearch.reasoning ?? "low"} disabled={!sidecar || sidecarSaving}
170+
onChange={e => saveSidecar({ webSearch: { model: sidecar!.webSearch.model, reasoning: e.target.value } })}>
171+
{REASONING_LEVELS.map(r => <option key={r} value={r}>{r}</option>)}
172+
</select>
173+
</div>
174+
</div>
175+
</div>
176+
177+
<div className="panel" style={{ marginBottom: 24 }}>
178+
<div className="spread">
179+
<div style={{ flex: 1 }}>
180+
<div style={{ fontWeight: 650 }}>{t("dash.visionModel")}</div>
181+
<div className="muted" style={{ fontSize: 13, marginTop: 3 }}>{t("dash.visionModelHint")}</div>
182+
</div>
183+
<select className="select-sm" value={sidecar?.vision.model ?? "gpt-5.4-mini"} disabled={!sidecar || sidecarSaving}
184+
onChange={e => saveSidecar({ vision: { model: e.target.value } })}>
185+
{SIDECAR_MODELS.map(m => <option key={m} value={m}>{m}</option>)}
186+
</select>
187+
</div>
188+
</div>
189+
125190
<div className="h-section">{t("dash.activeProviders")} <span className="count">{providers.length}</span></div>
126191
{providers.length === 0 ? (
127192
<div className="empty"><Trans k="dash.noProviders" cmd="ocx init" /></div>
Collapse file

‎gui/src/styles.css‎

Copy file name to clipboardExpand all lines: gui/src/styles.css
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
211211
textarea.input { resize: vertical; font-family: var(--mono); line-height: 1.55; }
212212
.field-label { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 5px; display: block; }
213213
select.input { appearance: none; }
214+
.select-sm {
215+
padding: 5px 8px; border-radius: var(--radius-sm); background: var(--raised); border: 1px solid var(--border);
216+
color: var(--text); font: inherit; font-size: 13px; cursor: pointer; transition: border-color 0.12s;
217+
}
218+
.select-sm:focus { border-color: var(--accent); outline: none; }
219+
.select-sm:disabled { opacity: 0.5; cursor: default; }
214220

215221
/* ---- switch ---- */
216222
.switch { width: 34px; height: 19px; border-radius: 99px; border: none; cursor: pointer; background: light-dark(#c5c9d2, #3a3f4b); position: relative; flex-shrink: 0; transition: background 0.15s; padding: 0; }
Collapse file

‎src/adapters/openai-chat.ts‎

Copy file name to clipboardExpand all lines: src/adapters/openai-chat.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export function createOpenAIChatAdapter(provider: OcxProviderConfig): ProviderAd
160160
stream: parsed.stream,
161161
};
162162
if (tools) body.tools = tools;
163-
if (toolChoice !== undefined) {
163+
if (tools && toolChoice !== undefined) {
164164
body.tool_choice = modelInList(provider.autoToolChoiceOnlyModels, parsed.modelId)
165165
? (toolChoice === "none" ? "none" : "auto")
166166
: toolChoice;
Collapse file

‎src/cli.ts‎

Copy file name to clipboardExpand all lines: src/cli.ts
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ async function handleEnsure() {
159159
return;
160160
}
161161
if (await proxyHealthy(config.port)) {
162-
await syncModelsToCodex(config.port).catch(() => {});
162+
await syncModelsToCodex(config.port).catch(e => {
163+
console.error(`⚠️ Model sync skipped: ${e instanceof Error ? e.message : String(e)}`);
164+
});
163165
console.log(`✅ Proxy running on port ${config.port}`);
164166
return;
165167
}
@@ -177,7 +179,9 @@ async function handleEnsure() {
177179
process.exit(1);
178180
}
179181
config = loadConfig();
180-
await syncModelsToCodex(config.port ?? port).catch(() => {});
182+
await syncModelsToCodex(config.port ?? port).catch(e => {
183+
console.error(`⚠️ Model sync skipped: ${e instanceof Error ? e.message : String(e)}`);
184+
});
181185
console.log(`✅ Proxy running on port ${config.port ?? port}`);
182186
}
183187

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.