feat: improve codex app controls and recovery
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
const CODEX_APP_ONCE_NOTICE_PATTERNS = [
|
||||
/^Under-development features enabled:/i,
|
||||
/^Heads up: Long threads and multiple compactions/i,
|
||||
];
|
||||
|
||||
function createCodexAppRuntime(deps = {}) {
|
||||
const {
|
||||
wsSend,
|
||||
@@ -14,6 +19,23 @@ function createCodexAppRuntime(deps = {}) {
|
||||
return text.length > maxLen ? `${text.slice(0, maxLen)}...` : value;
|
||||
}
|
||||
|
||||
const shownOnceNoticeKeys = new Set();
|
||||
|
||||
function normalizeNoticeMessage(message) {
|
||||
return String(message || '').trim().replace(/\s+/g, ' ');
|
||||
}
|
||||
|
||||
function shouldShowRuntimeNotice(method, message) {
|
||||
const normalized = normalizeNoticeMessage(message);
|
||||
const isOnceNotice = CODEX_APP_ONCE_NOTICE_PATTERNS.some((pattern) => pattern.test(normalized));
|
||||
if (!isOnceNotice) return true;
|
||||
|
||||
const key = `${method}:${normalized}`;
|
||||
if (shownOnceNoticeKeys.has(key)) return false;
|
||||
shownOnceNoticeKeys.add(key);
|
||||
return true;
|
||||
}
|
||||
|
||||
function sendRuntime(entry, sessionId, payload) {
|
||||
wsSend(entry.ws, { ...payload, sessionId });
|
||||
}
|
||||
@@ -483,7 +505,9 @@ function createCodexAppRuntime(deps = {}) {
|
||||
const message = params.message || params.title || '';
|
||||
if (message) {
|
||||
if (method === 'error') entry.lastError = message;
|
||||
sendRuntime(entry, sessionId, { type: 'system_message', message });
|
||||
if (method === 'error' || shouldShowRuntimeNotice(method, message)) {
|
||||
sendRuntime(entry, sessionId, { type: 'system_message', message });
|
||||
}
|
||||
}
|
||||
return { done: false };
|
||||
}
|
||||
|
||||
@@ -133,6 +133,10 @@ function createCodexAppServerClient(options = {}) {
|
||||
sendRaw({ method, params });
|
||||
}
|
||||
|
||||
function reloadMcpServers() {
|
||||
return request('config/mcpServer/reload', {}, 30000);
|
||||
}
|
||||
|
||||
function start() {
|
||||
if (initPromise) return initPromise;
|
||||
exited = false;
|
||||
@@ -212,6 +216,7 @@ function createCodexAppServerClient(options = {}) {
|
||||
stop,
|
||||
request,
|
||||
notification,
|
||||
reloadMcpServers,
|
||||
isRunning,
|
||||
pid: () => proc?.pid || null,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user