You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for taking the time to fill out this bug report!
Please search existing issues to see if an issue already exists for the bug you encountered.
What happened?
The git branch name displayed in the footer (below the input prompt) does not update when the user switches branches externally (e.g. git checkout branch2 or git switch branch2). Running /clear also does not refresh it. The stale branch name persists until the next fs.watch event fires (which may never happen on some filesystems).
What did you expect to happen?
The branch name in the footer should update within a few seconds of switching branches, regardless of the filesystem type.
Steps to reproduce
Start qwen-code in a git repo on branch feature-1
Confirm the footer shows feature-1
In another terminal (or via !git switch feature-2), switch to feature-2
Observe the footer still shows feature-1
Run /clear — footer still shows feature-1
Root cause
useGitBranchName (packages/cli/src/ui/hooks/useGitBranchName.ts) uses watchRepoBranch which sets up fs.watch on .git/logs/HEAD (the reflog). Two problems:
fs.watch is unreliable on some filesystems (NFS, FUSE, Docker overlay, some Linux filesystems). Events can be silently dropped, leaving the branch name stale with no recovery path.
No polling fallback. Unlike the extension file watcher which has both fs.watch and a generation-based polling fallback, the branch watcher has no polling. If the watch event is missed, the branch name stays stale indefinitely.
/clear does not trigger a refresh. The useEffect in useGitBranchName depends on [cwd]. Since /clear doesn't change cwd, the effect doesn't re-run and no refresh occurs.
Suggested fix
Add a polling fallback (e.g. every 5-10 seconds) in watchRepoBranch or useGitBranchName that calls resolveBranchName and compares with the current value, triggering onChange if different.
Alternatively, expose a refreshGitBranch() function and call it from /clear, new message submission, and other session lifecycle events.
Environment
Qwen Code: v0.20.1 / v0.21.0
OS: Linux (reported on multiple filesystem types)
Anything else we need to know?
resolveBranchName itself does NOT cache — it reads .git/HEAD directly every call. The problem is purely that the watcher doesn't fire and there's no fallback to trigger a re-read.
Important
Thanks for taking the time to fill out this bug report!
Please search existing issues to see if an issue already exists for the bug you encountered.
What happened?
The git branch name displayed in the footer (below the input prompt) does not update when the user switches branches externally (e.g.
git checkout branch2orgit switch branch2). Running/clearalso does not refresh it. The stale branch name persists until the next fs.watch event fires (which may never happen on some filesystems).What did you expect to happen?
The branch name in the footer should update within a few seconds of switching branches, regardless of the filesystem type.
Steps to reproduce
feature-1feature-1!git switch feature-2), switch tofeature-2feature-1/clear— footer still showsfeature-1Root cause
useGitBranchName(packages/cli/src/ui/hooks/useGitBranchName.ts) useswatchRepoBranchwhich sets upfs.watchon.git/logs/HEAD(the reflog). Two problems:fs.watchis unreliable on some filesystems (NFS, FUSE, Docker overlay, some Linux filesystems). Events can be silently dropped, leaving the branch name stale with no recovery path.No polling fallback. Unlike the extension file watcher which has both
fs.watchand a generation-based polling fallback, the branch watcher has no polling. If the watch event is missed, the branch name stays stale indefinitely./cleardoes not trigger a refresh. TheuseEffectinuseGitBranchNamedepends on[cwd]. Since/cleardoesn't changecwd, the effect doesn't re-run and no refresh occurs.Suggested fix
Add a polling fallback (e.g. every 5-10 seconds) in
watchRepoBranchoruseGitBranchNamethat callsresolveBranchNameand compares with the current value, triggeringonChangeif different.Alternatively, expose a
refreshGitBranch()function and call it from/clear, new message submission, and other session lifecycle events.Environment
Anything else we need to know?
resolveBranchNameitself does NOT cache — it reads.git/HEADdirectly every call. The problem is purely that the watcher doesn't fire and there's no fallback to trigger a re-read.