@atlaskit/editor-plugin-mentions 18.0.6 → 18.1.1

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 18.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`243f04087ceef`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/243f04087ceef) -
8
+ Dismiss the agent profile card and clear the mention's node selection when opening Rovo chat from
9
+ the mention card's chat action, gated behind platform_editor_agent_card_close_on_chat.
10
+ - Updated dependencies
11
+
12
+ ## 18.1.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [`e25ceefc49864`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e25ceefc49864) -
17
+ Style agent mentions based on their run-state, with mention pills showing a shimmer when agent is
18
+ in the "analysing" state. Changes are gated behind the `platform_editor_agent_mention_state_anim`
19
+ experiment.
20
+
3
21
  ## 18.0.6
4
22
 
5
23
  ### Patch Changes
@@ -31,7 +31,7 @@ var _InlineInvitePopupContainer = require("./ui/InlineInvitePopupContainer");
31
31
  var _SecondaryToolbarComponent = require("./ui/SecondaryToolbarComponent");
32
32
  var _typeAhead = require("./ui/type-ahead");
33
33
  var _getMentionQuickInsertComponents = require("./ui/quick-insert/getMentionQuickInsertComponents");
34
- var _excluded2 = ["pendingPastedAgentMention"]; // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
34
+ var _excluded2 = ["pendingPastedAgentMention", "runStateDecorations"]; // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
35
35
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
36
36
  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; }
37
37
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(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; }
@@ -215,6 +215,21 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
215
215
  options.handleMentionsChanged(mentionChanges);
216
216
  }
217
217
  },
218
+ setAgentMentionRunStates: function setAgentMentionRunStates(runStateByLocalId) {
219
+ var _api$core$actions$exe;
220
+ if (!((0, _experiments.editorExperiment)('platform_editor_agent_mentions', true) && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mention_state_anim'))) {
221
+ return false;
222
+ }
223
+ return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref7) {
224
+ var tr = _ref7.tr;
225
+ return tr.setMeta(_key.mentionPluginKey, {
226
+ action: _main.ACTIONS.SET_AGENT_RUN_STATES,
227
+ params: {
228
+ runStateByLocalId: runStateByLocalId
229
+ }
230
+ });
231
+ })) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
232
+ },
218
233
  updateSectionTitle: function updateSectionTitle(props) {
219
234
  var _api$typeAhead$action, _api$typeAhead2, _api$typeAhead2$updat;
220
235
  if (!(options !== null && options !== void 0 && options.enableAgentSectioning)) {
@@ -224,7 +239,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
224
239
  },
225
240
  setProvider: function () {
226
241
  var _setProvider = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(providerPromise) {
227
- var _api$core$actions$exe;
242
+ var _api$core$actions$exe2;
228
243
  var provider;
229
244
  return _regenerator.default.wrap(function (_context) {
230
245
  while (1) switch (_context.prev = _context.next) {
@@ -246,15 +261,15 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
246
261
  return _context.abrupt("return", false);
247
262
  case 3:
248
263
  previousMediaProvider = provider;
249
- return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref7) {
250
- var tr = _ref7.tr;
264
+ return _context.abrupt("return", (_api$core$actions$exe2 = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref8) {
265
+ var tr = _ref8.tr;
251
266
  return tr.setMeta(_key.mentionPluginKey, {
252
267
  action: _main.ACTIONS.SET_PROVIDER,
253
268
  params: {
254
269
  provider: provider
255
270
  }
256
271
  });
257
- })) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false);
272
+ })) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false);
258
273
  case 4:
259
274
  case "end":
260
275
  return _context.stop();
@@ -276,9 +291,10 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
276
291
  // Exclude pendingPastedAgentMention — it is an @internal transient field and
277
292
  // should not be part of the public shared state API. Exposing it would cause
278
293
  // unnecessary re-renders in subscribers and leak implementation details.
279
- var _ref8 = mentionPluginState !== null && mentionPluginState !== void 0 ? mentionPluginState : {},
280
- _excluded = _ref8.pendingPastedAgentMention,
281
- publicPluginState = (0, _objectWithoutProperties2.default)(_ref8, _excluded2);
294
+ var _ref9 = mentionPluginState !== null && mentionPluginState !== void 0 ? mentionPluginState : {},
295
+ _excluded = _ref9.pendingPastedAgentMention,
296
+ _excludedRunState = _ref9.runStateDecorations,
297
+ publicPluginState = (0, _objectWithoutProperties2.default)(_ref9, _excluded2);
282
298
  return _objectSpread(_objectSpread(_objectSpread({}, publicPluginState), agentMentionPluginState ? {
283
299
  lastAgentMentionInsertionCount: agentMentionPluginState.lastAgentMentionInsertionCount,
284
300
  lastInsertedAgentMentionContext: agentMentionPluginState.lastInsertedAgentMentionContext,
@@ -292,8 +308,8 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
292
308
  });
293
309
  },
