MoonshotAI / MoonshotAI/kimi-code
Git status should handle detached HEAD by showing the current commit
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
Summary
Kimi Code appears to skip git status information when the current repository is in detached HEAD state.
The git status helper reads the branch name with:
git branch --show-current
In a detached checkout, that command returns an empty string. The current code treats an empty branch name as no status and returns null, so the footer/status UI can lose useful repository context even though the worktree is still a valid git repository.
Why this happens
apps/kimi-code/src/utils/git/git-status.ts returns null when getBranchName() is empty. Detached HEAD is common when users:
- check out a tag,
- inspect a specific commit,
- reproduce a CI failure,
- review a generated branch/commit from another tool.
Suggested behavior
If git branch --show-current is empty, fall back to something like:
git rev-parse --short HEAD
Then display a detached label such as:
detached@abc1234
The rest of the status calculation can still use git status --porcelain=v1 --branch; it already includes detached/head metadata that could also be parsed if preferred.
Why it matters
Detached HEAD is not an error state. Users still benefit from seeing that Kimi Code is operating inside a git repository and which commit is currently checked out.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in apps/kimi-code/src/utils/git/git-status.ts, focusing on getBranchName() and the path that returns null for an empty branch name. Check the existing git status commands, then verify that a detached checkout displays a detached label with the short commit while normal branch status remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, typescript
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100