@uipath/apollo-wind 2.95.2 → 2.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/components/forms/aria-ids.cjs +24 -2
  2. package/dist/components/forms/aria-ids.d.ts +15 -0
  3. package/dist/components/forms/aria-ids.js +14 -1
  4. package/dist/components/forms/field-control.cjs +18 -16
  5. package/dist/components/forms/field-control.d.ts +6 -5
  6. package/dist/components/forms/field-control.js +19 -17
  7. package/dist/components/forms/field-renderer.cjs +14 -10
  8. package/dist/components/forms/field-renderer.js +15 -11
  9. package/dist/components/forms/form-schema.d.ts +6 -1
  10. package/dist/components/forms/metadata-form.cjs +8 -3
  11. package/dist/components/forms/metadata-form.js +9 -4
  12. package/dist/components/forms/mode-aware-field.cjs +11 -9
  13. package/dist/components/forms/mode-aware-field.js +12 -10
  14. package/dist/components/forms/string-list-field.cjs +10 -6
  15. package/dist/components/forms/string-list-field.d.ts +1 -1
  16. package/dist/components/forms/string-list-field.js +10 -6
  17. package/dist/components/ui/byo-model-dialog/byo-model-dialog.cjs +340 -212
  18. package/dist/components/ui/byo-model-dialog/byo-model-dialog.js +342 -214
  19. package/dist/components/ui/byo-model-dialog/index.d.ts +1 -1
  20. package/dist/components/ui/byo-model-dialog/labels.cjs +22 -10
  21. package/dist/components/ui/byo-model-dialog/labels.d.ts +19 -5
  22. package/dist/components/ui/byo-model-dialog/labels.js +22 -10
  23. package/dist/components/ui/byo-model-dialog/model-alias-picker.cjs +293 -0
  24. package/dist/components/ui/byo-model-dialog/model-alias-picker.d.ts +24 -0
  25. package/dist/components/ui/byo-model-dialog/model-alias-picker.js +259 -0
  26. package/dist/components/ui/byo-model-dialog/types.d.ts +19 -0
  27. package/dist/components/ui/index.cjs +22 -22
  28. package/dist/index.d.ts +1 -1
  29. package/package.json +1 -1
@@ -31,17 +31,18 @@ const external_lucide_react_namespaceObject = require("lucide-react");
31
31
  const external_react_namespaceObject = require("react");
32
32
  const external_alert_cjs_namespaceObject = require("../alert.cjs");
33
33
  const external_button_cjs_namespaceObject = require("../button.cjs");
34
+ const external_checkbox_cjs_namespaceObject = require("../checkbox.cjs");
34
35
  const external_collapsible_cjs_namespaceObject = require("../collapsible.cjs");
35
36
  const external_command_cjs_namespaceObject = require("../command.cjs");
36
37
  const external_dialog_cjs_namespaceObject = require("../dialog.cjs");
37
38
  const external_input_cjs_namespaceObject = require("../input.cjs");
38
39
  const external_label_cjs_namespaceObject = require("../label.cjs");
39
40
  const external_popover_cjs_namespaceObject = require("../popover.cjs");
40
- const external_radio_group_cjs_namespaceObject = require("../radio-group.cjs");
41
41
  const external_select_cjs_namespaceObject = require("../select.cjs");
42
42
  const external_spinner_cjs_namespaceObject = require("../spinner.cjs");
43
43
  const index_cjs_namespaceObject = require("../../../lib/index.cjs");
44
44
  const external_labels_cjs_namespaceObject = require("./labels.cjs");
