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

chore: git mod - minor fixes #38563

Merged
merged 4 commits into from
Jan 10, 2025
Merged

chore: git mod - minor fixes #38563

merged 4 commits into from
Jan 10, 2025

Conversation

brayn003
Copy link
Contributor

@brayn003 brayn003 commented Jan 9, 2025

Description

  • Fixes initial loading state for status
  • Includes module instances and source module count
  • Fixes discard flow

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/12692930817
Commit: 6689c8e
Cypress dashboard.
Tags: @tag.Git
Spec:


Fri, 10 Jan 2025 08:32:22 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new focus on source modules instead of packages
    • Enhanced tracking of module instances and source module changes
  • Bug Fixes

    • Updated status change calculations to more accurately reflect module modifications
    • Improved handling of artifact identification in discard operations
  • Refactor

    • Renamed and restructured various status-related interfaces and functions
    • Modified selectors and reducers to support new module tracking approach
  • Chores

    • Updated type definitions and selector implementations
    • Removed deprecated package-related tracking mechanisms

@brayn003 brayn003 requested a review from a team as a code owner January 9, 2025 15:11
Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

Walkthrough

This pull request introduces significant changes to the Git synchronization and status tracking mechanisms in the application. The modifications primarily focus on transforming how module instances and source modules are processed, removing package-related tracking, and updating various components to reflect these changes. The updates span multiple files, affecting status transformations, component props, hooks, and selectors to align with a new approach to tracking Git changes.

Changes

