@trops/dash-core 0.1.627 → 0.1.629
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.
- package/dist/electron/index.js +151 -2
- package/dist/electron/index.js.map +1 -1
- package/dist/index.esm.js +118 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +118 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47436,14 +47436,44 @@ var BotDetail = function BotDetail(_ref) {
|
|
|
47436
47436
|
_useState28 = _slicedToArray(_useState27, 2),
|
|
47437
47437
|
schedulePrompt = _useState28[0],
|
|
47438
47438
|
setSchedulePrompt = _useState28[1];
|
|
47439
|
-
|
|
47439
|
+
|
|
47440
|
+
// --- Run-on-events (subscriptions) ---
|
|
47441
|
+
var _useState29 = React.useState(((bot === null || bot === void 0 ? void 0 : bot.subscriptions) || []).map(function (s) {
|
|
47442
|
+
return s && s.eventType;
|
|
47443
|
+
}).filter(Boolean)),
|
|
47440
47444
|
_useState30 = _slicedToArray(_useState29, 2),
|
|
47441
|
-
|
|
47442
|
-
|
|
47443
|
-
var _useState31 = React.useState(
|
|
47445
|
+
subscriptions = _useState30[0],
|
|
47446
|
+
setSubscriptions = _useState30[1];
|
|
47447
|
+
var _useState31 = React.useState(""),
|
|
47444
47448
|
_useState32 = _slicedToArray(_useState31, 2),
|
|
47445
|
-
|
|
47446
|
-
|
|
47449
|
+
newEvent = _useState32[0],
|
|
47450
|
+
setNewEvent = _useState32[1];
|
|
47451
|
+
var _useState33 = React.useState([]),
|
|
47452
|
+
_useState34 = _slicedToArray(_useState33, 2),
|
|
47453
|
+
knownEvents = _useState34[0],
|
|
47454
|
+
setKnownEvents = _useState34[1];
|
|
47455
|
+
var _useState35 = React.useState(false),
|
|
47456
|
+
_useState36 = _slicedToArray(_useState35, 2),
|
|
47457
|
+
saving = _useState36[0],
|
|
47458
|
+
setSaving = _useState36[1];
|
|
47459
|
+
var _useState37 = React.useState(null),
|
|
47460
|
+
_useState38 = _slicedToArray(_useState37, 2),
|
|
47461
|
+
error = _useState38[0],
|
|
47462
|
+
setError = _useState38[1];
|
|
47463
|
+
|
|
47464
|
+
// Discover recently-seen widget event types to suggest as subscriptions.
|
|
47465
|
+
React.useEffect(function () {
|
|
47466
|
+
var _api$widgetEvent;
|
|
47467
|
+
var alive = true;
|
|
47468
|
+
var api = getMainApi();
|
|
47469
|
+
if (!(api !== null && api !== void 0 && (_api$widgetEvent = api.widgetEvent) !== null && _api$widgetEvent !== void 0 && _api$widgetEvent.getLastEvents)) return undefined;
|
|
47470
|
+
Promise.resolve(api.widgetEvent.getLastEvents()).then(function (events) {
|
|
47471
|
+
if (alive && events) setKnownEvents(Object.keys(events).sort());
|
|
47472
|
+
})["catch"](function () {});
|
|
47473
|
+
return function () {
|
|
47474
|
+
alive = false;
|
|
47475
|
+
};
|
|
47476
|
+
}, []);
|
|
47447
47477
|
|
|
47448
47478
|
// Discover the user's connected integrations for the picker.
|
|
47449
47479
|
React.useEffect(function () {
|
|
@@ -47505,6 +47535,26 @@ var BotDetail = function BotDetail(_ref) {
|
|
|
47505
47535
|
}) : [].concat(_toConsumableArray(prev), [serverName]);
|
|
47506
47536
|
});
|
|
47507
47537
|
};
|
|
47538
|
+
var addSubscription = function addSubscription(eventType) {
|
|
47539
|
+
var ev = (eventType || "").trim();
|
|
47540
|
+
if (!ev) return;
|
|
47541
|
+
setSubscriptions(function (prev) {
|
|
47542
|
+
return prev.includes(ev) ? prev : [].concat(_toConsumableArray(prev), [ev]);
|
|
47543
|
+
});
|
|
47544
|
+
setNewEvent("");
|
|
47545
|
+
};
|
|
47546
|
+
var removeSubscription = function removeSubscription(eventType) {
|
|
47547
|
+
setSubscriptions(function (prev) {
|
|
47548
|
+
return prev.filter(function (e) {
|
|
47549
|
+
return e !== eventType;
|
|
47550
|
+
});
|
|
47551
|
+
});
|
|
47552
|
+
};
|
|
47553
|
+
|
|
47554
|
+
// Recently-seen events not already subscribed — offered as one-click adds.
|
|
47555
|
+
var eventSuggestions = knownEvents.filter(function (ev) {
|
|
47556
|
+
return !subscriptions.includes(ev);
|
|
47557
|
+
});
|
|
47508
47558
|
var canSave = name.trim() && instructions.trim() && !saving;
|
|
47509
47559
|
var handleSave = /*#__PURE__*/function () {
|
|
47510
47560
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
@@ -47532,7 +47582,12 @@ var BotDetail = function BotDetail(_ref) {
|
|
|
47532
47582
|
model: model.trim() || null,
|
|
47533
47583
|
approvalPolicy: approvalPolicy,
|
|
47534
47584
|
mcpServers: selectedServers,
|
|
47535
|
-
schedules: schedules
|
|
47585
|
+
schedules: schedules,
|
|
47586
|
+
subscriptions: subscriptions.map(function (eventType) {
|
|
47587
|
+
return {
|
|
47588
|
+
eventType: eventType
|
|
47589
|
+
};
|
|
47590
|
+
})
|
|
47536
47591
|
});
|
|
47537
47592
|
setSaving(true);
|
|
47538
47593
|
_context.prev = 1;
|
|
@@ -47671,6 +47726,62 @@ var BotDetail = function BotDetail(_ref) {
|
|
|
47671
47726
|
className: "text-xs opacity-60 hover:opacity-100 self-start",
|
|
47672
47727
|
children: advanced ? "Use simple schedule" : "Advanced (cron)"
|
|
47673
47728
|
})]
|
|
47729
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
47730
|
+
className: "flex flex-col gap-2",
|
|
47731
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
47732
|
+
className: "text-sm font-medium",
|
|
47733
|
+
children: "Run on events"
|
|
47734
|
+
}), subscriptions.length ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
47735
|
+
className: "flex flex-row flex-wrap gap-2",
|
|
47736
|
+
children: subscriptions.map(function (ev) {
|
|
47737
|
+
return /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
47738
|
+
className: "flex flex-row items-center gap-1 text-xs px-2 py-1 rounded bg-gray-700",
|
|
47739
|
+
children: [ev, /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
47740
|
+
type: "button",
|
|
47741
|
+
onClick: function onClick() {
|
|
47742
|
+
return removeSubscription(ev);
|
|
47743
|
+
},
|
|
47744
|
+
className: "opacity-60 hover:opacity-100",
|
|
47745
|
+
"aria-label": "Remove ".concat(ev),
|
|
47746
|
+
children: "\xD7"
|
|
47747
|
+
})]
|
|
47748
|
+
}, ev);
|
|
47749
|
+
})
|
|
47750
|
+
}) : /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
47751
|
+
className: "text-xs opacity-50",
|
|
47752
|
+
children: "This bot doesn't run on any events yet."
|
|
47753
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
47754
|
+
className: "flex flex-row gap-2",
|
|
47755
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.InputText, {
|
|
47756
|
+
value: newEvent,
|
|
47757
|
+
onChange: setNewEvent,
|
|
47758
|
+
placeholder: "Event name, e.g. pr.opened"
|
|
47759
|
+
}), /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
|
|
47760
|
+
title: "Add",
|
|
47761
|
+
onClick: function onClick() {
|
|
47762
|
+
return addSubscription(newEvent);
|
|
47763
|
+
},
|
|
47764
|
+
size: "sm",
|
|
47765
|
+
disabled: !newEvent.trim()
|
|
47766
|
+
})]
|
|
47767
|
+
}), eventSuggestions.length ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
47768
|
+
className: "flex flex-row flex-wrap gap-1 items-center text-xs opacity-60",
|
|
47769
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
47770
|
+
children: "Recently seen:"
|
|
47771
|
+
}), eventSuggestions.slice(0, 8).map(function (ev) {
|
|
47772
|
+
return /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
47773
|
+
type: "button",
|
|
47774
|
+
onClick: function onClick() {
|
|
47775
|
+
return addSubscription(ev);
|
|
47776
|
+
},
|
|
47777
|
+
className: "underline hover:opacity-100",
|
|
47778
|
+
children: ev
|
|
47779
|
+
}, ev);
|
|
47780
|
+
})]
|
|
47781
|
+
}) : null, /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
47782
|
+
className: "text-xs opacity-50",
|
|
47783
|
+
children: "The bot runs automatically when one of these events fires."
|
|
47784
|
+
})]
|
|
47674
47785
|
}), error ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
47675
47786
|
className: "text-sm text-red-400",
|
|
47676
47787
|
children: error
|