refactor: replace history_split with current_input_file configuration

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
CJACK
2026-04-27 23:36:56 +08:00
parent 1e9170e385
commit 28bb85ad63
33 changed files with 184 additions and 517 deletions

View File

@@ -1,51 +1,9 @@
export default function HistorySplitSection({ t, form, setForm }) {
export default function CurrentInputFileSection({ t, form, setForm }) {
return (
<div className="bg-card border border-border rounded-xl p-5 space-y-4">
<div className="space-y-1">
<h3 className="font-semibold">{t('settings.historySplitTitle')}</h3>
<p className="text-sm text-muted-foreground">{t('settings.historySplitDesc')}</p>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<label className="flex items-start gap-3 rounded-lg border border-border bg-background/60 p-4">
<input
type="checkbox"
checked={Boolean(form.history_split?.enabled)}
onChange={(e) => setForm((prev) => ({
...prev,
history_split: {
...prev.history_split,
enabled: e.target.checked,
},
current_input_file: {
...prev.current_input_file,
enabled: e.target.checked ? false : Boolean(prev.current_input_file?.enabled),
},
}))}
className="mt-1 h-4 w-4 rounded border-border"
/>
<div className="space-y-1">
<span className="text-sm font-medium block">{t('settings.historySplitEnabled')}</span>
<span className="text-xs text-muted-foreground block">{t('settings.historySplitEnabledDesc')}</span>
</div>
</label>
<label className="text-sm space-y-2">
<span className="text-muted-foreground">{t('settings.historySplitTriggerAfterTurns')}</span>
<input
type="number"
min={1}
max={1000}
value={form.history_split?.trigger_after_turns || 1}
onChange={(e) => setForm((prev) => ({
...prev,
history_split: {
...prev.history_split,
trigger_after_turns: Number(e.target.value || 1),
},
}))}
className="w-full bg-background border border-border rounded-lg px-3 py-2"
/>
<p className="text-xs text-muted-foreground">{t('settings.historySplitTriggerHelp')}</p>
</label>
<h3 className="font-semibold">{t('settings.currentInputFileTitle')}</h3>
<p className="text-sm text-muted-foreground">{t('settings.currentInputFileDesc')}</p>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<label className="flex items-start gap-3 rounded-lg border border-border bg-background/60 p-4">
@@ -54,10 +12,6 @@ export default function HistorySplitSection({ t, form, setForm }) {
checked={Boolean(form.current_input_file?.enabled)}
onChange={(e) => setForm((prev) => ({
...prev,
history_split: {
...prev.history_split,
enabled: e.target.checked ? false : Boolean(prev.history_split?.enabled),
},
current_input_file: {
...prev.current_input_file,
enabled: e.target.checked,
@@ -89,7 +43,6 @@ export default function HistorySplitSection({ t, form, setForm }) {
<p className="text-xs text-muted-foreground">{t('settings.currentInputFileHelp')}</p>
</label>
</div>
<p className="text-xs text-muted-foreground">{t('settings.splitPassThroughHelp')}</p>
</div>
)
}

View File

@@ -5,7 +5,7 @@ import { useSettingsForm } from './useSettingsForm'
import SecuritySection from './SecuritySection'
import RuntimeSection from './RuntimeSection'
import BehaviorSection from './BehaviorSection'
import HistorySplitSection from './HistorySplitSection'
import CurrentInputFileSection from './HistorySplitSection'
import CompatibilitySection from './CompatibilitySection'
import AutoDeleteSection from './AutoDeleteSection'
import ModelSection from './ModelSection'
@@ -96,7 +96,7 @@ export default function SettingsContainer({ onRefresh, onMessage, authFetch, onF
<BehaviorSection t={t} form={form} setForm={setForm} />
<HistorySplitSection t={t} form={form} setForm={setForm} />
<CurrentInputFileSection t={t} form={form} setForm={setForm} />
<CompatibilitySection t={t} form={form} setForm={setForm} />

View File

@@ -17,7 +17,6 @@ const DEFAULT_FORM = {
responses: { store_ttl_seconds: 900 },
embeddings: { provider: '' },
auto_delete: { mode: 'none' },
history_split: { enabled: false, trigger_after_turns: 1 },
current_input_file: { enabled: true, min_chars: 0 },
thinking_injection: { enabled: true, prompt: '', default_prompt: '' },
model_aliases_text: '{}',
@@ -52,8 +51,7 @@ function normalizeAutoDeleteMode(raw) {
}
function fromServerForm(data) {
const historySplitEnabled = Boolean(data.history_split?.enabled)
const currentInputFileEnabled = historySplitEnabled ? false : (data.current_input_file?.enabled ?? true)
const currentInputFileEnabled = data.current_input_file?.enabled ?? true
return {
admin: { jwt_expire_hours: Number(data.admin?.jwt_expire_hours || 24) },
runtime: {
@@ -74,10 +72,6 @@ function fromServerForm(data) {
auto_delete: {
mode: normalizeAutoDeleteMode(data.auto_delete),
},
history_split: {
enabled: historySplitEnabled,
trigger_after_turns: Number(data.history_split?.trigger_after_turns || 1),
},
current_input_file: {
enabled: currentInputFileEnabled,
min_chars: Number(data.current_input_file?.min_chars ?? 0),
@@ -92,8 +86,7 @@ function fromServerForm(data) {
}
function toServerPayload(form) {
const historySplitEnabled = Boolean(form.history_split?.enabled)
const currentInputFileEnabled = historySplitEnabled ? false : Boolean(form.current_input_file?.enabled)
const currentInputFileEnabled = Boolean(form.current_input_file?.enabled)
return {
admin: { jwt_expire_hours: Number(form.admin.jwt_expire_hours) },
runtime: {
@@ -108,10 +101,6 @@ function toServerPayload(form) {
responses: { store_ttl_seconds: Number(form.responses.store_ttl_seconds) },
embeddings: { provider: String(form.embeddings.provider || '').trim() },
auto_delete: { mode: normalizeAutoDeleteMode(form.auto_delete) },
history_split: {
enabled: historySplitEnabled,
trigger_after_turns: Number(form.history_split?.trigger_after_turns || 1),
},
current_input_file: {
enabled: currentInputFileEnabled,
min_chars: Number(form.current_input_file?.min_chars ?? 0),

View File

@@ -385,17 +385,11 @@
"thinkingInjectionDesc": "Append a structured <think> checklist to the latest user message before prompt assembly.",
"thinkingInjectionPrompt": "Thinking format prompt",
"thinkingInjectionPromptHelp": "Leave empty to use the built-in default prompt shown as the input placeholder.",
"historySplitTitle": "Context Split",
"historySplitDesc": "Choose one context-splitting mode to avoid inlining very long prompts.",
"historySplitEnabled": "Turn split (second turn by default)",
"historySplitEnabledDesc": "After the configured user-turn threshold, pack earlier conversation into HISTORY.txt.",
"historySplitTriggerAfterTurns": "Trigger threshold (user turns)",
"historySplitTriggerHelp": "Default is 1, which means history split starts from the second turn.",
"currentInputFileTitle": "Independent Split",
"currentInputFileEnabled": "Independent split (by size)",
"currentInputFileDesc": "After the character threshold is reached, upload the full context as a hidden context file and skip HISTORY.txt.",
"currentInputFileDesc": "Enabled by default. Once the character threshold is reached, upload the full context as a hidden context file.",
"currentInputFileMinChars": "Current input threshold (characters)",
"currentInputFileHelp": "Default is 0, which uses independent split whenever there is input.",
"splitPassThroughHelp": "Turn split and independent split are mutually exclusive; choose at most one. If both are unchecked, requests pass through directly without uploading split context files.",
"currentInputFileHelp": "Default is 0, which uses independent split for any non-empty input.",
"compatibilityTitle": "Compatibility",
"compatibilityDesc": "Compatibility controls that keep stream output closer to the wire format or safer for the web UI.",
"stripReferenceMarkers": "Strip [reference:N] markers",

View File

@@ -385,17 +385,11 @@
"thinkingInjectionDesc": "在组装 prompt 前,将结构化 <think> 检查清单追加到最新用户消息末尾。",
"thinkingInjectionPrompt": "思考格式提示词",
"thinkingInjectionPromptHelp": "留空时使用内置默认提示词;默认内容会显示在输入框占位文本中。",
"historySplitTitle": "上下文拆分",
"historySplitDesc": "选择一种上下文拆分方式,减少超长 prompt 直接内联。",
"historySplitEnabled": "轮次拆分(默认第二轮)",
"historySplitEnabledDesc": "从配置的用户回合数之后,将更早的对话整理成 HISTORY.txt。",
"historySplitTriggerAfterTurns": "触发阈值(用户回合数)",
"historySplitTriggerHelp": "默认值为 1表示从第二轮开始拆分历史。",
"currentInputFileTitle": "独立拆分",
"currentInputFileEnabled": "独立拆分(按量)",
"currentInputFileDesc": "达到字符阈值后,将完整上下文上传为隐藏上下文文件,并跳过 HISTORY.txt。",
"currentInputFileDesc": "默认开启。达到字符阈值后,将完整上下文上传为隐藏上下文文件。",
"currentInputFileMinChars": "当前输入阈值(字符数)",
"currentInputFileHelp": "默认 0表示有输入就使用独立拆分。",
"splitPassThroughHelp": "轮次拆分和独立拆分互斥,只能选择一种;如果都不勾选,请求会直接透传,不上传拆分上下文文件。",
"currentInputFileHelp": "默认 0表示只要有输入就使用独立拆分。",
"compatibilityTitle": "兼容性设置",
"compatibilityDesc": "用于控制输出格式兼容性,避免把模型原始流里的标记直接暴露到前端。",
"stripReferenceMarkers": "移除 [reference:N] 标记",