45
+ const external_model_alias_picker_cjs_namespaceObject = require("./model-alias-picker.cjs");
45
46
  function ByoModelDialog({ open, onOpenChange, ...rest }) {
46
47
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dialog_cjs_namespaceObject.Dialog, {
47
48
  open: open,
@@ -69,7 +70,7 @@ const NO_MODELS = {
69
70
  }
70
71
  };
71
72
  function defaultConnectionName(providerName, connections) {
72
- const base = `${providerName} – personal`;
73
+ const base = providerName;
73
74
  const taken = new Set(connections.map((c)=>c.name.toLowerCase()));
74
75
  if (!taken.has(base.toLowerCase())) return base;
75
76
  let n = 2;
@@ -87,6 +88,8 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
87
88
  const [editTarget] = external_react_namespaceObject.useState(editing);
88
89
  const generation = external_react_namespaceObject.useRef(0);
89
90
  const formLoad = external_react_namespaceObject.useRef(0);
91
+ const stoppedEdits = external_react_namespaceObject.useRef(new WeakSet());
92
+ const formFolder = external_react_namespaceObject.useRef('');
90
93
  external_react_namespaceObject.useEffect(()=>()=>{
91
94
  generation.current += 1;
92
95
  formLoad.current += 1;
@@ -111,12 +114,14 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
111
114
  status: 'idle'
112
115
  });
113
116
  const [modelsState, setModelsState] = external_react_namespaceObject.useState(NO_MODELS);
117
+ const [changeAgreed, setChangeAgreed] = external_react_namespaceObject.useState(false);
118
+ const [applyingChange, setApplyingChange] = external_react_namespaceObject.useState(false);
114
119
  const [modelId, setModelId] = external_react_namespaceObject.useState('');
115
120
  const [modelQuery, setModelQuery] = external_react_namespaceObject.useState('');
116
121
  const [modelListOpen, setModelListOpen] = external_react_namespaceObject.useState(false);
117
122
  const [name, setName] = external_react_namespaceObject.useState('');
118
- const [nameTouched, setNameTouched] = external_react_namespaceObject.useState(false);
119
- const [useAs, setUseAs] = external_react_namespaceObject.useState('own');
123
+ const [useAs, setUseAs] = external_react_namespaceObject.useState('replacement');
124
+ const [dismissedFailures, setDismissedFailures] = external_react_namespaceObject.useState([]);
120
125
  const [replaces, setReplaces] = external_react_namespaceObject.useState('');
121
126
  const [apiType, setApiType] = external_react_namespaceObject.useState('');
122
127
  const [test, setTest] = external_react_namespaceObject.useState({
@@ -136,11 +141,35 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
136
141
  const connected = Boolean(connection) && !editingConnection;
137
142
  const loadModels = async (pid, conn, gen)=>{
138
143
  if (!conn) return void setModelsState(NO_MODELS);
139
- setModelsState({
140
- ...NO_MODELS,
141
- status: 'loading'
142
- });
144
+ setChangeAgreed(false);
145
+ let cleared = !api.checkConnection;
143
146
  try {
147
+ if (api.checkConnection) {
148
+ setModelsState({
149
+ ...NO_MODELS,
150
+ status: 'checking'
151
+ });
152
+ const checked = await api.checkConnection(pid, conn);
153
+ if (gen !== generation.current) return;
154
+ if (!checked.ok) return void setModelsState({
155
+ ...NO_MODELS,
156
+ status: 'error',
157
+ failure: {
158
+ ...checked.failure
159
+ },
160
+ unchecked: true
161
+ });
162
+ if (checked.value) return void setModelsState({
163
+ ...NO_MODELS,
164
+ status: 'change',
165
+ change: checked.value
166
+ });
167
+ cleared = true;
168
+ }
169
+ setModelsState({
170
+ ...NO_MODELS,
171
+ status: 'loading'
172
+ });
144
173
  const result = await api.listModels(pid, conn);
145
174
  if (gen !== generation.current) return;
146
175
  result.ok ? setModelsState({
@@ -149,17 +178,23 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
149
178
  }) : setModelsState({
150
179
  ...NO_MODELS,
151
180
  status: 'error',
152
- failure: result.failure
181
+ failure: {
182
+ ...result.failure
183
+ }
153
184
  });
154
185
  } catch (err) {
155
186
  if (gen === generation.current) setModelsState({
156
187
  ...NO_MODELS,
157
188
  status: 'error',
158
- failure: unexpected(err)
189
+ failure: unexpected(err),
190
+ ...cleared ? {} : {
191
+ unchecked: true
192
+ }
159
193
  });
160
194
  }
161
195
  };
162
196
  const loadForm = async (pid, folder)=>{
197
+ formFolder.current = folder;
163
198
  formLoad.current += 1;
164
199
  const load = formLoad.current;
165
200
  setFormState({
@@ -195,23 +230,27 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
195
230
  };
196
231
  const startFromSavedModel = (model, loaded, defaultFolder)=>{
197
232
  const gen = generation.current;
198
- const savedConnection = loaded.connections.find((c)=>c.id === model.connectionId) ?? null;
233
+ const ownConnection = loaded.connections.find((c)=>c.id === model.connectionId) ?? null;
234
+ const savedConnection = ownConnection ?? loaded.connections.find((c)=>c.providerId === model.providerId) ?? null;
199
235
  const savedProvider = loaded.providers.find((p)=>p.id === model.providerId);
200
236
  setModelToEdit(model);
201
237
  setProviderId(model.providerId);
202
238
  setConnectionChoice(savedConnection ? savedConnection.id : NEW);
203
239
  setConnName(defaultConnectionName(savedProvider?.name ?? model.providerId, loaded.connections));
204
- setModelId(model.modelId);
240
+ setModelId(ownConnection ? model.modelId : '');
205
241
  setName(model.replaces ? '' : model.name);
206
- setNameTouched(true);
207
242
  setUseAs(model.replaces ? 'replacement' : 'own');
208
243
  setReplaces(model.replaces ?? '');
209
244
  setApiType(model.apiType ?? '');
210
245
  loadModels(model.providerId, savedConnection, gen);
211
246
  loadForm(model.providerId, savedConnection?.folderId ?? defaultFolder);
212
247
  };
248
+ const [contextAttempt, setContextAttempt] = external_react_namespaceObject.useState(0);
213
249
  external_react_namespaceObject.useEffect(()=>{
214
250
  const gen = generation.current;
251
+ setContext({
252
+ status: 'running'
253
+ });
215
254
  const load = async ()=>{
216
255
  const contextResult = await api.loadContext();
217
256
  if (gen !== generation.current) return;
@@ -237,7 +276,6 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
237
276
  });
238
277
  setConnections(loaded.connections);
239
278
  setFolderId(defaultFolder);
240
- if (!loaded.allowsNewNames) setUseAs('replacement');
241
279
  if (savedModel) startFromSavedModel(savedModel, loaded, defaultFolder);
242
280
  };
243
281
  load().catch((err)=>{
@@ -248,14 +286,13 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
248
286
  });
249
287
  }, [
250
288
  api,
251
- editTarget
289
+ editTarget,
290
+ contextAttempt
252
291
  ]);
253
292
  const resetDownstream = ()=>{
254
293
  setModelQuery('');
255
294
  setModelListOpen(false);
256
295
  setModelId('');
257
- setName('');
258
- setNameTouched(false);
259
296
  setTest({
260
297
  status: 'idle'
261
298
  });
@@ -275,12 +312,25 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
275
312
  status: 'idle'
276
313
  });
277
314
  resetDownstream();
278
- setUseAs(ctx?.allowsNewNames === false ? 'replacement' : 'own');
279
- setReplaces('');
280
315
  setApiType('');
281
316
  loadModels(id, existing[0] ?? null, gen);
282
317
  loadForm(id, folderId);
283
318
  };
319
+ const clearProvider = ()=>{
320
+ generation.current += 1;
321
+ formLoad.current += 1;
322
+ setProviderId('');
323
+ setConnectionChoice(NEW);
324
+ setMoreOpen(false);
325
+ setEditingConnection(false);
326
+ setConnect({
327
+ status: 'idle'
328
+ });
329
+ resetDownstream();
330
+ setApiType('');
331
+ setModelsState(NO_MODELS);
332
+ setFormState(NO_FORM);
333
+ };
284
334
  const chooseConnection = (id)=>{
285
335
  generation.current += 1;
286
336
  setConnectionChoice(id);
@@ -296,9 +346,13 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
296
346
  const failConnectionEdit = (failure)=>{
297
347
  setEditingConnection(false);
298
348
  resetFormValues();
349
+ const stopped = {
350
+ ...failure
351
+ };
352
+ stoppedEdits.current.add(stopped);
299
353
  setConnect({
300
354
  status: 'error',
301
- failure
355
+ failure: stopped
302
356
  });
303
357
  loadModels(providerId, connection, generation.current);
304
358
  };
@@ -334,6 +388,46 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
334
388
  if (gen === generation.current) setLoadingConnectionValues(false);
335
389
  }
336
390
  };
391
+ const applyChange = async ()=>{
392
+ if (!connection || !api.applyConnectionChange || 'change' !== modelsState.status) return;
393
+ const gen = generation.current;
394
+ const pending = modelsState;
395
+ setApplyingChange(true);
396
+ try {
397
+ const result = await api.applyConnectionChange(providerId, connection);
398
+ if (gen !== generation.current) return;
399
+ if (!result.ok) {
400
+ setChangeAgreed(false);
401
+ setModelsState(result.failure.final ? {
402
+ ...NO_MODELS,
403
+ status: 'error',
404
+ failure: {
405
+ ...result.failure
406
+ },
407
+ unchecked: true
408
+ } : {
409
+ ...pending,
410
+ failure: {
411
+ ...result.failure
412
+ }
413
+ });
414
+ return;
415
+ }
416
+ const switched = result.value;
417
+ setConnections((prev)=>prev.map((c)=>c.id === switched.id ? switched : c));
418
+ loadModels(providerId, switched, gen);
419
+ } catch (err) {
420
+ if (gen === generation.current) {
421
+ setChangeAgreed(false);
422
+ setModelsState({
423
+ ...pending,
424
+ failure: unexpected(err)
425
+ });
426
+ }
427
+ } finally{
428
+ setApplyingChange(false);
429
+ }
430
+ };
337
431
  const cancelConnectionEdit = ()=>{
338
432
  generation.current += 1;
339
433
  setEditingConnection(false);
@@ -392,7 +486,9 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
392
486
  if (gen !== generation.current) return;
393
487
  if (!result.ok) return void setConnect({
394
488
  status: 'error',
395
- failure: result.failure
489
+ failure: {
490
+ ...result.failure
491
+ }
396
492
  });
397
493
  const saved = result.value;
398
494
  existing ? setConnections((prev)=>prev.map((c)=>c.id === saved.id ? saved : c)) : setConnections((prev)=>[
@@ -413,7 +509,6 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
413
509
  };
414
510
  const pickModel = (id)=>{
415
511
  setModelId(id);
416
- if (!nameTouched) setName(id);
417
512
  setTest({
418
513
  status: 'idle'
419
514
  });
@@ -425,27 +520,56 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
425
520
  let nameProblem = null;
426
521
  if (ownName && takenNames.has(ownName.toLowerCase())) nameProblem = labels.nameTaken(ownName);
427
522
  else if (ownName && reservedNames.has(ownName.toLowerCase())) nameProblem = labels.nameReserved(ownName);
428
- const replacementOptions = (ctx?.replaceableModels ?? []).filter((m)=>(!m.replaced || m.name === modelToEdit?.replaces) && Boolean(provider) && api.apiTypes(providerId, m.name).length > 0);
523
+ const replacementOptions = (ctx?.replaceableModels ?? []).filter((m)=>(!m.replaced || m.name === modelToEdit?.replaces) && providers.some((p)=>api.apiTypes(p.id, m.name).length > 0));
429
524
  const canUseOwnName = ctx?.allowsNewNames ?? false;
430
525
  const replacing = 'replacement' === useAs;
431
526
  const replacement = replacementOptions.find((m)=>m.name === replaces) ?? null;
432
527
  const chosenName = replacing ? replacement?.name ?? '' : ownName;
433
528
  const nameReady = replacing ? Boolean(replacement) : Boolean(ownName) && !nameProblem;
434
- const apiTypeOptions = provider && (!replacing || replacement) ? api.apiTypes(providerId, replacing ? replacement?.name ?? null : null) : [];
529
+ let alias = null;
530
+ if (replacing && replacement) alias = {
531
+ kind: 'replacement',
532
+ name: replacement.name
533
+ };
534
+ else if (!replacing && ownName) alias = {
535
+ kind: 'custom',
536
+ name: ownName
537
+ };
538
+ const apiTypesFor = (pid, a)=>api.apiTypes(pid, a?.kind === 'replacement' ? a.name : null);
539
+ const providerOptions = providers.filter((p)=>apiTypesFor(p.id, alias).length > 0);
540
+ const chooseAlias = (next)=>{
541
+ if ('replacement' === next.kind) {
542
+ setUseAs('replacement');
543
+ setReplaces(next.name);
544
+ } else {
545
+ setUseAs('own');
546
+ setName(next.name);
547
+ }
548
+ setTest({
549
+ status: 'idle'
550
+ });
551
+ if (providerId && 0 === apiTypesFor(providerId, next).length) clearProvider();
552
+ };
553
+ const apiTypeOptions = provider && alias ? apiTypesFor(providerId, alias) : [];
435
554
  const apiTypeKey = apiTypeOptions.map((t)=>t.value).join('|');
436
555
  external_react_namespaceObject.useEffect(()=>{
437
- if (apiTypeOptions.some((t)=>t.value === apiType)) return;
438
- const first = apiTypeOptions[0]?.value ?? '';
439
- setApiType(replacing || 1 === apiTypeOptions.length ? first : '');
556
+ const saved = modelToEdit?.apiType;
557
+ const next = saved && apiTypeOptions.some((o)=>o.value === saved) ? saved : apiTypeOptions[0]?.value ?? '';
558
+ if (apiType !== next) setApiType(next);
440
559
  }, [
441
560
  apiTypeKey,
442
- replacing,
443
- apiType
561
+ apiType,
562
+ modelToEdit
444
563
  ]);
445
564
  const apiTypeReady = apiTypeOptions.some((t)=>t.value === apiType);
446
565
  const busy = keyLocked || 'running' === test.status || 'ok' === test.status;
447
566
  const hasModel = Boolean(modelId.trim());
448
- const readyToSave = connected && hasModel && nameReady && apiTypeReady;
567
+ const connectionCleared = 'checking' !== modelsState.status && 'change' !== modelsState.status && !modelsState.unchecked;
568
+ const providerOpen = nameReady;
569
+ const providerDone = providerOpen && Boolean(provider);
570
+ const connectionDone = providerDone && connected && connectionCleared;
571
+ const modelDone = connectionDone && hasModel;
572
+ const readyToSave = modelDone && apiTypeReady;
449
573
  const runTest = async ()=>{
450
574
  if (!connection || !readyToSave || busy) return;
451
575
  const gen = generation.current;
@@ -473,7 +597,9 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
473
597
  if (!result.ok) {
474
598
  if (stillOpen) setTest({
475
599
  status: 'error',
476
- failure: result.failure
600
+ failure: {
601
+ ...result.failure
602
+ }
477
603
  });
478
604
  return;
479
605
  }
@@ -503,7 +629,7 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
503
629
  hint: keepsCurrentValue(f) ? labels.secretKeepHint : f.hint,
504
630
  required: isRequired(f),
505
631
  children: f.options?.length ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
506
- value: values[f.key] || void 0,
632
+ value: values[f.key] ?? '',
507
633
  onValueChange: (v)=>setValue(f.key, v),
508
634
  disabled: keyLocked,
509
635
  children: [
@@ -541,6 +667,8 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
541
667
  }, f.key);
542
668
  const modelTriggerText = (()=>{
543
669
  if (!connected) return labels.modelNeedsConnection(providerName);
670
+ if ('checking' === modelsState.status) return labels.checkingConnection;
671
+ if ('change' === modelsState.status) return labels.modelNeedsConnection(providerName);
544
672
  if ('loading' === modelsState.status) return labels.modelsLoading(providerName);
545
673
  if ('error' === modelsState.status) return labels.modelsFailed(providerName);
546
674
  return labels.modelSelect(models.compatible.length);
@@ -551,10 +679,37 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
551
679
  if (connectOutcome.updated) return labels.connectionUpdated;
552
680
  return labels.connectedIn(folderLabel(connectOutcome.connection.folderId));
553
681
  })();
554
- let failure = null;
555
- if ('error' === connect.status) failure = connect.failure;
556
- else if ('error' === test.status) failure = test.failure;
557
- else if ('error' === modelsState.status) failure = modelsState.failure ?? null;
682
+ const modelsFailure = 'error' === modelsState.status ? modelsState.failure ?? null : null;
683
+ const failureHint = (f)=>{
684
+ if (f.final) return;
685
+ if ('error' === connect.status && f === connect.failure) {
686
+ if (stoppedEdits.current.has(f)) return;
687
+ return labels.retryConnect(editingConnection ? labels.saveConnection : labels.connect);
688
+ }
689
+ if ('error' === test.status && f === test.failure) return labels.retryTest(saveLabel);
690
+ if ('change' === modelsState.status && f === modelsState.failure) return labels.retrySwitch;
691
+ };
692
+ const failure = [
693
+ 'error' === connect.status ? connect.failure : null,
694
+ 'error' === test.status ? test.failure : null,
695
+ 'error' === modelsState.status || 'change' === modelsState.status ? modelsState.failure ?? null : null
696
+ ].find((f)=>f && !dismissedFailures.includes(f)) ?? null;
697
+ let aliasHint = {
698
+ text: labels.nameHint,
699
+ tone: 'text-foreground-muted'
700
+ };
701
+ if (replacing && replacement?.retiresOn) aliasHint = {
702
+ text: labels.retiresOn(replacement.retiresOn),
703
+ tone: 'text-warning'
704
+ };
705
+ else if (replacing && replacement) aliasHint = {
706
+ text: labels.replacementHint,
707
+ tone: 'text-foreground-muted'
708
+ };
709
+ else if (!replacing && nameProblem) aliasHint = {
710
+ text: nameProblem,
711
+ tone: 'text-error'
712
+ };
558
713
  const title = editTarget ? labels.editTitle : labels.title;
559
714
  const description = editTarget ? labels.editDescription : labels.description;
560
715
  const saveLabel = editTarget ? labels.testAndSave : labels.testAndAdd;
@@ -592,16 +747,42 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
592
747
  }),
593
748
  'error' === context.status && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FailureAlert, {
594
749
  failure: context.failure,
595
- labels: labels
750
+ labels: labels,
751
+ onRetry: ()=>setContextAttempt((n)=>n + 1)
596
752
  }),
597
753
  ctx && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
598
754
  children: [
599
755
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Step, {
600
756
  n: 1,
757
+ title: labels.nameStep,
758
+ done: nameReady,
759
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
760
+ className: "flex flex-col gap-1.5",
761
+ children: [
762
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_model_alias_picker_cjs_namespaceObject.ModelAliasPicker, {
763
+ replaceable: replacementOptions,
764
+ allowsCustom: canUseOwnName,
765
+ value: alias,
766
+ onChange: chooseAlias,
767
+ disabled: busy,
768
+ invalid: Boolean(nameProblem) && !replacing,
769
+ container: container,
770
+ labels: labels
771
+ }),
772
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
773
+ className: (0, index_cjs_namespaceObject.cn)('text-xs', aliasHint.tone),
774
+ children: aliasHint.text
775
+ })
776
+ ]
777
+ })
778
+ }),
779
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Step, {
780
+ n: 2,
601
781
  title: labels.providerStep,
602
- done: Boolean(provider),
782
+ done: providerDone,
783
+ disabled: !providerOpen,
603
784
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
604
- value: providerId || void 0,
785
+ value: providerId,
605
786
  onValueChange: chooseProvider,
606
787
  disabled: busy,
607
788
  children: [
@@ -614,7 +795,7 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
614
795
  }),
