diff --git a/.claude/hooks/goal_phase_eval.sh b/.claude/hooks/goal_phase_eval.sh index 8469459..a5f7170 100755 --- a/.claude/hooks/goal_phase_eval.sh +++ b/.claude/hooks/goal_phase_eval.sh @@ -32,6 +32,7 @@ esac [ -z "$TRANSCRIPT" ] && exit 0 [ -f "$TRANSCRIPT" ] || exit 0 -# Afinar el reposo en background; el hook retorna de inmediato. +# Afinar el reposo en background; el hook retorna de inmediato (no bloquea el +# turno). El statusline reflejara el valor final en el siguiente refresco. nohup bash "$HOME/.claude/hooks/goal_phase_worker.sh" "$SID" "$TRANSCRIPT" "$F" >/dev/null 2>&1 & exit 0 diff --git a/.claude/settings.json b/.claude/settings.json index 9647d39..d224548 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -39,7 +39,8 @@ "statusLine": { "type": "command", "command": "~/.claude/statusline.sh", - "padding": 1 + "padding": 1, + "refreshInterval": 2 }, "enabledPlugins": { "gopls-lsp@claude-plugins-official": true, diff --git a/.claude/statusline.sh b/.claude/statusline.sh index b3cb2eb..6b1d698 100755 --- a/.claude/statusline.sh +++ b/.claude/statusline.sh @@ -63,10 +63,18 @@ RESET_7D="" [ "$RESET_5H_EPOCH" -gt 0 ] && RESET_5H=$(date -d "@$RESET_5H_EPOCH" +"%H:%M" 2>/dev/null) [ "$RESET_7D_EPOCH" -gt 0 ] && RESET_7D=$(date -d "@$RESET_7D_EPOCH" +"%a %H:%M" 2>/dev/null) -# Git info (si estamos en un repo) +# Git info (si estamos en un repo). Con cache de TTL corto: como el statusline +# se re-ejecuta cada pocos segundos (refreshInterval), recomputar git en cada +# tick es caro en repos grandes y el estado git no cambia estando idle. Se cachea +# por directorio y se recomputa solo si el cache tiene mas de 6s. GIT_BRANCH="" GIT_STATUS="" -if git rev-parse --git-dir > /dev/null 2>&1; then +GIT_CACHE="/tmp/fn_sl_git_$(printf '%s' "$CURRENT_DIR" | cksum | cut -d' ' -f1).cache" +GIT_CACHE_AGE=999 +[ -f "$GIT_CACHE" ] && GIT_CACHE_AGE=$(( $(date +%s) - $(stat -c %Y "$GIT_CACHE" 2>/dev/null || echo 0) )) +if [ "$GIT_CACHE_AGE" -lt 6 ]; then + . "$GIT_CACHE" +elif git rev-parse --git-dir > /dev/null 2>&1; then GIT_BRANCH=$(git branch --show-current 2>/dev/null || echo "detached") # Obtener archivos staged, modified, untracked @@ -94,6 +102,9 @@ if git rev-parse --git-dir > /dev/null 2>&1; then # Trim trailing space GIT_STATUS=$(echo "$GIT_STATUS" | sed 's/ $//') + + # Guardar en cache (quoting seguro para re-source). + printf 'GIT_BRANCH=%q\nGIT_STATUS=%q\n' "$GIT_BRANCH" "$GIT_STATUS" > "$GIT_CACHE" 2>/dev/null fi # Color estable por sesión (hash del session_id → paleta ANSI 256 legible).