feat: add configurable token_refresh_interval_hours to runtime settings with validation and hot-reload support

This commit is contained in:
CJACK
2026-03-30 01:41:13 +08:00
parent af7c7c6770
commit 822b14ed6b
25 changed files with 300 additions and 41 deletions

View File

@@ -2,7 +2,7 @@ export default function RuntimeSection({ t, form, setForm }) {
return (
<div className="bg-card border border-border rounded-xl p-5 space-y-4">
<h3 className="font-semibold">{t('settings.runtimeTitle')}</h3>
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<label className="text-sm space-y-2">
<span className="text-muted-foreground">{t('settings.accountMaxInflight')}</span>
<input
@@ -42,6 +42,21 @@ export default function RuntimeSection({ t, form, setForm }) {
className="w-full bg-background border border-border rounded-lg px-3 py-2"
/>
</label>
<label className="text-sm space-y-2">
<span className="text-muted-foreground">{t('settings.tokenRefreshIntervalHours')}</span>
<input
type="number"
min={1}
max={720}
step={1}
value={form.runtime.token_refresh_interval_hours}
onChange={(e) => setForm((prev) => ({
...prev,
runtime: { ...prev.runtime, token_refresh_interval_hours: Number(e.target.value || 1) },
}))}
className="w-full bg-background border border-border rounded-lg px-3 py-2"
/>
</label>
</div>
</div>
)

View File

@@ -12,7 +12,7 @@ const MAX_AUTO_FETCH_FAILURES = 3
const DEFAULT_FORM = {
admin: { jwt_expire_hours: 24 },
runtime: { account_max_inflight: 2, account_max_queue: 10, global_max_inflight: 10 },
runtime: { account_max_inflight: 2, account_max_queue: 10, global_max_inflight: 10, token_refresh_interval_hours: 6 },
toolcall: { mode: 'feature_match', early_emit_confidence: 'high' },
responses: { store_ttl_seconds: 900 },
embeddings: { provider: '' },
@@ -45,6 +45,7 @@ function fromServerForm(data) {
account_max_inflight: Number(data.runtime?.account_max_inflight || 2),
account_max_queue: Number(data.runtime?.account_max_queue || 10),
global_max_inflight: Number(data.runtime?.global_max_inflight || 10),
token_refresh_interval_hours: Number(data.runtime?.token_refresh_interval_hours || 6),
},
toolcall: {
mode: data.toolcall?.mode || 'feature_match',
@@ -71,6 +72,7 @@ function toServerPayload(form) {
account_max_inflight: Number(form.runtime.account_max_inflight),
account_max_queue: Number(form.runtime.account_max_queue),
global_max_inflight: Number(form.runtime.global_max_inflight),
token_refresh_interval_hours: Number(form.runtime.token_refresh_interval_hours),
},
toolcall: {
mode: String(form.toolcall.mode || '').trim(),

View File

@@ -222,10 +222,11 @@
"passwordTooShort": "Password must be at least 4 characters.",
"passwordUpdated": "Password updated. Please sign in again.",
"passwordUpdateFailed": "Failed to update password.",
"runtimeTitle": "Concurrency & Queue",
"runtimeTitle": "Runtime",
"accountMaxInflight": "Per-account max inflight",
"accountMaxQueue": "Account max queue size",
"globalMaxInflight": "Global max inflight",
"tokenRefreshIntervalHours": "Managed token refresh interval (hours)",
"behaviorTitle": "Behavior",
"toolcallMode": "Toolcall mode",
"earlyEmitConfidence": "Early emit confidence",

View File

@@ -222,10 +222,11 @@
"passwordTooShort": "新密码至少 4 位",
"passwordUpdated": "密码已更新,需重新登录",
"passwordUpdateFailed": "密码更新失败",
"runtimeTitle": "并发与队列",
"runtimeTitle": "运行时设置",
"accountMaxInflight": "每账号并发上限",
"accountMaxQueue": "账号等待队列上限",
"globalMaxInflight": "全局并发上限",
"tokenRefreshIntervalHours": "托管账号 Token 刷新间隔(小时)",
"behaviorTitle": "行为设置",
"toolcallMode": "Toolcall 模式",
"earlyEmitConfidence": "早发置信度",