615
796
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
616
797
  container: container,
617
- children: providers.map((p)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
798
+ children: providerOptions.map((p)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
618
799
  value: p.id,
619
800
  children: p.name
620
801
  }, p.id))
@@ -623,10 +804,10 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
623
804
  })
624
805
  }),
625
806
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Step, {
626
- n: 2,
807
+ n: 3,
627
808
  title: labels.connectionStep,
628
- done: connected,
629
- disabled: !provider,
809
+ done: connectionDone,
810
+ disabled: !providerDone,
630
811
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
631
812
  className: "flex flex-col gap-3",
632
813
  children: [
@@ -670,7 +851,17 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
670
851
  connectMessage
671
852
  ]
672
853
  }),
673
- connection && !editingConnection && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
854
+ connection && !editingConnection && 'change' === modelsState.status && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ConnectionChangeNotice, {
855
+ change: modelsState.change,
856
+ agreed: changeAgreed,
857
+ applying: applyingChange,
858
+ disabled: busy,
859
+ labels: labels,
860
+ onAgreedChange: setChangeAgreed,
861
+ onApply: applyChange,
862
+ onSeparate: ()=>chooseConnection(NEW)
863
+ }),
864
+ connection && !editingConnection && connectionCleared && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
674
865
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
675
866
  variant: "link",
676
867
  size: "2xs",
@@ -680,6 +871,11 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
680
871
  children: labels.editConnection
681
872
  })
682
873
  }),
874
+ connection && !showConnectionForm && 'error' === formState.status && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FailureAlert, {
875
+ failure: formState.failure,
876
+ labels: labels,
877
+ onRetry: ()=>loadForm(providerId, formFolder.current)
878
+ }),
683
879
  showConnectionForm && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
684
880
  children: [
685
881
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(Group, {
@@ -699,7 +895,8 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
699
895
  }),
700
896
  'error' === formState.status && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FailureAlert, {
701
897
  failure: formState.failure,
702
- labels: labels
898
+ labels: labels,
899
+ onRetry: ()=>loadForm(providerId, formFolder.current)
703
900
  }),
704
901
  loadingConnectionValues && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
705
902
  className: "flex items-center gap-2 text-xs text-foreground-muted",
@@ -787,7 +984,7 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
787
984
  id: "byo-folder",
788
985
  label: labels.folder,
789
986
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
790
- value: formFolderId || void 0,
987
+ value: formFolderId,
791
988
  onValueChange: setFolderId,
792
989
  disabled: keyLocked || editingConnection,
793
990
  children: [
@@ -843,10 +1040,10 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
843
1040
  })
