@atlaskit/editor-plugin-collab-edit 16.0.5 → 16.0.7
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 +15 -0
- package/dist/cjs/pm-plugins/actions.js +5 -1
- package/dist/cjs/pm-plugins/main/agent-edit-requester.js +29 -0
- package/dist/cjs/pm-plugins/main/agent-review-segments.js +8 -24
- package/dist/es2019/pm-plugins/actions.js +5 -1
- package/dist/es2019/pm-plugins/main/agent-edit-requester.js +19 -0
- package/dist/es2019/pm-plugins/main/agent-review-segments.js +10 -23
- package/dist/esm/pm-plugins/actions.js +5 -1
- package/dist/esm/pm-plugins/main/agent-edit-requester.js +22 -0
- package/dist/esm/pm-plugins/main/agent-review-segments.js +8 -25
- package/dist/types/pm-plugins/main/agent-edit-requester.d.ts +8 -0
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-collab-edit
|
|
2
2
|
|
|
3
|
+
## 16.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8e31bb980f037`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8e31bb980f037) -
|
|
8
|
+
Under platform_editor_agent_be_review_undo, record locally requested backend agent edits in native
|
|
9
|
+
undo history while preserving existing remote-collab history behavior for other updates.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 16.0.6
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 16.0.5
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -10,12 +10,14 @@ var allAtlaskitCustomSteps = _interopRequireWildcard(require("@atlaskit/custom-s
|
|
|
10
10
|
var _collabAgentRemoteEditReview = require("@atlaskit/editor-common/collab-agent-remote-edit-review");
|
|
11
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
12
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
13
|
+
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
13
14
|
var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
|
|
14
15
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
15
16
|
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
16
17
|
var _analytics = require("./analytics");
|
|
17
18
|
var _agentReviewSegments = require("./main/agent-review-segments");
|
|
18
19
|
var _agentShimmerDecorations = require("./main/agent-shimmer-decorations");
|
|
20
|
+
var _agentEditRequester = require("./main/agent-edit-requester");
|
|
19
21
|
var _agentShimmerRanges = require("./main/agent-shimmer-ranges");
|
|
20
22
|
var _utils = require("./utils");
|
|
21
23
|
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); }
|
|
@@ -83,7 +85,9 @@ var applyRemoteSteps = exports.applyRemoteSteps = function applyRemoteSteps(json
|
|
|
83
85
|
});
|
|
84
86
|
}
|
|
85
87
|
if (tr) {
|
|
86
|
-
|
|
88
|
+
var agentEditRequester = (0, _fg.fg)('platform_editor_agent_be_review_undo') ? (0, _agentEditRequester.getAgentEditRequester)(json, view) : null;
|
|
89
|
+
var shouldRecordAgentEditInHistory = (agentEditRequester === null || agentEditRequester === void 0 ? void 0 : agentEditRequester.isLocalUserRequester) === true;
|
|
90
|
+
tr.setMeta('addToHistory', shouldRecordAgentEditInHistory);
|
|
87
91
|
tr.setMeta('isRemote', true);
|
|
88
92
|
|
|
89
93
|
// Agent edit shimmer: mark the ranges agent steps just wrote so the plugin reveals them with the
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getAgentEditRequester = void 0;
|
|
8
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
|
+
var _pluginKey = require("./plugin-key");
|
|
10
|
+
var isAgentRemoteStep = function isAgentRemoteStep(step) {
|
|
11
|
+
return (0, _typeof2.default)(step) === 'object' && step !== null && typeof step.agentType === 'string';
|
|
12
|
+
};
|
|
13
|
+
var getAgentEditRequester = exports.getAgentEditRequester = function getAgentEditRequester(json, view) {
|
|
14
|
+
var _collabPluginState$ac;
|
|
15
|
+
var agentStep = json.find(isAgentRemoteStep);
|
|
16
|
+
if (!agentStep) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
var actorUserId = typeof agentStep.userId === 'string' ? agentStep.userId : undefined;
|
|
20
|
+
var collabPluginState = _pluginKey.pluginKey.getState(view.state);
|
|
21
|
+
var localSessionId = collabPluginState === null || collabPluginState === void 0 ? void 0 : collabPluginState.sessionId;
|
|
22
|
+
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
|
+
return {
|
|
24
|
+
agentId: typeof agentStep.agentId === 'string' ? agentStep.agentId : undefined,
|
|
25
|
+
agentType: agentStep.agentType,
|
|
26
|
+
actorUserId: actorUserId,
|
|
27
|
+
isLocalUserRequester: actorUserId !== undefined && localUserId !== undefined && actorUserId === localUserId
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -7,8 +7,8 @@ exports.getAgentEditSegments = exports.REVIEW_MOMENT_AGENT_TYPES_CONFIG = void 0
|
|
|
7
7
|
var _collabAgentReviewSliceCompare = require("@atlaskit/editor-common/collab-agent-review-slice-compare");
|
|
8
8
|
var _expVal = require("@atlaskit/platform-feature-experiments/exp-val");
|
|
9
9
|
var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
|
|
10
|
+
var _agentEditRequester = require("./agent-edit-requester");
|
|
10
11
|
var _agentShimmerRanges = require("./agent-shimmer-ranges");
|
|
11
|
-
var _pluginKey = require("./plugin-key");
|
|
12
12
|
// Statsig dynamic config: which BE-streaming `agentType` values may open Review Moment.
|
|
13
13
|
// Code default is `[]` (fail closed) until the list is set in Statsig.
|
|
14
14
|
var REVIEW_MOMENT_AGENT_TYPES_CONFIG = exports.REVIEW_MOMENT_AGENT_TYPES_CONFIG = 'platform_editor_backend_review_moment_agent_types';
|
|
@@ -101,37 +101,21 @@ var mapToBeforeDoc = function mapToBeforeDoc(steps, pos, stepIndex, bias) {
|
|
|
101
101
|
* @param view the editor view (for the collab rebase guard)
|
|
102
102
|
*/
|
|
103
103
|
var getAgentEditSegments = exports.getAgentEditSegments = function getAgentEditSegments(json, steps, tr, view) {
|
|
104
|
-
var
|
|
105
|
-
|
|
106
|
-
// from the first agent step; it is identical across a batch.
|
|
107
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
|
-
var agentStep = json.find(function (step) {
|
|
109
|
-
return typeof (step === null || step === void 0 ? void 0 : step.agentType) === 'string';
|
|
110
|
-
});
|
|
111
|
-
var agentType = agentStep === null || agentStep === void 0 ? void 0 : agentStep.agentType;
|
|
112
|
-
if (agentType === undefined) {
|
|
104
|
+
var agentEditRequester = (0, _agentEditRequester.getAgentEditRequester)(json, view);
|
|
105
|
+
if (!agentEditRequester) {
|
|
113
106
|
return null;
|
|
114
107
|
}
|
|
108
|
+
var actorUserId = agentEditRequester.actorUserId,
|
|
109
|
+
agentId = agentEditRequester.agentId,
|
|
110
|
+
agentType = agentEditRequester.agentType,
|
|
111
|
+
isLocalUserRequester = agentEditRequester.isLocalUserRequester;
|
|
112
|
+
|
|
115
113
|
// Only record Review Moment for agentTypes allowlisted in Statsig. Default `[]` fails
|
|
116
114
|
// closed until the config is populated (CCI-18607).
|
|
117
115
|
var allowedAgentTypes = (0, _expVal.expVal)(REVIEW_MOMENT_AGENT_TYPES_CONFIG, 'value', []);
|
|
118
116
|
if (!allowedAgentTypes.includes(agentType)) {
|
|
119
117
|
return null;
|
|
120
118
|
}
|
|
121
|
-
// The user the agent acted on behalf of (the requester). Optional/additive on the
|
|
122
|
-
// step contract, so it may be absent.
|
|
123
|
-
var actorUserId = typeof (agentStep === null || agentStep === void 0 ? void 0 : agentStep.userId) === 'string' ? agentStep.userId : undefined;
|
|
124
|
-
// Resolve the local user's AAID via the collab session: the plugin state knows this
|
|
125
|
-
// client's session id, and the participant list maps that to a `userId`. Both are
|
|
126
|
-
// optional, so an unresolvable identity degrades to `false` (see the contract).
|
|
127
|
-
var collabPluginState = _pluginKey.pluginKey.getState(view.state);
|
|
128
|
-
var localSessionId = collabPluginState === null || collabPluginState === void 0 ? void 0 : collabPluginState.sessionId;
|
|
129
|
-
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;
|
|
130
|
-
var isLocalUserRequester = actorUserId !== undefined && localUserId !== undefined && actorUserId === localUserId;
|
|
131
|
-
// Which agent instance wrote the batch. Additive on the step contract like
|
|
132
|
-
// `userId`, so treat it as optional. Carried for contract clarity / future
|
|
133
|
-
// per-agent attribution; nothing consumes it yet.
|
|
134
|
-
var agentId = typeof (agentStep === null || agentStep === void 0 ? void 0 : agentStep.agentId) === 'string' ? agentStep.agentId : undefined;
|
|
135
119
|
// Hybrid end-of-edit seam: if the BE/NCS flags a batch as the terminal one, carry
|
|
136
120
|
// it so the AI plugin can open review immediately instead of waiting for the
|
|
137
121
|
// debounce. Additive marker; absent for streaming (non-final) batches.
|
|
@@ -7,12 +7,14 @@ import * as allAtlaskitCustomSteps from '@atlaskit/custom-steps';
|
|
|
7
7
|
import { AGENT_REMOTE_EDIT_REVIEW_DATA } from '@atlaskit/editor-common/collab-agent-remote-edit-review';
|
|
8
8
|
import { AllSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
10
11
|
import { receiveTransaction } from '@atlaskit/prosemirror-collab';
|
|
11
12
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
13
|
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
13
14
|
import { getAgentEditShimmerNotShownPayload } from './analytics';
|
|
14
15
|
import { getAgentEditSegments } from './main/agent-review-segments';
|
|
15
16
|
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';
|
|
17
|
+
import { getAgentEditRequester } from './main/agent-edit-requester';
|
|
16
18
|
import { getAgentShimmerRanges } from './main/agent-shimmer-ranges';
|
|
17
19
|
import { replaceDocument } from './utils';
|
|
18
20
|
|
|
@@ -87,7 +89,9 @@ export const applyRemoteSteps = (json, view, userIds, options, editorAnalyticsAp
|
|
|
87
89
|
steps.forEach(step => tr.step(step));
|
|
88
90
|
}
|
|
89
91
|
if (tr) {
|
|
90
|
-
|
|
92
|
+
const agentEditRequester = fg('platform_editor_agent_be_review_undo') ? getAgentEditRequester(json, view) : null;
|
|
93
|
+
const shouldRecordAgentEditInHistory = (agentEditRequester === null || agentEditRequester === void 0 ? void 0 : agentEditRequester.isLocalUserRequester) === true;
|
|
94
|
+
tr.setMeta('addToHistory', shouldRecordAgentEditInHistory);
|
|
91
95
|
tr.setMeta('isRemote', true);
|
|
92
96
|
|
|
93
97
|
// Agent edit shimmer: mark the ranges agent steps just wrote so the plugin reveals them with the
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { pluginKey } from './plugin-key';
|
|
2
|
+
const isAgentRemoteStep = step => typeof step === 'object' && step !== null && typeof step.agentType === 'string';
|
|
3
|
+
export const getAgentEditRequester = (json, view) => {
|
|
4
|
+
var _collabPluginState$ac, _collabPluginState$ac2;
|
|
5
|
+
const agentStep = json.find(isAgentRemoteStep);
|
|
6
|
+
if (!agentStep) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const actorUserId = typeof agentStep.userId === 'string' ? agentStep.userId : undefined;
|
|
10
|
+
const collabPluginState = pluginKey.getState(view.state);
|
|
11
|
+
const localSessionId = collabPluginState === null || collabPluginState === void 0 ? void 0 : collabPluginState.sessionId;
|
|
12
|
+
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
|
+
return {
|
|
14
|
+
agentId: typeof agentStep.agentId === 'string' ? agentStep.agentId : undefined,
|
|
15
|
+
agentType: agentStep.agentType,
|
|
16
|
+
actorUserId,
|
|
17
|
+
isLocalUserRequester: actorUserId !== undefined && localUserId !== undefined && actorUserId === localUserId
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { slicesEqualIgnoringLocalId } from '@atlaskit/editor-common/collab-agent-review-slice-compare';
|
|
2
2
|
import { expVal } from '@atlaskit/platform-feature-experiments/exp-val';
|
|
3
3
|
import { getCollabState } from '@atlaskit/prosemirror-collab';
|
|
4
|
+
import { getAgentEditRequester } from './agent-edit-requester';
|
|
4
5
|
import { isPositionNeutralStep } from './agent-shimmer-ranges';
|
|
5
|
-
import { pluginKey } from './plugin-key';
|
|
6
|
-
|
|
7
6
|
// Statsig dynamic config: which BE-streaming `agentType` values may open Review Moment.
|
|
8
7
|
// Code default is `[]` (fail closed) until the list is set in Statsig.
|
|
9
8
|
export const REVIEW_MOMENT_AGENT_TYPES_CONFIG = 'platform_editor_backend_review_moment_agent_types';
|
|
@@ -90,35 +89,23 @@ const mapToBeforeDoc = (steps, pos, stepIndex, bias) => {
|
|
|
90
89
|
* @param view the editor view (for the collab rebase guard)
|
|
91
90
|
*/
|
|
92
91
|
export const getAgentEditSegments = (json, steps, tr, view) => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// from the first agent step; it is identical across a batch.
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
|
-
const agentStep = json.find(step => typeof (step === null || step === void 0 ? void 0 : step.agentType) === 'string');
|
|
98
|
-
const agentType = agentStep === null || agentStep === void 0 ? void 0 : agentStep.agentType;
|
|
99
|
-
if (agentType === undefined) {
|
|
92
|
+
const agentEditRequester = getAgentEditRequester(json, view);
|
|
93
|
+
if (!agentEditRequester) {
|
|
100
94
|
return null;
|
|
101
95
|
}
|
|
96
|
+
const {
|
|
97
|
+
actorUserId,
|
|
98
|
+
agentId,
|
|
99
|
+
agentType,
|
|
100
|
+
isLocalUserRequester
|
|
101
|
+
} = agentEditRequester;
|
|
102
|
+
|
|
102
103
|
// Only record Review Moment for agentTypes allowlisted in Statsig. Default `[]` fails
|
|
103
104
|
// closed until the config is populated (CCI-18607).
|
|
104
105
|
const allowedAgentTypes = expVal(REVIEW_MOMENT_AGENT_TYPES_CONFIG, 'value', []);
|
|
105
106
|
if (!allowedAgentTypes.includes(agentType)) {
|
|
106
107
|
return null;
|
|
107
108
|
}
|
|
108
|
-
// The user the agent acted on behalf of (the requester). Optional/additive on the
|
|
109
|
-
// step contract, so it may be absent.
|
|
110
|
-
const actorUserId = typeof (agentStep === null || agentStep === void 0 ? void 0 : agentStep.userId) === 'string' ? agentStep.userId : undefined;
|
|
111
|
-
// Resolve the local user's AAID via the collab session: the plugin state knows this
|
|
112
|
-
// client's session id, and the participant list maps that to a `userId`. Both are
|
|
113
|
-
// optional, so an unresolvable identity degrades to `false` (see the contract).
|
|
114
|
-
const collabPluginState = pluginKey.getState(view.state);
|
|
115
|
-
const localSessionId = collabPluginState === null || collabPluginState === void 0 ? void 0 : collabPluginState.sessionId;
|
|
116
|
-
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;
|
|
117
|
-
const isLocalUserRequester = actorUserId !== undefined && localUserId !== undefined && actorUserId === localUserId;
|
|
118
|
-
// Which agent instance wrote the batch. Additive on the step contract like
|
|
119
|
-
// `userId`, so treat it as optional. Carried for contract clarity / future
|
|
120
|
-
// per-agent attribution; nothing consumes it yet.
|
|
121
|
-
const agentId = typeof (agentStep === null || agentStep === void 0 ? void 0 : agentStep.agentId) === 'string' ? agentStep.agentId : undefined;
|
|
122
109
|
// Hybrid end-of-edit seam: if the BE/NCS flags a batch as the terminal one, carry
|
|
123
110
|
// it so the AI plugin can open review immediately instead of waiting for the
|
|
124
111
|
// debounce. Additive marker; absent for streaming (non-final) batches.
|
|
@@ -7,12 +7,14 @@ import * as allAtlaskitCustomSteps from '@atlaskit/custom-steps';
|
|
|
7
7
|
import { AGENT_REMOTE_EDIT_REVIEW_DATA } from '@atlaskit/editor-common/collab-agent-remote-edit-review';
|
|
8
8
|
import { AllSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
10
11
|
import { receiveTransaction } from '@atlaskit/prosemirror-collab';
|
|
11
12
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
13
|
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
13
14
|
import { getAgentEditShimmerNotShownPayload } from './analytics';
|
|
14
15
|
import { getAgentEditSegments } from './main/agent-review-segments';
|
|
15
16
|
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';
|
|
17
|
+
import { getAgentEditRequester } from './main/agent-edit-requester';
|
|
16
18
|
import { getAgentShimmerRanges } from './main/agent-shimmer-ranges';
|
|
17
19
|
import { replaceDocument } from './utils';
|
|
18
20
|
|
|
@@ -74,7 +76,9 @@ export var applyRemoteSteps = function applyRemoteSteps(json, view, userIds, opt
|
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
78
|
if (tr) {
|
|
77
|
-
|
|
79
|
+
var agentEditRequester = fg('platform_editor_agent_be_review_undo') ? getAgentEditRequester(json, view) : null;
|
|
80
|
+
var shouldRecordAgentEditInHistory = (agentEditRequester === null || agentEditRequester === void 0 ? void 0 : agentEditRequester.isLocalUserRequester) === true;
|
|
81
|
+
tr.setMeta('addToHistory', shouldRecordAgentEditInHistory);
|
|
78
82
|
tr.setMeta('isRemote', true);
|
|
79
83
|
|
|
80
84
|
// Agent edit shimmer: mark the ranges agent steps just wrote so the plugin reveals them with the
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
import { pluginKey } from './plugin-key';
|
|
3
|
+
var isAgentRemoteStep = function isAgentRemoteStep(step) {
|
|
4
|
+
return _typeof(step) === 'object' && step !== null && typeof step.agentType === 'string';
|
|
5
|
+
};
|
|
6
|
+
export var getAgentEditRequester = function getAgentEditRequester(json, view) {
|
|
7
|
+
var _collabPluginState$ac;
|
|
8
|
+
var agentStep = json.find(isAgentRemoteStep);
|
|
9
|
+
if (!agentStep) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
var actorUserId = typeof agentStep.userId === 'string' ? agentStep.userId : undefined;
|
|
13
|
+
var collabPluginState = pluginKey.getState(view.state);
|
|
14
|
+
var localSessionId = collabPluginState === null || collabPluginState === void 0 ? void 0 : collabPluginState.sessionId;
|
|
15
|
+
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
|
+
return {
|
|
17
|
+
agentId: typeof agentStep.agentId === 'string' ? agentStep.agentId : undefined,
|
|
18
|
+
agentType: agentStep.agentType,
|
|
19
|
+
actorUserId: actorUserId,
|
|
20
|
+
isLocalUserRequester: actorUserId !== undefined && localUserId !== undefined && actorUserId === localUserId
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { slicesEqualIgnoringLocalId } from '@atlaskit/editor-common/collab-agent-review-slice-compare';
|
|
2
2
|
import { expVal } from '@atlaskit/platform-feature-experiments/exp-val';
|
|
3
3
|
import { getCollabState } from '@atlaskit/prosemirror-collab';
|
|
4
|
+
import { getAgentEditRequester } from './agent-edit-requester';
|
|
4
5
|
import { isPositionNeutralStep } from './agent-shimmer-ranges';
|
|
5
|
-
import { pluginKey } from './plugin-key';
|
|
6
|
-
|
|
7
6
|
// Statsig dynamic config: which BE-streaming `agentType` values may open Review Moment.
|
|
8
7
|
// Code default is `[]` (fail closed) until the list is set in Statsig.
|
|
9
8
|
export var REVIEW_MOMENT_AGENT_TYPES_CONFIG = 'platform_editor_backend_review_moment_agent_types';
|
|
@@ -96,37 +95,21 @@ var mapToBeforeDoc = function mapToBeforeDoc(steps, pos, stepIndex, bias) {
|
|
|
96
95
|
* @param view the editor view (for the collab rebase guard)
|
|
97
96
|
*/
|
|
98
97
|
export var getAgentEditSegments = function getAgentEditSegments(json, steps, tr, view) {
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
// from the first agent step; it is identical across a batch.
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
-
var agentStep = json.find(function (step) {
|
|
104
|
-
return typeof (step === null || step === void 0 ? void 0 : step.agentType) === 'string';
|
|
105
|
-
});
|
|
106
|
-
var agentType = agentStep === null || agentStep === void 0 ? void 0 : agentStep.agentType;
|
|
107
|
-
if (agentType === undefined) {
|
|
98
|
+
var agentEditRequester = getAgentEditRequester(json, view);
|
|
99
|
+
if (!agentEditRequester) {
|
|
108
100
|
return null;
|
|
109
101
|
}
|
|
102
|
+
var actorUserId = agentEditRequester.actorUserId,
|
|
103
|
+
agentId = agentEditRequester.agentId,
|
|
104
|
+
agentType = agentEditRequester.agentType,
|
|
105
|
+
isLocalUserRequester = agentEditRequester.isLocalUserRequester;
|
|
106
|
+
|
|
110
107
|
// Only record Review Moment for agentTypes allowlisted in Statsig. Default `[]` fails
|
|
111
108
|
// closed until the config is populated (CCI-18607).
|
|
112
109
|
var allowedAgentTypes = expVal(REVIEW_MOMENT_AGENT_TYPES_CONFIG, 'value', []);
|
|
113
110
|
if (!allowedAgentTypes.includes(agentType)) {
|
|
114
111
|
return null;
|
|
115
112
|
}
|
|
116
|
-
// The user the agent acted on behalf of (the requester). Optional/additive on the
|
|
117
|
-
// step contract, so it may be absent.
|
|
118
|
-
var actorUserId = typeof (agentStep === null || agentStep === void 0 ? void 0 : agentStep.userId) === 'string' ? agentStep.userId : undefined;
|
|
119
|
-
// Resolve the local user's AAID via the collab session: the plugin state knows this
|
|
120
|
-
// client's session id, and the participant list maps that to a `userId`. Both are
|
|
121
|
-
// optional, so an unresolvable identity degrades to `false` (see the contract).
|
|
122
|
-
var collabPluginState = pluginKey.getState(view.state);
|
|
123
|
-
var localSessionId = collabPluginState === null || collabPluginState === void 0 ? void 0 : collabPluginState.sessionId;
|
|
124
|
-
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;
|
|
125
|
-
var isLocalUserRequester = actorUserId !== undefined && localUserId !== undefined && actorUserId === localUserId;
|
|
126
|
-
// Which agent instance wrote the batch. Additive on the step contract like
|
|
127
|
-
// `userId`, so treat it as optional. Carried for contract clarity / future
|
|
128
|
-
// per-agent attribution; nothing consumes it yet.
|
|
129
|
-
var agentId = typeof (agentStep === null || agentStep === void 0 ? void 0 : agentStep.agentId) === 'string' ? agentStep.agentId : undefined;
|
|
130
113
|
// Hybrid end-of-edit seam: if the BE/NCS flags a batch as the terminal one, carry
|
|
131
114
|
// it so the AI plugin can open review immediately instead of waiting for the
|
|
132
115
|
// debounce. Additive marker; absent for streaming (non-final) batches.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
export interface AgentEditRequester {
|
|
3
|
+
actorUserId?: string;
|
|
4
|
+
agentId?: string;
|
|
5
|
+
agentType: string;
|
|
6
|
+
isLocalUserRequester: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const getAgentEditRequester: (json: unknown[], view: EditorView) => AgentEditRequester | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-collab-edit",
|
|
3
|
-
"version": "16.0.
|
|
3
|
+
"version": "16.0.7",
|
|
4
4
|
"description": "Collab Edit plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
33
33
|
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
34
34
|
"@atlaskit/prosemirror-collab": "^1.0.0",
|
|
35
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
35
|
+
"@atlaskit/tmp-editor-statsig": "^152.0.0",
|
|
36
36
|
"@atlaskit/tokens": "^16.7.0",
|
|
37
37
|
"@babel/runtime": "^7.0.0",
|
|
38
38
|
"memoize-one": "^6.0.0"
|
|
@@ -85,6 +85,9 @@
|
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
"platform-feature-flags": {
|
|
88
|
+
"platform_editor_agent_be_review_undo": {
|
|
89
|
+
"type": "boolean"
|
|
90
|
+
},
|
|
88
91
|
"platform_editor_collab_organic_change_reporting": {
|
|
89
92
|
"type": "boolean"
|
|
90
93
|
}
|