Skip to content

Conversation

@ameer2468
Copy link
Contributor

@ameer2468 ameer2468 commented Nov 3, 2025

This PR: adds the ability to delete an org.

Summary by CodeRabbit

  • New Features

    • Added ability to delete organizations with confirmation dialog.
    • System automatically switches to another organization when one is deleted.
  • Bug Fixes

    • Deleted organizations no longer appear in dashboard queries and search results.
    • Fixed organization name text truncation on mobile layouts.
  • Style

    • Updated destructive button styling for clarity.
    • Improved mobile organization controls layout with better spacing.
    • Adjusted settings card background colors.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

Walkthrough

Implements organization deletion with soft-delete (tombstoning) functionality. Adds a DeleteOrg UI component and dialog for confirming deletion, introduces backend RPC handlers and domain schemas, updates database schema with tombstoneAt column, filters queries to exclude tombstoned organizations, and includes UI layout/styling refinements.

Changes

Cohort / File(s) Summary
Database schema
packages/database/schema.ts
Added tombstoneAt timestamp column to organizations table for soft-delete support.
Organization deletion backend
packages/web-domain/src/Organisation.ts, packages/web-backend/src/Organisations/OrganisationsRpcs.ts, packages/web-backend/src/Organisations/index.ts
Introduced OrganisationDelete schema/type, new RPC handler OrganisationDelete, and deleteOrg service method with transactional org tombstoning and active organization reassignment logic. Updated Organisations.update return to include deleteOrg handler.
Deletion UI components
apps/web/app/(org)/dashboard/settings/organization/Organization.tsx, apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrg.tsx, apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrgDialog.tsx
Added DeleteOrg component (renders card with destructive delete button, disabled when single org exists) and DeleteOrgDialog component (modal with confirmation input, RPC mutation, success/error handling, router navigation). Integrated DeleteOrg into Organization.tsx.
Query filtering updates
apps/web/app/(org)/dashboard/dashboard-data.ts, apps/web/app/s/[videoId]/page.tsx, apps/web/app/api/desktop/[...route]/root.ts
Updated three query where clauses to filter out tombstoned organizations via isNull(organizations.tombstoneAt) constraint alongside existing ownership/access conditions.
Mobile UI layout
apps/web/app/(org)/dashboard/_components/MobileTab.tsx
Restructured layout by wrapping org controls in a container, increased gap from 5 to 10, added flex-auto sizing to org components with max width constraints, applied truncation to org names for overflow handling.
Component styling
apps/web/app/(org)/dashboard/settings/organization/components/CapSettingsCard.tsx
Changed container background class from bg-gray-1 to bg-gray-2.
Button variant styling
packages/ui/src/components/Button.tsx
Updated destructive variant styling: added border, adjusted disabled state colors (bg-gray-7, text-gray-10), set transparent border default.
Import cleanup
apps/web/app/(org)/dashboard/settings/organization/components/OrganizationIcon.tsx
Removed unused withRpc import from @/lib/Rpcs.

Sequence Diagram

