Skip to content

fix(import): fix file picker not opening on repeated import attempts COMPASS-10565#7981

Draft
johnjackweir wants to merge 2 commits intomainfrom
cursor/data-import-functionality-e5f2
Draft

fix(import): fix file picker not opening on repeated import attempts COMPASS-10565#7981
johnjackweir wants to merge 2 commits intomainfrom
cursor/data-import-functionality-e5f2

Conversation

@johnjackweir
Copy link
Copy Markdown
Collaborator

Description

Fixes two interrelated bugs that prevented the "Add Data >> Import JSON or CSV file" feature from working reliably, particularly on macOS ARM:

Bug 1 – Silent error swallowing in file dialog backend: When electron.dialog.showOpenDialog rejected (e.g. due to @electron/remote issues on macOS ARM), the .catch(() => { /* ignore */ }) handler silently swallowed the error without notifying listeners. This left the import modal in a stuck invisible state (isOpen: true, rendering inside display: none), where the user sees "nothing happened."

Fix: The catch handler now notifies listeners with an empty file list ([]) on error, which triggers the onCancel callback and properly closes the modal.

Bug 2 – File dialog not re-opening on second attempt: When the import was re-triggered while the modal was stuck (or after a failed first attempt where state wasn't cleaned up), openImport dispatched OPEN which reset the state to the same shape (isOpen: true, fileName: '', errors: []). React reused the existing ImportFileInput component without remounting it, so the mount-only autoOpen effect (useEffect([], [])) never re-fired, and the native file dialog never opened.

Fix: Added an openId counter to the import Redux state that increments on each OPEN action. This openId is used as a React key on the ImportFileInput component, forcing React to remount it on every new import attempt, which re-triggers the autoOpen effect.

Bug 3 – Incorrect telemetry origin: openImportFileDialog in crud-store.ts always hardcoded origin: 'empty-state' regardless of the actual origin ('crud-toolbar' or 'empty-state').

Fix: The method now accepts and forwards the origin parameter.

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • If this change could impact the load on the MongoDB cluster, please describe the expected and worst case impact
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

Users on macOS ARM reported that the import file picker would either do nothing on first attempt, or completely stop responding on subsequent attempts within the same session (COMPASS-10565).

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

  • The FilePickerDialog component is marked as @deprecated in favor of FileSelector. A follow-up migration could further improve robustness.

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)
Open in Web Open in Cursor 

cursoragent and others added 2 commits April 15, 2026 17:15
…OMPASS-10565

Two issues were preventing the import file picker from working reliably:

1. In createElectronFileInputBackend, when showOpenDialog rejected (e.g. on
   macOS ARM), the catch handler silently swallowed the error without notifying
   listeners. This left the import modal in a stuck invisible state. Fix: notify
   listeners with an empty file list on error so the modal can clean up via the
   onCancel handler.

2. When the import was re-triggered while the modal was stuck, openImport reset
   the state to the same shape (isOpen: true, fileName: '', errors: []).
   React reused the existing ImportFileInput without remounting, so the
   mount-only autoOpen effect never re-fired. Fix: add an openId counter to
   the import state that increments on each OPEN action and use it as a React
   key to force remounting ImportFileInput.

Also fixed openImportFileDialog in crud-store to accept and forward the
origin parameter for correct telemetry tracking.

Co-authored-by: Jack Weir <johnjackweir@users.noreply.github.com>
@github-actions github-actions bot added the fix label Apr 15, 2026
@nbbeeken nbbeeken requested a review from Copilot April 15, 2026 18:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes reliability issues with the “Add Data → Import JSON or CSV file” flow by ensuring file dialog failures and repeated open attempts always result in a clean cancel/close path, and by correcting telemetry origin attribution.

Changes:

  • Add an openId counter to import Redux state and use it as a React key to force remounting the auto-opening file input on each OPEN.
  • Ensure Electron file dialog backend notifies listeners with [] when showOpenDialog rejects (instead of silently swallowing the error).
  • Update CRUD store openImportFileDialog to accept/forward an origin parameter rather than hardcoding 'empty-state'.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/compass-import-export/src/modules/import.ts Adds openId to state and increments it on each OPEN to support deterministic remounting behavior.
packages/compass-import-export/src/modules/import.spec.ts Adds reducer-level tests validating openId increments across opens (with and without closing).
packages/compass-import-export/src/components/import-modal.tsx Uses openId as a key for ImportFileInput when auto-opening, forcing the native dialog to re-trigger on re-open.
packages/compass-crud/src/stores/crud-store.ts Forwards the correct origin in the emitted open-import event.
packages/compass-components/src/components/file-picker-dialog.tsx Calls listeners with [] when the Electron dialog promise rejects, avoiding stuck UI state.
packages/compass-components/src/components/file-picker-dialog.spec.tsx Adds a test ensuring listeners are called with [] on dialog rejection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants