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