Source:
<code>void updatePrimaryStar() { if (_env == null || !OTOptions.isEditable(_obsComp.getProgram(), _obsComp.getContextObservation())) return; final TargetEnvironment env = _dataObject.getTargetEnvironment(); final Option<SPTarget> targetOpt = getSelectedPos(); final Option<IndexedGuideGroup> iggOpt = targetOpt.flatMap(this::getTargetGroup).orElse(getSelectedGroup()); <START> final boolean primaryGroupIsSelected = iggOpt.exists(igg -> igg.group().equals(env.getOrCreatePrimaryGuideGroup())); <END> if (targetOpt.isDefined() && primaryGroupIsSelected) { final boolean autoGroup = targetOpt.flatMap(this::getTargetGroup).exists(igg -> igg.group().isAutomatic()); if (!autoGroup) PrimaryTargetToggle.instance.toggle(_dataObject, targetOpt.getValue()); } else { iggOpt.foreach(igg -> { final GuideGroup primary = env.getOrCreatePrimaryGuideGroup(); ImOption.apply(env.getGuideEnvironment()).foreach(ge -> { final GuideGrp grp = igg.group().grp(); if (ge != null && grp instanceof AutomaticGroup.Disabled$) { final TargetEnvironment envNew = env.setGuideEnvironment(ge.setAutomaticGroup(GuideGroup.AutomaticInitial()).setPrimaryIndex(0)); _dataObject.setTargetEnvironment(envNew); _model.enableAutoRow(envNew); } else if (ge != null && primary != igg.group() && confirmGroupChange(primary, igg.group())) { _dataObject.setTargetEnvironment(env.setGuideEnvironment(ge.setPrimaryIndex(igg.index()))); if (grp instanceof AutomaticGroup.Active) { updatePosAngle(((AutomaticGroup.Active) grp).posAngle()); } } }); }); } }</code><technical_language>Unrelated this PR, add issue, a GitHub issue fine, rename getOrCreatePrimaryGuideGroup getPrimaryGuideGroup? add a commit do I suppose. is longer case this method create is misleading. is a primary guide group now</technical_language>

Target:
void updatePrimaryStar() { if (_env == null || !OTOptions.isEditable(_obsComp.getProgram(), _obsComp.getContextObservation())) return; final TargetEnvironment env = _dataObject.getTargetEnvironment(); final Option<SPTarget> targetOpt = getSelectedPos(); final Option<IndexedGuideGroup> iggOpt = targetOpt.flatMap(this::getTargetGroup).orElse(getSelectedGroup()); final boolean primaryGroupIsSelected = iggOpt.exists(igg -> igg.group().equals(env.getPrimaryGuideGroup())); if (!primaryGroupIsSelected) { iggOpt.foreach(igg -> { final GuideGroup primary = env.getPrimaryGuideGroup(); ImOption.apply(env.getGuideEnvironment()).foreach(ge -> { final GuideGrp grp = igg.group().grp(); if (ge != null && grp instanceof AutomaticGroup.Disabled$) { final TargetEnvironment envNew = env.setGuideEnvironment(ge.setAutomaticGroup(GuideGroup.AutomaticInitial()).setPrimaryIndex(0)); _dataObject.setTargetEnvironment(envNew); _model.enableAutoRow(envNew); } else if (ge != null && primary != igg.group() && confirmGroupChange(primary, igg.group())) { _dataObject.setTargetEnvironment(env.setGuideEnvironment(ge.setPrimaryIndex(igg.index()))); if (grp instanceof AutomaticGroup.Active) { updatePosAngle(((AutomaticGroup.Active) grp).posAngle()); } } }); }); } final boolean autoGroup = targetOpt.flatMap(this::getTargetGroup).exists(igg -> igg.group().isAutomatic()); if (!autoGroup) { targetOpt.foreach(target -> { if (primaryGroupIsSelected || iggOpt.exists(igg -> igg.group().getAllContaining(target).forall(gpt -> gpt.getPrimary().forall(pt -> pt != target)))) { PrimaryTargetToggle.instance.toggle(_dataObject, target); } }); } }