Skip to content

Commit tool window steals focus when the prefix is updated on branch change #37

Description

@thomasrepnik

Describe the bug

When the current git branch changes (e.g. via git switch in the terminal), Git Auto Prefix updates the commit message prefix — but the update also activates the Commit tool window and moves keyboard focus into the commit message editor. Focus is stolen from whatever the user was doing (typically the terminal).

Steps to reproduce

  1. Use the non-modal commit UI (default) and open a git project.
  2. Focus the embedded terminal.
  3. Switch to a branch with a different ticket, e.g. git switch -c feature/ABC-1234-test.

Expected behavior

The commit message prefix is updated to ABC-1234: in the background. Focus stays in the terminal.

Actual behavior

The prefix is updated, but the Commit tool window is activated and grabs focus (the message text is also select-all-ed).

Root cause

CommitPrefixCheckinHandler.updateCommitMessage() calls CheckinProjectPanel.setCommitMessage(...) on every GIT_REPO_CHANGE event. In the non-modal commit UI the panel is the platform's CommitProjectPanelAdapter, whose setCommitMessage() unconditionally calls commitMessageUi.focus() — which activates the Commit tool window.

Additionally, the message bus connection created in the handler's constructor is never disposed, so stale handlers accumulate (handlers are re-created when VCS mappings change) and each one repeats the focus-stealing update.

Environment

  • Plugin: Git Auto Prefix 1.4.2
  • IDE: IntelliJ IDEA 2026.1.4, non-modal commit interface

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions