@trops/dash-core 0.1.628 → 0.1.630

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/index.esm.js CHANGED
@@ -47418,14 +47418,44 @@ var BotDetail = function BotDetail(_ref) {
47418
47418
  _useState28 = _slicedToArray(_useState27, 2),
47419
47419
  schedulePrompt = _useState28[0],
47420
47420
  setSchedulePrompt = _useState28[1];
47421
- var _useState29 = useState(false),
47421
+
47422
+ // --- Run-on-events (subscriptions) ---
47423
+ var _useState29 = useState(((bot === null || bot === void 0 ? void 0 : bot.subscriptions) || []).map(function (s) {
47424
+ return s && s.eventType;
47425
+ }).filter(Boolean)),
47422
47426
  _useState30 = _slicedToArray(_useState29, 2),
47423
- saving = _useState30[0],
47424
- setSaving = _useState30[1];
47425
- var _useState31 = useState(null),
47427
+ subscriptions = _useState30[0],
47428
+ setSubscriptions = _useState30[1];
47429
+ var _useState31 = useState(""),
47426
47430
  _useState32 = _slicedToArray(_useState31, 2),
47427
- error = _useState32[0],
47428
- setError = _useState32[1];
47431
+ newEvent = _useState32[0],
47432
+ setNewEvent = _useState32[1];
47433
+ var _useState33 = useState([]),
47434
+ _useState34 = _slicedToArray(_useState33, 2),
47435
+ knownEvents = _useState34[0],
47436
+ setKnownEvents = _useState34[1];
47437
+ var _useState35 = useState(false),
47438
+ _useState36 = _slicedToArray(_useState35, 2),
47439
+ saving = _useState36[0],
47440
+ setSaving = _useState36[1];
47441
+ var _useState37 = useState(null),
47442
+ _useState38 = _slicedToArray(_useState37, 2),
47443
+ error = _useState38[0],
47444
+ setError = _useState38[1];
47445
+
47446
+ // Discover recently-seen widget event types to suggest as subscriptions.
47447
+ useEffect(function () {
47448
+ var _api$widgetEvent;
47449
+ var alive = true;
47450
+ var api = getMainApi();
47451
+ if (!(api !== null && api !== void 0 && (_api$widgetEvent = api.widgetEvent) !== null && _api$widgetEvent !== void 0 && _api$widgetEvent.getLastEvents)) return undefined;
47452
+ Promise.resolve(api.widgetEvent.getLastEvents()).then(function (events) {
47453
+ if (alive && events) setKnownEvents(Object.keys(events).sort());
47454
+ })["catch"](function () {});
47455
+ return function () {
47456
+ alive = false;
47457
+ };
47458
+ }, []);
47429
47459
 
47430
47460
  // Discover the user's connected integrations for the picker.
47431
47461
  useEffect(function () {
@@ -47487,6 +47517,26 @@ var BotDetail = function BotDetail(_ref) {
47487
47517
  }) : [].concat(_toConsumableArray(prev), [serverName]);
47488
47518
  });
47489
47519
  };
47520
+ var addSubscription = function addSubscription(eventType) {
47521
+ var ev = (eventType || "").trim();
47522
+ if (!ev) return;
47523
+ setSubscriptions(function (prev) {
47524
+ return prev.includes(ev) ? prev : [].concat(_toConsumableArray(prev), [ev]);
47525
+ });
47526
+ setNewEvent("");
47527
+ };
47528
+ var removeSubscription = function removeSubscription(eventType) {
47529
+ setSubscriptions(function (prev) {
47530
+ return prev.filter(function (e) {
47531
+ return e !== eventType;
47532
+ });
47533
+ });
47534
+ };
47535
+
47536
+ // Recently-seen events not already subscribed — offered as one-click adds.
47537
+ var eventSuggestions = knownEvents.filter(function (ev) {
47538
+ return !subscriptions.includes(ev);
47539
+ });
47490
47540
  var canSave = name.trim() && instructions.trim() && !saving;
47491
47541
  var handleSave = /*#__PURE__*/function () {
47492
47542
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
@@ -47514,7 +47564,12 @@ var BotDetail = function BotDetail(_ref) {
47514
47564
  model: model.trim() || null,
47515
47565
  approvalPolicy: approvalPolicy,
47516
47566
  mcpServers: selectedServers,
47517
- schedules: schedules
47567
+ schedules: schedules,
47568
+ subscriptions: subscriptions.map(function (eventType) {
47569
+ return {
47570
+ eventType: eventType
47571
+ };
47572
+ })
47518
47573
  });
47519
47574
  setSaving(true);
47520
47575
  _context.prev = 1;
@@ -47653,6 +47708,62 @@ var BotDetail = function BotDetail(_ref) {
47653
47708
  className: "text-xs opacity-60 hover:opacity-100 self-start",
47654
47709
  children: advanced ? "Use simple schedule" : "Advanced (cron)"
47655
47710
  })]
47711
+ }), /*#__PURE__*/jsxs("div", {
47712
+ className: "flex flex-col gap-2",
47713
+ children: [/*#__PURE__*/jsx("span", {
47714
+ className: "text-sm font-medium",
47715
+ children: "Run on events"
47716
+ }), subscriptions.length ? /*#__PURE__*/jsx("div", {
47717
+ className: "flex flex-row flex-wrap gap-2",
47718
+ children: subscriptions.map(function (ev) {
47719
+ return /*#__PURE__*/jsxs("span", {
47720
+ className: "flex flex-row items-center gap-1 text-xs px-2 py-1 rounded bg-gray-700",
47721
+ children: [ev, /*#__PURE__*/jsx("button", {
47722
+ type: "button",
47723
+ onClick: function onClick() {
47724
+ return removeSubscription(ev);
47725
+ },
47726
+ className: "opacity-60 hover:opacity-100",
47727
+ "aria-label": "Remove ".concat(ev),
47728
+ children: "\xD7"
47729
+ })]
47730
+ }, ev);
47731
+ })
47732
+ }) : /*#__PURE__*/jsx("span", {
47733
+ className: "text-xs opacity-50",
47734
+ children: "This bot doesn't run on any events yet."
47735
+ }), /*#__PURE__*/jsxs("div", {
47736
+ className: "flex flex-row gap-2",
47737
+ children: [/*#__PURE__*/jsx(InputText, {
47738
+ value: newEvent,
47739
+ onChange: setNewEvent,
47740
+ placeholder: "Event name, e.g. pr.opened"
47741
+ }), /*#__PURE__*/jsx(Button, {
47742
+ title: "Add",
47743
+ onClick: function onClick() {
47744
+ return addSubscription(newEvent);
47745
+ },
47746
+ size: "sm",
47747
+ disabled: !newEvent.trim()
47748
+ })]
47749
+ }), eventSuggestions.length ? /*#__PURE__*/jsxs("div", {
47750
+ className: "flex flex-row flex-wrap gap-1 items-center text-xs opacity-60",
47751
+ children: [/*#__PURE__*/jsx("span", {
47752
+ children: "Recently seen:"
47753
+ }), eventSuggestions.slice(0, 8).map(function (ev) {
47754
+ return /*#__PURE__*/jsx("button", {
47755
+ type: "button",
47756
+ onClick: function onClick() {
47757
+ return addSubscription(ev);
47758
+ },
47759
+ className: "underline hover:opacity-100",
47760
+ children: ev
47761
+ }, ev);
47762
+ })]
47763
+ }) : null, /*#__PURE__*/jsx("span", {
47764
+ className: "text-xs opacity-50",
47765
+ children: "The bot runs automatically when one of these events fires."
47766
+ })]
47656
47767
  }), error ? /*#__PURE__*/jsx("span", {
47657
47768
  className: "text-sm text-red-400",
47658
47769
  children: error