fix: GUI improvements, CROF gate, data dir consolidation, sticky proxy port
- GUI: add Clear Log, Restart Proxy, View Log (opens requests.log) buttons - CROF: skip entirely unless TARGET_URL contains crof.ai (no logs pollution) - Consolidate all data dirs into codex-proxy (remove codex-desktop, codex-launcher) - Proxy port persists across restarts via .last-proxy-port file - Adaptive compact budget raised from 60% to 80% context window - Startup config cleanup moved after _init_runtime() to avoid deleting active config
This commit is contained in:
@@ -41,8 +41,8 @@ if IS_WINDOWS:
|
||||
PROXY_CONFIG_DIR = _LOCAL_APPDATA / "codex-proxy"
|
||||
CONFIG_DIR = HOME / ".codex"
|
||||
BIN_DIR = _LOCAL_APPDATA / "Programs" / "Codex-Launcher"
|
||||
LOG_DIR = _LOCAL_APPDATA / "codex-desktop"
|
||||
PID_REGISTRY = _LOCAL_APPDATA / "codex-launcher" / "pids.json"
|
||||
LOG_DIR = _LOCAL_APPDATA / "codex-proxy"
|
||||
PID_REGISTRY = _LOCAL_APPDATA / "codex-proxy" / "pids.json"
|
||||
_USAGE_STATS_FILE = _LOCAL_APPDATA / "codex-proxy" / "usage-stats.json"
|
||||
MONITORING_FILE = _LOCAL_APPDATA / "codex-proxy" / "monitoring-config.json"
|
||||
INCIDENT_STORE_FILE = _LOCAL_APPDATA / "codex-proxy" / "incident-store.json"
|
||||
@@ -52,8 +52,8 @@ else:
|
||||
PROXY_CONFIG_DIR = HOME / ".cache/codex-proxy"
|
||||
CONFIG_DIR = HOME / ".codex"
|
||||
BIN_DIR = HOME / ".local/bin"
|
||||
LOG_DIR = HOME / ".cache/codex-desktop"
|
||||
PID_REGISTRY = HOME / ".cache" / "codex-launcher" / "pids.json"
|
||||
LOG_DIR = HOME / ".cache/codex-proxy"
|
||||
PID_REGISTRY = HOME / ".cache/codex-proxy" / "pids.json"
|
||||
_USAGE_STATS_FILE = HOME / ".cache/codex-proxy/usage-stats.json"
|
||||
MONITORING_FILE = HOME / ".cache/codex-proxy/monitoring-config.json"
|
||||
INCIDENT_STORE_FILE = HOME / ".cache/codex-proxy/incident-store.json"
|
||||
@@ -1388,9 +1388,18 @@ def safe_cleanup_owned(logfn=None):
|
||||
|
||||
_proxy_proc = None
|
||||
_proxy_port = None
|
||||
_PROXY_PORT_FILE = PROXY_CONFIG_DIR / ".last-proxy-port"
|
||||
|
||||
|
||||
def _pick_free_port():
|
||||
saved = None
|
||||
try:
|
||||
saved = int(_PROXY_PORT_FILE.read_text().strip())
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.bind(("127.0.0.1", saved))
|
||||
return saved
|
||||
except (ValueError, OSError, FileNotFoundError):
|
||||
pass
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.bind(("127.0.0.1", 0))
|
||||
return s.getsockname()[1]
|
||||
@@ -1421,6 +1430,8 @@ def start_proxy_for(endpoint, logfn):
|
||||
stop_proxy()
|
||||
port = _pick_free_port()
|
||||
_proxy_port = port
|
||||
_PROXY_PORT_FILE.parent.mkdir(parents=True, exist_ok=True)
|
||||
_PROXY_PORT_FILE.write_text(str(port))
|
||||
|
||||
model_list = endpoint.get("models", [])
|
||||
if (endpoint.get("backend_type") or "").startswith("gemini-oauth") and (endpoint.get("oauth_provider") or "").startswith("google"):
|
||||
@@ -1507,6 +1518,8 @@ def start_bgp_proxy(pool, model, logfn):
|
||||
stop_proxy()
|
||||
port = _pick_free_port()
|
||||
_proxy_port = port
|
||||
_PROXY_PORT_FILE.parent.mkdir(parents=True, exist_ok=True)
|
||||
_PROXY_PORT_FILE.write_text(str(port))
|
||||
|
||||
bgp_ep = {
|
||||
"name": pool["name"],
|
||||
|
||||
Reference in New Issue
Block a user