fix: skip archived saved session on boot
This commit is contained in:
1 parent
8a26269d72
commit
a51e58efc0
4 files changed
+19
-1
No files matched your search
+1
-1
@@ -85,7 +85,7 @@ async function _savedSessionShouldStaySidebarOnly(sid){
|
|||||||
try{
|
try{
|
||||||
const data = await api(`/api/session?session_id=${encodeURIComponent(sid)}&messages=0&resolve_model=0`);
|
const data = await api(`/api/session?session_id=${encodeURIComponent(sid)}&messages=0&resolve_model=0`);
|
||||||
const session = data&&data.session;
|
const session = data&&data.session;
|
||||||
return !!(session&&(session.active_stream_id||session.pending_user_message));
|
return !!(session&&(session.active_stream_id||session.pending_user_message||session.archived));
|
||||||
}catch(e){
|
}catch(e){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3558,6 +3558,7 @@ async function _archiveSession(session, archived=true, beforeListRender=null){
|
|||||||
const cached=(_allSessions||[]).find(s=>s&&s.session_id===session.session_id);
|
const cached=(_allSessions||[]).find(s=>s&&s.session_id===session.session_id);
|
||||||
if(cached) cached.archived=archived;
|
if(cached) cached.archived=archived;
|
||||||
if(S.session&&S.session.session_id===session.session_id) S.session.archived=archived;
|
if(S.session&&S.session.session_id===session.session_id) S.session.archived=archived;
|
||||||
|
try{ if(archived&&session.session_id&&localStorage.getItem('hermes-webui-session')===session.session_id) localStorage.removeItem('hermes-webui-session'); }catch(_){ }
|
||||||
showToast(session.archived?_sessionArchiveToast(response,session):t('session_restored'));
|
showToast(session.archived?_sessionArchiveToast(response,session):t('session_restored'));
|
||||||
if(renderHold) await renderHold;
|
if(renderHold) await renderHold;
|
||||||
if(_showArchived&&!_sessionPrefersReducedMotion()) _sessionSwipeReturnOffsets.set(session.session_id,'0px');
|
if(_showArchived&&!_sessionPrefersReducedMotion()) _sessionSwipeReturnOffsets.set(session.session_id,'0px');
|
||||||
|
|||||||
@@ -72,6 +72,10 @@ def test_saved_running_session_helper_uses_metadata_only_and_runtime_markers():
|
|||||||
assert "resolve_model=0" in helper, "helper must avoid unnecessary model resolution"
|
assert "resolve_model=0" in helper, "helper must avoid unnecessary model resolution"
|
||||||
assert "active_stream_id" in helper, "helper must treat active_stream_id as running"
|
assert "active_stream_id" in helper, "helper must treat active_stream_id as running"
|
||||||
assert "pending_user_message" in helper, "helper must treat pending_user_message as running"
|
assert "pending_user_message" in helper, "helper must treat pending_user_message as running"
|
||||||
|
assert "session.archived" in helper, (
|
||||||
|
"helper must skip auto-opening archived localStorage sessions so root "
|
||||||
|
"boot lands on the empty state instead of reopening archived chats"
|
||||||
|
)
|
||||||
assert "loadSession(" not in helper, (
|
assert "loadSession(" not in helper, (
|
||||||
"helper must not call loadSession(), because that would already project "
|
"helper must not call loadSession(), because that would already project "
|
||||||
"the saved session into the active pane"
|
"the saved session into the active pane"
|
||||||
|
|||||||
@@ -46,6 +46,19 @@ def test_archive_action_repaints_sidebar_before_full_refresh():
|
|||||||
assert helper_body.index(api_call) < helper_body.index(optimistic) < helper_body.index(cached_render) < helper_body.index(full_refresh)
|
assert helper_body.index(api_call) < helper_body.index(optimistic) < helper_body.index(cached_render) < helper_body.index(full_refresh)
|
||||||
|
|
||||||
|
|
||||||
|
def test_archive_action_clears_saved_session_pointer_for_archived_current_session():
|
||||||
|
"""Archiving the saved active session should not leave boot localStorage stale."""
|
||||||
|
helper_body = _function_block(SESSIONS_JS, "_archiveSession")
|
||||||
|
stale_saved_pointer_guard = (
|
||||||
|
"try{ if(archived&&session.session_id&&localStorage.getItem('hermes-webui-session')===session.session_id) "
|
||||||
|
"localStorage.removeItem('hermes-webui-session'); }catch(_){ }"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert stale_saved_pointer_guard in helper_body
|
||||||
|
assert helper_body.index("if(S.session&&S.session.session_id===session.session_id) S.session.archived=archived;") < helper_body.index(stale_saved_pointer_guard)
|
||||||
|
assert helper_body.index(stale_saved_pointer_guard) < helper_body.index("showToast(session.archived?_sessionArchiveToast(response,session):t('session_restored'));")
|
||||||
|
|
||||||
|
|
||||||
def test_delete_action_repaints_sidebar_before_loading_remaining_sessions():
|
def test_delete_action_repaints_sidebar_before_loading_remaining_sessions():
|
||||||
"""Delete should remove the row locally before loading replacement session data."""
|
"""Delete should remove the row locally before loading replacement session data."""
|
||||||
body = _function_block(SESSIONS_JS, "deleteSession")
|
body = _function_block(SESSIONS_JS, "deleteSession")
|
||||||
|
|||||||
Reference in new issue
Block a user