feat: support multiple nango connections#4481
Conversation
✅ Deploy Preview for hyprnote-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for hyprnote ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Note that we need |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Free Tier Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Autofix Details
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Auto-mode cleanup deletes all user connections for integration
- The auto-mode 404 reconnect cleanup now deletes only the stale
integration_id+connection_idrow viadelete_connection_by_connectioninstead of all user integration rows.
- The auto-mode 404 reconnect cleanup now deletes only the stale
- ✅ Fixed: Failed connection fetch causes sibling calendars to be deleted
syncCalendarsnow tracks per-provider connection fetch errors and skips provider-wide calendar deletion when any connection list call fails, preventing accidental sibling calendar removal.
Or push these changes by commenting:
@cursor push 9fc6081528
Preview (9fc6081528)
diff --git a/apps/desktop/src/services/calendar/ctx.ts b/apps/desktop/src/services/calendar/ctx.ts
--- a/apps/desktop/src/services/calendar/ctx.ts
+++ b/apps/desktop/src/services/calendar/ctx.ts
@@ -100,13 +100,17 @@
connectionId: string;
calendars: CalendarListItem[];
}[] = [];
+ let hadConnectionError = false;
for (const connectionId of connection_ids) {
const result = await calendarCommands.listCalendars(
provider,
connectionId,
);
- if (result.status === "error") continue;
+ if (result.status === "error") {
+ hadConnectionError = true;
+ continue;
+ }
perConnection.push({ connectionId, calendars: result.data });
}
@@ -117,14 +121,16 @@
store.transaction(() => {
const removedCalendarIds = new Set<string>();
- for (const rowId of store.getRowIds("calendars")) {
- const row = store.getRow("calendars", rowId);
- if (
- row.provider === provider &&
- !incomingIds.has(row.tracking_id_calendar as string)
- ) {
- removedCalendarIds.add(rowId);
- store.delRow("calendars", rowId);
+ if (!hadConnectionError) {
+ for (const rowId of store.getRowIds("calendars")) {
+ const row = store.getRow("calendars", rowId);
+ if (
+ row.provider === provider &&
+ !incomingIds.has(row.tracking_id_calendar as string)
+ ) {
+ removedCalendarIds.add(rowId);
+ store.delRow("calendars", rowId);
+ }
}
}
diff --git a/crates/api-nango/src/routes/connect.rs b/crates/api-nango/src/routes/connect.rs
--- a/crates/api-nango/src/routes/connect.rs
+++ b/crates/api-nango/src/routes/connect.rs
@@ -126,7 +126,10 @@
);
state
.supabase
- .delete_connection(&user_id, &body.integration_id)
+ .delete_connection_by_connection(
+ &body.integration_id,
+ &existing.connection_id,
+ )
.await?;
}
Err(err) => {This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
cd55872 to
e5de61d
Compare

Note
Medium Risk
Medium risk because it changes integration session/disconnect APIs, calendar sync behavior, and Supabase uniqueness constraints to key by
integration_id + connection_id, which could affect existing connections and sync data cleanup if mis-migrated.Overview
Adds multi-account support for Nango-backed integrations by treating connections as
(integration_id, connection_id)instead of a single connection per integration.Updates the backend calendar API to require
connection_idinlist-calendars/list-events(Google/Outlook) and validates connection status/ownership via a newNangoConnectionState.build_http_clientpath. The Nango session API now acceptsmode(auto/connect/reconnect) plus optionalconnection_id, and disconnect deletes byconnection_id.Desktop and web UIs are updated to surface multiple connections (add account, pick connection for reconnect/disconnect), and the desktop calendar sync pipeline is refactored to sync per provider and per
connectionId, storingconnection_idon calendars and filtering/syncing events accordingly (including cleanup for removed calendars). A Supabase migration and upsert conflict target are updated to allow multiple connections per integration, and the Tauri calendar plugin gainslist_connection_idsplusconnectionIdparameters for calendar/event listing.Written by Cursor Bugbot for commit af2da4e. This will update automatically on new commits. Configure here.