release: v2.2.8 [2026-06-16 15:53:20]

### 新功能
- **填表记录 · 版本恢复**(填表设置面板「回退重填」旁新增「填表记录」按钮):针对"模型填表前把整张表删空 / 误删大量内容"的反馈,提供一键找回。
  - **零新存储**:直接复用各楼层 `extra.amily2_tables_data` 里逐轮继承的表格快照——历史本就在聊天中,无需另建存储或元数据
  - 点开列出所有带快照的楼层(最新在上),可**展开预览**每一版的表格内容(CSV)后再决定
  - **恢复某版本**:把该楼层快照设为当前状态,并清除其**之后**所有楼层的快照与填表标记 hash——使该版本成为最新有效状态,后续楼层下轮自动重填会从恢复点往前重建(赌模型不再抽风)
  - 「回退重填」按钮保留,但版本恢复是更安全的找回路径
### 重构
- 抽出 `_normalizeTableState` 共用旧存档字段归一逻辑,`loadTables` 与"恢复快照"复用,消除重复
---
This commit is contained in:
Jenkins CI
2026-06-16 15:53:20 +08:00
parent cc6618a493
commit 4b2229f0f4
14 changed files with 213 additions and 329 deletions

View File

@@ -14,6 +14,7 @@ import { showContentModal, showHtmlModal, showCwbWarningModal } from './page-win
import { openAutoCharCardWindow } from '../core/auto-char-card/ui-bindings.js';
import { showPresetSettings } from '../PresetSettings/prese_ui.js';
import { watchProfileSliderGuard } from './profile-slider-guard.js';
import { refreshSuperMemoryPanel } from '../core/super-memory/bindings.js';
function displayDailyAuthCode() {
const displayEl = document.getElementById('amily2_daily_code_display');
@@ -855,6 +856,8 @@ export function bindModalEvents() {
return;
}
superMemoryPanel.show();
// 面板挂载后只渲染过一次,打开时按当前聊天的表格状态重渲染,避免显示上一个聊天的旧列表
refreshSuperMemoryPanel();
break;
case 'amily2_open_progressive_memory': {
const pmUserType = parseInt(localStorage.getItem("plugin_user_type") || "0");

View File

@@ -2017,5 +2017,59 @@ function bindFloorFillButtons() {
rollbackBtn.dataset.rollbackEventBound = 'true';
log('"回退重填"按钮已成功绑定。', 'success');
}
const fillHistoryBtn = document.getElementById('table-fill-history-btn');
if (fillHistoryBtn && !fillHistoryBtn.dataset.fillHistoryBound) {
fillHistoryBtn.addEventListener('click', () => {
const snapshots = TableManager.listFillSnapshots();
if (snapshots.length === 0) {
toastr.info('当前聊天还没有任何表格快照(先进行一次填表)。');
return;
}
// 最新在上
const itemsHtml = [...snapshots].reverse().map(s => {
const csv = escapeHTML(TableManager.getSnapshotCsv(s.index) || '(空表)');
const preview = escapeHTML(s.preview);
const roleTag = s.isUser ? '用户' : 'AI';
return `
<details style="margin-bottom:8px; border:1px solid rgba(255,255,255,0.12); border-radius:5px; padding:6px 10px;">
<summary style="cursor:pointer; color:#e0e0e0; user-select:none;">
${s.index + 1} 楼(${roleTag} · ${s.tableCount} 表 / ${s.rowCount}
<span style="color:#888; font-size:0.85em;"> ${preview}…</span>
</summary>
<pre style="white-space:pre-wrap; word-break:break-all; font-size:0.78em; color:#ccc; max-height:220px; overflow:auto; margin:8px 0; background:rgba(0,0,0,0.25); padding:8px; border-radius:4px;">${csv}</pre>
<button class="menu_button primary small_button amily2-snapshot-restore-btn" data-floor-index="${s.index}">
恢复到此版本
</button>
</details>`;
}).join('');
const html = `
<p class="notes" style="margin-top:0;">每条 = 那一轮填表后保存在该楼层的表格快照(逐轮继承)。点开可预览内容。<br>
<b>恢复某版本</b>后,其后楼层的快照与填表标记会被清除——该版本成为最新状态,后续楼层下轮会自动重填。适合救回被模型误删/清空的表格。</p>
${itemsHtml}`;
showHtmlModal('填表记录 · 版本恢复', html, {
showCancel: false,
okText: '关闭',
onShow: (dialog) => {
dialog.on('click', '.amily2-snapshot-restore-btn', async function () {
const idx = parseInt(this.getAttribute('data-floor-index'), 10);
if (Number.isNaN(idx)) return;
if (!confirm(`确定恢复到第 ${idx + 1} 楼的表格版本?\n该楼层之后的快照与填表标记将被清除。`)) return;
const ok = await TableManager.restoreToSnapshot(idx);
if (ok) {
toastr.success(`已恢复到第 ${idx + 1} 楼的表格版本。`);
dialog[0].close();
dialog.remove();
}
});
},
});
});
fillHistoryBtn.dataset.fillHistoryBound = 'true';
log('"填表记录"按钮已成功绑定。', 'success');
}
}