@bigbinary/neeto-assist-frontend 1.0.1 → 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/ar.json +73 -0
- package/app/javascript/src/translations/bg.json +73 -0
- package/app/javascript/src/translations/ca.json +73 -0
- package/app/javascript/src/translations/cs.json +73 -0
- package/app/javascript/src/translations/da.json +73 -0
- package/app/javascript/src/translations/de.json +73 -0
- package/app/javascript/src/translations/en.json +26 -4
- package/app/javascript/src/translations/es-MX.json +73 -0
- package/app/javascript/src/translations/es.json +73 -0
- package/app/javascript/src/translations/et.json +73 -0
- package/app/javascript/src/translations/fi.json +73 -0
- package/app/javascript/src/translations/fil.json +73 -0
- package/app/javascript/src/translations/fr.json +73 -0
- package/app/javascript/src/translations/he.json +73 -0
- package/app/javascript/src/translations/hi.json +73 -0
- package/app/javascript/src/translations/hr.json +73 -0
- package/app/javascript/src/translations/hu.json +73 -0
- package/app/javascript/src/translations/id.json +73 -0
- package/app/javascript/src/translations/it.json +73 -0
- package/app/javascript/src/translations/ja.json +73 -0
- package/app/javascript/src/translations/ko.json +73 -0
- package/app/javascript/src/translations/lv.json +75 -0
- package/app/javascript/src/translations/nl.json +73 -0
- package/app/javascript/src/translations/pl.json +73 -0
- package/app/javascript/src/translations/pt-BR.json +73 -0
- package/app/javascript/src/translations/pt.json +73 -0
- package/app/javascript/src/translations/ro.json +73 -0
- package/app/javascript/src/translations/ru.json +73 -0
- package/app/javascript/src/translations/sk.json +73 -0
- package/app/javascript/src/translations/sl.json +73 -0
- package/app/javascript/src/translations/sv.json +73 -0
- package/app/javascript/src/translations/th.json +73 -0
- package/app/javascript/src/translations/tr.json +73 -0
- package/app/javascript/src/translations/uk.json +73 -0
- package/app/javascript/src/translations/vi.json +73 -0
- package/app/javascript/src/translations/zh-CN.json +73 -0
- package/app/javascript/src/translations/zh-TW.json +73 -0
- 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
package/dist/NeetoAssistPane.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { i as isWebUrl, e as errorMessageKey, b as useAskNeetoAssist, c as
|
|
2
|
-
import
|
|
3
|
-
import { Typography, Textarea, Spinner,
|
|
4
|
-
import { isEmpty } from 'ramda';
|
|
5
|
-
import { e as SUGGESTION_KEYS, M as MAX_QUESTION_LENGTH, f as MAX_NOTE_LENGTH, g as RUN_TEST_ID, h as EXPANDED_PANE_WIDTH, C as COLLAPSED_PANE_WIDTH } from './neeto_assist-Ha049T0Q.js';
|
|
6
|
-
import { withT } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
|
|
7
|
-
import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
1
|
+
import { i as isWebUrl, e as errorMessageKey, b as useAskNeetoAssist, c as useApplyAction, d as useDismissAction, f as actionsOf, g as useUpdateFeedback, s as stepsOf, h as isPending, j as hasRunningStep, k as hasWrittenReply, m as skippedReasonMessageKey, n as isRateable, u as useNeetoAssistStore, a as useFetchRuns, l as latestDraftId, r as runsInConversationOrder, S as Sparkle } from './useNeetoAssistStore--JwP_Upt.js';
|
|
2
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
+
import { Typography, Textarea, Spinner, Button, typographyVariants, Tooltip, Badge } from '@bigbinary/neeto-atoms';
|
|
8
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
6
|
+
import { useState, useRef, createElement, Fragment as Fragment$1, useEffect } from 'react';
|
|
7
|
+
import { propOr, prop, isEmpty, not } from 'ramda';
|
|
8
|
+
import { e as SUGGESTION_KEYS, M as MAX_QUESTION_LENGTH, A as ACTION_ERROR_MESSAGE_KEYS, f as SETTLED_ACTION_STATUSES, g as QUIET_ACTION_STATUS_KEYS, h as MAX_NOTE_LENGTH, i as RUN_TEST_ID, j as EXPANDED_PANE_WIDTH, C as COLLAPSED_PANE_WIDTH } from './neeto_assist-CpUBA-3Z.js';
|
|
9
|
+
import { withT } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
|
|
9
10
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
10
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
11
11
|
import classNames from 'classnames';
|
|
12
|
-
import { CircleArrowUp, ExternalLink, CornerDownLeft, Copy, ThumbsUp, ThumbsDown, Minimize2, Maximize2
|
|
12
|
+
import { CircleArrowUp, Check, ExternalLink, CornerDownLeft, Copy, ThumbsUp, ThumbsDown, X, ChevronUp, ChevronDown, Minimize2, Maximize2 } from 'lucide-react';
|
|
13
13
|
import { isNotEmpty } from '@bigbinary/neeto-cist';
|
|
14
14
|
import { copyToClipboard } from '@bigbinary/neeto-commons-frontend/v2/utils';
|
|
15
15
|
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
@@ -19,8 +19,39 @@ import 'axios';
|
|
|
19
19
|
|
|
20
20
|
var HEADER_ICON_SIZE = 18;
|
|
21
21
|
var SEND_ICON_SIZE = 24;
|
|
22
|
+
|
|
23
|
+
// The size of the small spinner, so a check or a cross lines up with one.
|
|
24
|
+
var STATUS_ICON_SIZE = 12;
|
|
22
25
|
var SCROLL_MARGIN = 8;
|
|
23
26
|
|
|
27
|
+
// How far down the window a finished run's reply starts at most, as a part of
|
|
28
|
+
// the window's height.
|
|
29
|
+
var REPLY_STARTS_WITHIN = 1 / 3;
|
|
30
|
+
|
|
31
|
+
// Stands where the host's label goes while the sentence around it is
|
|
32
|
+
// translated.
|
|
33
|
+
var CONTEXT_LABEL_SLOT = "\0";
|
|
34
|
+
|
|
35
|
+
var ContextLabel = function ContextLabel(_ref) {
|
|
36
|
+
var label = _ref.label;
|
|
37
|
+
var _useTranslation = useTranslation(),
|
|
38
|
+
t = _useTranslation.t;
|
|
39
|
+
var _t$split = t("neetoAssist.lookingAt", {
|
|
40
|
+
label: CONTEXT_LABEL_SLOT
|
|
41
|
+
}).split(CONTEXT_LABEL_SLOT),
|
|
42
|
+
_t$split2 = _slicedToArray(_t$split, 2),
|
|
43
|
+
before = _t$split2[0],
|
|
44
|
+
after = _t$split2[1];
|
|
45
|
+
return /*#__PURE__*/jsxs(Typography, {
|
|
46
|
+
className: "border-border truncate border-b px-4 py-2",
|
|
47
|
+
color: "muted",
|
|
48
|
+
"data-testid": "neeto-assist-context-label",
|
|
49
|
+
title: label,
|
|
50
|
+
variant: "body3",
|
|
51
|
+
children: [before, label, after]
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
24
55
|
var CreditsBanner$1 = function CreditsBanner(_ref) {
|
|
25
56
|
var credits = _ref.credits,
|
|
26
57
|
t = _ref.t;
|
|
@@ -124,8 +155,8 @@ var EmptyState = function EmptyState(_ref) {
|
|
|
124
155
|
});
|
|
125
156
|
};
|
|
126
157
|
|
|
127
|
-
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; }
|
|
128
|
-
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; }
|
|
158
|
+
function ownKeys$3(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; }
|
|
159
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
129
160
|
var MessageInput = function MessageInput(_ref) {
|
|
130
161
|
var conversationId = _ref.conversationId;
|
|
131
162
|
var _useTranslation = useTranslation(),
|
|
@@ -154,7 +185,7 @@ var MessageInput = function MessageInput(_ref) {
|
|
|
154
185
|
requestId: newRequestId()
|
|
155
186
|
};
|
|
156
187
|
}
|
|
157
|
-
ask(_objectSpread({
|
|
188
|
+
ask(_objectSpread$3({
|
|
158
189
|
conversationId: conversationId
|
|
159
190
|
}, requestRef.current), {
|
|
160
191
|
onSuccess: function onSuccess() {
|
|
@@ -222,6 +253,281 @@ var MessageInput = function MessageInput(_ref) {
|
|
|
222
253
|
});
|
|
223
254
|
};
|
|
224
255
|
|
|
256
|
+
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; }
|
|
257
|
+
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; }
|
|
258
|
+
var isSettled = function isSettled(_ref) {
|
|
259
|
+
var status = _ref.status;
|
|
260
|
+
return SETTLED_ACTION_STATUSES.includes(status);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// What the answer to a click says became of the action. A 200 carries the
|
|
264
|
+
// action as it is now, and so does a 409 when someone else got to it first. A
|
|
265
|
+
// 422 on Apply means the host refused the change or could not make it, with a
|
|
266
|
+
// sentence that says why.
|
|
267
|
+
var answeredAction = function answeredAction(_ref2) {
|
|
268
|
+
var _error$response;
|
|
269
|
+
var isApply = _ref2.isApply,
|
|
270
|
+
data = _ref2.data,
|
|
271
|
+
error = _ref2.error;
|
|
272
|
+
if (!error) return data === null || data === void 0 ? void 0 : data.action;
|
|
273
|
+
var _ref3 = (_error$response = error.response) !== null && _error$response !== void 0 ? _error$response : {},
|
|
274
|
+
status = _ref3.status,
|
|
275
|
+
body = _ref3.data;
|
|
276
|
+
if (status === 409) return body === null || body === void 0 ? void 0 : body.action;
|
|
277
|
+
if (status === 422 && isApply) {
|
|
278
|
+
var _body$message, _body$action;
|
|
279
|
+
return _objectSpread$2(_objectSpread$2({}, body === null || body === void 0 ? void 0 : body.action), {}, {
|
|
280
|
+
status: "failed",
|
|
281
|
+
error: (_body$message = body === null || body === void 0 ? void 0 : body.message) !== null && _body$message !== void 0 ? _body$message : body === null || body === void 0 || (_body$action = body.action) === null || _body$action === void 0 ? void 0 : _body$action.error
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
return undefined;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// A card shows what NeetoAssist says about its action, with one exception: the
|
|
288
|
+
// answer to the rep's own click settles it at once, before the runs are fetched
|
|
289
|
+
// again. That also holds when NeetoAssist never heard how an apply ended and
|
|
290
|
+
// goes on saying the action is being applied.
|
|
291
|
+
var shownAction = function shownAction(action, answer) {
|
|
292
|
+
if (!answer || isSettled(action)) return action;
|
|
293
|
+
var answered = answeredAction(answer);
|
|
294
|
+
return answered && isSettled(answered) ? _objectSpread$2(_objectSpread$2({}, action), answered) : action;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
// The words under the buttons after a click that changed nothing. A 409 has
|
|
298
|
+
// none: the action changed while the card was on screen, and the runs fetched
|
|
299
|
+
// after the click show what became of it. Nor has a 422 on Apply, which the
|
|
300
|
+
// card shows as failed. No answer at all means the request never reached
|
|
301
|
+
// NeetoAssist.
|
|
302
|
+
var answerErrorMessageKey = function answerErrorMessageKey(answer) {
|
|
303
|
+
var _error$response$statu, _error$response2;
|
|
304
|
+
if (!(answer !== null && answer !== void 0 && answer.error)) return null;
|
|
305
|
+
var isApply = answer.isApply,
|
|
306
|
+
error = answer.error;
|
|
307
|
+
var status = (_error$response$statu = (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) !== null && _error$response$statu !== void 0 ? _error$response$statu : 503;
|
|
308
|
+
if (status === 409 || status === 422 && isApply) return null;
|
|
309
|
+
return propOr(errorMessageKey(error), status, ACTION_ERROR_MESSAGE_KEYS);
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
var Outcome = function Outcome(_ref) {
|
|
313
|
+
var _ref$action = _ref.action,
|
|
314
|
+
status = _ref$action.status,
|
|
315
|
+
result = _ref$action.result,
|
|
316
|
+
error = _ref$action.error,
|
|
317
|
+
actedBy = _ref$action.actedBy,
|
|
318
|
+
errorMessageKey = _ref.errorMessageKey,
|
|
319
|
+
isApplying = _ref.isApplying,
|
|
320
|
+
isDismissing = _ref.isDismissing,
|
|
321
|
+
onApply = _ref.onApply,
|
|
322
|
+
onDismiss = _ref.onDismiss;
|
|
323
|
+
var _useTranslation = useTranslation(),
|
|
324
|
+
t = _useTranslation.t;
|
|
325
|
+
if (status === "suggested") {
|
|
326
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
327
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
328
|
+
className: "flex flex-wrap gap-2",
|
|
329
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
330
|
+
"data-testid": "neeto-assist-action-apply-button",
|
|
331
|
+
disabled: isApplying || isDismissing,
|
|
332
|
+
label: t("neetoAssist.actions.apply"),
|
|
333
|
+
loading: isApplying,
|
|
334
|
+
size: "sm",
|
|
335
|
+
onClick: onApply
|
|
336
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
337
|
+
"data-testid": "neeto-assist-action-dismiss-button",
|
|
338
|
+
disabled: isApplying || isDismissing,
|
|
339
|
+
label: t("neetoAssist.actions.dismiss"),
|
|
340
|
+
loading: isDismissing,
|
|
341
|
+
size: "sm",
|
|
342
|
+
variant: "ghost",
|
|
343
|
+
onClick: onDismiss
|
|
344
|
+
})]
|
|
345
|
+
}), errorMessageKey && /*#__PURE__*/jsx(Typography, {
|
|
346
|
+
color: "destructive",
|
|
347
|
+
"data-testid": "neeto-assist-action-error",
|
|
348
|
+
variant: "body3",
|
|
349
|
+
children: t(errorMessageKey)
|
|
350
|
+
})]
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
if (status === "applying") {
|
|
354
|
+
return /*#__PURE__*/jsxs("div", {
|
|
355
|
+
className: "flex items-center gap-1.5",
|
|
356
|
+
children: [/*#__PURE__*/jsx(Spinner, {
|
|
357
|
+
size: "sm"
|
|
358
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
359
|
+
color: "muted",
|
|
360
|
+
variant: "body3",
|
|
361
|
+
children: t("neetoAssist.actions.applying")
|
|
362
|
+
})]
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
if (status === "applied") {
|
|
366
|
+
return /*#__PURE__*/jsxs("div", {
|
|
367
|
+
className: "flex items-start gap-1.5",
|
|
368
|
+
children: [/*#__PURE__*/jsx(Check, {
|
|
369
|
+
className: "text-success-foreground mt-1 shrink-0",
|
|
370
|
+
size: STATUS_ICON_SIZE
|
|
371
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
372
|
+
className: "min-w-0",
|
|
373
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
374
|
+
variant: "body3",
|
|
375
|
+
children: result || t("neetoAssist.actions.applied")
|
|
376
|
+
}), (actedBy === null || actedBy === void 0 ? void 0 : actedBy.name) && /*#__PURE__*/jsx(Typography, {
|
|
377
|
+
color: "muted",
|
|
378
|
+
variant: "body3",
|
|
379
|
+
children: t("neetoAssist.actions.by", {
|
|
380
|
+
name: actedBy.name
|
|
381
|
+
})
|
|
382
|
+
})]
|
|
383
|
+
})]
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
if (status === "failed") {
|
|
387
|
+
return /*#__PURE__*/jsx(Typography, {
|
|
388
|
+
color: "destructive",
|
|
389
|
+
"data-testid": "neeto-assist-action-error",
|
|
390
|
+
variant: "body3",
|
|
391
|
+
children: error || t("neetoAssist.actions.failed")
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
return null;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
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; }
|
|
398
|
+
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; }
|
|
399
|
+
var Card = function Card(_ref) {
|
|
400
|
+
var action = _ref.action,
|
|
401
|
+
conversationId = _ref.conversationId,
|
|
402
|
+
onActionApplied = _ref.onActionApplied;
|
|
403
|
+
var _useTranslation = useTranslation(),
|
|
404
|
+
t = _useTranslation.t;
|
|
405
|
+
var _useState = useState(null),
|
|
406
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
407
|
+
answer = _useState2[0],
|
|
408
|
+
setAnswer = _useState2[1];
|
|
409
|
+
var isActingRef = useRef(false);
|
|
410
|
+
|
|
411
|
+
// The host is told through the hook, which still hears the answer to a
|
|
412
|
+
// click when this card is gone by then.
|
|
413
|
+
var _useApplyAction = useApplyAction(conversationId, function (applied) {
|
|
414
|
+
return onActionApplied === null || onActionApplied === void 0 ? void 0 : onActionApplied(_objectSpread$1(_objectSpread$1({}, action), applied));
|
|
415
|
+
}),
|
|
416
|
+
apply = _useApplyAction.mutate,
|
|
417
|
+
isApplying = _useApplyAction.isPending;
|
|
418
|
+
var _useDismissAction = useDismissAction(conversationId),
|
|
419
|
+
dismiss = _useDismissAction.mutate,
|
|
420
|
+
isDismissing = _useDismissAction.isPending;
|
|
421
|
+
var shown = shownAction(action, answer);
|
|
422
|
+
var name = shown.name,
|
|
423
|
+
status = shown.status,
|
|
424
|
+
title = shown.title,
|
|
425
|
+
details = shown.details,
|
|
426
|
+
reason = shown.reason,
|
|
427
|
+
actedBy = shown.actedBy;
|
|
428
|
+
var quietStatusKey = prop(status, QUIET_ACTION_STATUS_KEYS);
|
|
429
|
+
// Someone dismissed an action. Nobody expired one.
|
|
430
|
+
var dismissedBy = status === "dismissed" ? actedBy === null || actedBy === void 0 ? void 0 : actedBy.name : null;
|
|
431
|
+
|
|
432
|
+
// Two clicks can land before the buttons are seen as disabled, and the second
|
|
433
|
+
// must not ask the host to make the change again.
|
|
434
|
+
var act = function act(mutate, isApply) {
|
|
435
|
+
if (isActingRef.current) return;
|
|
436
|
+
isActingRef.current = true;
|
|
437
|
+
setAnswer(null);
|
|
438
|
+
mutate({
|
|
439
|
+
conversationId: conversationId,
|
|
440
|
+
actionId: action.id
|
|
441
|
+
}, {
|
|
442
|
+
onSettled: function onSettled(data, error) {
|
|
443
|
+
isActingRef.current = false;
|
|
444
|
+
setAnswer({
|
|
445
|
+
isApply: isApply,
|
|
446
|
+
data: data,
|
|
447
|
+
error: error
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
};
|
|
452
|
+
if (quietStatusKey) {
|
|
453
|
+
return /*#__PURE__*/jsxs("div", {
|
|
454
|
+
className: "border-border text-muted-foreground rounded-lg border px-3 py-2 text-sm",
|
|
455
|
+
"data-action-name": name,
|
|
456
|
+
"data-status": status,
|
|
457
|
+
"data-testid": "neeto-assist-action-card",
|
|
458
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
459
|
+
className: "flex items-center justify-between gap-3",
|
|
460
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
461
|
+
title: title,
|
|
462
|
+
className: "truncate",
|
|
463
|
+
children: title
|
|
464
|
+
}), /*#__PURE__*/jsx("span", {
|
|
465
|
+
className: "shrink-0",
|
|
466
|
+
children: t(quietStatusKey)
|
|
467
|
+
})]
|
|
468
|
+
}), dismissedBy && /*#__PURE__*/jsx("div", {
|
|
469
|
+
className: "text-end",
|
|
470
|
+
children: t("neetoAssist.actions.by", {
|
|
471
|
+
name: dismissedBy
|
|
472
|
+
})
|
|
473
|
+
})]
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
return /*#__PURE__*/jsxs("div", {
|
|
477
|
+
className: "border-border space-y-2 rounded-lg border p-3 break-words",
|
|
478
|
+
"data-action-name": name,
|
|
479
|
+
"data-status": status,
|
|
480
|
+
"data-testid": "neeto-assist-action-card",
|
|
481
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
482
|
+
className: "space-y-1",
|
|
483
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
484
|
+
variant: "body2",
|
|
485
|
+
weight: "medium",
|
|
486
|
+
children: title
|
|
487
|
+
}), (details !== null && details !== void 0 ? details : []).map(function (detail, index) {
|
|
488
|
+
return /*#__PURE__*/jsx(Typography, {
|
|
489
|
+
className: "whitespace-pre-wrap",
|
|
490
|
+
variant: "body3",
|
|
491
|
+
children: detail
|
|
492
|
+
}, index);
|
|
493
|
+
}), reason && /*#__PURE__*/jsx(Typography, {
|
|
494
|
+
color: "muted",
|
|
495
|
+
variant: "body3",
|
|
496
|
+
children: reason
|
|
497
|
+
})]
|
|
498
|
+
}), /*#__PURE__*/jsx(Outcome, {
|
|
499
|
+
isApplying: isApplying,
|
|
500
|
+
isDismissing: isDismissing,
|
|
501
|
+
action: shown,
|
|
502
|
+
errorMessageKey: answerErrorMessageKey(answer),
|
|
503
|
+
onApply: function onApply() {
|
|
504
|
+
return act(apply, true);
|
|
505
|
+
},
|
|
506
|
+
onDismiss: function onDismiss() {
|
|
507
|
+
return act(dismiss, false);
|
|
508
|
+
}
|
|
509
|
+
})]
|
|
510
|
+
});
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
var Actions = function Actions(_ref) {
|
|
514
|
+
var actions = _ref.actions,
|
|
515
|
+
conversationId = _ref.conversationId,
|
|
516
|
+
onActionApplied = _ref.onActionApplied;
|
|
517
|
+
if (isEmpty(actions)) return null;
|
|
518
|
+
return /*#__PURE__*/jsx("div", {
|
|
519
|
+
className: "flex flex-col gap-2",
|
|
520
|
+
children: actions.map(function (action) {
|
|
521
|
+
return /*#__PURE__*/createElement(Card, {
|
|
522
|
+
action: action,
|
|
523
|
+
conversationId: conversationId,
|
|
524
|
+
onActionApplied: onActionApplied,
|
|
525
|
+
key: action.id
|
|
526
|
+
});
|
|
527
|
+
})
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
|
|
225
531
|
var Sources = function Sources(_ref) {
|
|
226
532
|
var _ref$sources = _ref.sources,
|
|
227
533
|
sources = _ref$sources === void 0 ? [] : _ref$sources;
|
|
@@ -268,16 +574,22 @@ var BLOCK_TYPES = {
|
|
|
268
574
|
BULLET_LIST: "bulletList"
|
|
269
575
|
};
|
|
270
576
|
var HEADING_PATTERN = /^\s{0,3}#{1,6}\s+(.*)$/;
|
|
271
|
-
|
|
577
|
+
|
|
578
|
+
// The first group is the item's own number, the second its text.
|
|
579
|
+
var ORDERED_ITEM_PATTERN = /^\s*(\d+)[.)]\s+(.*)$/;
|
|
272
580
|
var BULLET_ITEM_PATTERN = /^\s*[-*•]\s+(.*)$/;
|
|
581
|
+
|
|
582
|
+
// What a model puts on either side of bold text.
|
|
583
|
+
var BOLD_MARK = "**";
|
|
273
584
|
var BOLD_PATTERN = /\*\*(.+?)\*\*/;
|
|
585
|
+
|
|
586
|
+
// `Settings`: a name a model set off as code. Splits a line into the text
|
|
587
|
+
// around the spans and the spans themselves, backticks included.
|
|
588
|
+
var CODE_SPAN_PATTERN = /(`[^`\n]+`)/;
|
|
274
589
|
var UNSAFE_HTML_CHARACTERS = /[&<>"']/g;
|
|
275
590
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
// Model output can carry markup a visitor slipped into the conversation, so
|
|
279
|
-
// text is only ever escaped into HTML or rendered as React text, never trusted
|
|
280
|
-
// as markup.
|
|
591
|
+
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; }
|
|
592
|
+
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; }
|
|
281
593
|
var escapeHtmlCharacter = function escapeHtmlCharacter(character) {
|
|
282
594
|
switch (character) {
|
|
283
595
|
case "&":
|
|
@@ -296,14 +608,42 @@ var escapeHtml = function escapeHtml(text) {
|
|
|
296
608
|
return text.replace(UNSAFE_HTML_CHARACTERS, escapeHtmlCharacter);
|
|
297
609
|
};
|
|
298
610
|
|
|
611
|
+
// "a `b` c" becomes a plain "a ", a code "b" and a plain " c", each bold or
|
|
612
|
+
// not. An unclosed backtick stays as it is.
|
|
613
|
+
var parseCodeSpans = function parseCodeSpans(text, bold) {
|
|
614
|
+
return text.split(CODE_SPAN_PATTERN).flatMap(function (part, index) {
|
|
615
|
+
if (part === "") return [];
|
|
616
|
+
return index % 2 === 1 ? [{
|
|
617
|
+
text: part.slice(1, -1),
|
|
618
|
+
bold: bold,
|
|
619
|
+
code: true
|
|
620
|
+
}] : [{
|
|
621
|
+
text: part,
|
|
622
|
+
bold: bold
|
|
623
|
+
}];
|
|
624
|
+
});
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
// The line with every code span blanked out and every character still where
|
|
628
|
+
// it was.
|
|
629
|
+
var blankCodeSpans = function blankCodeSpans(line) {
|
|
630
|
+
return line.split(CODE_SPAN_PATTERN).map(function (part, index) {
|
|
631
|
+
return index % 2 === 1 ? " ".repeat(part.length) : part;
|
|
632
|
+
}).join("");
|
|
633
|
+
};
|
|
634
|
+
|
|
299
635
|
// "a **b** c" becomes a plain "a ", a bold "b" and a plain " c". An unclosed
|
|
300
|
-
// "**" stays as it is.
|
|
636
|
+
// "**" stays as it is. Bold is looked for with the code spans blanked out, so
|
|
637
|
+
// the "**" a model quotes in one stays what it is, and each piece is then cut
|
|
638
|
+
// from the line itself, at the place the blanked line has it.
|
|
301
639
|
var parseInline = function parseInline(line) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
640
|
+
var position = 0;
|
|
641
|
+
return blankCodeSpans(line).split(BOLD_PATTERN).flatMap(function (piece, index) {
|
|
642
|
+
var isBold = index % 2 === 1;
|
|
643
|
+
var start = position + (isBold ? BOLD_MARK.length : 0);
|
|
644
|
+
var end = start + piece.length;
|
|
645
|
+
position = end + (isBold ? BOLD_MARK.length : 0);
|
|
646
|
+
return parseCodeSpans(line.slice(start, end), isBold);
|
|
307
647
|
});
|
|
308
648
|
};
|
|
309
649
|
var matchListItem = function matchListItem(line) {
|
|
@@ -311,7 +651,8 @@ var matchListItem = function matchListItem(line) {
|
|
|
311
651
|
if (orderedItem) {
|
|
312
652
|
return {
|
|
313
653
|
type: BLOCK_TYPES.ORDERED_LIST,
|
|
314
|
-
text: orderedItem[
|
|
654
|
+
text: orderedItem[2],
|
|
655
|
+
number: Number(orderedItem[1])
|
|
315
656
|
};
|
|
316
657
|
}
|
|
317
658
|
var bulletItem = line.match(BULLET_ITEM_PATTERN);
|
|
@@ -323,7 +664,9 @@ var matchListItem = function matchListItem(line) {
|
|
|
323
664
|
|
|
324
665
|
// Blocks hold lines of inline segments: a paragraph's lines, a heading's one
|
|
325
666
|
// line, or each list item's lines. A list carries on across blank lines, since
|
|
326
|
-
// models often leave one between items.
|
|
667
|
+
// models often leave one between items. A numbered list remembers the number
|
|
668
|
+
// it starts at, so one that carries on after bullets a model nested under an
|
|
669
|
+
// item counts on instead of starting again at 1.
|
|
327
670
|
var parseLightMarkdown = function parseLightMarkdown() {
|
|
328
671
|
var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
329
672
|
var blocks = [];
|
|
@@ -351,10 +694,12 @@ var parseLightMarkdown = function parseLightMarkdown() {
|
|
|
351
694
|
} else if (listItem) {
|
|
352
695
|
var _openBlock;
|
|
353
696
|
if (((_openBlock = openBlock) === null || _openBlock === void 0 ? void 0 : _openBlock.type) !== listItem.type) {
|
|
354
|
-
startBlock({
|
|
697
|
+
startBlock(_objectSpread({
|
|
355
698
|
type: listItem.type,
|
|
356
699
|
items: []
|
|
357
|
-
}
|
|
700
|
+
}, listItem.number === undefined ? {} : {
|
|
701
|
+
start: listItem.number
|
|
702
|
+
}));
|
|
358
703
|
}
|
|
359
704
|
openBlock.items.push([parseInline(listItem.text.trim())]);
|
|
360
705
|
} else if (isList && !afterBlankLine && /^\s/.test(line)) {
|
|
@@ -405,18 +750,33 @@ var lightMarkdownToHtml = function lightMarkdownToHtml(text) {
|
|
|
405
750
|
return parseLightMarkdown(text).map(blockToHtml).join("");
|
|
406
751
|
};
|
|
407
752
|
|
|
408
|
-
var
|
|
409
|
-
var
|
|
753
|
+
var Words = function Words(_ref) {
|
|
754
|
+
var code = _ref.code,
|
|
755
|
+
text = _ref.text;
|
|
756
|
+
return code ? /*#__PURE__*/jsx("code", {
|
|
757
|
+
className: "bg-muted rounded px-1 font-mono text-[0.9em]",
|
|
758
|
+
children: text
|
|
759
|
+
}) : text;
|
|
760
|
+
};
|
|
761
|
+
var Lines = function Lines(_ref2) {
|
|
762
|
+
var lines = _ref2.lines;
|
|
410
763
|
return lines.map(function (segments, lineIndex) {
|
|
411
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
412
|
-
children: [lineIndex > 0 && /*#__PURE__*/jsx("br", {}), segments.map(function (
|
|
413
|
-
var text =
|
|
414
|
-
bold =
|
|
764
|
+
return /*#__PURE__*/jsxs(Fragment$1, {
|
|
765
|
+
children: [lineIndex > 0 && /*#__PURE__*/jsx("br", {}), segments.map(function (_ref3, segmentIndex) {
|
|
766
|
+
var text = _ref3.text,
|
|
767
|
+
bold = _ref3.bold,
|
|
768
|
+
code = _ref3.code;
|
|
415
769
|
return bold ? /*#__PURE__*/jsx("strong", {
|
|
416
770
|
className: "font-semibold",
|
|
417
|
-
children:
|
|
418
|
-
|
|
419
|
-
|
|
771
|
+
children: /*#__PURE__*/jsx(Words, {
|
|
772
|
+
code: code,
|
|
773
|
+
text: text
|
|
774
|
+
})
|
|
775
|
+
}, segmentIndex) : /*#__PURE__*/jsx(Fragment$1, {
|
|
776
|
+
children: /*#__PURE__*/jsx(Words, {
|
|
777
|
+
code: code,
|
|
778
|
+
text: text
|
|
779
|
+
})
|
|
420
780
|
}, segmentIndex);
|
|
421
781
|
})]
|
|
422
782
|
}, lineIndex);
|
|
@@ -443,6 +803,7 @@ var Block = function Block(_ref) {
|
|
|
443
803
|
var isOrdered = block.type === BLOCK_TYPES.ORDERED_LIST;
|
|
444
804
|
var List = isOrdered ? "ol" : "ul";
|
|
445
805
|
return /*#__PURE__*/jsx(List, {
|
|
806
|
+
start: isOrdered ? block.start : undefined,
|
|
446
807
|
className: classNames({
|
|
447
808
|
"list-decimal space-y-1 pl-5": isOrdered,
|
|
448
809
|
"list-disc space-y-1 pl-5": !isOrdered
|
|
@@ -514,30 +875,45 @@ var SuggestedReply$1 = function SuggestedReply(_ref) {
|
|
|
514
875
|
var SuggestedReply = withT(SuggestedReply$1);
|
|
515
876
|
|
|
516
877
|
var Answer = function Answer(_ref) {
|
|
517
|
-
var
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
answer = _ref$run.answer,
|
|
522
|
-
suggestedReply = _ref$run.suggestedReply,
|
|
523
|
-
needsHumanAction = _ref$run.needsHumanAction,
|
|
524
|
-
sources = _ref$run.sources;
|
|
878
|
+
var conversationId = _ref.conversationId,
|
|
879
|
+
onActionApplied = _ref.onActionApplied,
|
|
880
|
+
onUseReply = _ref.onUseReply,
|
|
881
|
+
run = _ref.run;
|
|
525
882
|
var _useTranslation = useTranslation(),
|
|
526
883
|
t = _useTranslation.t;
|
|
884
|
+
var kind = run.kind,
|
|
885
|
+
outcome = run.outcome,
|
|
886
|
+
answer = run.answer,
|
|
887
|
+
suggestedReply = run.suggestedReply,
|
|
888
|
+
needsHumanAction = run.needsHumanAction,
|
|
889
|
+
sources = run.sources;
|
|
890
|
+
var actions = /*#__PURE__*/jsx(Actions, {
|
|
891
|
+
conversationId: conversationId,
|
|
892
|
+
onActionApplied: onActionApplied,
|
|
893
|
+
actions: actionsOf(run)
|
|
894
|
+
});
|
|
527
895
|
if (outcome === "no_answer") {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
}), answer && /*#__PURE__*/jsx(FormattedText, {
|
|
535
|
-
className: "text-muted-foreground",
|
|
896
|
+
// A rep asked, and NeetoAssist says in its own words what it cannot do or
|
|
897
|
+
// what is missing. That sentence is its answer. A reply it could not draft
|
|
898
|
+
// for a customer's message keeps the heading, since nobody asked for it.
|
|
899
|
+
var saysWhy = kind === "ask" && !!answer;
|
|
900
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
901
|
+
children: [saysWhy ? /*#__PURE__*/jsx(FormattedText, {
|
|
536
902
|
text: answer
|
|
537
|
-
})
|
|
903
|
+
}) : /*#__PURE__*/jsxs("div", {
|
|
904
|
+
className: "space-y-1",
|
|
905
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
906
|
+
variant: "body2",
|
|
907
|
+
weight: "medium",
|
|
908
|
+
children: t("neetoAssist.run.noAnswer")
|
|
909
|
+
}), answer && /*#__PURE__*/jsx(FormattedText, {
|
|
910
|
+
className: "text-muted-foreground",
|
|
911
|
+
text: answer
|
|
912
|
+
})]
|
|
913
|
+
}), actions]
|
|
538
914
|
});
|
|
539
915
|
}
|
|
540
|
-
return /*#__PURE__*/jsxs(Fragment
|
|
916
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
541
917
|
children: [kind === "ask" && answer && /*#__PURE__*/jsx(FormattedText, {
|
|
542
918
|
text: answer
|
|
543
919
|
}), suggestedReply && /*#__PURE__*/jsx(SuggestedReply, {
|
|
@@ -548,7 +924,7 @@ var Answer = function Answer(_ref) {
|
|
|
548
924
|
variant: "body3",
|
|
549
925
|
weight: "medium",
|
|
550
926
|
children: t("neetoAssist.run.needsFollowUp")
|
|
551
|
-
}), /*#__PURE__*/jsx(Sources, {
|
|
927
|
+
}), actions, /*#__PURE__*/jsx(Sources, {
|
|
552
928
|
sources: sources
|
|
553
929
|
})]
|
|
554
930
|
});
|
|
@@ -748,8 +1124,92 @@ var Question = function Question(_ref) {
|
|
|
748
1124
|
});
|
|
749
1125
|
};
|
|
750
1126
|
|
|
1127
|
+
var Step = function Step(_ref) {
|
|
1128
|
+
var isRunPending = _ref.isRunPending,
|
|
1129
|
+
_ref$step = _ref.step,
|
|
1130
|
+
label = _ref$step.label,
|
|
1131
|
+
status = _ref$step.status,
|
|
1132
|
+
summary = _ref$step.summary;
|
|
1133
|
+
var _useTranslation = useTranslation(),
|
|
1134
|
+
t = _useTranslation.t;
|
|
1135
|
+
var isRunning = status === "running" && isRunPending;
|
|
1136
|
+
var isCompleted = status === "completed";
|
|
1137
|
+
var isFailed = status === "failed" || status === "running" && !isRunning;
|
|
1138
|
+
return /*#__PURE__*/jsxs("li", {
|
|
1139
|
+
className: "flex items-start gap-1.5",
|
|
1140
|
+
"data-status": status,
|
|
1141
|
+
"data-testid": "neeto-assist-step",
|
|
1142
|
+
children: [/*#__PURE__*/jsxs("span", {
|
|
1143
|
+
className: "mt-1 flex size-3 shrink-0 items-center justify-center",
|
|
1144
|
+
children: [isRunning && /*#__PURE__*/jsx(Spinner, {
|
|
1145
|
+
size: "sm"
|
|
1146
|
+
}), isCompleted && /*#__PURE__*/jsx(Check, {
|
|
1147
|
+
"aria-label": t("neetoAssist.steps.completed"),
|
|
1148
|
+
className: "text-success-foreground",
|
|
1149
|
+
role: "img",
|
|
1150
|
+
size: STATUS_ICON_SIZE
|
|
1151
|
+
}), isFailed && /*#__PURE__*/jsx(X, {
|
|
1152
|
+
"aria-label": t("neetoAssist.steps.failed"),
|
|
1153
|
+
className: "text-destructive",
|
|
1154
|
+
role: "img",
|
|
1155
|
+
size: STATUS_ICON_SIZE
|
|
1156
|
+
})]
|
|
1157
|
+
}), /*#__PURE__*/jsxs(Typography, {
|
|
1158
|
+
className: "min-w-0 break-words",
|
|
1159
|
+
color: "muted",
|
|
1160
|
+
variant: "body3",
|
|
1161
|
+
children: [label, isCompleted && summary && /*#__PURE__*/jsxs("span", {
|
|
1162
|
+
children: [": ", summary]
|
|
1163
|
+
})]
|
|
1164
|
+
})]
|
|
1165
|
+
});
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1168
|
+
var Steps = function Steps(_ref) {
|
|
1169
|
+
var run = _ref.run;
|
|
1170
|
+
var _useTranslation = useTranslation(),
|
|
1171
|
+
t = _useTranslation.t;
|
|
1172
|
+
var _useState = useState(false),
|
|
1173
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1174
|
+
isOpen = _useState2[0],
|
|
1175
|
+
setIsOpen = _useState2[1];
|
|
1176
|
+
var steps = stepsOf(run);
|
|
1177
|
+
var isRunPending = isPending(run);
|
|
1178
|
+
if (isEmpty(steps)) return null;
|
|
1179
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1180
|
+
className: "flex flex-col gap-1",
|
|
1181
|
+
"data-testid": "neeto-assist-steps",
|
|
1182
|
+
children: [!isRunPending && /*#__PURE__*/jsxs("button", {
|
|
1183
|
+
"aria-expanded": isOpen,
|
|
1184
|
+
className: "text-muted-foreground hover:text-foreground flex cursor-pointer items-center gap-1.5 self-start text-sm",
|
|
1185
|
+
"data-testid": "neeto-assist-steps-toggle",
|
|
1186
|
+
type: "button",
|
|
1187
|
+
onClick: function onClick() {
|
|
1188
|
+
return setIsOpen(not);
|
|
1189
|
+
},
|
|
1190
|
+
children: [isOpen ? /*#__PURE__*/jsx(ChevronUp, {
|
|
1191
|
+
size: STATUS_ICON_SIZE
|
|
1192
|
+
}) : /*#__PURE__*/jsx(ChevronDown, {
|
|
1193
|
+
size: STATUS_ICON_SIZE
|
|
1194
|
+
}), t("neetoAssist.steps.lookedAt", {
|
|
1195
|
+
count: steps.length
|
|
1196
|
+
})]
|
|
1197
|
+
}), (isRunPending || isOpen) && /*#__PURE__*/jsx("ul", {
|
|
1198
|
+
className: "flex flex-col gap-1",
|
|
1199
|
+
children: steps.map(function (step) {
|
|
1200
|
+
return /*#__PURE__*/createElement(Step, {
|
|
1201
|
+
isRunPending: isRunPending,
|
|
1202
|
+
step: step,
|
|
1203
|
+
key: step.id
|
|
1204
|
+
});
|
|
1205
|
+
})
|
|
1206
|
+
})]
|
|
1207
|
+
});
|
|
1208
|
+
};
|
|
1209
|
+
|
|
751
1210
|
var Run$1 = function Run(_ref) {
|
|
752
1211
|
var conversationId = _ref.conversationId,
|
|
1212
|
+
onActionApplied = _ref.onActionApplied,
|
|
753
1213
|
onUseReply = _ref.onUseReply,
|
|
754
1214
|
run = _ref.run,
|
|
755
1215
|
t = _ref.t;
|
|
@@ -758,7 +1218,9 @@ var Run$1 = function Run(_ref) {
|
|
|
758
1218
|
"data-testid": RUN_TEST_ID,
|
|
759
1219
|
children: [/*#__PURE__*/jsx(Question, {
|
|
760
1220
|
run: run
|
|
761
|
-
}),
|
|
1221
|
+
}), /*#__PURE__*/jsx(Steps, {
|
|
1222
|
+
run: run
|
|
1223
|
+
}), isPending(run) && !hasRunningStep(run) && /*#__PURE__*/jsxs("div", {
|
|
762
1224
|
className: "flex items-center gap-1.5",
|
|
763
1225
|
children: [/*#__PURE__*/jsx(Spinner, {
|
|
764
1226
|
size: "sm"
|
|
@@ -768,6 +1230,8 @@ var Run$1 = function Run(_ref) {
|
|
|
768
1230
|
children: t("neetoAssist.run.pending")
|
|
769
1231
|
})]
|
|
770
1232
|
}), hasWrittenReply(run) && /*#__PURE__*/jsx(Answer, {
|
|
1233
|
+
conversationId: conversationId,
|
|
1234
|
+
onActionApplied: onActionApplied,
|
|
771
1235
|
onUseReply: onUseReply,
|
|
772
1236
|
run: run
|
|
773
1237
|
}), run.status === "skipped" && !hasWrittenReply(run) && /*#__PURE__*/jsx(Typography, {
|
|
@@ -786,10 +1250,25 @@ var Run$1 = function Run(_ref) {
|
|
|
786
1250
|
};
|
|
787
1251
|
var Run = withT(Run$1);
|
|
788
1252
|
|
|
789
|
-
var
|
|
790
|
-
var
|
|
791
|
-
|
|
792
|
-
|
|
1253
|
+
var topOfFinishedRun = function topOfFinishedRun(list, run) {
|
|
1254
|
+
var _run$children;
|
|
1255
|
+
var _ref = (_run$children = run.children) !== null && _run$children !== void 0 ? _run$children : [],
|
|
1256
|
+
_ref2 = _slicedToArray(_ref, 2),
|
|
1257
|
+
reply = _ref2[1];
|
|
1258
|
+
var runTop = run.offsetTop - list.offsetTop - SCROLL_MARGIN;
|
|
1259
|
+
if (!reply) return runTop;
|
|
1260
|
+
var replyTop = reply.offsetTop - list.offsetTop;
|
|
1261
|
+
return Math.max(runTop, replyTop - list.clientHeight * REPLY_STARTS_WITHIN);
|
|
1262
|
+
};
|
|
1263
|
+
|
|
1264
|
+
// Everything NeetoAssist did on one ticket, kept for as long as the ticket is,
|
|
1265
|
+
// and the box to ask it more. Keyed by conversation, so moving to another
|
|
1266
|
+
// ticket starts fresh and not even a half-typed question carries over.
|
|
1267
|
+
var Conversation = function Conversation(_ref3) {
|
|
1268
|
+
var conversationId = _ref3.conversationId,
|
|
1269
|
+
isVisible = _ref3.isVisible,
|
|
1270
|
+
onActionApplied = _ref3.onActionApplied,
|
|
1271
|
+
onUseReply = _ref3.onUseReply;
|
|
793
1272
|
var listRef = useRef(null);
|
|
794
1273
|
var markDraftSeen = useNeetoAssistStore(function (state) {
|
|
795
1274
|
return state.markDraftSeen;
|
|
@@ -804,19 +1283,24 @@ var Conversation = function Conversation(_ref) {
|
|
|
804
1283
|
error = _useFetchRuns.error,
|
|
805
1284
|
isLoading = _useFetchRuns.isLoading;
|
|
806
1285
|
var newestRun = runs[0];
|
|
1286
|
+
var newestRunLookups = newestRun ? stepsOf(newestRun).length : 0;
|
|
1287
|
+
var isNewestRunPending = !!newestRun && isPending(newestRun);
|
|
807
1288
|
var draftId = latestDraftId(runs);
|
|
808
1289
|
|
|
809
|
-
//
|
|
810
|
-
// from
|
|
1290
|
+
// While NeetoAssist works, each lookup adds a line at the end, and the window
|
|
1291
|
+
// stays on the end: from the top of a long question or a long list of
|
|
1292
|
+
// lookups, the sign of work would be below the window. A finished run is
|
|
1293
|
+
// shown from its top, or from where its reply is in view.
|
|
811
1294
|
useEffect(function () {
|
|
812
1295
|
var list = listRef.current;
|
|
813
1296
|
var renderedRuns = list === null || list === void 0 ? void 0 : list.querySelectorAll("[data-testid=\"".concat(RUN_TEST_ID, "\"]"));
|
|
814
1297
|
var newest = renderedRuns === null || renderedRuns === void 0 ? void 0 : renderedRuns[renderedRuns.length - 1];
|
|
815
1298
|
if (!newest) return;
|
|
1299
|
+
var top = isNewestRunPending ? list.scrollHeight : topOfFinishedRun(list, newest);
|
|
816
1300
|
list.scrollTo({
|
|
817
|
-
top:
|
|
1301
|
+
top: top
|
|
818
1302
|
});
|
|
819
|
-
}, [newestRun === null || newestRun === void 0 ? void 0 : newestRun.id,
|
|
1303
|
+
}, [newestRun === null || newestRun === void 0 ? void 0 : newestRun.id, isNewestRunPending, newestRunLookups]);
|
|
820
1304
|
useEffect(function () {
|
|
821
1305
|
if (isVisible && draftId) markDraftSeen(conversationId, draftId);
|
|
822
1306
|
}, [conversationId, draftId, isVisible, markDraftSeen]);
|
|
@@ -830,6 +1314,7 @@ var Conversation = function Conversation(_ref) {
|
|
|
830
1314
|
}), runsInConversationOrder(runs).map(function (run) {
|
|
831
1315
|
return /*#__PURE__*/createElement(Run, {
|
|
832
1316
|
conversationId: conversationId,
|
|
1317
|
+
onActionApplied: onActionApplied,
|
|
833
1318
|
onUseReply: onUseReply,
|
|
834
1319
|
run: run,
|
|
835
1320
|
key: run.id
|
|
@@ -954,17 +1439,20 @@ var NeetoAssistPane = function NeetoAssistPane() {
|
|
|
954
1439
|
return /*#__PURE__*/jsx(Pane, {
|
|
955
1440
|
isExpanded: isExpanded,
|
|
956
1441
|
isOpen: isVisible,
|
|
957
|
-
children: conversation && /*#__PURE__*/jsxs(Fragment
|
|
1442
|
+
children: conversation && /*#__PURE__*/jsxs(Fragment, {
|
|
958
1443
|
children: [/*#__PURE__*/jsx(Header, {
|
|
959
1444
|
isExpanded: isExpanded,
|
|
960
1445
|
onClose: close,
|
|
961
1446
|
onToggleExpand: function onToggleExpand() {
|
|
962
1447
|
return setExpanded(!isExpanded);
|
|
963
1448
|
}
|
|
1449
|
+
}), conversation.contextLabel && /*#__PURE__*/jsx(ContextLabel, {
|
|
1450
|
+
label: conversation.contextLabel
|
|
964
1451
|
}), /*#__PURE__*/createElement(Conversation, {
|
|
965
1452
|
isVisible: isVisible,
|
|
966
1453
|
conversationId: conversation.id,
|
|
967
1454
|
key: conversation.id,
|
|
1455
|
+
onActionApplied: conversation.onActionApplied,
|
|
968
1456
|
onUseReply: conversation.onUseReply
|
|
969
1457
|
})]
|
|
970
1458
|
})
|