#!/usr/bin/env bash # "The shell would not reload" -> an agent already holding the error. # # Quickshell keeps the old shell running when a reload fails, which is what # makes this rung possible at all: the desktop that just refused the new code is # still there to notify you about it, and still there to click. shell.qml's # onReloadFailed sends that notification; this builds the prompt behind it. # # panama-agent-reload "" # # The failure string on its own is usually one line naming one file. The journal # around it is where the rest is -- the QML warnings that preceded the fatal # one, the property that was already undefined two saves ago -- so both go in. # # Environment seams, for the contract: # # PANAMA_PATH the repository # PANAMA_RELOAD_UNIT the unit to read (default panama-quickshell.service) set -euo pipefail PANAMA_PATH="${PANAMA_PATH:-$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/.." && pwd)}" UNIT="${PANAMA_RELOAD_UNIT:-panama-quickshell.service}" summary="${1:-}" if [[ -z "${summary// }" ]]; then printf 'Usage: panama-agent-reload ""\n' >&2 exit 1 fi # Read a generous window and filter it down, rather than asking journalctl for # forty lines and hoping they were the relevant ones. A failed reload usually # arrives after a burst of unrelated shell chatter. # # Each line is truncated because the prompt leaves as one argv element and the # kernel caps that at 128KB; a single Quickshell backtrace can be most of it. context="" if command -v journalctl >/dev/null 2>&1; then context="$(journalctl --user -u "$UNIT" -n 400 --no-pager --output=cat 2>/dev/null \ | grep -iE 'quickshell|\.qml|qml:|panama' \ | tail -40 \ | cut -c 1-300)" || true fi [[ -n "${context// }" ]] || context="(nothing in the journal for $UNIT)" prompt="$( cat <