改用 HTTP 加载会话历史并更新 CentOS 7 发布包
This commit is contained in:
@@ -3793,12 +3793,13 @@ function assertSessionSwitchResilienceContract() {
|
||||
'Frontend should actively detect an OPEN-but-stale WebSocket before session load timeout'
|
||||
);
|
||||
assert(frontendSource.includes('sessionLoadRequestTimer'), 'Frontend should track the session load request timeout timer');
|
||||
assert(frontendSource.includes('function clearPendingSessionSwitchRequest'), 'Frontend should be able to cancel stale pending session switch requests');
|
||||
assert(frontendSource.includes('function scheduleSessionLoadRequestTimeout'), 'Frontend should schedule cancellation for stuck load_session requests');
|
||||
assert(frontendSource.includes('sessionLoadAbortController?.abort()'), 'Frontend should cancel superseded HTTP session queries');
|
||||
assert(frontendSource.includes('function scheduleSessionLoadRequestTimeout'), 'Frontend should bound the duration of session queries');
|
||||
assert(frontendSource.includes('pendingSessionResumeRequest'), 'Frontend should track lightweight running-session resume requests');
|
||||
assert(frontendSource.includes('SESSION_RESUME_FALLBACK_MS'), 'Frontend should keep a compatibility fallback for servers without resume_session');
|
||||
assert(frontendSource.includes('function requestSessionResume'), 'Frontend should request running-session resume without full history reload');
|
||||
assert(frontendSource.includes("type: 'resume_session'"), 'Frontend should use resume_session for reconnecting running conversations');
|
||||
assert(frontendSource.includes("type: 'subscribe_session'"), 'Frontend should subscribe to real-time events without loading history through WebSocket');
|
||||
assert(!frontendSource.includes("type: 'load_session'") && !frontendSource.includes("type: 'load_history_page'"), 'Browser history reads must use HTTP');
|
||||
assert(frontendSource.includes("case 'session_subscribed':"), 'Frontend should handle independent subscription results');
|
||||
assert(frontendSource.includes("case 'resume_session_result':"), 'Frontend should handle lightweight resume results');
|
||||
assert(
|
||||
/case 'resume_session_result':[\s\S]*?if \(!msg\.isRunning && currentSessionId && msg\.sessionId === currentSessionId\) \{[\s\S]*?finishGenerating\(msg\.sessionId \|\| currentSessionId\);[\s\S]*?\}[\s\S]*?break;/.test(frontendSource),
|
||||
@@ -3812,7 +3813,7 @@ function assertSessionSwitchResilienceContract() {
|
||||
/preserveStreaming[\s\S]*?reconcileRenderedSessionMessages\(snapshot\.messages/.test(frontendSource),
|
||||
'Frontend running-session snapshots should reconcile persisted bubbles instead of skipping history'
|
||||
);
|
||||
assert(frontendSource.includes('recoverCurrent: true'), 'Frontend fallback load_session should preserve the current running view');
|
||||
assert(frontendSource.includes('recoverCurrent: true'), 'HTTP reconciliation should preserve the current running view');
|
||||
const visibilityStart = frontendSource.indexOf("document.addEventListener('visibilitychange'");
|
||||
const visibilityEnd = visibilityStart >= 0 ? frontendSource.indexOf("if (!authToken)", visibilityStart) : -1;
|
||||
const visibilitySource = visibilityStart >= 0 && visibilityEnd > visibilityStart
|
||||
@@ -3823,12 +3824,12 @@ function assertSessionSwitchResilienceContract() {
|
||||
assert(!visibilitySource.includes("type: 'load_session'"), 'Visibility restore must not force load_session and rerender the current conversation');
|
||||
assert(!visibilitySource.includes('beginSessionSwitch('), 'Visibility restore must not force a session switch and scroll to bottom');
|
||||
assert(
|
||||
/else if \(currentSessionId && \(isGenerating \|\| currentSessionRunning\)[\s\S]*?pendingSessionResumeRequest\s*=\s*\{/.test(frontendSource),
|
||||
'Frontend should queue a lightweight resume request for running conversations when WS closes'
|
||||
/if \(currentSessionId && !isPageUnloading\)[\s\S]*?pendingSessionResumeRequest\s*=\s*\{/.test(frontendSource),
|
||||
'Frontend should queue a real-time subscription when WS closes'
|
||||
);
|
||||
assert(
|
||||
/const flushedSessionResume = flushedSessionSwitch \? false : flushPendingSessionResume\(\);[\s\S]*?requestSessionResume\(currentSessionId/.test(frontendSource),
|
||||
'Frontend should resume the current running session after auth without forcing load_session'
|
||||
/const flushedSessionResume = sessionLoadAbortController \? false : flushPendingSessionResume\(\);[\s\S]*?requestSessionResume\(currentSessionId/.test(frontendSource),
|
||||
'Frontend should subscribe to the current view after auth without interrupting an HTTP query'
|
||||
);
|
||||
assert(
|
||||
frontendSource.includes("send({ type: 'abort', sessionId: currentSessionId })"),
|
||||
@@ -3851,12 +3852,12 @@ function assertSessionSwitchResilienceContract() {
|
||||
'Frontend should ignore history chunks from recovery fallback to avoid duplicating/redrawing bubbles'
|
||||
);
|
||||
assert(
|
||||
/function flushPendingSessionSwitch\(\)[\s\S]*?return false[\s\S]*?return true/.test(frontendSource),
|
||||
'Frontend flushPendingSessionSwitch should report whether it sent a load_session request'
|
||||
/fetch\(`\/api\/sessions\//.test(frontendSource),
|
||||
'Frontend should load sessions and history pages through the authenticated HTTP endpoint'
|
||||
);
|
||||
assert(
|
||||
/pendingSessionSwitchRequest\s*=\s*\{[\s\S]*?blocking:\s*false[\s\S]*?requestId:\s*activeSessionLoad\.requestId/.test(frontendSource),
|
||||
'Frontend should retry load_session after WS close without re-blocking the UI'
|
||||
!extractFunctionSource(frontendSource, 'connect').slice(extractFunctionSource(frontendSource, 'connect').indexOf('socket.onclose')).includes('clearSessionLoading()'),
|
||||
'WebSocket close must not cancel an independent HTTP history query'
|
||||
);
|
||||
assert(
|
||||
frontendSource.includes('!messageRequestId && !currentSessionId && !activeLoad && !pendingNewSession'),
|
||||
@@ -7723,6 +7724,15 @@ async function main() {
|
||||
console.log('Session switch race regression checks passed.');
|
||||
return;
|
||||
}
|
||||
if (regressionTarget === 'session-http-load') {
|
||||
assertSessionSwitchResilienceContract();
|
||||
const result = spawnSync(process.execPath, [path.join(REPO_DIR, 'scripts', 'session-http-load-regression.js')], {
|
||||
encoding: 'utf8', timeout: 60000,
|
||||
});
|
||||
assert(result.status === 0, result.stderr || result.stdout || result.error?.message || 'HTTP 会话回归失败');
|
||||
console.log(result.stdout.trim());
|
||||
return;
|
||||
}
|
||||
if (regressionTarget === 'history-recall') {
|
||||
assertHistoryRecallContract();
|
||||
console.log('History recall regression checks passed.');
|
||||
|
||||
Reference in New Issue
Block a user