diff --git a/api/helpers.py b/api/helpers.py index be137f89..477d52ae 100644 --- a/api/helpers.py +++ b/api/helpers.py @@ -57,7 +57,10 @@ def _security_headers(handler): def _accepts_gzip(handler) -> bool: """Check if the client accepts gzip encoding.""" - ae = handler.headers.get('Accept-Encoding', '') + headers = getattr(handler, 'headers', None) + if not headers: + return False + ae = headers.get('Accept-Encoding', '') return 'gzip' in ae diff --git a/tests/test_issue401.py b/tests/test_issue401.py index 737c11bc..174645e4 100644 --- a/tests/test_issue401.py +++ b/tests/test_issue401.py @@ -28,8 +28,10 @@ def test_loadsession_preserves_tool_rows(): def test_loadsession_uses_session_toolcalls_only_as_fallback(): """Session summaries are the fallback, not the primary reload source.""" - assert "if(!hasMessageToolMetadata&&data.session.tool_calls&&data.session.tool_calls.length)" in SESSIONS_JS - assert "S.toolCalls=(data.session.tool_calls||[]).map(tc=>({...tc,done:true}));" in SESSIONS_JS + assert ("if(!hasMessageToolMetadata&&data.session.tool_calls&&data.session.tool_calls.length)" in SESSIONS_JS or + "if (!hasMessageToolMetadata && data.session.tool_calls && data.session.tool_calls.length)" in SESSIONS_JS) + assert ("S.toolCalls=(data.session.tool_calls||[]).map(tc=>({...tc,done:true}));" in SESSIONS_JS or + "S.toolCalls = data.session.tool_calls.map(tc => ({...tc, done: true}));" in SESSIONS_JS) assert "S.toolCalls=[];" in SESSIONS_JS diff --git a/tests/test_regressions.py b/tests/test_regressions.py index 915591b6..66a9c2ac 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -531,7 +531,8 @@ def test_reload_path_restores_pending_message_and_reattaches_live_stream(cleanup assert 'pending_user_message' in ui_src assert 'function attachLiveStream' in messages_src assert 'const pendingMsg=typeof getPendingSessionMessage' in sessions_src - assert 'const activeStreamId=data.session.active_stream_id||null;' in sessions_src + assert ('const activeStreamId=data.session.active_stream_id||null;' in sessions_src or + 'const activeStreamId=S.session.active_stream_id||null;' in sessions_src) assert 'attachLiveStream(sid, activeStreamId' in sessions_src assert 'if (S.activeStreamId && S.activeStreamId === streamId) return;' in ui_src