@atlaskit/editor-plugin-collab-edit 20.0.1 → 20.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,26 @@
1
1
  # @atlaskit/editor-plugin-collab-edit
2
2
 
3
+ ## 20.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 20.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`fcc5d229eacdb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fcc5d229eacdb) -
14
+ Resolve consistent agent labels and colours for collaborators, filter local acknowledgements under
15
+ M1, and use shared display defaults instead of legacy streaming settings.
16
+ - [`fcc5d229eacdb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fcc5d229eacdb) -
17
+ Keep agent highlights associated with their actor and invocation under
18
+ platform_editor_ai_streaming_ux_experience_m1.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+
3
24
  ## 20.0.1
4
25
 
5
26
  ### Patch Changes
@@ -19,10 +19,11 @@ var _fg = require("@atlaskit/platform-feature-flags/fg");
19
19
  var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
20
20
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
21
21
  var _analytics = require("./analytics");
22
+ var _agentEditRequester = require("./main/agent-edit-requester");
22
23
  var _agentReviewSegments = require("./main/agent-review-segments");
23
24
  var _agentShimmerDecorations = require("./main/agent-shimmer-decorations");
24
- var _agentEditRequester = require("./main/agent-edit-requester");
25
25
  var _agentShimmerRanges = require("./main/agent-shimmer-ranges");
26
+ var _remoteAgentChromeIdentity = require("./main/remote-agent-chrome-identity");
26
27
  var _utils = require("./utils");
27
28
  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); }
28
29
  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; }
@@ -102,7 +103,7 @@ var applyRemoteSteps = exports.applyRemoteSteps = function applyRemoteSteps(json
102
103
  var agentShimmers = [];
103
104
  var visualJson = json;
104
105
  var visualSteps = steps;
105
- if (options !== null && options !== void 0 && options.useNativePlugin && userIds && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_be_streaming')) {
106
+ if (options !== null && options !== void 0 && options.useNativePlugin && userIds && ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ai_streaming_ux_experience_m1') || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_be_streaming'))) {
106
107
  var _sendableSteps;
107
108
  // Read the client ID before applying the acknowledgement, while the local steps
108
109
  // are still unconfirmed. receiveTransaction removes this same local prefix.
@@ -120,17 +121,19 @@ var applyRemoteSteps = exports.applyRemoteSteps = function applyRemoteSteps(json
120
121
  visualJson = json.slice(acknowledgedSteps);
121
122
  visualSteps = steps.slice(acknowledgedSteps);
122
123
  }
124
+ var isM1StreamingEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ai_streaming_ux_experience_m1');
123
125
  var isUnifiedPostApplyChromeEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ai_unified_post_apply_chrome');
124
- if (isUnifiedPostApplyChromeEnabled && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_be_streaming')) {
126
+ if (isUnifiedPostApplyChromeEnabled && (isM1StreamingEnabled || (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_be_streaming'))) {
125
127
  var ranges = (0, _agentShimmerRanges.getAgentEditChromeRanges)(visualJson, visualSteps, tr, view, function (reason, agentType, error) {
126
128
  return editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent((0, _analytics.getAgentEditShimmerNotShownPayload)(reason, agentType, error))(tr);
127
129
  });
128
130
  var requester = (0, _agentEditRequester.getAgentEditRequester)(visualJson, view);
129
131
  if (ranges.length && requester) {
130
132
  // Collab supplies a machine agent type, not a display name; preserve the legacy
131
- // uppercase telepointer label.
133
+ // uppercase telepointer label as the fallback for observers that cannot resolve a
134
+ // redesigned presentation from the forwarded identity.
132
135
  var telepointerLabel = requester.agentType.trim().toUpperCase();
133
- tr.setMeta(_collabAgentEditChrome.AGENT_EDIT_CHROME_DATA, _objectSpread(_objectSpread(_objectSpread({}, (0, _collabAgentEditChrome.getAgentEditChromeDynamicConfig)()), telepointerLabel ? {
136
+ tr.setMeta(_collabAgentEditChrome.AGENT_EDIT_CHROME_DATA, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, !isM1StreamingEnabled ? (0, _collabAgentEditChrome.getAgentEditChromeDynamicConfig)() : {}), (0, _remoteAgentChromeIdentity.getRemoteAgentChromeIdentity)(requester)), telepointerLabel ? {
134
137
  telepointerLabel: telepointerLabel
135
138
  } : {}), {}, {
136
139
  ranges: ranges
@@ -4,26 +4,40 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.getAgentEditRequester = void 0;
7
+ exports.isStepFromAgentEdit = exports.getAgentEditRequester = void 0;
8
8
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  var _pluginKey = require("./plugin-key");
10
10
  var isAgentRemoteStep = function isAgentRemoteStep(step) {
11
11
  return (0, _typeof2.default)(step) === 'object' && step !== null && typeof step.agentType === 'string';
12
12
  };
13
+ var asString = function asString(value) {
14
+ return typeof value === 'string' ? value : undefined;
15
+ };
16
+ var isStepFromAgentEdit = exports.isStepFromAgentEdit = function isStepFromAgentEdit(step, requester) {
17
+ if (!isAgentRemoteStep(step)) {
18
+ return false;
19
+ }
20
+ return step.agentType === requester.agentType && asString(step.agentId) === requester.agentId && asString(step.agentSourceId) === requester.agentSourceId && asString(step.agentNamedId) === requester.agentNamedId && asString(step.userId) === requester.actorUserId && asString(step.invocationId) === requester.invocationId;
21
+ };
13
22
  var getAgentEditRequester = exports.getAgentEditRequester = function getAgentEditRequester(json, view) {
14
23
  var _collabPluginState$ac;
15
24
  var agentStep = json.find(isAgentRemoteStep);
16
25
  if (!agentStep) {
17
26
  return null;
18
27
  }
19
- var actorUserId = typeof agentStep.userId === 'string' ? agentStep.userId : undefined;
28
+ var actorUserId = asString(agentStep.userId);
20
29
  var collabPluginState = _pluginKey.pluginKey.getState(view.state);
21
30
  var localSessionId = collabPluginState === null || collabPluginState === void 0 ? void 0 : collabPluginState.sessionId;
22
31
  var localUserId = localSessionId ? collabPluginState === null || collabPluginState === void 0 || (_collabPluginState$ac = collabPluginState.activeParticipants) === null || _collabPluginState$ac === void 0 || (_collabPluginState$ac = _collabPluginState$ac.get(localSessionId)) === null || _collabPluginState$ac === void 0 ? void 0 : _collabPluginState$ac.userId : undefined;
23
32
  return {
24
- agentId: typeof agentStep.agentId === 'string' ? agentStep.agentId : undefined,
33
+ agentId: asString(agentStep.agentId),
34
+ agentName: asString(agentStep.agentName),
35
+ agentNamedId: asString(agentStep.agentNamedId),
36
+ agentSourceId: asString(agentStep.agentSourceId),
25
37
  agentType: agentStep.agentType,
26
38
  actorUserId: actorUserId,
39
+ invocationId: asString(agentStep.invocationId),
40
+ isThirdPartyAgent: typeof agentStep.isThirdPartyAgent === 'boolean' ? agentStep.isThirdPartyAgent : undefined,
27
41
  isLocalUserRequester: actorUserId !== undefined && localUserId !== undefined && actorUserId === localUserId
28
42
  };
29
43
  };
@@ -4,12 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isPositionNeutralStep = exports.getMarkStepRange = exports.getAgentShimmerRanges = exports.getAgentEditChromeRanges = void 0;
7
- var _collabAgentReviewSliceCompare = require("@atlaskit/editor-common/collab-agent-review-slice-compare");
8
7
  var _collabAgentEditChangedRanges = require("@atlaskit/editor-common/collab-agent-edit-changed-ranges");
8
+ var _collabAgentReviewSliceCompare = require("@atlaskit/editor-common/collab-agent-review-slice-compare");
9
9
  var _monitoring = require("@atlaskit/editor-common/monitoring");
10
10
  var _transform = require("@atlaskit/editor-prosemirror/transform");
11
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
11
12
  var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
12
13
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
14
+ var _agentEditRequester = require("./agent-edit-requester");
13
15
  // When an agent step lands we cover the top-level block(s) it wrote with a skeleton-loader shimmer
14
16
  // (plus a Rovo agent telepointer at the end of the range), then remove it on a timer to reveal the
15
17
  // content. Gated behind the `platform_editor_agent_be_streaming` experiment. `shimmerDurationMs` and
@@ -286,9 +288,11 @@ var getAgentEditChromeRanges = exports.getAgentEditChromeRanges = function getAg
286
288
  // rolls back unconfirmed local steps before applying these remote steps, and
287
289
  // replays the local steps afterwards. Select the actual applied remote indexes;
288
290
  // the shared extractor maps them through every later step into tr.doc.
291
+ var requester = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ai_streaming_ux_experience_m1') ? (0, _agentEditRequester.getAgentEditRequester)(json, view) : null;
289
292
  var includedStepIndexes = [];
290
293
  json.forEach(function (rawStep, index) {
291
- if (typeof (rawStep === null || rawStep === void 0 ? void 0 : rawStep.agentType) === 'string' && steps[index]) {
294
+ var belongsToSelectedAgent = !requester || (0, _agentEditRequester.isStepFromAgentEdit)(rawStep, requester);
295
+ if (typeof (rawStep === null || rawStep === void 0 ? void 0 : rawStep.agentType) === 'string' && steps[index] && belongsToSelectedAgent) {
292
296
  includedStepIndexes.push(rebasedSteps + index);
293
297
  }
294
298
  });
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getRemoteAgentChromeIdentity = void 0;
7
+ /**
8
+ * Maps collab step attribution onto the shared agent-edit chrome identity fields.
9
+ *
10
+ * Step attribution carries the agent's provisioned Atlassian identity account id under `agentId`
11
+ * (see `getAgentAttribution`), so it is forwarded as `agentIdentityAccountId` rather than as the
12
+ * agent's own source-system id.
13
+ */
14
+ var getRemoteAgentChromeIdentity = exports.getRemoteAgentChromeIdentity = function getRemoteAgentChromeIdentity(requester) {
15
+ var _requester$agentSourc, _requester$agentId, _requester$agentName, _requester$agentNamed;
16
+ return {
17
+ actorUserId: requester.actorUserId,
18
+ invocationId: requester.invocationId,
19
+ agentId: ((_requester$agentSourc = requester.agentSourceId) === null || _requester$agentSourc === void 0 ? void 0 : _requester$agentSourc.trim()) || undefined,
20
+ agentIdentityAccountId: ((_requester$agentId = requester.agentId) === null || _requester$agentId === void 0 ? void 0 : _requester$agentId.trim()) || undefined,
21
+ agentName: ((_requester$agentName = requester.agentName) === null || _requester$agentName === void 0 ? void 0 : _requester$agentName.trim()) || undefined,
22
+ agentNamedId: ((_requester$agentNamed = requester.agentNamedId) === null || _requester$agentNamed === void 0 ? void 0 : _requester$agentNamed.trim()) || undefined,
23
+ agentType: requester.agentType.trim() || undefined,
24
+ isThirdParty: requester.isThirdPartyAgent
25
+ };
26
+ };
@@ -7,9 +7,9 @@ exports.createPlugin = exports.createFilterTransaction = void 0;
7
7
  exports.generateTransactionKey = generateTransactionKey;
8
8
  exports.trackSpammingStepsPluginKey = exports.sanitizeFilteredStep = void 0;
9
9
  var _analytics = require("@atlaskit/adf-schema/steps/analytics");
10
- var _typeAhead = require("@atlaskit/adf-schema/steps/type-ahead");
11
10
  var _linkMetaStep = require("@atlaskit/adf-schema/steps/link-meta-step");
12
11
  var _setAttrs = require("@atlaskit/adf-schema/steps/set-attrs");
12
+ var _typeAhead = require("@atlaskit/adf-schema/steps/type-ahead");
13
13
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
14
14
  var _state = require("@atlaskit/editor-prosemirror/state");
15
15
  var _transform = require("@atlaskit/editor-prosemirror/transform");
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.track = exports.task = exports.sanitizeStep = exports.groupSteps = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _analytics = require("@atlaskit/adf-schema/steps/analytics");
10
- var _setAttrs = require("@atlaskit/adf-schema/steps/set-attrs");
11
10
  var _batchAttrsStep = require("@atlaskit/adf-schema/steps/batch-attrs-step");
11
+ var _setAttrs = require("@atlaskit/adf-schema/steps/set-attrs");
12
12
  var _transform = require("@atlaskit/editor-prosemirror/transform");
13
13
  var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
14
14
  var _trackStepMetrics = require("./track-step-metrics");
@@ -1,2 +1,3 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
+
2
3
  export { collabEditPlugin } from '../collabEditPlugin';
@@ -14,10 +14,11 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
14
14
  import { receiveTransaction, sendableSteps } from '@atlaskit/prosemirror-collab';
15
15
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
16
16
  import { getAgentEditShimmerNotShownPayload } from './analytics';
17
+ import { getAgentEditRequester } from './main/agent-edit-requester';
17
18
  import { getAgentEditSegments } from './main/agent-review-segments';
18
19
  import { ADD_AGENT_SHIMMER_META, AGENT_EDIT_HIGHLIGHT_DEFAULT_DURATION_MS, AGENT_SHIMMER_DEFAULT_DURATION_MS, HIGHLIGHT_AGENT_SHIMMER_META, REMOVE_AGENT_SHIMMER_META } from './main/agent-shimmer-decorations';
19
- import { getAgentEditRequester } from './main/agent-edit-requester';
20
20
  import { getAgentEditChromeRanges, getAgentShimmerRanges } from './main/agent-shimmer-ranges';
21
+ import { getRemoteAgentChromeIdentity } from './main/remote-agent-chrome-identity';
21
22
  import { replaceDocument } from './utils';
22
23
 
23
24
  /*
@@ -105,7 +106,7 @@ export const applyRemoteSteps = (json, view, userIds, options, editorAnalyticsAp
105
106
  let agentShimmers = [];
106
107
  let visualJson = json;
107
108
  let visualSteps = steps;
108
- if (options !== null && options !== void 0 && options.useNativePlugin && userIds && isExperimentEnabled('platform_editor_agent_be_streaming')) {
109
+ if (options !== null && options !== void 0 && options.useNativePlugin && userIds && (isExperimentEnabled('platform_editor_ai_streaming_ux_experience_m1') || isExperimentEnabled('platform_editor_agent_be_streaming'))) {
109
110
  var _sendableSteps;
110
111
  // Read the client ID before applying the acknowledgement, while the local steps
111
112
  // are still unconfirmed. receiveTransaction removes this same local prefix.
@@ -123,16 +124,19 @@ export const applyRemoteSteps = (json, view, userIds, options, editorAnalyticsAp
123
124
  visualJson = json.slice(acknowledgedSteps);
124
125
  visualSteps = steps.slice(acknowledgedSteps);
125
126
  }
127
+ const isM1StreamingEnabled = isExperimentEnabled('platform_editor_ai_streaming_ux_experience_m1');
126
128
  const isUnifiedPostApplyChromeEnabled = isExperimentEnabled('platform_editor_ai_unified_post_apply_chrome');
127
- if (isUnifiedPostApplyChromeEnabled && isExperimentEnabled('platform_editor_agent_be_streaming')) {
129
+ if (isUnifiedPostApplyChromeEnabled && (isM1StreamingEnabled || isExperimentEnabled('platform_editor_agent_be_streaming'))) {
128
130
  const ranges = getAgentEditChromeRanges(visualJson, visualSteps, tr, view, (reason, agentType, error) => editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(getAgentEditShimmerNotShownPayload(reason, agentType, error))(tr));
129
131
  const requester = getAgentEditRequester(visualJson, view);
130
132
  if (ranges.length && requester) {
131
133
  // Collab supplies a machine agent type, not a display name; preserve the legacy
132
- // uppercase telepointer label.
134
+ // uppercase telepointer label as the fallback for observers that cannot resolve a
135
+ // redesigned presentation from the forwarded identity.
133
136
  const telepointerLabel = requester.agentType.trim().toUpperCase();
134
137
  tr.setMeta(AGENT_EDIT_CHROME_DATA, {
135
- ...getAgentEditChromeDynamicConfig(),
138
+ ...(!isM1StreamingEnabled ? getAgentEditChromeDynamicConfig() : {}),
139
+ ...getRemoteAgentChromeIdentity(requester),
136
140
  ...(telepointerLabel ? {
137
141
  telepointerLabel
138
142
  } : {}),
@@ -1,19 +1,31 @@
1
1
  import { pluginKey } from './plugin-key';
2
2
  const isAgentRemoteStep = step => typeof step === 'object' && step !== null && typeof step.agentType === 'string';
3
+ const asString = value => typeof value === 'string' ? value : undefined;
4
+ export const isStepFromAgentEdit = (step, requester) => {
5
+ if (!isAgentRemoteStep(step)) {
6
+ return false;
7
+ }
8
+ return step.agentType === requester.agentType && asString(step.agentId) === requester.agentId && asString(step.agentSourceId) === requester.agentSourceId && asString(step.agentNamedId) === requester.agentNamedId && asString(step.userId) === requester.actorUserId && asString(step.invocationId) === requester.invocationId;
9
+ };
3
10
  export const getAgentEditRequester = (json, view) => {
4
11
  var _collabPluginState$ac, _collabPluginState$ac2;
5
12
  const agentStep = json.find(isAgentRemoteStep);
6
13
  if (!agentStep) {
7
14
  return null;
8
15
  }
9
- const actorUserId = typeof agentStep.userId === 'string' ? agentStep.userId : undefined;
16
+ const actorUserId = asString(agentStep.userId);
10
17
  const collabPluginState = pluginKey.getState(view.state);
11
18
  const localSessionId = collabPluginState === null || collabPluginState === void 0 ? void 0 : collabPluginState.sessionId;
12
19
  const localUserId = localSessionId ? collabPluginState === null || collabPluginState === void 0 ? void 0 : (_collabPluginState$ac = collabPluginState.activeParticipants) === null || _collabPluginState$ac === void 0 ? void 0 : (_collabPluginState$ac2 = _collabPluginState$ac.get(localSessionId)) === null || _collabPluginState$ac2 === void 0 ? void 0 : _collabPluginState$ac2.userId : undefined;
13
20
  return {
14
- agentId: typeof agentStep.agentId === 'string' ? agentStep.agentId : undefined,
21
+ agentId: asString(agentStep.agentId),
22
+ agentName: asString(agentStep.agentName),
23
+ agentNamedId: asString(agentStep.agentNamedId),
24
+ agentSourceId: asString(agentStep.agentSourceId),
15
25
  agentType: agentStep.agentType,
16
26
  actorUserId,
27
+ invocationId: asString(agentStep.invocationId),
28
+ isThirdPartyAgent: typeof agentStep.isThirdPartyAgent === 'boolean' ? agentStep.isThirdPartyAgent : undefined,
17
29
  isLocalUserRequester: actorUserId !== undefined && localUserId !== undefined && actorUserId === localUserId
18
30
  };
19
31
  };
@@ -1,9 +1,11 @@
1
- import { slicesEqualIgnoringLocalId } from '@atlaskit/editor-common/collab-agent-review-slice-compare';
2
1
  import { getAgentEditChangedRanges } from '@atlaskit/editor-common/collab-agent-edit-changed-ranges';
2
+ import { slicesEqualIgnoringLocalId } from '@atlaskit/editor-common/collab-agent-review-slice-compare';
3
3
  import { logException } from '@atlaskit/editor-common/monitoring';
4
4
  import { AddMarkStep, RemoveMarkStep } from '@atlaskit/editor-prosemirror/transform';
5
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
5
6
  import { getCollabState } from '@atlaskit/prosemirror-collab';
6
7
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
+ import { getAgentEditRequester, isStepFromAgentEdit } from './agent-edit-requester';
7
9
  // When an agent step lands we cover the top-level block(s) it wrote with a skeleton-loader shimmer
8
10
  // (plus a Rovo agent telepointer at the end of the range), then remove it on a timer to reveal the
9
11
  // content. Gated behind the `platform_editor_agent_be_streaming` experiment. `shimmerDurationMs` and
@@ -264,9 +266,11 @@ export const getAgentEditChromeRanges = (json, steps, tr, view, onNotShown) => {
264
266
  // rolls back unconfirmed local steps before applying these remote steps, and
265
267
  // replays the local steps afterwards. Select the actual applied remote indexes;
266
268
  // the shared extractor maps them through every later step into tr.doc.
269
+ const requester = isExperimentEnabled('platform_editor_ai_streaming_ux_experience_m1') ? getAgentEditRequester(json, view) : null;
267
270
  const includedStepIndexes = [];
268
271
  json.forEach((rawStep, index) => {
269
- if (typeof (rawStep === null || rawStep === void 0 ? void 0 : rawStep.agentType) === 'string' && steps[index]) {
272
+ const belongsToSelectedAgent = !requester || isStepFromAgentEdit(rawStep, requester);
273
+ if (typeof (rawStep === null || rawStep === void 0 ? void 0 : rawStep.agentType) === 'string' && steps[index] && belongsToSelectedAgent) {
270
274
  includedStepIndexes.push(rebasedSteps + index);
271
275
  }
272
276
  });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Maps collab step attribution onto the shared agent-edit chrome identity fields.
3
+ *
4
+ * Step attribution carries the agent's provisioned Atlassian identity account id under `agentId`
5
+ * (see `getAgentAttribution`), so it is forwarded as `agentIdentityAccountId` rather than as the
6
+ * agent's own source-system id.
7
+ */
8
+ export const getRemoteAgentChromeIdentity = requester => {
9
+ var _requester$agentSourc, _requester$agentId, _requester$agentName, _requester$agentNamed;
10
+ return {
11
+ actorUserId: requester.actorUserId,
12
+ invocationId: requester.invocationId,
13
+ agentId: ((_requester$agentSourc = requester.agentSourceId) === null || _requester$agentSourc === void 0 ? void 0 : _requester$agentSourc.trim()) || undefined,
14
+ agentIdentityAccountId: ((_requester$agentId = requester.agentId) === null || _requester$agentId === void 0 ? void 0 : _requester$agentId.trim()) || undefined,
15
+ agentName: ((_requester$agentName = requester.agentName) === null || _requester$agentName === void 0 ? void 0 : _requester$agentName.trim()) || undefined,
16
+ agentNamedId: ((_requester$agentNamed = requester.agentNamedId) === null || _requester$agentNamed === void 0 ? void 0 : _requester$agentNamed.trim()) || undefined,
17
+ agentType: requester.agentType.trim() || undefined,
18
+ isThirdParty: requester.isThirdPartyAgent
19
+ };
20
+ };
@@ -1,7 +1,7 @@
1
1
  import { AnalyticsStep } from '@atlaskit/adf-schema/steps/analytics';
2
- import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps/type-ahead';
3
2
  import { LinkMetaStep } from '@atlaskit/adf-schema/steps/link-meta-step';
4
3
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps/set-attrs';
4
+ import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps/type-ahead';
5
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
6
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
7
  import { AddMarkStep, AddNodeMarkStep, AttrStep, DocAttrStep, RemoveMarkStep, RemoveNodeMarkStep, ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
@@ -1,7 +1,7 @@
1
1
  // delete this file when cleaning up platform_editor_remove_collab_step_metrics
2
2
  import { AnalyticsStep } from '@atlaskit/adf-schema/steps/analytics';
3
- import { SetAttrsStep } from '@atlaskit/adf-schema/steps/set-attrs';
4
3
  import { BatchAttrsStep } from '@atlaskit/adf-schema/steps/batch-attrs-step';
4
+ import { SetAttrsStep } from '@atlaskit/adf-schema/steps/set-attrs';
5
5
  import { AddMarkStep, AddNodeMarkStep, AttrStep, DocAttrStep, RemoveMarkStep, RemoveNodeMarkStep } from '@atlaskit/editor-prosemirror/transform';
6
6
  import { sendableSteps } from '@atlaskit/prosemirror-collab';
7
7
  import { updateNcsSessionStepMetrics } from './track-step-metrics';
@@ -1,2 +1,3 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
+
2
3
  export { collabEditPlugin } from '../collabEditPlugin';
@@ -17,10 +17,11 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
17
17
  import { receiveTransaction, sendableSteps } from '@atlaskit/prosemirror-collab';
18
18
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
19
19
  import { getAgentEditShimmerNotShownPayload } from './analytics';
20
+ import { getAgentEditRequester } from './main/agent-edit-requester';
20
21
  import { getAgentEditSegments } from './main/agent-review-segments';
21
22
  import { ADD_AGENT_SHIMMER_META, AGENT_EDIT_HIGHLIGHT_DEFAULT_DURATION_MS, AGENT_SHIMMER_DEFAULT_DURATION_MS, HIGHLIGHT_AGENT_SHIMMER_META, REMOVE_AGENT_SHIMMER_META } from './main/agent-shimmer-decorations';
22
- import { getAgentEditRequester } from './main/agent-edit-requester';
23
23
  import { getAgentEditChromeRanges, getAgentShimmerRanges } from './main/agent-shimmer-ranges';
24
+ import { getRemoteAgentChromeIdentity } from './main/remote-agent-chrome-identity';
24
25
  import { replaceDocument } from './utils';
25
26
 
26
27
  /*
@@ -95,7 +96,7 @@ export var applyRemoteSteps = function applyRemoteSteps(json, view, userIds, opt
95
96
  var agentShimmers = [];
96
97
  var visualJson = json;
97
98
  var visualSteps = steps;
98
- if (options !== null && options !== void 0 && options.useNativePlugin && userIds && isExperimentEnabled('platform_editor_agent_be_streaming')) {
99
+ if (options !== null && options !== void 0 && options.useNativePlugin && userIds && (isExperimentEnabled('platform_editor_ai_streaming_ux_experience_m1') || isExperimentEnabled('platform_editor_agent_be_streaming'))) {
99
100
  var _sendableSteps;
100
101
  // Read the client ID before applying the acknowledgement, while the local steps
101
102
  // are still unconfirmed. receiveTransaction removes this same local prefix.
@@ -113,17 +114,19 @@ export var applyRemoteSteps = function applyRemoteSteps(json, view, userIds, opt
113
114
  visualJson = json.slice(acknowledgedSteps);
114
115
  visualSteps = steps.slice(acknowledgedSteps);
115
116
  }
117
+ var isM1StreamingEnabled = isExperimentEnabled('platform_editor_ai_streaming_ux_experience_m1');
116
118
  var isUnifiedPostApplyChromeEnabled = isExperimentEnabled('platform_editor_ai_unified_post_apply_chrome');
117
- if (isUnifiedPostApplyChromeEnabled && isExperimentEnabled('platform_editor_agent_be_streaming')) {
119
+ if (isUnifiedPostApplyChromeEnabled && (isM1StreamingEnabled || isExperimentEnabled('platform_editor_agent_be_streaming'))) {
118
120
  var ranges = getAgentEditChromeRanges(visualJson, visualSteps, tr, view, function (reason, agentType, error) {
119
121
  return editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(getAgentEditShimmerNotShownPayload(reason, agentType, error))(tr);
120
122
  });
121
123
  var requester = getAgentEditRequester(visualJson, view);
122
124
  if (ranges.length && requester) {
123
125
  // Collab supplies a machine agent type, not a display name; preserve the legacy
124
- // uppercase telepointer label.
126
+ // uppercase telepointer label as the fallback for observers that cannot resolve a
127
+ // redesigned presentation from the forwarded identity.
125
128
  var telepointerLabel = requester.agentType.trim().toUpperCase();
126
- tr.setMeta(AGENT_EDIT_CHROME_DATA, _objectSpread(_objectSpread(_objectSpread({}, getAgentEditChromeDynamicConfig()), telepointerLabel ? {
129
+ tr.setMeta(AGENT_EDIT_CHROME_DATA, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, !isM1StreamingEnabled ? getAgentEditChromeDynamicConfig() : {}), getRemoteAgentChromeIdentity(requester)), telepointerLabel ? {
127
130
  telepointerLabel: telepointerLabel
128
131
  } : {}), {}, {
129
132
  ranges: ranges
@@ -3,20 +3,34 @@ import { pluginKey } from './plugin-key';
3
3
  var isAgentRemoteStep = function isAgentRemoteStep(step) {
4
4
  return _typeof(step) === 'object' && step !== null && typeof step.agentType === 'string';
5
5
  };
6
+ var asString = function asString(value) {
7
+ return typeof value === 'string' ? value : undefined;
8
+ };
9
+ export var isStepFromAgentEdit = function isStepFromAgentEdit(step, requester) {
10
+ if (!isAgentRemoteStep(step)) {
11
+ return false;
12
+ }
13
+ return step.agentType === requester.agentType && asString(step.agentId) === requester.agentId && asString(step.agentSourceId) === requester.agentSourceId && asString(step.agentNamedId) === requester.agentNamedId && asString(step.userId) === requester.actorUserId && asString(step.invocationId) === requester.invocationId;
14
+ };
6
15
  export var getAgentEditRequester = function getAgentEditRequester(json, view) {
7
16
  var _collabPluginState$ac;
8
17
  var agentStep = json.find(isAgentRemoteStep);
9
18
  if (!agentStep) {
10
19
  return null;
11
20
  }
12
- var actorUserId = typeof agentStep.userId === 'string' ? agentStep.userId : undefined;
21
+ var actorUserId = asString(agentStep.userId);
13
22
  var collabPluginState = pluginKey.getState(view.state);
14
23
  var localSessionId = collabPluginState === null || collabPluginState === void 0 ? void 0 : collabPluginState.sessionId;
15
24
  var localUserId = localSessionId ? collabPluginState === null || collabPluginState === void 0 || (_collabPluginState$ac = collabPluginState.activeParticipants) === null || _collabPluginState$ac === void 0 || (_collabPluginState$ac = _collabPluginState$ac.get(localSessionId)) === null || _collabPluginState$ac === void 0 ? void 0 : _collabPluginState$ac.userId : undefined;
16
25
  return {
17
- agentId: typeof agentStep.agentId === 'string' ? agentStep.agentId : undefined,
26
+ agentId: asString(agentStep.agentId),
27
+ agentName: asString(agentStep.agentName),
28
+ agentNamedId: asString(agentStep.agentNamedId),
29
+ agentSourceId: asString(agentStep.agentSourceId),
18
30
  agentType: agentStep.agentType,
19
31
  actorUserId: actorUserId,
32
+ invocationId: asString(agentStep.invocationId),
33
+ isThirdPartyAgent: typeof agentStep.isThirdPartyAgent === 'boolean' ? agentStep.isThirdPartyAgent : undefined,
20
34
  isLocalUserRequester: actorUserId !== undefined && localUserId !== undefined && actorUserId === localUserId
21
35
  };
22
36
  };
@@ -1,9 +1,11 @@
1
- import { slicesEqualIgnoringLocalId } from '@atlaskit/editor-common/collab-agent-review-slice-compare';
2
1
  import { getAgentEditChangedRanges } from '@atlaskit/editor-common/collab-agent-edit-changed-ranges';
2
+ import { slicesEqualIgnoringLocalId } from '@atlaskit/editor-common/collab-agent-review-slice-compare';
3
3
  import { logException } from '@atlaskit/editor-common/monitoring';
4
4
  import { AddMarkStep, RemoveMarkStep } from '@atlaskit/editor-prosemirror/transform';
5
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
5
6
  import { getCollabState } from '@atlaskit/prosemirror-collab';
6
7
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
+ import { getAgentEditRequester, isStepFromAgentEdit } from './agent-edit-requester';
7
9
  // When an agent step lands we cover the top-level block(s) it wrote with a skeleton-loader shimmer
8
10
  // (plus a Rovo agent telepointer at the end of the range), then remove it on a timer to reveal the
9
11
  // content. Gated behind the `platform_editor_agent_be_streaming` experiment. `shimmerDurationMs` and
@@ -280,9 +282,11 @@ export var getAgentEditChromeRanges = function getAgentEditChromeRanges(json, st
280
282
  // rolls back unconfirmed local steps before applying these remote steps, and
281
283
  // replays the local steps afterwards. Select the actual applied remote indexes;
282
284
  // the shared extractor maps them through every later step into tr.doc.
285
+ var requester = isExperimentEnabled('platform_editor_ai_streaming_ux_experience_m1') ? getAgentEditRequester(json, view) : null;
283
286
  var includedStepIndexes = [];
284
287
  json.forEach(function (rawStep, index) {
285
- if (typeof (rawStep === null || rawStep === void 0 ? void 0 : rawStep.agentType) === 'string' && steps[index]) {
288
+ var belongsToSelectedAgent = !requester || isStepFromAgentEdit(rawStep, requester);
289
+ if (typeof (rawStep === null || rawStep === void 0 ? void 0 : rawStep.agentType) === 'string' && steps[index] && belongsToSelectedAgent) {
286
290
  includedStepIndexes.push(rebasedSteps + index);
287
291
  }
288
292
  });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Maps collab step attribution onto the shared agent-edit chrome identity fields.
3
+ *
4
+ * Step attribution carries the agent's provisioned Atlassian identity account id under `agentId`
5
+ * (see `getAgentAttribution`), so it is forwarded as `agentIdentityAccountId` rather than as the
6
+ * agent's own source-system id.
7
+ */
8
+ export var getRemoteAgentChromeIdentity = function getRemoteAgentChromeIdentity(requester) {
9
+ var _requester$agentSourc, _requester$agentId, _requester$agentName, _requester$agentNamed;
10
+ return {
11
+ actorUserId: requester.actorUserId,
12
+ invocationId: requester.invocationId,
13
+ agentId: ((_requester$agentSourc = requester.agentSourceId) === null || _requester$agentSourc === void 0 ? void 0 : _requester$agentSourc.trim()) || undefined,
14
+ agentIdentityAccountId: ((_requester$agentId = requester.agentId) === null || _requester$agentId === void 0 ? void 0 : _requester$agentId.trim()) || undefined,
15
+ agentName: ((_requester$agentName = requester.agentName) === null || _requester$agentName === void 0 ? void 0 : _requester$agentName.trim()) || undefined,
16
+ agentNamedId: ((_requester$agentNamed = requester.agentNamedId) === null || _requester$agentNamed === void 0 ? void 0 : _requester$agentNamed.trim()) || undefined,
17
+ agentType: requester.agentType.trim() || undefined,
18
+ isThirdParty: requester.isThirdPartyAgent
19
+ };
20
+ };
@@ -1,7 +1,7 @@
1
1
  import { AnalyticsStep } from '@atlaskit/adf-schema/steps/analytics';
2
- import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps/type-ahead';
3
2
  import { LinkMetaStep } from '@atlaskit/adf-schema/steps/link-meta-step';
4
3
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps/set-attrs';
4
+ import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps/type-ahead';
5
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
6
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
7
  import { AddMarkStep, AddNodeMarkStep, AttrStep, DocAttrStep, RemoveMarkStep, RemoveNodeMarkStep, ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
@@ -4,8 +4,8 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
4
4
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
5
  // delete this file when cleaning up platform_editor_remove_collab_step_metrics
6
6
  import { AnalyticsStep } from '@atlaskit/adf-schema/steps/analytics';
7
- import { SetAttrsStep } from '@atlaskit/adf-schema/steps/set-attrs';
8
7
  import { BatchAttrsStep } from '@atlaskit/adf-schema/steps/batch-attrs-step';
8
+ import { SetAttrsStep } from '@atlaskit/adf-schema/steps/set-attrs';
9
9
  import { AddMarkStep, AddNodeMarkStep, AttrStep, DocAttrStep, RemoveMarkStep, RemoveNodeMarkStep } from '@atlaskit/editor-prosemirror/transform';
10
10
  import { sendableSteps } from '@atlaskit/prosemirror-collab';
11
11
  import { updateNcsSessionStepMetrics } from './track-step-metrics';
@@ -2,7 +2,13 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
2
  export interface AgentEditRequester {
3
3
  actorUserId?: string;
4
4
  agentId?: string;
5
+ agentName?: string;
6
+ agentNamedId?: string;
7
+ agentSourceId?: string;
5
8
  agentType: string;
9
+ invocationId?: string;
6
10
  isLocalUserRequester: boolean;
11
+ isThirdPartyAgent?: boolean;
7
12
  }
13
+ export declare const isStepFromAgentEdit: (step: unknown, requester: AgentEditRequester) => boolean;
8
14
  export declare const getAgentEditRequester: (json: unknown[], view: EditorView) => AgentEditRequester | null;
@@ -0,0 +1,12 @@
1
+ import type { AgentEditChromeData } from '@atlaskit/editor-common/collab-agent-edit-chrome';
2
+ import type { AgentEditRequester } from './agent-edit-requester';
3
+ type RemoteAgentChromeIdentity = Pick<AgentEditChromeData, 'actorUserId' | 'invocationId' | 'agentId' | 'agentIdentityAccountId' | 'agentName' | 'agentNamedId' | 'agentType' | 'isThirdParty'>;
4
+ /**
5
+ * Maps collab step attribution onto the shared agent-edit chrome identity fields.
6
+ *
7
+ * Step attribution carries the agent's provisioned Atlassian identity account id under `agentId`
8
+ * (see `getAgentAttribution`), so it is forwarded as `agentIdentityAccountId` rather than as the
9
+ * agent's own source-system id.
10
+ */
11
+ export declare const getRemoteAgentChromeIdentity: (requester: AgentEditRequester) => RemoteAgentChromeIdentity;
12
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-collab-edit",
3
- "version": "20.0.1",
3
+ "version": "20.1.1",
4
4
  "description": "Collab Edit plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,13 +32,13 @@
32
32
  "@atlaskit/platform-feature-experiments": "^0.3.0",
33
33
  "@atlaskit/platform-feature-flags": "^2.2.0",
34
34
  "@atlaskit/prosemirror-collab": "^1.1.0",
35
- "@atlaskit/tmp-editor-statsig": "^200.0.0",
35
+ "@atlaskit/tmp-editor-statsig": "^201.0.0",
36
36
  "@atlaskit/tokens": "^18.2.0",
37
37
  "@babel/runtime": "^7.0.0",
38
38
  "memoize-one": "^6.0.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "@atlaskit/editor-common": "^123.0.0",
41
+ "@atlaskit/editor-common": "^123.2.0",
42
42
  "react": "^18.2.0 || ^19.2.0",
43
43
  "react-dom": "^18.2.0 || ^19.2.0"
44
44
  },