@atlaskit/rovo-agent-components 0.3.2 → 0.4.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/CHANGELOG.md +8 -0
- package/dist/cjs/common/ui/chat-icon/index.js +4 -3
- package/dist/cjs/common/ui/chat-pill/index.js +2 -8
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/ui/agent-conversation-starters/index.js +47 -97
- package/dist/cjs/ui/agent-conversation-starters/messages.js +0 -90
- package/dist/es2019/common/ui/chat-icon/index.js +4 -3
- package/dist/es2019/common/ui/chat-pill/index.js +2 -8
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/ui/agent-conversation-starters/index.js +40 -86
- package/dist/es2019/ui/agent-conversation-starters/messages.js +0 -90
- package/dist/esm/common/ui/chat-icon/index.js +4 -3
- package/dist/esm/common/ui/chat-pill/index.js +2 -8
- package/dist/esm/index.js +1 -1
- package/dist/esm/ui/agent-conversation-starters/index.js +47 -97
- package/dist/esm/ui/agent-conversation-starters/messages.js +0 -90
- package/dist/types/index.d.ts +1 -1
- package/dist/types/ui/agent-conversation-starters/index.d.ts +8 -13
- package/dist/types/ui/agent-conversation-starters/messages.d.ts +0 -90
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/agent-conversation-starters/index.d.ts +8 -13
- package/dist/types-ts4.5/ui/agent-conversation-starters/messages.d.ts +0 -90
- package/package.json +1 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/rovo-agent-components
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#122546](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/122546)
|
|
8
|
+
[`b40f5bb07ebcb`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b40f5bb07ebcb) -
|
|
9
|
+
Added LLM-generated contextual conversation starters (feature gated)
|
|
10
|
+
|
|
3
11
|
## 0.3.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -10,8 +10,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _icon = _interopRequireDefault(require("@atlaskit/icon"));
|
|
11
11
|
var CustomGlyph = function CustomGlyph(props) {
|
|
12
12
|
return /*#__PURE__*/_react.default.createElement("svg", (0, _extends2.default)({
|
|
13
|
-
width: "
|
|
14
|
-
height: "
|
|
13
|
+
width: "16",
|
|
14
|
+
height: "16",
|
|
15
15
|
viewBox: "0 0 20 20",
|
|
16
16
|
fill: "none",
|
|
17
17
|
xmlns: "http://www.w3.org/2000/svg"
|
|
@@ -47,6 +47,7 @@ var CustomGlyph = function CustomGlyph(props) {
|
|
|
47
47
|
var ChatPillIcon = exports.ChatPillIcon = function ChatPillIcon(props) {
|
|
48
48
|
return /*#__PURE__*/_react.default.createElement(_icon.default, (0, _extends2.default)({}, props, {
|
|
49
49
|
glyph: CustomGlyph,
|
|
50
|
-
label: ""
|
|
50
|
+
label: "",
|
|
51
|
+
size: "small"
|
|
51
52
|
}));
|
|
52
53
|
};
|
|
@@ -16,7 +16,7 @@ var buttonStyles = (0, _primitives.xcss)({
|
|
|
16
16
|
padding: 'space.100',
|
|
17
17
|
borderRadius: 'border.radius.200',
|
|
18
18
|
borderBottomRightRadius: "var(--ds-border-radius-050, 2px)",
|
|
19
|
-
lineHeight: '
|
|
19
|
+
lineHeight: '16px',
|
|
20
20
|
fontWeight: '500',
|
|
21
21
|
fontSize: '14px',
|
|
22
22
|
textOverflow: 'ellipsis',
|
|
@@ -40,10 +40,6 @@ var queryTextStyles = (0, _primitives.xcss)({
|
|
|
40
40
|
var whiteSpacePreWrapStyles = (0, _primitives.xcss)({
|
|
41
41
|
whiteSpace: 'pre-wrap'
|
|
42
42
|
});
|
|
43
|
-
var iconWrapper = (0, _primitives.xcss)({
|
|
44
|
-
minWidth: '20px',
|
|
45
|
-
height: '20px'
|
|
46
|
-
});
|
|
47
43
|
var ChatPill = exports.ChatPill = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
48
44
|
var children = _ref.children,
|
|
49
45
|
_ref$whiteSpacePreWra = _ref.whiteSpacePreWrap,
|
|
@@ -56,9 +52,7 @@ var ChatPill = exports.ChatPill = /*#__PURE__*/_react.default.forwardRef(functio
|
|
|
56
52
|
}), /*#__PURE__*/_react.default.createElement(_primitives.Inline, {
|
|
57
53
|
space: "space.050",
|
|
58
54
|
xcss: buttonInlineStyles
|
|
59
|
-
}, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
60
|
-
xcss: iconWrapper
|
|
61
|
-
}, /*#__PURE__*/_react.default.createElement(_chatIcon.ChatPillIcon, null)), /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
55
|
+
}, /*#__PURE__*/_react.default.createElement(_chatIcon.ChatPillIcon, null), /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
62
56
|
xcss: [queryTextStyles, whiteSpacePreWrap && whiteSpacePreWrapStyles]
|
|
63
57
|
}, children)));
|
|
64
58
|
});
|
package/dist/cjs/index.js
CHANGED
|
@@ -51,6 +51,12 @@ Object.defineProperty(exports, "ChatPillIcon", {
|
|
|
51
51
|
return _chatIcon.ChatPillIcon;
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
+
Object.defineProperty(exports, "ConversationStarters", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _agentConversationStarters.ConversationStarters;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
54
60
|
Object.defineProperty(exports, "StarIconButton", {
|
|
55
61
|
enumerable: true,
|
|
56
62
|
get: function get() {
|
|
@@ -5,101 +5,29 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.getConversationStarters = exports.ConversationStarters = exports.AgentConversationStarters = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
var _bindEventListener = require("bind-event-listener");
|
|
14
13
|
var _reactIntlNext = require("react-intl-next");
|
|
15
|
-
var
|
|
14
|
+
var _new = require("@atlaskit/button/new");
|
|
15
|
+
var _retry = _interopRequireDefault(require("@atlaskit/icon/core/retry"));
|
|
16
|
+
var _primitives = require("@atlaskit/primitives");
|
|
16
17
|
var _chatPill = require("../../common/ui/chat-pill");
|
|
17
18
|
var _messages = require("./messages");
|
|
18
|
-
var
|
|
19
|
+
var _excluded = ["userDefinedConversationStarters", "isAgentDefault"];
|
|
19
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
21
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
|
-
function useWindowLocationChange() {
|
|
22
|
-
var _useState = (0, _react.useState)(window.location.href),
|
|
23
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
24
|
-
location = _useState2[0],
|
|
25
|
-
setLocation = _useState2[1];
|
|
26
|
-
var handleLocationChange = function handleLocationChange() {
|
|
27
|
-
setLocation(window.location.href);
|
|
28
|
-
};
|
|
29
|
-
(0, _react.useEffect)(function () {
|
|
30
|
-
var originalPushState = window.history.pushState;
|
|
31
|
-
var originalReplaceState = window.history.replaceState;
|
|
32
|
-
window.history.pushState = function () {
|
|
33
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
34
|
-
args[_key] = arguments[_key];
|
|
35
|
-
}
|
|
36
|
-
originalPushState.apply(this, args);
|
|
37
|
-
handleLocationChange();
|
|
38
|
-
};
|
|
39
|
-
window.history.replaceState = function () {
|
|
40
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
41
|
-
args[_key2] = arguments[_key2];
|
|
42
|
-
}
|
|
43
|
-
originalReplaceState.apply(this, args);
|
|
44
|
-
handleLocationChange();
|
|
45
|
-
};
|
|
46
|
-
var unbind = (0, _bindEventListener.bindAll)(window, [{
|
|
47
|
-
type: 'popstate',
|
|
48
|
-
listener: handleLocationChange
|
|
49
|
-
}]);
|
|
50
|
-
return function () {
|
|
51
|
-
unbind();
|
|
52
|
-
window.history.pushState = originalPushState;
|
|
53
|
-
window.history.replaceState = originalReplaceState;
|
|
54
|
-
};
|
|
55
|
-
}, []);
|
|
56
|
-
return location;
|
|
57
|
-
}
|
|
58
|
-
var PageContextType = exports.PageContextType = /*#__PURE__*/function (PageContextType) {
|
|
59
|
-
PageContextType["CONFLUENCE_HOME"] = "confluence-home";
|
|
60
|
-
PageContextType["CONFLUENCE_PAGE_VIEW"] = "confluence-page-view";
|
|
61
|
-
PageContextType["CONFLUENCE_PAGE_EDIT"] = "confluence-page-edit";
|
|
62
|
-
PageContextType["JIRA_HOME"] = "jira-home";
|
|
63
|
-
PageContextType["JIRA_ISSUE_VIEW"] = "jira-issue-view";
|
|
64
|
-
PageContextType["JIRA_ISSUE_LIST"] = "jira-issue-list";
|
|
65
|
-
PageContextType["UNKNOWN"] = "unknown";
|
|
66
|
-
return PageContextType;
|
|
67
|
-
}({});
|
|
68
|
-
var PAGE_TYPE_CONVERSATION_STARTERS = (_PAGE_TYPE_CONVERSATI = {}, (0, _defineProperty2.default)(_PAGE_TYPE_CONVERSATI, PageContextType.CONFLUENCE_HOME, [_messages.messages.confluenceHomeSuggestion1, _messages.messages.confluenceHomeSuggestion2, _messages.messages.confluenceHomeSuggestion3]), (0, _defineProperty2.default)(_PAGE_TYPE_CONVERSATI, PageContextType.CONFLUENCE_PAGE_EDIT, [_messages.messages.confluencePageEditSuggestion1, _messages.messages.confluencePageEditSuggestion2, _messages.messages.confluencePageEditSuggestion3]), (0, _defineProperty2.default)(_PAGE_TYPE_CONVERSATI, PageContextType.CONFLUENCE_PAGE_VIEW, [_messages.messages.confluencePageViewSuggestion1, _messages.messages.confluencePageViewSuggestion2, _messages.messages.confluencePageViewSuggestion3]), (0, _defineProperty2.default)(_PAGE_TYPE_CONVERSATI, PageContextType.JIRA_HOME, [_messages.messages.jiraHomeSuggestion1, _messages.messages.jiraHomeSuggestion2, _messages.messages.jiraHomeSuggestion3]), (0, _defineProperty2.default)(_PAGE_TYPE_CONVERSATI, PageContextType.JIRA_ISSUE_VIEW, [_messages.messages.jiraIssueViewSuggestion1, _messages.messages.jiraIssueViewSuggestion2, _messages.messages.jiraIssueViewSuggestion3]), (0, _defineProperty2.default)(_PAGE_TYPE_CONVERSATI, PageContextType.JIRA_ISSUE_LIST, [_messages.messages.jiraIssueListSuggestion1, _messages.messages.jiraIssueListSuggestion2, _messages.messages.jiraIssueListSuggestion3]), (0, _defineProperty2.default)(_PAGE_TYPE_CONVERSATI, PageContextType.UNKNOWN, [_messages.messages.emptyStateSuggestion1, _messages.messages.emptyStateSuggestion2, _messages.messages.emptyStateSuggestion3]), _PAGE_TYPE_CONVERSATI);
|
|
69
|
-
function determinePageType(location) {
|
|
70
|
-
var urlPatterns = [[PageContextType.CONFLUENCE_HOME, /\/wiki\/home$/], [PageContextType.CONFLUENCE_PAGE_EDIT, /\/wiki\/spaces\/[^\/]+\/(?:pages|blog)\/edit-v2\//], [PageContextType.CONFLUENCE_PAGE_VIEW, /\/wiki\/spaces\/[^\/]+\/(?:pages|blog)\//], [PageContextType.JIRA_ISSUE_VIEW, /\/browse\/[^\/]+$/], [PageContextType.JIRA_ISSUE_VIEW, /\/jira\/.+\/projects\/.+\?selectedIssue/], [PageContextType.JIRA_ISSUE_LIST, /\/jira\/.+\/projects\//], [PageContextType.JIRA_HOME, /\/jira\/dashboards\/last-visited$/]];
|
|
71
|
-
for (var _i = 0, _urlPatterns = urlPatterns; _i < _urlPatterns.length; _i++) {
|
|
72
|
-
var _urlPatterns$_i = (0, _slicedToArray2.default)(_urlPatterns[_i], 2),
|
|
73
|
-
type = _urlPatterns$_i[0],
|
|
74
|
-
pattern = _urlPatterns$_i[1];
|
|
75
|
-
if (pattern.test(location)) {
|
|
76
|
-
return type;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return PageContextType.UNKNOWN;
|
|
80
|
-
}
|
|
81
|
-
var usePageContextType = exports.usePageContextType = function usePageContextType() {
|
|
82
|
-
var location = useWindowLocationChange();
|
|
83
|
-
var _useState3 = (0, _react.useState)(determinePageType(location)),
|
|
84
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
85
|
-
pageContextType = _useState4[0],
|
|
86
|
-
setPageContextType = _useState4[1];
|
|
87
|
-
(0, _react.useEffect)(function () {
|
|
88
|
-
setPageContextType(determinePageType(location));
|
|
89
|
-
}, [location]);
|
|
90
|
-
return pageContextType;
|
|
91
|
-
};
|
|
92
22
|
var getConversationStarters = exports.getConversationStarters = function getConversationStarters(_ref) {
|
|
93
23
|
var userDefinedConversationStartersParam = _ref.userDefinedConversationStarters,
|
|
94
|
-
isAgentDefault = _ref.isAgentDefault
|
|
95
|
-
_ref$pageContextType = _ref.pageContextType,
|
|
96
|
-
pageContextType = _ref$pageContextType === void 0 ? PageContextType.UNKNOWN : _ref$pageContextType;
|
|
24
|
+
isAgentDefault = _ref.isAgentDefault;
|
|
97
25
|
var customAgentConversationStarters = [_messages.messages.agentEmptyStateSuggestion1, _messages.messages.agentEmptyStateSuggestion2, _messages.messages.agentEmptyStateSuggestion3];
|
|
98
26
|
var userDefinedConversationStarters = userDefinedConversationStartersParam !== null && userDefinedConversationStartersParam !== void 0 ? userDefinedConversationStartersParam : [];
|
|
99
|
-
var
|
|
100
|
-
var defaultAgentConversationStarters = isPageContextConvoStartersEnabled ? PAGE_TYPE_CONVERSATION_STARTERS[pageContextType] : [_messages.messages.emptyStateSuggestion1, _messages.messages.emptyStateSuggestion2, _messages.messages.emptyStateSuggestion3];
|
|
27
|
+
var defaultAgentConversationStarters = [_messages.messages.emptyStateSuggestion1, _messages.messages.emptyStateSuggestion2, _messages.messages.emptyStateSuggestion3];
|
|
101
28
|
var getCombinedConversationStarters = function getCombinedConversationStarters() {
|
|
102
|
-
|
|
29
|
+
var shouldCombine = !isAgentDefault;
|
|
30
|
+
if (shouldCombine) {
|
|
103
31
|
// Return default suggestions + user defined suggestions with a max of 3 suggestions
|
|
104
32
|
return [].concat((0, _toConsumableArray2.default)(customAgentConversationStarters.slice(0, 3 - userDefinedConversationStarters.length)), (0, _toConsumableArray2.default)(userDefinedConversationStarters));
|
|
105
33
|
}
|
|
@@ -115,29 +43,51 @@ var getConversationStarters = exports.getConversationStarters = function getConv
|
|
|
115
43
|
var AgentConversationStarters = exports.AgentConversationStarters = function AgentConversationStarters(_ref2) {
|
|
116
44
|
var userDefinedConversationStarters = _ref2.userDefinedConversationStarters,
|
|
117
45
|
isAgentDefault = _ref2.isAgentDefault,
|
|
118
|
-
|
|
46
|
+
props = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
|
|
119
47
|
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
120
48
|
formatMessage = _useIntl.formatMessage;
|
|
121
|
-
var pageContextType = usePageContextType();
|
|
122
49
|
var _useMemo = (0, _react.useMemo)(function () {
|
|
123
50
|
return getConversationStarters({
|
|
124
51
|
userDefinedConversationStarters: userDefinedConversationStarters,
|
|
125
|
-
isAgentDefault: isAgentDefault
|
|
126
|
-
pageContextType: pageContextType
|
|
52
|
+
isAgentDefault: isAgentDefault
|
|
127
53
|
});
|
|
128
|
-
}, [userDefinedConversationStarters, isAgentDefault
|
|
54
|
+
}, [userDefinedConversationStarters, isAgentDefault]),
|
|
129
55
|
combinedConversationStarters = _useMemo.combinedConversationStarters;
|
|
130
|
-
var
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
56
|
+
var starters = (0, _react.useMemo)(function () {
|
|
57
|
+
return combinedConversationStarters.map(function (starter) {
|
|
58
|
+
return typeof starter === 'string' ? starter : formatMessage(starter);
|
|
59
|
+
});
|
|
60
|
+
}, [combinedConversationStarters, formatMessage]);
|
|
61
|
+
return /*#__PURE__*/_react.default.createElement(ConversationStarters, (0, _extends2.default)({
|
|
62
|
+
starters: starters
|
|
63
|
+
}, props));
|
|
64
|
+
};
|
|
65
|
+
var ConversationStarters = exports.ConversationStarters = function ConversationStarters(_ref3) {
|
|
66
|
+
var starters = _ref3.starters,
|
|
67
|
+
onConversationStarterClick = _ref3.onConversationStarterClick,
|
|
68
|
+
_ref3$showReloadButto = _ref3.showReloadButton,
|
|
69
|
+
showReloadButton = _ref3$showReloadButto === void 0 ? false : _ref3$showReloadButto,
|
|
70
|
+
_ref3$onReloadButtonC = _ref3.onReloadButtonClick,
|
|
71
|
+
onReloadButtonClick = _ref3$onReloadButtonC === void 0 ? function () {} : _ref3$onReloadButtonC;
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, starters.map(function (starter, index) {
|
|
73
|
+
var isLastStarter = index === starters.length - 1;
|
|
74
|
+
var chatPill = /*#__PURE__*/_react.default.createElement(_chatPill.ChatPill, {
|
|
136
75
|
testId: "conversation-starter",
|
|
137
|
-
key:
|
|
76
|
+
key: starter,
|
|
138
77
|
onClick: function onClick() {
|
|
139
|
-
return
|
|
78
|
+
return onConversationStarterClick(starter);
|
|
140
79
|
}
|
|
141
|
-
},
|
|
80
|
+
}, starter);
|
|
81
|
+
return isLastStarter && showReloadButton ? /*#__PURE__*/_react.default.createElement(_primitives.Inline, {
|
|
82
|
+
space: "space.050",
|
|
83
|
+
grow: "fill",
|
|
84
|
+
alignInline: "end",
|
|
85
|
+
key: starter
|
|
86
|
+
}, chatPill, /*#__PURE__*/_react.default.createElement(_new.IconButton, {
|
|
87
|
+
icon: _retry.default,
|
|
88
|
+
onClick: onReloadButtonClick,
|
|
89
|
+
appearance: "subtle",
|
|
90
|
+
label: ""
|
|
91
|
+
})) : chatPill;
|
|
142
92
|
}));
|
|
143
93
|
};
|
|
@@ -35,95 +35,5 @@ var messages = exports.messages = (0, _reactIntlNext.defineMessages)({
|
|
|
35
35
|
id: 'ai-mate.chat-history.empty-state.agent-suggestion3',
|
|
36
36
|
defaultMessage: "Summarize what I'm looking at",
|
|
37
37
|
description: 'The third suggestion displayed in the empty state when an agent is selected'
|
|
38
|
-
},
|
|
39
|
-
confluenceHomeSuggestion1: {
|
|
40
|
-
id: 'ai-mate.chat-history.empty-state.confluence-home.suggestion1',
|
|
41
|
-
defaultMessage: "Is there any new activity on pages I've written?",
|
|
42
|
-
description: 'The first suggestion displayed in the empty state of the chat history when viewing confluence home.'
|
|
43
|
-
},
|
|
44
|
-
confluenceHomeSuggestion2: {
|
|
45
|
-
id: 'ai-mate.chat-history.empty-state.confluence-home.suggestion2',
|
|
46
|
-
defaultMessage: "What's popular at the moment?",
|
|
47
|
-
description: 'The second suggestion displayed in the empty state of the chat history when viewing confluence home.'
|
|
48
|
-
},
|
|
49
|
-
confluenceHomeSuggestion3: {
|
|
50
|
-
id: 'ai-mate.chat-history.empty-state.confluence-home.suggestion3',
|
|
51
|
-
defaultMessage: 'How can Rovo help me use Confluence?',
|
|
52
|
-
description: 'The third suggestion displayed in the empty state of the chat history when viewing confluence home.'
|
|
53
|
-
},
|
|
54
|
-
confluencePageEditSuggestion1: {
|
|
55
|
-
id: 'ai-mate.chat-history.empty-state.confluence-page-edit.suggestion1',
|
|
56
|
-
defaultMessage: 'Can you improve the writing on this page?',
|
|
57
|
-
description: 'The first suggestion displayed in the empty state of the chat history when editing a confluence page.'
|
|
58
|
-
},
|
|
59
|
-
confluencePageEditSuggestion2: {
|
|
60
|
-
id: 'ai-mate.chat-history.empty-state.confluence-page-edit.suggestion2',
|
|
61
|
-
defaultMessage: 'Write an executive summary for this page.',
|
|
62
|
-
description: 'The second suggestion displayed in the empty state of the chat history when editing a confluence page.'
|
|
63
|
-
},
|
|
64
|
-
confluencePageEditSuggestion3: {
|
|
65
|
-
id: 'ai-mate.chat-history.empty-state.confluence-page-edit.suggestion3',
|
|
66
|
-
defaultMessage: 'Give me links to some other relevant pages.',
|
|
67
|
-
description: 'The third suggestion displayed in the empty state of the chat history when editing a confluence page.'
|
|
68
|
-
},
|
|
69
|
-
confluencePageViewSuggestion1: {
|
|
70
|
-
id: 'ai-mate.chat-history.empty-state.confluence-page-view.suggestion1',
|
|
71
|
-
defaultMessage: 'Summarize what I’m looking at.',
|
|
72
|
-
description: 'The first suggestion displayed in the empty state of the chat history when viewing a confluence page.'
|
|
73
|
-
},
|
|
74
|
-
confluencePageViewSuggestion2: {
|
|
75
|
-
id: 'ai-mate.chat-history.empty-state.confluence-page-view.suggestion2',
|
|
76
|
-
defaultMessage: 'Has anything on this page changed in the last week?',
|
|
77
|
-
description: 'The second suggestion displayed in the empty state of the chat history when viewing a confluence page.'
|
|
78
|
-
},
|
|
79
|
-
confluencePageViewSuggestion3: {
|
|
80
|
-
id: 'ai-mate.chat-history.empty-state.confluence-page-view.suggestion3',
|
|
81
|
-
defaultMessage: 'Summarize the comments on this page.',
|
|
82
|
-
description: 'The third suggestion displayed in the empty state of the chat history when viewing a confluence page.'
|
|
83
|
-
},
|
|
84
|
-
jiraHomeSuggestion1: {
|
|
85
|
-
id: 'ai-mate.chat-history.empty-state.jira-home.suggestion1',
|
|
86
|
-
defaultMessage: 'What’s changed in the past week?',
|
|
87
|
-
description: 'The first suggestion displayed in the empty state of the chat history when viewing jira home.'
|
|
88
|
-
},
|
|
89
|
-
jiraHomeSuggestion2: {
|
|
90
|
-
id: 'ai-mate.chat-history.empty-state.jira-home.suggestion2',
|
|
91
|
-
defaultMessage: 'What issues are the highest priority?',
|
|
92
|
-
description: 'The second suggestion displayed in the empty state of the chat history when viewing jira home.'
|
|
93
|
-
},
|
|
94
|
-
jiraHomeSuggestion3: {
|
|
95
|
-
id: 'ai-mate.chat-history.empty-state.jira-home.suggestion3',
|
|
96
|
-
defaultMessage: 'What issues have comments mentioning me?',
|
|
97
|
-
description: 'The third suggestion displayed in the empty state of the chat history when viewing jira home.'
|
|
98
|
-
},
|
|
99
|
-
jiraIssueViewSuggestion1: {
|
|
100
|
-
id: 'ai-mate.chat-history.empty-state.jira-issue-view.suggestion1',
|
|
101
|
-
defaultMessage: 'Are there any similar issues to this one?',
|
|
102
|
-
description: 'The first suggestion displayed in the empty state of the chat history when viewing a jira issue.'
|
|
103
|
-
},
|
|
104
|
-
jiraIssueViewSuggestion2: {
|
|
105
|
-
id: 'ai-mate.chat-history.empty-state.jira-issue-view.suggestion2',
|
|
106
|
-
defaultMessage: 'What issues aren’t connected to a parent issue?',
|
|
107
|
-
description: 'The second suggestion displayed in the empty state of the chat history when viewing a jira issue.'
|
|
108
|
-
},
|
|
109
|
-
jiraIssueViewSuggestion3: {
|
|
110
|
-
id: 'ai-mate.chat-history.empty-state.jira-issue-view.suggestion3',
|
|
111
|
-
defaultMessage: 'List the issues that are currently “In Progress” and group them by assignee.',
|
|
112
|
-
description: 'The third suggestion displayed in the empty state of the chat history when viewing a jira issue.'
|
|
113
|
-
},
|
|
114
|
-
jiraIssueListSuggestion1: {
|
|
115
|
-
id: 'ai-mate.chat-history.empty-state.jira-issue-list.suggestion1',
|
|
116
|
-
defaultMessage: 'What issues are unassigned?',
|
|
117
|
-
description: 'The first suggestion displayed in the empty state of the chat history when viewing a list of jira issues.'
|
|
118
|
-
},
|
|
119
|
-
jiraIssueListSuggestion2: {
|
|
120
|
-
id: 'ai-mate.chat-history.empty-state.jira-issue-list.suggestion2',
|
|
121
|
-
defaultMessage: 'What issues have been open the longest?',
|
|
122
|
-
description: 'The second suggestion displayed in the empty state of the chat history when viewing a list of jira issues.'
|
|
123
|
-
},
|
|
124
|
-
jiraIssueListSuggestion3: {
|
|
125
|
-
id: 'ai-mate.chat-history.empty-state.jira-issue-list.suggestion3',
|
|
126
|
-
defaultMessage: 'Who has the most tasks?',
|
|
127
|
-
description: 'The third suggestion displayed in the empty state of the chat history when viewing a list of jira issues.'
|
|
128
38
|
}
|
|
129
39
|
});
|
|
@@ -2,8 +2,8 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Icon from '@atlaskit/icon';
|
|
4
4
|
const CustomGlyph = props => /*#__PURE__*/React.createElement("svg", _extends({
|
|
5
|
-
width: "
|
|
6
|
-
height: "
|
|
5
|
+
width: "16",
|
|
6
|
+
height: "16",
|
|
7
7
|
viewBox: "0 0 20 20",
|
|
8
8
|
fill: "none",
|
|
9
9
|
xmlns: "http://www.w3.org/2000/svg"
|
|
@@ -37,5 +37,6 @@ const CustomGlyph = props => /*#__PURE__*/React.createElement("svg", _extends({
|
|
|
37
37
|
}));
|
|
38
38
|
export const ChatPillIcon = props => /*#__PURE__*/React.createElement(Icon, _extends({}, props, {
|
|
39
39
|
glyph: CustomGlyph,
|
|
40
|
-
label: ""
|
|
40
|
+
label: "",
|
|
41
|
+
size: "small"
|
|
41
42
|
}));
|
|
@@ -7,7 +7,7 @@ const buttonStyles = xcss({
|
|
|
7
7
|
padding: 'space.100',
|
|
8
8
|
borderRadius: 'border.radius.200',
|
|
9
9
|
borderBottomRightRadius: "var(--ds-border-radius-050, 2px)",
|
|
10
|
-
lineHeight: '
|
|
10
|
+
lineHeight: '16px',
|
|
11
11
|
fontWeight: '500',
|
|
12
12
|
fontSize: '14px',
|
|
13
13
|
textOverflow: 'ellipsis',
|
|
@@ -31,10 +31,6 @@ const queryTextStyles = xcss({
|
|
|
31
31
|
const whiteSpacePreWrapStyles = xcss({
|
|
32
32
|
whiteSpace: 'pre-wrap'
|
|
33
33
|
});
|
|
34
|
-
const iconWrapper = xcss({
|
|
35
|
-
minWidth: '20px',
|
|
36
|
-
height: '20px'
|
|
37
|
-
});
|
|
38
34
|
export const ChatPill = /*#__PURE__*/React.forwardRef(({
|
|
39
35
|
children,
|
|
40
36
|
whiteSpacePreWrap = true,
|
|
@@ -46,8 +42,6 @@ export const ChatPill = /*#__PURE__*/React.forwardRef(({
|
|
|
46
42
|
}), /*#__PURE__*/React.createElement(Inline, {
|
|
47
43
|
space: "space.050",
|
|
48
44
|
xcss: buttonInlineStyles
|
|
49
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
50
|
-
xcss: iconWrapper
|
|
51
|
-
}, /*#__PURE__*/React.createElement(ChatPillIcon, null)), /*#__PURE__*/React.createElement(Box, {
|
|
45
|
+
}, /*#__PURE__*/React.createElement(ChatPillIcon, null), /*#__PURE__*/React.createElement(Box, {
|
|
52
46
|
xcss: [queryTextStyles, whiteSpacePreWrap && whiteSpacePreWrapStyles]
|
|
53
47
|
}, children))));
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { AgentProfileInfo, AgentProfileCreator, AgentStarCount } from './ui/agent-profile-info';
|
|
2
2
|
export { StarIconButton } from './common/ui/star-icon-button';
|
|
3
|
-
export { AgentConversationStarters, getConversationStarters } from './ui/agent-conversation-starters';
|
|
3
|
+
export { AgentConversationStarters, ConversationStarters, getConversationStarters } from './ui/agent-conversation-starters';
|
|
4
4
|
export { ChatPill } from './common/ui/chat-pill';
|
|
5
5
|
export { ChatPillIcon } from './common/ui/chat-icon';
|
|
6
6
|
export { AgentAvatar } from './ui/agent-avatar';
|
|
@@ -1,84 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
3
|
import { useIntl } from 'react-intl-next';
|
|
4
|
-
import {
|
|
4
|
+
import { IconButton } from '@atlaskit/button/new';
|
|
5
|
+
import RetryIcon from '@atlaskit/icon/core/retry';
|
|
6
|
+
import { Inline } from '@atlaskit/primitives';
|
|
5
7
|
import { ChatPill } from '../../common/ui/chat-pill';
|
|
6
8
|
import { messages } from './messages';
|
|
7
|
-
function useWindowLocationChange() {
|
|
8
|
-
const [location, setLocation] = useState(window.location.href);
|
|
9
|
-
const handleLocationChange = () => {
|
|
10
|
-
setLocation(window.location.href);
|
|
11
|
-
};
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const originalPushState = window.history.pushState;
|
|
14
|
-
const originalReplaceState = window.history.replaceState;
|
|
15
|
-
window.history.pushState = function (...args) {
|
|
16
|
-
originalPushState.apply(this, args);
|
|
17
|
-
handleLocationChange();
|
|
18
|
-
};
|
|
19
|
-
window.history.replaceState = function (...args) {
|
|
20
|
-
originalReplaceState.apply(this, args);
|
|
21
|
-
handleLocationChange();
|
|
22
|
-
};
|
|
23
|
-
const unbind = bindAll(window, [{
|
|
24
|
-
type: 'popstate',
|
|
25
|
-
listener: handleLocationChange
|
|
26
|
-
}]);
|
|
27
|
-
return () => {
|
|
28
|
-
unbind();
|
|
29
|
-
window.history.pushState = originalPushState;
|
|
30
|
-
window.history.replaceState = originalReplaceState;
|
|
31
|
-
};
|
|
32
|
-
}, []);
|
|
33
|
-
return location;
|
|
34
|
-
}
|
|
35
|
-
export let PageContextType = /*#__PURE__*/function (PageContextType) {
|
|
36
|
-
PageContextType["CONFLUENCE_HOME"] = "confluence-home";
|
|
37
|
-
PageContextType["CONFLUENCE_PAGE_VIEW"] = "confluence-page-view";
|
|
38
|
-
PageContextType["CONFLUENCE_PAGE_EDIT"] = "confluence-page-edit";
|
|
39
|
-
PageContextType["JIRA_HOME"] = "jira-home";
|
|
40
|
-
PageContextType["JIRA_ISSUE_VIEW"] = "jira-issue-view";
|
|
41
|
-
PageContextType["JIRA_ISSUE_LIST"] = "jira-issue-list";
|
|
42
|
-
PageContextType["UNKNOWN"] = "unknown";
|
|
43
|
-
return PageContextType;
|
|
44
|
-
}({});
|
|
45
|
-
const PAGE_TYPE_CONVERSATION_STARTERS = {
|
|
46
|
-
[PageContextType.CONFLUENCE_HOME]: [messages.confluenceHomeSuggestion1, messages.confluenceHomeSuggestion2, messages.confluenceHomeSuggestion3],
|
|
47
|
-
[PageContextType.CONFLUENCE_PAGE_EDIT]: [messages.confluencePageEditSuggestion1, messages.confluencePageEditSuggestion2, messages.confluencePageEditSuggestion3],
|
|
48
|
-
[PageContextType.CONFLUENCE_PAGE_VIEW]: [messages.confluencePageViewSuggestion1, messages.confluencePageViewSuggestion2, messages.confluencePageViewSuggestion3],
|
|
49
|
-
[PageContextType.JIRA_HOME]: [messages.jiraHomeSuggestion1, messages.jiraHomeSuggestion2, messages.jiraHomeSuggestion3],
|
|
50
|
-
[PageContextType.JIRA_ISSUE_VIEW]: [messages.jiraIssueViewSuggestion1, messages.jiraIssueViewSuggestion2, messages.jiraIssueViewSuggestion3],
|
|
51
|
-
[PageContextType.JIRA_ISSUE_LIST]: [messages.jiraIssueListSuggestion1, messages.jiraIssueListSuggestion2, messages.jiraIssueListSuggestion3],
|
|
52
|
-
[PageContextType.UNKNOWN]: [messages.emptyStateSuggestion1, messages.emptyStateSuggestion2, messages.emptyStateSuggestion3]
|
|
53
|
-
};
|
|
54
|
-
function determinePageType(location) {
|
|
55
|
-
const urlPatterns = [[PageContextType.CONFLUENCE_HOME, /\/wiki\/home$/], [PageContextType.CONFLUENCE_PAGE_EDIT, /\/wiki\/spaces\/[^\/]+\/(?:pages|blog)\/edit-v2\//], [PageContextType.CONFLUENCE_PAGE_VIEW, /\/wiki\/spaces\/[^\/]+\/(?:pages|blog)\//], [PageContextType.JIRA_ISSUE_VIEW, /\/browse\/[^\/]+$/], [PageContextType.JIRA_ISSUE_VIEW, /\/jira\/.+\/projects\/.+\?selectedIssue/], [PageContextType.JIRA_ISSUE_LIST, /\/jira\/.+\/projects\//], [PageContextType.JIRA_HOME, /\/jira\/dashboards\/last-visited$/]];
|
|
56
|
-
for (const [type, pattern] of urlPatterns) {
|
|
57
|
-
if (pattern.test(location)) {
|
|
58
|
-
return type;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return PageContextType.UNKNOWN;
|
|
62
|
-
}
|
|
63
|
-
export const usePageContextType = () => {
|
|
64
|
-
const location = useWindowLocationChange();
|
|
65
|
-
const [pageContextType, setPageContextType] = useState(determinePageType(location));
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
setPageContextType(determinePageType(location));
|
|
68
|
-
}, [location]);
|
|
69
|
-
return pageContextType;
|
|
70
|
-
};
|
|
71
9
|
export const getConversationStarters = ({
|
|
72
10
|
userDefinedConversationStarters: userDefinedConversationStartersParam,
|
|
73
|
-
isAgentDefault
|
|
74
|
-
pageContextType = PageContextType.UNKNOWN
|
|
11
|
+
isAgentDefault
|
|
75
12
|
}) => {
|
|
76
13
|
const customAgentConversationStarters = [messages.agentEmptyStateSuggestion1, messages.agentEmptyStateSuggestion2, messages.agentEmptyStateSuggestion3];
|
|
77
14
|
const userDefinedConversationStarters = userDefinedConversationStartersParam !== null && userDefinedConversationStartersParam !== void 0 ? userDefinedConversationStartersParam : [];
|
|
78
|
-
const
|
|
79
|
-
const defaultAgentConversationStarters = isPageContextConvoStartersEnabled ? PAGE_TYPE_CONVERSATION_STARTERS[pageContextType] : [messages.emptyStateSuggestion1, messages.emptyStateSuggestion2, messages.emptyStateSuggestion3];
|
|
15
|
+
const defaultAgentConversationStarters = [messages.emptyStateSuggestion1, messages.emptyStateSuggestion2, messages.emptyStateSuggestion3];
|
|
80
16
|
const getCombinedConversationStarters = () => {
|
|
81
|
-
|
|
17
|
+
const shouldCombine = !isAgentDefault;
|
|
18
|
+
if (shouldCombine) {
|
|
82
19
|
// Return default suggestions + user defined suggestions with a max of 3 suggestions
|
|
83
20
|
return [...customAgentConversationStarters.slice(0, 3 - userDefinedConversationStarters.length), ...userDefinedConversationStarters];
|
|
84
21
|
}
|
|
@@ -94,28 +31,45 @@ export const getConversationStarters = ({
|
|
|
94
31
|
export const AgentConversationStarters = ({
|
|
95
32
|
userDefinedConversationStarters,
|
|
96
33
|
isAgentDefault,
|
|
97
|
-
|
|
34
|
+
...props
|
|
98
35
|
}) => {
|
|
99
36
|
const {
|
|
100
37
|
formatMessage
|
|
101
38
|
} = useIntl();
|
|
102
|
-
const pageContextType = usePageContextType();
|
|
103
39
|
const {
|
|
104
40
|
combinedConversationStarters
|
|
105
41
|
} = useMemo(() => getConversationStarters({
|
|
106
42
|
userDefinedConversationStarters,
|
|
107
|
-
isAgentDefault
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
43
|
+
isAgentDefault
|
|
44
|
+
}), [userDefinedConversationStarters, isAgentDefault]);
|
|
45
|
+
const starters = useMemo(() => combinedConversationStarters.map(starter => typeof starter === 'string' ? starter : formatMessage(starter)), [combinedConversationStarters, formatMessage]);
|
|
46
|
+
return /*#__PURE__*/React.createElement(ConversationStarters, _extends({
|
|
47
|
+
starters: starters
|
|
48
|
+
}, props));
|
|
49
|
+
};
|
|
50
|
+
export const ConversationStarters = ({
|
|
51
|
+
starters,
|
|
52
|
+
onConversationStarterClick,
|
|
53
|
+
showReloadButton = false,
|
|
54
|
+
onReloadButtonClick = () => {}
|
|
55
|
+
}) => {
|
|
56
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, starters.map((starter, index) => {
|
|
57
|
+
const isLastStarter = index === starters.length - 1;
|
|
58
|
+
const chatPill = /*#__PURE__*/React.createElement(ChatPill, {
|
|
116
59
|
testId: "conversation-starter",
|
|
117
|
-
key:
|
|
118
|
-
onClick: () =>
|
|
119
|
-
},
|
|
60
|
+
key: starter,
|
|
61
|
+
onClick: () => onConversationStarterClick(starter)
|
|
62
|
+
}, starter);
|
|
63
|
+
return isLastStarter && showReloadButton ? /*#__PURE__*/React.createElement(Inline, {
|
|
64
|
+
space: "space.050",
|
|
65
|
+
grow: "fill",
|
|
66
|
+
alignInline: "end",
|
|
67
|
+
key: starter
|
|
68
|
+
}, chatPill, /*#__PURE__*/React.createElement(IconButton, {
|
|
69
|
+
icon: RetryIcon,
|
|
70
|
+
onClick: onReloadButtonClick,
|
|
71
|
+
appearance: "subtle",
|
|
72
|
+
label: ""
|
|
73
|
+
})) : chatPill;
|
|
120
74
|
}));
|
|
121
75
|
};
|