fix: correct session project and rebuild CentOS 7 release

This commit is contained in:
shiyue
2026-08-19 08:31:41 +08:00
parent 682589c03e
commit d7dc32e924
3 changed files with 95 additions and 4 deletions

View File

@@ -2609,6 +2609,84 @@ function assertSessionItemTooltipContract() {
assert(!createItemSource.includes('item.title = sessionCwd'), 'Session card should not fall back to a project-only tooltip');
}
function assertSessionProjectSnapshotContract() {
const frontendSource = fs.readFileSync(PUBLIC_APP_PATH, 'utf8');
const mergeSource = extractFunctionSource(frontendSource, 'mergeSessionListSnapshot');
const api = new Function(`
let sessions = [];
function normalizeAgent(agent) {
return ['claude', 'codex', 'codexapp'].includes(agent) ? agent : 'claude';
}
function getPathLeaf(input) {
const normalized = String(input || '').replace(/\\\\/g, '/').replace(/\\/+$/, '');
return normalized.split('/').filter(Boolean).pop() || '';
}
function compareSessionUpdatedDesc(a, b) {
return new Date(b.updated || 0) - new Date(a.updated || 0);
}
${mergeSource}
return {
mergeSessionListSnapshot,
setSessions(next) { sessions = next.map((item) => ({ ...item })); },
getSession(id) { return sessions.find((item) => item.id === id) || null; },
};
`)();
api.setSessions([{
id: 'snapshot-session',
agent: 'codexapp',
cwd: '/home/hdzx/2026/english',
projectName: 'english',
title: '输入保护',
updated: '2026-08-19T01:25:00.000Z',
}]);
api.mergeSessionListSnapshot({
sessionId: 'snapshot-session',
cwd: '',
projectName: '',
title: '输入保护',
updated: '2026-08-19T01:26:00.000Z',
});
const cleared = api.getSession('snapshot-session');
assert(cleared.cwd === '', 'Explicit empty snapshot cwd should clear the stale session cwd');
assert(cleared.projectName === '', 'Explicit empty snapshot cwd should clear the stale project name');
api.setSessions([{
id: 'snapshot-session',
agent: 'codexapp',
cwd: '/home/hdzx',
projectName: 'hdzx',
title: '输入保护',
updated: '2026-08-19T01:25:00.000Z',
}]);
api.mergeSessionListSnapshot({
sessionId: 'snapshot-session',
cwd: '/home/hdzx/2026/english',
projectName: 'hdzx',
title: '输入保护',
updated: '2026-08-19T01:27:00.000Z',
});
const changed = api.getSession('snapshot-session');
assert(changed.cwd === '/home/hdzx/2026/english', 'Snapshot cwd changes should replace the previous project cwd');
assert(changed.projectName === 'english', 'Snapshot cwd changes should derive the displayed project from the new cwd');
api.setSessions([{
id: 'snapshot-session',
agent: 'codexapp',
cwd: '/home/hdzx/2026/english',
projectName: 'english',
title: '输入保护',
updated: '2026-08-19T01:25:00.000Z',
}]);
api.mergeSessionListSnapshot({
sessionId: 'snapshot-session',
title: '输入保护',
updated: '2026-08-19T01:28:00.000Z',
});
const omitted = api.getSession('snapshot-session');
assert(omitted.cwd === '/home/hdzx/2026/english' && omitted.projectName === 'english', 'Snapshots that omit cwd should preserve the cached project metadata');
}
function assertSidebarTitleRefreshStormContract() {
const frontendSource = fs.readFileSync(PUBLIC_APP_PATH, 'utf8');
const createItemSource = extractFunctionSource(frontendSource, 'createSessionListItem');
@@ -5897,6 +5975,11 @@ async function main() {
console.log('Session item tooltip regression checks passed.');
return;
}
if (regressionTarget === 'session-project-snapshot') {
assertSessionProjectSnapshotContract();
console.log('Session project snapshot regression checks passed.');
return;
}
if (regressionTarget === 'sidebar-title-refresh-storm') {
assertSidebarTitleRefreshStormContract();
assertCcwebMcpChildUpdateCoalescingContract();
@@ -5977,6 +6060,7 @@ async function main() {
assertFrontendPrimaryCodexAppUiContract();
assertSetTitleMcpContract();
assertSessionItemTooltipContract();
assertSessionProjectSnapshotContract();
assertCcwebMcpChildUpdateCoalescingContract();
assertTitleHistoryOutlineContract();
assertSessionSwitchResilienceContract();