294
310
  pluginsOptions: {
295
- quickInsert: isRegisteredSlashCommandEnabled ? undefined : function (_ref9) {
296
- var formatMessage = _ref9.formatMessage;
311
+ quickInsert: isRegisteredSlashCommandEnabled ? undefined : function (_ref0) {
312
+ var formatMessage = _ref0.formatMessage;
297
313
  return [{
298
314
  id: 'mention',
299
315
  title: formatMessage(_messages.toolbarInsertBlockMessages.mention),
@@ -103,7 +103,14 @@ var profileCardRenderer = exports.profileCardRenderer = function profileCardRend
103
103
  profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
104
104
  onAgentMentionChatClick: options !== null && options !== void 0 && options.onAgentMentionChatClick && (0, _fg.fg)('platform_editor_agent_mentions_drop_one_fixes') ? function (agentId) {
105
105
  var _options$onAgentMenti;
106
- return (_options$onAgentMenti = options.onAgentMentionChatClick) === null || _options$onAgentMenti === void 0 ? void 0 : _options$onAgentMenti.call(options, agentId, agentMentionContext);
106
+ (_options$onAgentMenti = options.onAgentMentionChatClick) === null || _options$onAgentMenti === void 0 || _options$onAgentMenti.call(options, agentId, agentMentionContext);
107
+ // The mention stays node-selected after the chat opens; collapse the
108
+ // selection to a cursor just after it so it is no longer left selected.
109
+ // Selection-only change, so it does not move focus (EDITOR-8257).
110
+ if (editorView && (0, _fg.fg)('platform_editor_agent_card_close_on_chat')) {
111
+ var state = editorView.state;
112
+ editorView.dispatch(state.tr.setSelection(_state.TextSelection.create(state.doc, state.selection.to)));
113
+ }
107
114
  } : undefined,
108
115
  dom: referenceElement,
109
116
  closeComponent: removeProfileCard
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.nextRunStateDecorations = exports.buildAgentRunStateDecorations = void 0;
7
+ var _view = require("@atlaskit/editor-prosemirror/view");
8
+ var AGENT_MENTION_USER_TYPES = new Set(['APP', 'AGENT']);
9
+ var isAgentMentionUserType = function isAgentMentionUserType(userType) {
10
+ return typeof userType === 'string' && AGENT_MENTION_USER_TYPES.has(userType);
11
+ };
12
+ var AGENT_RUN_STATE_ANALYSING_CLASS = 'agent-mention-analysing-state';
13
+
14
+ /**
15
+ * Map the bridge's run-state to a mention node visual class.
16
+ * Currently only the "analysing" state changes the chip, applying a shimmer to the pill.
17
+ */
18
+ var getRunStateClass = function getRunStateClass(runState) {
19
+ switch (runState) {
20
+ case 'thinking':
21
+ case 'working':
22
+ return AGENT_RUN_STATE_ANALYSING_CLASS;
23
+ default:
24
+ return undefined;
25
+ }
26
+ };
27
+
28
+ /**
29
+ * Build the node-decoration set that styles agent mentions by their run-state.
30
+ */
31
+ var buildAgentRunStateDecorations = exports.buildAgentRunStateDecorations = function buildAgentRunStateDecorations(state, runStateByLocalId) {
32
+ if (!runStateByLocalId || Object.keys(runStateByLocalId).length === 0) {
33
+ return _view.DecorationSet.empty;
34
+ }
35
+ var mentionNodeType = state.schema.nodes.mention;
36
+ if (!mentionNodeType) {
37
+ return _view.DecorationSet.empty;
38
+ }
39
+ var decorations = [];
40
+ state.doc.descendants(function (node, pos) {
41
+ if (node.type !== mentionNodeType || !isAgentMentionUserType(node.attrs.userType)) {
42
+ return true;
43
+ }
44
+ var localId = node.attrs.localId;
45
+ var runState = typeof localId === 'string' ? runStateByLocalId[localId] : undefined;
46
+ if (!runState) {
47
+ return true;
48
+ }
49
+ var stateClass = getRunStateClass(runState);
50
+ if (!stateClass) {
51
+ return true;
52
+ }
53
+ decorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
54
+ class: stateClass
55
+ }));
56
+ return true;
57
+ });
58
+ return decorations.length ? _view.DecorationSet.create(state.doc, decorations) : _view.DecorationSet.empty;
59
+ };
60
+
61
+ /**
62
+ * Computes the next cached run-state `DecorationSet` for a plugin's `apply`, so that
63
+ * `props.decorations` can return a stored set instead of walking the doc on every transaction:
64
+ */
65
+ var nextRunStateDecorations = exports.nextRunStateDecorations = function nextRunStateDecorations(previous, tr, newState, runStateByLocalId) {
66
+ if (runStateByLocalId !== undefined) {
67
+ return buildAgentRunStateDecorations(newState, runStateByLocalId);
68
+ }
69
+ if (tr.docChanged && previous) {
70
+ return previous.map(tr.mapping, tr.doc);
71
+ }
72
+ return previous;
73
+ };
@@ -9,10 +9,13 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
+ var _view = require("@atlaskit/editor-prosemirror/view");
12
13
  var _resource = require("@atlaskit/mention/resource");
14
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
13
15
  var _fg = require("@atlaskit/platform-feature-flags/fg");
14
16
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
15
17
  var _agentMentionContext = require("./agent-mention-context");
18
+ var _agentRunState = require("./agent-run-state");
16
19
  var _key = require("./key");
17
20
  var _main = require("./main");
18
21
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
@@ -738,6 +741,7 @@ var createAgentMentionPlugin = exports.createAgentMentionPlugin = function creat
738
741
  return {};
739
742
  },
740
743
  apply: function apply(tr, pluginState, oldState, newState) {
744
+ var _meta$params$runState, _meta$params;
741
745
  var result = applyAgentMentionState({
742
746
  tr: tr,
743
747
  pluginState: pluginState,
@@ -745,11 +749,32 @@ var createAgentMentionPlugin = exports.createAgentMentionPlugin = function creat
745
749
  newState: newState,
746
750
  getIsRovoPanelOpen: options === null || options === void 0 ? void 0 : options.getIsRovoPanelOpen
747
751
  });
752
+ var nextPluginState = result.pluginState;
753
+ var meta = tr.getMeta(_key.mentionPluginKey);
754
+ var nextDecorations = (0, _agentRunState.nextRunStateDecorations)(pluginState.runStateDecorations, tr, newState, (meta === null || meta === void 0 ? void 0 : meta.action) === _main.ACTIONS.SET_AGENT_RUN_STATES ? (_meta$params$runState = (_meta$params = meta.params) === null || _meta$params === void 0 ? void 0 : _meta$params.runStateByLocalId) !== null && _meta$params$runState !== void 0 ? _meta$params$runState : {} : undefined);
755
+ if (nextPluginState.runStateDecorations !== nextDecorations) {
756
+ nextPluginState = _objectSpread(_objectSpread({}, nextPluginState), {}, {
757
+ runStateDecorations: nextDecorations
758
+ });
759
+ }
748
760
  var mentionPluginState = _key.mentionPluginKey.getState(newState);
749
761
  if (result.hasPublicPluginStateChanged) {
750
762
  pmPluginFactoryParams.dispatch(_key.mentionPluginKey, _objectSpread(_objectSpread({}, mentionPluginState), result.pluginState));
751
763
  }
752
- return result.pluginState;
764
+ return nextPluginState;
765
+ }
766
+ },
767
+ props: {
768
+ decorations: function decorations(state) {
769
+ var _agentMentionPluginKe;
770
+ var runStateDecorations = (_agentMentionPluginKe = agentMentionPluginKey.getState(state)) === null || _agentMentionPluginKe === void 0 ? void 0 : _agentMentionPluginKe.runStateDecorations;
771
+ if (!runStateDecorations || runStateDecorations === _view.DecorationSet.empty) {
772
+ return undefined;
773
+ }
774
+ if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mention_state_anim')) {
775
+ return undefined;
776
+ }
777
+ return runStateDecorations;
753
778
  }
754
779
  },
