feat: refine codex live chat flow
This commit is contained in:
@@ -18,6 +18,7 @@ export type AppConfig = {
|
||||
chat: {
|
||||
maxContextMessages: number;
|
||||
maxContextChars: number;
|
||||
codexLiveMaxExecutionSeconds: number;
|
||||
};
|
||||
automation: {
|
||||
autoRefreshEnabled: boolean;
|
||||
@@ -70,6 +71,7 @@ export const DEFAULT_APP_CONFIG: AppConfig = {
|
||||
chat: {
|
||||
maxContextMessages: 12,
|
||||
maxContextChars: 3200,
|
||||
codexLiveMaxExecutionSeconds: 600,
|
||||
},
|
||||
automation: {
|
||||
autoRefreshEnabled: true,
|
||||
@@ -243,6 +245,14 @@ function normalizeChatContextCharLimit(value: number | undefined, fallback: numb
|
||||
return Math.min(20_000, Math.max(500, Math.round(value)));
|
||||
}
|
||||
|
||||
function normalizeCodexLiveMaxExecutionSeconds(value: number | undefined, fallback: number) {
|
||||
if (value === undefined || !Number.isFinite(value)) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
return Math.min(7200, Math.max(60, Math.round(value)));
|
||||
}
|
||||
|
||||
function normalizeConfig(raw?: Partial<AppConfig>): AppConfig {
|
||||
const chat = raw?.chat;
|
||||
const automation = raw?.automation;
|
||||
@@ -258,6 +268,10 @@ function normalizeConfig(raw?: Partial<AppConfig>): AppConfig {
|
||||
DEFAULT_APP_CONFIG.chat.maxContextMessages,
|
||||
),
|
||||
maxContextChars: normalizeChatContextCharLimit(chat?.maxContextChars, DEFAULT_APP_CONFIG.chat.maxContextChars),
|
||||
codexLiveMaxExecutionSeconds: normalizeCodexLiveMaxExecutionSeconds(
|
||||
chat?.codexLiveMaxExecutionSeconds,
|
||||
DEFAULT_APP_CONFIG.chat.codexLiveMaxExecutionSeconds,
|
||||
),
|
||||
},
|
||||
automation: {
|
||||
autoRefreshEnabled: automation?.autoRefreshEnabled ?? DEFAULT_APP_CONFIG.automation.autoRefreshEnabled,
|
||||
|
||||
Reference in New Issue
Block a user