sequenceDiagram
    actor User
    participant UI as DeleteOrg Component
    participant Dialog as DeleteOrgDialog
    participant RPC as OrganisationDelete RPC
    participant Backend as Organisations.deleteOrg
    participant DB as Database

    User->>UI: Click Delete Organization
    activate UI
    UI->>Dialog: open=true
    activate Dialog
    
    User->>Dialog: Enter org name & confirm
    Dialog->>Dialog: Validate name matches
    
    rect rgb(180, 220, 200)
        Note over Dialog,Backend: Deletion Flow
        Dialog->>RPC: deleteOrg({id})
        activate RPC
        RPC->>Backend: deleteOrg(id)
        activate Backend
        
        Backend->>DB: Set org.tombstoneAt = now()
        Backend->>DB: Find next non-tombstoned org owned by user
        Backend->>DB: Update user.activeOrganizationId
        Backend->>DB: Update user.defaultOrgId
        DB-->>Backend: Success
    end
    
    Backend-->>RPC: Success
    deactivate Backend
    RPC-->>Dialog: Success response
    deactivate RPC
    
    rect rgb(200, 220, 180)
        Note over Dialog: Post-deletion
        Dialog->>Dialog: Show success toast
        Dialog->>Dialog: Close dialog
        Dialog->>UI: Navigate to /dashboard/caps
    end
    
    deactivate Dialog
    deactivate UI
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

  • Backend service logic (packages/web-backend/src/Organisations/index.ts): Complex transactional flow with org tombstoning and active organization reassignment requires careful verification of transaction semantics and edge case handling.
  • Dialog component (DeleteOrgDialog.tsx): Combines async RPC mutation with state management, error handling, UI feedback (toast), and router navigation; validate all state transitions and error paths.
  • Multiple query updates: Four separate files modify query filtering with tombstoneAt constraints; ensure consistency and no unintended exclusions across dashboards, videos, and APIs.
  • Database schema change: Verify migration compatibility and that tombstoneAt is properly indexed/queried.

Possibly related PRs

Suggested reviewers

  • Brendonovich

Poem

🐰 Soft deletes in the garden grow,
Organizations fade to tombstoned snow,
New dialogs dance, confirmations flow,
While schemas bloom with timestamps aglow,
Active orgs reassign, cleanup's the show!

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'web: delete org' directly aligns with the primary objective stated in the PR description: 'This PR adds the ability to delete an org.' The title is concise, clear, and accurately summarizes the main change across the changeset, which includes new DeleteOrg and DeleteOrgDialog components, RPC handlers, and database schema modifications to support organization deletion.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch delete-org

📜 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 c2edd0b and daa99c1.

📒 Files selected for processing (2)
  • packages/web-backend/src/Organisations/OrganisationsRpcs.ts (1 hunks)
  • packages/web-backend/src/Organisations/index.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/web-backend/src/Organisations/OrganisationsRpcs.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use a 2-space indent for TypeScript code.
Use Biome for formatting and linting TypeScript/JavaScript files by running pnpm format.

Files:

  • packages/web-backend/src/Organisations/index.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Use kebab-case for filenames for TypeScript/JavaScript modules (e.g., user-menu.tsx).
Use PascalCase for React/Solid components.

Files:

  • packages/web-backend/src/Organisations/index.ts
🧬 Code graph analysis (1)
packages/web-backend/src/Organisations/index.ts (2)
packages/web-domain/src/Authentication.ts (1)
  • CurrentUser (8-16)
packages/web-domain/src/Policy.ts (2)
  • Policy (8-12)
  • policy (29-41)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Analyze (rust)

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/database/migrations/meta/_journal.json (1)

2-2: Fix migration journal version mismatch.

The pipeline failure indicates that the migration journal version must be incremented when adding a new migration entry. Since a new migration with idx: 6 was added, the version should be updated from "5" to "6".

