Skip to content

fix: timeout error on org creation#308

Merged
carhartlewis merged 3 commits into
mainfrom
lewis/timeout
Apr 6, 2025
Merged

fix: timeout error on org creation#308
carhartlewis merged 3 commits into
mainfrom
lewis/timeout

Conversation

@carhartlewis

@carhartlewis carhartlewis commented Apr 6, 2025

Copy link
Copy Markdown
Contributor

we had maxDuration = 5 on the root layout... :(

Summary by CodeRabbit

  • New Features
    • Introduced a new commenting system that allows users to add and view comments across policies, risks, and vendors.
    • Added an intuitive comment submission form and a dedicated comment display component for enhanced interaction.
  • Chores
    • Refined existing flows by removing redundant task handling in favor of streamlined comment management.
    • Applied formatting and performance optimizations, including database schema updates to support the new comment functionality.

- Added `addCommentAction` for server-side comment creation with validation using Zod.
- Introduced `Comments` component for displaying and adding comments in various pages.
- Updated relevant pages (Policy, Risk, Vendor) to include comments functionality.
- Created `CreateCommentForm` for user input and submission of comments.
- Added database schema for `Comment` and updated related models in Prisma.
- Ensured comments are fetched and displayed correctly in the UI.
- Wrapped comments fetching logic in try-catch blocks across Policy, Risk, and Vendor pages to improve error handling.
- Ensured that errors are logged and an empty array is returned in case of failure, maintaining UI stability.
- Reformatted metadata and viewport properties in layout files for both app and portal to enhance readability and maintainability.
- Ensured consistent structure across metadata definitions, including Twitter and Open Graph settings.
- Updated layout component structure for improved clarity in rendering logic.
@vercel

vercel Bot commented Apr 6, 2025

Copy link
Copy Markdown

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

Name Status Preview Comments Updated (UTC)
app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 6, 2025 2:37am
comp-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 6, 2025 2:37am

@coderabbitai

coderabbitai Bot commented Apr 6, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces a comprehensive commenting feature. It adds a new backend action to create comments with proper validation of user sessions and organization membership, along with a corresponding schema. Frontend pages including policies, risks, and vendors are updated to fetch and display comments. New React components for displaying and creating comments are added. In addition, a database migration and corresponding Prisma schema updates support a new Comment model and its associations.

Changes

File(s) Change Summary
apps/.../actions/add-comment.ts, apps/.../actions/schema.ts Added addCommentAction with validation and error handling, and introduced addCommentSchema for validating comment data; includes formatting adjustments.
apps/.../policies/[policyId]/page.tsx, apps/.../risk/[riskId]/page.tsx, apps/.../vendors/[vendorId]/page.tsx Integrated comments fetching by adding getComments, updated caching logic, removed deprecated task retrieval, and incorporated the Comments component into UI pages.
apps/.../components/comments.tsx, apps/.../components/forms/create-comment-form.tsx Introduced new React components: Comments to display comments and CreateCommentForm to handle comment submission using form validation and toast notifications.
apps/.../vendors/components/create-vendor-form.tsx, apps/.../layout.tsx, apps/portal/.../layout.tsx, apps/.../components/forms/create-organization-form.tsx Simplified vendor form by removing obsolete state and hooks, and applied consistent formatting and indentation across layout and organization form files.
packages/db/prisma/migrations/.../migration.sql, packages/db/prisma/schema/auth.prisma, packages/db/prisma/schema/common.prisma, packages/db/prisma/schema/organization.prisma Added new SQL migration to create the Comment table with indexes and foreign key constraints; updated Prisma schemas by adding the Comment model and linking it to the Member and Organization models.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant CF as CreateCommentForm
  participant AC as addCommentAction
  participant DB as Database

  U->>CF: Fill and submit comment form
  CF->>AC: Call addCommentAction({ content, entityId })
  AC->>AC: Validate session, organization, and member
  AC->>DB: Insert new comment record
  DB-->>AC: Return success response
  AC->>CF: Send success status (trigger revalidation if needed)
  CF->>U: Display confirmation and update UI
Loading
sequenceDiagram
  participant U as User
  participant P as PolicyDetails Page
  participant GC as getComments
  participant DB as Database
  participant C as Comments Component

  U->>P: Request policy details
  P->>GC: Fetch comments for policyId
  GC->>DB: Query comments from Comment table
  DB-->>GC: Return comments list
  GC-->>P: Deliver comments data
  P->>C: Render comments in UI
Loading

Possibly related PRs

  • Mariano/risk improvements #271 – Addressed comment management and display similar to this PR’s new getComments integration.
  • Lewis/vendor management #109 – Introduced the addCommentAction and addCommentSchema, which directly relate to the new comment UI components.
  • Charts #85 – Focused on handling and submission of comments through actions, aligning with the functionality added in this PR.

Poem

I'm a happy little rabbit, hopping through the code,
Adding comments and features on a spirited new road.
Lines of SQL and React, dancing in delight 😄,
With each new commit, our project shines so bright.
Cheers to thoughtful changes and paths kept ever light!
🐇💻✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2a7099a and 8eb1e11.

📒 Files selected for processing (15)
  • apps/app/src/actions/add-comment.ts (1 hunks)
  • apps/app/src/actions/schema.ts (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/policies/[policyId]/page.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/risk/[riskId]/page.tsx (6 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/page.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/components/create-vendor-form.tsx (1 hunks)
  • apps/app/src/app/[locale]/layout.tsx (1 hunks)
  • apps/app/src/components/comments.tsx (1 hunks)
  • apps/app/src/components/forms/create-comment-form.tsx (1 hunks)
  • apps/app/src/components/forms/create-organization-form.tsx (1 hunks)
  • apps/portal/src/app/[locale]/layout.tsx (1 hunks)
  • packages/db/prisma/migrations/20250406004306_added_common_comment_table/migration.sql (1 hunks)
  • packages/db/prisma/schema/auth.prisma (1 hunks)
  • packages/db/prisma/schema/common.prisma (1 hunks)
  • packages/db/prisma/schema/organization.prisma (1 hunks)
✨ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant