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 Issue #386: Add a button so users can reset their AI Profile #387

Merged
merged 21 commits into from
Feb 21, 2025

Conversation

Phrosfire
Copy link
Collaborator

@Phrosfire Phrosfire commented Feb 18, 2025

Pull Request

Adding a button to allow users to reset their AI profile in the case that their current profile generates the 500 error when attempting to open it.

fix #386

License

By making this pull request, I confirm that I have the right to waive copyright and related rights to my contribution, and agree that all copyright and related rights in my contributions are waived, and I acknowledge that the Studie-Tech ApS organization has the copyright to use and modify my contribution for perpetuity.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Introduced a button in the combat settings to reset the AI profile, enhancing user control over AI behavior.
    • Added error handling with toast messages to inform users of the success or failure of the AI profile reset action.
    • Improved data integrity by filtering out non-existent entries in user-related AI data responses.

Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Copy link

vercel bot commented Feb 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tnr ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2025 4:49am

Copy link
Contributor

coderabbitai bot commented Feb 18, 2025

Warning

Rate limit exceeded

@Phrosfire has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 57 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 13f0f55 and e3bc57d.

📒 Files selected for processing (1)
  • app/src/app/profile/edit/page.tsx (3 hunks)

Walkthrough

The pull request introduces a new mutation for updating the AI profile within the BattleSettingsEdit component. It adds a button labeled "Reset AI Profile" that triggers this mutation, constructing a defaultAiProfilePayload object with an AI profile ID and combat behavior rules. The button also includes error handling to display toast messages based on the mutation's success or failure. Additionally, the import statements are updated to enhance type safety with new types related to AI rules. Furthermore, modifications are made to the profileRouter to filter out non-existent entries in the user data retrieval processes.

Changes

File(s) Summary
app/src/app/.../profile/edit/page.tsx - Added a new button in the "Combat Preferences" section that triggers the updateAiProfile mutation
- Constructs a defaultAiProfilePayload with AI profile ID and combat rules
- Includes error handling for mutation success and failure
- Updated import statements to include new AI rule types
app/src/server/.../api/routers/profile.ts - Updated getAi and getPublicUser methods to filter out non-existent entries in jutsus and items arrays
- Enhanced comments to reflect new filtering logic for better clarity

Suggested reviewers

  • MathiasGruber

Poem

I'm a little rabbit, hopping through the code,
A button was born on a digital road.
With rules for combat in a clever dance,
Toasts will cheer for each new chance.
Code carrots crunch, and the AI leaps high—
Celebrating changes under the open sky!
🥕🐇✨


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.

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
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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2711c02 and 71431a4.

📒 Files selected for processing (1)
  • app/src/app/profile/edit/page.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-test
  • GitHub Check: Analyze (javascript)

Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
@MathiasGruber
Copy link
Owner

Seems like some stuff is missing from this PR? What's the origin of the 500 error, do we know?

@Phrosfire
Copy link
Collaborator Author

Seems like some stuff is missing from this PR? What's the origin of the 500 error, do we know?

Sorry, you replied right before I put the tag on that it needs additional work. It seems to be caused by items that the user may not have anymore. I have screenshots attached to the issue itself.

Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
@Phrosfire Phrosfire changed the title Fix Issue #386: 500 Error when opening AI profile Fix Issue #386: Add AI reset button to fix 500 error for AI Rules view Feb 18, 2025
@Phrosfire Phrosfire changed the title Fix Issue #386: Add AI reset button to fix 500 error for AI Rules view Fix Issue #386: Add a button so users can reset their AI Profile Feb 18, 2025
Copy link
Owner

@MathiasGruber MathiasGruber left a comment

Choose a reason for hiding this comment

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

I think it's fine to still have a reset button, but let's also fix it at the core :)

Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between db87601 and eaf6bb1.

📒 Files selected for processing (1)
  • app/src/app/profile/edit/page.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-test
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
app/src/app/profile/edit/page.tsx (2)

78-82: Well-structured imports for AI profile types!

The imports are properly scoped and follow the project's conventions.


301-310: Well-implemented mutation hook with proper error handling!

The mutation hook follows best practices with proper cache invalidation and user feedback through toast messages.

Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
@MathiasGruber MathiasGruber merged commit bfd5cd4 into main Feb 21, 2025
10 checks passed
@MathiasGruber MathiasGruber deleted the Phrosfire-patch-1 branch February 21, 2025 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

500 Error when opening AI profile
2 participants