Skip to content

fix(tui): show detached HEAD in git status#602

Open
lurenjia534 wants to merge 1 commit into
MoonshotAI:mainfrom
lurenjia534:fix/detached-head-git-status
Open

fix(tui): show detached HEAD in git status#602
lurenjia534 wants to merge 1 commit into
MoonshotAI:mainfrom
lurenjia534:fix/detached-head-git-status

Conversation

@lurenjia534

Copy link
Copy Markdown
Contributor

Related Issue

Resolve #566

Problem

See linked issue. In a detached HEAD checkout, git branch --show-current returns an empty string even though the working directory is still a valid git repository. The footer could therefore drop useful git context instead of showing which commit is checked out.

What changed

  • Fall back to git rev-parse --short HEAD when no branch name is available and display detached@<short-sha>.
  • Treat detached HEAD as a no-branch state for pull request lookup so stale branch PR results cannot appear in the footer.
  • Add regression coverage for detached HEAD display and stale pull request callbacks after switching from a branch to detached HEAD.

Verification

  • corepack pnpm vitest run apps/kimi-code/test/utils/git/git-status.test.ts
  • corepack pnpm --filter @moonshot-ai/kimi-code run typecheck
  • corepack pnpm lint (515 warnings, 0 errors; warnings are existing repository-wide lint warnings)
  • Built the full CLI with corepack pnpm --filter @moonshot-ai/kimi-code run build and manually verified the footer in a detached checkout

Note: full corepack pnpm test was also run locally on Windows before opening this PR and failed on unrelated existing Windows/path/process snapshot failures; the focused regression test above passes.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5166916

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 9, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@5166916
npx https://pkg.pr.new/@moonshot-ai/kimi-code@5166916

commit: 5166916

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git status should handle detached HEAD by showing the current commit

1 participant