Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface OnboardingContentProps {
}

export function OnboardingContent({ step }: OnboardingContentProps) {
const { emailAccountId, provider } = useAccount();
const { emailAccountId, provider, isLoading } = useAccount();

useSignUpEvent();

Expand Down Expand Up @@ -101,5 +101,10 @@ export function OnboardingContent({ step }: OnboardingContentProps) {

const renderStep = steps[clampedStep - 1] || steps[0];

// Show loading if provider is needed but not loaded yet
if (isLoading && !provider) {
return null;
}
Comment on lines +104 to +107
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Verify the loading guard covers all edge cases.

The current guard blocks rendering only when isLoading && !provider. However, if isLoading is false but provider is still undefined (e.g., due to a data loading error), the rendering will proceed and steps 5-7 (StepLabels, StepDraft, StepCustomRules) will receive an undefined provider.

Consider whether the guard should be if (!provider) instead, or verify that provider is always defined once isLoading is false.

Run the following script to check how the dependent steps handle undefined provider:


🏁 Script executed:

#!/bin/bash
# Description: Check if StepLabels, StepDraft, and StepCustomRules handle undefined provider

# Search for provider usage in these step components
for step in StepLabels StepDraft StepCustomRules; do
  echo "=== Checking $step ==="
  fd -t f "$step.tsx" -x cat {} \; | head -100
done

# Look for provider type definitions to see if it's nullable
echo "=== Checking provider type definition ==="
rg -A 5 "type.*provider" apps/web/providers/EmailAccountProvider.tsx

Length of output: 6778


#!/bin/bash

Locate and preview OnboardingContent.tsx

echo "=== File Path ==="
fd OnboardingContent.tsx
echo "=== OnboardingContent.tsx Preview ==="
fd OnboardingContent.tsx -x sed -n '1,200p' {} ;

Search for provider hook usage

echo "=== Searching for provider hook ==="
rg -n "provider" -C3 apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsx


🏁 Script executed:

#!/bin/bash
# Locate OnboardingContent.tsx
file=$(fd OnboardingContent.tsx | head -n1)
echo "=== File Path ==="
echo "$file"

# Preview first 200 lines
echo "=== Preview Lines 1-200 ==="
sed -n '1,200p' "$file"

# Search for provider, isLoading, and hook definitions
echo "=== Searching for provider usage ==="
rg -n "provider" -C3 "$file"

echo "=== Searching for isLoading usage ==="
rg -n "isLoading" -C3 "$file"

echo "=== Searching for hook or data loader ==="
rg -n "use" -C3 "$file"

Length of output: 7953


🏁 Script executed:

#!/bin/bash
# Locate EmailAccountProvider.tsx
file=$(fd providers/EmailAccountProvider.tsx | head -n1)
echo "=== File Path ==="
echo "$file"

# Preview first 200 lines (context, context provider setup)
echo "=== Preview Lines 1-200 ==="
sed -n '1,200p' "$file"

# Search for `provider` in context value and types
echo "=== Searching for provider in context ==="
rg -n "provider" -C3 "$file"

Length of output: 173


🏁 Script executed:

#!/bin/bash
# Find the EmailAccountProvider file (ts or tsx)
echo "=== Candidate Files ==="
fd -e ts -e tsx EmailAccountProvider

# Preview the first match
file=$(fd -e ts -e tsx EmailAccountProvider | head -n1)
echo "=== File Path ==="
echo "$file"

echo "=== Preview Lines 1-200 ==="
sed -n '1,200p' "$file"

# Show useAccount implementation
echo "=== useAccount Definition ==="
rg -n "useAccount" -C5 "$file"

# Show context value shape including provider and isLoading
echo "=== Context Value ==="
rg -n "createContext" -C5 "$file"
rg -n "AccountContext" -C5 "$file"
rg -n "value=" -C5 "$file"

Length of output: 4628


Include provider presence in loading guard
In OnboardingContent.tsx (lines 104–107), update the render guard to also block when provider is missing:

-  // Show loading if provider is needed but not loaded yet
-  if (isLoading && !provider) {
-    return null;
-  }
+  // Show loading or missing provider
+  if (isLoading || !provider) {
+    return null;
+  }
📝 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
// Show loading if provider is needed but not loaded yet
if (isLoading && !provider) {
return null;
}
// Show loading or missing provider
if (isLoading || !provider) {
return null;
}
🤖 Prompt for AI Agents
In apps/web/app/(app)/[emailAccountId]/onboarding/OnboardingContent.tsx around
lines 104 to 107, the render guard only returns early when isLoading is true and
provider is falsy; update it so the component also blocks rendering whenever
provider is missing by changing the condition to use a logical OR between
isLoading and the provider presence check, returning null if either is true.


return renderStep ? renderStep() : null;
}
6 changes: 3 additions & 3 deletions apps/web/utils/category-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const categoryConfig = (
tooltipText: "Newsletters, blogs, and publications",
Icon: NewspaperIcon,
iconColor: "purple",
action: "label",
action: isMicrosoftProvider(provider) ? "move_folder" : "label",
},
{
key: SystemRule.Marketing,
Expand All @@ -61,15 +61,15 @@ export const categoryConfig = (
tooltipText: "Invoices, receipts, and payments",
Icon: ReceiptIcon,
iconColor: "orange",
action: "label",
action: isMicrosoftProvider(provider) ? "move_folder" : "label",
},
{
key: SystemRule.Notification,
label: "Notification",
tooltipText: "Alerts, status updates, and system messages",
Icon: BellIcon,
iconColor: "red",
action: "label",
action: isMicrosoftProvider(provider) ? "move_folder" : "label",
},
{
key: SystemRule.ColdEmail,
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.15.3
v2.15.4
Loading