844
1041
  }),
845
1042
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Step, {
846
- n: 3,
1043
+ n: 4,
847
1044
  title: labels.modelStep,
848
- done: hasModel,
849
- disabled: !connected,
1045
+ done: modelDone,
1046
+ disabled: !connectionDone,
850
1047
  children: freeTextModel ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_cjs_namespaceObject.Input, {
851
1048
  ref: modelTriggerRef,
852
1049
  "aria-label": labels.modelIdLabel,
@@ -911,7 +1108,7 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
911
1108
  children: labels.modelNoMatch(modelQuery)
912
1109
  }),
913
1110
  shownCompatible.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandGroup, {
914
- heading: labels.compatibleGroup(shownCompatible.length),
1111
+ heading: models.incompatible.length > 0 ? labels.compatibleGroup(shownCompatible.length) : void 0,
915
1112
  children: shownCompatible.map((m)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ModelRow, {
916
1113
  model: m,
917
1114
  selected: m.id === modelId,
@@ -936,165 +1133,6 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
936
1133
  })
937
1134
  ]
938
1135
  })
939
- }),
940
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Step, {
941
- n: 4,
942
- title: labels.nameStep,
943
- done: hasModel && nameReady,
944
- disabled: !hasModel,
945
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
946
- className: "flex flex-col gap-3",
947
- children: [
948
- canUseOwnName && replacementOptions.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_radio_group_cjs_namespaceObject.RadioGroup, {
949
- value: useAs,
950
- onValueChange: (v)=>{
951
- setUseAs(v);
952
- setTest({
953
- status: 'idle'
954
- });
955
- },
956
- disabled: busy,
957
- "aria-label": labels.nameStep,
958
- className: "flex flex-wrap gap-4",
959
- children: [
960
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
961
- className: "flex items-center gap-2",
962
- children: [
963
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_radio_group_cjs_namespaceObject.RadioGroupItem, {
964
- value: "own",
965
- id: "byo-use-own"
966
- }),
967
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_label_cjs_namespaceObject.Label, {
968
- htmlFor: "byo-use-own",
969
- className: "text-xs font-normal",
970
- children: labels.useOwnName
971
- })
972
- ]
973
- }),
974
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
975
- className: "flex items-center gap-2",
976
- children: [
977
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_radio_group_cjs_namespaceObject.RadioGroupItem, {
978
- value: "replacement",
979
- id: "byo-use-replacement"
980
- }),
981
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_label_cjs_namespaceObject.Label, {
982
- htmlFor: "byo-use-replacement",
983
- className: "text-xs font-normal",
984
- children: labels.useReplacement
985
- })
986
- ]
987
- })
988
- ]
989
- }),
990
- replacing ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
991
- className: "flex flex-col gap-1.5",
992
- children: [
993
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
994
- value: replacement?.name,
995
- onValueChange: (v)=>{
996
- setReplaces(v);
997
- setTest({
998
- status: 'idle'
999
- });
1000
- },
1001
- disabled: busy,
1002
- children: [
1003
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
1004
- className: "w-full",
1005
- "aria-label": labels.useReplacement,
1006
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {
1007
- placeholder: labels.replacementPlaceholder
1008
- })
1009
- }),
1010
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
1011
- container: container,
1012
- children: replacementOptions.map((m)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.SelectItem, {
1013
- value: m.name,
1014
- children: [
1015
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1016
- className: "font-mono text-xs",
1017
- children: m.name
1018
- }),
1019
- m.retiresOn && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1020
- className: "ml-2 text-xs text-foreground-muted",
1021
- children: labels.deprecated
1022
- })
1023
- ]
1024
- }, m.name))
1025
- })
1026
- ]
1027
- }),
1028
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
1029
- className: (0, index_cjs_namespaceObject.cn)('text-xs', replacement?.retiresOn ? 'text-warning' : 'text-foreground-muted'),
1030
- children: replacement?.retiresOn ? labels.retiresOn(replacement.retiresOn) : labels.replacementHint
1031
- })
1032
- ]
1033
- }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1034
- className: "flex flex-col gap-1.5",
1035
- children: [
1036
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_cjs_namespaceObject.Input, {
1037
- "aria-label": labels.nameStep,
1038
- value: name,
1039
- disabled: busy,
1040
- onChange: (e)=>{
1041
- setName(e.target.value);
1042
- setNameTouched(true);
1043
- setTest({
1044
- status: 'idle'
1045
- });
1046
- },
1047
- "aria-invalid": Boolean(nameProblem)
1048
- }),
1049
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
1050
- className: (0, index_cjs_namespaceObject.cn)('text-xs', nameProblem ? 'text-error' : 'text-foreground-muted'),
1051
- children: nameProblem ?? labels.nameHint
1052
- })
1053
- ]
1054
- })
1055
- ]
1056
- })
1057
- }),
1058
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Step, {
1059
- n: 5,
1060
- title: labels.apiTypeStep,
1061
- done: readyToSave,
1062
- disabled: !hasModel || !nameReady,
1063
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1064
- className: "flex flex-col gap-1.5",
1065
- children: [
1066
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
1067
- value: apiTypeReady ? apiType : void 0,
1068
- onValueChange: (v)=>{
1069
- setApiType(v);
1070
- setTest({
1071
- status: 'idle'
1072
- });
1073
- },
1074
- disabled: busy || 0 === apiTypeOptions.length,
1075
- children: [
1076
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
1077
- className: "w-full",
1078
- "aria-label": labels.apiTypeStep,
1079
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {
1080
- placeholder: labels.apiTypePlaceholder
1081
- })
1082
- }),
1083
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
1084
- container: container,
1085
- children: apiTypeOptions.map((t)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
1086
- value: t.value,
1087
- children: t.label
1088
- }, t.value))
1089
- })
1090
- ]
1091
- }),
1092
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
1093
- className: "text-xs text-foreground-muted",
1094
- children: hasModel && nameReady && 0 === apiTypeOptions.length ? labels.apiTypeNone(providerName) : labels.apiTypeHint
1095
- })
1096
- ]
1097
- })
1098
1136
  })
1099
1137
  ]
1100
1138
  })
@@ -1104,7 +1142,13 @@ function DialogBody({ api: apiProp, onSaved, editing, labels: labelOverrides, co
1104
1142
  className: "max-h-[40%] shrink-0 overflow-y-auto border-t border-border-subtle px-6 py-3",
1105
1143
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FailureAlert, {
1106
1144
  failure: failure,
1107
- labels: labels
1145
+ labels: labels,
1146
+ onDismiss: ()=>setDismissedFailures((prev)=>[
1147
+ ...prev,
1148
+ failure
1149
+ ]),
1150
+ onRetry: failure === modelsFailure && connection && !busy ? ()=>loadModels(providerId, connection, generation.current) : void 0,
1151
+ hint: failureHint(failure)
1108
1152
  })
1109
1153
  }),
1110
1154
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dialog_cjs_namespaceObject.DialogFooter, {
@@ -1232,12 +1276,83 @@ function Field({ id, label, hint, required, children }) {
1232
1276
  ]
1233
1277
  });
1234
1278
  }
1235
- function FailureAlert({ failure, labels }) {
1279
+ function ConnectionChangeNotice({ change, agreed, applying, disabled, labels, onAgreedChange, onApply, onSeparate }) {
1280
+ const id = external_react_namespaceObject.useId();
1281
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_alert_cjs_namespaceObject.Alert, {
1282
+ variant: "warning",
1283
+ className: "min-w-0",
1284
+ children: [
1285
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.TriangleAlert, {}),
1286
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_cjs_namespaceObject.AlertTitle, {
1287
+ children: change.title
1288
+ }),
1289
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_alert_cjs_namespaceObject.AlertDescription, {
1290
+ className: "flex flex-col gap-3 break-words",
1291
+ children: [
1292
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
1293
+ children: change.message
1294
+ }),
1295
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1296
+ className: "flex items-start gap-2",
1297
+ children: [
1298
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_checkbox_cjs_namespaceObject.Checkbox, {
1299
+ id: id,
1300
+ checked: agreed,
1301
+ disabled: disabled || applying,
1302
+ onCheckedChange: (v)=>onAgreedChange(true === v),
1303
+ className: "mt-0.5"
1304
+ }),
1305
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_label_cjs_namespaceObject.Label, {
1306
+ htmlFor: id,
1307
+ className: "text-xs font-normal leading-4",
1308
+ children: change.agreement
1309
+ })
1310
+ ]
1311
+ }),
1312
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
1313
+ className: "flex flex-wrap items-center gap-3",
1314
+ children: [
1315
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
1316
+ size: "2xs",
1317
+ disabled: !agreed || disabled || applying,
1318
+ onClick: onApply,
1319
+ children: [
1320
+ applying && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_spinner_cjs_namespaceObject.Spinner, {
1321
+ size: "sm"
1322
+ }),
1323
+ applying ? labels.applyingChange : labels.applyChange
1324
+ ]
1325
+ }),
1326
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
1327
+ variant: "link",
1328
+ size: "2xs",
1329
+ className: "h-auto p-0 text-xs",
1330
+ disabled: disabled || applying,
1331
+ onClick: onSeparate,
1332
+ children: labels.separateConnection
1333
+ })
1334
+ ]
1335
+ })
1336
+ ]
1337
+ })
1338
+ ]
1339
+ });
1340
+ }
1341
+ function FailureAlert({ failure, labels, onDismiss, onRetry, hint }) {
1236
1342
  const [showRaw, setShowRaw] = external_react_namespaceObject.useState(false);
1237
1343
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_alert_cjs_namespaceObject.Alert, {
1238
1344
  variant: "destructive",
1239
- className: "min-w-0",
1345
+ className: (0, index_cjs_namespaceObject.cn)('min-w-0', onDismiss && 'pr-9'),
1240
1346
  children: [
1347
+ onDismiss && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
1348
+ variant: "ghost",
1349
+ size: "3xs",
1350
+ icon: true,
1351
+ className: "absolute top-2 right-2",
1352
+ "aria-label": labels.dismiss,
1353
+ onClick: onDismiss,
1354
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.X, {})
1355
+ }),
1241
1356
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.AlertCircle, {}),
1242
1357
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_cjs_namespaceObject.AlertTitle, {
1243
1358
  children: failure.title
@@ -1261,6 +1376,19 @@ function FailureAlert({ failure, labels }) {
1261
1376
  !failure.detail && failure.message && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_cjs_namespaceObject.AlertDescription, {
1262
1377
  className: "break-words",
1263
1378
  children: failure.message
1379
+ }),
1380
+ hint && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_cjs_namespaceObject.AlertDescription, {
1381
+ className: "text-foreground-muted",
1382
+ children: hint
1383
+ }),
1384
+ onRetry && !failure.final && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_alert_cjs_namespaceObject.AlertDescription, {
1385
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
1386
+ variant: "link",
1387
+ size: "2xs",
1388
+ className: "mt-1 h-auto p-0 text-xs",
1389
+ onClick: onRetry,
1390
+ children: labels.tryAgain
1391
+ })
1264
1392
  })
1265
1393
  ]
1266
1394
  });