Skip to content

fix(ui): send prompt on first click when switching branch#3277

Merged
MattPua merged 1 commit into
mainfrom
posthog-code/fix-branch-switch-single-click
Jul 10, 2026
Merged

fix(ui): send prompt on first click when switching branch#3277
MattPua merged 1 commit into
mainfrom
posthog-code/fix-branch-switch-single-click

Conversation

@MattPua

@MattPua MattPua commented Jul 8, 2026

Copy link
Copy Markdown
Member

Problem

Clicking "Switch branch" on the branch-mismatch dialog switched the branch but didn't send the pending prompt, so it had to be sent again.

Changes

  • Removed the AlertDialog.Action wrapper around "Switch branch". It force-closes the dialog on click, which fired onCancel() and wiped the pending message before the async checkoutBranch mutation resolved.
  • handleCancel in useBranchMismatchDialog now no-ops while a switch is in flight, so a dismiss during the async checkout can't drop the pending message.

How did you test this?

  • pnpm --filter @posthog/ui test useBranchMismatchDialog -- 9/9 passing (added a test covering dismiss-during-switch).

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

Switch branch was wrapped in AlertDialog.Action, which force-closed the dialog on click. That fired onOpenChange(false) -> onCancel(), wiping the pending message before the async checkoutBranch mutation resolved, so the prompt was silently dropped and the user had to send it again.

Generated-By: PostHog Code
Task-Id: 1040f7c6-d5ab-4994-9854-a7eaadf01a9a
@trunk-io

trunk-io Bot commented Jul 8, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit d9f0589.

@MattPua MattPua marked this pull request as ready for review July 8, 2026 16:04
@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(ui): send prompt on first click when..." | Re-trigger Greptile

@charlesvien charlesvien added the Stamphog This will request an autostamp by stamphog on small changes label Jul 10, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, focused bug fix: removes the Radix AlertDialog.Action auto-close wrapper and adds an isSwitching guard in handleCancel so a pending prompt isn't silently dropped during an in-flight branch switch. New test covers the scenario directly.

@MattPua MattPua merged commit e279264 into main Jul 10, 2026
32 checks passed
@MattPua MattPua deleted the posthog-code/fix-branch-switch-single-click branch July 10, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants