Commit 48d59ca
authored
fix(connectors): make selector dropdowns resolve options the drain has not reached (#6027)
* fix(connectors): stop the connector selector implying an option does not exist
The connector selector field ignored the drain state the shared selector hook
already exposes. Paginated selectors fill in the background and the combobox
filters client-side, so a not-yet-drained option is genuinely absent from the
list — and the dropdown said "No spaces found", which reads as "this space does
not exist" and sends users off to enter the value by hand. That is what happened
with a Confluence space on a site with thousands of personal spaces.
It now reports that the list is still filling, surfaces a failed drain instead of
claiming to load forever, and is honest when the drain stops at its page cap.
* feat(connectors): resolve selector options by exact key without waiting on the drain
The connector selector fills by draining pages in the background and filters
client-side, so an option is only findable once its page has arrived. On a large
Confluence site that is ~38 seconds, during which searching for a real space
returned nothing.
Resolves the typed value and the selected value directly through the selector's
`fetchById`, merging both into the option list, so an exact key is selectable
immediately regardless of drain progress. `confluence.spaces.fetchById` now uses
the documented v2 `keys` filter instead of scanning only the first page — which
never resolved a space sorting beyond it.
Adds `onSearchChange` to the shared Combobox so a consumer can observe the search
box, held in a ref so its identity stays stable for the handlers that capture it
without declaring it.
Also fixes a pre-existing hazard in useSelectorOptionDetail: a caller-supplied
`enabled` replaced the guard that checks a definition declares `fetchById`, so
`queryFn`'s non-null assertion would throw for the ~12 selectors without one.
* fix(connectors): paginate the Confluence pages selector instead of returning one page
`/api/tools/confluence/pages` issued a single request and discarded the
`_links.next` cursor Confluence returns, so the picker showed only the first
`limit` pages of however many exist — a search for a real page found nothing,
with no error and no truncation signal.
Threads the documented opaque cursor and moves the selector to `fetchPage`, so
the option list drains like `confluence.spaces` and reports real `hasMore` /
`truncated` state. The `title` server-side filter is unchanged and now paginates
too. `limit` is deliberately left at its existing default: the endpoint's maximum
is not confirmable from Atlassian's published reference, and raising it is not
needed for correctness.
Also guards `data.results`, which threw when the response omitted it.
* fix(connectors): query both space statuses explicitly on exact-key lookup
The exact-key lookup omitted `status`, assuming that matched a space whether it
was current or archived. Atlassian documents a `current,archived` default for
`/pages` but documents no default for `/spaces`, where `status` takes a single
value rather than an array — so the assumption was unverified, and resolving
only current spaces would silently miss archived ones. Archived spaces are
reachable through the paged path and sync works against them.
Queries `current` first and falls back to `archived` only when it finds nothing,
so the common case stays one request and the behaviour no longer depends on an
undocumented default.
* fix(connectors): revert pages drain, restore CloudWatch labels, tighten key lookup
Six adversarial verification passes against the provider spec and the surrounding
plumbing found three defects in the prior commits.
Reverts the Confluence pages selector to a single request. Draining it was not
strictly better: with no search term `title` is unset, so opening the dropdown
walked the entire site — up to 50 sequential requests and 2,500 options where
there had been one request and 50 — and the route forwards no abort signal
upstream, so superseded drains still bill the tenant's rate limit. The same
fan-out reached `loadAllSelectorOptions`, and the justification rested on `title`
semantics Atlassian does not publish. The list cap is a real gap, but it needs
confirmed server-side search, not brute force. Keeps the `results` guard.
Restores selector display names for CloudWatch blocks. Narrowing a caller's
`enabled` against `definition.enabled` disabled a detail query those selectors
satisfy without AWS context, so collapsed blocks rendered "-" instead of the log
group name. A caller that opts in is now narrowed only by the hard precondition
that `fetchById` exists, which is what `queryFn` actually asserts.
Queries both space statuses concurrently rather than sequentially: the key is
user-typed text, so a miss dominates while typing and paid two round-trips. Each
row now falls back to the status its own call requested.
Also drops the "enter the value directly" empty states — the combobox is not
editable, so there is no such affordance — and dedupes `onSearchChange`, which
several reset paths fire redundantly.
* fix(connectors): keep resolved option labels and survive a half-failed key lookup
Addresses three review findings.
A key lookup failed entirely when either status leg errored, discarding a match
the other leg had found. Only a total failure is fatal now.
Resolved option labels are remembered for the lifetime of the field. Both lookups
key on values that change — the search box clears on select and close, and a
multi-select field resolves no id at all — so the label for a just-picked option
vanished a debounce later and the trigger fell back to a raw id. This covers the
multi-select case, which is what the Confluence space field uses.
A failed exact-value lookup now reads differently from a failed list load, rather
than being reported as "still loading" or "none found".
* fix(connectors): drop remembered option labels when the selector context changes
Resolved ids are only meaningful within one selector context, so switching
credential, domain, or a dependency has to discard what was remembered under the
old one — the queries re-key, but the remembered labels would linger and mislabel
until the field remounted.
Keyed on the serialized context rather than its identity: the context memo also
depends on `sourceConfig`, so its identity changes on unrelated field edits and
would clear the cache far more often than intended.
* refactor(connectors): resolve selected option labels with useQueries
Replaces the remembered-label map with per-id queries over the selected values,
following the pattern the knowledge-base selector already uses. The map only ever
held ids searched for in the current session, so a multi-select field restored
from saved config still rendered raw ids — the case that actually matters. It
also needed two effects and a serialized-context key to avoid leaking labels
across a context change, all of which disappear: queries key on the context, so a
label cannot outlive it.
Gates the speculative lookup of typed text on a new `resolvesUnknownIds` flag,
set only where `fetchById` returns null for an id that does not exist. Most
implementations resolve a record by id, so every partial keystroke was a failed
upstream request, retried once, and its error made "could not check that exact
value" the normal empty state on those selectors.
Also: pass handlers straight to the combobox rather than through identity
wrappers that defeated its memo, move the latest-callback ref write into an
effect, rename the raw search setter so the deduping write path cannot be
bypassed, and correct the prop and staleTime docs.1 parent 60f2d03 commit 48d59ca
7 files changed
Lines changed: 335 additions & 56 deletions
File tree
- apps/sim
- app
- api/tools/confluence/selector-spaces
- workspace/[workspaceId]/knowledge/[id]/components/connector-selector-field
- hooks/selectors
- providers/confluence
- lib/api/contracts/selectors
- packages/emcn/src/components/combobox
Lines changed: 84 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
26 | 47 | | |
27 | 48 | | |
28 | 49 | | |
| |||
45 | 66 | | |
46 | 67 | | |
47 | 68 | | |
48 | | - | |
| 69 | + | |
49 | 70 | | |
50 | 71 | | |
51 | 72 | | |
| |||
101 | 122 | | |
102 | 123 | | |
103 | 124 | | |
104 | | - | |
105 | | - | |
106 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
107 | 139 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 140 | + | |
| 141 | + | |
112 | 142 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
118 | 182 | | |
119 | 183 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
127 | 189 | | |
128 | 190 | | |
129 | | - | |
| 191 | + | |
130 | 192 | | |
131 | 193 | | |
132 | 194 | | |
| |||
142 | 204 | | |
143 | 205 | | |
144 | 206 | | |
145 | | - | |
| 207 | + | |
146 | 208 | | |
147 | 209 | | |
148 | 210 | | |
| |||
Lines changed: 98 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
12 | 14 | | |
13 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
14 | 21 | | |
15 | 22 | | |
16 | 23 | | |
| |||
34 | 41 | | |
35 | 42 | | |
36 | 43 | | |
| 44 | + | |
37 | 45 | | |
38 | 46 | | |
39 | 47 | | |
| |||
62 | 70 | | |
63 | 71 | | |
64 | 72 | | |
65 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
66 | 81 | | |
67 | 82 | | |
68 | 83 | | |
69 | 84 | | |
70 | | - | |
71 | | - | |
72 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
73 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
74 | 135 | | |
75 | 136 | | |
76 | 137 | | |
| |||
88 | 149 | | |
89 | 150 | | |
90 | 151 | | |
91 | | - | |
| 152 | + | |
92 | 153 | | |
| 154 | + | |
93 | 155 | | |
94 | 156 | | |
95 | 157 | | |
| |||
99 | 161 | | |
100 | 162 | | |
101 | 163 | | |
102 | | - | |
| 164 | + | |
103 | 165 | | |
104 | 166 | | |
105 | 167 | | |
106 | 168 | | |
107 | | - | |
108 | 169 | | |
109 | 170 | | |
110 | 171 | | |
111 | 172 | | |
112 | | - | |
| 173 | + | |
113 | 174 | | |
| 175 | + | |
114 | 176 | | |
115 | 177 | | |
116 | 178 | | |
| |||
120 | 182 | | |
121 | 183 | | |
122 | 184 | | |
123 | | - | |
| 185 | + | |
124 | 186 | | |
125 | 187 | | |
126 | 188 | | |
127 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
128 | 215 | | |
129 | 216 | | |
130 | 217 | | |
| |||
Lines changed: 16 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
52 | 54 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
90 | 102 | | |
91 | 103 | | |
92 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
139 | 146 | | |
140 | 147 | | |
141 | 148 | | |
0 commit comments