Skip to content

Conversation

@hmacr
Copy link
Contributor

@hmacr hmacr commented Nov 6, 2025

Task: https://linear.app/appwrite/issue/SER-53/send-email-on-failed-deployment

Summary by CodeRabbit

  • New Features
    • Introduced a new "Alerts" section in account settings
    • Users can now manage email notifications for deployment failures using a dedicated toggle
    • Deployment failure email alert preference added to user account management

@appwrite
Copy link

appwrite bot commented Nov 6, 2025

Console

Project ID: 688b7bf400350cbd60e9

Sites (1)
Site Status Logs Preview QR
 console-stage
688b7cf6003b1842c9dc
Ready Ready View Logs Preview URL QR Code

Tip

Cursor pagination performs better than offset pagination when loading further pages.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

Walkthrough

This pull request adds a new deployment failed email alert preference feature. It introduces a deploymentFailedEmailAlert boolean field to the Account type in the user store, creates a new alerts settings page as a Svelte component with a toggle switch for this preference, and adds a corresponding navigation tab in the account header. The alerts page manages state locally and persists changes via an SDK call to update user preferences.

Estimated Code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • src/lib/stores/user.ts: Verify the new field is properly typed and integrated into the Account type structure
  • src/routes/(console)/account/alerts/+page.svelte: Ensure the state initialization correctly handles the fallback to true when the preference is undefined, validate that the toggle function properly constructs the merged preferences object, and confirm the SDK call to updatePrefs() is syntactically correct
  • src/routes/(console)/account/header.svelte: Verify the new tab entry is correctly positioned and that the href, title, and event properties are properly configured

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 'feat: Alert preference for deployment failures' directly and clearly summarizes the main change: adding an alert preference feature for deployment failures, which is evidenced by the new deploymentFailedEmailAlert field, the alerts page component, and the alerts tab addition.
✨ 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 ser-53

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

🧹 Nitpick comments (1)
src/routes/(console)/account/alerts/+page.svelte (1)

1-1: Consider using TypeScript.

Other files in the codebase (e.g., header.svelte) use <script lang="ts">. Consider using TypeScript for consistency and type safety.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0ff33c and af25785.

📒 Files selected for processing (3)
  • src/lib/stores/user.ts (1 hunks)
  • src/routes/(console)/account/alerts/+page.svelte (1 hunks)
  • src/routes/(console)/account/header.svelte (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Tests
src/routes/(console)/account/alerts/+page.svelte

[warning] 1-1: Code style issues found by Prettier. Run 'prettier --write' to fix.

src/routes/(console)/account/header.svelte

[warning] 1-1: Code style issues found by Prettier. Run 'prettier --write' to fix.

⏰ 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). (1)
  • GitHub Check: e2e
🔇 Additional comments (1)
src/lib/stores/user.ts (1)

12-12: LGTM!

The addition of the deploymentFailedEmailAlert boolean field to the Account type is correct and follows the existing pattern.

Comment on lines +1 to +38
<script>
import { CardGrid } from "$lib/components";
import { InputChoice } from "$lib/elements/forms";
import { Container } from "$lib/layout";
import { sdk } from '$lib/stores/sdk';
import { user } from '$lib/stores/user';
import { Layout } from "@appwrite.io/pink-svelte";
let deploymentFailedEmailAlert = $user.prefs.deploymentFailedEmailAlert ?? true;
function toggleDeploymentFailedEmailAlert() {
deploymentFailedEmailAlert = !deploymentFailedEmailAlert;
const newPrefs = {
...$user.prefs,
deploymentFailedEmailAlert: deploymentFailedEmailAlert
};
sdk.forConsole.account.updatePrefs({ prefs: newPrefs });
}
</script>
<Container>
<CardGrid>
<svelte:fragment slot="title">Email Alerts</svelte:fragment>
Toggle email preferences to receive notifications when certain events occur.
<svelte:fragment slot="aside">
<Layout.Stack gap="xl">
<InputChoice
on:change={toggleDeploymentFailedEmailAlert}
type="switchbox"
id="mfa"
label="Deployment Failed"
value={deploymentFailedEmailAlert} />
</Layout.Stack>
</svelte:fragment>
</CardGrid>
</Container> No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix code formatting.

