@@ -95,6 +95,37 @@ async def test_sse_reconnect_preserves_chat_history(page):
9595 assert user_msgs >= 1 , "User message should be preserved after reconnect"
9696
9797
98+ async def test_refresh_without_hash_reopens_active_thread_history (page ):
99+ """Refreshing should reopen the server active thread when the URL has no thread hash."""
100+ await page .locator ("#thread-new-btn" ).click ()
101+ await page .wait_for_function (
102+ "() => !!currentThreadId && currentThreadId !== assistantThreadId"
103+ )
104+ thread_id = await page .evaluate ("() => currentThreadId" )
105+
106+ result = await send_chat_and_wait_for_terminal_message (
107+ page ,
108+ "Refresh should keep this thread" ,
109+ )
110+ assert result ["role" ] == "assistant"
111+
112+ await page .evaluate (
113+ "() => history.replaceState(null, '', location.pathname + location.search)"
114+ )
115+ await page .reload ()
116+ await page .wait_for_selector ("#auth-screen" , state = "hidden" , timeout = 15000 )
117+ await _wait_for_connected (page , timeout = 15000 )
118+ await page .wait_for_function (
119+ "(threadId) => currentThreadId === threadId" ,
120+ arg = thread_id ,
121+ timeout = 15000 ,
122+ )
123+
124+ await page .locator (SEL ["message_user" ]).filter (
125+ has_text = "Refresh should keep this thread"
126+ ).wait_for (state = "visible" , timeout = 15000 )
127+
128+
98129async def test_sse_keepalive_comments_arrive (managed_gateway_server ):
99130 """Idle SSE connections should receive keepalive comments within 30 seconds."""
100131 async with sse_stream (managed_gateway_server .base_url , timeout = 50 ) as response :
0 commit comments