fix(ena-planner): persist active template and extend default keep tags
This commit is contained in:
@@ -258,7 +258,7 @@
|
||||
<div class="card-title">聊天与历史</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">保留的规划输出标签(逗号分隔)</label>
|
||||
<input id="ep_keep_tags" type="text" class="input" placeholder="plot, note">
|
||||
<input id="ep_keep_tags" type="text" class="input" placeholder="plot, note, plot-log, state">
|
||||
<p class="form-hint">仅支持英文标签(如 plot, note, memory)。留空表示不按标签过滤(仅去除 think)。无效标签会自动忽略。</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -684,7 +684,7 @@
|
||||
$('ep_wb_pos4').value = String(toBool(cfg.excludeWorldbookPosition4, true));
|
||||
$('ep_wb_exclude_names').value = arrToCsv(cfg.worldbookExcludeNames);
|
||||
$('ep_plot_n').value = String(toNum(cfg.plotCount, 2));
|
||||
$('ep_keep_tags').value = arrToCsv(cfg.responseKeepTags || ['plot', 'note']);
|
||||
$('ep_keep_tags').value = arrToCsv(cfg.responseKeepTags || ['plot', 'note', 'plot-log', 'state']);
|
||||
$('ep_exclude_tags').value = arrToCsv(cfg.chatExcludeTags);
|
||||
|
||||
$('ep_logs_persist').value = String(toBool(cfg.logsPersist, true));
|
||||
@@ -692,7 +692,7 @@
|
||||
|
||||
setBadge(toBool(cfg.enabled, true));
|
||||
updatePrefixModeUI();
|
||||
const keepSelectedTemplate = $('ep_tpl_select')?.value || '';
|
||||
const keepSelectedTemplate = cfg?.activePromptTemplate || $('ep_tpl_select')?.value || '';
|
||||
renderTemplateSelect(keepSelectedTemplate);
|
||||
renderPromptList();
|
||||
renderLogs();
|
||||
@@ -732,6 +732,7 @@
|
||||
|
||||
p.promptBlocks = cfg?.promptBlocks || [];
|
||||
p.promptTemplates = cfg?.promptTemplates || {};
|
||||
p.activePromptTemplate = $('ep_tpl_select')?.value || '';
|
||||
|
||||
return p;
|
||||
}
|
||||
@@ -799,6 +800,7 @@
|
||||
|
||||
$('ep_tpl_select').addEventListener('change', () => {
|
||||
const name = $('ep_tpl_select').value;
|
||||
cfg.activePromptTemplate = name;
|
||||
if (!name) return;
|
||||
const blocks = cfg?.promptTemplates?.[name];
|
||||
if (!Array.isArray(blocks)) return;
|
||||
@@ -811,6 +813,7 @@
|
||||
if (!name) { setSaveIndicator('error', '请先选择或创建模板'); return; }
|
||||
cfg.promptTemplates = cfg.promptTemplates || {};
|
||||
cfg.promptTemplates[name] = structuredClone(cfg.promptBlocks || []);
|
||||
cfg.activePromptTemplate = name;
|
||||
renderTemplateSelect(name); scheduleSave();
|
||||
});
|
||||
|
||||
@@ -819,6 +822,7 @@
|
||||
if (!name) return;
|
||||
cfg.promptTemplates = cfg.promptTemplates || {};
|
||||
cfg.promptTemplates[name] = structuredClone(cfg.promptBlocks || []);
|
||||
cfg.activePromptTemplate = name;
|
||||
renderTemplateSelect(name); scheduleSave();
|
||||
});
|
||||
|
||||
@@ -827,6 +831,7 @@
|
||||
if (!name) return;
|
||||
const backup = structuredClone(cfg.promptTemplates[name]);
|
||||
delete cfg.promptTemplates[name];
|
||||
cfg.activePromptTemplate = '';
|
||||
renderTemplateSelect('');
|
||||
showUndoBar(name, backup);
|
||||
});
|
||||
@@ -835,6 +840,7 @@
|
||||
if (!undoState) return;
|
||||
cfg.promptTemplates = cfg.promptTemplates || {};
|
||||
cfg.promptTemplates[undoState.name] = undoState.blocks;
|
||||
cfg.activePromptTemplate = undoState.name;
|
||||
renderTemplateSelect(undoState.name);
|
||||
clearUndo(); scheduleSave();
|
||||
});
|
||||
|
||||
@@ -33,12 +33,14 @@ function getDefaultSettings() {
|
||||
// Plot extraction
|
||||
plotCount: 2,
|
||||
// Planner response tags to keep, in source order (empty = keep full response)
|
||||
responseKeepTags: ['plot', 'note'],
|
||||
responseKeepTags: ['plot', 'note', 'plot-log', 'state'],
|
||||
|
||||
// Planner prompts (designer)
|
||||
promptBlocks: structuredClone(DEFAULT_PROMPT_BLOCKS),
|
||||
// Saved prompt templates: { name: promptBlocks[] }
|
||||
promptTemplates: structuredClone(BUILTIN_TEMPLATES),
|
||||
// Currently selected prompt template name in UI
|
||||
activePromptTemplate: '',
|
||||
|
||||
// Planner API
|
||||
api: {
|
||||
|
||||
Reference in New Issue
Block a user