fix: preserve same-session load ownership on redundant reload + guard hint cleanup
Gate review (Codex) reproduced two SILENT regressions in the generation-token ownership change, both validated against PR head + merge base: 1. sessions.js:1428 — the no-op early-return did NOT fire for a redundant same-session load (currentSid===sid, !_loadingSessionId was false because a keep-stale refresh was in flight). The redundant loadSession() then bumped _loadSessionGeneration and CANCELLED the authoritative in-flight refresh — stale rows remained while message_count advanced, so later polling could not detect them. Restore the pre-existing behavior: also return when the in-flight load is for the SAME sid (!_loadingSessionId || _loadingSessionId===sid). 2. sessions.js:2781 — _ensureMessagesLoaded's finally cleared the transcript-width reload hint unconditionally, so a stale same-session response collapsed a long session to the default tail window. Guard the cleanup with _ownsLoad() so only the owning load clears the hint. Both fixes retain the PR's cross-session, same-session-rejection, and INFLIGHT race behavior (47 tests pass incl. the new isolation suite + the 4 edited files). Co-authored-by: starship-s <starship-s@users.noreply.github.com>
This commit is contained in:
parent
47c3fcf387
commit
07b3f411d7
1 changed files with 2 additions and 2 deletions
|
|
@ -1425,7 +1425,7 @@ async function loadSession(sid){
|
|||
// #2971: idempotent re-arm before the no-op guard revives a stream a prior
|
||||
// failed loadSession killed; no-ops on real switches.
|
||||
_rearmActiveSessionStream();
|
||||
if(currentSid===sid && !forceReload && !_loadingSessionId) return;
|
||||
if(currentSid===sid && !forceReload && (!_loadingSessionId || _loadingSessionId===sid)) return;
|
||||
// Mark this session as the in-flight load. Subsequent loadSession() calls
|
||||
// will overwrite this; stale awaits use the mismatch to bail out (#1060).
|
||||
const _loadGeneration = ++_loadSessionGeneration;
|
||||
|
|
@ -2778,7 +2778,7 @@ async function _ensureMessagesLoaded(sid, opts) {
|
|||
{timeoutMs:120000}
|
||||
);
|
||||
} finally {
|
||||
_clearSameSessionForceReloadHint(sid);
|
||||
if (_ownsLoad()) _clearSameSessionForceReloadHint(sid);
|
||||
}
|
||||
if (!_ownsLoad()) return;
|
||||
// Guard: api() may have redirected (401) and returned undefined.
|
||||
|
|
|
|||
Loading…
Reference in a new issue