chore(claude-opus-4-6): Branch name in sidebar sometimes doesn't update correctly... (#199)

This commit is contained in:
Austin Wang 2026-02-20 14:31:13 -08:00 committed by GitHub
parent f3a4e4db43
commit 94d44fefd2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 6 deletions

View file

@ -88,9 +88,16 @@ _cmux_prompt_command() {
# Git branch/dirty can change without a directory change (e.g. `git checkout`),
# so update on every prompt (still async + de-duped by the running-job check).
# When pwd changes (cd into a different repo), kill the old probe and start fresh
# so the sidebar picks up the new branch immediately.
if [[ -n "$_CMUX_GIT_JOB_PID" ]] && kill -0 "$_CMUX_GIT_JOB_PID" 2>/dev/null; then
:
else
if [[ "$pwd" != "$_CMUX_GIT_LAST_PWD" ]]; then
kill "$_CMUX_GIT_JOB_PID" >/dev/null 2>&1 || true
_CMUX_GIT_JOB_PID=""
fi
fi
if [[ -z "$_CMUX_GIT_JOB_PID" ]] || ! kill -0 "$_CMUX_GIT_JOB_PID" 2>/dev/null; then
_CMUX_GIT_LAST_PWD="$pwd"
_CMUX_GIT_LAST_RUN=$now
{

View file

@ -139,11 +139,12 @@ _cmux_preexec() {
_CMUX_CMD_START=$EPOCHSECONDS
# Heuristic: git commands can change branch/dirty state without changing $PWD.
# Heuristic: commands that may change git branch/dirty state without changing $PWD.
local cmd="${1## }"
if [[ "$cmd" == git\ * || "$cmd" == git ]]; then
_CMUX_GIT_FORCE=1
fi
case "$cmd" in
git\ *|git|gh\ *|lazygit|lazygit\ *|tig|tig\ *|gitui|gitui\ *|stg\ *|jj\ *)
_CMUX_GIT_FORCE=1 ;;
esac
# Register TTY + kick batched port scan for foreground commands (servers).
_cmux_report_tty_once
@ -196,6 +197,9 @@ _cmux_precmd() {
head_mtime="$(_cmux_git_head_mtime "$_CMUX_GIT_HEAD_PATH" 2>/dev/null || echo 0)"
if [[ -n "$head_mtime" && "$head_mtime" != 0 && "$head_mtime" != "$_CMUX_GIT_HEAD_MTIME" ]]; then
_CMUX_GIT_HEAD_MTIME="$head_mtime"
# Treat HEAD file change like a git command — force-replace any
# running probe so the sidebar picks up the new branch immediately.
_CMUX_GIT_FORCE=1
should_git=1
fi
fi