@adecore/agents-react 0.75.0 → 0.76.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.
@@ -424,6 +424,9 @@ function rowsForItems(items, options, children) {
424
424
  }),
425
425
  ...(item.said === undefined ? {} : {
426
426
  said: item.said
427
+ }),
428
+ ...(item.stops === undefined ? {} : {
429
+ stops: item.stops
427
430
  })
428
431
  });
429
432
  }
@@ -0,0 +1 @@
1
+ export declare function useStopTask(chatId: string): (taskId: string) => void;
@@ -0,0 +1,34 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { useTranslation } from 'react-i18next';
3
+ import { useChatHost } from '../host/host.js';
4
+ import { useChatActions } from './actions.js';
5
+ /* Stops a command or monitor a chat runs in the background, and tells the person when the host refused. */
6
+ export function useStopTask(chatId) {
7
+ const $ = _c(5);
8
+ const host = useChatHost();
9
+ const {
10
+ t
11
+ } = useTranslation("agent-chat");
12
+ const actions = useChatActions();
13
+ let t0;
14
+ if ($[0] !== actions || $[1] !== chatId || $[2] !== host || $[3] !== t) {
15
+ t0 = taskId => {
16
+ actions.stopTask(chatId, taskId).catch(error => {
17
+ const description = error instanceof Error ? error.message : t("subagents.noAnswer");
18
+ host.notify({
19
+ kind: "error",
20
+ title: t("activity.stopFailed"),
21
+ description
22
+ });
23
+ });
24
+ };
25
+ $[0] = actions;
26
+ $[1] = chatId;
27
+ $[2] = host;
28
+ $[3] = t;
29
+ $[4] = t0;
30
+ } else {
31
+ t0 = $[4];
32
+ }
33
+ return t0;
34
+ }
@@ -11,8 +11,8 @@ import { useChatHost } from '../../host/host.js';
11
11
  import { useHostTask, useHostTasks } from '../../host/host-hooks.js';
12
12
  import { useChatScope } from '../../scope.js';
13
13
  import { useChatRow, useChats } from '../../state/chats.js';
14
- import { useChatActions } from '../actions.js';
15
14
  import { backgroundCounts, backgroundTaskName, backgroundTaskTime } from '../activity.js';
15
+ import { useStopTask } from '../stop-task.js';
16
16
  import { badgeCountOf, entryTimeOf, flyoutSubagents, progressOf, statusWordOf, subagentTitle, summaryWordOf, taskRowStateOf } from '../subagent-list.js';
17
17
  import { useSubagentSupport } from '../subagent-support.js';
18
18
  import { canOpenSubagent, crumbOf, openFromMain, useSubagentTrail } from '../subagent-view.js';
@@ -852,43 +852,21 @@ function SubagentEntry(t0) {
852
852
  }
853
853
  /* Only drawn while the flyout is open, so the clock ticks for nobody otherwise. */
854
854
  function BackgroundTaskRows(t0) {
855
- const $ = _c(14);
855
+ const $ = _c(9);
856
856
  const {
857
857
  chatId,
858
858
  tasks
859
859
  } = t0;
860
- const host = useChatHost();
861
860
  const {
862
861
  t
863
862
  } = useTranslation("agent-chat");
864
863
  const now = useNow(1000);
865
- const actions = useChatActions();
864
+ const stop = useStopTask(chatId);
866
865
  let t1;
867
- if ($[0] !== actions || $[1] !== chatId || $[2] !== host || $[3] !== t) {
868
- t1 = function stop(taskId) {
869
- actions.stopTask(chatId, taskId).catch(e => {
870
- const description = e instanceof Error ? e.message : t("subagents.noAnswer");
871
- host.notify({
872
- kind: "error",
873
- title: t("activity.stopFailed"),
874
- description
875
- });
876
- });
877
- };
878
- $[0] = actions;
879
- $[1] = chatId;
880
- $[2] = host;
881
- $[3] = t;
882
- $[4] = t1;
883
- } else {
884
- t1 = $[4];
885
- }
886
- const stop = t1;
887
- let t2;
888
- if ($[5] !== now || $[6] !== stop || $[7] !== t || $[8] !== tasks) {
889
- let t3;
890
- if ($[10] !== now || $[11] !== stop || $[12] !== t) {
891
- t3 = task => /*#__PURE__*/_jsx(ActivityRow, {
866
+ if ($[0] !== now || $[1] !== stop || $[2] !== t || $[3] !== tasks) {
867
+ let t2;
868
+ if ($[5] !== now || $[6] !== stop || $[7] !== t) {
869
+ t2 = task => /*#__PURE__*/_jsx(ActivityRow, {
892
870
  icon: /*#__PURE__*/_jsx(Icon, {
893
871
  icon: scheduledWakeupAt(task) !== null ? Clock : task.kind === "shell" ? SquareTerminal : Activity,
894
872
  size: 14,
@@ -905,21 +883,21 @@ function BackgroundTaskRows(t0) {
905
883
  onClick: () => stop(task.id)
906
884
  })
907
885
  }, task.id);
908
- $[10] = now;
909
- $[11] = stop;
910
- $[12] = t;
911
- $[13] = t3;
886
+ $[5] = now;
887
+ $[6] = stop;
888
+ $[7] = t;
889
+ $[8] = t2;
912
890
  } else {
913
- t3 = $[13];
891
+ t2 = $[8];
914
892
  }
915
- t2 = tasks.map(t3);
916
- $[5] = now;
917
- $[6] = stop;
918
- $[7] = t;
919
- $[8] = tasks;
920
- $[9] = t2;
893
+ t1 = tasks.map(t2);
894
+ $[0] = now;
895
+ $[1] = stop;
896
+ $[2] = t;
897
+ $[3] = tasks;
898
+ $[4] = t1;
921
899
  } else {
922
- t2 = $[9];
900
+ t1 = $[4];
923
901
  }
924
- return t2;
902
+ return t1;
925
903
  }