Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Expand managed dev browser proof pack

rcourtman9d74c943c780
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4d5b05efdd..396b4c8f39 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -83,7 +83,7 @@ examples where possible.
- Runtime logs: `npm run dev:logs`
- Managed restart: `npm run dev:restart`
- Managed backend restart: `npm run dev:backend-restart`
-- Browser recovery proof: `npm run dev:verify`
+- Browser proof pack: `npm run dev:verify`
- Foreground managed launcher: `npm run dev:foreground`
- Frontend-only escape hatch: `cd frontend-modern && npm run dev:frontend-only`
- Tests: `npm run test`
diff --git a/README.md b/README.md
index 5913edcdc0..333b430857 100644
--- a/README.md
+++ b/README.md
@@ -104,14 +104,15 @@ Canonical local dev commands:
- `npm run dev` — start the managed runtime and reclaim the canonical dev ports if an older unmanaged session is still using them
- `npm run dev:status` — show frontend shell health, proxied API health, direct backend health, and listener ownership
-- `npm run dev:verify` — run the managed browser recovery proof against the live dev runtime
+- `npm run dev:verify` — run the managed browser proof pack against the live dev runtime, including runtime recovery and the desktop Recovery layout guard
- `npm run dev:logs` — tail the managed runtime log
- `npm run dev:backend-restart` — bounce only the managed backend through the launcher contract
- `npm run dev:stop` — stop the managed runtime
- `npm run dev:foreground` — run the foreground hot-reload launcher intentionally if you need an attached shell
If `npm run dev:verify` passes, the managed dev shell, proxy path, backend
-health endpoint, and browser recovery path are all aligned.
+health endpoint, browser recovery path, and Recovery desktop history-table
+layout are all aligned.
## 📚 Documentation
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index efca9cb708..bdf86d730a 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -169,12 +169,22 @@ browser runtime, cover both stream-only reconnect degradation and full backend
loss, bounce the real backend through the launcher contract when needed, and
prove that the shell degrades and recovers through the proxy instead of
relying on backend-only API checks that miss browser/runtime drift.
+That same managed browser proof pack must also keep the desktop Recovery page
+layout guard on the canonical entrypoint, so `dev:verify` catches right-edge
+history-table overflow regressions introduced by more human-readable subject
+labels instead of leaving that check as a hidden one-off Playwright command.
That same launcher boundary now also owns the one-command verification entry
point for that proof. `./scripts/hot-dev-bg.sh verify` must prepare a coherent
managed runtime, run the canonical browser recovery proof with the managed dev
credentials and browser entrypoint defaults, and fail with ownership or health
diagnostics instead of leaving operators to remember the exact Playwright
command and env combination by hand.
+That same takeover path must remain safe on the default macOS Bash runtime and
+must not tear down the operator's current shell lineage while reclaiming a
+foreground `hot-dev.sh` session. When the canonical ports are already owned by
+that foreground session, the managed wrapper should reclaim the occupied
+listener processes without relying on Bash-4-only shell features or killing
+the terminal that invoked the takeover.
That same launcher boundary now also owns the canonical repo-root developer
entry surface. `package.json` must expose the managed runtime as the default
local dev path, including explicit status, log, stop, backend-restart, and
diff --git a/scripts/hot-dev-bg.sh b/scripts/hot-dev-bg.sh
index 502d938ac9..8540a4f641 100755
--- a/scripts/hot-dev-bg.sh
+++ b/scripts/hot-dev-bg.sh
@@ -76,6 +76,67 @@ process_parent_id() {
ps -o ppid= -p "${pid}" 2>/dev/null | tr -d '[:space:]'
}
+array_contains() {
+ local needle="${1:-}"
+ shift || true
+
+ local item
+ for item in "$@"; do
+ [[ "${item}" == "${needle}" ]] && return 0
+ done
+
+ return 1
+}
+
+safe_kill_target() {
+ local signal="${1:-TERM}"
+ local target_pgid="${2:-}"
+ local target_pid="${3:-}"
+ local current_pgid=""
+
+ if [[ -n "${target_pgid}" ]]; then
+ current_pgid="$(process_group_id "$$")"
+ if [[ -n "${current_pgid}" && "${target_pgid}" != "${current_pgid}" ]]; then
+ kill "-${signal}" "-${target_pgid}" 2>/dev/null && return 0
+ fi
+ fi
+
+ [[ -n "${target_pid}" ]] || return 1
+ kill "-${signal}" "${target_pid}" 2>/dev/null
+}
+
+current_shell_has_ancestor() {
+ local target_pid="${1:-}"
+ local current_pid="$$"
+ local parent_pid
+
+ [[ -n "${target_pid}" ]] || return 1
+
+ while [[ -n "${current_pid}" && "${current_pid}" != "1" ]]; do
+ parent_pid="$(process_parent_id "${current_pid}")"
+ [[ -n "${parent_pid}" && "${parent_pid}" != "${current_pid}" ]] || break
+ if [[ "${parent_pid}" == "${target_pid}" ]]; then
+ return 0
+ fi
+ current_pid="${parent_pid}"
+ done
+
+ return 1
+}
+
+takeover_should_signal_listeners_only() {
+ local target_pgid="${1:-}"
+ local target_pid="${2:-}"
+ local current_pgid=""
+
+ current_pgid="$(process_group_id "$$")"
+ if [[ -n "${target_pgid}" && -n "${current_pgid}" && "${target_pgid}" == "${current_pgid}" ]]; then
+ return 0
+ fi
+
+ current_shell_has_ancestor "${target_pid}"
+}
+
pid_is_managed() {
local pid="$1"
local session_pid="$2"
@@ -251,24 +312,31 @@ hot_dev_root_pids() {
stop_hot_dev_sessions() {
local signal="${1:-TERM}"
local root_pid root_pgid root_command target_key
- declare -A seen=()
+ local seen=()
while IFS= read -r root_pid; do
[[ -n "${root_pid}" ]] || continue
root_pgid="$(process_group_id "${root_pid}")"
if [[ -n "${root_pgid}" ]]; then
+ if takeover_should_signal_listeners_only "${root_pgid}" "${root_pid}"; then
+ continue
+ fi
target_key="pgid:${root_pgid}"
- [[ -z "${seen[${target_key}]:-}" ]] || continue
- seen["${target_key}"]=1
+ if array_contains "${target_key}" "${seen[@]-}"; then
+ continue
+ fi
+ seen+=("${target_key}")
root_command="$(process_command "${root_pid}")"
log "Takeover sending ${signal} to hot-dev session group ${root_pgid} rooted at pid=${root_pid} cmd=${root_command:-unknown}"
- kill "-${signal}" "-${root_pgid}" 2>/dev/null || kill "-${signal}" "${root_pid}" 2>/dev/null || true
+ safe_kill_target "${signal}" "${root_pgid}" "${root_pid}" || true
continue
fi
target_key="pid:${root_pid}"
- [[ -z "${seen[${target_key}]:-}" ]] || continue
- seen["${target_key}"]=1
+ if array_contains "${target_key}" "${seen[@]-}"; then
+ continue
+ fi
+ seen+=("${target_key}")
root_command="$(process_command "${root_pid}")"
log "Takeover sending ${signal} to hot-dev root pid=${root_pid} cmd=${root_command:-unknown}"
kill "-${signal}" "${root_pid}" 2>/dev/null || true
@@ -295,7 +363,7 @@ stop_launchd_hot_dev_job() {
stop_takeover_targets() {
local signal="${1:-TERM}"
local port listener_pid ancestor_pid target_key target_pid target_pgid target_command
- declare -A seen=()
+ local seen=()
for port in "${FRONTEND_DEV_PORT}" "${PULSE_DEV_API_PORT}"; do
while IFS= read -r listener_pid; do
@@ -305,18 +373,24 @@ stop_takeover_targets() {
if [[ -n "${ancestor_pid}" ]]; then
target_pgid="$(process_group_id "${ancestor_pid}")"
[[ -n "${target_pgid}" ]] || continue
- target_key="pgid:${target_pgid}"
- [[ -z "${seen[${target_key}]:-}" ]] || continue
- seen["${target_key}"]=1
- target_command="$(process_command "${ancestor_pid}")"
- log "Takeover sending ${signal} to hot-dev process group ${target_pgid} rooted at pid=${ancestor_pid} cmd=${target_command:-unknown}"
- kill "-${signal}" "-${target_pgid}" 2>/dev/null || kill "-${signal}" "${ancestor_pid}" 2>/dev/null || true
- continue
+ if ! takeover_should_signal_listeners_only "${target_pgid}" "${ancestor_pid}"; then
+ target_key="pgid:${target_pgid}"
+ if array_contains "${target_key}" "${seen[@]-}"; then
+ continue
+ fi
+ seen+=("${target_key}")
+ target_command="$(process_command "${ancestor_pid}")"
+ log "Takeover sending ${signal} to hot-dev process group ${target_pgid} rooted at pid=${ancestor_pid} cmd=${target_command:-unknown}"
+ safe_kill_target "${signal}" "${target_pgid}" "${ancestor_pid}" || true
+ continue
+ fi
fi
target_key="pid:${listener_pid}"
- [[ -z "${seen[${target_key}]:-}" ]] || continue
- seen["${target_key}"]=1
+ if array_contains "${target_key}" "${seen[@]-}"; then
+ continue
+ fi
+ seen+=("${target_key}")
target_command="$(process_command "${listener_pid}")"
log "Takeover sending ${signal} to listener pid=${listener_pid} cmd=${target_command:-unknown}"
kill "-${signal}" "${listener_pid}" 2>/dev/null || true
diff --git a/scripts/tests/test-hot-dev-bg.sh b/scripts/tests/test-hot-dev-bg.sh
index e03c89f0c5..d39acbb277 100755
--- a/scripts/tests/test-hot-dev-bg.sh
+++ b/scripts/tests/test-hot-dev-bg.sh
@@ -197,6 +197,48 @@ EOF
assert_contains "default verify proof keeps chromium project pin" "${output}" "--project=chromium"
}
+test_takeover_avoids_killing_current_shell_lineage() {
+ local output
+ output="$(
+ HOT_DEV_BG_PATH="${HOT_DEV_BG}" \
+ bash -lc '
+ source "${HOT_DEV_BG_PATH}"
+ process_group_id() {
+ case "${1:-}" in
+ "$$"|900)
+ printf "4242\n"
+ ;;
+ *)
+ printf "9999\n"
+ ;;
+ esac
+ }
+ process_parent_id() {
+ case "${1:-}" in
+ "$$")
+ printf "900\n"
+ ;;
+ *)
+ printf "1\n"
+ ;;
+ esac
+ }
+ hot_dev_root_pids() { printf "900\n"; }
+ listener_pids() { printf "901\n"; }
+ find_hot_dev_ancestor() { printf "900\n"; }
+ process_command() { printf "cmd-%s\n" "${1:-unknown}"; }
+ kill() { printf "kill %s\n" "$*"; }
+
+ stop_hot_dev_sessions TERM
+ stop_takeover_targets TERM
+ '
+ )"
+
+ assert_not_contains "takeover does not signal the current process group" "${output}" "kill -TERM -4242"
+ assert_not_contains "takeover does not signal the current shell ancestor" "${output}" "kill -TERM 900"
+ assert_contains "takeover falls back to killing the occupied listener pid" "${output}" "kill -TERM 901"
+}
+
test_launchd_session_supervises_managed_runtime() {
local output
output="$(
@@ -404,7 +446,7 @@ test_hot_dev_script_advertises_foreground_escape_hatch() {
test_hot_dev_bg_script_advertises_managed_entrypoint() {
local output
- output="$(sed -n '1,720p' "${ROOT_DIR}/scripts/hot-dev-bg.sh")"
+ output="$(sed -n '1,780p' "${ROOT_DIR}/scripts/hot-dev-bg.sh")"
assert_contains "hot-dev-bg usage points to managed runtime first" "${output}" "npm run dev # Canonical managed dev runtime"
assert_contains "hot-dev-bg still documents direct launcher start" "${output}" "./scripts/hot-dev-bg.sh start [--takeover]"
@@ -658,6 +700,7 @@ main() {
test_cli_parses_takeover_flag
test_verify_command_injects_managed_runtime_env
test_default_verify_command_runs_runtime_and_layout_proofs
+ test_takeover_avoids_killing_current_shell_lineage
test_launchd_session_supervises_managed_runtime
test_start_bg_reports_browser_entrypoint
test_launchd_wrapper_uses_managed_supervisor
diff --git a/tests/integration/README.md b/tests/integration/README.md
index e3c3a5dce8..c99ff19e0d 100644
--- a/tests/integration/README.md
+++ b/tests/integration/README.md
@@ -40,6 +40,13 @@ End-to-end Playwright tests that validate critical user flows against a running
- Replays verified Stripe webhook events into control plane
- Asserts tenant activation after checkout event processing
- Asserts tenant cancellation after subscription deletion event processing
+- `tests/16-dev-runtime-recovery.spec.ts` — managed browser runtime proof:
+ - Attaches Playwright to the canonical `5173` browser entrypoint
+ - Restarts the managed backend and proves the browser shell recovers through the proxy
+- `tests/17-recovery-layout.spec.ts` — desktop Recovery layout regression guard:
+ - Mocks a realistic Recovery dataset with human-readable subject labels
+ - Proves the focused history table fits the desktop wrapper without horizontal overflow
+ - Proves the `Outcome` column stays visible at the right edge
## Running Tests
@@ -133,14 +140,14 @@ Equivalent direct proof command from the integration harness:
cd tests/integration
PULSE_E2E_USE_HOT_DEV=1 \
PULSE_E2E_SKIP_PLAYWRIGHT_INSTALL=1 \
-npm test -- tests/16-dev-runtime-recovery.spec.ts --project=chromium
+npm test -- tests/16-dev-runtime-recovery.spec.ts tests/17-recovery-layout.spec.ts --project=chromium
```
This mode attaches Playwright to the canonical dev browser entrypoint on `http://127.0.0.1:5173`, uses `scripts/hot-dev-bg.sh` as the runtime control surface, and writes browser runtime connection state for Playwright instead of targeting the backend port directly.
If the managed runtime is not already running, the harness starts it. If you need the harness to reclaim existing unmanaged `5173`/`7655` listeners first, add `PULSE_E2E_HOT_DEV_TAKEOVER=1`.
-The managed recovery proof bounces the real backend through `npm run dev:backend-restart` and verifies that the browser shell reports the outage and then recovers through the proxy. When the harness attaches to an already-running managed dev session, `posttest` leaves that runtime running.
+The managed proof pack bounces the real backend through `npm run dev:backend-restart`, verifies that the browser shell reports the outage and then recovers through the proxy, and keeps a desktop Recovery layout guard on the same canonical browser entrypoint. When the harness attaches to an already-running managed dev session, `posttest` leaves that runtime running.
For deterministic paid-feature runs against an existing instance, provide one of:
- `PULSE_E2E_BILLING_STATE_PATH=/absolute/path/to/billing.json` to let the harness write the billing state file directly.