Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: git merge button visibility on branch change after a successful merge #38847

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

ashit-rath
Copy link
Contributor

@ashit-rath ashit-rath commented Jan 27, 2025

Description

The mergeSuccess status in the reducer was not getting reset on branch change.
Introduced a new action to reset it on change

Fixes #38844

Automation

/ok-to-test tags="@tag.Git"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12983463132
Commit: f012fbb
Cypress dashboard.
Tags: @tag.Git
Spec:


Mon, 27 Jan 2025 07:39:33 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced merge state management with a new resetMergeSuccessState function
    • Improved ability to reset merge success state during branch selection
  • Bug Fixes

    • Resolved potential state persistence issues in merge operations
  • Refactor

    • Updated hooks and components to support more flexible merge state handling

@ashit-rath ashit-rath self-assigned this Jan 27, 2025
Copy link
Contributor

coderabbitai bot commented Jan 27, 2025

Walkthrough

This pull request introduces a mechanism to reset the merge success state across multiple components in the Git integration module. The changes span four files, adding a new resetMergeSuccessState function that allows clearing the merge success state when switching between merge operations. The modification ensures that the merge button and related UI elements can be properly reset after a previous successful merge.

Changes

File Change Summary
app/client/.../TabMergeView.tsx Added resetMergeSuccessState method to component props
app/client/.../TabMerge/index.tsx Extracted and passed resetMergeSuccessState from useMerge hook
app/client/.../useMerge.ts Implemented resetMergeSuccessState function in hook
app/client/.../mergeActions.ts Added resetMergeSuccessAction for state management
app/client/.../gitArtifactSlice.ts Added reducer for resetting merge success state

Assessment against linked issues

Objective Addressed Explanation
Fix merge button visibility after previous merge
Ensure merge UI resets between operations

Possibly related PRs

Suggested labels

bug, git-integration, ui-fix, state-management

Suggested reviewers

  • hetunandu
  • sagar-qa007
  • ankitakinger

Poem

🌿 Merge branches dance and sway,
Reset state, clear the way!
Button hidden, now in sight,
Git's magic works just right! 🚀

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Bug Something isn't working DailyPromotionBlocker DailyPromotionBlocker Git Product Issues related to version control product Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage Packages & Git Pod All issues belonging to Packages and Git Release labels Jan 27, 2025
@ashit-rath ashit-rath added the ok-to-test Required label for CI label Jan 27, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/client/src/git/components/OpsModal/TabMerge/TabMergeView.tsx (1)

211-222: Consider consolidating merge state management.

The component manages multiple merge-related states (mergeStatus, isMergeSuccess, etc.). Consider extracting this logic into a custom hook for better maintainability.

This would help:

  • Centralize merge state management
  • Simplify the component logic
  • Make state transitions more predictable
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7552813 and f012fbb.

📒 Files selected for processing (5)
  • app/client/src/git/components/OpsModal/TabMerge/TabMergeView.tsx (3 hunks)
  • app/client/src/git/components/OpsModal/TabMerge/index.tsx (2 hunks)
  • app/client/src/git/hooks/useMerge.ts (2 hunks)
  • app/client/src/git/store/actions/mergeActions.ts (1 hunks)
  • app/client/src/git/store/gitArtifactSlice.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
🔇 Additional comments (7)
app/client/src/git/store/actions/mergeActions.ts (1)

44-48: LGTM! Clean implementation of the reset action.

The action follows the established pattern and maintains a single responsibility of resetting the merge success state.

app/client/src/git/components/OpsModal/TabMerge/index.tsx (1)

19-19: LGTM! Clean prop handling.

The resetMergeSuccessState is properly extracted from the hook and passed down to the child component.

Also applies to: 46-46

app/client/src/git/hooks/useMerge.ts (1)

69-73: LGTM! Well-structured hook implementation.

The resetMergeSuccessState function is properly memoized and follows the established pattern for state management functions.

Also applies to: 86-86

app/client/src/git/store/gitArtifactSlice.ts (1)

88-88: LGTM! Proper Redux integration.

The action is correctly imported and integrated into the reducers object in the appropriate section.

Also applies to: 196-196

app/client/src/git/components/OpsModal/TabMerge/TabMergeView.tsx (3)

83-83: LGTM! Interface update is clean and well-typed.

The addition of resetMergeSuccessState to the interface maintains type safety.


103-103: LGTM! Default prop value prevents runtime errors.

Good practice using noop as the default value to prevent undefined function calls.


213-221: Verify the timing of merge status reset.

The implementation correctly resets the merge success state when selecting a new branch. However, we should verify that this doesn't interfere with the merge status fetching.

Let's verify the sequence of operations:

✅ Verification successful

The merge status reset implementation is safe and well-structured.

The reset occurs after initiating the fetch but doesn't interfere with its completion. The Redux store properly manages state transitions, and the UI correctly reflects all possible states including loading states.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other components that might be affected by the merge success state reset
rg "resetMergeSuccessState" -B 2 -A 2

# Look for potential race conditions in merge status related effects
ast-grep --pattern 'useEffect($$$fetchMergeStatus$$$)'

Length of output: 69556


Script:

#!/bin/bash
# Find the fetchMergeStatus implementation and its dependencies
ast-grep --pattern 'const fetchMergeStatus = $$$'

# Look for components using mergeSuccess state
rg "mergeSuccess" -B 2 -A 2

# Find other useEffect hooks that might be affected by merge status changes
ast-grep --pattern 'useEffect($$$mergeStatus$$$)'

Length of output: 77676


Script:

#!/bin/bash
# Find the Redux reducer handling merge status
rg "case ['\"].*MERGE.*['\"]" -B 2 -A 4

# Find components subscribing to merge status state
rg "useSelector.*merge" -B 2 -A 2

# Find the complete chain of merge status actions
rg "MERGE_STATUS" -B 2 -A 2

Length of output: 15794

@ashit-rath ashit-rath merged commit 56018b0 into release Jan 27, 2025
48 checks passed
@ashit-rath ashit-rath deleted the fix/git-merge-btn branch January 27, 2025 07:54
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Feb 7, 2025
…merge (appsmithorg#38847)

## Description
The `mergeSuccess` status in the reducer was not getting reset on branch
change.
Introduced a new action to reset it on change

Fixes appsmithorg#38844

## Automation

/ok-to-test tags="@tag.Git"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/12983463132>
> Commit: f012fbb
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12983463132&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Mon, 27 Jan 2025 07:39:33 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced merge state management with a new `resetMergeSuccessState`
function
	- Improved ability to reset merge success state during branch selection

- **Bug Fixes**
	- Resolved potential state persistence issues in merge operations

- **Refactor**
- Updated hooks and components to support more flexible merge state
handling

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working DailyPromotionBlocker DailyPromotionBlocker Git Product Issues related to version control product Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Packages & Git Pod All issues belonging to Packages and Git Release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: The Merge Changes button isn't seen after a successful merge was done previously
2 participants