@atlaskit/rovo-triggers 10.34.0 → 10.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/rovo-triggers
2
2
 
3
+ ## 10.35.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`64dbb5601ed23`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/64dbb5601ed23) -
8
+ Ask the product for context when the extension context bridge client mounts.
9
+
10
+ `ExtensionContextBridgeClient` now sends a single `request-context` control message once its
11
+ transport is ready. A product that answers requests replies with the context it has already
12
+ published, so a chat opened after the page settled is caught up instead of waiting for the next
13
+ publish.
14
+
15
+ This completes the handshake whose two halves shipped separately: the control message itself, and
16
+ the product-side answer. It exists because the bridge is otherwise fire-and-forget, which suits a
17
+ publisher that runs continuously, such as the Confluence editor, but not one that publishes once
18
+ per navigation, such as a Jira view.
19
+
20
+ Additive and safe against products that do not answer: the request is sent once per mount, carries
21
+ no data, and a product that ignores it behaves exactly as before.
22
+
3
23
  ## 10.34.0
4
24
 
5
25
  ### Minor Changes
@@ -131,6 +131,24 @@ var ExtensionContextBridgeClient = exports.ExtensionContextBridgeClient = functi
131
131
  });
132
132
  }, [activeTransport, publish]);
133
133
 
134
+ // Handshake: ask the product to re-send its current context.
135
+ //
136
+ // The chat only ever sees context published while it is listening, and it mounts long after the
137
+ // page — the user opens the side panel on a page that settled minutes ago. Products that publish
138
+ // once per navigation (Jira views) would otherwise never be observed at all. Asking, rather than
139
+ // having the extension retain context on the chance a panel opens later, keeps page data in the
140
+ // page until a chat actually exists to receive it.
141
+ (0, _react.useEffect)(function () {
142
+ if (!activeTransport) {
143
+ return;
144
+ }
145
+ try {
146
+ activeTransport.send((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants.BRIDGE_MESSAGE_MARKER, true), "direction", _constants.BRIDGE_TO_PRODUCT), "control", _constants.BRIDGE_CONTROL_REQUEST_CONTEXT));
147
+ } catch (_unused2) {
148
+ // Never let bridging break the chat iframe.
149
+ }
150
+ }, [activeTransport]);
151
+
134
152
  // Outbound (WRITE, payloads): allowlisted chat actions -> product.
135
153
  (0, _main.useSubscribeAll)(function (payload) {
136
154
  if (!activeTransport) {
@@ -149,7 +167,7 @@ var ExtensionContextBridgeClient = exports.ExtensionContextBridgeClient = functi
149
167
  }
150
168
  try {
151
169
  activeTransport.send((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants.BRIDGE_MESSAGE_MARKER, true), "direction", _constants.BRIDGE_TO_PRODUCT), "payload", serialized));
152
- } catch (_unused2) {
170
+ } catch (_unused3) {
153
171
  // Never let bridging break the chat iframe.
154
172
  }
155
173
  });
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useMemo, useRef } from 'react';
2
2
  import { fg } from '@atlaskit/platform-feature-flags/fg';
3
3
  import { usePublish, useSubscribeAll } from '../../../main';
4
- import { BRIDGE_MESSAGE_MARKER, BRIDGE_SOURCE, BRIDGE_TO_EXTENSION, BRIDGE_TO_PRODUCT } from './constants';
4
+ import { BRIDGE_CONTROL_REQUEST_CONTEXT, BRIDGE_MESSAGE_MARKER, BRIDGE_SOURCE, BRIDGE_TO_EXTENSION, BRIDGE_TO_PRODUCT } from './constants';
5
5
  import { shouldRelayToProduct } from './policy';
6
6
  import { deserializePayload, serializePayload } from './registry';
7
7
  import { createWindowTransport, isBridgeControlMessage } from './transport';
@@ -125,6 +125,28 @@ export const ExtensionContextBridgeClient = ({
125
125
  });
126
126
  }, [activeTransport, publish]);
127
127
 
