fix: switching profiles mid-conversation starts a new session instead of cross-tagging
A session with messages belongs to the profile it was created under. Switching profiles while a conversation is in progress should not retag that session or update its workspace/model in place — that would corrupt the session's context. New behavior: - Session has NO messages (empty): profile switch updates it in place (model, workspace). Works exactly as before — nothing was started yet. - Session HAS messages (in progress): profile switch calls newSession() to start a fresh session tagged to the new profile. The old session is left untouched. Toast: 'Switched to profile: X — new conversation started'. - Agent busy: blocked as before, no change. Also: S._profileDefaultWorkspace is now consumed (set to null) inside newSession() after the first use, so it doesn't keep forcing the same workspace on every subsequent new session after a switch.
This commit is contained in:
@@ -13,9 +13,10 @@ async function newSession(flash){
|
||||
MSG_QUEUE.length=0;updateQueueBadge();
|
||||
S.toolCalls=[];
|
||||
clearLiveToolCards();
|
||||
// Use profile default workspace for new sessions after a profile switch,
|
||||
// Use profile default workspace for new sessions after a profile switch (one-shot),
|
||||
// otherwise inherit from the current session (or let server pick the default)
|
||||
const inheritWs=S._profileDefaultWorkspace||( S.session?S.session.workspace:null);
|
||||
const inheritWs=S._profileDefaultWorkspace||(S.session?S.session.workspace:null);
|
||||
S._profileDefaultWorkspace=null; // consume — only applies to the first new session after switch
|
||||
const data=await api('/api/session/new',{method:'POST',body:JSON.stringify({model:$('modelSelect').value,workspace:inheritWs})});
|
||||
S.session=data.session;S.messages=data.session.messages||[];
|
||||
if(flash)S.session._flash=true;
|
||||
|
||||
Reference in New Issue
Block a user