mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 09:47:22 +01:00
After a PC restart, Fleet Runner now brings zellij + every agent back
without the user opening a terminal or typing CLI names. The last
runtime_snapshot.panes (extended with {tab, paneIndex, agentCli, cwd})
acts as SSOT for "what should be running" — Fleet Runner generates a KDL
layout with embedded `bash -c "cd … && claude"` per pane and spawns
`zellij --session fleet --layout`, bypassing zellij's press-ENTER
resurrection prompt entirely.
Injection is now self-healing end-to-end. Pre-flight ensureZellijReady
re-spawns the session if it died mid-day. /tmp/fc-cmd-<id>.done sentinels
make commands actually idempotent so a PATCH-ack retry can't fire the
same prompt twice. Post-flight watches ~/.claude/sessions/<tab>.md mtime
for 5s after inject and reports verified=false if the agent didn't pick
up — surfaced in AttentionBar via getRecentFailedCommands. The legacy
"No Zellij session found — start Zellij first" throw is replaced with a
synchronous spawn-default-session path so /api/agent/launch on
self-hosted servers self-heals too.
Settings → Agent gets a new Fleet Lifecycle section (auto-restore on/off,
fresh-spawn vs leave-alone for exited zellij sessions, session name,
auto-start at login). Stored as users.fleet_settings jsonb so future
knobs don't need a migration each time.
Bundled binary version-aware (Fleet Runner ≥0.4.0 ships zellij in
resources/bin and prepends to PATH). Inline tests for the KDL generator
run as a 9th suite under `npm run test:home` — 8/8 cases pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
62 lines
2.2 KiB
Bash
Executable File
62 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Run every inline self-test suite under home/. Each suite is a single
|
|
# tsx invocation with no external test runner — see home/README.md for
|
|
# the per-module breakdown. Exits non-zero on the first failure.
|
|
#
|
|
# Use: npm run test:home
|
|
# bash scripts/test-home.sh
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
# Module → invocation. Modules with --self-test gate their boot path on
|
|
# the flag; the others (state/decide/projects/render) run their suite
|
|
# when invoked directly with no args.
|
|
declare -A SUITES=(
|
|
[state]="home/state.ts"
|
|
[decide]="home/decide.ts"
|
|
[projects]="home/projects.ts"
|
|
[render]="home/render.ts"
|
|
[emit]="home/emit.ts --self-test"
|
|
[log]="home/log.ts --self-test"
|
|
[watcher]="home/watcher.ts --self-test"
|
|
[worker]="home/worker.ts --self-test"
|
|
[layout-generator]="src/lib/zellij-layout-generator.ts --self-test"
|
|
)
|
|
|
|
# Stable order so the output reads top-to-bottom predictably.
|
|
SUITES_ORDER=(state decide projects render emit log watcher worker layout-generator)
|
|
|
|
cd "$REPO_ROOT"
|
|
|
|
total_pass=0
|
|
total_fail=0
|
|
for name in "${SUITES_ORDER[@]}"; do
|
|
cmd="${SUITES[$name]}"
|
|
printf '\n→ %s\n' "$name"
|
|
# Capture full output so we can extract the N/M passed footer.
|
|
output=$(npx tsx $cmd 2>&1) || {
|
|
echo "$output"
|
|
echo "✗ $name suite failed"
|
|
exit 1
|
|
}
|
|
echo "$output"
|
|
# Parse "N/M" from the final line — most suites print "N/M passed"
|
|
# but render.ts uses "N/M intents render". Match the count tokens only.
|
|
footer=$(printf '%s' "$output" | tail -1)
|
|
if [[ "$footer" =~ ^([0-9]+)/([0-9]+) ]]; then
|
|
total_pass=$(( total_pass + ${BASH_REMATCH[1]} ))
|
|
total_fail=$(( total_fail + ${BASH_REMATCH[2]} - ${BASH_REMATCH[1]} ))
|
|
fi
|
|
done
|
|
|
|
echo
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
printf '✓ %d total tests passed across %d home/ self-test suites\n' "$total_pass" "${#SUITES[@]}"
|
|
if (( total_fail > 0 )); then
|
|
printf '✗ %d failures\n' "$total_fail"
|
|
exit 1
|
|
fi
|