Skip to content

fix(knowledge): connector spinner race condition + connectors column#3812

Merged
waleedlatif1 merged 4 commits intostagingfrom
waleedlatif1/connector-spinner-fix
Mar 27, 2026
Merged

fix(knowledge): connector spinner race condition + connectors column#3812
waleedlatif1 merged 4 commits intostagingfrom
waleedlatif1/connector-spinner-fix

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@waleedlatif1 waleedlatif1 commented Mar 27, 2026

Summary

  • Replace single syncingConnectorId string with syncingIds Set — concurrent syncs on multiple connectors no longer race
  • Replace global isSyncing (from useTriggerSync().isPending) with per-connector isSyncPending — syncing connector A no longer disables the sync button on connector B
  • Replace global isUpdating (from useUpdateConnector().isPending) with per-connector updatingIds Set — pausing connector A no longer disables the pause button on connector B
  • Add Connectors column to knowledge base list table — shows connector icons with tooltips next to Tokens column
  • Show spinner next to connector name while actively syncing (isSyncPending || connector.status === 'syncing')
  • Extract addToSet/removeFromSet helpers to DRY up Set state mutations
  • Extract handleTogglePause callback (was 25-line inline handler)
  • Use onSettled consistently for both syncingIds and updatingIds cleanup

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@cursor
Copy link
Copy Markdown

cursor bot commented Mar 27, 2026

PR Summary

Low Risk
Low risk UI/state-management changes that mainly affect connector action disabling/spinners and knowledge-base list rendering; primary risk is minor UX regressions around pending-state cleanup or sorting.

Overview
Fixes connector action race conditions by tracking sync and pause/update per connector (using Set state + onSettled cleanup) so triggering a sync/pause no longer disables controls for other connectors; the connector card now shows a name-adjacent spinner when that specific connector is syncing.

Adds a Connectors column to the knowledge base list that renders registered connector icons with tooltips and enables sorting by connector count.

Written by Cursor Bugbot for commit 959b7a8. Configure here.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Mar 27, 2026 7:48pm

Request Review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 27, 2026

Greptile Summary

This PR fixes two race conditions in the connectors section of the knowledge base feature and adds a new Connectors column to the knowledge base list view.\n\n- Race condition fix (sync): Replaces the single syncingConnectorId string and global isSyncing flag with a per-connector syncingIds Set, so that triggering a sync on connector A no longer disables the sync button on connector B.\n- Race condition fix (pause/resume): Replaces the global isUpdating flag from useUpdateConnector().isPending with a per-connector updatingIds Set backed by the new handleTogglePause callback, so pausing connector A no longer disables the pause button on connector B.\n- Cleanup consolidation: Both syncingIds and updatingIds entries are now removed in a unified onSettled callback, consistent with the idiomatic React Query pattern for covering both success and error paths.\n- Connectors column: knowledge.tsx adds a Connectors column after Tokens that renders connector icons with tooltips. It filters out unknown registry types gracefully with an em-dash fallback. The server-side connectorTypes array is already deduplicated in service.ts, so the key values in the icon map are safe from duplicate React key warnings.

Confidence Score: 5/5

Safe to merge — all changes are isolated UI state fixes with no data-integrity risk.

No P0 or P1 issues found. The per-connector Set state is implemented correctly with functional updates, server-side deduplication guarantees unique React keys, and the onSettled pattern is now consistent across both sync and update paths. Prior concern about inconsistent cleanup strategy was resolved in the head SHA.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/connectors-section/connectors-section.tsx Replaces single-connector sync/update state with per-connector Set-based state, fixing race conditions when multiple connectors are managed simultaneously; adds dedicated handleTogglePause callback and consolidates cleanup to onSettled.
apps/sim/app/workspace/[workspaceId]/knowledge/knowledge.tsx Adds a Connectors column to the knowledge base list table, rendering per-connector icons with tooltips derived from CONNECTOR_REGISTRY; handles undefined/unknown types gracefully with em-dash fallback.

Sequence Diagram

sequenceDiagram
    participant U as User
    participant CC as ConnectorCard (A)
    participant CC2 as ConnectorCard (B)
    participant CS as ConnectorsSection
    participant TQ as TriggerSync Mutation

    Note over CS: syncingIds = Set{}, updatingIds = Set{}

    U->>CC: Click Sync (connector A)
    CC->>CS: onSync(connectorA.id)
    CS->>CS: addToSet(setSyncingIds, connectorA.id)
    Note over CS: syncingIds = Set{"connectorA"}
    CS->>TQ: triggerSync({knowledgeBaseId, connectorA.id})
    CC-->>U: Sync button disabled for A only

    U->>CC2: Click Sync (connector B) — now allowed!
    CC2->>CS: onSync(connectorB.id)
    CS->>CS: addToSet(setSyncingIds, connectorB.id)
    Note over CS: syncingIds = Set{"connectorA","connectorB"}
    CS->>TQ: triggerSync({knowledgeBaseId, connectorB.id})

    TQ-->>CS: onSettled (connector A)
    CS->>CS: removeFromSet(setSyncingIds, connectorA.id)
    Note over CS: syncingIds = Set{"connectorB"}

    TQ-->>CS: onSettled (connector B)
    CS->>CS: removeFromSet(setSyncingIds, connectorB.id)
    Note over CS: syncingIds = Set{}
Loading

Reviews (2): Last reviewed commit: "refactor(knowledge): use onSettled for s..." | Re-trigger Greptile

@waleedlatif1 waleedlatif1 changed the title fix(knowledge): scope sync/update state per-connector to prevent race conditions fix(knowledge): connector spinner race condition + connectors column Mar 27, 2026
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@waleedlatif1 waleedlatif1 merged commit b90bb75 into staging Mar 27, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/connector-spinner-fix branch March 27, 2026 19:54
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.

1 participant