修复完整会话历史与长气泡交互并更新 CentOS 7 发布包
提交当前工作区全部源码、回归脚本、任务记录及重新构建的 Bun baseline 发布包。发布单文件 MCP 初始化及前端资源一致性验证通过。
This commit is contained in:
@@ -6,6 +6,7 @@ const crypto = require('node:crypto');
|
||||
const fs = require('node:fs');
|
||||
const os = require('node:os');
|
||||
const path = require('node:path');
|
||||
const { createServerHarness } = require('./session-history-store-unit');
|
||||
const source = fs.readFileSync(path.join(__dirname, '..', 'server.js'), 'utf8');
|
||||
function extract(name) {
|
||||
const start = source.indexOf(`function ${name}(`);
|
||||
@@ -140,6 +141,7 @@ check('三个历史出口使用同一 resolver,异常边界保持当前快照'
|
||||
${extract('isPersistenceNoticeMessage')}
|
||||
function loadNativeSessionHistory() { return { messages: ${JSON.stringify(native)} }; }
|
||||
function plog() {}
|
||||
const sessionHistoryStore = { state() { return null; } };
|
||||
${extract('resolveSessionHistory')}
|
||||
return resolveSessionHistory;
|
||||
`)(crypto);
|
||||
@@ -157,7 +159,8 @@ check('迁移只在 idle 执行并精确保留备份,写后可以重新加载'
|
||||
const filePath = path.join(dir, `${id}.json`);
|
||||
const original = JSON.stringify({ ...session, id });
|
||||
fs.writeFileSync(filePath, original);
|
||||
const testApi = new Function('fs', 'path', 'crypto', 'SESSIONS_DIR', 'nativeMessages', `
|
||||
const persistenceAdapter = createServerHarness(dir);
|
||||
const testApi = new Function('fs', 'path', 'crypto', 'SESSIONS_DIR', 'nativeMessages', 'persistenceAdapter', `
|
||||
${pureSource}
|
||||
${extract('isPersistenceNoticeMessage')}
|
||||
let running = true;
|
||||
@@ -165,6 +168,7 @@ check('迁移只在 idle 执行并精确保留备份,写后可以重新加载'
|
||||
const SESSION_LOAD_MAX_BYTES = 10000000;
|
||||
const sessionHistoryCache = new Map();
|
||||
const sessionSearchIndex = { scheduleUpsert() {} };
|
||||
const sessionHistoryStore = persistenceAdapter.sessionHistoryStore;
|
||||
function scheduleUsageStatisticsUpsert() {}
|
||||
function sanitizeId(id) { return id; }
|
||||
function sessionPath(id) { return path.join(SESSIONS_DIR, id + '.json'); }
|
||||
@@ -172,7 +176,8 @@ check('迁移只在 idle 执行并精确保留备份,写后可以重新加载'
|
||||
function normalizeSession(value) { return value; }
|
||||
function loadNativeSessionHistory() { return { messages: nativeMessages }; }
|
||||
function textByteLength(value) { return Buffer.byteLength(value); }
|
||||
function loadSession(id) { return JSON.parse(fs.readFileSync(sessionPath(id), 'utf8')); }
|
||||
function loadSession(id) { return persistenceAdapter.loadSession(id); }
|
||||
function saveSession(session) { return persistenceAdapter.saveSession(session); }
|
||||
function sessionHistoryCacheKey(session) { return session.id; }
|
||||
function wsSend(ws, result) { response = result; }
|
||||
function attachClientRequestId(payload) { return payload; }
|
||||
@@ -181,7 +186,7 @@ check('迁移只在 idle 执行并精确保留备份,写后可以重新加载'
|
||||
${extract('writeFileAtomicSync')}
|
||||
${extract('handleMigrateSessionHistory')}
|
||||
return { run(id, apply) { handleMigrateSessionHistory(null, { sessionId: id, apply }); return response; }, idle() { running = false; } };
|
||||
`)(fs, path, crypto, dir, native);
|
||||
`)(fs, path, crypto, dir, native, persistenceAdapter);
|
||||
assert.equal(testApi.run(id, true).code, 'session_running');
|
||||
assert.equal(fs.readFileSync(filePath, 'utf8'), original);
|
||||
testApi.idle();
|
||||
@@ -191,7 +196,7 @@ check('迁移只在 idle 执行并精确保留备份,写后可以重新加载'
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(result.changed, true);
|
||||
assert.equal(fs.readFileSync(result.backupPath, 'utf8'), original);
|
||||
const restored = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
||||
const restored = createServerHarness(dir).loadSession(id);
|
||||
assert.equal(restored.messages.length, 483);
|
||||
assert(!restored.messages.some(m => m.ccwebPersistenceNotice));
|
||||
assert.deepEqual(restored.messages.slice(-68).map(m => m.id), snapshot.map(m => m.id));
|
||||
|
||||
Reference in New Issue
Block a user