Apply this diff:

 {
-	"version": "5",
+	"version": "6",
 	"dialect": "mysql",
apps/web/app/(org)/dashboard/dashboard-data.ts (1)

102-108: Backend deleteOrg only partially handles active organization reassignment; stale references possible when deleting a user's last organization.

The backend implementation (packages/web-backend/src/Organisations/index.ts:51-90) attempts to reassign activeOrganizationId to another non-tombstoned organization, but this fails silently if no other organization exists. When a user deletes their only organization:

  1. The org is tombstoned
  2. The query for otherOrg returns empty (no other owned orgs exist)
  3. activeOrganizationId is not updated and remains pointing to the tombstoned org

While the frontend fallback in dashboard-data.ts handles this case, the backend should defensively clear or null activeOrganizationId when no alternative organization exists to prevent stale references in other code paths that directly access user.activeOrganizationId.

Suggested fix: After the otherOrg query, add a fallback update to set activeOrganizationId to null (or a sentinel value) if no other organization is available.

🧹 Nitpick comments (1)
packages/database/schema.ts (1)

183-183: Consider adding an index on tombstoneAt.

Since multiple queries now filter by isNull(organizations.tombstoneAt) (in dashboard-data.ts and page.tsx), an index on this column could improve query performance, especially as the number of tombstoned organizations grows.

Apply this diff to add an index:

 	(table) => ({
 		ownerIdIndex: index("owner_id_idx").on(table.ownerId),
 		customDomainIndex: index("custom_domain_idx").on(table.customDomain),
+		tombstoneAtIndex: index("tombstone_at_idx").on(table.tombstoneAt),
 	}),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 48a7fe2 and 00145f9.

📒 Files selected for processing (14)
  • apps/web/app/(org)/dashboard/_components/MobileTab.tsx (4 hunks)
  • apps/web/app/(org)/dashboard/dashboard-data.ts (2 hunks)
  • apps/web/app/(org)/dashboard/settings/organization/Organization.tsx (2 hunks)
  • apps/web/app/(org)/dashboard/settings/organization/components/CapSettingsCard.tsx (1 hunks)
  • apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrg.tsx (1 hunks)
  • apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrgDialog.tsx (1 hunks)
  • apps/web/app/(org)/dashboard/settings/organization/components/OrganizationIcon.tsx (0 hunks)
  • apps/web/app/s/[videoId]/page.tsx (2 hunks)
  • packages/database/migrations/meta/_journal.json (1 hunks)
  • packages/database/schema.ts (1 hunks)
  • packages/ui/src/components/Button.tsx (1 hunks)
  • packages/web-backend/src/Organisations/OrganisationsRpcs.ts (1 hunks)
  • packages/web-backend/src/Organisations/index.ts (2 hunks)
  • packages/web-domain/src/Organisation.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/app/(org)/dashboard/settings/organization/components/OrganizationIcon.tsx
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use a 2-space indent for TypeScript code.
Use Biome for formatting and linting TypeScript/JavaScript files by running pnpm format.

Files:

  • packages/ui/src/components/Button.tsx
  • packages/web-backend/src/Organisations/OrganisationsRpcs.ts
  • apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrg.tsx
  • packages/web-domain/src/Organisation.ts
  • apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrgDialog.tsx
  • apps/web/app/(org)/dashboard/_components/MobileTab.tsx
  • apps/web/app/(org)/dashboard/settings/organization/components/CapSettingsCard.tsx
  • apps/web/app/s/[videoId]/page.tsx
  • packages/web-backend/src/Organisations/index.ts
  • apps/web/app/(org)/dashboard/settings/organization/Organization.tsx
  • packages/database/schema.ts
  • apps/web/app/(org)/dashboard/dashboard-data.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Use kebab-case for filenames for TypeScript/JavaScript modules (e.g., user-menu.tsx).
Use PascalCase for React/Solid components.

Files:

  • packages/ui/src/components/Button.tsx
  • packages/web-backend/src/Organisations/OrganisationsRpcs.ts
  • apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrg.tsx
  • packages/web-domain/src/Organisation.ts
  • apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrgDialog.tsx
  • apps/web/app/(org)/dashboard/_components/MobileTab.tsx
  • apps/web/app/(org)/dashboard/settings/organization/components/CapSettingsCard.tsx
  • apps/web/app/s/[videoId]/page.tsx
  • packages/web-backend/src/Organisations/index.ts
  • apps/web/app/(org)/dashboard/settings/organization/Organization.tsx
  • packages/database/schema.ts
  • apps/web/app/(org)/dashboard/dashboard-data.ts
packages/ui/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Component files in packages/ui should use PascalCase naming if they define React/Solid components.

Files:

  • packages/ui/src/components/Button.tsx
apps/web/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

On the client, always use useEffectQuery or useEffectMutation from @/lib/EffectRuntime; never call EffectRuntime.run* directly in components.

Files:

  • apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrg.tsx
  • apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrgDialog.tsx
  • apps/web/app/(org)/dashboard/_components/MobileTab.tsx
  • apps/web/app/(org)/dashboard/settings/organization/components/CapSettingsCard.tsx
  • apps/web/app/s/[videoId]/page.tsx
  • apps/web/app/(org)/dashboard/settings/organization/Organization.tsx
  • apps/web/app/(org)/dashboard/dashboard-data.ts
🧠 Learnings (2)
📚 Learning: 2025-09-22T14:19:56.010Z
Learnt from: CR
Repo: CapSoftware/Cap PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-22T14:19:56.010Z
Learning: Applies to packages/ui/**/*.{ts,tsx,js,jsx} : Component files in `packages/ui` should use PascalCase naming if they define React/Solid components.

Applied to files:

  • apps/web/app/(org)/dashboard/settings/organization/components/CapSettingsCard.tsx
📚 Learning: 2025-09-22T14:19:56.010Z
Learnt from: CR
Repo: CapSoftware/Cap PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-22T14:19:56.010Z
Learning: Applies to **/queries.ts : Do not edit auto-generated files named `queries.ts`.

Applied to files:

  • apps/web/app/s/[videoId]/page.tsx
  • apps/web/app/(org)/dashboard/dashboard-data.ts
🧬 Code graph analysis (8)
packages/web-backend/src/Organisations/OrganisationsRpcs.ts (1)
packages/web-domain/src/Errors.ts (1)
  • InternalError (3-6)
apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrg.tsx (1)
apps/web/app/(org)/dashboard/Contexts.tsx (1)
  • useDashboardContext (50-50)
packages/web-domain/src/Organisation.ts (5)
packages/web-domain/src/Errors.ts (1)
  • InternalError (3-6)
packages/web-domain/src/Policy.ts (1)
  • PolicyDeniedError (20-24)
packages/web-domain/src/Video.ts (1)
  • NotFoundError (135-139)
packages/web-domain/src/Folder.ts (1)
  • NotFoundError (17-21)
packages/web-domain/src/Authentication.ts (1)
  • RpcAuthMiddleware (35-41)
apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrgDialog.tsx (3)
apps/web/app/(org)/dashboard/Contexts.tsx (1)
  • useDashboardContext (50-50)
apps/web/lib/EffectRuntime.ts (2)
  • useRpcClient (25-25)
  • useEffectMutation (23-23)
packages/web-domain/src/Organisation.ts (3)
  • Organisation (21-24)
  • OrganisationId (16-18)
  • OrganisationId (19-19)
apps/web/app/(org)/dashboard/_components/MobileTab.tsx (1)
apps/web/components/SignedImageUrl.tsx (1)
  • SignedImageUrl (11-25)
apps/web/app/s/[videoId]/page.tsx (1)
packages/database/schema.ts (2)
  • videos (289-344)
  • organizations (172-207)
packages/web-backend/src/Organisations/index.ts (3)
packages/web-domain/src/Organisation.ts (3)
  • Organisation (21-24)
  • OrganisationId (16-18)
  • OrganisationId (19-19)
apps/web/app/Layout/AuthContext.tsx (1)
  • CurrentUser (6-14)
packages/web-domain/src/Authentication.ts (1)
  • CurrentUser (8-16)
apps/web/app/(org)/dashboard/dashboard-data.ts (1)
packages/database/schema.ts (2)
  • organizations (172-207)
  • organizationMembers (210-232)
🪛 GitHub Actions: Validate Migrations
packages/database/migrations/meta/_journal.json

[error] 2-2: Migration journal version cannot be changed (was: $BASE_VERSION, now: $CURRENT_VERSION)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Analyze (rust)
🔇 Additional comments (19)
apps/web/app/s/[videoId]/page.tsx (2)

32-32: LGTM!

The isNull import is correctly added to support tombstone filtering.


304-304: LGTM!

The tombstone filtering logic correctly ensures that videos from deleted organizations are not accessible. The use of and with the existing eq(videos.id, videoId) condition properly combines the filters.

packages/ui/src/components/Button.tsx (1)

19-20: LGTM!

The updated destructive variant styling improves consistency with other button variants by adding border support and using the design system's gray palette for disabled states. The transparent border default ensures the button appears borderless when not disabled.

apps/web/app/(org)/dashboard/settings/organization/Organization.tsx (2)

16-16: LGTM!

The DeleteOrg component import is correctly placed and follows the naming convention.


94-94: LGTM!

The DeleteOrg component is appropriately positioned at the end of the organization settings form, which is a logical placement for a destructive action.

apps/web/app/(org)/dashboard/settings/organization/components/CapSettingsCard.tsx (1)

163-163: LGTM!

The background color change from bg-gray-1 to bg-gray-2 improves visual contrast for the settings options. This appears to be a deliberate design system refinement.

apps/web/app/(org)/dashboard/dashboard-data.ts (2)

74-80: LGTM!

The tombstone filtering correctly uses and(or(...), isNull(organizations.tombstoneAt)) to ensure that organizations are filtered by membership/ownership AND are not tombstoned. This prevents deleted organizations from appearing in the dashboard.


328-333: LGTM!

The totalInvites query correctly filters out tombstoned organizations when counting organization members and invites. This ensures accurate quota calculations for non-deleted organizations.

packages/web-backend/src/Organisations/OrganisationsRpcs.ts (1)

17-25: Review comment is incorrect based on codebase analysis.

The deleteOrg implementation performs only a soft delete (marks tombstoneAt) and does not involve S3 operations. It contains only database operations—there is no resource cleanup or S3 interaction. The S3Error handling in OrganisationUpdate is specific to that operation, which modifies organization metadata including icon uploads. Since OrganisationDelete does not perform S3 operations, catching only DatabaseError is correct and appropriate.

Likely an incorrect or invalid review comment.

packages/web-backend/src/Organisations/index.ts (1)

91-91: LGTM!

The return statement correctly exposes both operations.

apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrg.tsx (1)

23-34: LGTM!

The disable logic correctly prevents deletion when only one organization remains, which aligns with the dialog's validation logic.

packages/web-domain/src/Organisation.ts (2)

26-29: LGTM!

The OrganisationDelete payload structure is clean and follows the existing pattern.


42-45: LGTM!

The RPC definition follows the same pattern as OrganisationUpdate with appropriate error types and middleware.

apps/web/app/(org)/dashboard/_components/MobileTab.tsx (4)

46-52: LGTM!

The layout restructuring improves organization of the org controls with better spacing and containment.


78-96: LGTM!

The addition of flex-auto, max-w-[224px], and truncate classes ensures the organization selector handles long names gracefully while maintaining responsive layout.


117-118: LGTM!

The menu container adjustments provide better width management for the dropdown.


145-152: LGTM!

Adding truncate to organization names in the menu prevents overflow issues with long names.

apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrgDialog.tsx (2)

36-48: LGTM!

The success and error handlers appropriately manage toast notifications, dialog state, and navigation.


76-80: LGTM!

The button disable conditions correctly prevent deletion when:

  • Only one organization remains
  • The entered name doesn't match
  • Deletion is in progress

This provides good UX and prevents accidental deletions.

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

♻️ Duplicate comments (1)
packages/web-backend/src/Organisations/index.ts (1)

81-91: Handle case when user has no remaining organizations.

When otherOrg is undefined (user has no other organizations), the user's activeOrganizationId and defaultOrgId remain pointed at the tombstoned organization. This leaves the user in a broken state and could cause failures when accessing organization-scoped features.

Apply this diff to set the fields to null when no other org exists:

   if (otherOrg) {
     yield* db.use((db) =>
       db
         .update(Db.users)
         .set({
           activeOrganizationId: otherOrg.id,
           defaultOrgId: otherOrg.id,
         })
         .where(Dz.eq(Db.users.id, user.id)),
     );
+  } else {
+    yield* db.use((db) =>
+      db
+        .update(Db.users)
+        .set({
+          activeOrganizationId: null,
+          defaultOrgId: null,
+        })
+        .where(Dz.eq(Db.users.id, user.id)),
+    );
   }
🧹 Nitpick comments (1)
apps/web/app/api/desktop/[...route]/root.ts (1)

215-221: Soft-delete filter correctly implemented.

The logic correctly excludes tombstoned organizations while preserving the existing owner-or-member access control. The and() condition properly combines the tombstone check with the authorization logic, and the LEFT JOIN semantics are maintained.

Performance consideration: As the organizations table grows, consider adding an index on tombstoneAt to optimize this query. Since most organizations are expected to be non-tombstoned, the database may handle IS NULL checks efficiently, but an index would provide more predictable performance at scale.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00145f9 and c2edd0b.

📒 Files selected for processing (3)
  • apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrgDialog.tsx (1 hunks)
  • apps/web/app/api/desktop/[...route]/root.ts (2 hunks)
  • packages/web-backend/src/Organisations/index.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrgDialog.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use a 2-space indent for TypeScript code.
Use Biome for formatting and linting TypeScript/JavaScript files by running pnpm format.

Files:

  • apps/web/app/api/desktop/[...route]/root.ts
  • packages/web-backend/src/Organisations/index.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Use kebab-case for filenames for TypeScript/JavaScript modules (e.g., user-menu.tsx).
Use PascalCase for React/Solid components.

Files:

  • apps/web/app/api/desktop/[...route]/root.ts
  • packages/web-backend/src/Organisations/index.ts
apps/web/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

On the client, always use useEffectQuery or useEffectMutation from @/lib/EffectRuntime; never call EffectRuntime.run* directly in components.

Files:

  • apps/web/app/api/desktop/[...route]/root.ts
🧠 Learnings (1)
📚 Learning: 2025-09-22T14:19:56.010Z
Learnt from: CR
Repo: CapSoftware/Cap PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-22T14:19:56.010Z
Learning: Applies to **/queries.ts : Do not edit auto-generated files named `queries.ts`.

Applied to files:

  • apps/web/app/api/desktop/[...route]/root.ts
🧬 Code graph analysis (2)
apps/web/app/api/desktop/[...route]/root.ts (1)
packages/database/schema.ts (2)
  • organizations (172-207)
  • organizationMembers (210-232)
packages/web-backend/src/Organisations/index.ts (4)
packages/web-domain/src/Organisation.ts (3)
  • Organisation (21-24)
  • OrganisationId (16-18)
  • OrganisationId (19-19)
packages/web-domain/src/Authentication.ts (1)
  • CurrentUser (8-16)
packages/web-domain/src/Policy.ts (2)
  • Policy (8-12)
  • policy (29-41)
packages/database/index.ts (1)
  • db (18-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Analyze (rust)
🔇 Additional comments (3)
apps/web/app/api/desktop/[...route]/root.ts (1)

11-11: LGTM! Necessary imports for tombstone filtering.

The addition of isNull and and imports is correct and required for the soft-delete filtering logic implemented in the /organizations endpoint.

packages/web-backend/src/Organisations/index.ts (2)

2-2: LGTM! Imports support the new delete functionality.

The addition of CurrentUser and Policy imports is necessary for the authentication and authorization checks in the deleteOrg function.


54-56: Policy check correctly implemented.

The ownership verification has been properly added as suggested in the previous review. The implementation correctly ensures the current user owns the organization before allowing deletion.

@ameer2468 ameer2468 merged commit 4e2ee9c into main Nov 3, 2025
17 checks passed
@ameer2468 ameer2468 deleted the delete-org branch November 3, 2025 13:05
});

return { update };
const deleteOrg = Effect.fn("Organisations.deleteOrg")(function* (
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would be better named softDelete

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.

3 participants