#!/usr/bin/env bash
# Route the Claude Code statusline by launch mode.
# claudex (Systray AI codex proxy) exports SYSTRAY_CODEX_ACCOUNT_SLUG into the
# child claude env; a plain `claude` session never sets it.
#   claudex      -> statusline.py (codex account + 5h/7d codex usage)
#   plain claude -> statusline-command.sh (native model + Anthropic 5h/7d usage)
# Arg 1 is the entry point: "render" (statusLine) or "session-start" (hook).
set -euo pipefail
mode=${1:-render}

if [ -n "${SYSTRAY_CODEX_ACCOUNT_SLUG:-}" ]; then
  # Named on PATH, not by workstation path: every host this file converges to carries a
  # different ~/.local/bin, and an absolute miss here renders an empty statusline.
  codex_statusline="$(command -v statusline.py)" || {
    echo "statusline-router: statusline.py is not on PATH — no codex statusline on this host" >&2
    exit 1
  }
  exec "$codex_statusline" "$mode"
fi

case "$mode" in
  render) exec bash /home/user/.claude/statusline-command.sh ;;
  *) exit 0 ;;  # native mode has no session priming step
esac
