Skip to content

Fix: commit message reappears after committing while switching tabs#21721

Merged
sergiou87 merged 2 commits intodevelopmentfrom
copilot/fix-commit-message-clearing-again
Mar 4, 2026
Merged

Fix: commit message reappears after committing while switching tabs#21721
sergiou87 merged 2 commits intodevelopmentfrom
copilot/fix-commit-message-clearing-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

When a user clicks Commit and quickly navigates to the History tab, the CommitMessage component unmounts mid-commit, persisting the typed message to gitStore._commitMessage via componentWillUnmount. After the commit succeeds, gitStore._commitMessage was never cleared — so returning to the Changes tab remounts the component with the stale message.

Description

Root cause: gitStore._commitMessage is only set to DefaultCommitMessage at startup or when undoing/amending commits. In the normal flow (component stays mounted), it's never written at all during a commit, so it stays as DefaultCommitMessage and componentWillReceiveProps (which guards on timestamp comparison) correctly ignores it. But when the component unmounts mid-commit, componentWillUnmount writes the user's typed message into the git store — and nothing ever clears it.

Fix: After a successful commit in _commitIncludedChanges, explicitly reset the git store's commit message before refreshing state:

// app/src/lib/stores/app-store.ts
await gitStore.setCommitMessage(DefaultCommitMessage)

await this.refreshChangesSection(repository, {
  includingStatus: true,
  clearPartialState: true,
})

This is safe for the mounted case because DefaultCommitMessage.timestamp === 0, so componentWillReceiveProps's timestamp > guard prevents it from overriding any message the user may have already started typing for the next commit.

Screenshots

N/A — no UI change in the normal commit flow; this only affects the race condition when switching tabs during a commit.

Release notes

Notes: Fixed a bug where the commit message was not cleared after a successful commit when the user switched to the History tab while the commit was in progress.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • electronjs.org
    • Triggering command: /opt/hostedtoolcache/node/24.13.1/x64/bin/node /opt/hostedtoolcache/node/24.13.1/x64/bin/node /opt/hostedtoolcache/node/24.13.1/x64/lib/node_modules/npm/bin/node-gyp-bin/../../node_modules/node-gyp/bin/node-gyp.js rebuild (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Commit message is not cleared after commit has been done</issue_title>
<issue_description>### The problem

When pushing a commit while navigating to the "History" tab the commit message hasn't been cleared after the push has been concluded.

Release version

Version 3.5.4 (x64)

Operating system

Windows 11 Home

Steps to reproduce the behavior

(Updated by @sergiou87 after being able to reproduce this without pushing, on both macOs and Windows… see #21602 (comment))

  1. Create some changes in a repo
  2. Write a commit title
  3. Click on the Commit button and very quickly press Control/Cmd + 2 to switch to the History tab while the app is making the commit.
  4. After the commit is done, switch back to the Changes tab.

Log files

Sorry, for privacy reasons I can't share it

Screenshots

No response

Additional context

No response</issue_description>

<agent_instructions>Use the agent deskocat for this task (you can find it in .github/agents/deskocat.agent.md)</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@sergiou87 Thank you for your report!! 💖

I was able to reproduce this on both Windows and macOS, but there is no need to push the commit, just switching to the History tab while it's making the commit is enough. These are my steps to reproduce:

  1. Create some changes in a repo
  2. Write a commit title
  3. Click on the Commit button and very quickly press Control/Cmd + 2 to switch to the History tab while the app is making the commit.
  4. After the commit is done, switch back to the Changes tab.

The commit title is still there and it shouldn't 😬 </comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix commit message not clearing after commit Fix: commit message reappears after committing while switching tabs Mar 3, 2026
@sergiou87 sergiou87 changed the base branch from what-are-engineers-now to development March 3, 2026 11:04
Copilot AI and others added 2 commits March 3, 2026 12:04
Co-authored-by: sergiou87 <1083228+sergiou87@users.noreply.github.com>
@sergiou87 sergiou87 force-pushed the copilot/fix-commit-message-clearing-again branch from 05c2e7f to b2650de Compare March 3, 2026 11:05
@sergiou87 sergiou87 marked this pull request as ready for review March 3, 2026 11:12
@sergiou87 sergiou87 merged commit d24b314 into development Mar 4, 2026
7 checks passed
@sergiou87 sergiou87 deleted the copilot/fix-commit-message-clearing-again branch March 4, 2026 08:47
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.

Commit message is not cleared after commit has been done

3 participants