Skip to content

feat(connectors): use resource selectors for KB connector config#5116

Merged
waleedlatif1 merged 2 commits into
stagingfrom
worktree-fix-gdrive-folder-selector-kb
Jun 17, 2026
Merged

feat(connectors): use resource selectors for KB connector config#5116
waleedlatif1 merged 2 commits into
stagingfrom
worktree-fix-gdrive-folder-selector-kb

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Replace raw ID text inputs with selector pickers across KB connectors so users pick resources instead of pasting IDs — matching the workflow blocks:
    • Google Drive / Docs / Forms — folder picker (google.drive, folder mime)
    • Google Sheets — spreadsheet picker (google.drive, spreadsheet mime)
    • Notion — page picker (notion.pages)
    • Monday — board picker (monday.boards)
    • Webflow — collection picker (webflow.collections)
  • Each field is a canonical pair: a selector (basic) + the original manual-input field (advanced, reachable via the ↔ toggle), sharing canonicalParamId so the resolved config key is unchanged.
  • Add multi-select where the sync handler supports it (Drive/Docs/Forms folders, Monday boards, Webflow collections) via parseMultiValue.
  • Add shared escapeDriveQueryValue / buildDriveParentsClause helpers for safe multi-folder Drive q queries (single-quote/backslash escaped, OR-joined).
  • Add ConnectorConfigField.mimeType, plumbed into the selector context so the Drive picker can be scoped to folders vs spreadsheets.
  • Fix Webflow listingCapped not being set on maxItems truncation — prevents the sync engine from hard-deleting still-existing documents.

Backward compatibility

  • Legacy single-string IDs and comma-separated values both normalize through parseMultiValue (string | string[]); a single stored ID produces the identical single-value query as before, empty stays "all".
  • Resolved canonical keys (folderId, spreadsheetId, rootPageId, boardIds, collectionId) are unchanged, so existing connectors and sync handlers are unaffected; opening + saving an unchanged connector is a no-op.

Type of Change

  • New feature / improvement

Testing

  • Ran /validate-connector against all 7 connectors, cross-checked each against live API docs (Drive/Docs/Sheets/Forms, Notion, monday.com GraphQL, Webflow Data API v2) — all pass.
  • bunx tsc clean, bun run lint clean, bun run check:api-validation passes.

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)

Replace raw ID text inputs with selector pickers (canonical selector +
manual-input pairs) across Google Drive/Docs/Forms/Sheets, Notion, Monday,
and Webflow KB connectors, so users pick folders/spreadsheets/pages/boards/
collections instead of pasting IDs — matching the workflow blocks.

- Add multi-select where the sync handler supports it (Drive/Docs/Forms
  folders, Monday boards, Webflow collections) via parseMultiValue
- Add shared escapeDriveQueryValue/buildDriveParentsClause helpers for safe
  multi-folder Drive queries
- Add ConnectorConfigField.mimeType, plumbed into the selector context
- Fix Webflow listingCapped not set on maxItems truncation (deletion-
  reconciliation data-loss safety)

Fully backward compatible: legacy single-string IDs and CSV both normalize
via parseMultiValue; resolved canonical keys are unchanged.
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jun 17, 2026 7:40pm

Request Review

@cursor

cursor Bot commented Jun 17, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes sync listing queries, validation, and deletion reconciliation (Webflow cap flag); mistakes could mis-scope syncs or delete KB documents, though canonical keys and parseMultiValue preserve legacy configs.

Overview
Knowledge base connector setup now favors resource pickers (basic mode) over pasting IDs, with the same manual ID fields kept in advanced mode behind a canonical pair (canonicalParamId + mode). Resolved config keys (folderId, spreadsheetId, etc.) stay the same for backward compatibility.

Google Drive, Docs, and Forms gain multi-folder folder pickers and comma-separated advanced IDs; listing/validation use parseMultiValue and shared buildDriveParentsClause / escapeDriveQueryValue for safe OR-style Drive q queries. Sheets adds a spreadsheet picker scoped by mimeType. Notion, Monday, and Webflow add page/board/collection selectors (Webflow collections are multi-select and depend on site).

ConnectorConfigField.mimeType is wired through ConnectorSelectorField into selector context so the Drive picker can limit to folders vs spreadsheets.

Webflow now treats maxItems truncation as a capped listing (listingCapped) when more items/pages/collections remain, so the sync engine does not reconcile deletions against an incomplete list.

Reviewed by Cursor Bugbot for commit 345bc5a. Configure here.

@greptile-apps

greptile-apps Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces raw ID text inputs with resource selector pickers across KB connectors (Google Drive/Docs/Forms, Google Sheets, Notion, Monday, Webflow), adding multi-select support where the sync handler supports it. It also introduces shared escapeDriveQueryValue/buildDriveParentsClause helpers, adds a mimeType field to ConnectorConfigField for scoping Drive pickers, and fixes a Webflow listingCapped edge case for single-page collections truncated within a page.

  • Selector/manual-input canonical pairs: Each affected field gains a selector (basic mode) sibling sharing canonicalParamId with the existing text input (advanced mode), so the resolved config key fed to connector handlers is unchanged and backward-compatible with stored single-string and CSV IDs.
  • Multi-value Drive queries: buildDriveParentsClause emits ('A' in parents or 'B' in parents) (parenthesized OR) for multi-folder Drive q queries and falls back to the bare single-folder form, with proper single-quote/backslash escaping.
  • Webflow listingCapped fix: A new droppedWithinPage guard catches the case where maxItems truncates within a single-page collection response — previously the flag was never set, causing the sync engine to hard-delete still-existing documents.

