Skip to content

Comments

Fix CSV import notification staying visible after completion#2832

Open
aaravjaichand wants to merge 1 commit intoappwrite:mainfrom
aaravjaichand:fix/csv-import-notification-stuck
Open

Fix CSV import notification staying visible after completion#2832
aaravjaichand wants to merge 1 commit intoappwrite:mainfrom
aaravjaichand:fix/csv-import-notification-stuck

Conversation

@aaravjaichand
Copy link

@aaravjaichand aaravjaichand commented Feb 4, 2026

Summary

  • Auto-remove completed and failed import notifications after 5 seconds
  • Add timeout tracking to prevent memory leaks and race conditions
  • Clean up timeouts on component unmount and manual clear

Related Issue

Fixes #2877

Test Plan

  • Import a CSV file successfully and verify the notification disappears after 5 seconds
  • Import a CSV file with invalid headers to trigger a failure and verify the notification disappears after 5 seconds
  • Navigate away from the page during an import and return to verify no stale notifications persist

Summary by CodeRabbit

  • Bug Fixes
    • Import items that reach completed or failed status now show completion notifications and are automatically removed from the import list after 5 seconds.
    • Improved cleanup on unload and during import clearing to cancel pending removals and prevent memory leaks during repeated CSV import operations.

@appwrite
Copy link

appwrite bot commented Feb 4, 2026

Console (appwrite/console)

Project ID: 688b7bf400350cbd60e9

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

Tip

Functions can run for up to 15 minutes before timing out

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

Adds automatic timed removal of completed or failed CSV import items from the UI using a removalTimeouts map that tracks per-item setTimeout handles. When an import reaches completed/failed, any existing timeout for that item is cleared, showCompletionNotification is invoked inside a try/finally, and a new 5-second timeout is scheduled to remove the item and clear its handle. clear() and the onMount cleanup now clear all active removal timeouts and reset removalTimeouts, and the realtime listener unsubscribe is captured and invoked on teardown.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix CSV import notification staying visible after completion' accurately summarizes the main change—implementing auto-removal of completed/failed import notifications.
Linked Issues check ✅ Passed The code changes fully address issue #10219 by implementing auto-removal of failed/completed import notifications after 5 seconds with proper timeout tracking to prevent memory leaks.
Out of Scope Changes check ✅ Passed All changes in csvImportBox.svelte are scoped to fixing the notification persistence issue through timeout management and cleanup logic, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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

🤖 Fix all issues with AI agents
In `@src/lib/components/csvImportBox.svelte`:
- Around line 125-141: The auto-removal scheduling is skipped if
showCompletionNotification(databaseId, tableId, importData) rejects; wrap the
await call in a try { await showCompletionNotification(...) } finally { ... }
block so the existing timeout-clear and setTimeout logic (using removalTimeouts,
importItems and importData.$id) always runs; keep the existing
clearTimeout/removalTimeouts.set(...) semantics inside the finally and rethrow
the error after the finally if you want callers to observe failures.
🧹 Nitpick comments (1)
src/lib/components/csvImportBox.svelte (1)

40-45: Trim non-essential comments for removalTimeouts.

These comments restate straightforward logic and add noise. Consider removing them to keep comments minimal.

♻️ Suggested cleanup
-    /**
-     * Tracks removal timeouts for completed/failed imports.
-     * Used to prevent memory leaks and race conditions.
-     */
     let removalTimeouts = new Map<string, ReturnType<typeof setTimeout>>();
@@
-            // Clear any existing timeout for this item to prevent race conditions
             const existingTimeout = removalTimeouts.get(importData.$id);
             if (existingTimeout) {
                 clearTimeout(existingTimeout);
             }
 
-            // Auto-remove completed/failed items after a delay so users see the result
             const timeoutId = setTimeout(() => {
                 const next = new Map(importItems);
                 next.delete(importData.$id);
                 importItems = next;
                 removalTimeouts.delete(importData.$id);
             }, 5000);

As per coding guidelines: Use minimal comments; only comment TODOs or complex logic.

Also applies to: 128-135

Auto-remove completed and failed import notifications after 5 seconds.
Adds proper timeout tracking to prevent memory leaks and race conditions,
with cleanup on component unmount.

Fixes appwrite/appwrite#10219
@aaravjaichand aaravjaichand force-pushed the fix/csv-import-notification-stuck branch from 6b01291 to 46cdfcf Compare February 23, 2026 04:56
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.

🐛 Bug Report: Failed CSV import makes import notification UI always visible on console

1 participant