Skip to content

User Account deletion - #128

Merged
Friedrich482 merged 9 commits into
mainfrom
features
Apr 5, 2026
Merged

Friedrich482 merged 9 commits into
mainfrom
features

Conversation

@Friedrich482

@Friedrich482 Friedrich482 commented Apr 5, 2026 •

Copy link
Copy Markdown
Owner

Commits

  • feat: delete account

    • added the proper trpc procedure in the auth router and the appropriate method in the auth service to delete the user, used the delete method of the users service, and since the tables are related by one-to-many relationships and ON DELETE CASCADE, it removes all the user data
    • installed the shadcn dialog component
    • added a DeleteAccountSection component in the dashboard with a dialog containing a form: the user is asked to enter his email and the confirm text : "delete my account"
    • fixed the contrast issue of the destructive variant of the button component
    • reduced the opacity of the placeholder text for the input
    • when the user confirms his account deletion, we log him out of the dashboard and also from the extension
  • fix: custom-tooltip

    • fixed the issue of the percentage symbol (%) not being displayed when its value is 0 in the CustomChartToolTip component
    • explicitly added the type "email" for all email inputs in the forms
  • chore: extension

    • bumped extension version to v0.0.60
  • refactor: dashboard

    • renamed the main.tsx and the App.tsx to router.tsx and app.tsx respectively and moved them in the app folder
    • updated the path of the router in the index.html file of the dashboard
    • updated the shared eslint rules in the lint.ts file of the eslint-config package
  • build: turborepo

    • bumped turbo to v2.9.3
  • refactor: vscode extension context

    • got the context directly from the getExtensionContext function instead of passing it in argument to the following functions: serveDashboard, serveDashboardDev, serveDashboardProd, deleteToken, storeJwtToken

Summary by CodeRabbit

  • New Features

    • Account deletion UI with confirmation and server-side account removal.
    • New reusable Dialog component in the UI library.
  • Improvements

    • Inputs explicitly set to email; placeholder styling refined.
    • Higher-contrast destructive button styling.
    • Chart tooltip displays zero percent values.
    • Publisher casing and callback URL validation now case-insensitive.
  • Chores

    • VS Code extension bumped to 0.0.60; developer tooling updated.

- added the proper trpc procedure in the auth router and the appropriate method in the auth service to delete the user, used the delete method of the users service, and since the tables are related by one-to-many relationships and ON DELETE CASCADE, it removes all the user data
- installed the shadcn dialog component
- added a `DeleteAccountSection` component in the dashboard with a dialog containing a form: the user is asked to enter his email and the confirm text : "delete my account"
- fixed the contrast issue of the destructive variant of the button component
- reduced the opacity of the placeholder text for the input
- when the user confirms his account deletion, we log him out of the dashboard and also from the extension
- fixed the issue of the percentage symbol (%) not being displayed when its value is 0 in the `CustomChartToolTip` component
- explicitly added the type "email" for all email inputs in the forms
- bumped extension version to `v0.0.60`
- renamed the `main.tsx` and the `App.tsx` to `router.tsx` and `app.tsx` respectively and moved them in the app folder
- updated the path of the router in the `index.html` file of the dashboard
- updated the shared eslint rules in the `lint.ts` file of the `eslint-config` package
- bumped turbo to `v2.9.3`
- got the context directly from the `getExtensionContext` function instead of passing it in argument to the following functions: `serveDashboard`, `serveDashboardDev`, `serveDashboardProd`, `deleteToken`, `storeJwtToken`
@coderabbitai

coderabbitai Bot commented Apr 5, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds end-to-end account deletion (UI, API, services), a reusable Dialog component, shifts VS Code extension functions to obtain ExtensionContext internally, updates import paths and small UI/styling tweaks, and bumps extension and tooling versions.

Changes

