@bigbinary/neeto-assist-frontend 1.0.2 → 1.1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNeetoAssistStore-CGEUMbes.js","sources":["../app/javascript/src/components/commons/Sparkle.jsx","../app/javascript/src/utils/collapseRepeatedSkips.js","../app/javascript/src/utils/runs.js","../app/javascript/src/hooks/reactQuery/useRunsApi.js","../app/javascript/src/stores/useNeetoAssistStore.js"],"sourcesContent":["const Sparkle = ({ size = 18, className, ...otherProps }) => (\n <svg\n {...{ className }}\n aria-hidden=\"true\"\n fill=\"none\"\n height={size}\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"1.5\"\n viewBox=\"0 0 18 18\"\n width={size}\n xmlns=\"http://www.w3.org/2000/svg\"\n {...otherProps}\n >\n <path\n d=\"M5.658 2.99L4.395 2.569L3.974 1.306C3.837 0.898 3.162 0.898 3.025 1.306L2.604 2.569L1.341 2.99C1.137 3.058 0.999 3.249 0.999 3.464C0.999 3.679 1.137 3.87 1.341 3.938L2.604 4.359L3.025 5.622C3.093 5.826 3.285 5.964 3.5 5.964C3.715 5.964 3.906 5.826 3.975 5.622L4.396 4.359L5.659 3.938C5.863 3.87 6.001 3.679 6.001 3.464C6.001 3.249 5.862 3.058 5.658 2.99Z\"\n fill=\"currentColor\"\n stroke=\"none\"\n />\n <path d=\"M9.5 2.75L11.412 7.587L16.25 9.5L11.412 11.413L9.5 16.25L7.587 11.413L2.75 9.5L7.587 7.587L9.5 2.75Z\" />\n </svg>\n);\n\nexport default Sparkle;\n","// While a quiet rule holds, NeetoAssist skips every visitor message for the\n// same reason. One note says it, so of skips in a row for one of these\n// reasons, only the latest stays. Runs are in conversation order.\nexport const collapseRepeatedSkips = (runs, reasons) =>\n runs.filter((run, index) => {\n const next = runs[index + 1];\n\n return !(\n reasons.includes(run.skippedReason) &&\n next?.skippedReason === run.skippedReason\n );\n });\n","import { any, propEq, propOr, reverse } from \"ramda\";\n\nimport {\n ERROR_MESSAGE_KEYS,\n PENDING_STATUSES,\n QUIET_SKIPPED_REASONS,\n RATEABLE_STATUSES,\n REPLY_SUGGESTION,\n SKIPPED_REASON_MESSAGE_KEYS,\n UNRATEABLE_SKIPPED_REASONS,\n} from \"common/constants\";\nimport { collapseRepeatedSkips } from \"utils/collapseRepeatedSkips\";\n\n// A reply suggestion that is still waiting gets replaced by a newer one, which\n// answers its messages too, so only the newest shows as being worked on.\nconst withoutReplacedDrafts = runs =>\n runs.filter(\n (run, index) =>\n !(\n run.kind === REPLY_SUGGESTION &&\n run.status === \"queued\" &&\n runs.slice(index + 1).some(({ kind }) => kind === REPLY_SUGGESTION)\n )\n );\n\nexport const isPending = ({ status }) => PENDING_STATUSES.includes(status);\n\nexport const withoutRepeatedQuietSkips = runs =>\n collapseRepeatedSkips(runs, QUIET_SKIPPED_REASONS);\n\n// NeetoAssist lists the newest run first. The pane reads like the conversation\n// instead: oldest at the top, the latest at the bottom. A quiet rule skips every\n// message while it holds, and one note says so.\nexport const runsInConversationOrder = runs =>\n withoutRepeatedQuietSkips(withoutReplacedDrafts(reverse(runs)));\n\n// The newest reply NeetoAssist drafted on its own. Runs are newest first.\nexport const latestDraftId = runs =>\n runs.find(\n ({ kind, suggestedReply }) => kind === REPLY_SUGGESTION && !!suggestedReply\n )?.id;\n\n// A hello is skipped, since nothing was looked up, but it still gets a reply.\nexport const hasWrittenReply = ({ status, answer, suggestedReply }) =>\n status === \"completed\" ||\n (status === \"skipped\" && !!(answer || suggestedReply));\n\n// A rep's own hello or thanks got a friendly line, which is nothing to judge.\nexport const isRateable = ({ kind, status, skippedReason }) =>\n RATEABLE_STATUSES.includes(status) &&\n !UNRATEABLE_SKIPPED_REASONS.includes(skippedReason) &&\n !(kind === \"ask\" && status === \"skipped\");\n\n// What the pane polls quickly for: a run NeetoAssist is still working on. An\n// action someone is applying is not one. The rep who clicked has the answer\n// to the click, and an action whose end NeetoAssist never hears of would keep\n// every open pane polling quickly until NeetoAssist gives up on it.\nexport const hasPendingRun = (runs = []) => runs.some(isPending);\n\n// The lookups NeetoAssist made while answering, in the order they started. A\n// run from an older NeetoAssist carries none.\nexport const stepsOf = ({ steps }) => steps ?? [];\n\nexport const hasRunningStep = run =>\n any(propEq(\"running\", \"status\"), stepsOf(run));\n\n// A suggested action can only be applied once its run has finished. Until then\n// NeetoAssist may still take it back and start over, so its card waits.\nexport const actionsOf = ({ status, actions }) =>\n status === \"completed\" ? (actions ?? []) : [];\n\nexport const skippedReasonMessageKey = reason =>\n propOr(\"neetoAssist.run.skipped\", reason, SKIPPED_REASON_MESSAGE_KEYS);\n\n// No answer at all means the request never reached NeetoAssist.\nexport const errorMessageKey = error => {\n if (!error?.response) return ERROR_MESSAGE_KEYS[503];\n\n return propOr(\n \"neetoAssist.errors.generic\",\n error.response.status,\n ERROR_MESSAGE_KEYS\n );\n};\n\n// Sources come from a knowledge base, so only web links become links.\nexport const isWebUrl = url => /^https?:\\/\\//i.test(url ?? \"\");\n","import { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/v2/react-utils\";\n\nimport neetoAssistApi from \"apis/neeto_assist\";\nimport {\n IDLE_POLL_INTERVAL,\n PENDING_POLL_INTERVAL,\n QUERY_KEYS,\n} from \"common/constants\";\nimport { hasPendingRun } from \"utils/runs\";\n\n// Fresh on every mount, then polled: quickly while NeetoAssist is working on a\n// run, slowly otherwise. A failed poll is retried by the next one and never\n// shown as a toast. Comes with the workspace's credit state.\nconst useFetchRuns = conversationId =>\n useQuery({\n queryKey: [QUERY_KEYS.RUNS, conversationId],\n queryFn: () => neetoAssistApi.fetchRuns(conversationId),\n select: ({ runs = [], credits = null }) => ({ runs, credits }),\n staleTime: 0,\n retry: false,\n refetchInterval: ({ state: { data, error } }) =>\n !error && hasPendingRun(data?.runs)\n ? PENDING_POLL_INTERVAL\n : IDLE_POLL_INTERVAL,\n });\n\nconst useAskNeetoAssist = conversationId =>\n useMutationWithInvalidation(neetoAssistApi.createRun, {\n keysToInvalidate: [[QUERY_KEYS.RUNS, conversationId]],\n });\n\nconst useUpdateFeedback = conversationId =>\n useMutationWithInvalidation(neetoAssistApi.updateFeedback, {\n keysToInvalidate: [[QUERY_KEYS.RUNS, conversationId]],\n });\n\n// A click on a card changes what its run shows whether it worked or not: the\n// action was applied, or someone else got to it first, or it expired. So the\n// runs are fetched again either way. The card does not wait for them: the\n// answer to the click already says what happened.\nconst useActOnAction = (mutationFn, conversationId, callbacks = {}) => {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn,\n onSettled: () => {\n queryClient.invalidateQueries({\n queryKey: [QUERY_KEYS.RUNS, conversationId],\n });\n },\n ...callbacks,\n });\n};\n\n// The host hears of an applied action from here and not from the card that\n// was clicked. React Query drops what a card hands to mutate once the card is\n// off the screen, as when the rep opens another conversation before the answer\n// arrives, and the change was made all the same. The click does not wait for\n// the host's handler, so what the handler returns is left alone.\nconst useApplyAction = (conversationId, onApplied) =>\n useActOnAction(neetoAssistApi.applyAction, conversationId, {\n onSuccess: data => {\n onApplied?.(data?.action);\n },\n });\n\nconst useDismissAction = conversationId =>\n useActOnAction(neetoAssistApi.dismissAction, conversationId);\n\nexport {\n useFetchRuns,\n useAskNeetoAssist,\n useUpdateFeedback,\n useApplyAction,\n useDismissAction,\n};\n","import { withImmutableActions } from \"neetocommons/v2/react-utils\";\nimport { getFromLocalStorage, setToLocalStorage } from \"neetocommons/v2/utils\";\nimport { create } from \"zustand\";\n\nimport { EXPANDED_STORAGE_KEY } from \"common/constants\";\n\n// The pane is mounted once in the host's layout and the button sits on the\n// ticket, so this is how they talk: whether the pane is open and how wide, and\n// which conversation it is about. A reload starts closed, and the width is kept.\n/** @type {import(\"neetocommons/react-utils\").ZustandStoreHook} */\nconst useNeetoAssistStore = create(\n withImmutableActions(set => ({\n isOpen: false,\n isExpanded: getFromLocalStorage(EXPANDED_STORAGE_KEY) || false,\n conversation: null,\n seenDrafts: {},\n\n close: () => set({ isOpen: false }),\n\n toggle: () => set(state => ({ isOpen: !state.isOpen })),\n\n setExpanded: value => {\n setToLocalStorage(EXPANDED_STORAGE_KEY, value);\n set({ isExpanded: value });\n },\n\n setConversation: conversation => set({ conversation }),\n\n // Only the conversation that is leaving: the next one's button may already\n // have taken its place.\n clearConversation: conversationId =>\n set(state =>\n state.conversation?.id === conversationId ? { conversation: null } : {}\n ),\n\n markDraftSeen: (conversationId, runId) =>\n set(state => ({\n seenDrafts: { ...state.seenDrafts, [conversationId]: runId },\n })),\n }))\n);\n\nexport default useNeetoAssistStore;\n"],"names":["Sparkle","_ref","_ref$size","size","className","otherProps","_objectWithoutProperties","_excluded","_jsxs","_objectSpread","fill","height","stroke","strokeLinecap","strokeLinejoin","strokeWidth","viewBox","width","xmlns","children","_jsx","d","collapseRepeatedSkips","runs","reasons","filter","run","index","next","includes","skippedReason","withoutReplacedDrafts","kind","REPLY_SUGGESTION","status","slice","some","isPending","_ref2","PENDING_STATUSES","withoutRepeatedQuietSkips","QUIET_SKIPPED_REASONS","runsInConversationOrder","reverse","latestDraftId","_runs$find","find","_ref3","suggestedReply","id","hasWrittenReply","_ref4","answer","isRateable","_ref5","RATEABLE_STATUSES","UNRATEABLE_SKIPPED_REASONS","hasPendingRun","arguments","length","undefined","stepsOf","_ref6","steps","hasRunningStep","any","propEq","actionsOf","_ref7","actions","skippedReasonMessageKey","reason","propOr","SKIPPED_REASON_MESSAGE_KEYS","errorMessageKey","error","response","ERROR_MESSAGE_KEYS","isWebUrl","url","test","useFetchRuns","conversationId","useQuery","queryKey","QUERY_KEYS","RUNS","queryFn","neetoAssistApi","fetchRuns","select","_ref$runs","_ref$credits","credits","staleTime","retry","refetchInterval","_ref2$state","state","data","PENDING_POLL_INTERVAL","IDLE_POLL_INTERVAL","useAskNeetoAssist","useMutationWithInvalidation","createRun","keysToInvalidate","useUpdateFeedback","updateFeedback","useActOnAction","mutationFn","callbacks","queryClient","useQueryClient","useMutation","onSettled","invalidateQueries","useApplyAction","onApplied","applyAction","onSuccess","action","useDismissAction","dismissAction","useNeetoAssistStore","create","withImmutableActions","set","isOpen","isExpanded","getFromLocalStorage","EXPANDED_STORAGE_KEY","conversation","seenDrafts","close","toggle","setExpanded","value","setToLocalStorage","setConversation","clearConversation","_state$conversation","markDraftSeen","runId","_defineProperty"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAMA,OAAO,GAAG,SAAVA,OAAOA,CAAAC,IAAA,EAAA;AAAA,EAAA,IAAAC,SAAA,GAAAD,IAAA,CAAME,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,SAAA;IAAEE,SAAS,GAAAH,IAAA,CAATG,SAAS;AAAKC,IAAAA,UAAU,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA,CAAA;AAAA,EAAA,oBACpDC,eAAA,CAAA,KAAA,EAAAC,eAAA,CAAAA,eAAA,CAAA;AACQL,IAAAA,SAAS,EAATA,SAAS;AACf,IAAA,aAAA,EAAY,MAAM;AAClBM,IAAAA,IAAI,EAAC,MAAM;AACXC,IAAAA,MAAM,EAAER,IAAK;AACbS,IAAAA,MAAM,EAAC,cAAc;AACrBC,IAAAA,aAAa,EAAC,OAAO;AACrBC,IAAAA,cAAc,EAAC,OAAO;AACtBC,IAAAA,WAAW,EAAC,KAAK;AACjBC,IAAAA,OAAO,EAAC,WAAW;AACnBC,IAAAA,KAAK,EAAEd,IAAK;AACZe,IAAAA,KAAK,EAAC;AAA4B,GAAA,EAC9Bb,UAAU,CAAA,EAAA,EAAA,EAAA;AAAAc,IAAAA,QAAA,gBAEdC,cAAA,CAAA,MAAA,EAAA;AACEC,MAAAA,CAAC,EAAC,oWAAoW;AACtWX,MAAAA,IAAI,EAAC,cAAc;AACnBE,MAAAA,MAAM,EAAC;KACR,CAAC,eACFQ,cAAA,CAAA,MAAA,EAAA;AAAMC,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,CAAA,EAAA,EAAG7D,cAAc,EAAG4D,KAAK,CAAA;SAC3D;AAAA,MAAA,CAAC,CAAC;AAAA,IAAA;GACN;AAAA,CAAC,CACJ;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-assist-frontend",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "NeetoAssist pane and helpers for Neeto products",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://github.com/bigbinary/neeto-assist-nano",
package/types.d.ts CHANGED
@@ -2,6 +2,37 @@ import React from "react";
2
2
 
3
3
  import { UseQueryResult } from "@tanstack/react-query";
4
4
 
5
+ /**
6
+ * A suggested action as the pane has it: what NeetoAssist's cards show and what
7
+ * `onActionApplied` is called with. It never carries the action's arguments.
8
+ */
9
+ export interface NeetoAssistAction {
10
+ id: string;
11
+ /** The action's name in the host's catalog, such as `assign_conversation`. */
12
+ name: string;
13
+ /** The host's own words for what the action does. */
14
+ title: string;
15
+ /** More of the host's words, one line each. */
16
+ details: string[];
17
+ /** The model's one sentence on why it suggested the action. */
18
+ reason: string | null;
19
+ status:
20
+ | "suggested"
21
+ | "applying"
22
+ | "applied"
23
+ | "failed"
24
+ | "dismissed"
25
+ | "expired";
26
+ /** The host's sentence on what was done, once applied. */
27
+ result: string | null;
28
+ /** The host's sentence on what went wrong, once failed. */
29
+ error: string | null;
30
+ /** Who applied or dismissed the action. */
31
+ actedBy: { id: string; name: string } | null;
32
+ actedAt: string | null;
33
+ expiresAt: string | null;
34
+ }
35
+
5
36
  export interface NeetoAssistButtonProps {
6
37
  /**
7
38
  * The host's own id for the conversation. The pane calls
@@ -9,6 +40,23 @@ export interface NeetoAssistButtonProps {
9
40
  * looks it up through the host adapter's `find_conversation`.
10
41
  */
11
42
  conversationId: string;
43
+ /**
44
+ * A short phrase for what the rep is looking at, such as "Sam Smith's
45
+ * conversation". The pane shows "Looking at Sam Smith's conversation" under
46
+ * its header, as plain text. Leave it out to show no such line.
47
+ */
48
+ contextLabel?: string;
49
+ /**
50
+ * Called once after a rep clicked "Apply" on a card and the host made the
51
+ * change. The change went through the host's own code on the server, so the
52
+ * page still shows what was there before: fetch the conversation again, or
53
+ * whatever `action.name` changed, so the rep sees it without a reload. It is
54
+ * not called for an action that failed or was dismissed. It is called even
55
+ * when the rep opened another conversation before the answer arrived, and
56
+ * the handler called is then the one last given for the conversation the
57
+ * action was applied on.
58
+ */
59
+ onActionApplied?: (action: NeetoAssistAction) => void;
12
60
  /**
13
61
  * Called when the rep clicks "Use reply". Put the reply in the composer and
14
62
  * send nothing: NeetoAssist never writes to the customer. Leave it out to
@@ -36,11 +84,14 @@ export const NeetoAssistButton: React.FC<NeetoAssistButtonProps>;
36
84
  * NeetoAssist's chat window. Mount it once in the host's layout, as the last
37
85
  * child of the flex row that holds the page, so it opens on the right and
38
86
  * pushes the page to the left. It takes no props and no room until a
39
- * `NeetoAssistButton` opens it. It shows everything NeetoAssist did on the
40
- * ticket, oldest first, and polls every 3 seconds while a run is pending and
41
- * every 30 seconds otherwise. While open it sets `data-neeto-assist-open` on
42
- * the document's root element, to `default` or `expanded`, for a host that needs
43
- * CSS to make room.
87
+ * `NeetoAssistButton` opens it. It shows what NeetoAssist did on the ticket,
88
+ * oldest first: the replies it suggested, and for each of the rep's own
89
+ * questions what it looked up, its answer, and a card for every action it
90
+ * suggests, with "Apply" and "Dismiss". Another rep's questions are not shown.
91
+ * It polls every 2 seconds while a run is pending and every 30 seconds
92
+ * otherwise. While open it sets `data-neeto-assist-open` on the document's
93
+ * root element, to `default` or `expanded`, for a host that needs CSS to make
94
+ * room.
44
95
  */
45
96
  export const NeetoAssistPane: React.FC;
46
97
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"neeto_assist-BbwXxKis.js","sources":["../app/javascript/src/common/constants.js","../app/javascript/src/apis/neeto_assist.js"],"sourcesContent":["export const BASE_URL = \"/neeto_assist/api/v1\";\n\n// The pane shows NeetoAssist's errors itself. Without these, the host's axios\n// setup would raise a toast, or swap the page for an error page on a 403, 404\n// or 429.\nexport const REQUEST_OPTIONS = {\n showToastr: false,\n show403ErrorPage: false,\n show404ErrorPage: false,\n show429ErrorPage: false,\n};\n\nexport const QUERY_KEYS = {\n STATUS: \"neeto-assist-status\",\n RUNS: \"neeto-assist-runs\",\n};\n\nexport const PENDING_POLL_INTERVAL = 3_000;\n\nexport const IDLE_POLL_INTERVAL = 30_000;\n\nexport const PENDING_STATUSES = [\"queued\", \"running\"];\n\nexport const RATEABLE_STATUSES = [\"completed\", \"skipped\"];\n\n// The skips from the workspace's quiet rules, in NeetoAssist's settings. Each\n// one holds for every visitor message until something changes, such as the\n// agent who owns the conversation handing it back.\nexport const QUIET_SKIPPED_REASONS = [\n \"assigned_to_human\",\n \"handed_off\",\n \"no_answer_cooldown\",\n];\n\n// These skips come from the workspace's state, not from reading the\n// conversation, so there is nothing for a rep to judge.\nexport const UNRATEABLE_SKIPPED_REASONS = [\n \"disabled\",\n \"no_knowledge_source\",\n \"out_of_credits\",\n ...QUIET_SKIPPED_REASONS,\n];\n\nexport const MAX_QUESTION_LENGTH = 2_000;\n\nexport const MAX_NOTE_LENGTH = 2_000;\n\n// The same widths as Neeti's pane in NeetoCal, so Neeto's assistants feel alike.\nexport const COLLAPSED_PANE_WIDTH = \"min(100vw, 400px)\";\n\nexport const EXPANDED_PANE_WIDTH = \"min(50vw, 800px)\";\n\nexport const EXPANDED_STORAGE_KEY = \"neetoAssist.isExpanded\";\n\nexport const REPLY_SUGGESTION = \"reply_suggestion\";\n\nexport const RUN_TEST_ID = \"neeto-assist-run\";\n\nexport const SUGGESTION_KEYS = [\n \"neetoAssist.suggestions.summarize\",\n \"neetoAssist.suggestions.whatToReply\",\n \"neetoAssist.suggestions.whatToCheck\",\n];\n\nexport const SKIPPED_REASON_MESSAGE_KEYS = {\n greeting: \"neetoAssist.skippedReasons.greeting\",\n acknowledgment: \"neetoAssist.skippedReasons.acknowledgment\",\n agent_handoff: \"neetoAssist.skippedReasons.agentHandoff\",\n unclear: \"neetoAssist.skippedReasons.unclear\",\n other_product: \"neetoAssist.skippedReasons.otherProduct\",\n no_knowledge_source: \"neetoAssist.skippedReasons.noKnowledgeSource\",\n disabled: \"neetoAssist.skippedReasons.disabled\",\n no_question: \"neetoAssist.skippedReasons.noQuestion\",\n out_of_credits: \"neetoAssist.skippedReasons.outOfCredits\",\n assigned_to_human: \"neetoAssist.skippedReasons.assignedToHuman\",\n handed_off: \"neetoAssist.skippedReasons.handedOff\",\n no_answer_cooldown: \"neetoAssist.skippedReasons.noAnswerCooldown\",\n};\n\nexport const ERROR_MESSAGE_KEYS = {\n 404: \"neetoAssist.errors.notFound\",\n 409: \"neetoAssist.errors.disabled\",\n 422: \"neetoAssist.errors.invalid\",\n 503: \"neetoAssist.errors.unavailable\",\n};\n","import axios from \"axios\";\n\nimport { BASE_URL, REQUEST_OPTIONS } from \"common/constants\";\n\nconst runsUrl = conversationId =>\n `${BASE_URL}/conversations/${encodeURIComponent(conversationId)}/runs`;\n\nconst fetchStatus = () => axios.get(`${BASE_URL}/status`, REQUEST_OPTIONS);\n\nconst fetchRuns = conversationId =>\n axios.get(runsUrl(conversationId), REQUEST_OPTIONS);\n\nconst createRun = ({ conversationId, question, requestId }) =>\n axios.post(\n runsUrl(conversationId),\n { run: { question, request_id: requestId } },\n REQUEST_OPTIONS\n );\n\nconst updateFeedback = ({ conversationId, runId, rating, note }) =>\n axios.put(\n `${runsUrl(conversationId)}/${encodeURIComponent(runId)}/feedback`,\n { feedback: { rating, note } },\n REQUEST_OPTIONS\n );\n\nconst neetoAssistApi = { fetchStatus, fetchRuns, createRun, updateFeedback };\n\nexport default neetoAssistApi;\n"],"names":["BASE_URL","REQUEST_OPTIONS","showToastr","show403ErrorPage","show404ErrorPage","show429ErrorPage","QUERY_KEYS","STATUS","RUNS","PENDING_POLL_INTERVAL","IDLE_POLL_INTERVAL","PENDING_STATUSES","RATEABLE_STATUSES","QUIET_SKIPPED_REASONS","UNRATEABLE_SKIPPED_REASONS","concat","MAX_QUESTION_LENGTH","MAX_NOTE_LENGTH","COLLAPSED_PANE_WIDTH","EXPANDED_PANE_WIDTH","EXPANDED_STORAGE_KEY","REPLY_SUGGESTION","RUN_TEST_ID","SUGGESTION_KEYS","SKIPPED_REASON_MESSAGE_KEYS","greeting","acknowledgment","agent_handoff","unclear","other_product","no_knowledge_source","disabled","no_question","out_of_credits","assigned_to_human","handed_off","no_answer_cooldown","ERROR_MESSAGE_KEYS","runsUrl","conversationId","encodeURIComponent","fetchStatus","axios","get","fetchRuns","createRun","_ref","question","requestId","post","run","request_id","updateFeedback","_ref2","runId","rating","note","put","feedback","neetoAssistApi"],"mappings":";;;;AAAO,IAAMA,QAAQ,GAAG,sBAAsB;;AAE9C;AACA;AACA;AACO,IAAMC,eAAe,GAAG;AAC7BC,EAAAA,UAAU,EAAE,KAAK;AACjBC,EAAAA,gBAAgB,EAAE,KAAK;AACvBC,EAAAA,gBAAgB,EAAE,KAAK;AACvBC,EAAAA,gBAAgB,EAAE;AACpB,CAAC;AAEM,IAAMC,UAAU,GAAG;AACxBC,EAAAA,MAAM,EAAE,qBAAqB;AAC7BC,EAAAA,IAAI,EAAE;AACR;AAEO,IAAMC,qBAAqB,GAAG;AAE9B,IAAMC,kBAAkB,GAAG;IAErBC,gBAAgB,GAAG,CAAC,QAAQ,EAAE,SAAS;IAEvCC,iBAAiB,GAAG,CAAC,WAAW,EAAE,SAAS;;AAExD;AACA;AACA;AACO,IAAMC,qBAAqB,GAAG,CACnC,mBAAmB,EACnB,YAAY,EACZ,oBAAoB;;AAGtB;AACA;AACO,IAAMC,0BAA0B,GAAA,CACrC,UAAU,EACV,qBAAqB,EACrB,gBAAgB,CAAA,CAAAC,MAAA,CACbF,qBAAqB;AAGnB,IAAMG,mBAAmB,GAAG;AAE5B,IAAMC,eAAe,GAAG;;AAE/B;AACO,IAAMC,oBAAoB,GAAG;AAE7B,IAAMC,mBAAmB,GA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sources":["../app/javascript/src/common/constants.js","../app/javascript/src/apis/neeto_assist.js"],"sourcesContent":["export const BASE_URL = \"/neeto_assist/api/v1\";\n\n// The pane shows NeetoAssist's errors itself. Without these, the host's axios\n// setup would raise a toast, or swap the page for an error page on a 403, 404\n// or 429.\nexport const REQUEST_OPTIONS = {\n showToastr: false,\n show403ErrorPage: false,\n show404ErrorPage: false,\n show429ErrorPage: false,\n};\n\nexport const QUERY_KEYS = {\n STATUS: \"neeto-assist-status\",\n RUNS: \"neeto-assist-runs\",\n};\n\nexport const PENDING_POLL_INTERVAL = 3_000;\n\nexport const IDLE_POLL_INTERVAL = 30_000;\n\nexport const PENDING_STATUSES = [\"queued\", \"running\"];\n\nexport const RATEABLE_STATUSES = [\"completed\", \"skipped\"];\n\n// The skips from the workspace's quiet rules, in NeetoAssist's settings. Each\n// one holds for every visitor message until something changes, such as the\n// agent who owns the conversation handing it back.\nexport const QUIET_SKIPPED_REASONS = [\n \"assigned_to_human\",\n \"handed_off\",\n \"no_answer_cooldown\",\n];\n\n// These skips come from the workspace's state, not from reading the\n// conversation, so there is nothing for a rep to judge.\nexport const UNRATEABLE_SKIPPED_REASONS = [\n \"disabled\",\n \"no_knowledge_source\",\n \"out_of_credits\",\n ...QUIET_SKIPPED_REASONS,\n];\n\nexport const MAX_QUESTION_LENGTH = 2_000;\n\nexport const MAX_NOTE_LENGTH = 2_000;\n\n// The same widths as Neeti's pane in NeetoCal, so Neeto's assistants feel alike.\nexport const COLLAPSED_PANE_WIDTH = \"min(100vw, 400px)\";\n\nexport const EXPANDED_PANE_WIDTH = \"min(50vw, 800px)\";\n\nexport const EXPANDED_STORAGE_KEY = \"neetoAssist.isExpanded\";\n\nexport const REPLY_SUGGESTION = \"reply_suggestion\";\n\nexport const RUN_TEST_ID = \"neeto-assist-run\";\n\nexport const SUGGESTION_KEYS = [\n \"neetoAssist.suggestions.summarize\",\n \"neetoAssist.suggestions.whatToReply\",\n \"neetoAssist.suggestions.whatToCheck\",\n];\n\nexport const SKIPPED_REASON_MESSAGE_KEYS = {\n greeting: \"neetoAssist.skippedReasons.greeting\",\n acknowledgment: \"neetoAssist.skippedReasons.acknowledgment\",\n agent_handoff: \"neetoAssist.skippedReasons.agentHandoff\",\n unclear: \"neetoAssist.skippedReasons.unclear\",\n other_product: \"neetoAssist.skippedReasons.otherProduct\",\n no_knowledge_source: \"neetoAssist.skippedReasons.noKnowledgeSource\",\n disabled: \"neetoAssist.skippedReasons.disabled\",\n no_question: \"neetoAssist.skippedReasons.noQuestion\",\n out_of_credits: \"neetoAssist.skippedReasons.outOfCredits\",\n assigned_to_human: \"neetoAssist.skippedReasons.assignedToHuman\",\n handed_off: \"neetoAssist.skippedReasons.handedOff\",\n no_answer_cooldown: \"neetoAssist.skippedReasons.noAnswerCooldown\",\n};\n\nexport const ERROR_MESSAGE_KEYS = {\n 404: \"neetoAssist.errors.notFound\",\n 409: \"neetoAssist.errors.disabled\",\n 422: \"neetoAssist.errors.invalid\",\n 503: \"neetoAssist.errors.unavailable\",\n};\n","import axios from \"axios\";\n\nimport { BASE_URL, REQUEST_OPTIONS } from \"common/constants\";\n\nconst runsUrl = conversationId =>\n `${BASE_URL}/conversations/${encodeURIComponent(conversationId)}/runs`;\n\nconst fetchStatus = () => axios.get(`${BASE_URL}/status`, REQUEST_OPTIONS);\n\nconst fetchRuns = conversationId =>\n axios.get(runsUrl(conversationId), REQUEST_OPTIONS);\n\nconst createRun = ({ conversationId, question, requestId }) =>\n axios.post(\n runsUrl(conversationId),\n { run: { question, request_id: requestId } },\n REQUEST_OPTIONS\n );\n\nconst updateFeedback = ({ conversationId, runId, rating, note }) =>\n axios.put(\n `${runsUrl(conversationId)}/${encodeURIComponent(runId)}/feedback`,\n { feedback: { rating, note } },\n REQUEST_OPTIONS\n );\n\nconst neetoAssistApi = { fetchStatus, fetchRuns, createRun, updateFeedback };\n\nexport default neetoAssistApi;\n"],"names":["BASE_URL","REQUEST_OPTIONS","showToastr","show403ErrorPage","show404ErrorPage","show429ErrorPage","QUERY_KEYS","STATUS","RUNS","PENDING_POLL_INTERVAL","IDLE_POLL_INTERVAL","PENDING_STATUSES","RATEABLE_STATUSES","QUIET_SKIPPED_REASONS","UNRATEABLE_SKIPPED_REASONS","concat","MAX_QUESTION_LENGTH","MAX_NOTE_LENGTH","COLLAPSED_PANE_WIDTH","EXPANDED_PANE_WIDTH","EXPANDED_STORAGE_KEY","REPLY_SUGGESTION","RUN_TEST_ID","SUGGESTION_KEYS","SKIPPED_REASON_MESSAGE_KEYS","greeting","acknowledgment","agent_handoff","unclear","other_product","no_knowledge_source","disabled","no_question","out_of_credits","assigned_to_human","handed_off","no_answer_cooldown","ERROR_MESSAGE_KEYS","runsUrl","conversationId","encodeURIComponent","fetchStatus","axios","get","fetchRuns","createRun","_ref","question","requestId","post","run","request_id","updateFeedback","_ref2","runId","rating","note","put","feedback","neetoAssistApi"],"mappings":";;AAAO,IAAMA,QAAQ,GAAG,sBAAsB;;AAE9C;AACA;AACA;AACO,IAAMC,eAAe,GAAG;AAC7BC,EAAAA,UAAU,EAAE,KAAK;AACjBC,EAAAA,gBAAgB,EAAE,KAAK;AACvBC,EAAAA,gBAAgB,EAAE,KAAK;AACvBC,EAAAA,gBAAgB,EAAE;AACpB,CAAC;AAEM,IAAMC,UAAU,GAAG;AACxBC,EAAAA,MAAM,EAAE,qBAAqB;AAC7BC,EAAAA,IAAI,EAAE;AACR;AAEO,IAAMC,qBAAqB,GAAG;AAE9B,IAAMC,kBAAkB,GAAG;IAErBC,gBAAgB,GAAG,CAAC,QAAQ,EAAE,SAAS;IAEvCC,iBAAiB,GAAG,CAAC,WAAW,EAAE,SAAS;;AAExD;AACA;AACA;AACO,IAAMC,qBAAqB,GAAG,CACnC,mBAAmB,EACnB,YAAY,EACZ,oBAAoB;;AAGtB;AACA;AACO,IAAMC,0BAA0B,GAAA,CACrC,UAAU,EACV,qBAAqB,EACrB,gBAAgB,CAAA,CAAAC,MAAA,CACbF,qBAAqB;AAGnB,IAAMG,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cAAc,EAAdA;AAAe;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useNeetoAssistStore-B5U7FFgQ.js","sources":["../app/javascript/src/components/commons/Sparkle.jsx","../app/javascript/src/utils/collapseRepeatedSkips.js","../app/javascript/src/utils/runs.js","../app/javascript/src/hooks/reactQuery/useRunsApi.js","../app/javascript/src/stores/useNeetoAssistStore.js"],"sourcesContent":["const Sparkle = ({ size = 18, className, ...otherProps }) => (\n <svg\n {...{ className }}\n aria-hidden=\"true\"\n fill=\"none\"\n height={size}\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"1.5\"\n viewBox=\"0 0 18 18\"\n width={size}\n xmlns=\"http://www.w3.org/2000/svg\"\n {...otherProps}\n >\n <path\n d=\"M5.658 2.99L4.395 2.569L3.974 1.306C3.837 0.898 3.162 0.898 3.025 1.306L2.604 2.569L1.341 2.99C1.137 3.058 0.999 3.249 0.999 3.464C0.999 3.679 1.137 3.87 1.341 3.938L2.604 4.359L3.025 5.622C3.093 5.826 3.285 5.964 3.5 5.964C3.715 5.964 3.906 5.826 3.975 5.622L4.396 4.359L5.659 3.938C5.863 3.87 6.001 3.679 6.001 3.464C6.001 3.249 5.862 3.058 5.658 2.99Z\"\n fill=\"currentColor\"\n stroke=\"none\"\n />\n <path d=\"M9.5 2.75L11.412 7.587L16.25 9.5L11.412 11.413L9.5 16.25L7.587 11.413L2.75 9.5L7.587 7.587L9.5 2.75Z\" />\n </svg>\n);\n\nexport default Sparkle;\n","// While a quiet rule holds, NeetoAssist skips every visitor message for the\n// same reason. One note says it, so of skips in a row for one of these\n// reasons, only the latest stays. Runs are in conversation order.\nexport const collapseRepeatedSkips = (runs, reasons) =>\n runs.filter((run, index) => {\n const next = runs[index + 1];\n\n return !(\n reasons.includes(run.skippedReason) &&\n next?.skippedReason === run.skippedReason\n );\n });\n","import { propOr, reverse } from \"ramda\";\n\nimport {\n ERROR_MESSAGE_KEYS,\n PENDING_STATUSES,\n QUIET_SKIPPED_REASONS,\n RATEABLE_STATUSES,\n REPLY_SUGGESTION,\n SKIPPED_REASON_MESSAGE_KEYS,\n UNRATEABLE_SKIPPED_REASONS,\n} from \"common/constants\";\nimport { collapseRepeatedSkips } from \"utils/collapseRepeatedSkips\";\n\n// A reply suggestion that is still waiting gets replaced by a newer one, which\n// answers its messages too, so only the newest shows as being worked on.\nconst withoutReplacedDrafts = runs =>\n runs.filter(\n (run, index) =>\n !(\n run.kind === REPLY_SUGGESTION &&\n run.status === \"queued\" &&\n runs.slice(index + 1).some(({ kind }) => kind === REPLY_SUGGESTION)\n )\n );\n\nexport const isPending = ({ status }) => PENDING_STATUSES.includes(status);\n\nexport const withoutRepeatedQuietSkips = runs =>\n collapseRepeatedSkips(runs, QUIET_SKIPPED_REASONS);\n\n// NeetoAssist lists the newest run first. The pane reads like the conversation\n// instead: oldest at the top, the latest at the bottom. A quiet rule skips every\n// message while it holds, and one note says so.\nexport const runsInConversationOrder = runs =>\n withoutRepeatedQuietSkips(withoutReplacedDrafts(reverse(runs)));\n\n// The newest reply NeetoAssist drafted on its own. Runs are newest first.\nexport const latestDraftId = runs =>\n runs.find(\n ({ kind, suggestedReply }) => kind === REPLY_SUGGESTION && !!suggestedReply\n )?.id;\n\n// A hello is skipped, since nothing was looked up, but it still gets a reply.\nexport const hasWrittenReply = ({ status, answer, suggestedReply }) =>\n status === \"completed\" ||\n (status === \"skipped\" && !!(answer || suggestedReply));\n\n// A rep's own hello or thanks got a friendly line, which is nothing to judge.\nexport const isRateable = ({ kind, status, skippedReason }) =>\n RATEABLE_STATUSES.includes(status) &&\n !UNRATEABLE_SKIPPED_REASONS.includes(skippedReason) &&\n !(kind === \"ask\" && status === \"skipped\");\n\nexport const hasPendingRun = (runs = []) => runs.some(isPending);\n\nexport const skippedReasonMessageKey = reason =>\n propOr(\"neetoAssist.run.skipped\", reason, SKIPPED_REASON_MESSAGE_KEYS);\n\n// No answer at all means the request never reached NeetoAssist.\nexport const errorMessageKey = error => {\n if (!error?.response) return ERROR_MESSAGE_KEYS[503];\n\n return propOr(\n \"neetoAssist.errors.generic\",\n error.response.status,\n ERROR_MESSAGE_KEYS\n );\n};\n\n// Sources come from a knowledge base, so only web links become links.\nexport const isWebUrl = url => /^https?:\\/\\//i.test(url ?? \"\");\n","import { useQuery } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/v2/react-utils\";\n\nimport neetoAssistApi from \"apis/neeto_assist\";\nimport {\n IDLE_POLL_INTERVAL,\n PENDING_POLL_INTERVAL,\n QUERY_KEYS,\n} from \"common/constants\";\nimport { hasPendingRun } from \"utils/runs\";\n\n// Fresh on every mount, then polled: quickly while NeetoAssist is working on a\n// run, slowly otherwise. A failed poll is retried by the next one and never\n// shown as a toast. Comes with the workspace's credit state.\nconst useFetchRuns = conversationId =>\n useQuery({\n queryKey: [QUERY_KEYS.RUNS, conversationId],\n queryFn: () => neetoAssistApi.fetchRuns(conversationId),\n select: ({ runs = [], credits = null }) => ({ runs, credits }),\n staleTime: 0,\n retry: false,\n refetchInterval: ({ state: { data, error } }) =>\n !error && hasPendingRun(data?.runs)\n ? PENDING_POLL_INTERVAL\n : IDLE_POLL_INTERVAL,\n });\n\nconst useAskNeetoAssist = conversationId =>\n useMutationWithInvalidation(neetoAssistApi.createRun, {\n keysToInvalidate: [[QUERY_KEYS.RUNS, conversationId]],\n });\n\nconst useUpdateFeedback = conversationId =>\n useMutationWithInvalidation(neetoAssistApi.updateFeedback, {\n keysToInvalidate: [[QUERY_KEYS.RUNS, conversationId]],\n });\n\nexport { useFetchRuns, useAskNeetoAssist, useUpdateFeedback };\n","import { withImmutableActions } from \"neetocommons/v2/react-utils\";\nimport { getFromLocalStorage, setToLocalStorage } from \"neetocommons/v2/utils\";\nimport { create } from \"zustand\";\n\nimport { EXPANDED_STORAGE_KEY } from \"common/constants\";\n\n// The pane is mounted once in the host's layout and the button sits on the\n// ticket, so this is how they talk: whether the pane is open and how wide, and\n// which conversation it is about. A reload starts closed, and the width is kept.\n/** @type {import(\"neetocommons/react-utils\").ZustandStoreHook} */\nconst useNeetoAssistStore = create(\n withImmutableActions(set => ({\n isOpen: false,\n isExpanded: getFromLocalStorage(EXPANDED_STORAGE_KEY) || false,\n conversation: null,\n seenDrafts: {},\n\n close: () => set({ isOpen: false }),\n\n toggle: () => set(state => ({ isOpen: !state.isOpen })),\n\n setExpanded: value => {\n setToLocalStorage(EXPANDED_STORAGE_KEY, value);\n set({ isExpanded: value });\n },\n\n setConversation: conversation => set({ conversation }),\n\n // Only the conversation that is leaving: the next one's button may already\n // have taken its place.\n clearConversation: conversationId =>\n set(state =>\n state.conversation?.id === conversationId ? { conversation: null } : {}\n ),\n\n markDraftSeen: (conversationId, runId) =>\n set(state => ({\n seenDrafts: { ...state.seenDrafts, [conversationId]: runId },\n })),\n }))\n);\n\nexport default useNeetoAssistStore;\n"],"names":["Sparkle","_ref","_ref$size","size","className","otherProps","_objectWithoutProperties","_excluded","_jsxs","_objectSpread","fill","height","stroke","strokeLinecap","strokeLinejoin","strokeWidth","viewBox","width","xmlns","children","_jsx","d","collapseRepeatedSkips","runs","reasons","filter","run","index","next","includes","skippedReason","withoutReplacedDrafts","kind","REPLY_SUGGESTION","status","slice","some","isPending","_ref2","PENDING_STATUSES","withoutRepeatedQuietSkips","QUIET_SKIPPED_REASONS","runsInConversationOrder","reverse","latestDraftId","_runs$find","find","_ref3","suggestedReply","id","hasWrittenReply","_ref4","answer","isRateable","_ref5","RATEABLE_STATUSES","UNRATEABLE_SKIPPED_REASONS","hasPendingRun","arguments","length","undefined","skippedReasonMessageKey","reason","propOr","SKIPPED_REASON_MESSAGE_KEYS","errorMessageKey","error","response","ERROR_MESSAGE_KEYS","isWebUrl","url","test","useFetchRuns","conversationId","useQuery","queryKey","QUERY_KEYS","RUNS","queryFn","neetoAssistApi","fetchRuns","select","_ref$runs","_ref$credits","credits","staleTime","retry","refetchInterval","_ref2$state","state","data","PENDING_POLL_INTERVAL","IDLE_POLL_INTERVAL","useAskNeetoAssist","useMutationWithInvalidation","createRun","keysToInvalidate","useUpdateFeedback","updateFeedback","useNeetoAssistStore","create","withImmutableActions","set","isOpen","isExpanded","getFromLocalStorage","EXPANDED_STORAGE_KEY","conversation","seenDrafts","close","toggle","setExpanded","value","setToLocalStorage","setConversation","clearConversation","_state$conversation","markDraftSeen","runId","_defineProperty"],"mappings":";;;;;;;;;;;;;AAAA,IAAMA,OAAO,GAAG,SAAVA,OAAOA,CAAAC,IAAA,EAAA;AAAA,EAAA,IAAAC,SAAA,GAAAD,IAAA,CAAME,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,SAAA;IAAEE,SAAS,GAAAH,IAAA,CAATG,SAAS;AAAKC,IAAAA,UAAU,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA,CAAA;AAAA,EAAA,oBACpDC,IAAA,CAAA,KAAA,EAAAC,eAAA,CAAAA,eAAA,CAAA;AACQL,IAAAA,SAAS,EAATA,SAAS;AACf,IAAA,aAAA,EAAY,MAAM;AAClBM,IAAAA,IAAI,EAAC,MAAM;AACXC,IAAAA,MAAM,EAAER,IAAK;AACbS,IAAAA,MAAM,EAAC,cAAc;AACrBC,IAAAA,aAAa,EAAC,OAAO;AACrBC,IAAAA,cAAc,EAAC,OAAO;AACtBC,IAAAA,WAAW,EAAC,KAAK;AACjBC,IAAAA,OAAO,EAAC,WAAW;AACnBC,IAAAA,KAAK,EAAEd,IAAK;AACZe,IAAAA,KAAK,EAAC;AAA4B,GAAA,EAC9Bb,UAAU,CAAA,EAAA,EAAA,EAAA;AAAAc,IAAAA,QAAA,gBAEdC,GAAA,CAAA,MAAA,EAAA;AACEC,MAAAA,CAAC,EAAC,oWAAoW;AACtWX,MAAAA,IAAI,EAAC,cAAc;AACnBE,MAAAA,MAAM,EAAC;KACR,CAAC,eACFQ,GAAA,CAAA,MAAA,EAAA;AAAMC,MAAAA,CAAC,EAAC;AAAsG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K,EAAA;AAAA,QAAA,IAAA2B,mBAAA;AAAA,QAAA,OACP,CAAA,CAAAA,mBAAA,GAAA3B,KAAK,CAACkB,YAAY,MAAA,IAAA,IAAAS,mBAAA,KAAA,MAAA,GAAA,MAAA,GAAlBA,mBAAA,CAAoBnE,EAAE,MAAKwB,cAAc,GAAG;AAAEkC,UAAAA,YAAY,EAAE;SAAM,GAAG,EAAE;AAAA,MAAA,CACzE,CAAC;AAAA,IAAA,CAAA;AAEHU,IAAAA,aAAa,EAAE,SAAfA,aAAaA,CAAG5C,cAAc,EAAE6C,KAAK,EAAA;MAAA,OACnChB,GAAG,CAAC,UAAAb,KAAK,EAAA;QAAA,OAAK;AACZmB,UAAAA,UAAU,EAAAnG,aAAA,CAAAA,aAAA,CAAA,EAAA,EAAOgF,KAAK,CAACmB,UAAU,CAAA,EAAA,EAAA,EAAAW,eAAA,CAAA,EAAA,EAAG9C,cAAc,EAAG6C,KAAK,CAAA;SAC3D;AAAA,MAAA,CAAC,CAAC;AAAA,IAAA;GACN;AAAA,CAAC,CACJ;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useNeetoAssistStore-C4fEnA_y.js","sources":["../app/javascript/src/components/commons/Sparkle.jsx","../app/javascript/src/utils/collapseRepeatedSkips.js","../app/javascript/src/utils/runs.js","../app/javascript/src/hooks/reactQuery/useRunsApi.js","../app/javascript/src/stores/useNeetoAssistStore.js"],"sourcesContent":["const Sparkle = ({ size = 18, className, ...otherProps }) => (\n <svg\n {...{ className }}\n aria-hidden=\"true\"\n fill=\"none\"\n height={size}\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"1.5\"\n viewBox=\"0 0 18 18\"\n width={size}\n xmlns=\"http://www.w3.org/2000/svg\"\n {...otherProps}\n >\n <path\n d=\"M5.658 2.99L4.395 2.569L3.974 1.306C3.837 0.898 3.162 0.898 3.025 1.306L2.604 2.569L1.341 2.99C1.137 3.058 0.999 3.249 0.999 3.464C0.999 3.679 1.137 3.87 1.341 3.938L2.604 4.359L3.025 5.622C3.093 5.826 3.285 5.964 3.5 5.964C3.715 5.964 3.906 5.826 3.975 5.622L4.396 4.359L5.659 3.938C5.863 3.87 6.001 3.679 6.001 3.464C6.001 3.249 5.862 3.058 5.658 2.99Z\"\n fill=\"currentColor\"\n stroke=\"none\"\n />\n <path d=\"M9.5 2.75L11.412 7.587L16.25 9.5L11.412 11.413L9.5 16.25L7.587 11.413L2.75 9.5L7.587 7.587L9.5 2.75Z\" />\n </svg>\n);\n\nexport default Sparkle;\n","// While a quiet rule holds, NeetoAssist skips every visitor message for the\n// same reason. One note says it, so of skips in a row for one of these\n// reasons, only the latest stays. Runs are in conversation order.\nexport const collapseRepeatedSkips = (runs, reasons) =>\n runs.filter((run, index) => {\n const next = runs[index + 1];\n\n return !(\n reasons.includes(run.skippedReason) &&\n next?.skippedReason === run.skippedReason\n );\n });\n","import { propOr, reverse } from \"ramda\";\n\nimport {\n ERROR_MESSAGE_KEYS,\n PENDING_STATUSES,\n QUIET_SKIPPED_REASONS,\n RATEABLE_STATUSES,\n REPLY_SUGGESTION,\n SKIPPED_REASON_MESSAGE_KEYS,\n UNRATEABLE_SKIPPED_REASONS,\n} from \"common/constants\";\nimport { collapseRepeatedSkips } from \"utils/collapseRepeatedSkips\";\n\n// A reply suggestion that is still waiting gets replaced by a newer one, which\n// answers its messages too, so only the newest shows as being worked on.\nconst withoutReplacedDrafts = runs =>\n runs.filter(\n (run, index) =>\n !(\n run.kind === REPLY_SUGGESTION &&\n run.status === \"queued\" &&\n runs.slice(index + 1).some(({ kind }) => kind === REPLY_SUGGESTION)\n )\n );\n\nexport const isPending = ({ status }) => PENDING_STATUSES.includes(status);\n\nexport const withoutRepeatedQuietSkips = runs =>\n collapseRepeatedSkips(runs, QUIET_SKIPPED_REASONS);\n\n// NeetoAssist lists the newest run first. The pane reads like the conversation\n// instead: oldest at the top, the latest at the bottom. A quiet rule skips every\n// message while it holds, and one note says so.\nexport const runsInConversationOrder = runs =>\n withoutRepeatedQuietSkips(withoutReplacedDrafts(reverse(runs)));\n\n// The newest reply NeetoAssist drafted on its own. Runs are newest first.\nexport const latestDraftId = runs =>\n runs.find(\n ({ kind, suggestedReply }) => kind === REPLY_SUGGESTION && !!suggestedReply\n )?.id;\n\n// A hello is skipped, since nothing was looked up, but it still gets a reply.\nexport const hasWrittenReply = ({ status, answer, suggestedReply }) =>\n status === \"completed\" ||\n (status === \"skipped\" && !!(answer || suggestedReply));\n\n// A rep's own hello or thanks got a friendly line, which is nothing to judge.\nexport const isRateable = ({ kind, status, skippedReason }) =>\n RATEABLE_STATUSES.includes(status) &&\n !UNRATEABLE_SKIPPED_REASONS.includes(skippedReason) &&\n !(kind === \"ask\" && status === \"skipped\");\n\nexport const hasPendingRun = (runs = []) => runs.some(isPending);\n\nexport const skippedReasonMessageKey = reason =>\n propOr(\"neetoAssist.run.skipped\", reason, SKIPPED_REASON_MESSAGE_KEYS);\n\n// No answer at all means the request never reached NeetoAssist.\nexport const errorMessageKey = error => {\n if (!error?.response) return ERROR_MESSAGE_KEYS[503];\n\n return propOr(\n \"neetoAssist.errors.generic\",\n error.response.status,\n ERROR_MESSAGE_KEYS\n );\n};\n\n// Sources come from a knowledge base, so only web links become links.\nexport const isWebUrl = url => /^https?:\\/\\//i.test(url ?? \"\");\n","import { useQuery } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/v2/react-utils\";\n\nimport neetoAssistApi from \"apis/neeto_assist\";\nimport {\n IDLE_POLL_INTERVAL,\n PENDING_POLL_INTERVAL,\n QUERY_KEYS,\n} from \"common/constants\";\nimport { hasPendingRun } from \"utils/runs\";\n\n// Fresh on every mount, then polled: quickly while NeetoAssist is working on a\n// run, slowly otherwise. A failed poll is retried by the next one and never\n// shown as a toast. Comes with the workspace's credit state.\nconst useFetchRuns = conversationId =>\n useQuery({\n queryKey: [QUERY_KEYS.RUNS, conversationId],\n queryFn: () => neetoAssistApi.fetchRuns(conversationId),\n select: ({ runs = [], credits = null }) => ({ runs, credits }),\n staleTime: 0,\n retry: false,\n refetchInterval: ({ state: { data, error } }) =>\n !error && hasPendingRun(data?.runs)\n ? PENDING_POLL_INTERVAL\n : IDLE_POLL_INTERVAL,\n });\n\nconst useAskNeetoAssist = conversationId =>\n useMutationWithInvalidation(neetoAssistApi.createRun, {\n keysToInvalidate: [[QUERY_KEYS.RUNS, conversationId]],\n });\n\nconst useUpdateFeedback = conversationId =>\n useMutationWithInvalidation(neetoAssistApi.updateFeedback, {\n keysToInvalidate: [[QUERY_KEYS.RUNS, conversationId]],\n });\n\nexport { useFetchRuns, useAskNeetoAssist, useUpdateFeedback };\n","import { withImmutableActions } from \"neetocommons/v2/react-utils\";\nimport { getFromLocalStorage, setToLocalStorage } from \"neetocommons/v2/utils\";\nimport { create } from \"zustand\";\n\nimport { EXPANDED_STORAGE_KEY } from \"common/constants\";\n\n// The pane is mounted once in the host's layout and the button sits on the\n// ticket, so this is how they talk: whether the pane is open and how wide, and\n// which conversation it is about. A reload starts closed, and the width is kept.\n/** @type {import(\"neetocommons/react-utils\").ZustandStoreHook} */\nconst useNeetoAssistStore = create(\n withImmutableActions(set => ({\n isOpen: false,\n isExpanded: getFromLocalStorage(EXPANDED_STORAGE_KEY) || false,\n conversation: null,\n seenDrafts: {},\n\n close: () => set({ isOpen: false }),\n\n toggle: () => set(state => ({ isOpen: !state.isOpen })),\n\n setExpanded: value => {\n setToLocalStorage(EXPANDED_STORAGE_KEY, value);\n set({ isExpanded: value });\n },\n\n setConversation: conversation => set({ conversation }),\n\n // Only the conversation that is leaving: the next one's button may already\n // have taken its place.\n clearConversation: conversationId =>\n set(state =>\n state.conversation?.id === conversationId ? { conversation: null } : {}\n ),\n\n markDraftSeen: (conversationId, runId) =>\n set(state => ({\n seenDrafts: { ...state.seenDrafts, [conversationId]: runId },\n })),\n }))\n);\n\nexport default useNeetoAssistStore;\n"],"names":["Sparkle","_ref","_ref$size","size","className","otherProps","_objectWithoutProperties","_excluded","_jsxs","_objectSpread","fill","height","stroke","strokeLinecap","strokeLinejoin","strokeWidth","viewBox","width","xmlns","children","_jsx","d","collapseRepeatedSkips","runs","reasons","filter","run","index","next","includes","skippedReason","withoutReplacedDrafts","kind","REPLY_SUGGESTION","status","slice","some","isPending","_ref2","PENDING_STATUSES","withoutRepeatedQuietSkips","QUIET_SKIPPED_REASONS","runsInConversationOrder","reverse","latestDraftId","_runs$find","find","_ref3","suggestedReply","id","hasWrittenReply","_ref4","answer","isRateable","_ref5","RATEABLE_STATUSES","UNRATEABLE_SKIPPED_REASONS","hasPendingRun","arguments","length","undefined","skippedReasonMessageKey","reason","propOr","SKIPPED_REASON_MESSAGE_KEYS","errorMessageKey","error","response","ERROR_MESSAGE_KEYS","isWebUrl","url","test","useFetchRuns","conversationId","useQuery","queryKey","QUERY_KEYS","RUNS","queryFn","neetoAssistApi","fetchRuns","select","_ref$runs","_ref$credits","credits","staleTime","retry","refetchInterval","_ref2$state","state","data","PENDING_POLL_INTERVAL","IDLE_POLL_INTERVAL","useAskNeetoAssist","useMutationWithInvalidation","createRun","keysToInvalidate","useUpdateFeedback","updateFeedback","useNeetoAssistStore","create","withImmutableActions","set","isOpen","isExpanded","getFromLocalStorage","EXPANDED_STORAGE_KEY","conversation","seenDrafts","close","toggle","setExpanded","value","setToLocalStorage","setConversation","clearConversation","_state$conversation","markDraftSeen","runId","_defineProperty"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAMA,OAAO,GAAG,SAAVA,OAAOA,CAAAC,IAAA,EAAA;AAAA,EAAA,IAAAC,SAAA,GAAAD,IAAA,CAAME,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,SAAA;IAAEE,SAAS,GAAAH,IAAA,CAATG,SAAS;AAAKC,IAAAA,UAAU,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA,CAAA;AAAA,EAAA,oBACpDC,eAAA,CAAA,KAAA,EAAAC,eAAA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