755
780
  view: function view(editorView) {
@@ -11,6 +11,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
13
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
14
+ var _view = require("@atlaskit/editor-prosemirror/view");
14
15
  var _insm = require("@atlaskit/insm");
15
16
  var _resource = require("@atlaskit/mention/resource");
16
17
  var _types = require("@atlaskit/mention/types");
@@ -20,6 +21,7 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
20
21
  var _mentionNodeView = require("../nodeviews/mentionNodeView");
21
22
  var _types2 = require("../types");
22
23
  var _agentMentionContext = require("./agent-mention-context");
24
+ var _agentRunState = require("./agent-run-state");
23
25
  var _key = require("./key");
24
26
  var _utils = require("./utils");
25
27
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
@@ -32,6 +34,11 @@ var ACTIONS = exports.ACTIONS = {
32
34
  DISCARD_PENDING_TYPED_AGENT_MENTION: 'DISCARD_PENDING_TYPED_AGENT_MENTION',
33
35
  SET_PENDING_TYPED_AGENT_MENTION: 'SET_PENDING_TYPED_AGENT_MENTION',
34
36
  SET_PROVIDER: 'SET_PROVIDER',
37
+ /**
38
+ * Dispatched by the `setAgentMentionRunStates` action to push the product's run-state
39
+ * map into plugin state, which drives the run-state node decorations.
40
+ */
41
+ SET_AGENT_RUN_STATES: 'SET_AGENT_RUN_STATES',
35
42
  /**
36
43
  * Dispatched from view().update() when async resolveMentionName() resolves
37
44
  * for a pasted agent mention.
@@ -67,7 +74,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
67
74
  var AGENT_MENTION_INACTIVITY_MS = 3000;
68
75
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
69
76
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
70
- var PACKAGE_VERSION = "18.0.5";
77
+ var PACKAGE_VERSION = "18.1.0";
71
78
  var setProvider = function setProvider(provider) {
72
79
  return function (state, dispatch) {
73
80
  if (dispatch) {
@@ -377,6 +384,7 @@ function createMentionPlugin(_ref2) {
377
384
  };
378
385
  },
379
386
  apply: function apply(tr, pluginState, oldState, newState) {
387
+ var _params$runStateByLoc;
380
388
  var _ref3 = tr.getMeta(_key.mentionPluginKey) || {
381
389
  action: null,
382
390
  params: null
@@ -400,6 +408,12 @@ function createMentionPlugin(_ref2) {
400
408
  hasPublicPluginStateChanged = true;
401
409
  break;
402
410
  }
411
+ var nextDecorations = (0, _agentRunState.nextRunStateDecorations)(newPluginState.runStateDecorations, tr, newState, action === ACTIONS.SET_AGENT_RUN_STATES ? (_params$runStateByLoc = params === null || params === void 0 ? void 0 : params.runStateByLocalId) !== null && _params$runStateByLoc !== void 0 ? _params$runStateByLoc : {} : undefined);
412
+ if (nextDecorations !== newPluginState.runStateDecorations) {
413
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
414
+ runStateDecorations: nextDecorations
415
+ });
416
+ }
403
417
  if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mentions_separate_pm_plugin') && (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true)) {
404
418
  switch (action) {
405
419
  case ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION:
@@ -827,6 +841,19 @@ function createMentionPlugin(_ref2) {
827
841
  portalProviderAPI: pmPluginFactoryParams.portalProviderAPI
828
842
  });
829
843
  }
844
+ },
845
+ // Duplicated in platform/packages/editor/editor-plugin-mentions/src/pm-plugins/agent.ts
846
+ // Can remove once platform_editor_agent_mentions_separate_pm_plugin has been cleaned up
847
+ decorations: function decorations(state) {
848
+ var _mentionPluginKey$get;
849
+ var runStateDecorations = (_mentionPluginKey$get = _key.mentionPluginKey.getState(state)) === null || _mentionPluginKey$get === void 0 ? void 0 : _mentionPluginKey$get.runStateDecorations;
850
+ if (!runStateDecorations || runStateDecorations === _view.DecorationSet.empty) {
851
+ return undefined;
852
+ }
853
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mentions_separate_pm_plugin') || !(0, _experiments.editorExperiment)('platform_editor_agent_mentions', true) || !(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_mention_state_anim')) {
854
+ return undefined;
855
+ }
856
+ return runStateDecorations;
830
857
  }
831
858
  },
832
859
  view: function view(editorView) {
@@ -894,7 +921,7 @@ function createMentionPlugin(_ref2) {
894
921
  });
895
922
  pendingTypedAgentMentionTimerKey = timerKey;
896
923
  pendingTypedAgentMentionTimer = setTimeout(function () {
897
- var _mentionPluginKey$get;
924
+ var _mentionPluginKey$get2;
898
925
  {
899
926
  var _options$getIsRovoPan3;
900
927
  // Suppress the agent-mention nudge when the Rovo panel is already open. Task
@@ -915,7 +942,7 @@ function createMentionPlugin(_ref2) {
915
942
  return;
916
943
  }
917
944
  }
918
- var latestPendingTypedAgentMention = (_mentionPluginKey$get = _key.mentionPluginKey.getState(editorView.state)) === null || _mentionPluginKey$get === void 0 ? void 0 : _mentionPluginKey$get.pendingTypedAgentMention;
945
+ var latestPendingTypedAgentMention = (_mentionPluginKey$get2 = _key.mentionPluginKey.getState(editorView.state)) === null || _mentionPluginKey$get2 === void 0 ? void 0 : _mentionPluginKey$get2.pendingTypedAgentMention;
919
946
  if (!latestPendingTypedAgentMention || latestPendingTypedAgentMention.localId !== pendingTypedAgentMention.localId || latestPendingTypedAgentMention.resetCount !== pendingTypedAgentMention.resetCount) {
920
947
  return;
921
948
  }
@@ -11,4 +11,9 @@ var MENTION_PROVIDER_UNDEFINED = exports.MENTION_PROVIDER_UNDEFINED = 'UNDEFINED
11
11
  * @private
12
12
  * @deprecated Use {@link MentionsPluginOptions} instead.
13
13
  * @see https://product-fabric.atlassian.net/browse/ED-27496
14
+ */
15
+
16
+ /**
17
+ * Agent run-state for an agent mention, mirrored from the agent-run-state bridge's
18
+ * `AgentRunState` (@atlassian/conversation-assistant-store/controllers/agent-mention-run-state).
14
19
  */
@@ -209,11 +209,13 @@ function ProfileCardComponent(_ref5) {
209
209
  hideActions: hideActions,
210
210
  text: (0, _expVal.expVal)('platform_editor_reduced_agent_profile_cards', 'isEnabled', false) ? text : undefined,
211
211
  onChatClick: onAgentMentionChatClick && (0, _fg.fg)('platform_editor_agent_mentions_drop_one_fixes') ? function (event, agentStudioId) {
212
- return (
213
- // agentMentionContext is already captured in the onAgentMentionChatClick
214
- // closure built by profileCardRenderer at chip-click time via doc.descendants()
215
- onAgentMentionChatClick(agentStudioId !== null && agentStudioId !== void 0 ? agentStudioId : id)
216
- );
212
+ // agentMentionContext is already captured in the onAgentMentionChatClick
213
+ // closure built by profileCardRenderer at chip-click time via doc.descendants()
214
+ onAgentMentionChatClick(agentStudioId !== null && agentStudioId !== void 0 ? agentStudioId : id);
215
+ // Dismiss the profile card once the Rovo chat panel opens (EDITOR-8257).
216
+ if ((0, _fg.fg)('platform_editor_agent_card_close_on_chat')) {
217
+ closeComponent();
218
+ }
217
219
  } : undefined
218
220
  }) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
219
221
  accessLevel: accessLevel,
@@ -210,6 +210,20 @@ const mentionsPlugin = ({
210
210
  options.handleMentionsChanged(mentionChanges);
211
211
  }
212
212
  },
213
+ setAgentMentionRunStates: runStateByLocalId => {
214
+ var _api$core$actions$exe;
215
+ if (!(editorExperiment('platform_editor_agent_mentions', true) && isExperimentEnabled('platform_editor_agent_mention_state_anim'))) {
216
+ return false;
217
+ }
218
+ return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(({
219
+ tr
220
+ }) => tr.setMeta(mentionPluginKey, {
221
+ action: ACTIONS.SET_AGENT_RUN_STATES,
222
+ params: {
223
+ runStateByLocalId
224
+ }
225
+ }))) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
226
+ },
213
227
  updateSectionTitle: props => {
214
228
  var _api$typeAhead$action2, _api$typeAhead2, _api$typeAhead2$actio, _api$typeAhead2$actio2;
215
229
  if (!(options !== null && options !== void 0 && options.enableAgentSectioning)) {
@@ -218,7 +232,7 @@ const mentionsPlugin = ({
218
232
  return (_api$typeAhead$action2 = api === null || api === void 0 ? void 0 : (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : (_api$typeAhead2$actio = _api$typeAhead2.actions) === null || _api$typeAhead2$actio === void 0 ? void 0 : (_api$typeAhead2$actio2 = _api$typeAhead2$actio.updateSectionTitle) === null || _api$typeAhead2$actio2 === void 0 ? void 0 : _api$typeAhead2$actio2.call(_api$typeAhead2$actio, props)) !== null && _api$typeAhead$action2 !== void 0 ? _api$typeAhead$action2 : false;
219
233
  },
220
234
  setProvider: async providerPromise => {
221
- var _api$core$actions$exe;
235
+ var _api$core$actions$exe2;
222
236
  if (!fg('platform_editor_mention_provider_via_plugin_config')) {
223
237
  return false;
224
238
  }
@@ -228,14 +242,14 @@ const mentionsPlugin = ({
228
242
  return false;
229
243
  }
230
244
  previousMediaProvider = provider;
231
- return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(({
245
+ return (_api$core$actions$exe2 = api === null || api === void 0 ? void 0 : api.core.actions.execute(({
232
246
  tr
233
247
  }) => tr.setMeta(mentionPluginKey, {
234
248
  action: ACTIONS.SET_PROVIDER,
235
249
  params: {
236
250
  provider
237
251
  }
238
- }))) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
252
+ }))) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false;
239
253
  }
240
254
  },
241
255
  getSharedState(editorState) {
@@ -249,6 +263,8 @@ const mentionsPlugin = ({
249
263
  // unnecessary re-renders in subscribers and leak implementation details.
250
264
  const {
251
265
  pendingPastedAgentMention: _excluded,
266
+ // Internal decoration-only state, kept out of the public shared state.
267
+ runStateDecorations: _excludedRunState,
252
268
  ...publicPluginState
253
269
  } = mentionPluginState !== null && mentionPluginState !== void 0 ? mentionPluginState : {};
254
270
  return {
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { bind } from 'bind-event-listener';
3
3
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
4
4
  import uuid from 'uuid/v4';
5
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
+ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { findChildrenByAttr } from '@atlaskit/editor-prosemirror/utils';
7
7
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
8
8
  import { fg } from '@atlaskit/platform-feature-flags/fg';
@@ -92,7 +92,16 @@ export const profileCardRenderer = ({
92
92
  profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
93
93
  onAgentMentionChatClick: options !== null && options !== void 0 && options.onAgentMentionChatClick && fg('platform_editor_agent_mentions_drop_one_fixes') ? agentId => {
94
94
  var _options$onAgentMenti;
95
- return (_options$onAgentMenti = options.onAgentMentionChatClick) === null || _options$onAgentMenti === void 0 ? void 0 : _options$onAgentMenti.call(options, agentId, agentMentionContext);
95
+ (_options$onAgentMenti = options.onAgentMentionChatClick) === null || _options$onAgentMenti === void 0 ? void 0 : _options$onAgentMenti.call(options, agentId, agentMentionContext);
96
+ // The mention stays node-selected after the chat opens; collapse the
97
+ // selection to a cursor just after it so it is no longer left selected.
98
+ // Selection-only change, so it does not move focus (EDITOR-8257).
99
+ if (editorView && fg('platform_editor_agent_card_close_on_chat')) {
100
+ const {
101
+ state
102
+ } = editorView;
103
+ editorView.dispatch(state.tr.setSelection(TextSelection.create(state.doc, state.selection.to)));
104
+ }
96
105
  } : undefined,
97
106
  dom: referenceElement,
98
107
  closeComponent: removeProfileCard
@@ -0,0 +1,67 @@
1
+ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
2
+ const AGENT_MENTION_USER_TYPES = new Set(['APP', 'AGENT']);
3
+ const isAgentMentionUserType = userType => typeof userType === 'string' && AGENT_MENTION_USER_TYPES.has(userType);
4
+ const AGENT_RUN_STATE_ANALYSING_CLASS = 'agent-mention-analysing-state';
5
+
6
+ /**
7
+ * Map the bridge's run-state to a mention node visual class.
8
+ * Currently only the "analysing" state changes the chip, applying a shimmer to the pill.
9
+ */
10
+ const getRunStateClass = runState => {
11
+ switch (runState) {
12
+ case 'thinking':
13
+ case 'working':
14
+ return AGENT_RUN_STATE_ANALYSING_CLASS;
15
+ default:
16
+ return undefined;
17
+ }
18
+ };
19
+
20
+ /**
21
+ * Build the node-decoration set that styles agent mentions by their run-state.
22
+ */
23
+ export const buildAgentRunStateDecorations = (state, runStateByLocalId) => {
24
+ if (!runStateByLocalId || Object.keys(runStateByLocalId).length === 0) {
25
+ return DecorationSet.empty;
26
+ }
27
+ const mentionNodeType = state.schema.nodes.mention;
28
+ if (!mentionNodeType) {
29
+ return DecorationSet.empty;
30
+ }
31
+ const decorations = [];
32
+ state.doc.descendants((node, pos) => {
33
+ if (node.type !== mentionNodeType || !isAgentMentionUserType(node.attrs.userType)) {
34
+ return true;
35
+ }
36
+ const {
37
+ localId
38
+ } = node.attrs;
39
+ const runState = typeof localId === 'string' ? runStateByLocalId[localId] : undefined;
40
+ if (!runState) {
41
+ return true;
42
+ }
43
+ const stateClass = getRunStateClass(runState);
44
+ if (!stateClass) {
45
+ return true;
46
+ }
47
+ decorations.push(Decoration.node(pos, pos + node.nodeSize, {
48
+ class: stateClass
49
+ }));
50
+ return true;
51
+ });
52
+ return decorations.length ? DecorationSet.create(state.doc, decorations) : DecorationSet.empty;
53
+ };
54
+
55
+ /**
56
+ * Computes the next cached run-state `DecorationSet` for a plugin's `apply`, so that
57
+ * `props.decorations` can return a stored set instead of walking the doc on every transaction:
58
+ */
59
+ export const nextRunStateDecorations = (previous, tr, newState, runStateByLocalId) => {
60
+ if (runStateByLocalId !== undefined) {
61
+ return buildAgentRunStateDecorations(newState, runStateByLocalId);
62
+ }
63
+ if (tr.docChanged && previous) {
64
+ return previous.map(tr.mapping, tr.doc);
65
+ }
66
+ return previous;
67
+ };
@@ -1,9 +1,12 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
4
  import { isResolvingMentionProvider, MentionNameStatus } from '@atlaskit/mention/resource';
5
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
4
6
  import { fg } from '@atlaskit/platform-feature-flags/fg';
5
7
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
8
  import { getAgentMentionParentContext } from './agent-mention-context';
9
+ import { nextRunStateDecorations } from './agent-run-state';
7
10
  import { mentionPluginKey } from './key';
8
11
  import { ACTIONS } from './main';
9
12
 
@@ -705,6 +708,7 @@ export const createAgentMentionPlugin = ({
705
708
  return {};
706
709
  },
707
710
  apply(tr, pluginState, oldState, newState) {
711
+ var _meta$params$runState, _meta$params;
708
712
  const result = applyAgentMentionState({
709
713
  tr,
710
714
  pluginState,
@@ -712,6 +716,15 @@ export const createAgentMentionPlugin = ({
712
716
  newState,
713
717
  getIsRovoPanelOpen: options === null || options === void 0 ? void 0 : options.getIsRovoPanelOpen
714
718
  });
719
+ let nextPluginState = result.pluginState;
720
+ const meta = tr.getMeta(mentionPluginKey);
721
+ const nextDecorations = nextRunStateDecorations(pluginState.runStateDecorations, tr, newState, (meta === null || meta === void 0 ? void 0 : meta.action) === ACTIONS.SET_AGENT_RUN_STATES ? (_meta$params$runState = (_meta$params = meta.params) === null || _meta$params === void 0 ? void 0 : _meta$params.runStateByLocalId) !== null && _meta$params$runState !== void 0 ? _meta$params$runState : {} : undefined);
722
+ if (nextPluginState.runStateDecorations !== nextDecorations) {
723
+ nextPluginState = {
724
+ ...nextPluginState,
725
+ runStateDecorations: nextDecorations
726
+ };
727
+ }
715
728
  const mentionPluginState = mentionPluginKey.getState(newState);
716
729
  if (result.hasPublicPluginStateChanged) {
717
730
  pmPluginFactoryParams.dispatch(mentionPluginKey, {
@@ -719,7 +732,20 @@ export const createAgentMentionPlugin = ({
719
732
  ...result.pluginState
720
733
  });
721
734
  }
722
- return result.pluginState;
735
+ return nextPluginState;
736
+ }
737
+ },
738
+ props: {
739
+ decorations(state) {
740
+ var _agentMentionPluginKe;
741
+ const runStateDecorations = (_agentMentionPluginKe = agentMentionPluginKey.getState(state)) === null || _agentMentionPluginKe === void 0 ? void 0 : _agentMentionPluginKe.runStateDecorations;
742
+ if (!runStateDecorations || runStateDecorations === DecorationSet.empty) {
743
+ return undefined;
744
+ }
745
+ if (!isExperimentEnabled('platform_editor_agent_mention_state_anim')) {
746
+ return undefined;
747
+ }
748
+ return runStateDecorations;
723
749
  }
724
750
  },
725
751
  view(editorView) {
@@ -1,5 +1,6 @@
1
1
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
4
  import { insm } from '@atlaskit/insm';
4
5
  import { isResolvingMentionProvider, MentionNameStatus, SLI_EVENT_TYPE, SMART_EVENT_TYPE } from '@atlaskit/mention/resource';
5
6
  import { ComponentNames } from '@atlaskit/mention/types';
@@ -9,6 +10,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
10
  import { MentionNodeView } from '../nodeviews/mentionNodeView';
10
11
  import { MENTION_PROVIDER_REJECTED, MENTION_PROVIDER_UNDEFINED } from '../types';
11
12
  import { getAgentMentionParentContext } from './agent-mention-context';
13
+ import { nextRunStateDecorations } from './agent-run-state';
12
14
  import { mentionPluginKey } from './key';
13
15
  import { canMentionBeCreatedInRange } from './utils';
14
16
  export const ACTIONS = {
@@ -16,6 +18,11 @@ export const ACTIONS = {
16
18
  DISCARD_PENDING_TYPED_AGENT_MENTION: 'DISCARD_PENDING_TYPED_AGENT_MENTION',
17
19
  SET_PENDING_TYPED_AGENT_MENTION: 'SET_PENDING_TYPED_AGENT_MENTION',
18
20
  SET_PROVIDER: 'SET_PROVIDER',
21
+ /**
22
+ * Dispatched by the `setAgentMentionRunStates` action to push the product's run-state
23
+ * map into plugin state, which drives the run-state node decorations.
24
+ */
25
+ SET_AGENT_RUN_STATES: 'SET_AGENT_RUN_STATES',
19
26
  /**
20
27
  * Dispatched from view().update() when async resolveMentionName() resolves
21
28
  * for a pasted agent mention.
@@ -51,7 +58,7 @@ const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
51
58
  const AGENT_MENTION_INACTIVITY_MS = 3000;
52
59
  const MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
53
60
  const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
54
- const PACKAGE_VERSION = "18.0.5";
61
+ const PACKAGE_VERSION = "18.1.0";
55
62
  const setProvider = provider => (state, dispatch) => {
56
63
  if (dispatch) {
57
64
  dispatch(state.tr.setMeta(mentionPluginKey, {
@@ -355,6 +362,7 @@ export function createMentionPlugin({
355
362
  };
356
363
  },
357
364
  apply(tr, pluginState, oldState, newState) {
365
+ var _params$runStateByLoc;
358
366
  const {
359
367
  action,
360
368
  params
@@ -381,6 +389,13 @@ export function createMentionPlugin({
381
389
  hasPublicPluginStateChanged = true;
382
390
  break;
383
391
  }
392
+ const nextDecorations = nextRunStateDecorations(newPluginState.runStateDecorations, tr, newState, action === ACTIONS.SET_AGENT_RUN_STATES ? (_params$runStateByLoc = params === null || params === void 0 ? void 0 : params.runStateByLocalId) !== null && _params$runStateByLoc !== void 0 ? _params$runStateByLoc : {} : undefined);
393
+ if (nextDecorations !== newPluginState.runStateDecorations) {
394
+ newPluginState = {
395
+ ...newPluginState,
396
+ runStateDecorations: nextDecorations
397
+ };
398
+ }
384
399
  if (!isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') && editorExperiment('platform_editor_agent_mentions', true)) {
385
400
  switch (action) {
386
401
  case ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION:
@@ -791,6 +806,19 @@ export function createMentionPlugin({
791
806
  portalProviderAPI: pmPluginFactoryParams.portalProviderAPI
792
807
  });
793
808
  }
809
+ },
810
+ // Duplicated in platform/packages/editor/editor-plugin-mentions/src/pm-plugins/agent.ts
811
+ // Can remove once platform_editor_agent_mentions_separate_pm_plugin has been cleaned up
812
+ decorations(state) {
813
+ var _mentionPluginKey$get;
814
+ const runStateDecorations = (_mentionPluginKey$get = mentionPluginKey.getState(state)) === null || _mentionPluginKey$get === void 0 ? void 0 : _mentionPluginKey$get.runStateDecorations;
815
+ if (!runStateDecorations || runStateDecorations === DecorationSet.empty) {
816
+ return undefined;
817
+ }
818
+ if (isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') || !editorExperiment('platform_editor_agent_mentions', true) || !isExperimentEnabled('platform_editor_agent_mention_state_anim')) {
819
+ return undefined;
820
+ }
821
+ return runStateDecorations;
794
822
  }
795
823
  },
796
824
  view(editorView) {
@@ -854,7 +882,7 @@ export function createMentionPlugin({
854
882
  });
855
883
  pendingTypedAgentMentionTimerKey = timerKey;
856
884
  pendingTypedAgentMentionTimer = setTimeout(() => {
857
- var _mentionPluginKey$get;
885
+ var _mentionPluginKey$get2;
858
886
  {
859
887
  var _options$getIsRovoPan3;
860
888
  // Suppress the agent-mention nudge when the Rovo panel is already open. Task
@@ -875,7 +903,7 @@ export function createMentionPlugin({
875
903
  return;
876
904
  }
877
905
  }
878
- const latestPendingTypedAgentMention = (_mentionPluginKey$get = mentionPluginKey.getState(editorView.state)) === null || _mentionPluginKey$get === void 0 ? void 0 : _mentionPluginKey$get.pendingTypedAgentMention;
906
+ const latestPendingTypedAgentMention = (_mentionPluginKey$get2 = mentionPluginKey.getState(editorView.state)) === null || _mentionPluginKey$get2 === void 0 ? void 0 : _mentionPluginKey$get2.pendingTypedAgentMention;
879
907
  if (!latestPendingTypedAgentMention || latestPendingTypedAgentMention.localId !== pendingTypedAgentMention.localId || latestPendingTypedAgentMention.resetCount !== pendingTypedAgentMention.resetCount) {
880
908
  return;
881
909
  }
@@ -5,4 +5,9 @@ export const MENTION_PROVIDER_UNDEFINED = 'UNDEFINED';
5
5
  * @private
6
6
  * @deprecated Use {@link MentionsPluginOptions} instead.
7
7
  * @see https://product-fabric.atlassian.net/browse/ED-27496
8
+ */
9
+
10
+ /**
11
+ * Agent run-state for an agent mention, mirrored from the agent-run-state bridge's
12
+ * `AgentRunState` (@atlassian/conversation-assistant-store/controllers/agent-mention-run-state).
8
13
  */
@@ -138,10 +138,15 @@ export function ProfileCardComponent({
138
138
  provider: provider,
139
139
  hideActions: hideActions,
140
140
  text: expVal('platform_editor_reduced_agent_profile_cards', 'isEnabled', false) ? text : undefined,
141
- onChatClick: onAgentMentionChatClick && fg('platform_editor_agent_mentions_drop_one_fixes') ? (event, agentStudioId) =>
142
- // agentMentionContext is already captured in the onAgentMentionChatClick
143
- // closure built by profileCardRenderer at chip-click time via doc.descendants()
144
- onAgentMentionChatClick(agentStudioId !== null && agentStudioId !== void 0 ? agentStudioId : id) : undefined
141
+ onChatClick: onAgentMentionChatClick && fg('platform_editor_agent_mentions_drop_one_fixes') ? (event, agentStudioId) => {
142
+ // agentMentionContext is already captured in the onAgentMentionChatClick
143
+ // closure built by profileCardRenderer at chip-click time via doc.descendants()
144
+ onAgentMentionChatClick(agentStudioId !== null && agentStudioId !== void 0 ? agentStudioId : id);
145
+ // Dismiss the profile card once the Rovo chat panel opens (EDITOR-8257).
146
+ if (fg('platform_editor_agent_card_close_on_chat')) {
147
+ closeComponent();
148
+ }
149
+ } : undefined
145
150
  }) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
146
151
  accessLevel: accessLevel,
147
152
  id: id,
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
- var _excluded2 = ["pendingPastedAgentMention"];
4
+ var _excluded2 = ["pendingPastedAgentMention", "runStateDecorations"];
5
5
  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; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).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; }
7
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
@@ -207,6 +207,21 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
207
207
  options.handleMentionsChanged(mentionChanges);
208
208
  }
209
209
  },
210
+ setAgentMentionRunStates: function setAgentMentionRunStates(runStateByLocalId) {
211
+ var _api$core$actions$exe;
212
+ if (!(editorExperiment('platform_editor_agent_mentions', true) && isExperimentEnabled('platform_editor_agent_mention_state_anim'))) {
213
+ return false;
214
+ }
215
+ return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref7) {
216
+ var tr = _ref7.tr;
217
+ return tr.setMeta(mentionPluginKey, {
218
+ action: ACTIONS.SET_AGENT_RUN_STATES,
219
+ params: {
220
+ runStateByLocalId: runStateByLocalId
221
+ }
222
+ });
223
+ })) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
224
+ },
210
225
  updateSectionTitle: function updateSectionTitle(props) {
211
226
  var _api$typeAhead$action, _api$typeAhead2, _api$typeAhead2$updat;
212
227
  if (!(options !== null && options !== void 0 && options.enableAgentSectioning)) {
@@ -216,7 +231,7 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
216
231
  },
217
232
  setProvider: function () {
218
233
  var _setProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(providerPromise) {
219
- var _api$core$actions$exe;
234
+ var _api$core$actions$exe2;
220
235
  var provider;
221
236
  return _regeneratorRuntime.wrap(function (_context) {
222
237
  while (1) switch (_context.prev = _context.next) {
@@ -238,15 +253,15 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
238
253
  return _context.abrupt("return", false);
239
254
  case 3:
240
255
  previousMediaProvider = provider;
241
- return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref7) {
242
- var tr = _ref7.tr;
256
+ return _context.abrupt("return", (_api$core$actions$exe2 = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref8) {
257
+ var tr = _ref8.tr;
243
258
  return tr.setMeta(mentionPluginKey, {
244
259
  action: ACTIONS.SET_PROVIDER,
245
260
  params: {
246
261
  provider: provider
247
262
  }
248
263
  });
249
- })) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false);
264
+ })) !== null && _api$core$actions$exe2 !== void 0 ? _api$core$actions$exe2 : false);
250
265
  case 4:
251
266
  case "end":
252
267
  return _context.stop();
@@ -268,9 +283,10 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
268
283
  // Exclude pendingPastedAgentMention — it is an @internal transient field and
269
284
  // should not be part of the public shared state API. Exposing it would cause
270
285
  // unnecessary re-renders in subscribers and leak implementation details.
271
- var _ref8 = mentionPluginState !== null && mentionPluginState !== void 0 ? mentionPluginState : {},
272
- _excluded = _ref8.pendingPastedAgentMention,
273
- publicPluginState = _objectWithoutProperties(_ref8, _excluded2);
286
+ var _ref9 = mentionPluginState !== null && mentionPluginState !== void 0 ? mentionPluginState : {},
287
+ _excluded = _ref9.pendingPastedAgentMention,
288
+ _excludedRunState = _ref9.runStateDecorations,
289
+ publicPluginState = _objectWithoutProperties(_ref9, _excluded2);
274
290
  return _objectSpread(_objectSpread(_objectSpread({}, publicPluginState), agentMentionPluginState ? {
275
291
  lastAgentMentionInsertionCount: agentMentionPluginState.lastAgentMentionInsertionCount,
276
292
  lastInsertedAgentMentionContext: agentMentionPluginState.lastInsertedAgentMentionContext,
@@ -284,8 +300,8 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
284
300
  });
285
301
  },
286
302
  pluginsOptions: {
287
- quickInsert: isRegisteredSlashCommandEnabled ? undefined : function (_ref9) {
288
- var formatMessage = _ref9.formatMessage;
303
+ quickInsert: isRegisteredSlashCommandEnabled ? undefined : function (_ref0) {
304
+ var formatMessage = _ref0.formatMessage;
289
305
  return [{
290
306
  id: 'mention',
291
307
  title: formatMessage(messages.mention),
@@ -5,7 +5,7 @@ import React from 'react';
5
5
  import { bind } from 'bind-event-listener';
6
6
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
7
7
  import uuid from 'uuid/v4';
8
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
8
+ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
9
9
  import { findChildrenByAttr } from '@atlaskit/editor-prosemirror/utils';
10
10
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
11
11
  import { fg } from '@atlaskit/platform-feature-flags/fg';
@@ -97,7 +97,14 @@ export var profileCardRenderer = function profileCardRenderer(_ref) {
97
97
  profilecardProvider: options === null || options === void 0 ? void 0 : options.profilecardProvider,
98
98
  onAgentMentionChatClick: options !== null && options !== void 0 && options.onAgentMentionChatClick && fg('platform_editor_agent_mentions_drop_one_fixes') ? function (agentId) {
99
99
  var _options$onAgentMenti;
100
- return (_options$onAgentMenti = options.onAgentMentionChatClick) === null || _options$onAgentMenti === void 0 ? void 0 : _options$onAgentMenti.call(options, agentId, agentMentionContext);
100
+ (_options$onAgentMenti = options.onAgentMentionChatClick) === null || _options$onAgentMenti === void 0 || _options$onAgentMenti.call(options, agentId, agentMentionContext);
101
+ // The mention stays node-selected after the chat opens; collapse the
102
+ // selection to a cursor just after it so it is no longer left selected.
103
+ // Selection-only change, so it does not move focus (EDITOR-8257).
104
+ if (editorView && fg('platform_editor_agent_card_close_on_chat')) {
105
+ var state = editorView.state;
106
+ editorView.dispatch(state.tr.setSelection(TextSelection.create(state.doc, state.selection.to)));
107
+ }
101
108
  } : undefined,
102
109
  dom: referenceElement,
103
110
  closeComponent: removeProfileCard
@@ -0,0 +1,67 @@
1
+ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
2
+ var AGENT_MENTION_USER_TYPES = new Set(['APP', 'AGENT']);
3
+ var isAgentMentionUserType = function isAgentMentionUserType(userType) {
4
+ return typeof userType === 'string' && AGENT_MENTION_USER_TYPES.has(userType);
5
+ };
6
+ var AGENT_RUN_STATE_ANALYSING_CLASS = 'agent-mention-analysing-state';
7
+
8
+ /**
9
+ * Map the bridge's run-state to a mention node visual class.
10
+ * Currently only the "analysing" state changes the chip, applying a shimmer to the pill.
11
+ */
12
+ var getRunStateClass = function getRunStateClass(runState) {
13
+ switch (runState) {
14
+ case 'thinking':
15
+ case 'working':
16
+ return AGENT_RUN_STATE_ANALYSING_CLASS;
17
+ default:
18
+ return undefined;
19
+ }
20
+ };
21
+
22
+ /**
23
+ * Build the node-decoration set that styles agent mentions by their run-state.
24
+ */
25
+ export var buildAgentRunStateDecorations = function buildAgentRunStateDecorations(state, runStateByLocalId) {
26
+ if (!runStateByLocalId || Object.keys(runStateByLocalId).length === 0) {
27
+ return DecorationSet.empty;
28
+ }
29
+ var mentionNodeType = state.schema.nodes.mention;
30
+ if (!mentionNodeType) {
31
+ return DecorationSet.empty;
32
+ }
33
+ var decorations = [];
34
+ state.doc.descendants(function (node, pos) {
35
+ if (node.type !== mentionNodeType || !isAgentMentionUserType(node.attrs.userType)) {
36
+ return true;
37
+ }
38
+ var localId = node.attrs.localId;
39
+ var runState = typeof localId === 'string' ? runStateByLocalId[localId] : undefined;
40
+ if (!runState) {
41
+ return true;
42
+ }
43
+ var stateClass = getRunStateClass(runState);
44
+ if (!stateClass) {
45
+ return true;
46
+ }
47
+ decorations.push(Decoration.node(pos, pos + node.nodeSize, {
48
+ class: stateClass
49
+ }));
50
+ return true;
51
+ });
52
+ return decorations.length ? DecorationSet.create(state.doc, decorations) : DecorationSet.empty;
53
+ };
54
+
55
+ /**
56
+ * Computes the next cached run-state `DecorationSet` for a plugin's `apply`, so that
57
+ * `props.decorations` can return a stored set instead of walking the doc on every transaction:
58
+ */
59
+ export var nextRunStateDecorations = function nextRunStateDecorations(previous, tr, newState, runStateByLocalId) {
60
+ if (runStateByLocalId !== undefined) {
61
+ return buildAgentRunStateDecorations(newState, runStateByLocalId);
62
+ }
63
+ if (tr.docChanged && previous) {
64
+ return previous.map(tr.mapping, tr.doc);
65
+ }
66
+ return previous;
67
+ };
@@ -7,10 +7,13 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
7
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).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; }
8
8
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
9
9
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
10
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
10
11
  import { isResolvingMentionProvider, MentionNameStatus } from '@atlaskit/mention/resource';
12
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
11
13
  import { fg } from '@atlaskit/platform-feature-flags/fg';
12
14
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
15
  import { getAgentMentionParentContext } from './agent-mention-context';
16
+ import { nextRunStateDecorations } from './agent-run-state';
14
17
  import { mentionPluginKey } from './key';
15
18
  import { ACTIONS } from './main';
16
19
 
@@ -732,6 +735,7 @@ export var createAgentMentionPlugin = function createAgentMentionPlugin(_ref7) {
732
735
  return {};
733
736
  },
734
737
  apply: function apply(tr, pluginState, oldState, newState) {
738
+ var _meta$params$runState, _meta$params;
735
739
  var result = applyAgentMentionState({
736
740
  tr: tr,
737
741
  pluginState: pluginState,
@@ -739,11 +743,32 @@ export var createAgentMentionPlugin = function createAgentMentionPlugin(_ref7) {
739
743
  newState: newState,
740
744
  getIsRovoPanelOpen: options === null || options === void 0 ? void 0 : options.getIsRovoPanelOpen
741
745
  });
746
+ var nextPluginState = result.pluginState;
747
+ var meta = tr.getMeta(mentionPluginKey);
748
+ var nextDecorations = nextRunStateDecorations(pluginState.runStateDecorations, tr, newState, (meta === null || meta === void 0 ? void 0 : meta.action) === ACTIONS.SET_AGENT_RUN_STATES ? (_meta$params$runState = (_meta$params = meta.params) === null || _meta$params === void 0 ? void 0 : _meta$params.runStateByLocalId) !== null && _meta$params$runState !== void 0 ? _meta$params$runState : {} : undefined);
749
+ if (nextPluginState.runStateDecorations !== nextDecorations) {
750
+ nextPluginState = _objectSpread(_objectSpread({}, nextPluginState), {}, {
751
+ runStateDecorations: nextDecorations
752
+ });
753
+ }
742
754
  var mentionPluginState = mentionPluginKey.getState(newState);
743
755
  if (result.hasPublicPluginStateChanged) {
744
756
  pmPluginFactoryParams.dispatch(mentionPluginKey, _objectSpread(_objectSpread({}, mentionPluginState), result.pluginState));
745
757
  }
746
- return result.pluginState;
758
+ return nextPluginState;
759
+ }
760
+ },
761
+ props: {
762
+ decorations: function decorations(state) {
763
+ var _agentMentionPluginKe;
764
+ var runStateDecorations = (_agentMentionPluginKe = agentMentionPluginKey.getState(state)) === null || _agentMentionPluginKe === void 0 ? void 0 : _agentMentionPluginKe.runStateDecorations;
765
+ if (!runStateDecorations || runStateDecorations === DecorationSet.empty) {
766
+ return undefined;
767
+ }
768
+ if (!isExperimentEnabled('platform_editor_agent_mention_state_anim')) {
769
+ return undefined;
770
+ }
771
+ return runStateDecorations;
747
772
  }
748
773
  },
749
774
  view: function view(editorView) {
@@ -7,6 +7,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
7
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).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; }
8
8
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
9
9
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
10
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
10
11
  import { insm } from '@atlaskit/insm';
11
12
  import { isResolvingMentionProvider, MentionNameStatus, SLI_EVENT_TYPE, SMART_EVENT_TYPE } from '@atlaskit/mention/resource';
12
13
  import { ComponentNames } from '@atlaskit/mention/types';
@@ -16,6 +17,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
17
  import { MentionNodeView } from '../nodeviews/mentionNodeView';
17
18
  import { MENTION_PROVIDER_REJECTED, MENTION_PROVIDER_UNDEFINED } from '../types';
18
19
  import { getAgentMentionParentContext } from './agent-mention-context';
20
+ import { nextRunStateDecorations } from './agent-run-state';
19
21
  import { mentionPluginKey } from './key';
20
22
  import { canMentionBeCreatedInRange } from './utils';
21
23
  export var ACTIONS = {
@@ -23,6 +25,11 @@ export var ACTIONS = {
23
25
  DISCARD_PENDING_TYPED_AGENT_MENTION: 'DISCARD_PENDING_TYPED_AGENT_MENTION',
24
26
  SET_PENDING_TYPED_AGENT_MENTION: 'SET_PENDING_TYPED_AGENT_MENTION',
25
27
  SET_PROVIDER: 'SET_PROVIDER',
28
+ /**
29
+ * Dispatched by the `setAgentMentionRunStates` action to push the product's run-state
30
+ * map into plugin state, which drives the run-state node decorations.
31
+ */
32
+ SET_AGENT_RUN_STATES: 'SET_AGENT_RUN_STATES',
26
33
  /**
27
34
  * Dispatched from view().update() when async resolveMentionName() resolves
28
35
  * for a pasted agent mention.
@@ -58,7 +65,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
58
65
  var AGENT_MENTION_INACTIVITY_MS = 3000;
59
66
  var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
60
67
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
61
- var PACKAGE_VERSION = "18.0.5";
68
+ var PACKAGE_VERSION = "18.1.0";
62
69
  var setProvider = function setProvider(provider) {
63
70
  return function (state, dispatch) {
64
71
  if (dispatch) {
@@ -368,6 +375,7 @@ export function createMentionPlugin(_ref2) {
368
375
  };
369
376
  },
370
377
  apply: function apply(tr, pluginState, oldState, newState) {
378
+ var _params$runStateByLoc;
371
379
  var _ref3 = tr.getMeta(mentionPluginKey) || {
372
380
  action: null,
373
381
  params: null
@@ -391,6 +399,12 @@ export function createMentionPlugin(_ref2) {
391
399
  hasPublicPluginStateChanged = true;
392
400
  break;
393
401
  }
402
+ var nextDecorations = nextRunStateDecorations(newPluginState.runStateDecorations, tr, newState, action === ACTIONS.SET_AGENT_RUN_STATES ? (_params$runStateByLoc = params === null || params === void 0 ? void 0 : params.runStateByLocalId) !== null && _params$runStateByLoc !== void 0 ? _params$runStateByLoc : {} : undefined);
403
+ if (nextDecorations !== newPluginState.runStateDecorations) {
404
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
405
+ runStateDecorations: nextDecorations
406
+ });
407
+ }
394
408
  if (!isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') && editorExperiment('platform_editor_agent_mentions', true)) {
395
409
  switch (action) {
396
410
  case ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION:
@@ -818,6 +832,19 @@ export function createMentionPlugin(_ref2) {
818
832
  portalProviderAPI: pmPluginFactoryParams.portalProviderAPI
819
833
  });
820
834
  }
835
+ },
836
+ // Duplicated in platform/packages/editor/editor-plugin-mentions/src/pm-plugins/agent.ts
837
+ // Can remove once platform_editor_agent_mentions_separate_pm_plugin has been cleaned up
838
+ decorations: function decorations(state) {
839
+ var _mentionPluginKey$get;
840
+ var runStateDecorations = (_mentionPluginKey$get = mentionPluginKey.getState(state)) === null || _mentionPluginKey$get === void 0 ? void 0 : _mentionPluginKey$get.runStateDecorations;
841
+ if (!runStateDecorations || runStateDecorations === DecorationSet.empty) {
842
+ return undefined;
843
+ }
844
+ if (isExperimentEnabled('platform_editor_agent_mentions_separate_pm_plugin') || !editorExperiment('platform_editor_agent_mentions', true) || !isExperimentEnabled('platform_editor_agent_mention_state_anim')) {
845
+ return undefined;
846
+ }
847
+ return runStateDecorations;
821
848
  }
822
849
  },
823
850
  view: function view(editorView) {
@@ -885,7 +912,7 @@ export function createMentionPlugin(_ref2) {
885
912
  });
886
913
  pendingTypedAgentMentionTimerKey = timerKey;
887
914
  pendingTypedAgentMentionTimer = setTimeout(function () {
888
- var _mentionPluginKey$get;
915
+ var _mentionPluginKey$get2;
889
916
  {
890
917
  var _options$getIsRovoPan3;
891
918
  // Suppress the agent-mention nudge when the Rovo panel is already open. Task
@@ -906,7 +933,7 @@ export function createMentionPlugin(_ref2) {
906
933
  return;
907
934
  }
908
935
  }
909
- var latestPendingTypedAgentMention = (_mentionPluginKey$get = mentionPluginKey.getState(editorView.state)) === null || _mentionPluginKey$get === void 0 ? void 0 : _mentionPluginKey$get.pendingTypedAgentMention;
936
+ var latestPendingTypedAgentMention = (_mentionPluginKey$get2 = mentionPluginKey.getState(editorView.state)) === null || _mentionPluginKey$get2 === void 0 ? void 0 : _mentionPluginKey$get2.pendingTypedAgentMention;
910
937
  if (!latestPendingTypedAgentMention || latestPendingTypedAgentMention.localId !== pendingTypedAgentMention.localId || latestPendingTypedAgentMention.resetCount !== pendingTypedAgentMention.resetCount) {
911
938
  return;
912
939
  }
@@ -5,4 +5,9 @@ export var MENTION_PROVIDER_UNDEFINED = 'UNDEFINED';
5
5
  * @private
6
6
  * @deprecated Use {@link MentionsPluginOptions} instead.
7
7
  * @see https://product-fabric.atlassian.net/browse/ED-27496
8
+ */
9
+
10
+ /**
11
+ * Agent run-state for an agent mention, mirrored from the agent-run-state bridge's
12
+ * `AgentRunState` (@atlassian/conversation-assistant-store/controllers/agent-mention-run-state).
8
13
  */
@@ -198,11 +198,13 @@ export function ProfileCardComponent(_ref5) {
198
198
  hideActions: hideActions,
199
199
  text: expVal('platform_editor_reduced_agent_profile_cards', 'isEnabled', false) ? text : undefined,
200
200
  onChatClick: onAgentMentionChatClick && fg('platform_editor_agent_mentions_drop_one_fixes') ? function (event, agentStudioId) {
201
- return (
202
- // agentMentionContext is already captured in the onAgentMentionChatClick
203
- // closure built by profileCardRenderer at chip-click time via doc.descendants()
204
- onAgentMentionChatClick(agentStudioId !== null && agentStudioId !== void 0 ? agentStudioId : id)
205
- );
201
+ // agentMentionContext is already captured in the onAgentMentionChatClick
202
+ // closure built by profileCardRenderer at chip-click time via doc.descendants()
203
+ onAgentMentionChatClick(agentStudioId !== null && agentStudioId !== void 0 ? agentStudioId : id);
204
+ // Dismiss the profile card once the Rovo chat panel opens (EDITOR-8257).
205
+ if (fg('platform_editor_agent_card_close_on_chat')) {
206
+ closeComponent();
207
+ }
206
208
  } : undefined
207
209
  }) : /*#__PURE__*/React.createElement(UserProfileCardContent, {
208
210
  accessLevel: accessLevel,
@@ -8,14 +8,16 @@ import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead/type-ah
8
8
  import type { TypeAheadInputMethod } from '@atlaskit/editor-plugin-type-ahead/types';
9
9
  import type { MentionProvider } from '@atlaskit/mention/resource';
10
10
  import type { InsertMentionParameters } from './editor-commands';
11
- import type { MentionChange, MentionPluginOptions, MentionSharedState } from './types';
11
+ import type { AgentRunStateByLocalId, MentionChange, MentionPluginOptions, MentionSharedState } from './types';
12
12
  export type MentionActionOpenTypeAhead = (inputMethod: TypeAheadInputMethod) => boolean;
13
13
  export type MentionActionAnnounceMentionsInsertion = (mentionIds: MentionChange[]) => void;
14
14
  export type MentionActionSetProvider = (provider: Promise<MentionProvider>) => Promise<boolean>;
15
15
  export type MentionActionUpdateSectionTitle = (props: TypeAheadSectionTitleUpdate) => boolean;
16
+ export type MentionActionSetAgentMentionRunStates = (runStateByLocalId: AgentRunStateByLocalId) => boolean;
16
17
  export type MentionActions = {
17
18
  announceMentionsInsertion: MentionActionAnnounceMentionsInsertion;
18
19
  openTypeAhead: MentionActionOpenTypeAhead;
20
+ setAgentMentionRunStates: MentionActionSetAgentMentionRunStates;
19
21
  setProvider: MentionActionSetProvider;
20
22
  updateSectionTitle: MentionActionUpdateSectionTitle;
21
23
  };
@@ -0,0 +1,12 @@
1
+ import type { EditorState, ReadonlyTransaction } from '@atlaskit/editor-prosemirror/state';
2
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
+ import type { AgentRunStateByLocalId } from '../types';
4
+ /**
5
+ * Build the node-decoration set that styles agent mentions by their run-state.
6
+ */
7
+ export declare const buildAgentRunStateDecorations: (state: EditorState, runStateByLocalId: AgentRunStateByLocalId | undefined) => DecorationSet;
8
+ /**
9
+ * Computes the next cached run-state `DecorationSet` for a plugin's `apply`, so that
10
+ * `props.decorations` can return a stored set instead of walking the doc on every transaction:
11
+ */
12
+ export declare const nextRunStateDecorations: (previous: DecorationSet | undefined, tr: ReadonlyTransaction, newState: EditorState, runStateByLocalId: AgentRunStateByLocalId | undefined) => DecorationSet | undefined;
@@ -2,7 +2,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import type { PMPluginFactoryParams } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState, ReadonlyTransaction } from '@atlaskit/editor-prosemirror/state';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
+ import { type EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { ResolvingMentionProvider } from '@atlaskit/mention/resource';
7
7
  import type { MentionPluginOptions, MentionPluginState } from '../types';
8
8
  /**
@@ -1,6 +1,6 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
3
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import { type EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { ResolvingMentionProvider } from '@atlaskit/mention/resource';
5
5
  import type { MentionsPlugin } from '../mentionsPluginType';
6
6
  import type { FireElementsChannelEvent, MentionPluginOptions, MentionPluginState } from '../types';
@@ -9,6 +9,11 @@ export declare const ACTIONS: {
9
9
  DISCARD_PENDING_TYPED_AGENT_MENTION: string;
10
10
  SET_PENDING_TYPED_AGENT_MENTION: string;
11
11
  SET_PROVIDER: string;
12
+ /**
13
+ * Dispatched by the `setAgentMentionRunStates` action to push the product's run-state
14
+ * map into plugin state, which drives the run-state node decorations.
15
+ */
16
+ SET_AGENT_RUN_STATES: string;
12
17
  /**
13
18
  * Dispatched from view().update() when async resolveMentionName() resolves
14
19
  * for a pasted agent mention.
@@ -3,6 +3,7 @@ import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
3
3
  import type { MentionNodeDataProvider } from '@atlaskit/editor-common/mention';
4
4
  import type { Providers, ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
5
5
  import type { TypeAheadHandler } from '@atlaskit/editor-common/types';
6
+ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
7
  import type { MentionDescription, MentionProvider } from '@atlaskit/mention';
7
8
  export declare const MENTION_PROVIDER_REJECTED = "REJECTED";
8
9
  export declare const MENTION_PROVIDER_UNDEFINED = "UNDEFINED";
@@ -172,8 +173,20 @@ export type MentionPluginState = {
172
173
  */
173
174
  resetCount: number;
174
175
  } | null;
176
+ /**
177
+ * @internal Cached agent run-state node decorations. Rebuilt only when the
178
+ * `setAgentMentionRunStates` action changes the run-state map, and mapped through
179
+ * doc changes otherwise.
180
+ */
181
+ runStateDecorations?: DecorationSet;
175
182
  };
176
183
  export type FireElementsChannelEvent = (payload: AnalyticsEventPayload, channel?: string) => void;
177
- export type MentionSharedState = Omit<MentionPluginState, 'pendingPastedAgentMention'> & {
184
+ export type MentionSharedState = Omit<MentionPluginState, 'pendingPastedAgentMention' | 'runStateDecorations'> & {
178
185
  typeAheadHandler: TypeAheadHandler;
179
186
  };
187
+ /**
188
+ * Agent run-state for an agent mention, mirrored from the agent-run-state bridge's
189
+ * `AgentRunState` (@atlassian/conversation-assistant-store/controllers/agent-mention-run-state).
190
+ */
191
+ export type AgentMentionRunState = 'thinking' | 'working' | 'editing' | 'needs-input' | 'done' | 'failed' | 'blocked';
192
+ export type AgentRunStateByLocalId = Record<string, AgentMentionRunState>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "18.0.6",
3
+ "version": "18.1.1",
4
4
  "description": "Mentions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -47,7 +47,7 @@
47
47
  "@atlaskit/section-message": "^10.1.0",
48
48
  "@atlaskit/teams-app-config": "^3.0.0",
49
49
  "@atlaskit/theme": "^28.1.0",
50
- "@atlaskit/tmp-editor-statsig": "^163.0.0",
50
+ "@atlaskit/tmp-editor-statsig": "^164.0.0",
51
51
  "@atlaskit/tokens": "^16.8.0",
52
52
  "@atlaskit/tooltip": "^24.2.0",
53
53
  "@atlaskit/user-picker": "^13.10.0",
@@ -129,6 +129,9 @@
129
129
  "platform_editor_agent_mentions_drop_one_fixes": {
130
130
  "type": "boolean"
131
131
  },
132
+ "platform_editor_agent_card_close_on_chat": {
133
+ "type": "boolean"
134
+ },
132
135
  "platform_editor_mention_typeahead_profilecard": {
133
136
  "type": "boolean"
134
137
  },