fix(chat): accept session_id URL parameter

This commit is contained in:
ai-ag2026 committed 2026-05-25 07:59:21 +02:00
1 parent 4ea762ae0d
commit 21655af09b
3 files changed
+24 -1

No files matched your search

+4
View File
@@ -3,6 +3,10 @@
## [Unreleased] ## [Unreleased]
### Fixed
- Browser session links that use the API-style `?session_id=<id>` query parameter now open the requested conversation instead of falling back to the last locally stored session.
## [v0.51.134] — 2026-05-25 — Release DF (stage-batch16 — single-PR Windows path defaults) ## [v0.51.134] — 2026-05-25 — Release DF (stage-batch16 — single-PR Windows path defaults)
### Fixed ### Fixed
+1 -1
View File
@@ -1556,7 +1556,7 @@ function _sessionIdFromLocation(){
} }
try{ try{
const qs=new URLSearchParams(window.location.search||''); const qs=new URLSearchParams(window.location.search||'');
return qs.get('session')||null; return qs.get('session')||qs.get('session_id')||null;
}catch(_e){return null;} }catch(_e){return null;}
} }
function _sessionUrlForSid(sid){ function _sessionUrlForSid(sid){
+19
View File
@@ -650,6 +650,25 @@ def test_loadSession_inflight_merges_tail_with_persisted_transcript(cleanup_test
) )
def test_browser_session_url_accepts_api_session_id_param(cleanup_test_sessions):
"""External links using ?session_id=... should open that session in the browser.
The API endpoint uses `session_id`, while the browser URL historically used
`session`/`/session/<id>`. Auth/cookie bridges and external callers can
legitimately produce `/?session_id=<sid>`; ignoring it falls back to stale
localStorage and renders the wrong or empty conversation.
"""
src = (REPO_ROOT / "static/sessions.js").read_text()
start = src.find("function _sessionIdFromLocation")
assert start >= 0, "session URL parser not found"
end = src.find("function _sessionUrlForSid", start)
assert end > start, "session URL parser block end not found"
block = src[start:end]
assert "qs.get('session')" in block or 'qs.get("session")' in block
assert "qs.get('session_id')" in block or 'qs.get("session_id")' in block
def test_inflight_merge_dedupes_uploaded_user_message(cleanup_test_sessions): def test_inflight_merge_dedupes_uploaded_user_message(cleanup_test_sessions):
"""Uploaded-file turns render optimistically before the server stores the """Uploaded-file turns render optimistically before the server stores the
final pending text with an `[Attached files: ...]` suffix. The INFLIGHT final pending text with an `[Attached files: ...]` suffix. The INFLIGHT