Skip to content

fix(wren-ui): delete semantics when reseting project#1490

Merged
onlyjackfrost merged 1 commit intomainfrom
fix/reset-project
Mar 28, 2025
Merged

fix(wren-ui): delete semantics when reseting project#1490
onlyjackfrost merged 1 commit intomainfrom
fix/reset-project

Conversation

@onlyjackfrost
Copy link
Copy Markdown
Contributor

@onlyjackfrost onlyjackfrost commented Mar 28, 2025

delete semantics when reseting project

Summary by CodeRabbit

  • Chores

    • Updated version control settings to exclude a local Docker configuration file.
  • New Features

    • Enhanced project reset operations with an additional deletion process for associated semantic data, ensuring a more thorough cleanup.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 28, 2025

Walkthrough

The changes introduce three key modifications. First, a new entry is added to the .gitignore file to ignore the docker/docker-compose-local.yaml file. Second, a new delete method is added to the IWrenAIAdaptor interface and implemented in the WrenAIAdaptor class, enabling deletion of semantics by making an HTTP DELETE request. Finally, the resetCurrentProject method in the project resolver now calls this new deletion method as part of the project cleanup process.

Changes

File(s) Change Summary
.gitignore Added entry to ignore docker/docker-compose-local.yaml.
wren-ui/.../wrenAIAdaptor.ts Added delete(projectId: number): Promise<void> method to both the adaptor interface and its implementation.
wren-ui/.../projectResolver.ts Integrated a call to ctx.wrenAIAdaptor.delete(id) within the resetCurrentProject method to trigger semantics deletion.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant R as ProjectResolver
    participant A as WrenAIAdaptor
    participant S as RemoteService

    C->>R: Request resetProject(id)
    R->>R: Delete project-related entities (views, models, etc.)
    R->>A: Call delete(id)
    A->>S: HTTP DELETE /v1/semantics?projectId=id
    S-->>A: Respond (200 or error)
    A-->>R: Return result
    R-->>C: Return final response
Loading

Suggested reviewers

  • wwwy3y3

Poem

Oh, I’m the rabbit in the code, so swift and spry,
Hopping through commits with a gleam in my eye.
I skipped a file in .gitignore, oh so neat,
And a delete method now makes the cleanup complete.
Code carrots abound, let’s celebrate with a hop and a tweet!
🥕🐰✨

✨ 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 plan to trigger planning for file edits and PR creation.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link
Copy Markdown
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)
wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts (1)

131-153: Implementation handles errors properly but could improve validation

The implementation of the delete method properly makes an HTTP DELETE request to the semantics endpoint and includes good error handling. However, there are a few opportunities for improvement:

Consider these improvements:

  1. Add more specific input validation for projectId (checking if it's a positive number)
  2. Log errors at the appropriate level (using logger.error instead of only throwing)
  3. Consider adding more specific error handling for different HTTP status codes
 public async delete(projectId: number): Promise<void> {
   try {
     if (!projectId) {
       throw new Error('Project ID is required');
+    } else if (!Number.isInteger(projectId) || projectId <= 0) {
+      throw new Error('Project ID must be a positive integer');
     }
     const url = `${this.wrenAIBaseEndpoint}/v1/semantics`;
     const response = await axios.delete(url, {
       params: {
         project_id: projectId.toString(),
       },
     });

     if (response.status === 200) {
       logger.info(`Wren AI: Deleted semantics for project ${projectId}`);
+    } else if (response.status === 404) {
+      logger.warn(`Wren AI: No semantics found for project ${projectId}`);
+      // Not throwing an error since this is an acceptable state
     } else {
+      logger.error(`Wren AI: Failed to delete semantics for project ${projectId}. Status: ${response.status}, Error: ${response.data?.error}`);
       throw new Error(`Failed to delete semantics. ${response.data?.error}`);
     }
   } catch (error: any) {
+    logger.error(`Wren AI: Error deleting semantics for project ${projectId}:`, error);
     throw new Error(
       `Wren AI: Failed to delete semantics: ${getAIServiceError(error)}`,
     );
   }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 37efb57 and 51af040.

📒 Files selected for processing (3)
  • .gitignore (1 hunks)
  • wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts (2 hunks)
  • wren-ui/src/apollo/server/resolvers/projectResolver.ts (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts (1)
wren-ui/src/apollo/client/graphql/__types__.ts (1)
  • Error (433-439)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (3)
.gitignore (1)

32-32: Added appropriate entry to .gitignore

The addition of docker/docker-compose-local.yaml to the gitignore file is appropriate as it prevents committing local Docker configuration, which typically contains environment-specific settings.

wren-ui/src/apollo/server/resolvers/projectResolver.ts (1)

133-133: Properly integrates semantics cleanup in project reset

The addition of the delete call to clean up semantics is well-placed after all other project-related entities are deleted, ensuring proper cleanup order. This implementation fixes the issue mentioned in the PR title about deleting semantics when resetting a project.

wren-ui/src/apollo/server/adaptors/wrenAIAdaptor.ts (1)

51-51: LGTM: Interface method correctly declared

The addition of the delete method to the IWrenAIAdaptor interface is correctly defined with appropriate parameter and return type.

@onlyjackfrost onlyjackfrost merged commit c0b277d into main Mar 28, 2025
6 checks passed
@onlyjackfrost onlyjackfrost deleted the fix/reset-project branch March 28, 2025 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants