From cea9d42fcc330be33a1df5d7dfa31820f636800a Mon Sep 17 00:00:00 2001 From: ai-ag2026 <261867348+ai-ag2026@users.noreply.github.com> Date: Sat, 13 Jun 2026 22:02:07 +0200 Subject: [PATCH] fix: extend timeout for full history session loads (cherry picked from commit 27cbff974eeaa58780d91fb4f25802cf0ac76381) --- CHANGELOG.md | 4 ++++ static/sessions.js | 2 +- ...test_issue2184_fork_from_here_absolute_index.py | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa691231..a558a6ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ ## [Unreleased] +### Fixed + +- **Full-history session loads now use an extended client timeout.** Actions that intentionally fetch the entire transcript (fork/export/start-jump helpers) can legitimately take longer than the default API timeout on very large sessions; the WebUI now gives that path up to 120 seconds instead of showing a premature "Request timed out" toast while the backend is still working. + ## [v0.51.395] — 2026-06-13 — Release NH (push source filters into agent session scans, #3930) ### Fixed diff --git a/static/sessions.js b/static/sessions.js index d944d497..2341c94a 100644 --- a/static/sessions.js +++ b/static/sessions.js @@ -2470,7 +2470,7 @@ async function _ensureAllMessagesLoaded() { _loadingOlder = true; try { const sid = S.session.session_id; - const data = await api(`/api/session?session_id=${encodeURIComponent(sid)}&messages=1&resolve_model=0`); + const data = await api(`/api/session?session_id=${encodeURIComponent(sid)}&messages=1&resolve_model=0`, {timeoutMs:120000}); // Guard: api() may have redirected (401) and returned undefined. if (!data || !data.session) return; // Session may have been switched while we awaited. Bail rather than diff --git a/tests/test_issue2184_fork_from_here_absolute_index.py b/tests/test_issue2184_fork_from_here_absolute_index.py index a4e23ef9..05fa2192 100644 --- a/tests/test_issue2184_fork_from_here_absolute_index.py +++ b/tests/test_issue2184_fork_from_here_absolute_index.py @@ -160,6 +160,20 @@ def test_ensure_all_resets_oldest_idx_to_zero(): ) +def test_ensure_all_messages_uses_extended_timeout_for_full_history_load(): + """Full-history loads for fork/export/start-jump can legitimately exceed the API default timeout.""" + body = _function_body(SESSIONS_JS, "_ensureAllMessagesLoaded") + full_history_call = re.search( + r"api\((?P`[^`]*messages=1&resolve_model=0[^`]*`)\s*,\s*\{(?P[^}]*)\}\s*\)", + body, + re.S, + ) + assert full_history_call, "_ensureAllMessagesLoaded must pass options to the full-history api() call" + timeout_match = re.search(r"timeoutMs\s*:\s*(\d+)", full_history_call.group("opts")) + assert timeout_match, "Full-history api() call must specify timeoutMs" + assert int(timeout_match.group(1)) >= 120000 + + # --------------------------------------------------------------------------- # Short-session / full-transcript behaviour preserved # ---------------------------------------------------------------------------