File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4594,7 +4594,19 @@ async function persistAndSyncSelectedAccount({
45944594 ! ! storage . activeIndexByFamily &&
45954595 targetIndex === storage . activeIndex ;
45964596 storage . activeIndex = targetIndex ;
4597- if ( ! shouldPreserveActiveIndexByFamily ) {
4597+ storage . activeIndexByFamily = storage . activeIndexByFamily ?? { } ;
4598+ if ( shouldPreserveActiveIndexByFamily ) {
4599+ const maxIndex = Math . max ( 0 , storage . accounts . length - 1 ) ;
4600+ for ( const family of MODEL_FAMILIES ) {
4601+ const raw = storage . activeIndexByFamily [ family ] ;
4602+ const candidate =
4603+ typeof raw === "number" && Number . isFinite ( raw ) ? raw : targetIndex ;
4604+ storage . activeIndexByFamily [ family ] = Math . max (
4605+ 0 ,
4606+ Math . min ( candidate , maxIndex ) ,
4607+ ) ;
4608+ }
4609+ } else {
45984610 storage . activeIndexByFamily = storage . activeIndexByFamily ?? { } ;
45994611 for ( const family of MODEL_FAMILIES ) {
46004612 storage . activeIndexByFamily [ family ] = targetIndex ;
You can’t perform that action at this time.
0 commit comments