relaunch ui last
All checks were successful
Blockstorage/repertory/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2025-09-14 20:55:43 -05:00
parent e94011151a
commit ed2823ba59

View File

@@ -182,21 +182,42 @@ unload_launchd_helpers_user() {
restart_launchagents_from_snapshot() {
[[ -n "${snapfile:-}" && -f "${snapfile}" ]] || return 0
local uid count=0 ui_seen=0
uid="$(id -u)"
# Pass 1: restart all non-UI agents first
while IFS=$'\t' read -r plist label; do
[[ -z "$plist" || -z "$label" ]] && continue
[[ -n "$plist" && -n "$label" ]] || continue
[[ -f "$plist" ]] || continue
[[ "$label" == "$UI_LABEL" ]] && continue
log "Re-starting LaunchAgent: ${label}"
/bin/launchctl bootstrap "gui/${uid}" "$plist" 2>/dev/null || true
/bin/launchctl kickstart -k "gui/${uid}/${label}" 2>/dev/null || true
((count++)) || true
[[ "$label" == "$UI_LABEL" ]] && ui_seen=1 || true
done <"$snapfile"
# Give helpers a moment to settle (e.g., automounts)
sleep 0.3
# Pass 2: restart the UI agent last (if present in the snapshot)
while IFS=$'\t' read -r plist label; do
[[ -n "$plist" && -n "$label" ]] || continue
[[ -f "$plist" ]] || continue
[[ "$label" == "$UI_LABEL" ]] || continue
log "Re-starting UI LaunchAgent last: ${label}"
/bin/launchctl bootstrap "gui/${uid}" "$plist" 2>/dev/null || true
/bin/launchctl kickstart -k "gui/${uid}/${label}" 2>/dev/null || true
ui_seen=1
((count++)) || true
done <"$snapfile"
log "Re-started ${count} LaunchAgent(s) with prefix ${LABEL_PREFIX}." || true
if ((ui_seen)); then
sleep 0.3
# If the UI label is active, skip manual open(1).
if /bin/launchctl list | /usr/bin/awk '{print $3}' | /usr/bin/grep -Fxq "$UI_LABEL"; then
log "UI LaunchAgent (${UI_LABEL}) active after restart; skipping manual UI launch."
skip_ui_launch=1