@atlaskit/editor-plugin-collab-edit 18.0.4 → 18.0.6

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,20 @@
1
1
  # @atlaskit/editor-plugin-collab-edit
2
2
 
3
+ ## 18.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e345ad014bb3c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e345ad014bb3c) -
8
+ Avoid duplicate agent highlights and telepointers for locally acknowledged frontend steps under
9
+ platform_editor_agent_be_streaming, while preserving remote collaborator and backend edit visuals.
10
+ - Updated dependencies
11
+
12
+ ## 18.0.5
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 18.0.4
4
19
 
5
20
  ### Patch Changes
@@ -100,12 +100,31 @@ var applyRemoteSteps = exports.applyRemoteSteps = function applyRemoteSteps(json
100
100
  var shimmerDurationMs = 0;
101
101
  var highlightDurationMs = 0;
102
102
  var agentShimmers = [];
103
+ var visualJson = json;
104
+ var visualSteps = steps;
105
+ if (options !== null && options !== void 0 && options.useNativePlugin && userIds && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_be_streaming')) {
106
+ var _sendableSteps;
107
+ // Read the client ID before applying the acknowledgement, while the local steps
108
+ // are still unconfirmed. receiveTransaction removes this same local prefix.
109
+ // Exclude it from visuals too: the originating FE stream already owns its UI.
110
+ var localClientId = (_sendableSteps = (0, _prosemirrorCollab.sendableSteps)(state)) === null || _sendableSteps === void 0 ? void 0 : _sendableSteps.clientID;
111
+ var acknowledgedSteps = 0;
112
+ if (localClientId != null) {
113
+ while (userIds[acknowledgedSteps] != null && String(userIds[acknowledgedSteps]) === String(localClientId)) {
114
+ acknowledgedSteps++;
115
+ }
116
+ }
117
+ // Slice both visual inputs so remote steps stay aligned with tr.docs. The
118
+ // full batch still participates in collaboration, presence and attribution.
119
+ visualJson = json.slice(acknowledgedSteps);
120
+ visualSteps = steps.slice(acknowledgedSteps);
121
+ }
103
122
  var isUnifiedPostApplyChromeEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_ai_unified_post_apply_chrome');
104
123
  if (isUnifiedPostApplyChromeEnabled && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_agent_be_streaming')) {
105
- var ranges = (0, _agentShimmerRanges.getAgentEditChromeRanges)(json, steps, tr, view, function (reason, agentType, error) {
124
+ var ranges = (0, _agentShimmerRanges.getAgentEditChromeRanges)(visualJson, visualSteps, tr, view, function (reason, agentType, error) {
106
125
  return editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent((0, _analytics.getAgentEditShimmerNotShownPayload)(reason, agentType, error))(tr);
107
126
  });
108
- var requester = (0, _agentEditRequester.getAgentEditRequester)(json, view);
127
+ var requester = (0, _agentEditRequester.getAgentEditRequester)(visualJson, view);
109
128
  if (ranges.length && requester) {
110
129
  // Collab supplies a machine agent type, not a display name; preserve the legacy
111
130
  // uppercase telepointer label.
@@ -127,7 +146,7 @@ var applyRemoteSteps = exports.applyRemoteSteps = function applyRemoteSteps(json
127
146
  // Telepointer shown by default; `telepointerDisabled` hides it (inverted because `expVal`
128
147
  // only permits `false` as a boolean default).
129
148
  var telepointerEnabled = !(0, _expVal.expVal)('platform_editor_agent_be_streaming', 'telepointerDisabled', false);
130
- agentShimmers = (0, _agentShimmerRanges.getAgentShimmerRanges)(json, steps, tr, view, shimmerDurationMs, highlightDurationMs, telepointerEnabled,
149
+ agentShimmers = (0, _agentShimmerRanges.getAgentShimmerRanges)(visualJson, visualSteps, tr, view, shimmerDurationMs, highlightDurationMs, telepointerEnabled,
131
150
  // An agent edit that applied without the shimmer fires the operational event on the same
132
151
  // transaction, so success stays event-free and only degrades are reported.
133
152
  function (reason, agentType, error) {
@@ -11,7 +11,7 @@ import { Step } from '@atlaskit/editor-prosemirror/transform-override';
11
11
  import { expVal } from '@atlaskit/platform-feature-experiments/exp-val';
12
12
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
13
13
  import { fg } from '@atlaskit/platform-feature-flags/fg';
14
- import { receiveTransaction } from '@atlaskit/prosemirror-collab';
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
17
  import { getAgentEditSegments } from './main/agent-review-segments';
@@ -103,10 +103,29 @@ export const applyRemoteSteps = (json, view, userIds, options, editorAnalyticsAp
103
103
  let shimmerDurationMs = 0;
104
104
  let highlightDurationMs = 0;
105
105
  let agentShimmers = [];
106
+ let visualJson = json;
107
+ let visualSteps = steps;
108
+ if (options !== null && options !== void 0 && options.useNativePlugin && userIds && isExperimentEnabled('platform_editor_agent_be_streaming')) {
109
+ var _sendableSteps;
110
+ // Read the client ID before applying the acknowledgement, while the local steps
111
+ // are still unconfirmed. receiveTransaction removes this same local prefix.
112
+ // Exclude it from visuals too: the originating FE stream already owns its UI.
113
+ const localClientId = (_sendableSteps = sendableSteps(state)) === null || _sendableSteps === void 0 ? void 0 : _sendableSteps.clientID;
114
+ let acknowledgedSteps = 0;
115
+ if (localClientId != null) {
116
+ while (userIds[acknowledgedSteps] != null && String(userIds[acknowledgedSteps]) === String(localClientId)) {
117
+ acknowledgedSteps++;
118
+ }
119
+ }
120
+ // Slice both visual inputs so remote steps stay aligned with tr.docs. The
121
+ // full batch still participates in collaboration, presence and attribution.
122
+ visualJson = json.slice(acknowledgedSteps);
123
+ visualSteps = steps.slice(acknowledgedSteps);
124
+ }
106
125
  const isUnifiedPostApplyChromeEnabled = isExperimentEnabled('platform_editor_ai_unified_post_apply_chrome');
107
126
  if (isUnifiedPostApplyChromeEnabled && isExperimentEnabled('platform_editor_agent_be_streaming')) {
108
- const ranges = getAgentEditChromeRanges(json, steps, tr, view, (reason, agentType, error) => editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(getAgentEditShimmerNotShownPayload(reason, agentType, error))(tr));
109
- const requester = getAgentEditRequester(json, view);
127
+ const ranges = getAgentEditChromeRanges(visualJson, visualSteps, tr, view, (reason, agentType, error) => editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(getAgentEditShimmerNotShownPayload(reason, agentType, error))(tr));
128
+ const requester = getAgentEditRequester(visualJson, view);
110
129
  if (ranges.length && requester) {
111
130
  // Collab supplies a machine agent type, not a display name; preserve the legacy
112
131
  // uppercase telepointer label.
@@ -130,7 +149,7 @@ export const applyRemoteSteps = (json, view, userIds, options, editorAnalyticsAp
130
149
  // Telepointer shown by default; `telepointerDisabled` hides it (inverted because `expVal`
131
150
  // only permits `false` as a boolean default).
132
151
  const telepointerEnabled = !expVal('platform_editor_agent_be_streaming', 'telepointerDisabled', false);
133
- agentShimmers = getAgentShimmerRanges(json, steps, tr, view, shimmerDurationMs, highlightDurationMs, telepointerEnabled,
152
+ agentShimmers = getAgentShimmerRanges(visualJson, visualSteps, tr, view, shimmerDurationMs, highlightDurationMs, telepointerEnabled,
134
153
  // An agent edit that applied without the shimmer fires the operational event on the same
135
154
  // transaction, so success stays event-free and only degrades are reported.
136
155
  (reason, agentType, error) => editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(getAgentEditShimmerNotShownPayload(reason, agentType, error))(tr));
@@ -14,7 +14,7 @@ import { Step } from '@atlaskit/editor-prosemirror/transform-override';
14
14
  import { expVal } from '@atlaskit/platform-feature-experiments/exp-val';
15
15
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
16
16
  import { fg } from '@atlaskit/platform-feature-flags/fg';
17
- import { receiveTransaction } from '@atlaskit/prosemirror-collab';
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
20
  import { getAgentEditSegments } from './main/agent-review-segments';
@@ -93,12 +93,31 @@ export var applyRemoteSteps = function applyRemoteSteps(json, view, userIds, opt
93
93
  var shimmerDurationMs = 0;
94
94
  var highlightDurationMs = 0;
95
95
  var agentShimmers = [];
96
+ var visualJson = json;
97
+ var visualSteps = steps;
98
+ if (options !== null && options !== void 0 && options.useNativePlugin && userIds && isExperimentEnabled('platform_editor_agent_be_streaming')) {
99
+ var _sendableSteps;
100
+ // Read the client ID before applying the acknowledgement, while the local steps
101
+ // are still unconfirmed. receiveTransaction removes this same local prefix.
102
+ // Exclude it from visuals too: the originating FE stream already owns its UI.
103
+ var localClientId = (_sendableSteps = sendableSteps(state)) === null || _sendableSteps === void 0 ? void 0 : _sendableSteps.clientID;
104
+ var acknowledgedSteps = 0;
105
+ if (localClientId != null) {
106
+ while (userIds[acknowledgedSteps] != null && String(userIds[acknowledgedSteps]) === String(localClientId)) {
107
+ acknowledgedSteps++;
108
+ }
109
+ }
110
+ // Slice both visual inputs so remote steps stay aligned with tr.docs. The
111
+ // full batch still participates in collaboration, presence and attribution.
112
+ visualJson = json.slice(acknowledgedSteps);
113
+ visualSteps = steps.slice(acknowledgedSteps);
114
+ }
96
115
  var isUnifiedPostApplyChromeEnabled = isExperimentEnabled('platform_editor_ai_unified_post_apply_chrome');
97
116
  if (isUnifiedPostApplyChromeEnabled && isExperimentEnabled('platform_editor_agent_be_streaming')) {
98
- var ranges = getAgentEditChromeRanges(json, steps, tr, view, function (reason, agentType, error) {
117
+ var ranges = getAgentEditChromeRanges(visualJson, visualSteps, tr, view, function (reason, agentType, error) {
99
118
  return editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(getAgentEditShimmerNotShownPayload(reason, agentType, error))(tr);
100
119
  });
101
- var requester = getAgentEditRequester(json, view);
120
+ var requester = getAgentEditRequester(visualJson, view);
102
121
  if (ranges.length && requester) {
103
122
  // Collab supplies a machine agent type, not a display name; preserve the legacy
104
123
  // uppercase telepointer label.
@@ -120,7 +139,7 @@ export var applyRemoteSteps = function applyRemoteSteps(json, view, userIds, opt
120
139
  // Telepointer shown by default; `telepointerDisabled` hides it (inverted because `expVal`
121
140
  // only permits `false` as a boolean default).
122
141
  var telepointerEnabled = !expVal('platform_editor_agent_be_streaming', 'telepointerDisabled', false);
123
- agentShimmers = getAgentShimmerRanges(json, steps, tr, view, shimmerDurationMs, highlightDurationMs, telepointerEnabled,
142
+ agentShimmers = getAgentShimmerRanges(visualJson, visualSteps, tr, view, shimmerDurationMs, highlightDurationMs, telepointerEnabled,
124
143
  // An agent edit that applied without the shimmer fires the operational event on the same
125
144
  // transaction, so success stays event-free and only degrades are reported.
126
145
  function (reason, agentType, error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-collab-edit",
3
- "version": "18.0.4",
3
+ "version": "18.0.6",
4
4
  "description": "Collab Edit plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,17 +28,17 @@
28
28
  "@atlaskit/editor-plugin-feature-flags": "^16.0.0",
29
29
  "@atlaskit/editor-prosemirror": "^8.0.0",
30
30
  "@atlaskit/editor-shared-styles": "^4.1.0",
31
- "@atlaskit/frontend-utilities": "^4.3.0",
31
+ "@atlaskit/frontend-utilities": "^4.4.0",
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": "^183.0.0",
35
+ "@atlaskit/tmp-editor-statsig": "^185.0.0",
36
36
  "@atlaskit/tokens": "^16.11.0",
37
37
  "@babel/runtime": "^7.0.0",
38
38
  "memoize-one": "^6.0.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "@atlaskit/editor-common": "^121.2.0",
41
+ "@atlaskit/editor-common": "^121.3.0",
42
42
  "react": "^18.2.0 || ^19.2.0",
43
43
  "react-dom": "^18.2.0 || ^19.2.0"
44
44
  },