Merge #4055 into stage-ml
This commit is contained in:
@@ -4744,44 +4744,56 @@ function _sidebarRowHasVisibleMessages(s, activeSidForSidebar){
|
||||
}
|
||||
|
||||
function _partitionSidebarSessionRows(allMatched, activeSidForSidebar){
|
||||
let webuiSessionCount=0;
|
||||
let cliSessionCount=0;
|
||||
for(const s of allMatched){
|
||||
if(!_sidebarRowHasVisibleMessages(s, activeSidForSidebar)) continue;
|
||||
if(_isCliSession(s)) cliSessionCount++;
|
||||
else webuiSessionCount++;
|
||||
}
|
||||
if(_sessionSourceFilter==='cli' && !window._showCliSessions && cliSessionCount===0){
|
||||
_sessionSourceFilter='webui';
|
||||
}
|
||||
const showCliOnly=_sessionSourceFilter==='cli';
|
||||
const profileFiltered=[];
|
||||
const sessionsRaw=[];
|
||||
let archivedCount=0;
|
||||
const webuiProfileFiltered=[];
|
||||
const cliProfileFiltered=[];
|
||||
const webuiSessionsRaw=[];
|
||||
const cliSessionsRaw=[];
|
||||
let webuiArchivedCount=0;
|
||||
let cliArchivedCount=0;
|
||||
for(const s of allMatched){
|
||||
if(!_sidebarRowHasVisibleMessages(s, activeSidForSidebar)) continue;
|
||||
const isCli=_isCliSession(s);
|
||||
if(showCliOnly ? !isCli : isCli) continue;
|
||||
if(isCli) cliSessionCount++;
|
||||
if(s.default_hidden&&!(_activeProject&&_activeProject!==NO_PROJECT_FILTER&&s.project_id===_activeProject)) continue;
|
||||
const profileFiltered=isCli ? cliProfileFiltered : webuiProfileFiltered;
|
||||
const sessionsRaw=isCli ? cliSessionsRaw : webuiSessionsRaw;
|
||||
profileFiltered.push(s);
|
||||
if(_activeProject===NO_PROJECT_FILTER){
|
||||
if(s.project_id) continue;
|
||||
} else if(_activeProject){
|
||||
if(s.project_id!==_activeProject) continue;
|
||||
}
|
||||
if(s.archived) archivedCount++;
|
||||
if(s.archived){
|
||||
if(isCli) cliArchivedCount++;
|
||||
else webuiArchivedCount++;
|
||||
}
|
||||
if(!_showArchived&&s.archived) continue;
|
||||
sessionsRaw.push(s);
|
||||
}
|
||||
if(_sessionSourceFilter==='cli' && !window._showCliSessions && cliSessionCount===0){
|
||||
_sessionSourceFilter='webui';
|
||||
}
|
||||
const showCliOnly=_sessionSourceFilter==='cli';
|
||||
return {
|
||||
webuiSessionCount,
|
||||
cliSessionCount,
|
||||
profileFiltered,
|
||||
sessionsRaw,
|
||||
archivedCount,
|
||||
profileFiltered: showCliOnly ? cliProfileFiltered : webuiProfileFiltered,
|
||||
sessionsRaw: showCliOnly ? cliSessionsRaw : webuiSessionsRaw,
|
||||
archivedCount: showCliOnly ? cliArchivedCount : webuiArchivedCount,
|
||||
webuiSessionsRaw,
|
||||
cliSessionsRaw,
|
||||
};
|
||||
}
|
||||
|
||||
function _renderSidebarRowsFromRawSessions(sessionsRaw){
|
||||
return _attachChildSessionsToSidebarRows(_collapseSessionLineageForSidebar(sessionsRaw), sessionsRaw);
|
||||
}
|
||||
|
||||
function _countRenderedSidebarRowsFromRawSessions(sessionsRaw){
|
||||
// Keep inactive-tab chip counts on the exact same top-level row path as render.
|
||||
return _renderSidebarRowsFromRawSessions(sessionsRaw).length;
|
||||
}
|
||||
|
||||
function renderSessionListFromCache(){
|
||||
// Don't re-render while user is actively renaming a session (would destroy the input)
|
||||
if(_renamingSid) return;
|
||||
@@ -4805,13 +4817,20 @@ function renderSessionListFromCache(){
|
||||
const searchMatches=_sessionSearchMergeMatches(sidebarRows,searchQueryRaw,_contentSearchResults);
|
||||
const allMatched=_ensureActiveSessionRowPresent(searchMatches,sidebarRows);
|
||||
const {
|
||||
webuiSessionCount,
|
||||
cliSessionCount,
|
||||
profileFiltered,
|
||||
sessionsRaw,
|
||||
archivedCount,
|
||||
webuiSessionsRaw,
|
||||
cliSessionsRaw,
|
||||
}=_partitionSidebarSessionRows(allMatched, activeSidForSidebar);
|
||||
const sessions=_attachChildSessionsToSidebarRows(_collapseSessionLineageForSidebar(sessionsRaw), sessionsRaw);
|
||||
const sessions=_renderSidebarRowsFromRawSessions(sessionsRaw);
|
||||
const renderedWebuiSessionCount=_sessionSourceFilter==='webui'
|
||||
? sessions.length
|
||||
: _countRenderedSidebarRowsFromRawSessions(webuiSessionsRaw);
|
||||
const renderedCliSessionCount=_sessionSourceFilter==='cli'
|
||||
? sessions.length
|
||||
: _countRenderedSidebarRowsFromRawSessions(cliSessionsRaw);
|
||||
_syncSidebarExpansionForActiveSession(sessions, activeSidForSidebar);
|
||||
const list=$('sessionList');
|
||||
const animateRefresh=_sessionListRefreshAnimationPending;
|
||||
@@ -4846,7 +4865,7 @@ function renderSessionListFromCache(){
|
||||
const sourceTabs=document.createElement('div');
|
||||
sourceTabs.className='session-source-tabs';
|
||||
for(const filter of ['webui','cli']){
|
||||
const count=filter==='cli'?cliSessionCount:webuiSessionCount;
|
||||
const count=filter==='cli'?renderedCliSessionCount:renderedWebuiSessionCount;
|
||||
const btn=document.createElement('button');
|
||||
btn.type='button';
|
||||
btn.className='session-source-tab'+(_sessionSourceFilter===filter?' active':'');
|
||||
|
||||
Reference in New Issue
Block a user