Cohort / File(s) Summary
Account Deletion (API & Services)
apps/api/src/auth/auth.dto.ts, apps/api/src/auth/auth.router.ts, apps/api/src/auth/auth.service.ts, apps/api/src/users/users.dto.ts, apps/api/src/users/users.service.ts
New DTO type aliases; added protected auth.deleteAccount tRPC procedure that calls AuthService.deleteAccount and clears auth cookie; AuthService.deleteAccount delegates to UsersService.delete, which performs a DB delete and throws NOT_FOUND if absent.
Dashboard UI: Delete Account
apps/dashboard/src/features/profile/components/delete-account-section.tsx, apps/dashboard/src/app/pages/profile/profile.tsx
New DeleteAccountSection component with confirmation dialog, zod form validation (email + exact phrase), calls tRPC deleteAccount, invalidates getUser, navigates to /login, and opens VS Code logout deep link; profile page renders it inside its own ErrorBoundary + Suspense.
Dialog UI Component
packages/ui/src/components/ui/dialog.tsx
Added Dialog module wrapping Radix primitives (Dialog, Trigger, Portal, Overlay, Content with optional close button, Header, Footer, Title, Description, Close) and exported helper components.
VS Code Extension: Context & Serve Changes
apps/vscode-extension/src/extension.ts, apps/vscode-extension/src/utils/auth/store-jwt-token.ts, apps/vscode-extension/src/utils/auth/register-auth-uri-handler.ts, apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard.ts, .../serve-dashboard-dev.ts, .../serve-dashboard-prod.ts
Removed vscode.ExtensionContext from public signatures; functions now call getExtensionContext() internally; renamed storeJWTToken → storeJwtToken(token); auth URI handler now supports /logout.
Dashboard Imports & Entry
apps/dashboard/index.html, apps/dashboard/src/app/router.tsx, apps/dashboard/src/app/app.tsx, apps/dashboard/src/components/layout/navigation-reset-wrapper.tsx
Switched HTML entry script to ./src/app/router.tsx; migrated several imports to alias-based paths; renamed exported Wrapper → NavigationResetWrapper and updated usage.
Form input types & minor UI tweaks
apps/dashboard/src/features/auth/components/*, apps/dashboard/src/features/profile/components/create-email-update-form.tsx, apps/dashboard/src/components/common/custom-chart-tooltip.tsx, packages/ui/src/components/ui/input.tsx, packages/ui/src/components/ui/button.tsx
Added explicit type="email" to multiple email inputs; tooltip now renders 0% by guarding against undefined; input placeholder opacity adjusted; destructive button variant restyled for higher contrast.
Radix state selector updates & styling tweaks
packages/ui/src/components/ui/dropdown-menu.tsx, packages/ui/src/components/ui/popover.tsx, packages/ui/src/components/ui/sheet.tsx, packages/ui/src/components/ui/sidebar.tsx
Replaced data-open/data-closed selectors with data-[state=open]/data-[state=closed] variants and adjusted one data-[state=open]:hover selector; styling behavior preserved.
Linting & Naming rules
apps/dashboard/eslint.config.ts, packages/eslint-config/lint.ts
Added import restriction zones to enforce boundaries between app/features and utility dirs; broadened filename-naming-convention globs to enforce kebab-case (removed App exemption).
Extension & Tooling bumps / minor formatting
apps/vscode-extension/package.json, package.json, apps/extension/extension.router.ts, apps/extension/extension.service.ts
Bumped VS Code extension version to 0.0.60; updated turbo to ^2.9.3; minor trailing-comma/formatting edits in extension router/service files.
Constants & schema tweak
packages/common/src/constants.ts, packages/common/src/types-schemas.ts
Changed exported PUBLISHER to Friedrich482 (capitalized) and made VSCode callback URL publisher validation case-insensitive to accept either case.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Browser as Browser (Dashboard)
participant Frontend as Frontend (TRPC Client)
participant API as API (AuthRouter)
participant AuthS as AuthService
participant UsersS as UsersService
participant DB as Database
participant VSCode as VS Code Extension

Browser->>Frontend: Open Delete Account dialog & submit (email + phrase)
Frontend->>API: tRPC auth.deleteAccount (authenticated)
API->>AuthS: deleteAccount({ userId })
AuthS->>UsersS: usersService.delete({ id: userId })
UsersS->>DB: DELETE users WHERE id = userId RETURNING id, username, email
DB-->>UsersS: deleted row or null
UsersS-->>AuthS: deletedUser or throw NOT_FOUND
AuthS-->>API: result / error
API-->>Frontend: mutation result; clears auth cookie
Frontend-->>Browser: navigate to /login
Frontend->>VSCode: open vscode://Friedrich482.{EXTENSION_ID}/logout (deep link)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I nibble keys and tweak a route,

dialogs, cookies, then a final shout,
matching emails, sentence true,
the server clears — adieu, adieu,
hop—account gone, the rabbit's out.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'User Account deletion' directly corresponds to the main feature added across the pull request: a complete user account deletion flow with backend tRPC procedures, service layer methods, and a frontend UI component with confirmation dialog.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch features

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
apps/dashboard/src/app/pages/profile/profile.tsx (1)

99-112: Consider extracting a reusable section boundary wrapper.

This new block repeats the same ErrorBoundary + FallBackRender + SuspenseBoundary structure already used multiple times in this file. Extracting a small wrapper component would reduce duplication and keep profile sections easier to maintain.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/dashboard/src/app/pages/profile/profile.tsx` around lines 99 - 112,
Extract a small wrapper component (e.g., ProfileSectionBoundary or
SectionBoundary) that composes ErrorBoundary, FallBackRender and
SuspenseBoundary and accepts children plus props like className,
hasCustomSkeleton, and hasCustomChildren; replace the repeated block around
DeleteAccountSection (and other similar blocks) with this new wrapper, ensuring
you forward the same ErrorBoundary FallbackComponent signature (error,
resetErrorBoundary) to FallBackRender and preserve SuspenseBoundary props and
children so the behavior of ErrorBoundary, FallBackRender and SuspenseBoundary
remains identical.
apps/api/src/auth/auth.service.ts (1)

369-372: Remove the return statement from deleteAccount—the mutation endpoint doesn't use it.

The deleteAccount mutation in the router (line 207) calls authService.deleteAccount() without capturing its return value, only clearing the authentication cookie. Returning the deleted user object is unnecessary; the endpoint should return void or a simple success response instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/api/src/auth/auth.service.ts` around lines 369 - 372, The deleteAccount
method currently returns the deleted user object from usersService.delete;
remove the unnecessary return so the method returns void/Promise<void> instead.
Update authService.deleteAccount (and its TypeScript signature if present) to
call await this.usersService.delete({ id: userId }) without returning the
result, ensuring the endpoint that calls deleteAccount still clears the auth
cookie and receives no value. Verify any callers assume a return value and
adjust types/imports accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/dashboard/src/features/profile/components/delete-account-section.tsx`:
- Line 77: The PUBLISHER constant is using the wrong casing which causes the
vscode deep-link to point to the wrong authority; update the PUBLISHER constant
definition (symbol: PUBLISHER in packages/common/src/constants.ts) from
"friedrich482" to "Friedrich482" so the generated URL (used in
delete-account-section's window.location.href) matches the extension manifest's
"publisher" value and the registered URI handler will be invoked.
- Around line 55-82: Make onSubmit an async function and replace the
callback-style deleteAccountMutation.mutate with await
deleteAccountMutation.mutateAsync(...) so the form's formState.isSubmitting
reliably stays true during the network call; remove the nested logoutMutation
entirely (logoutMutation and its callbacks) since deleteAccount already clears
the auth cookie, and instead after mutateAsync completes await invalidation of
the auth query (trpc.auth.getUser.queryKey) and call navigate("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/login") and the
vscode logout redirect (window.location.href =
`vscode://${PUBLISHER}.${EXTENSION_ID}/logout`) as the single post-success path;
also update the submit button to disable based on
deleteAccountMutation.isPending (or the mutation's pending state) rather than
relying on form.formState.isSubmitting.

In `@packages/ui/src/components/ui/dialog.tsx`:
- Line 42: Update the Tailwind attribute selectors used for Radix Dialog states:
replace occurrences of the custom variants like "data-open:animate-in
data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0" in the
Dialog component's overlay/panel className strings with Radix-compatible
selectors "data-[state=open]:animate-in data-[state=open]:fade-in-0
data-[state=closed]:animate-out data-[state=closed]:fade-out-0"; apply the same
pattern to all similar usages found in sheet.tsx, popover.tsx, and
dropdown-menu.tsx so the animations use Radix's data-state attributes.

---

Nitpick comments:
In `@apps/api/src/auth/auth.service.ts`:
- Around line 369-372: The deleteAccount method currently returns the deleted
user object from usersService.delete; remove the unnecessary return so the
method returns void/Promise<void> instead. Update authService.deleteAccount (and
its TypeScript signature if present) to call await this.usersService.delete({
id: userId }) without returning the result, ensuring the endpoint that calls
deleteAccount still clears the auth cookie and receives no value. Verify any
callers assume a return value and adjust types/imports accordingly.

In `@apps/dashboard/src/app/pages/profile/profile.tsx`:
- Around line 99-112: Extract a small wrapper component (e.g.,
ProfileSectionBoundary or SectionBoundary) that composes ErrorBoundary,
FallBackRender and SuspenseBoundary and accepts children plus props like
className, hasCustomSkeleton, and hasCustomChildren; replace the repeated block
around DeleteAccountSection (and other similar blocks) with this new wrapper,
ensuring you forward the same ErrorBoundary FallbackComponent signature (error,
resetErrorBoundary) to FallBackRender and preserve SuspenseBoundary props and
children so the behavior of ErrorBoundary, FallBackRender and SuspenseBoundary
remains identical.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1a2106a9-0db9-4e93-8866-f862c46b53dc

📥 Commits

Reviewing files that changed from the base of the PR and between fb352b6 and 3b57c9f.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (32)
  • apps/api/src/auth/auth.dto.ts
  • apps/api/src/auth/auth.router.ts
  • apps/api/src/auth/auth.service.ts
  • apps/api/src/extension/extension.router.ts
  • apps/api/src/extension/extension.service.ts
  • apps/api/src/users/users.dto.ts
  • apps/api/src/users/users.service.ts
  • apps/dashboard/eslint.config.ts
  • apps/dashboard/index.html
  • apps/dashboard/src/app/app.tsx
  • apps/dashboard/src/app/pages/profile/profile.tsx
  • apps/dashboard/src/app/router.tsx
  • apps/dashboard/src/components/common/custom-chart-tooltip.tsx
  • apps/dashboard/src/components/layout/navigation-reset-wrapper.tsx
  • apps/dashboard/src/features/auth/components/forgot-password-form.tsx
  • apps/dashboard/src/features/auth/components/login-form.tsx
  • apps/dashboard/src/features/auth/components/register-form.tsx
  • apps/dashboard/src/features/profile/components/create-email-update-form.tsx
  • apps/dashboard/src/features/profile/components/delete-account-section.tsx
  • apps/vscode-extension/package.json
  • apps/vscode-extension/src/extension.ts
  • apps/vscode-extension/src/utils/auth/delete-token.ts
  • apps/vscode-extension/src/utils/auth/register-auth-uri-handler.ts
  • apps/vscode-extension/src/utils/auth/store-jwt-token.ts
  • apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-dev.ts
  • apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-prod.ts
  • apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard.ts
  • package.json
  • packages/eslint-config/lint.ts
  • packages/ui/src/components/ui/button.tsx
  • packages/ui/src/components/ui/dialog.tsx
  • packages/ui/src/components/ui/input.tsx

Comment thread apps/dashboard/src/features/profile/components/delete-account-section.tsx Outdated
Comment thread packages/ui/src/components/ui/dialog.tsx Outdated
- capitalized the publisher constant
- since the callbackUri of the login function in the vscode-extension will always have the publisher name in lowercase, updated the `VSCodeCallbackUrlSchema` to support the publisher name in lowercase
- updated the return url in the `DeleteAccountSection` component to use the publisher name in lowercase
- fixed the broken transitions on the dialog (when it opens/closes)
- replaced all instances of `data-open` with `data-[state=open]` and `data-closed` with `data-[state=closed]` across the `DropdownMenu`, `Popover`, `Sheet` and `Sidebar` components

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/ui/src/components/ui/dialog.tsx`:
- Around line 144-146: The Tailwind selectors used in the cn call for className
(the tokens "*:[a]:hover:text-foreground", "*:[a]:underline",
"*:[a]:underline-offset-3") are invalid; replace them with Tailwind v4 arbitrary
selector variants that target descendant anchors (e.g., use the "[&_a]:..."
form) or direct-child anchors ("[&>a]:...") so the hover, underline and
underline-offset styles apply to anchor elements; update the className string
passed to cn accordingly while keeping the existing "text-muted-foreground" and
"text-sm" tokens.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bc421b7a-5f98-4c93-8aff-a97368da1087

📥 Commits

Reviewing files that changed from the base of the PR and between 73487fd and 1f45636.

📒 Files selected for processing (5)
  • packages/ui/src/components/ui/dialog.tsx
  • packages/ui/src/components/ui/dropdown-menu.tsx
  • packages/ui/src/components/ui/popover.tsx
  • packages/ui/src/components/ui/sheet.tsx
  • packages/ui/src/components/ui/sidebar.tsx

Comment thread packages/ui/src/components/ui/dialog.tsx
@Friedrich482
Friedrich482 merged commit db99ff4 into main Apr 5, 2026
1 check passed
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