Confidence Score: 5/5

Safe to merge — the changes are additive UI wiring with no breaking changes to stored config keys or connector handler contracts.

All connector handlers normalize inputs through parseMultiValue so legacy single-string and CSV values produce identical query behaviour to before. The Drive OR-query parenthesisation is correct, escapeDriveQueryValue ordering is right (backslash before quote), the Webflow listingCapped fix is logically sound, and mimeType is already a recognised SelectorContext field. siteId is in SELECTOR_CONTEXT_FIELDS, so the collectionSelector.dependsOn: ['siteSelector'] canonical-pair resolution works correctly in both basic and advanced site-input modes.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/connectors/utils.ts Adds escapeDriveQueryValue and buildDriveParentsClause helpers; escaping logic (backslash then single-quote) is order-correct and parenthesisation of multi-folder OR is applied properly.
apps/sim/connectors/types.ts Adds optional mimeType field to ConnectorConfigField for UI-side Drive picker scoping; no runtime impact on connector handlers.
apps/sim/connectors/webflow/webflow.ts Migrates collectionId to parseMultiValue; fixes listingCapped for single-page truncation via droppedWithinPage; validation loop correctly short-circuits on any failed collection check.
apps/sim/connectors/webflow/meta.ts Adds collectionSelector (basic, multi) with dependsOn: ['siteSelector'] so the collection picker is scoped to the selected site via canonical-pair mode resolution.
apps/sim/connectors/google-drive/google-drive.ts Migrates folderId to parseMultiValue; validation loop iterates all folder IDs with encodeURIComponent; buildDriveParentsClause replaces inline escaping in buildQuery.
apps/sim/connectors/google-forms/google-forms.ts Migrates buildDriveQuery signature from optional string to string[]; refactors logging to join array; validation loop is consistent with Drive/Docs pattern.
apps/sim/connectors/notion/meta.ts Adds rootPageSelector (basic) / updates rootPageId (advanced) with canonical pair linkage; single-select only, consistent with the connector accepting one root page.
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/connector-selector-field/connector-selector-field.tsx Threads field.mimeType into SelectorContext and adds it to the useMemo dependency array; mimeType is already a valid SelectorContext field.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User opens KB connector config] --> B{Mode toggle}
    B -->|basic| C[Selector picker]
    B -->|advanced| D[Manual text input]
    C --> E[Value stored via canonicalParamId]
    D --> E
    E --> F[parseMultiValue normalizes to string array]
    F --> G{Provider}
    G -->|Drive/Docs/Forms| H[buildDriveParentsClause OR-joined parents clauses with escaping]
    G -->|Webflow| I[fetchCollectionIds returns selected or all site collections]
    G -->|Notion| J[rootPageId single value]
    G -->|Monday| K[boardIds array]
    H --> L[Drive q query: trashed=false AND mimeType AND clause]
    I --> M[CursorState with collectionIndex]
    M --> N{maxItems reached?}
    N -->|yes plus items dropped or hasMore| O[listingCapped = true skip deletion reconciliation]
    N -->|exact boundary nothing dropped| P[Normal reconciliation safe to delete stale docs]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[User opens KB connector config] --> B{Mode toggle}
    B -->|basic| C[Selector picker]
    B -->|advanced| D[Manual text input]
    C --> E[Value stored via canonicalParamId]
    D --> E
    E --> F[parseMultiValue normalizes to string array]
    F --> G{Provider}
    G -->|Drive/Docs/Forms| H[buildDriveParentsClause OR-joined parents clauses with escaping]
    G -->|Webflow| I[fetchCollectionIds returns selected or all site collections]
    G -->|Notion| J[rootPageId single value]
    G -->|Monday| K[boardIds array]
    H --> L[Drive q query: trashed=false AND mimeType AND clause]
    I --> M[CursorState with collectionIndex]
    M --> N{maxItems reached?}
    N -->|yes plus items dropped or hasMore| O[listingCapped = true skip deletion reconciliation]
    N -->|exact boundary nothing dropped| P[Normal reconciliation safe to delete stale docs]
Loading

Reviews (2): Last reviewed commit: "fix(webflow): set listingCapped on withi..." | Re-trigger Greptile

Comment thread apps/sim/connectors/webflow/webflow.ts Outdated
When a collection's items fit in a single API page but maxItems cuts the
list within that page, neither hasMoreInCollection nor hasMoreCollections is
true, so listingCapped was not set and the sync engine could hard-delete
still-existing documents. Add the within-page drop signal to the guard.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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

Reviewed by Cursor Bugbot for commit 345bc5a. Configure here.

@waleedlatif1 waleedlatif1 merged commit 4d39b0c into staging Jun 17, 2026
16 checks passed
@waleedlatif1 waleedlatif1 deleted the worktree-fix-gdrive-folder-selector-kb branch June 17, 2026 19: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.

1 participant