I finally found the rhyme and reason of which context commands show up, ie. why selecting units and a factory sometimes allow for left click attack and sometimes don't. The context command is determined by the unit with the lowest aihint value. The aihint value is exactly equal to the unit id, which is determined by the the order in which spring finds the unit .fbi files and followed by the opposite order it finds the unit .swu files.
I think this should be changed. The com should be the lowest, followed by combat units, con units, factories and finally other buildings.