128
+ // Handshake: ask the product to re-send its current context.
129
+ //
130
+ // The chat only ever sees context published while it is listening, and it mounts long after the
131
+ // page — the user opens the side panel on a page that settled minutes ago. Products that publish
132
+ // once per navigation (Jira views) would otherwise never be observed at all. Asking, rather than
133
+ // having the extension retain context on the chance a panel opens later, keeps page data in the
134
+ // page until a chat actually exists to receive it.
135
+ useEffect(() => {
136
+ if (!activeTransport) {
137
+ return;
138
+ }
139
+ try {
140
+ activeTransport.send({
141
+ [BRIDGE_MESSAGE_MARKER]: true,
142
+ direction: BRIDGE_TO_PRODUCT,
143
+ control: BRIDGE_CONTROL_REQUEST_CONTEXT
144
+ });
145
+ } catch {
146
+ // Never let bridging break the chat iframe.
147
+ }
148
+ }, [activeTransport]);
149
+
128
150
  // Outbound (WRITE, payloads): allowlisted chat actions -> product.
129
151
  useSubscribeAll(payload => {
130
152
  if (!activeTransport) {
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { useEffect, useMemo, useRef } from 'react';
5
5
  import { fg } from '@atlaskit/platform-feature-flags/fg';
6
6
  import { usePublish, useSubscribeAll } from '../../../main';
7
- import { BRIDGE_MESSAGE_MARKER, BRIDGE_SOURCE, BRIDGE_TO_EXTENSION, BRIDGE_TO_PRODUCT } from './constants';
7
+ import { BRIDGE_CONTROL_REQUEST_CONTEXT, BRIDGE_MESSAGE_MARKER, BRIDGE_SOURCE, BRIDGE_TO_EXTENSION, BRIDGE_TO_PRODUCT } from './constants';
8
8
  import { shouldRelayToProduct } from './policy';
9
9
  import { deserializePayload, serializePayload } from './registry';
10
10
  import { createWindowTransport, isBridgeControlMessage } from './transport';
@@ -125,6 +125,24 @@ export var ExtensionContextBridgeClient = function ExtensionContextBridgeClient(
125
125
  });
126
126
  }, [activeTransport, publish]);
127
127
 
128
+ // Handshake: ask the product to re-send its current context.
129
+ //
130
+ // The chat only ever sees context published while it is listening, and it mounts long after the
131
+ // page — the user opens the side panel on a page that settled minutes ago. Products that publish
132
+ // once per navigation (Jira views) would otherwise never be observed at all. Asking, rather than
133
+ // having the extension retain context on the chance a panel opens later, keeps page data in the
134
+ // page until a chat actually exists to receive it.
135
+ useEffect(function () {
136
+ if (!activeTransport) {
137
+ return;
138
+ }
139
+ try {
140
+ activeTransport.send(_defineProperty(_defineProperty(_defineProperty({}, BRIDGE_MESSAGE_MARKER, true), "direction", BRIDGE_TO_PRODUCT), "control", BRIDGE_CONTROL_REQUEST_CONTEXT));
141
+ } catch (_unused2) {
142
+ // Never let bridging break the chat iframe.
143
+ }
144
+ }, [activeTransport]);
145
+
128
146
  // Outbound (WRITE, payloads): allowlisted chat actions -> product.
129
147
  useSubscribeAll(function (payload) {
130
148
  if (!activeTransport) {
@@ -143,7 +161,7 @@ export var ExtensionContextBridgeClient = function ExtensionContextBridgeClient(
143
161
  }
144
162
  try {
145
163
  activeTransport.send(_defineProperty(_defineProperty(_defineProperty({}, BRIDGE_MESSAGE_MARKER, true), "direction", BRIDGE_TO_PRODUCT), "payload", serialized));
146
- } catch (_unused2) {
164
+ } catch (_unused3) {
147
165
  // Never let bridging break the chat iframe.
148
166
  }
149
167
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/rovo-triggers",
3
- "version": "10.34.0",
3
+ "version": "10.35.0",
4
4
  "description": "Provides various trigger events to drive Rovo Chat functionality, such as a publish-subscribe and URL parameter hooks",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {