@stigmer/react 3.7.0 → 3.9.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 (219) hide show
  1. package/attachment/AttachmentChipList.d.ts.map +1 -1
  2. package/attachment/AttachmentChipList.js +30 -1
  3. package/attachment/AttachmentChipList.js.map +1 -1
  4. package/attachment/attachment-utils.d.ts +11 -0
  5. package/attachment/attachment-utils.d.ts.map +1 -1
  6. package/attachment/attachment-utils.js +23 -0
  7. package/attachment/attachment-utils.js.map +1 -1
  8. package/attachment/clipboard.d.ts +51 -0
  9. package/attachment/clipboard.d.ts.map +1 -0
  10. package/attachment/clipboard.js +89 -0
  11. package/attachment/clipboard.js.map +1 -0
  12. package/attachment/index.d.ts +6 -1
  13. package/attachment/index.d.ts.map +1 -1
  14. package/attachment/index.js +4 -1
  15. package/attachment/index.js.map +1 -1
  16. package/attachment/prepare-image.d.ts +43 -0
  17. package/attachment/prepare-image.d.ts.map +1 -0
  18. package/attachment/prepare-image.js +162 -0
  19. package/attachment/prepare-image.js.map +1 -0
  20. package/attachment/useAttachments.d.ts.map +1 -1
  21. package/attachment/useAttachments.js +23 -3
  22. package/attachment/useAttachments.js.map +1 -1
  23. package/attachment/vision-fit.d.ts +50 -0
  24. package/attachment/vision-fit.d.ts.map +1 -0
  25. package/attachment/vision-fit.js +76 -0
  26. package/attachment/vision-fit.js.map +1 -0
  27. package/channel/AgentChannelsPanel.d.ts.map +1 -1
  28. package/channel/AgentChannelsPanel.js +21 -2
  29. package/channel/AgentChannelsPanel.js.map +1 -1
  30. package/channel/ChannelConversationsDialog.d.ts +12 -4
  31. package/channel/ChannelConversationsDialog.d.ts.map +1 -1
  32. package/channel/ChannelConversationsDialog.js +18 -24
  33. package/channel/ChannelConversationsDialog.js.map +1 -1
  34. package/channel/providers.d.ts +23 -0
  35. package/channel/providers.d.ts.map +1 -1
  36. package/channel/providers.js +4 -0
  37. package/channel/providers.js.map +1 -1
  38. package/channel/useSaveAgentChannel.d.ts +5 -4
  39. package/channel/useSaveAgentChannel.d.ts.map +1 -1
  40. package/channel/useSaveAgentChannel.js +18 -4
  41. package/channel/useSaveAgentChannel.js.map +1 -1
  42. package/composer/ComposerToolbar.d.ts +1 -1
  43. package/composer/ComposerToolbar.d.ts.map +1 -1
  44. package/composer/SessionComposer.d.ts +4 -2
  45. package/composer/SessionComposer.d.ts.map +1 -1
  46. package/composer/SessionComposer.js +51 -5
  47. package/composer/SessionComposer.js.map +1 -1
  48. package/conversation/ConversationAttentionBanner.d.ts +22 -0
  49. package/conversation/ConversationAttentionBanner.d.ts.map +1 -0
  50. package/conversation/ConversationAttentionBanner.js +25 -0
  51. package/conversation/ConversationAttentionBanner.js.map +1 -0
  52. package/conversation/ConversationComposer.d.ts +41 -0
  53. package/conversation/ConversationComposer.d.ts.map +1 -0
  54. package/conversation/ConversationComposer.js +57 -0
  55. package/conversation/ConversationComposer.js.map +1 -0
  56. package/conversation/ConversationControlBanner.d.ts +52 -0
  57. package/conversation/ConversationControlBanner.d.ts.map +1 -0
  58. package/conversation/ConversationControlBanner.js +59 -0
  59. package/conversation/ConversationControlBanner.js.map +1 -0
  60. package/conversation/ConversationListPane.d.ts +68 -0
  61. package/conversation/ConversationListPane.d.ts.map +1 -0
  62. package/conversation/ConversationListPane.js +120 -0
  63. package/conversation/ConversationListPane.js.map +1 -0
  64. package/conversation/ConversationTimelineView.d.ts +46 -0
  65. package/conversation/ConversationTimelineView.d.ts.map +1 -0
  66. package/conversation/ConversationTimelineView.js +166 -0
  67. package/conversation/ConversationTimelineView.js.map +1 -0
  68. package/conversation/ConversationsWorkbench.d.ts +63 -0
  69. package/conversation/ConversationsWorkbench.d.ts.map +1 -0
  70. package/conversation/ConversationsWorkbench.js +165 -0
  71. package/conversation/ConversationsWorkbench.js.map +1 -0
  72. package/conversation/conversationPresentation.d.ts +137 -0
  73. package/conversation/conversationPresentation.d.ts.map +1 -0
  74. package/conversation/conversationPresentation.js +230 -0
  75. package/conversation/conversationPresentation.js.map +1 -0
  76. package/conversation/index.d.ts +26 -0
  77. package/conversation/index.d.ts.map +1 -0
  78. package/conversation/index.js +14 -0
  79. package/conversation/index.js.map +1 -0
  80. package/conversation/polling.d.ts +39 -0
  81. package/conversation/polling.d.ts.map +1 -0
  82. package/conversation/polling.js +39 -0
  83. package/conversation/polling.js.map +1 -0
  84. package/conversation/useConversation.d.ts +61 -0
  85. package/conversation/useConversation.d.ts.map +1 -0
  86. package/conversation/useConversation.js +153 -0
  87. package/conversation/useConversation.js.map +1 -0
  88. package/conversation/useConversationList.d.ts +98 -0
  89. package/conversation/useConversationList.d.ts.map +1 -0
  90. package/conversation/useConversationList.js +200 -0
  91. package/conversation/useConversationList.js.map +1 -0
  92. package/conversation/useConversationParticipation.d.ts +63 -0
  93. package/conversation/useConversationParticipation.d.ts.map +1 -0
  94. package/conversation/useConversationParticipation.js +84 -0
  95. package/conversation/useConversationParticipation.js.map +1 -0
  96. package/conversation/useConversationTimeline.d.ts +71 -0
  97. package/conversation/useConversationTimeline.d.ts.map +1 -0
  98. package/conversation/useConversationTimeline.js +152 -0
  99. package/conversation/useConversationTimeline.js.map +1 -0
  100. package/conversation/useConversationsWantsHumanCount.d.ts +42 -0
  101. package/conversation/useConversationsWantsHumanCount.d.ts.map +1 -0
  102. package/conversation/useConversationsWantsHumanCount.js +40 -0
  103. package/conversation/useConversationsWantsHumanCount.js.map +1 -0
  104. package/index.d.ts +6 -2
  105. package/index.d.ts.map +1 -1
  106. package/index.js +11 -2
  107. package/index.js.map +1 -1
  108. package/internal/tooltip.d.ts.map +1 -1
  109. package/internal/tooltip.js +7 -1
  110. package/internal/tooltip.js.map +1 -1
  111. package/internal/useAutoScroll.d.ts +25 -4
  112. package/internal/useAutoScroll.d.ts.map +1 -1
  113. package/internal/useAutoScroll.js +55 -15
  114. package/internal/useAutoScroll.js.map +1 -1
  115. package/internal/useFetch.d.ts.map +1 -1
  116. package/internal/useFetch.js +14 -4
  117. package/internal/useFetch.js.map +1 -1
  118. package/models/ModelSelector.d.ts +24 -5
  119. package/models/ModelSelector.d.ts.map +1 -1
  120. package/models/ModelSelector.js +31 -9
  121. package/models/ModelSelector.js.map +1 -1
  122. package/models/registry.d.ts +3 -2
  123. package/models/registry.d.ts.map +1 -1
  124. package/models/registry.js.map +1 -1
  125. package/models/service-tier.d.ts +1 -1
  126. package/models/service-tier.d.ts.map +1 -1
  127. package/models/service-tier.js +1 -1
  128. package/models/service-tier.js.map +1 -1
  129. package/package.json +4 -4
  130. package/schedule/ScheduleDetailView.js +1 -1
  131. package/schedule/ScheduleDetailView.js.map +1 -1
  132. package/schedule/ScheduleForm.d.ts.map +1 -1
  133. package/schedule/ScheduleForm.js +7 -6
  134. package/schedule/ScheduleForm.js.map +1 -1
  135. package/sharing/useSaveAgentShare.d.ts +10 -1
  136. package/sharing/useSaveAgentShare.d.ts.map +1 -1
  137. package/sharing/useSaveAgentShare.js +9 -0
  138. package/sharing/useSaveAgentShare.js.map +1 -1
  139. package/sidebar/WorkspaceSidebar.d.ts +12 -4
  140. package/sidebar/WorkspaceSidebar.d.ts.map +1 -1
  141. package/sidebar/WorkspaceSidebar.js +19 -7
  142. package/sidebar/WorkspaceSidebar.js.map +1 -1
  143. package/src/attachment/AttachmentChipList.tsx +45 -1
  144. package/src/attachment/__tests__/AttachmentChipList.test.tsx +103 -0
  145. package/src/attachment/__tests__/attachment-utils.test.ts +54 -0
  146. package/src/attachment/__tests__/clipboard.test.ts +110 -0
  147. package/src/attachment/__tests__/prepare-image.browser.test.ts +166 -0
  148. package/src/attachment/__tests__/prepare-image.test.ts +32 -0
  149. package/src/attachment/__tests__/vision-fit.test.ts +93 -0
  150. package/src/attachment/attachment-utils.ts +27 -0
  151. package/src/attachment/clipboard.ts +102 -0
  152. package/src/attachment/index.ts +13 -0
  153. package/src/attachment/prepare-image.ts +179 -0
  154. package/src/attachment/useAttachments.ts +26 -2
  155. package/src/attachment/vision-fit.ts +90 -0
  156. package/src/channel/AgentChannelsPanel.tsx +33 -2
  157. package/src/channel/ChannelConversationsDialog.tsx +22 -25
  158. package/src/channel/__tests__/AgentChannelsPanel.test.tsx +36 -5
  159. package/src/channel/__tests__/ChannelConversationsDialog.test.tsx +38 -1
  160. package/src/channel/__tests__/useSaveAgentChannel.test.tsx +26 -0
  161. package/src/channel/providers.ts +27 -0
  162. package/src/channel/useSaveAgentChannel.ts +18 -4
  163. package/src/composer/ComposerToolbar.tsx +1 -1
  164. package/src/composer/SessionComposer.tsx +75 -6
  165. package/src/composer/__tests__/SessionComposer-paste.test.tsx +263 -0
  166. package/src/composer/__tests__/SessionComposer-serviceTier.test.tsx +4 -3
  167. package/src/composer/__tests__/SessionComposer-uploadGate.test.tsx +239 -0
  168. package/src/conversation/ConversationAttentionBanner.tsx +77 -0
  169. package/src/conversation/ConversationComposer.tsx +156 -0
  170. package/src/conversation/ConversationControlBanner.tsx +193 -0
  171. package/src/conversation/ConversationListPane.tsx +459 -0
  172. package/src/conversation/ConversationTimelineView.tsx +435 -0
  173. package/src/conversation/ConversationsWorkbench.tsx +378 -0
  174. package/src/conversation/__tests__/ConversationAttentionBanner.test.tsx +82 -0
  175. package/src/conversation/__tests__/ConversationComposer.test.tsx +160 -0
  176. package/src/conversation/__tests__/ConversationControlBanner.test.tsx +190 -0
  177. package/src/conversation/__tests__/ConversationListPane.test.tsx +372 -0
  178. package/src/conversation/__tests__/ConversationTimelineView.layout.test.tsx +160 -0
  179. package/src/conversation/__tests__/ConversationTimelineView.test.tsx +405 -0
  180. package/src/conversation/__tests__/ConversationsWorkbench.test.tsx +860 -0
  181. package/src/conversation/__tests__/a11y/conversation-surfaces.a11y.test.tsx +235 -0
  182. package/src/conversation/__tests__/a11y/harness.tsx +100 -0
  183. package/src/conversation/__tests__/conversation-tooltips.layout.test.tsx +167 -0
  184. package/src/conversation/__tests__/conversationPollingComposition.test.tsx +138 -0
  185. package/src/conversation/__tests__/conversationPresentation.test.ts +289 -0
  186. package/src/conversation/__tests__/useConversation.test.tsx +243 -0
  187. package/src/conversation/__tests__/useConversationList.test.tsx +492 -0
  188. package/src/conversation/__tests__/useConversationParticipation.test.tsx +190 -0
  189. package/src/conversation/__tests__/useConversationTimeline.test.tsx +258 -0
  190. package/src/conversation/__tests__/useConversationsWantsHumanCount.test.tsx +102 -0
  191. package/src/conversation/conversationPresentation.ts +305 -0
  192. package/src/conversation/index.ts +80 -0
  193. package/src/conversation/polling.ts +41 -0
  194. package/src/conversation/useConversation.ts +221 -0
  195. package/src/conversation/useConversationList.ts +328 -0
  196. package/src/conversation/useConversationParticipation.ts +178 -0
  197. package/src/conversation/useConversationTimeline.ts +244 -0
  198. package/src/conversation/useConversationsWantsHumanCount.ts +86 -0
  199. package/src/index.ts +78 -1
  200. package/src/internal/__tests__/fake-timer-slices.ts +29 -0
  201. package/src/internal/__tests__/useAutoScroll.layout.test.tsx +143 -0
  202. package/src/internal/__tests__/useAutoScroll.test.tsx +62 -5
  203. package/src/internal/__tests__/useFetch-poll-under-render-pressure.test.tsx +79 -0
  204. package/src/internal/tooltip.tsx +6 -1
  205. package/src/internal/useAutoScroll.ts +66 -20
  206. package/src/internal/useFetch.ts +15 -4
  207. package/src/models/ModelSelector.tsx +81 -49
  208. package/src/models/__tests__/ModelSelector-serviceTier.test.tsx +105 -21
  209. package/src/models/registry.ts +3 -2
  210. package/src/models/service-tier.ts +1 -1
  211. package/src/schedule/ScheduleDetailView.tsx +1 -1
  212. package/src/schedule/ScheduleForm.tsx +7 -6
  213. package/src/schedule/__tests__/scheduleCreation.test.tsx +2 -2
  214. package/src/sharing/__tests__/useSaveAgentShare.test.tsx +55 -1
  215. package/src/sharing/__tests__/useShareToolReadiness.test.tsx +1 -0
  216. package/src/sharing/useSaveAgentShare.ts +19 -1
  217. package/src/sidebar/WorkspaceSidebar.tsx +62 -3
  218. package/src/sidebar/__tests__/WorkspaceSidebar.test.tsx +56 -1
  219. package/styles.css +1 -1
@@ -0,0 +1,63 @@
1
+ import type { ChannelConversation } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/conversation_io_pb";
2
+ import type { SendChannelMessageOutput } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/message_io_pb";
3
+ /** The four staff-facing participation commands. */
4
+ export type ConversationCommand = "reply" | "takeOver" | "handBack" | "clearAttention";
5
+ /** Options for {@link useConversationParticipation}. */
6
+ export interface UseConversationParticipationOptions {
7
+ /** AgentChannel the conversation belongs to. */
8
+ readonly agentChannelId: string;
9
+ /** Conversation key within the channel. */
10
+ readonly conversationKey: string;
11
+ /**
12
+ * Receives the fresh conversation row every command answers with —
13
+ * wire it to {@link useConversation}'s `applyServerState` so banners
14
+ * and controls adopt server truth immediately. Called for reply too
15
+ * (via a follow-up row read): a staff reply implicitly takes over
16
+ * BEFORE the send, unconditionally, so control has moved even when
17
+ * the send itself was refused.
18
+ */
19
+ readonly onConversation?: (fresh: ChannelConversation) => void;
20
+ }
21
+ /** Return value of {@link useConversationParticipation}. */
22
+ export interface UseConversationParticipationReturn {
23
+ /**
24
+ * Send a staff text reply. Resolves with the truthful outcome of the
25
+ * inline attempt: `accepted` (with `outboundMessageId` — the item will
26
+ * appear on the timeline as `ob:<that id>`), `queued`, or `refused`.
27
+ * A `refused` outcome WITHOUT an `outboundMessageId` left no ledger
28
+ * row and no timeline item will ever exist for it.
29
+ */
30
+ readonly reply: (text: string) => Promise<SendChannelMessageOutput>;
31
+ /**
32
+ * Take the conversation over: the agent goes quiet until handBack.
33
+ * Resolves with the fresh row — for the LOSER of a concurrent
34
+ * takeover too (success-with-the-winner's-state, never an error), so
35
+ * compare `controlledBy` against the caller rather than assuming the
36
+ * transition won.
37
+ */
38
+ readonly takeOver: () => Promise<ChannelConversation>;
39
+ /** Hand the conversation back to the agent. */
40
+ readonly handBack: () => Promise<ChannelConversation>;
41
+ /** Dismiss the needs-attention flag in place; control is untouched. */
42
+ readonly clearAttention: () => Promise<ChannelConversation>;
43
+ /** Commands currently in flight. */
44
+ readonly pendingCommands: ReadonlySet<ConversationCommand>;
45
+ /** Per-command failures, cleared when that command is retried. */
46
+ readonly commandErrors: ReadonlyMap<ConversationCommand, Error>;
47
+ /** Reset every recorded command error. */
48
+ readonly clearErrors: () => void;
49
+ }
50
+ /**
51
+ * Behavior hook for the participation commands on one conversation
52
+ * (channel-conversations DD-005/DD-007/DD-008/DD-009): reply, takeOver,
53
+ * handBack, clearAttention — each keyed independently so a slow reply
54
+ * and a takeover can be in flight at once with attributable spinners
55
+ * and errors.
56
+ *
57
+ * Every command re-throws its failure after recording it in
58
+ * {@link UseConversationParticipationReturn.commandErrors}, so callers
59
+ * choose the propagation (await-and-toast, or ignore and render the
60
+ * keyed error inline).
61
+ */
62
+ export declare function useConversationParticipation(options: UseConversationParticipationOptions): UseConversationParticipationReturn;
63
+ //# sourceMappingURL=useConversationParticipation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConversationParticipation.d.ts","sourceRoot":"","sources":["../../src/conversation/useConversationParticipation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACpB,MAAM,uEAAuE,CAAC;AAM/E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kEAAkE,CAAC;AAKjH,oDAAoD;AACpD,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,GAAG,gBAAgB,CAAC;AAEvF,wDAAwD;AACxD,MAAM,WAAW,mCAAmC;IAClD,gDAAgD;IAChD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC;;;;;;;OAOG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAChE;AAED,4DAA4D;AAC5D,MAAM,WAAW,kCAAkC;IACjD;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACpE;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACtD,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACtD,uEAAuE;IACvE,QAAQ,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC5D,oCAAoC;IACpC,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAC3D,kEAAkE;IAClE,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;IAChE,0CAA0C;IAC1C,QAAQ,CAAC,WAAW,EAAE,MAAM,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,mCAAmC,GAC3C,kCAAkC,CAiGpC"}
@@ -0,0 +1,84 @@
1
+ "use client";
2
+ import { create } from "@bufbuild/protobuf";
3
+ import { ConversationControlInputSchema, GetChannelConversationInputSchema, ReplyToConversationInputSchema, } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/conversation_io_pb";
4
+ import { useCallback, useMemo } from "react";
5
+ import { useStigmer } from "../hooks.js";
6
+ import { useKeyedSubmission } from "../internal/useKeyedSubmission.js";
7
+ /**
8
+ * Behavior hook for the participation commands on one conversation
9
+ * (channel-conversations DD-005/DD-007/DD-008/DD-009): reply, takeOver,
10
+ * handBack, clearAttention — each keyed independently so a slow reply
11
+ * and a takeover can be in flight at once with attributable spinners
12
+ * and errors.
13
+ *
14
+ * Every command re-throws its failure after recording it in
15
+ * {@link UseConversationParticipationReturn.commandErrors}, so callers
16
+ * choose the propagation (await-and-toast, or ignore and render the
17
+ * keyed error inline).
18
+ */
19
+ export function useConversationParticipation(options) {
20
+ const { agentChannelId, conversationKey, onConversation } = options;
21
+ const stigmer = useStigmer();
22
+ const submission = useKeyedSubmission();
23
+ const { run } = submission;
24
+ const controlInput = useCallback(() => create(ConversationControlInputSchema, { agentChannelId, conversationKey }), [agentChannelId, conversationKey]);
25
+ const takeOver = useCallback(() => run("takeOver", async () => {
26
+ const fresh = await stigmer.agentChannel.takeOver(controlInput());
27
+ onConversation?.(fresh);
28
+ return fresh;
29
+ }), [run, stigmer, controlInput, onConversation]);
30
+ const handBack = useCallback(() => run("handBack", async () => {
31
+ const fresh = await stigmer.agentChannel.handBack(controlInput());
32
+ onConversation?.(fresh);
33
+ return fresh;
34
+ }), [run, stigmer, controlInput, onConversation]);
35
+ const clearAttention = useCallback(() => run("clearAttention", async () => {
36
+ const fresh = await stigmer.agentChannel.clearAttention(controlInput());
37
+ onConversation?.(fresh);
38
+ return fresh;
39
+ }), [run, stigmer, controlInput, onConversation]);
40
+ const reply = useCallback((text) => run("reply", async () => {
41
+ const output = await stigmer.agentChannel.reply(create(ReplyToConversationInputSchema, {
42
+ agentChannelId,
43
+ conversationKey,
44
+ payload: { kind: { case: "text", value: { body: text } } },
45
+ }));
46
+ // The implicit takeover flipped control BEFORE the send ran —
47
+ // even a refused reply moved it — but reply answers the send
48
+ // outcome, not the row. One follow-up read keeps the control
49
+ // banner honest without waiting a poll tick. Best-effort: a
50
+ // failed read only delays the banner until the next poll.
51
+ if (onConversation) {
52
+ try {
53
+ onConversation(await stigmer.agentChannel.getConversation(create(GetChannelConversationInputSchema, {
54
+ agentChannelId,
55
+ conversationKey,
56
+ })));
57
+ }
58
+ catch {
59
+ // The reply itself succeeded; the poll will catch the row up.
60
+ }
61
+ }
62
+ return output;
63
+ }), [run, stigmer, agentChannelId, conversationKey, onConversation]);
64
+ return useMemo(() => ({
65
+ reply,
66
+ takeOver,
67
+ handBack,
68
+ clearAttention,
69
+ // The submission primitive keys by string; this hook only ever
70
+ // submits the four command names, so the narrowing is sound.
71
+ pendingCommands: submission.submittingKeys,
72
+ commandErrors: submission.errorsByKey,
73
+ clearErrors: submission.clearErrors,
74
+ }), [
75
+ reply,
76
+ takeOver,
77
+ handBack,
78
+ clearAttention,
79
+ submission.submittingKeys,
80
+ submission.errorsByKey,
81
+ submission.clearErrors,
82
+ ]);
83
+ }
84
+ //# sourceMappingURL=useConversationParticipation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConversationParticipation.js","sourceRoot":"","sources":["../../src/conversation/useConversationParticipation.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAI5C,OAAO,EACL,8BAA8B,EAC9B,iCAAiC,EACjC,8BAA8B,GAC/B,MAAM,uEAAuE,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAoDvE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAA4C;IAE5C,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IACpE,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,UAAU,GAAG,kBAAkB,EAAW,CAAC;IACjD,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC;IAE3B,MAAM,YAAY,GAAG,WAAW,CAC9B,GAAG,EAAE,CAAC,MAAM,CAAC,8BAA8B,EAAE,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC,EACjF,CAAC,cAAc,EAAE,eAAe,CAAC,CAClC,CAAC;IAEF,MAAM,QAAQ,GAAG,WAAW,CAC1B,GAAG,EAAE,CACH,GAAG,CAAC,UAAU,EAAE,KAAK,IAAI,EAAE;QACzB,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC;QAClE,cAAc,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D;QAC7D,6DAA6D;QAC7D,4DAA4D;QAC5D,0DAA0D;QAC1D,IAAI,cAAc,EAAE,CAAC;YACnB,IAAI,CAAC;gBACH,cAAc,CACZ,MAAM,OAAO,CAAC,YAAY,CAAC,eAAe,CACxC,MAAM,CAAC,iCAAiC,EAAE;oBACxC,cAAc;oBACd,eAAe;iBAChB,CAAC,CACH,CACF,CAAC;YACJ,CAAC;YAAC,MAAM,CAAC;gBACP,8DAA8D;YAChE,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAsC,EACzC,CAAC,GAAG,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,CAAC,CAChE,CAAC;IAEF,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,KAAK;QACL,QAAQ;QACR,QAAQ;QACR,cAAc;QACd,+DAA+D;QAC/D,6DAA6D;QAC7D,eAAe,EAAE,UAAU,CAAC,cAAkD;QAC9E,aAAa,EAAE,UAAU,CAAC,WAAsD;QAChF,WAAW,EAAE,UAAU,CAAC,WAAW;KACpC,CAAC,EACF;QACE,KAAK;QACL,QAAQ;QACR,QAAQ;QACR,cAAc;QACd,UAAU,CAAC,cAAc;QACzB,UAAU,CAAC,WAAW;QACtB,UAAU,CAAC,WAAW;KACvB,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type { ConversationTimelineItem } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/conversation_io_pb";
2
+ /** Options for {@link useConversationTimeline}. */
3
+ export interface UseConversationTimelineOptions {
4
+ /** Items per page, for the polled head and each loadOlder page. Default 50. */
5
+ readonly pageSize?: number;
6
+ /**
7
+ * Poll interval in milliseconds; `false` disables polling. Defaults to
8
+ * {@link CONVERSATION_DETAIL_POLL_INTERVAL_MS}. Only the head page
9
+ * polls — it is where new items land and where recent items' delivery
10
+ * and receipt states still move.
11
+ */
12
+ readonly refetchIntervalMs?: number | false;
13
+ }
14
+ /** Return value of {@link useConversationTimeline}. */
15
+ export interface UseConversationTimelineReturn {
16
+ /**
17
+ * Every item seen so far, in chronological (oldest → newest) order —
18
+ * the render order of a chat view. Items are never dropped: the polled
19
+ * head window may shift as new messages land, and an item that slides
20
+ * out of it stays here rather than vanishing mid-scroll.
21
+ */
22
+ readonly items: readonly ConversationTimelineItem[];
23
+ /**
24
+ * `true` while older history exists beyond what is loaded. Decided
25
+ * ONLY by the server's cursor — a short page mid-history is normal
26
+ * (same-second bursts narrow pages) and never means the end.
27
+ */
28
+ readonly hasOlder: boolean;
29
+ /** Load the next older page. No-op while one is already loading. */
30
+ readonly loadOlder: () => void;
31
+ /** `true` while a loadOlder page is in flight. */
32
+ readonly isLoadingOlder: boolean;
33
+ /** Error from the last failed loadOlder, or `null`. Cleared on retry. */
34
+ readonly loadOlderError: Error | null;
35
+ /** `true` only during the first head-page load. */
36
+ readonly isLoading: boolean;
37
+ /** `true` while the head page refreshes in the background. */
38
+ readonly isRefetching: boolean;
39
+ /** Error from the last failed head-page fetch, or `null`. */
40
+ readonly error: Error | null;
41
+ /** Re-fetch the head page. */
42
+ readonly refetch: () => void;
43
+ }
44
+ /**
45
+ * Data hook for one conversation's customer-visible timeline
46
+ * (channel-conversations DD-004): newest-first cursor pages from the
47
+ * server, accumulated into one chronological list for a chat view.
48
+ *
49
+ * The accumulation is an UPSERT by `item_id`, not head/tail
50
+ * concatenation, for two verified server behaviors:
51
+ *
52
+ * - Item instants are stable but STATUSES mutate in place — an outbound
53
+ * item's delivery status and receipt ticks advance after it first
54
+ * renders. Each head poll re-upserts the newest window, so those
55
+ * fields stay live without any diffing protocol.
56
+ * - The head window SHIFTS as new items land. Items that slide out of
57
+ * it are not in any loaded older page (older cursors are anchored
58
+ * below the original head), so concatenation would silently drop
59
+ * them; the upsert map keeps everything ever seen.
60
+ *
61
+ * The older cursor is captured from the FIRST head page only: later
62
+ * head refreshes serve the top of the timeline, while the cursor tracks
63
+ * how deep into history the consumer has scrolled — two independent
64
+ * frontiers. Receipt ticks on items deeper than the head window can go
65
+ * stale until the conversation is reopened; accepted for v1 (the T05
66
+ * liveness seam is where per-item freshness lands).
67
+ *
68
+ * Pass empty strings to skip fetching (the `null`-fetchFn convention).
69
+ */
70
+ export declare function useConversationTimeline(agentChannelId: string, conversationKey: string, options?: UseConversationTimelineOptions): UseConversationTimelineReturn;
71
+ //# sourceMappingURL=useConversationTimeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConversationTimeline.d.ts","sourceRoot":"","sources":["../../src/conversation/useConversationTimeline.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uEAAuE,CAAC;AAYtH,mDAAmD;AACnD,MAAM,WAAW,8BAA8B;IAC7C,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC7C;AAED,uDAAuD;AACvD,MAAM,WAAW,6BAA6B;IAC5C;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,wBAAwB,EAAE,CAAC;IACpD;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC;IAC/B,kDAAkD;IAClD,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,yEAAyE;IACzE,QAAQ,CAAC,cAAc,EAAE,KAAK,GAAG,IAAI,CAAC;IACtC,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,8DAA8D;IAC9D,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AASD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE,8BAA8B,GACvC,6BAA6B,CA6H/B"}
@@ -0,0 +1,152 @@
1
+ "use client";
2
+ import { create, equals } from "@bufbuild/protobuf";
3
+ import { ConversationTimelineItemSchema, GetConversationTimelineInputSchema, } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/conversation_io_pb";
4
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
5
+ import { useStigmer } from "../hooks.js";
6
+ import { toError } from "../internal/toError.js";
7
+ import { useFetch } from "../internal/useFetch.js";
8
+ import { compareTimelineItemsNewestFirst } from "./conversationPresentation.js";
9
+ import { CONVERSATION_DETAIL_POLL_INTERVAL_MS } from "./polling.js";
10
+ const EMPTY_HEAD = { items: [], nextPageToken: "" };
11
+ /**
12
+ * Data hook for one conversation's customer-visible timeline
13
+ * (channel-conversations DD-004): newest-first cursor pages from the
14
+ * server, accumulated into one chronological list for a chat view.
15
+ *
16
+ * The accumulation is an UPSERT by `item_id`, not head/tail
17
+ * concatenation, for two verified server behaviors:
18
+ *
19
+ * - Item instants are stable but STATUSES mutate in place — an outbound
20
+ * item's delivery status and receipt ticks advance after it first
21
+ * renders. Each head poll re-upserts the newest window, so those
22
+ * fields stay live without any diffing protocol.
23
+ * - The head window SHIFTS as new items land. Items that slide out of
24
+ * it are not in any loaded older page (older cursors are anchored
25
+ * below the original head), so concatenation would silently drop
26
+ * them; the upsert map keeps everything ever seen.
27
+ *
28
+ * The older cursor is captured from the FIRST head page only: later
29
+ * head refreshes serve the top of the timeline, while the cursor tracks
30
+ * how deep into history the consumer has scrolled — two independent
31
+ * frontiers. Receipt ticks on items deeper than the head window can go
32
+ * stale until the conversation is reopened; accepted for v1 (the T05
33
+ * liveness seam is where per-item freshness lands).
34
+ *
35
+ * Pass empty strings to skip fetching (the `null`-fetchFn convention).
36
+ */
37
+ export function useConversationTimeline(agentChannelId, conversationKey, options) {
38
+ const pageSize = options?.pageSize ?? 50;
39
+ const refetchIntervalMs = options?.refetchIntervalMs ?? CONVERSATION_DETAIL_POLL_INTERVAL_MS;
40
+ const stigmer = useStigmer();
41
+ const enabled = agentChannelId !== "" && conversationKey !== "";
42
+ const fetchFn = enabled
43
+ ? async () => {
44
+ const result = await stigmer.agentChannel.getTimeline(create(GetConversationTimelineInputSchema, {
45
+ agentChannelId,
46
+ conversationKey,
47
+ pageSize,
48
+ }));
49
+ return { items: result.items, nextPageToken: result.nextPageToken };
50
+ }
51
+ : null;
52
+ const { data: head, isLoading, isRefetching, error, refetch, } = useFetch(fetchFn, [agentChannelId, conversationKey, pageSize, stigmer], EMPTY_HEAD, {
53
+ refetchInterval: refetchIntervalMs,
54
+ // DD-012 D-a: returning to the tab is fresh (the head re-upserts, so
55
+ // a focus refetch can never disturb accumulated history).
56
+ refetchOnWindowFocus: true,
57
+ });
58
+ // Everything ever seen for this conversation, by item id.
59
+ const [known, setKnown] = useState(new Map());
60
+ // The older-history frontier: null until the first head page answers,
61
+ // "" once history is exhausted, otherwise the next older cursor.
62
+ const [olderCursor, setOlderCursor] = useState(null);
63
+ const [isLoadingOlder, setIsLoadingOlder] = useState(false);
64
+ const [loadOlderError, setLoadOlderError] = useState(null);
65
+ const epochRef = useRef(0);
66
+ useEffect(() => {
67
+ epochRef.current += 1;
68
+ setKnown(new Map());
69
+ setOlderCursor(null);
70
+ setIsLoadingOlder(false);
71
+ setLoadOlderError(null);
72
+ }, [agentChannelId, conversationKey, pageSize, stigmer]);
73
+ // Fold each head page into the map. `head` is referentially fresh per
74
+ // fetch, so this runs exactly once per answer.
75
+ useEffect(() => {
76
+ if (head === EMPTY_HEAD)
77
+ return;
78
+ setKnown((current) => upsert(current, head.items));
79
+ setOlderCursor((current) => (current === null ? head.nextPageToken : current));
80
+ }, [head]);
81
+ const loadOlder = useCallback(() => {
82
+ if (!enabled || isLoadingOlder || !olderCursor)
83
+ return;
84
+ const epoch = epochRef.current;
85
+ setIsLoadingOlder(true);
86
+ setLoadOlderError(null);
87
+ stigmer.agentChannel
88
+ .getTimeline(create(GetConversationTimelineInputSchema, {
89
+ agentChannelId,
90
+ conversationKey,
91
+ pageSize,
92
+ pageToken: olderCursor,
93
+ }))
94
+ .then((result) => {
95
+ if (epochRef.current !== epoch)
96
+ return;
97
+ setKnown((current) => upsert(current, result.items));
98
+ setOlderCursor(result.nextPageToken);
99
+ setIsLoadingOlder(false);
100
+ }, (err) => {
101
+ if (epochRef.current !== epoch)
102
+ return;
103
+ setLoadOlderError(toError(err));
104
+ setIsLoadingOlder(false);
105
+ });
106
+ }, [enabled, isLoadingOlder, olderCursor, agentChannelId, conversationKey, pageSize, stigmer]);
107
+ const items = useMemo(() => Array.from(known.values())
108
+ .sort(compareTimelineItemsNewestFirst)
109
+ .reverse(), [known]);
110
+ const hasOlder = olderCursor !== null && olderCursor !== "";
111
+ return useMemo(() => ({
112
+ items,
113
+ hasOlder,
114
+ loadOlder,
115
+ isLoadingOlder,
116
+ loadOlderError,
117
+ isLoading,
118
+ isRefetching,
119
+ error,
120
+ refetch,
121
+ }), [
122
+ items,
123
+ hasOlder,
124
+ loadOlder,
125
+ isLoadingOlder,
126
+ loadOlderError,
127
+ isLoading,
128
+ isRefetching,
129
+ error,
130
+ refetch,
131
+ ]);
132
+ }
133
+ /**
134
+ * Fold a page into the map, preserving references: a poll returns fresh
135
+ * proto objects even when nothing changed, and swapping equal items
136
+ * would defeat `React.memo` on every row every poll tick (DD-010 —
137
+ * reference stability is architectural, not an optimization). An
138
+ * unchanged page returns the SAME map, so the sorted `items` memo does
139
+ * not even re-run.
140
+ */
141
+ function upsert(current, incoming) {
142
+ let next = null;
143
+ for (const item of incoming) {
144
+ const existing = current.get(item.itemId);
145
+ if (existing && equals(ConversationTimelineItemSchema, existing, item))
146
+ continue;
147
+ next ??= new Map(current);
148
+ next.set(item.itemId, item);
149
+ }
150
+ return next ?? current;
151
+ }
152
+ //# sourceMappingURL=useConversationTimeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConversationTimeline.js","sourceRoot":"","sources":["../../src/conversation/useConversationTimeline.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EACL,8BAA8B,EAC9B,kCAAkC,GACnC,MAAM,uEAAuE,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,oCAAoC,EAAE,MAAM,cAAc,CAAC;AAmDpE,MAAM,UAAU,GAAa,EAAE,KAAK,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,uBAAuB,CACrC,cAAsB,EACtB,eAAuB,EACvB,OAAwC;IAExC,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,EAAE,CAAC;IACzC,MAAM,iBAAiB,GACrB,OAAO,EAAE,iBAAiB,IAAI,oCAAoC,CAAC;IACrE,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,MAAM,OAAO,GAAG,cAAc,KAAK,EAAE,IAAI,eAAe,KAAK,EAAE,CAAC;IAEhE,MAAM,OAAO,GAAG,OAAO;QACrB,CAAC,CAAC,KAAK,IAAuB,EAAE;YAC5B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,YAAY,CAA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IAAI,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,IAAI,IAAI,OAAO,CAAC;AACzB,CAAC"}
@@ -0,0 +1,42 @@
1
+ /** Options for {@link useConversationsWantsHumanCount}. */
2
+ export interface UseConversationsWantsHumanCountOptions {
3
+ /**
4
+ * Poll interval in milliseconds; `false` disables polling. Defaults to
5
+ * {@link CONVERSATION_BADGE_POLL_INTERVAL_MS} — deliberately the
6
+ * slowest budget on the conversation surface (DD-012 D-b): a badge
7
+ * tolerates staleness an open inbox does not, and it renders on every
8
+ * console page in every tab.
9
+ */
10
+ readonly refetchIntervalMs?: number | false;
11
+ }
12
+ /** Return value of {@link useConversationsWantsHumanCount}. */
13
+ export interface UseConversationsWantsHumanCountReturn {
14
+ /**
15
+ * Conversations where a human action is wanted:
16
+ * `needs_attention OR (awaiting_reply AND human-held)` — the two ways
17
+ * a conversation can be blocked on a person (the agent asked for one,
18
+ * or a human took over and the customer wrote). `0` until the first
19
+ * answer.
20
+ */
21
+ readonly count: number;
22
+ /** `true` only until the first answer arrives. */
23
+ readonly isLoading: boolean;
24
+ /** Error from the last failed read, or `null`. */
25
+ readonly error: Error | null;
26
+ /** Imperatively re-read the count. */
27
+ readonly refetch: () => void;
28
+ }
29
+ /**
30
+ * Data hook for the sidebar's Conversations badge (channel-conversations
31
+ * DD-011 D-f): how many conversations want a human right now, org-wide.
32
+ *
33
+ * The count IS the filtered list's `total_count` — one page-size-1 read
34
+ * with `filter_wants_human`, zero dedicated RPCs (DD-011 D-g). Because
35
+ * the badge and the wants-human list filter share one server-side
36
+ * predicate, the number shown and the list it leads to can never
37
+ * disagree.
38
+ *
39
+ * Pass `null` to skip fetching (no active org).
40
+ */
41
+ export declare function useConversationsWantsHumanCount(org: string | null, options?: UseConversationsWantsHumanCountOptions): UseConversationsWantsHumanCountReturn;
42
+ //# sourceMappingURL=useConversationsWantsHumanCount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConversationsWantsHumanCount.d.ts","sourceRoot":"","sources":["../../src/conversation/useConversationsWantsHumanCount.ts"],"names":[],"mappings":"AAYA,2DAA2D;AAC3D,MAAM,WAAW,sCAAsC;IACrD;;;;;;OAMG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC7C;AAED,+DAA+D;AAC/D,MAAM,WAAW,qCAAqC;IACpD;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,kDAAkD;IAClD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,OAAO,CAAC,EAAE,sCAAsC,GAC/C,qCAAqC,CA4BvC"}
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { create } from "@bufbuild/protobuf";
3
+ import { ChannelConversationListFilter, ListChannelConversationsInputSchema, } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/conversation_io_pb";
4
+ import { useMemo } from "react";
5
+ import { useStigmer } from "../hooks.js";
6
+ import { useFetch } from "../internal/useFetch.js";
7
+ import { CONVERSATION_BADGE_POLL_INTERVAL_MS } from "./polling.js";
8
+ /**
9
+ * Data hook for the sidebar's Conversations badge (channel-conversations
10
+ * DD-011 D-f): how many conversations want a human right now, org-wide.
11
+ *
12
+ * The count IS the filtered list's `total_count` — one page-size-1 read
13
+ * with `filter_wants_human`, zero dedicated RPCs (DD-011 D-g). Because
14
+ * the badge and the wants-human list filter share one server-side
15
+ * predicate, the number shown and the list it leads to can never
16
+ * disagree.
17
+ *
18
+ * Pass `null` to skip fetching (no active org).
19
+ */
20
+ export function useConversationsWantsHumanCount(org, options) {
21
+ const stigmer = useStigmer();
22
+ const refetchIntervalMs = options?.refetchIntervalMs ?? CONVERSATION_BADGE_POLL_INTERVAL_MS;
23
+ const fetchFn = org
24
+ ? async () => {
25
+ const result = await stigmer.agentChannel.listConversations(create(ListChannelConversationsInputSchema, {
26
+ org,
27
+ filter: ChannelConversationListFilter.filter_wants_human,
28
+ pageInfo: { num: 1, size: 1 },
29
+ }));
30
+ return result.totalCount;
31
+ }
32
+ : null;
33
+ const { data, isLoading, error, refetch } = useFetch(fetchFn, [org, stigmer], 0, {
34
+ refetchInterval: refetchIntervalMs,
35
+ // DD-012 D-a: returning to the tab is fresh.
36
+ refetchOnWindowFocus: true,
37
+ });
38
+ return useMemo(() => ({ count: data, isLoading, error, refetch }), [data, isLoading, error, refetch]);
39
+ }
40
+ //# sourceMappingURL=useConversationsWantsHumanCount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConversationsWantsHumanCount.js","sourceRoot":"","sources":["../../src/conversation/useConversationsWantsHumanCount.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,6BAA6B,EAC7B,mCAAmC,GACpC,MAAM,uEAAuE,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,mCAAmC,EAAE,MAAM,cAAc,CAAC;AAgCnE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,+BAA+B,CAC7C,GAAkB,EAClB,OAAgD;IAEhD,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,iBAAiB,GACrB,OAAO,EAAE,iBAAiB,IAAI,mCAAmC,CAAC;IAEpE,MAAM,OAAO,GAAG,GAAG;QACjB,CAAC,CAAC,KAAK,IAAqB,EAAE;YAC1B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,iBAAiB,CACzD,MAAM,CAAC,mCAAmC,EAAE;gBAC1C,GAAG;gBACH,MAAM,EAAE,6BAA6B,CAAC,kBAAkB;gBACxD,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;aAC9B,CAAC,CACH,CAAC;YACF,OAAO,MAAM,CAAC,UAAU,CAAC;QAC3B,CAAC;QACH,CAAC,CAAC,IAAI,CAAC;IAET,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE;QAC/E,eAAe,EAAE,iBAAiB;QAClC,6CAA6C;QAC7C,oBAAoB,EAAE,IAAI;KAC3B,CAAC,CAAC;IAEH,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAClD,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAClC,CAAC;AACJ,CAAC"}
package/index.d.ts CHANGED
@@ -23,8 +23,8 @@ export { isTerminalPhase, useCreateAgentExecution, useExecutionStream, useLiveAg
23
23
  export type { BootstrapSessionSpec, CreateAgentExecutionInput, CreateAgentExecutionResult, SharedAgentExecutionFields, UseCreateAgentExecutionReturn, UseExecutionStreamReturn, UseLiveAgentExecutionOptions, UseLiveAgentExecutionReturn, UseAgentExecutionActionsOptions, UseAgentExecutionActionsReturn, UseSubmitApprovalReturn, UseFileReviewReturn, FileDecisionOptions, FileReviewability, FileBlockReason, ChangeSetReviewability, FileReviewRowState, ExecutionPhaseBadgeProps, InteractionModeBadgeProps, SetupProgressProps, ExecutionProgressProps, TodoListProps, TodoCardProps, UsageWidgetProps, ContextGaugeProps, SummarizationBadgeProps, SummarizationCardProps, PlanCompletionCardProps, PlanArtifactCardProps, PlanStreamingCardProps, PlanDocumentMessageProps, ContextHealth, SummarizationEventView, UseContextWindowReturn, ToolCallGroupProps, ToolCallDetailProps, ResultViewProps, TerminalSessionProps, ToolPresentation, ToolPresenter, ToolDisclosure, McpToolDetailProps, McpArgsViewProps, McpMetadataRowProps, ToolArgsViewProps, ToolCallItemProps, SubAgentSectionProps, MessageEntryProps, MessageThreadProps, ThreadContentColumn, ThreadSkeletonProps, FollowUpInputProps, ApprovalCardProps, ApprovalCardHeaderProps, ApprovalCardBodyProps, FileReviewCardProps, FileReviewDockProps, FileChangeProgressBarProps, ApprovalContextValue, UseApprovalResult, FileReviewContextValue, ArtifactRowProps, ArtifactRowViewProps, ArtifactRowItem, ArtifactContentRendererProps, ArtifactContentBodyProps, ArtifactFileContentProps, ArtifactDocumentProps, ArtifactInspection, UseArtifactInspectionOptions, ArtifactRenderMode, ArtifactPreviewContentProps, ArtifactPreviewModalProps, ArtifactsWidgetProps, WriteBacksWidgetProps, FilePathLinkProps, FilePathContextValue, PathClassification, ResolvedPathAction, SessionVariableEntry, UseSessionVariablesReturn, SessionVariablesInputProps, UseExecutionArtifactsReturn, UseArtifactContentReturn, UseArtifactContentByIdReturn, UseArtifactDownloadUrlReturn, UseArtifactDownloadUrlOptions, UseArtifactDownloadReturn, UseArtifactCopyReturn, UseToolOutputContentReturn, ToolOutputRefLike, UseFileChangeContentReturn, UseWorkspaceWriteBacksReturn, WriteBackCardProps, DiffStatSummary, FileChangesViewProps, FileChangeDiffProps, EmptyChangeNoticeProps, EmptyChangeKind, } from "./execution/index.js";
24
24
  export type { ExecutionArtifact } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/artifact_pb";
25
25
  export { ExecutionArtifactKind } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
26
- export { useAttachments, AttachmentChipList, MAX_ATTACHMENT_BYTES, detectContentType, formatFileSize, validateAttachmentSize, } from "./attachment/index.js";
27
- export type { AttachmentPhase, AttachmentEntry, UseAttachmentsOptions, UseAttachmentsReturn, AttachmentChipListProps, } from "./attachment/index.js";
26
+ export { useAttachments, AttachmentChipList, MAX_ATTACHMENT_BYTES, MAX_VISION_LONG_EDGE_PX, MAX_VISION_PIXELS, detectContentType, exceedsVisionResolution, extractClipboardFiles, fitToVisionResolution, formatFileSize, prepareImageForVision, uniquifyFilename, validateAttachmentSize, } from "./attachment/index.js";
27
+ export type { AttachmentPhase, AttachmentEntry, ClipboardFilesSource, UseAttachmentsOptions, UseAttachmentsReturn, AttachmentChipListProps, VisionFitSize, } from "./attachment/index.js";
28
28
  export { useFileReferences, FileReferenceChipList, } from "./file-reference/index.js";
29
29
  export type { UseFileReferencesReturn, FileReferenceChipListProps, } from "./file-reference/index.js";
30
30
  export { FILE_REF_MIME } from "./internal/file-tree/index.js";
@@ -91,6 +91,10 @@ export { useSharedAgentProfile, SharedAgentChat, draftFromShare, sharingAudience
91
91
  export type { UseSharedAgentProfileOptions, UseSharedAgentProfileReturn, SharedAgentChatProps, AgentShareCreateIdentity, AgentShareDraft, SharingAudience, UseAgentSharesReturn, UseCanCreateAgentShareReturn, UseSaveAgentShareReturn, UseDeleteAgentShareReturn, UseRotateShareLinkReturn, ShareAgentDialogProps, AgentShareListProps, ShareToolReadiness, } from "./sharing/index.js";
92
92
  export { useAgentChannelList, useAgentChannel, useSaveAgentChannel, agentChannelToInput, useCreateAgentChannel, useDeleteAgentChannel, useConnectSlackChannel, useInstallChannel, useChannelToolReadiness, useChannelTemplateReadiness, useChannelSessions, useChannelTemplateList, templateStatusPhase, splitTemplateBody, AgentChannelsPanel, ConnectSlackDialog, ConnectWhatsAppDialog, ChannelCredentialsDialog, ChannelToolCredentials, ChannelConversationsDialog, ChannelTemplatesDialog, } from "./channel/index.js";
93
93
  export type { UseAgentChannelListReturn, UseAgentChannelReturn, UseSaveAgentChannelReturn, UseCreateAgentChannelReturn, UseDeleteAgentChannelReturn, UseConnectSlackChannelReturn, SlackConnectPhase, UseInstallChannelReturn, InstallChannelPhase, ChannelTemplateReadiness, UseChannelSessionsReturn, UseChannelTemplateListOptions, UseChannelTemplateListReturn, TemplateBodySegment, AgentChannelsPanelProps, ConnectSlackDialogProps, ConnectWhatsAppDialogProps, ChannelCredentialsDialogProps, ChannelToolCredentialsProps, ChannelConversationsDialogProps, ChannelTemplatesDialogProps, } from "./channel/index.js";
94
+ export { ConversationsWorkbench, ConversationListPane, ConversationTimelineView, ConversationControlBanner, ConversationAttentionBanner, ConversationComposer, useConversation, useConversationList, useConversationTimeline, useConversationParticipation, useConversationsWantsHumanCount, authorKindOf, awaitingIndicatorOf, compareTimelineItemsNewestFirst, conversationContactOf, conversationLabelOf, inboundPlaceholderOf, isInternalItem, receiptOf, sendAttemptOf, serviceWindowOf, CONVERSATION_BADGE_POLL_INTERVAL_MS, CONVERSATION_DETAIL_POLL_INTERVAL_MS, CONVERSATION_LIST_POLL_INTERVAL_MS, } from "./conversation/index.js";
95
+ export type { ConversationsWorkbenchProps, ConversationHeaderContext, ConversationIdentity, ConversationListPaneProps, ConversationTimelineViewProps, ConversationControlBannerProps, ConversationAttentionBannerProps, ConversationComposerProps, UseConversationOptions, UseConversationReturn, UseConversationListOptions, UseConversationListReturn, UseConversationTimelineOptions, UseConversationTimelineReturn, ConversationCommand, UseConversationParticipationOptions, UseConversationParticipationReturn, UseConversationsWantsHumanCountOptions, UseConversationsWantsHumanCountReturn, AwaitingIndicator, ConversationAuthorKind, ReceiptKind, SendAttemptKind, ServiceWindowState, } from "./conversation/index.js";
96
+ export { ChannelConversationListFilter, ConversationControl, } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/conversation_io_pb";
97
+ export type { ChannelConversation, ConversationTimelineItem, } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/conversation_io_pb";
94
98
  export { ErrorMessage, SecretFlowErrorGuide, isSecretFlowError } from "./error/index.js";
95
99
  export type { ErrorMessageProps, SecretFlowErrorGuideProps } from "./error/index.js";
96
100
  export { LibraryBreadcrumbProvider, useBreadcrumbLabel, useBreadcrumbOverride, ScopeToggle, ResourceCountCard, detectStigmerResource, useDetectStigmerResource, isSkillPackage, detectSkillPackage, useDetectSkillPackage, isPlanArtifact, isPlanArtifactName, findPlanArtifact, findLatestSessionPlan, findStreamingPlan, PLAN_ARTIFACT_NAME, PLAN_ARTIFACT_SUFFIX, useApplyResource, useExportResource, VisibilitySelector, VisibilityBadge, blueprintVisibilityLevels, INSTANCE_VISIBILITY_LEVELS, visibilityLabel, useUpdateVisibility, } from "./library/index.js";