The pipeline indicates Prettier formatting issues. Run prettier --write to fix.

🧰 Tools
🪛 GitHub Actions: Tests

[warning] 1-1: Code style issues found by Prettier. Run 'prettier --write' to fix.

🤖 Prompt for AI Agents
In src/routes/(console)/account/alerts/+page.svelte around lines 1 to 38 the
file fails Prettier formatting; run `prettier --write
src/routes/(console)/account/alerts/+page.svelte` (or `prettier --write .` at
repo root) to automatically fix formatting, then review the changed diff and
commit the formatted file so the pipeline passes.

Comment on lines +11 to +18
function toggleDeploymentFailedEmailAlert() {
deploymentFailedEmailAlert = !deploymentFailedEmailAlert;
const newPrefs = {
...$user.prefs,
deploymentFailedEmailAlert: deploymentFailedEmailAlert
};
sdk.forConsole.account.updatePrefs({ prefs: newPrefs });
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add error handling and await the API call.

The updatePrefs call has several issues:

  1. No error handling—if the API call fails, the local state will be out of sync with the server.
  2. The promise is not awaited, so you can't provide user feedback or handle failures.
  3. No loading or success indicators for the user.

Consider this approach:

+    import { addNotification } from '$lib/stores/notifications';
+
     let deploymentFailedEmailAlert = $user.prefs.deploymentFailedEmailAlert ?? true;
+    let isUpdating = false;

-    function toggleDeploymentFailedEmailAlert() {
+    async function toggleDeploymentFailedEmailAlert() {
+      if (isUpdating) return;
+      
+      const previousValue = deploymentFailedEmailAlert;
       deploymentFailedEmailAlert = !deploymentFailedEmailAlert;
+      
       const newPrefs = {
         ...$user.prefs,
         deploymentFailedEmailAlert: deploymentFailedEmailAlert
       };
-      sdk.forConsole.account.updatePrefs({ prefs: newPrefs });
+      
+      isUpdating = true;
+      try {
+        await sdk.forConsole.account.updatePrefs({ prefs: newPrefs });
+        addNotification({
+          type: 'success',
+          message: 'Email alert preference updated'
+        });
+      } catch (error) {
+        deploymentFailedEmailAlert = previousValue; // Revert on failure
+        addNotification({
+          type: 'error',
+          message: error.message
+        });
+      } finally {
+        isUpdating = false;
+      }
     }

Committable suggestion skipped: line range outside the PR's diff.

<InputChoice
on:change={toggleDeploymentFailedEmailAlert}
type="switchbox"
id="mfa"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix incorrect ID attribute.

The id attribute is set to "mfa" but this input is for deployment failure alerts, not multi-factor authentication.

Apply this diff:

-            id="mfa"
+            id="deploymentFailedEmailAlert"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
id="mfa"
id="deploymentFailedEmailAlert"
🤖 Prompt for AI Agents
In src/routes/(console)/account/alerts/+page.svelte around line 32, the input's
id is incorrectly set to "mfa" for a deployment failure alert; change the id to
a descriptive value such as "deployment-failure" (or "deploy-failure-alert") and
update any matching label for= attributes or JS selectors that reference "mfa"
to use the new id so markup and bindings remain consistent.

Comment on lines +36 to 41
},
{
href: `${path}/alerts`,
title: 'Alerts',
event: 'alerts',
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix code formatting.

The pipeline indicates Prettier formatting issues. Run prettier --write to fix.

🤖 Prompt for AI Agents
In src/routes/(console)/account/header.svelte around lines 36 to 41 the code is
misformatted according to Prettier; run the project's Prettier formatter (e.g.,
run `prettier --write src/routes/(console)/account/header.svelte` or simply
`prettier --write .`), or apply the repo's editor formatting rules to reformat
this block so spacing, commas and indentation match the project's Prettier
configuration, then stage and commit the formatted file.

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.

2 participants