fix(workspace): _profileDefaultWorkspace persists after newSession() (#823)

Closes #823.

Separates two conflated semantics in S._profileDefaultWorkspace:
- Persistent blank-page default (set by boot/settings, never nulled)
- Profile-switch one-shot (now S._profileSwitchWorkspace, consumed by newSession())

newSession() priority: switchWs → current session → _profileDefaultWorkspace.
switchToWorkspace() clears _profileSwitchWorkspace on explicit switch.

9 new tests. 1777/1777 suite. Browser-verified.
This commit is contained in:
nesquena-hermes
2026-04-21 19:14:31 -07:00
committed by GitHub
parent 859602340e
commit d41d05ea36
4 changed files with 154 additions and 5 deletions

View File

@@ -14,10 +14,13 @@ async function newSession(flash){
updateQueueBadge();
S.toolCalls=[];
clearLiveToolCards();
// 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);
S._profileDefaultWorkspace=null; // consume — only applies to the first new session after switch
// One-shot profile-switch workspace: applied to the first new session after a profile
// switch, then cleared. Use a dedicated flag so S._profileDefaultWorkspace (the
// persistent boot/settings default) is not consumed and remains available for the
// blank-page display on all subsequent returns to the empty state (#823).
const switchWs=S._profileSwitchWorkspace;
S._profileSwitchWorkspace=null;
const inheritWs=switchWs||(S.session?S.session.workspace:null)||(S._profileDefaultWorkspace||null);
const data=await api('/api/session/new',{method:'POST',body:JSON.stringify({model:$('modelSelect').value,workspace:inheritWs,profile:S.activeProfile||'default'})});
S.session=data.session;S.messages=data.session.messages||[];
S.lastUsage={...(data.session.last_usage||{})};