@comergehq/studio 0.1.33 → 0.1.34
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/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +30 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/studio/ComergeStudio.tsx +36 -6
package/dist/index.mjs
CHANGED
|
@@ -9929,6 +9929,7 @@ function ComergeStudio({
|
|
|
9929
9929
|
analyticsEnabled,
|
|
9930
9930
|
onNavigateHome,
|
|
9931
9931
|
onOpenAppRequested,
|
|
9932
|
+
onActiveAppChanged,
|
|
9932
9933
|
style,
|
|
9933
9934
|
showBubble = true,
|
|
9934
9935
|
enableAgentProgress = true,
|
|
@@ -9939,12 +9940,36 @@ function ComergeStudio({
|
|
|
9939
9940
|
const [activeAppId, setActiveAppId] = React51.useState(appId);
|
|
9940
9941
|
const [runtimeAppId, setRuntimeAppId] = React51.useState(appId);
|
|
9941
9942
|
const [pendingRuntimeTargetAppId, setPendingRuntimeTargetAppId] = React51.useState(null);
|
|
9943
|
+
const didSyncFromHostRef = React51.useRef(false);
|
|
9944
|
+
const lastNotifiedRef = React51.useRef(null);
|
|
9942
9945
|
const platform = React51.useMemo(() => RNPlatform.OS === "ios" ? "ios" : "android", []);
|
|
9946
|
+
const notifyActiveAppChanged = React51.useCallback(
|
|
9947
|
+
(nextAppId, source) => {
|
|
9948
|
+
if (!onActiveAppChanged) return;
|
|
9949
|
+
const trimmedAppId = nextAppId.trim();
|
|
9950
|
+
if (!trimmedAppId) return;
|
|
9951
|
+
const nextAppKey = (appKey == null ? void 0 : appKey.trim()) || "MicroMain";
|
|
9952
|
+
const dedupeKey = `${trimmedAppId}:${nextAppKey}`;
|
|
9953
|
+
if (lastNotifiedRef.current === dedupeKey) return;
|
|
9954
|
+
lastNotifiedRef.current = dedupeKey;
|
|
9955
|
+
onActiveAppChanged({ appId: trimmedAppId, appKey: nextAppKey, source });
|
|
9956
|
+
},
|
|
9957
|
+
[appKey, onActiveAppChanged]
|
|
9958
|
+
);
|
|
9959
|
+
const setActiveAppIdWithSource = React51.useCallback(
|
|
9960
|
+
(nextAppId, source) => {
|
|
9961
|
+
setActiveAppId(nextAppId);
|
|
9962
|
+
notifyActiveAppChanged(nextAppId, source);
|
|
9963
|
+
},
|
|
9964
|
+
[notifyActiveAppChanged]
|
|
9965
|
+
);
|
|
9943
9966
|
React51.useEffect(() => {
|
|
9944
|
-
|
|
9967
|
+
const source = didSyncFromHostRef.current ? "host_route_sync" : "initial";
|
|
9968
|
+
didSyncFromHostRef.current = true;
|
|
9969
|
+
setActiveAppIdWithSource(appId, source);
|
|
9945
9970
|
setRuntimeAppId(appId);
|
|
9946
9971
|
setPendingRuntimeTargetAppId(null);
|
|
9947
|
-
}, [appId]);
|
|
9972
|
+
}, [appId, setActiveAppIdWithSource]);
|
|
9948
9973
|
const captureTargetRef = React51.useRef(null);
|
|
9949
9974
|
return /* @__PURE__ */ jsx65(
|
|
9950
9975
|
StudioBootstrap,
|
|
@@ -9957,7 +9982,7 @@ function ComergeStudio({
|
|
|
9957
9982
|
{
|
|
9958
9983
|
userId,
|
|
9959
9984
|
activeAppId,
|
|
9960
|
-
setActiveAppId,
|
|
9985
|
+
setActiveAppId: setActiveAppIdWithSource,
|
|
9961
9986
|
runtimeAppId,
|
|
9962
9987
|
setRuntimeAppId,
|
|
9963
9988
|
pendingRuntimeTargetAppId,
|
|
@@ -10077,7 +10102,7 @@ function ComergeStudioInner({
|
|
|
10077
10102
|
userId,
|
|
10078
10103
|
app,
|
|
10079
10104
|
onForkedApp: (id, opts) => {
|
|
10080
|
-
setActiveAppId(id);
|
|
10105
|
+
setActiveAppId(id, "fork_edit");
|
|
10081
10106
|
const keepRenderingAppId = opts == null ? void 0 : opts.keepRenderingAppId;
|
|
10082
10107
|
if (keepRenderingAppId) {
|
|
10083
10108
|
setRuntimeAppId(keepRenderingAppId);
|
|
@@ -10222,7 +10247,7 @@ function ComergeStudioInner({
|
|
|
10222
10247
|
source: "related_apps_switcher"
|
|
10223
10248
|
});
|
|
10224
10249
|
} else {
|
|
10225
|
-
setActiveAppId(targetAppId);
|
|
10250
|
+
setActiveAppId(targetAppId, "related_apps");
|
|
10226
10251
|
setRuntimeAppId(targetAppId);
|
|
10227
10252
|
setPendingRuntimeTargetAppId(null);
|
|
10228
10253
|
}
|