File Path Change Summary
app/client/src/git/artifact-helpers/application/applicationStatusTransformer.ts Replaced statusPackagesTransformer with statusModuleInstancesTransformer
app/client/src/git/components/QuickActions/* Updated isStatusClean default value from false to true
app/client/src/git/hooks/useDiscard.ts Added artifactId extraction and updated discard logic
app/client/src/git/requests/fetchStatusRequest.types.ts Removed modifiedPackages and modifiedModules, added modifiedSourceModules
app/client/src/pages/Editor/gitSync/components/GitChangesList/* Removed package-related changes, updated module change tracking
app/client/src/reducers/uiReducers/gitSyncReducer.ts Updated GitStatusData interface
app/client/src/selectors/* Modified selectors to handle new module instance tracking

Sequence Diagram

sequenceDiagram
    participant Client
    participant GitStatusTransformer
    participant StatusSelector
    participant UIComponent

    Client->>GitStatusTransformer: Fetch Git Status
    GitStatusTransformer->>StatusSelector: Transform Status
    StatusSelector-->>UIComponent: Update with Source Modules
    UIComponent->>Client: Render Changes
Loading

Possibly related PRs

Suggested Labels

Bug, Task, Git Product, skip-changelog, ok-to-test, Packages & Git Pod

Suggested Reviewers

  • ashit-rath
  • nidhi-nair
  • sharat87

Poem

🌿 Modules dance, packages fade away,
Git's rhythm finds a brand new way
Status transforms with elegant grace
Source modules now take center stage
Code evolves, simplicity prevails! 🚀

Finishing Touches

  • 📝 Generate Docstrings

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 the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jan 9, 2025
@brayn003 brayn003 changed the title chore: git mod fixes 1 chore: git mod - minor fixes Jan 9, 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: 1

🧹 Nitpick comments (5)
app/client/src/pages/Editor/gitSync/components/GitChangesList/StaticChange.tsx (1)

59-62: Simplify the conditional message formatting.

The conditional string formatting can be simplified using template literals.

-    message: `${status.modifiedSourceModules ?? 0} ${
-      (status.modifiedSourceModules ?? 0) > 0 ? "modules" : "module"
-    } modified`,
+    message: `${status.modifiedSourceModules ?? 0} module${status.modifiedSourceModules !== 1 ? 's' : ''} modified`,
app/client/src/git/artifact-helpers/application/applicationStatusTransformer.ts (1)

275-276: Add type safety for status parameters.

Consider adding explicit type annotations for the destructured values to ensure type safety.

-  const { modifiedModuleInstances = 0, modifiedSourceModules = 0 } = status;
+  const { modifiedModuleInstances = 0 as number, modifiedSourceModules = 0 as number } = status;
app/client/src/selectors/gitSyncSelectors.tsx (1)

Line range hint 149-167: Consider grouping related modifications.

The count calculation could be more maintainable by grouping related modifications.

-  return (
-    modifiedDatasources +
-    modifiedJSLibs +
-    modifiedJSObjects +
-    modifiedSourceModules +
-    modifiedModuleInstances +
-    modifiedPages +
-    modifiedQueries +
-    themeCount +
-    settingsCount
-  );
+  const moduleChanges = modifiedSourceModules + modifiedModuleInstances;
+  const jsChanges = modifiedJSLibs + modifiedJSObjects;
+  const pageChanges = modifiedPages + modifiedQueries;
+  const configChanges = themeCount + settingsCount;
+  
+  return moduleChanges + jsChanges + pageChanges + configChanges + modifiedDatasources;
app/client/src/reducers/uiReducers/gitSyncReducer.ts (1)

757-758: Consider using strict types for module counts.

The changes look good. However, since these represent counts, consider using non-nullable types with default values.

-  modifiedSourceModules?: number;
-  modifiedModuleInstances?: number;
+  modifiedSourceModules: number = 0;
+  modifiedModuleInstances: number = 0;
app/client/src/git/hooks/useDiscard.ts (1)

9-10: Consider adding type safety for artifact ID.

The changes look good and improve artifact handling. Consider adding type assertion or validation for the artifact ID.

-  const artifactId = artifact?.id;
+  const artifactId = artifact?.id as string | undefined;
+  if (!artifactId) {
+    console.warn('Artifact ID is missing');
+  }

Also applies to: 16-17, 19-19

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6446f46 and 20a320d.

📒 Files selected for processing (15)
  • app/client/src/git/artifact-helpers/application/applicationStatusTransformer.ts (2 hunks)
  • app/client/src/git/components/QuickActions/BranchButton.tsx (1 hunks)
  • app/client/src/git/components/QuickActions/QuickActionsView.tsx (1 hunks)
  • app/client/src/git/components/QuickActions/hooks/useStatusChangeCount.ts (2 hunks)
  • app/client/src/git/components/QuickActions/index.tsx (1 hunks)
  • app/client/src/git/hooks/useDiscard.ts (1 hunks)
  • app/client/src/git/requests/fetchStatusRequest.types.ts (1 hunks)
  • app/client/src/git/sagas/discardSaga.ts (1 hunks)
  • app/client/src/git/store/actions/discardActions.ts (1 hunks)
  • app/client/src/pages/Editor/gitSync/components/GitChangesList/StaticChange.tsx (1 hunks)
  • app/client/src/pages/Editor/gitSync/components/GitChangesList/index.test.tsx (1 hunks)
  • app/client/src/pages/Editor/gitSync/components/GitChangesList/index.tsx (0 hunks)
  • app/client/src/reducers/uiReducers/gitSyncReducer.ts (1 hunks)
  • app/client/src/selectors/gitModSelectors.ts (1 hunks)
  • app/client/src/selectors/gitSyncSelectors.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/pages/Editor/gitSync/components/GitChangesList/index.tsx
🧰 Additional context used
📓 Learnings (1)
app/client/src/git/components/QuickActions/QuickActionsView.tsx (1)
Learnt from: brayn003
PR: appsmithorg/appsmith#38060
File: app/client/src/git/components/GitQuickActions/helpers/getPullButtonStatus.ts:16-24
Timestamp: 2024-12-10T10:53:17.146Z
Learning: In the `getPullBtnStatus` function (`app/client/src/git/components/GitQuickActions/helpers/getPullButtonStatus.ts`), default parameter values should be explicitly mentioned to handle component state properly, even if all props are required.
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-unit-tests / client-unit-tests
🔇 Additional comments (12)
app/client/src/git/store/actions/discardActions.ts (2)

7-9: LGTM! Good type safety improvement.

The new DiscardInitPayload interface properly extends GitArtifactBasePayload and adds the required artifactId field.


11-18: LGTM! Clean action creator implementation.

The action creator maintains immutability and follows Redux best practices.

app/client/src/git/requests/fetchStatusRequest.types.ts (1)

29-30: LGTM! Consistent type definitions.

The new modifiedSourceModules field aligns with the module tracking improvements and maintains consistency with other count fields.

app/client/src/git/components/QuickActions/hooks/useStatusChangeCount.ts (2)

11-11: LGTM! Proper status calculation update.

The new module tracking fields are correctly incorporated into the status calculation.

Also applies to: 14-14


27-28: Verify the order of operations.

Ensure that adding modifiedSourceModules and modifiedModuleInstances in this order aligns with the expected priority in the total count.

app/client/src/git/sagas/discardSaga.ts (2)

14-17: LGTM! Proper type safety in saga.

The saga correctly uses the new DiscardInitPayload type and properly destructures the required fields.


22-22: Verify error handling for artifactId.

Ensure that artifactId is validated before making the request call.

app/client/src/selectors/gitModSelectors.ts (1)

24-25: Verify the impact of removing feature flag.

The change forces Git modularization to be always enabled by removing the feature flag check. This could impact users if the feature isn't fully tested.

Run this script to check for any feature flag dependencies:

✅ Verification successful

Feature flag removal appears to be a planned graduation

The change is safe as the feature was already enabled in test environments and appears to be a planned graduation from feature flag to permanent feature. The implementation is well-integrated across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other uses of the git modularisation feature flag
rg -l "release_git_modularisation_enabled"

Length of output: 179


Script:

#!/bin/bash
# Check the feature flag definition and usage
echo "=== Feature Flag Definition ==="
cat app/client/src/ce/entities/FeatureFlag.ts

echo -e "\n=== Cypress Test Usage ==="
cat app/client/cypress/support/Objects/FeatureFlags.ts

echo -e "\n=== Searching for selectGitModEnabled usage ==="
rg "selectGitModEnabled" -A 2

Length of output: 11539

app/client/src/pages/Editor/gitSync/components/GitChangesList/index.test.tsx (1)

348-348: LGTM! Test updated to match new data structure.

The test case correctly reflects the change from modifiedModules to modifiedSourceModules.

app/client/src/git/components/QuickActions/BranchButton.tsx (1)

54-54: LGTM - Consistent with parent component

The default value change maintains consistency with the parent component's behavior.

app/client/src/git/components/QuickActions/QuickActionsView.tsx (2)

67-67: LGTM - Consistent default value

The default value change maintains consistency across the component hierarchy.


Line range hint 82-86: Verify pull button behavior with undefined status

The pull button status depends on isStatusClean. With the new default value, verify that the pull button behaves correctly when the Git status is undefined.

✅ Verification successful

Pull button behavior with undefined status is properly handled

The code has proper handling for undefined Git status:

  • When status is undefined, isStatusClean defaults to true via the nullish coalescing operator
  • The getPullButtonStatus helper has additional fallback defaults
  • Test coverage confirms the behavior in various states
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check pull button status handling across the codebase
ast-grep --pattern 'getPullBtnStatus({
  $$$
  isStatusClean: $_,
  $$$
})'

Length of output: 77


Script:

#!/bin/bash
# Search for pull button related code and status checks
rg -l "pull.*button|pullBtn" --type ts --type tsx

# Then look for status clean checks
rg "isStatusClean|statusClean" --type ts --type tsx -A 2

# Find component that uses these props
ast-grep --pattern 'const $_ = ({$$$isStatusClean$$$}: $_) => {
  $$$
}'

Length of output: 241


Script:

#!/bin/bash
# Search for pull button status function
rg "getPullBtnStatus" -A 5

# Look for status clean usage
rg "isStatusClean" -A 3

# Find pull button related code
rg "pull.*button|pullBtn" -A 3

Length of output: 121319

@brayn003 brayn003 self-assigned this Jan 9, 2025
@brayn003 brayn003 added Git Product Issues related to version control product ok-to-test Required label for CI labels Jan 9, 2025
@brayn003 brayn003 merged commit c169d48 into release Jan 10, 2025
50 of 54 checks passed
@brayn003 brayn003 deleted the chore/git-mod-fixes-1 branch January 10, 2025 11:16
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Feb 7, 2025
## Description
- Fixes initial loading state for status
- Includes module instances and source module count
- Fixes discard flow

## 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/12692930817>
> Commit: 6689c8e
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12692930817&attempt=4"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Fri, 10 Jan 2025 08:32:22 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**
	- Introduced a new focus on source modules instead of packages
	- Enhanced tracking of module instances and source module changes

- **Bug Fixes**
- Updated status change calculations to more accurately reflect module
modifications
	- Improved handling of artifact identification in discard operations

- **Refactor**
- Renamed and restructured various status-related interfaces and
functions
- Modified selectors and reducers to support new module tracking
approach

- **Chores**
	- Updated type definitions and selector implementations
	- Removed deprecated package-related tracking mechanisms

<!-- 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
Git Product Issues related to version control product ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants