@bigbinary/neeto-assist-frontend 1.0.2 → 1.1.0-beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +358 -22
- package/app/javascript/src/translations/en.json +26 -4
- package/dist/.ready +1 -1
- package/dist/NeetoAssistButton.js +27 -9
- package/dist/NeetoAssistButton.js.map +1 -1
- package/dist/NeetoAssistPane.js +554 -66
- package/dist/NeetoAssistPane.js.map +1 -1
- package/dist/cjs/NeetoAssistButton.js +27 -9
- package/dist/cjs/NeetoAssistButton.js.map +1 -1
- package/dist/cjs/NeetoAssistPane.js +547 -59
- package/dist/cjs/NeetoAssistPane.js.map +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/useNeetoAssistStatus.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{neeto_assist-Ha049T0Q.js → neeto_assist-CpUBA-3Z.js} +47 -14
- package/dist/neeto_assist-CpUBA-3Z.js.map +1 -0
- package/dist/{neeto_assist-BbwXxKis.js → neeto_assist-CznTN_YY.js} +49 -13
- package/dist/neeto_assist-CznTN_YY.js.map +1 -0
- package/dist/useNeetoAssistStatus.js +1 -1
- package/dist/{useNeetoAssistStore-B5U7FFgQ.js → useNeetoAssistStore--JwP_Upt.js} +67 -8
- package/dist/useNeetoAssistStore--JwP_Upt.js.map +1 -0
- package/dist/{useNeetoAssistStore-C4fEnA_y.js → useNeetoAssistStore-CGEUMbes.js} +69 -5
- package/dist/useNeetoAssistStore-CGEUMbes.js.map +1 -0
- package/package.json +1 -1
- package/types.d.ts +56 -5
- package/dist/neeto_assist-BbwXxKis.js.map +0 -1
- package/dist/neeto_assist-Ha049T0Q.js.map +0 -1
- package/dist/useNeetoAssistStore-B5U7FFgQ.js.map +0 -1
- package/dist/useNeetoAssistStore-C4fEnA_y.js.map +0 -1
|
@@ -15,11 +15,21 @@ var QUERY_KEYS = {
|
|
|
15
15
|
STATUS: "neeto-assist-status",
|
|
16
16
|
RUNS: "neeto-assist-runs"
|
|
17
17
|
};
|
|
18
|
-
var PENDING_POLL_INTERVAL =
|
|
18
|
+
var PENDING_POLL_INTERVAL = 2000;
|
|
19
19
|
var IDLE_POLL_INTERVAL = 30000;
|
|
20
20
|
var PENDING_STATUSES = ["queued", "running"];
|
|
21
21
|
var RATEABLE_STATUSES = ["completed", "skipped"];
|
|
22
22
|
|
|
23
|
+
// What became of a suggested action. NeetoAssist has the last word on an
|
|
24
|
+
// action in one of these: nothing a click says can be newer.
|
|
25
|
+
var SETTLED_ACTION_STATUSES = ["applied", "failed", "dismissed", "expired"];
|
|
26
|
+
|
|
27
|
+
// A suggestion nobody took up steps back to one muted line.
|
|
28
|
+
var QUIET_ACTION_STATUS_KEYS = {
|
|
29
|
+
dismissed: "neetoAssist.actions.dismissed",
|
|
30
|
+
expired: "neetoAssist.actions.expired"
|
|
31
|
+
};
|
|
32
|
+
|
|
23
33
|
// The skips from the workspace's quiet rules, in NeetoAssist's settings. Each
|
|
24
34
|
// one holds for every visitor message until something changes, such as the
|
|
25
35
|
// agent who owns the conversation handing it back.
|
|
@@ -37,7 +47,7 @@ var EXPANDED_PANE_WIDTH = "min(50vw, 800px)";
|
|
|
37
47
|
var EXPANDED_STORAGE_KEY = "neetoAssist.isExpanded";
|
|
38
48
|
var REPLY_SUGGESTION = "reply_suggestion";
|
|
39
49
|
var RUN_TEST_ID = "neeto-assist-run";
|
|
40
|
-
var SUGGESTION_KEYS = ["neetoAssist.suggestions.summarize", "neetoAssist.suggestions.whatToReply", "neetoAssist.suggestions.
|
|
50
|
+
var SUGGESTION_KEYS = ["neetoAssist.suggestions.summarize", "neetoAssist.suggestions.whatToReply", "neetoAssist.suggestions.writtenBefore", "neetoAssist.suggestions.whatNext"];
|
|
41
51
|
var SKIPPED_REASON_MESSAGE_KEYS = {
|
|
42
52
|
greeting: "neetoAssist.skippedReasons.greeting",
|
|
43
53
|
acknowledgment: "neetoAssist.skippedReasons.acknowledgment",
|
|
@@ -59,19 +69,31 @@ var ERROR_MESSAGE_KEYS = {
|
|
|
59
69
|
503: "neetoAssist.errors.unavailable"
|
|
60
70
|
};
|
|
61
71
|
|
|
72
|
+
// A click on a card that changed nothing. The other answers fall back to the
|
|
73
|
+
// keys above.
|
|
74
|
+
var ACTION_ERROR_MESSAGE_KEYS = {
|
|
75
|
+
403: "neetoAssist.actions.errors.forbidden",
|
|
76
|
+
503: "neetoAssist.actions.errors.unavailable"
|
|
77
|
+
};
|
|
78
|
+
|
|
62
79
|
var runsUrl = function runsUrl(conversationId) {
|
|
63
80
|
return "".concat(BASE_URL, "/conversations/").concat(encodeURIComponent(conversationId), "/runs");
|
|
64
81
|
};
|
|
82
|
+
var actionUrl = function actionUrl(_ref) {
|
|
83
|
+
var conversationId = _ref.conversationId,
|
|
84
|
+
actionId = _ref.actionId;
|
|
85
|
+
return "".concat(BASE_URL, "/conversations/").concat(encodeURIComponent(conversationId), "/actions/").concat(encodeURIComponent(actionId));
|
|
86
|
+
};
|
|
65
87
|
var fetchStatus = function fetchStatus() {
|
|
66
88
|
return axios.get("".concat(BASE_URL, "/status"), REQUEST_OPTIONS);
|
|
67
89
|
};
|
|
68
90
|
var fetchRuns = function fetchRuns(conversationId) {
|
|
69
91
|
return axios.get(runsUrl(conversationId), REQUEST_OPTIONS);
|
|
70
92
|
};
|
|
71
|
-
var createRun = function createRun(
|
|
72
|
-
var conversationId =
|
|
73
|
-
question =
|
|
74
|
-
requestId =
|
|
93
|
+
var createRun = function createRun(_ref2) {
|
|
94
|
+
var conversationId = _ref2.conversationId,
|
|
95
|
+
question = _ref2.question,
|
|
96
|
+
requestId = _ref2.requestId;
|
|
75
97
|
return axios.post(runsUrl(conversationId), {
|
|
76
98
|
run: {
|
|
77
99
|
question: question,
|
|
@@ -79,11 +101,11 @@ var createRun = function createRun(_ref) {
|
|
|
79
101
|
}
|
|
80
102
|
}, REQUEST_OPTIONS);
|
|
81
103
|
};
|
|
82
|
-
var updateFeedback = function updateFeedback(
|
|
83
|
-
var conversationId =
|
|
84
|
-
runId =
|
|
85
|
-
rating =
|
|
86
|
-
note =
|
|
104
|
+
var updateFeedback = function updateFeedback(_ref3) {
|
|
105
|
+
var conversationId = _ref3.conversationId,
|
|
106
|
+
runId = _ref3.runId,
|
|
107
|
+
rating = _ref3.rating,
|
|
108
|
+
note = _ref3.note;
|
|
87
109
|
return axios.put("".concat(runsUrl(conversationId), "/").concat(encodeURIComponent(runId), "/feedback"), {
|
|
88
110
|
feedback: {
|
|
89
111
|
rating: rating,
|
|
@@ -91,12 +113,23 @@ var updateFeedback = function updateFeedback(_ref2) {
|
|
|
91
113
|
}
|
|
92
114
|
}, REQUEST_OPTIONS);
|
|
93
115
|
};
|
|
116
|
+
|
|
117
|
+
// The host makes the change as the signed-in rep, so the request says only
|
|
118
|
+
// which action. Nothing about the change itself comes from the browser.
|
|
119
|
+
var applyAction = function applyAction(action) {
|
|
120
|
+
return axios.post("".concat(actionUrl(action), "/apply"), {}, REQUEST_OPTIONS);
|
|
121
|
+
};
|
|
122
|
+
var dismissAction = function dismissAction(action) {
|
|
123
|
+
return axios.post("".concat(actionUrl(action), "/dismiss"), {}, REQUEST_OPTIONS);
|
|
124
|
+
};
|
|
94
125
|
var neetoAssistApi = {
|
|
95
126
|
fetchStatus: fetchStatus,
|
|
96
127
|
fetchRuns: fetchRuns,
|
|
97
128
|
createRun: createRun,
|
|
98
|
-
updateFeedback: updateFeedback
|
|
129
|
+
updateFeedback: updateFeedback,
|
|
130
|
+
applyAction: applyAction,
|
|
131
|
+
dismissAction: dismissAction
|
|
99
132
|
};
|
|
100
133
|
|
|
101
|
-
export { COLLAPSED_PANE_WIDTH as C, ERROR_MESSAGE_KEYS as E, IDLE_POLL_INTERVAL as I, MAX_QUESTION_LENGTH as M, PENDING_STATUSES as P, QUERY_KEYS as Q, RATEABLE_STATUSES as R, SKIPPED_REASON_MESSAGE_KEYS as S, UNRATEABLE_SKIPPED_REASONS as U, REPLY_SUGGESTION as a, QUIET_SKIPPED_REASONS as b, PENDING_POLL_INTERVAL as c, EXPANDED_STORAGE_KEY as d, SUGGESTION_KEYS as e,
|
|
102
|
-
//# sourceMappingURL=neeto_assist-
|
|
134
|
+
export { ACTION_ERROR_MESSAGE_KEYS as A, COLLAPSED_PANE_WIDTH as C, ERROR_MESSAGE_KEYS as E, IDLE_POLL_INTERVAL as I, MAX_QUESTION_LENGTH as M, PENDING_STATUSES as P, QUERY_KEYS as Q, RATEABLE_STATUSES as R, SKIPPED_REASON_MESSAGE_KEYS as S, UNRATEABLE_SKIPPED_REASONS as U, REPLY_SUGGESTION as a, QUIET_SKIPPED_REASONS as b, PENDING_POLL_INTERVAL as c, EXPANDED_STORAGE_KEY as d, SUGGESTION_KEYS as e, SETTLED_ACTION_STATUSES as f, QUIET_ACTION_STATUS_KEYS as g, MAX_NOTE_LENGTH as h, RUN_TEST_ID as i, EXPANDED_PANE_WIDTH as j, neetoAssistApi as n };
|
|
135
|
+
//# sourceMappingURL=neeto_assist-CpUBA-3Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neeto_assist-CpUBA-3Z.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 = 2_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// What became of a suggested action. NeetoAssist has the last word on an\n// action in one of these: nothing a click says can be newer.\nexport const SETTLED_ACTION_STATUSES = [\n \"applied\",\n \"failed\",\n \"dismissed\",\n \"expired\",\n];\n\n// A suggestion nobody took up steps back to one muted line.\nexport const QUIET_ACTION_STATUS_KEYS = {\n dismissed: \"neetoAssist.actions.dismissed\",\n expired: \"neetoAssist.actions.expired\",\n};\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.writtenBefore\",\n \"neetoAssist.suggestions.whatNext\",\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\n// A click on a card that changed nothing. The other answers fall back to the\n// keys above.\nexport const ACTION_ERROR_MESSAGE_KEYS = {\n 403: \"neetoAssist.actions.errors.forbidden\",\n 503: \"neetoAssist.actions.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 actionUrl = ({ conversationId, actionId }) =>\n `${BASE_URL}/conversations/${encodeURIComponent(\n conversationId\n )}/actions/${encodeURIComponent(actionId)}`;\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\n// The host makes the change as the signed-in rep, so the request says only\n// which action. Nothing about the change itself comes from the browser.\nconst applyAction = action =>\n axios.post(`${actionUrl(action)}/apply`, {}, REQUEST_OPTIONS);\n\nconst dismissAction = action =>\n axios.post(`${actionUrl(action)}/dismiss`, {}, REQUEST_OPTIONS);\n\nconst neetoAssistApi = {\n fetchStatus,\n fetchRuns,\n createRun,\n updateFeedback,\n applyAction,\n dismissAction,\n};\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","SETTLED_ACTION_STATUSES","QUIET_ACTION_STATUS_KEYS","dismissed","expired","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","ACTION_ERROR_MESSAGE_KEYS","runsUrl","conversationId","encodeURIComponent","actionUrl","_ref","actionId","fetchStatus","axios","get","fetchRuns","createRun","_ref2","question","requestId","post","run","request_id","updateFeedback","_ref3","runId","rating","note","put","feedback","applyAction","action","dismissAction","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;IA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EAAY,EAAE,EAAEnE,eAAe,CAAC;AAAA,CAAA;AAEjE,IAAMqE,cAAc,GAAG;AACrBrB,EAAAA,WAAW,EAAXA,WAAW;AACXG,EAAAA,SAAS,EAATA,SAAS;AACTC,EAAAA,SAAS,EAATA,SAAS;AACTO,EAAAA,cAAc,EAAdA,cAAc;AACdO,EAAAA,WAAW,EAAXA,WAAW;AACXE,EAAAA,aAAa,EAAbA;AACF;;;;"}
|
|
@@ -17,11 +17,21 @@ var QUERY_KEYS = {
|
|
|
17
17
|
STATUS: "neeto-assist-status",
|
|
18
18
|
RUNS: "neeto-assist-runs"
|
|
19
19
|
};
|
|
20
|
-
var PENDING_POLL_INTERVAL =
|
|
20
|
+
var PENDING_POLL_INTERVAL = 2000;
|
|
21
21
|
var IDLE_POLL_INTERVAL = 30000;
|
|
22
22
|
var PENDING_STATUSES = ["queued", "running"];
|
|
23
23
|
var RATEABLE_STATUSES = ["completed", "skipped"];
|
|
24
24
|
|
|
25
|
+
// What became of a suggested action. NeetoAssist has the last word on an
|
|
26
|
+
// action in one of these: nothing a click says can be newer.
|
|
27
|
+
var SETTLED_ACTION_STATUSES = ["applied", "failed", "dismissed", "expired"];
|
|
28
|
+
|
|
29
|
+
// A suggestion nobody took up steps back to one muted line.
|
|
30
|
+
var QUIET_ACTION_STATUS_KEYS = {
|
|
31
|
+
dismissed: "neetoAssist.actions.dismissed",
|
|
32
|
+
expired: "neetoAssist.actions.expired"
|
|
33
|
+
};
|
|
34
|
+
|
|
25
35
|
// The skips from the workspace's quiet rules, in NeetoAssist's settings. Each
|
|
26
36
|
// one holds for every visitor message until something changes, such as the
|
|
27
37
|
// agent who owns the conversation handing it back.
|
|
@@ -39,7 +49,7 @@ var EXPANDED_PANE_WIDTH = "min(50vw, 800px)";
|
|
|
39
49
|
var EXPANDED_STORAGE_KEY = "neetoAssist.isExpanded";
|
|
40
50
|
var REPLY_SUGGESTION = "reply_suggestion";
|
|
41
51
|
var RUN_TEST_ID = "neeto-assist-run";
|
|
42
|
-
var SUGGESTION_KEYS = ["neetoAssist.suggestions.summarize", "neetoAssist.suggestions.whatToReply", "neetoAssist.suggestions.
|
|
52
|
+
var SUGGESTION_KEYS = ["neetoAssist.suggestions.summarize", "neetoAssist.suggestions.whatToReply", "neetoAssist.suggestions.writtenBefore", "neetoAssist.suggestions.whatNext"];
|
|
43
53
|
var SKIPPED_REASON_MESSAGE_KEYS = {
|
|
44
54
|
greeting: "neetoAssist.skippedReasons.greeting",
|
|
45
55
|
acknowledgment: "neetoAssist.skippedReasons.acknowledgment",
|
|
@@ -61,19 +71,31 @@ var ERROR_MESSAGE_KEYS = {
|
|
|
61
71
|
503: "neetoAssist.errors.unavailable"
|
|
62
72
|
};
|
|
63
73
|
|
|
74
|
+
// A click on a card that changed nothing. The other answers fall back to the
|
|
75
|
+
// keys above.
|
|
76
|
+
var ACTION_ERROR_MESSAGE_KEYS = {
|
|
77
|
+
403: "neetoAssist.actions.errors.forbidden",
|
|
78
|
+
503: "neetoAssist.actions.errors.unavailable"
|
|
79
|
+
};
|
|
80
|
+
|
|
64
81
|
var runsUrl = function runsUrl(conversationId) {
|
|
65
82
|
return "".concat(BASE_URL, "/conversations/").concat(encodeURIComponent(conversationId), "/runs");
|
|
66
83
|
};
|
|
84
|
+
var actionUrl = function actionUrl(_ref) {
|
|
85
|
+
var conversationId = _ref.conversationId,
|
|
86
|
+
actionId = _ref.actionId;
|
|
87
|
+
return "".concat(BASE_URL, "/conversations/").concat(encodeURIComponent(conversationId), "/actions/").concat(encodeURIComponent(actionId));
|
|
88
|
+
};
|
|
67
89
|
var fetchStatus = function fetchStatus() {
|
|
68
90
|
return axios.get("".concat(BASE_URL, "/status"), REQUEST_OPTIONS);
|
|
69
91
|
};
|
|
70
92
|
var fetchRuns = function fetchRuns(conversationId) {
|
|
71
93
|
return axios.get(runsUrl(conversationId), REQUEST_OPTIONS);
|
|
72
94
|
};
|
|
73
|
-
var createRun = function createRun(
|
|
74
|
-
var conversationId =
|
|
75
|
-
question =
|
|
76
|
-
requestId =
|
|
95
|
+
var createRun = function createRun(_ref2) {
|
|
96
|
+
var conversationId = _ref2.conversationId,
|
|
97
|
+
question = _ref2.question,
|
|
98
|
+
requestId = _ref2.requestId;
|
|
77
99
|
return axios.post(runsUrl(conversationId), {
|
|
78
100
|
run: {
|
|
79
101
|
question: question,
|
|
@@ -81,11 +103,11 @@ var createRun = function createRun(_ref) {
|
|
|
81
103
|
}
|
|
82
104
|
}, REQUEST_OPTIONS);
|
|
83
105
|
};
|
|
84
|
-
var updateFeedback = function updateFeedback(
|
|
85
|
-
var conversationId =
|
|
86
|
-
runId =
|
|
87
|
-
rating =
|
|
88
|
-
note =
|
|
106
|
+
var updateFeedback = function updateFeedback(_ref3) {
|
|
107
|
+
var conversationId = _ref3.conversationId,
|
|
108
|
+
runId = _ref3.runId,
|
|
109
|
+
rating = _ref3.rating,
|
|
110
|
+
note = _ref3.note;
|
|
89
111
|
return axios.put("".concat(runsUrl(conversationId), "/").concat(encodeURIComponent(runId), "/feedback"), {
|
|
90
112
|
feedback: {
|
|
91
113
|
rating: rating,
|
|
@@ -93,13 +115,25 @@ var updateFeedback = function updateFeedback(_ref2) {
|
|
|
93
115
|
}
|
|
94
116
|
}, REQUEST_OPTIONS);
|
|
95
117
|
};
|
|
118
|
+
|
|
119
|
+
// The host makes the change as the signed-in rep, so the request says only
|
|
120
|
+
// which action. Nothing about the change itself comes from the browser.
|
|
121
|
+
var applyAction = function applyAction(action) {
|
|
122
|
+
return axios.post("".concat(actionUrl(action), "/apply"), {}, REQUEST_OPTIONS);
|
|
123
|
+
};
|
|
124
|
+
var dismissAction = function dismissAction(action) {
|
|
125
|
+
return axios.post("".concat(actionUrl(action), "/dismiss"), {}, REQUEST_OPTIONS);
|
|
126
|
+
};
|
|
96
127
|
var neetoAssistApi = {
|
|
97
128
|
fetchStatus: fetchStatus,
|
|
98
129
|
fetchRuns: fetchRuns,
|
|
99
130
|
createRun: createRun,
|
|
100
|
-
updateFeedback: updateFeedback
|
|
131
|
+
updateFeedback: updateFeedback,
|
|
132
|
+
applyAction: applyAction,
|
|
133
|
+
dismissAction: dismissAction
|
|
101
134
|
};
|
|
102
135
|
|
|
136
|
+
exports.ACTION_ERROR_MESSAGE_KEYS = ACTION_ERROR_MESSAGE_KEYS;
|
|
103
137
|
exports.COLLAPSED_PANE_WIDTH = COLLAPSED_PANE_WIDTH;
|
|
104
138
|
exports.ERROR_MESSAGE_KEYS = ERROR_MESSAGE_KEYS;
|
|
105
139
|
exports.EXPANDED_PANE_WIDTH = EXPANDED_PANE_WIDTH;
|
|
@@ -110,12 +144,14 @@ exports.MAX_QUESTION_LENGTH = MAX_QUESTION_LENGTH;
|
|
|
110
144
|
exports.PENDING_POLL_INTERVAL = PENDING_POLL_INTERVAL;
|
|
111
145
|
exports.PENDING_STATUSES = PENDING_STATUSES;
|
|
112
146
|
exports.QUERY_KEYS = QUERY_KEYS;
|
|
147
|
+
exports.QUIET_ACTION_STATUS_KEYS = QUIET_ACTION_STATUS_KEYS;
|
|
113
148
|
exports.QUIET_SKIPPED_REASONS = QUIET_SKIPPED_REASONS;
|
|
114
149
|
exports.RATEABLE_STATUSES = RATEABLE_STATUSES;
|
|
115
150
|
exports.REPLY_SUGGESTION = REPLY_SUGGESTION;
|
|
116
151
|
exports.RUN_TEST_ID = RUN_TEST_ID;
|
|
152
|
+
exports.SETTLED_ACTION_STATUSES = SETTLED_ACTION_STATUSES;
|
|
117
153
|
exports.SKIPPED_REASON_MESSAGE_KEYS = SKIPPED_REASON_MESSAGE_KEYS;
|
|
118
154
|
exports.SUGGESTION_KEYS = SUGGESTION_KEYS;
|
|
119
155
|
exports.UNRATEABLE_SKIPPED_REASONS = UNRATEABLE_SKIPPED_REASONS;
|
|
120
156
|
exports.neetoAssistApi = neetoAssistApi;
|
|
121
|
-
//# sourceMappingURL=neeto_assist-
|
|
157
|
+
//# sourceMappingURL=neeto_assist-CznTN_YY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neeto_assist-CznTN_YY.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 = 2_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// What became of a suggested action. NeetoAssist has the last word on an\n// action in one of these: nothing a click says can be newer.\nexport const SETTLED_ACTION_STATUSES = [\n \"applied\",\n \"failed\",\n \"dismissed\",\n \"expired\",\n];\n\n// A suggestion nobody took up steps back to one muted line.\nexport const QUIET_ACTION_STATUS_KEYS = {\n dismissed: \"neetoAssist.actions.dismissed\",\n expired: \"neetoAssist.actions.expired\",\n};\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.writtenBefore\",\n \"neetoAssist.suggestions.whatNext\",\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\n// A click on a card that changed nothing. The other answers fall back to the\n// keys above.\nexport const ACTION_ERROR_MESSAGE_KEYS = {\n 403: \"neetoAssist.actions.errors.forbidden\",\n 503: \"neetoAssist.actions.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 actionUrl = ({ conversationId, actionId }) =>\n `${BASE_URL}/conversations/${encodeURIComponent(\n conversationId\n )}/actions/${encodeURIComponent(actionId)}`;\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\n// The host makes the change as the signed-in rep, so the request says only\n// which action. Nothing about the change itself comes from the browser.\nconst applyAction = action =>\n axios.post(`${actionUrl(action)}/apply`, {}, REQUEST_OPTIONS);\n\nconst dismissAction = action =>\n axios.post(`${actionUrl(action)}/dismiss`, {}, REQUEST_OPTIONS);\n\nconst neetoAssistApi = {\n fetchStatus,\n fetchRuns,\n createRun,\n updateFeedback,\n applyAction,\n dismissAction,\n};\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","SETTLED_ACTION_STATUSES","QUIET_ACTION_STATUS_KEYS","dismissed","expired","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","ACTION_ERROR_MESSAGE_KEYS","runsUrl","conversationId","encodeURIComponent","actionUrl","_ref","actionId","fetchStatus","axios","get","fetchRuns","createRun","_ref2","question","requestId","post","run","request_id","updateFeedback","_ref3","runId","rating","note","put","feedback","applyAction","action","dismissAction","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;AACO,IAAMC,uBAAuB,GAAG,CACrC,SAAS,EACT,QAAQ,EACR,WAAW,EACX,SAAS;;AAGX;AACO,IAAMC,wBAAwB,GAAG;AACtCC,EAAAA,SAAS,EAAE,+BAA+B;AAC1CC,EAAAA,OAAO,EAAE;AACX;;AAEA;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,GAAG;AAE5B,IAAMC,oBAAoB,GAAG;AAE7B,IAAMC,gBAAgB,GAAG;A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AAK,CAAC,EAAA,WAAA,CAAA,EACvD;AAAEI,IAAAA,QAAQ,EAAE;AAAEH,MAAAA,MAAM,EAANA,MAAM;AAAEC,MAAAA,IAAI,EAAJA;AAAK;GAAG,EAC9B/D,eACF,CAAC;AAAA,CAAA;;AAEH;AACA;AACA,IAAMkE,WAAW,GAAG,SAAdA,WAAWA,CAAGC,MAAM,EAAA;AAAA,EAAA,OACxBlB,KAAK,CAACO,IAAI,CAAA,EAAA,CAAAtC,MAAA,CAAI2B,SAAS,CAACsB,MAAM,CAAC,EAAA,QAAA,CAAA,EAAU,EAAE,EAAEnE,eAAe,CAAC;AAAA,CAAA;AAE/D,IAAMoE,aAAa,GAAG,SAAhBA,aAAaA,CAAGD,MAAM,EAAA;AAAA,EAAA,OAC1BlB,KAAK,CAACO,IAAI,CAAA,EAAA,CAAAtC,MAAA,CAAI2B,SAAS,CAACsB,MAAM,CAAC,EAAA,UAAA,CAAA,EAAY,EAAE,EAAEnE,eAAe,CAAC;AAAA,CAAA;AAEjE,IAAMqE,cAAc,GAAG;AACrBrB,EAAAA,WAAW,EAAXA,WAAW;AACXG,EAAAA,SAAS,EAATA,SAAS;AACTC,EAAAA,SAAS,EAATA,SAAS;AACTO,EAAAA,cAAc,EAAdA,cAAc;AACdO,EAAAA,WAAW,EAAXA,WAAW;AACXE,EAAAA,aAAa,EAAbA;AACF;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import { n as neetoAssistApi, Q as QUERY_KEYS } from './neeto_assist-
|
|
2
|
+
import { n as neetoAssistApi, Q as QUERY_KEYS } from './neeto_assist-CpUBA-3Z.js';
|
|
3
3
|
import 'axios';
|
|
4
4
|
|
|
5
5
|
// Answers every signed-in rep with { enabled }. A failure shows nothing to the
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
-
import { useQuery } from '@tanstack/react-query';
|
|
4
|
+
import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
|
|
5
5
|
import { useMutationWithInvalidation, withImmutableActions } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
|
|
6
|
-
import { E as ERROR_MESSAGE_KEYS, P as PENDING_STATUSES, S as SKIPPED_REASON_MESSAGE_KEYS, R as RATEABLE_STATUSES, U as UNRATEABLE_SKIPPED_REASONS, a as REPLY_SUGGESTION, b as QUIET_SKIPPED_REASONS, n as neetoAssistApi, Q as QUERY_KEYS, c as PENDING_POLL_INTERVAL, I as IDLE_POLL_INTERVAL, d as EXPANDED_STORAGE_KEY } from './neeto_assist-
|
|
7
|
-
import { propOr, reverse } from 'ramda';
|
|
6
|
+
import { E as ERROR_MESSAGE_KEYS, P as PENDING_STATUSES, S as SKIPPED_REASON_MESSAGE_KEYS, R as RATEABLE_STATUSES, U as UNRATEABLE_SKIPPED_REASONS, a as REPLY_SUGGESTION, b as QUIET_SKIPPED_REASONS, n as neetoAssistApi, Q as QUERY_KEYS, c as PENDING_POLL_INTERVAL, I as IDLE_POLL_INTERVAL, d as EXPANDED_STORAGE_KEY } from './neeto_assist-CpUBA-3Z.js';
|
|
7
|
+
import { propOr, any, propEq, reverse } from 'ramda';
|
|
8
8
|
import { setToLocalStorage, getFromLocalStorage } from '@bigbinary/neeto-commons-frontend/v2/utils';
|
|
9
9
|
import { create } from 'zustand';
|
|
10
10
|
|
|
11
11
|
var _excluded = ["size", "className"];
|
|
12
|
-
function ownKeys$
|
|
13
|
-
function _objectSpread$
|
|
12
|
+
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
14
|
var Sparkle = function Sparkle(_ref) {
|
|
15
15
|
var _ref$size = _ref.size,
|
|
16
16
|
size = _ref$size === void 0 ? 18 : _ref$size,
|
|
17
17
|
className = _ref.className,
|
|
18
18
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
-
return /*#__PURE__*/jsxs("svg", _objectSpread$
|
|
19
|
+
return /*#__PURE__*/jsxs("svg", _objectSpread$2(_objectSpread$2({
|
|
20
20
|
className: className,
|
|
21
21
|
"aria-hidden": "true",
|
|
22
22
|
fill: "none",
|
|
@@ -99,10 +99,33 @@ var isRateable = function isRateable(_ref5) {
|
|
|
99
99
|
skippedReason = _ref5.skippedReason;
|
|
100
100
|
return RATEABLE_STATUSES.includes(status) && !UNRATEABLE_SKIPPED_REASONS.includes(skippedReason) && !(kind === "ask" && status === "skipped");
|
|
101
101
|
};
|
|
102
|
+
|
|
103
|
+
// What the pane polls quickly for: a run NeetoAssist is still working on. An
|
|
104
|
+
// action someone is applying is not one. The rep who clicked has the answer
|
|
105
|
+
// to the click, and an action whose end NeetoAssist never hears of would keep
|
|
106
|
+
// every open pane polling quickly until NeetoAssist gives up on it.
|
|
102
107
|
var hasPendingRun = function hasPendingRun() {
|
|
103
108
|
var runs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
104
109
|
return runs.some(isPending);
|
|
105
110
|
};
|
|
111
|
+
|
|
112
|
+
// The lookups NeetoAssist made while answering, in the order they started. A
|
|
113
|
+
// run from an older NeetoAssist carries none.
|
|
114
|
+
var stepsOf = function stepsOf(_ref6) {
|
|
115
|
+
var steps = _ref6.steps;
|
|
116
|
+
return steps !== null && steps !== void 0 ? steps : [];
|
|
117
|
+
};
|
|
118
|
+
var hasRunningStep = function hasRunningStep(run) {
|
|
119
|
+
return any(propEq("running", "status"), stepsOf(run));
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// A suggested action can only be applied once its run has finished. Until then
|
|
123
|
+
// NeetoAssist may still take it back and start over, so its card waits.
|
|
124
|
+
var actionsOf = function actionsOf(_ref7) {
|
|
125
|
+
var status = _ref7.status,
|
|
126
|
+
actions = _ref7.actions;
|
|
127
|
+
return status === "completed" ? actions !== null && actions !== void 0 ? actions : [] : [];
|
|
128
|
+
};
|
|
106
129
|
var skippedReasonMessageKey = function skippedReasonMessageKey(reason) {
|
|
107
130
|
return propOr("neetoAssist.run.skipped", reason, SKIPPED_REASON_MESSAGE_KEYS);
|
|
108
131
|
};
|
|
@@ -118,6 +141,9 @@ var isWebUrl = function isWebUrl(url) {
|
|
|
118
141
|
return /^https?:\/\//i.test(url !== null && url !== void 0 ? url : "");
|
|
119
142
|
};
|
|
120
143
|
|
|
144
|
+
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
145
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
146
|
+
|
|
121
147
|
// Fresh on every mount, then polled: quickly while NeetoAssist is working on a
|
|
122
148
|
// run, slowly otherwise. A failed poll is retried by the next one and never
|
|
123
149
|
// shown as a toast. Comes with the workspace's credit state.
|
|
@@ -158,6 +184,39 @@ var useUpdateFeedback = function useUpdateFeedback(conversationId) {
|
|
|
158
184
|
});
|
|
159
185
|
};
|
|
160
186
|
|
|
187
|
+
// A click on a card changes what its run shows whether it worked or not: the
|
|
188
|
+
// action was applied, or someone else got to it first, or it expired. So the
|
|
189
|
+
// runs are fetched again either way. The card does not wait for them: the
|
|
190
|
+
// answer to the click already says what happened.
|
|
191
|
+
var useActOnAction = function useActOnAction(mutationFn, conversationId) {
|
|
192
|
+
var callbacks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
193
|
+
var queryClient = useQueryClient();
|
|
194
|
+
return useMutation(_objectSpread$1({
|
|
195
|
+
mutationFn: mutationFn,
|
|
196
|
+
onSettled: function onSettled() {
|
|
197
|
+
queryClient.invalidateQueries({
|
|
198
|
+
queryKey: [QUERY_KEYS.RUNS, conversationId]
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}, callbacks));
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
// The host hears of an applied action from here and not from the card that
|
|
205
|
+
// was clicked. React Query drops what a card hands to mutate once the card is
|
|
206
|
+
// off the screen, as when the rep opens another conversation before the answer
|
|
207
|
+
// arrives, and the change was made all the same. The click does not wait for
|
|
208
|
+
// the host's handler, so what the handler returns is left alone.
|
|
209
|
+
var useApplyAction = function useApplyAction(conversationId, onApplied) {
|
|
210
|
+
return useActOnAction(neetoAssistApi.applyAction, conversationId, {
|
|
211
|
+
onSuccess: function onSuccess(data) {
|
|
212
|
+
onApplied === null || onApplied === void 0 || onApplied(data === null || data === void 0 ? void 0 : data.action);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
var useDismissAction = function useDismissAction(conversationId) {
|
|
217
|
+
return useActOnAction(neetoAssistApi.dismissAction, conversationId);
|
|
218
|
+
};
|
|
219
|
+
|
|
161
220
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
162
221
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
163
222
|
|
|
@@ -214,5 +273,5 @@ var useNeetoAssistStore = create(withImmutableActions(function (set) {
|
|
|
214
273
|
};
|
|
215
274
|
}));
|
|
216
275
|
|
|
217
|
-
export { Sparkle as S, useFetchRuns as a, useAskNeetoAssist as b,
|
|
218
|
-
//# sourceMappingURL=useNeetoAssistStore
|
|
276
|
+
export { Sparkle as S, useFetchRuns as a, useAskNeetoAssist as b, useApplyAction as c, useDismissAction as d, errorMessageKey as e, actionsOf as f, useUpdateFeedback as g, isPending as h, isWebUrl as i, hasRunningStep as j, hasWrittenReply as k, latestDraftId as l, skippedReasonMessageKey as m, isRateable as n, runsInConversationOrder as r, stepsOf as s, useNeetoAssistStore as u };
|
|
277
|
+
//# sourceMappingURL=useNeetoAssistStore--JwP_Upt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNeetoAssistStore--JwP_Upt.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,G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AY,EAAA;AAAA,MAAA,OAAIL,GAAG,CAAC;AAAEK,QAAAA,YAAY,EAAZA;AAAa,OAAC,CAAC;AAAA,IAAA,CAAA;AAEtD;AACA;AACAQ,IAAAA,iBAAiB,EAAE,SAAnBA,iBAAiBA,CAAEzD,cAAc,EAAA;MAAA,OAC/B4C,GAAG,CAAC,UAAA5B,KAAK,EAAA;AAAA,QAAA,IAAA0C,mBAAA;AAAA,QAAA,OACP,CAAA,CAAAA,mBAAA,GAAA1C,KAAK,CAACiC,YAAY,MAAA,IAAA,IAAAS,mBAAA,KAAA,MAAA,GAAA,MAAA,GAAlBA,mBAAA,CAAoB3F,EAAE,MAAKiC,cAAc,GAAG;AAAEiD,UAAAA,YAAY,EAAE;SAAM,GAAG,EAAE;AAAA,MAAA,CACzE,CAAC;AAAA,IAAA,CAAA;AAEHU,IAAAA,aAAa,EAAE,SAAfA,aAAaA,CAAG3D,cAAc,EAAE4D,KAAK,EAAA;MAAA,OACnChB,GAAG,CAAC,UAAA5B,KAAK,EAAA;QAAA,OAAK;AACZkC,UAAAA,UAAU,EAAA3H,aAAA,CAAAA,aAAA,CAAA,EAAA,EAAOyF,KAAK,CAACkC,UAAU,CAAA,EAAA,EAAA,EAAAW,eAAA,CAAA,EAAA,EAAG7D,cAAc,EAAG4D,KAAK,CAAA;SAC3D;AAAA,MAAA,CAAC,CAAC;AAAA,IAAA;GACN;AAAA,CAAC,CACJ;;;;"}
|
|
@@ -5,20 +5,20 @@ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProp
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var reactQuery = require('@tanstack/react-query');
|
|
7
7
|
var reactUtils = require('@bigbinary/neeto-commons-frontend/v2/react-utils');
|
|
8
|
-
var neeto_assist = require('./neeto_assist-
|
|
8
|
+
var neeto_assist = require('./neeto_assist-CznTN_YY.js');
|
|
9
9
|
var ramda = require('ramda');
|
|
10
10
|
var utils = require('@bigbinary/neeto-commons-frontend/v2/utils');
|
|
11
11
|
var zustand = require('zustand');
|
|
12
12
|
|
|
13
13
|
var _excluded = ["size", "className"];
|
|
14
|
-
function ownKeys$
|
|
15
|
-
function _objectSpread$
|
|
14
|
+
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
16
|
var Sparkle = function Sparkle(_ref) {
|
|
17
17
|
var _ref$size = _ref.size,
|
|
18
18
|
size = _ref$size === void 0 ? 18 : _ref$size,
|
|
19
19
|
className = _ref.className,
|
|
20
20
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
21
|
-
return /*#__PURE__*/jsxRuntime.jsxs("svg", _objectSpread$
|
|
21
|
+
return /*#__PURE__*/jsxRuntime.jsxs("svg", _objectSpread$2(_objectSpread$2({
|
|
22
22
|
className: className,
|
|
23
23
|
"aria-hidden": "true",
|
|
24
24
|
fill: "none",
|
|
@@ -101,10 +101,33 @@ var isRateable = function isRateable(_ref5) {
|
|
|
101
101
|
skippedReason = _ref5.skippedReason;
|
|
102
102
|
return neeto_assist.RATEABLE_STATUSES.includes(status) && !neeto_assist.UNRATEABLE_SKIPPED_REASONS.includes(skippedReason) && !(kind === "ask" && status === "skipped");
|
|
103
103
|
};
|
|
104
|
+
|
|
105
|
+
// What the pane polls quickly for: a run NeetoAssist is still working on. An
|
|
106
|
+
// action someone is applying is not one. The rep who clicked has the answer
|
|
107
|
+
// to the click, and an action whose end NeetoAssist never hears of would keep
|
|
108
|
+
// every open pane polling quickly until NeetoAssist gives up on it.
|
|
104
109
|
var hasPendingRun = function hasPendingRun() {
|
|
105
110
|
var runs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
106
111
|
return runs.some(isPending);
|
|
107
112
|
};
|
|
113
|
+
|
|
114
|
+
// The lookups NeetoAssist made while answering, in the order they started. A
|
|
115
|
+
// run from an older NeetoAssist carries none.
|
|
116
|
+
var stepsOf = function stepsOf(_ref6) {
|
|
117
|
+
var steps = _ref6.steps;
|
|
118
|
+
return steps !== null && steps !== void 0 ? steps : [];
|
|
119
|
+
};
|
|
120
|
+
var hasRunningStep = function hasRunningStep(run) {
|
|
121
|
+
return ramda.any(ramda.propEq("running", "status"), stepsOf(run));
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// A suggested action can only be applied once its run has finished. Until then
|
|
125
|
+
// NeetoAssist may still take it back and start over, so its card waits.
|
|
126
|
+
var actionsOf = function actionsOf(_ref7) {
|
|
127
|
+
var status = _ref7.status,
|
|
128
|
+
actions = _ref7.actions;
|
|
129
|
+
return status === "completed" ? actions !== null && actions !== void 0 ? actions : [] : [];
|
|
130
|
+
};
|
|
108
131
|
var skippedReasonMessageKey = function skippedReasonMessageKey(reason) {
|
|
109
132
|
return ramda.propOr("neetoAssist.run.skipped", reason, neeto_assist.SKIPPED_REASON_MESSAGE_KEYS);
|
|
110
133
|
};
|
|
@@ -120,6 +143,9 @@ var isWebUrl = function isWebUrl(url) {
|
|
|
120
143
|
return /^https?:\/\//i.test(url !== null && url !== void 0 ? url : "");
|
|
121
144
|
};
|
|
122
145
|
|
|
146
|
+
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
147
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
148
|
+
|
|
123
149
|
// Fresh on every mount, then polled: quickly while NeetoAssist is working on a
|
|
124
150
|
// run, slowly otherwise. A failed poll is retried by the next one and never
|
|
125
151
|
// shown as a toast. Comes with the workspace's credit state.
|
|
@@ -160,6 +186,39 @@ var useUpdateFeedback = function useUpdateFeedback(conversationId) {
|
|
|
160
186
|
});
|
|
161
187
|
};
|
|
162
188
|
|
|
189
|
+
// A click on a card changes what its run shows whether it worked or not: the
|
|
190
|
+
// action was applied, or someone else got to it first, or it expired. So the
|
|
191
|
+
// runs are fetched again either way. The card does not wait for them: the
|
|
192
|
+
// answer to the click already says what happened.
|
|
193
|
+
var useActOnAction = function useActOnAction(mutationFn, conversationId) {
|
|
194
|
+
var callbacks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
195
|
+
var queryClient = reactQuery.useQueryClient();
|
|
196
|
+
return reactQuery.useMutation(_objectSpread$1({
|
|
197
|
+
mutationFn: mutationFn,
|
|
198
|
+
onSettled: function onSettled() {
|
|
199
|
+
queryClient.invalidateQueries({
|
|
200
|
+
queryKey: [neeto_assist.QUERY_KEYS.RUNS, conversationId]
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}, callbacks));
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
// The host hears of an applied action from here and not from the card that
|
|
207
|
+
// was clicked. React Query drops what a card hands to mutate once the card is
|
|
208
|
+
// off the screen, as when the rep opens another conversation before the answer
|
|
209
|
+
// arrives, and the change was made all the same. The click does not wait for
|
|
210
|
+
// the host's handler, so what the handler returns is left alone.
|
|
211
|
+
var useApplyAction = function useApplyAction(conversationId, onApplied) {
|
|
212
|
+
return useActOnAction(neeto_assist.neetoAssistApi.applyAction, conversationId, {
|
|
213
|
+
onSuccess: function onSuccess(data) {
|
|
214
|
+
onApplied === null || onApplied === void 0 || onApplied(data === null || data === void 0 ? void 0 : data.action);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
var useDismissAction = function useDismissAction(conversationId) {
|
|
219
|
+
return useActOnAction(neeto_assist.neetoAssistApi.dismissAction, conversationId);
|
|
220
|
+
};
|
|
221
|
+
|
|
163
222
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
164
223
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
165
224
|
|
|
@@ -217,7 +276,9 @@ var useNeetoAssistStore = zustand.create(reactUtils.withImmutableActions(functio
|
|
|
217
276
|
}));
|
|
218
277
|
|
|
219
278
|
exports.Sparkle = Sparkle;
|
|
279
|
+
exports.actionsOf = actionsOf;
|
|
220
280
|
exports.errorMessageKey = errorMessageKey;
|
|
281
|
+
exports.hasRunningStep = hasRunningStep;
|
|
221
282
|
exports.hasWrittenReply = hasWrittenReply;
|
|
222
283
|
exports.isPending = isPending;
|
|
223
284
|
exports.isRateable = isRateable;
|
|
@@ -225,8 +286,11 @@ exports.isWebUrl = isWebUrl;
|
|
|
225
286
|
exports.latestDraftId = latestDraftId;
|
|
226
287
|
exports.runsInConversationOrder = runsInConversationOrder;
|
|
227
288
|
exports.skippedReasonMessageKey = skippedReasonMessageKey;
|
|
289
|
+
exports.stepsOf = stepsOf;
|
|
290
|
+
exports.useApplyAction = useApplyAction;
|
|
228
291
|
exports.useAskNeetoAssist = useAskNeetoAssist;
|
|
292
|
+
exports.useDismissAction = useDismissAction;
|
|
229
293
|
exports.useFetchRuns = useFetchRuns;
|
|
230
294
|
exports.useNeetoAssistStore = useNeetoAssistStore;
|
|
231
295
|
exports.useUpdateFeedback = useUpdateFeedback;
|
|
232
|
-
//# sourceMappingURL=useNeetoAssistStore-
|
|
296
|
+
//# sourceMappingURL=useNeetoAssistStore-CGEUMbes.js.map
|