Skip to content

chore: filter out AI Datasource during import #40286

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

Merged
merged 1 commit into from
Apr 17, 2025

Conversation

jsartisan
Copy link
Contributor

@jsartisan jsartisan commented Apr 17, 2025

Before:

CleanShot.2025-04-17.at.11.57.06.mp4

After:

CleanShot.2025-04-17.at.11.57.30.mp4

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

Tip

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


Thu, 17 Apr 2025 07:16:52 UTC

Summary by CodeRabbit

  • Bug Fixes
    • The "AI Datasource" will no longer appear in the reconnect datasource modal during partial application or template imports, improving clarity for users when reconnecting datasources.

@jsartisan jsartisan requested a review from ayushpahwa as a code owner April 17, 2025 06:52
Copy link
Contributor

coderabbitai bot commented Apr 17, 2025

Walkthrough

A constant named AI_DATASOURCE_NAME with the value "AI Datasource" was introduced in two saga files. The code now filters out any datasource with this name from the list of unconfigured datasources before displaying the reconnect datasource modal during partial import or fork operations. This adjustment is applied in both application and template import flows, ensuring the AI Datasource does not appear in the modal. Minor type annotations and comments were also added to suppress TypeScript errors, but no other control flow or error handling changes were made.

Changes

File(s) Change Summary
app/client/src/ce/sagas/ApplicationSagas.tsx Introduced AI_DATASOURCE_NAME constant; filtered out "AI Datasource" from unconfigured datasources in partial import/fork flows; added type annotations and comments to suppress TypeScript errors.
app/client/src/sagas/TemplatesSagas.ts Added AI_DATASOURCE_NAME constant; filtered out "AI Datasource" from unconfigured datasources before showing reconnect modal in partial template import flow.

Suggested labels

skip-changelog

Poem

The AI Datasource, now unseen,
Slips quietly behind the screen.
No more in modals does it dwell,
Filtered out, and all is well.
With constants set and types in place,
The import flows at a smoother pace!
🚀✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @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.

@jsartisan jsartisan requested review from hetunandu and removed request for ayushpahwa April 17, 2025 06:52
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Apr 17, 2025
@jsartisan jsartisan added ok-to-test Required label for CI and removed skip-changelog Adding this label to a PR prevents it from being listed in the changelog labels Apr 17, 2025
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Apr 17, 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 (2)
app/client/src/ce/sagas/ApplicationSagas.tsx (2)

752-768: Good implementation of AI Datasource filtering in forkApplicationSaga.

The code correctly filters out AI Datasource entries from the unconfigured datasource list before showing the reconnect modal. The null/undefined check with fallback to empty array is a good defensive practice.

Consider extracting this filtering logic into a utility function since it's repeated in multiple places:

+// At the module level
+const filterOutAIDatasources = (datasources: Datasource[] = []): Datasource[] => {
+  return datasources.filter(datasource => datasource.name !== AI_DATASOURCE_NAME);
+};

// Then in the saga
-const filteredUnConfiguredDatasourceList = (
-  response?.data?.unConfiguredDatasourceList || []
-).filter(
-  (datasource) => datasource.name !== AI_DATASOURCE_NAME,
-) as Datasource[];
+const filteredUnConfiguredDatasourceList = filterOutAIDatasources(
+  response?.data?.unConfiguredDatasourceList
+);

838-851: Good implementation of AI Datasource filtering in importApplicationSaga.

The code correctly filters the unconfigured datasource list and uses the filtered list when showing the reconnect modal. The implementation is consistent with the approach used in forkApplicationSaga.

As mentioned earlier, consider extracting this filtering logic into a shared utility function to reduce duplication.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 99e3cb5 and a3d4aa2.

📒 Files selected for processing (2)
  • app/client/src/ce/sagas/ApplicationSagas.tsx (5 hunks)
  • app/client/src/sagas/TemplatesSagas.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
app/client/src/sagas/TemplatesSagas.ts (1)
app/client/src/ce/actions/applicationActions.ts (1)
  • showReconnectDatasourceModal (275-283)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (5)
app/client/src/sagas/TemplatesSagas.ts (2)

51-51: Good addition of a constant for better maintainability.

Adding this constant AI_DATASOURCE_NAME helps maintain consistency across the codebase and makes future changes to the name easier to implement.


100-114: Effective implementation of the AI Datasource filtering logic.

The code successfully filters out the AI Datasource entries before displaying the reconnect datasource modal. The logic is sound:

  1. Filter out datasources named "AI Datasource"
  2. Only show the modal if it's a partial import and there are remaining unconfigured datasources
  3. Pass the filtered list to the modal component

The null check with the fallback to an empty array (response.data.unConfiguredDatasourceList || []) provides good defensive programming.

app/client/src/ce/sagas/ApplicationSagas.tsx (3)

127-127: Good addition of the AI_DATASOURCE_NAME constant.

This matches the constant in TemplatesSagas.ts and ensures consistent filtering across the application.


811-815: Good type annotations for the API response.

Adding explicit typing for the API response improves code clarity and helps catch potential type errors during development.


864-865: TypeScript error suppression properly documented.

The @ts-expect-error directive is properly documented explaining why the error suppression is needed.

@jsartisan jsartisan merged commit 882ad85 into release Apr 17, 2025
50 checks passed
@jsartisan jsartisan deleted the chore/hide-ai-datasource-during-import branch April 17, 2025 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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