@iblai/web-utils 1.1.10 → 1.1.12
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/data-layer/src/features/retirement/api-slice.d.ts +165 -0
- package/dist/data-layer/src/features/retirement/constants.d.ts +7 -0
- package/dist/data-layer/src/features/retirement/types.d.ts +3 -0
- package/dist/data-layer/src/index.d.ts +3 -0
- package/dist/index.esm.js +76 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +76 -11
- package/dist/index.js.map +1 -1
- package/dist/package.json +8 -1
- package/package.json +8 -1
package/dist/index.js
CHANGED
|
@@ -6974,6 +6974,10 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
6974
6974
|
const ws = React.useRef(null);
|
|
6975
6975
|
const isConnected = React.useRef(false);
|
|
6976
6976
|
const messageQueue = React.useRef([]);
|
|
6977
|
+
// Keep sessionId in a ref so sendMessage always reads the latest value,
|
|
6978
|
+
// avoiding stale closures when Redux updates sessionIds between renders.
|
|
6979
|
+
const sessionIdRef = React.useRef(sessionId);
|
|
6980
|
+
sessionIdRef.current = sessionId;
|
|
6977
6981
|
const currentStreamingMessage = React.useRef({
|
|
6978
6982
|
id: null,
|
|
6979
6983
|
content: "",
|
|
@@ -7086,21 +7090,30 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
7086
7090
|
connectionAttempts.current >
|
|
7087
7091
|
MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS;
|
|
7088
7092
|
if (shouldShowError) {
|
|
7089
|
-
console.error(
|
|
7093
|
+
console.error("[ws-error] WebSocket connection error exceeded max attempts", {
|
|
7094
|
+
error,
|
|
7095
|
+
wsUrl,
|
|
7090
7096
|
tenant: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.tenant,
|
|
7091
7097
|
mentorId: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.name,
|
|
7092
7098
|
username: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.username,
|
|
7099
|
+
sessionId: sessionIdRef.current,
|
|
7100
|
+
isInitialConnection: isInitialConnection.current,
|
|
7093
7101
|
connectionAttempts: connectionAttempts.current,
|
|
7094
7102
|
maxAttempts: MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS,
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
})
|
|
7098
|
-
errorHandler === null || errorHandler === void 0 ? void 0 : errorHandler("Failed to connect to the mentor", error);
|
|
7103
|
+
readyState: socket.readyState,
|
|
7104
|
+
timestamp: new Date().toISOString(),
|
|
7105
|
+
});
|
|
7099
7106
|
onStatusChange("error");
|
|
7100
7107
|
reject(error);
|
|
7101
7108
|
}
|
|
7102
7109
|
else {
|
|
7103
|
-
console.warn(
|
|
7110
|
+
console.warn(`[ws-error] Initial connection attempt ${connectionAttempts.current}/${MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS} failed, will retry...`, {
|
|
7111
|
+
wsUrl,
|
|
7112
|
+
tenant: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.tenant,
|
|
7113
|
+
mentorId: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.name,
|
|
7114
|
+
readyState: socket.readyState,
|
|
7115
|
+
timestamp: new Date().toISOString(),
|
|
7116
|
+
});
|
|
7104
7117
|
}
|
|
7105
7118
|
onStreamingChange === null || onStreamingChange === void 0 ? void 0 : onStreamingChange(false);
|
|
7106
7119
|
});
|
|
@@ -7780,7 +7793,19 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
7780
7793
|
onStreamingChange === null || onStreamingChange === void 0 ? void 0 : onStreamingChange(false);
|
|
7781
7794
|
return;
|
|
7782
7795
|
}
|
|
7783
|
-
|
|
7796
|
+
console.error("[ws-error] WebSocket error on active connection", {
|
|
7797
|
+
error,
|
|
7798
|
+
wsUrl,
|
|
7799
|
+
tenant: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.tenant,
|
|
7800
|
+
mentorId: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.name,
|
|
7801
|
+
username: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.username,
|
|
7802
|
+
sessionId: sessionIdRef.current,
|
|
7803
|
+
isInitialConnection: isInitialConnection.current,
|
|
7804
|
+
connectionAttempts: connectionAttempts.current,
|
|
7805
|
+
readyState: socket.readyState,
|
|
7806
|
+
isConnected: isConnected.current,
|
|
7807
|
+
timestamp: new Date().toISOString(),
|
|
7808
|
+
});
|
|
7784
7809
|
onStreamingChange === null || onStreamingChange === void 0 ? void 0 : onStreamingChange(false);
|
|
7785
7810
|
onStatusChange("error");
|
|
7786
7811
|
});
|
|
@@ -7813,7 +7838,16 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
7813
7838
|
if (isInitialConnection.current &&
|
|
7814
7839
|
connectionAttempts.current >=
|
|
7815
7840
|
MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS) {
|
|
7816
|
-
|
|
7841
|
+
console.error("[ws-close] Failed to connect to the mentor after multiple attempts", {
|
|
7842
|
+
wsUrl,
|
|
7843
|
+
tenant: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.tenant,
|
|
7844
|
+
mentorId: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.name,
|
|
7845
|
+
username: flowConfig === null || flowConfig === void 0 ? void 0 : flowConfig.username,
|
|
7846
|
+
sessionId: sessionIdRef.current,
|
|
7847
|
+
connectionAttempts: connectionAttempts.current,
|
|
7848
|
+
maxAttempts: MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS,
|
|
7849
|
+
timestamp: new Date().toISOString(),
|
|
7850
|
+
});
|
|
7817
7851
|
onStatusChange("error");
|
|
7818
7852
|
isInitialConnection.current = false;
|
|
7819
7853
|
}
|
|
@@ -7914,9 +7948,19 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
7914
7948
|
onStatusChange("error");
|
|
7915
7949
|
return;
|
|
7916
7950
|
}
|
|
7951
|
+
// Guard against sending messages without a session ID.
|
|
7952
|
+
// This can happen due to race conditions (e.g., user sends before
|
|
7953
|
+
// createSessionId API returns, or stale closure after tab change).
|
|
7954
|
+
const currentSessionId = sessionIdRef.current;
|
|
7955
|
+
if (!currentSessionId) {
|
|
7956
|
+
console.warn("[sendMessage] No session ID available, cannot send message");
|
|
7957
|
+
onStatusChange("error");
|
|
7958
|
+
errorHandler === null || errorHandler === void 0 ? void 0 : errorHandler("Chat session not ready. Please try again.");
|
|
7959
|
+
return;
|
|
7960
|
+
}
|
|
7917
7961
|
let messageData = {
|
|
7918
7962
|
flow: flowConfig,
|
|
7919
|
-
session_id:
|
|
7963
|
+
session_id: currentSessionId,
|
|
7920
7964
|
token: wsToken,
|
|
7921
7965
|
prompt: text || "", // Allow empty prompt when sending files
|
|
7922
7966
|
};
|
|
@@ -7989,7 +8033,6 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
7989
8033
|
}
|
|
7990
8034
|
}, [
|
|
7991
8035
|
flowConfig,
|
|
7992
|
-
sessionId,
|
|
7993
8036
|
wsToken,
|
|
7994
8037
|
store,
|
|
7995
8038
|
triggerHapticFeedback,
|
|
@@ -13976,7 +14019,7 @@ const mentorApiSlice = createApi({
|
|
|
13976
14019
|
dispatch(mentorApiSlice.util.updateQueryData('getShareableLink', {
|
|
13977
14020
|
mentor: updateData.mentor,
|
|
13978
14021
|
org: updateData.org,
|
|
13979
|
-
// @ts-
|
|
14022
|
+
// @ts-expect-error userId may not be in the type
|
|
13980
14023
|
userId: updateData.userId,
|
|
13981
14024
|
}, (draft) => {
|
|
13982
14025
|
var _a;
|
|
@@ -17108,6 +17151,28 @@ createApi({
|
|
|
17108
17151
|
}),
|
|
17109
17152
|
});
|
|
17110
17153
|
|
|
17154
|
+
const RETIREMENT_ENDPOINTS = {
|
|
17155
|
+
SELF_RETIRE: {
|
|
17156
|
+
service: SERVICES.LMS,
|
|
17157
|
+
path: () => `/api/ibl/retirements/self_retire/`,
|
|
17158
|
+
},
|
|
17159
|
+
};
|
|
17160
|
+
|
|
17161
|
+
createApi({
|
|
17162
|
+
reducerPath: 'retirementApiSlice',
|
|
17163
|
+
baseQuery: iblFetchBaseQuery,
|
|
17164
|
+
endpoints: (builder) => ({
|
|
17165
|
+
selfRetire: builder.mutation({
|
|
17166
|
+
query: () => ({
|
|
17167
|
+
url: RETIREMENT_ENDPOINTS.SELF_RETIRE.path(),
|
|
17168
|
+
service: RETIREMENT_ENDPOINTS.SELF_RETIRE.service,
|
|
17169
|
+
method: 'POST',
|
|
17170
|
+
isJson: true,
|
|
17171
|
+
}),
|
|
17172
|
+
}),
|
|
17173
|
+
}),
|
|
17174
|
+
});
|
|
17175
|
+
|
|
17111
17176
|
const DISCLAIMERS_REDUCER_PATH = 'disclaimersApiSlice';
|
|
17112
17177
|
const DISCLAIMERS_ENDPOINTS = {
|
|
17113
17178
|
GET_DISCLAIMERS: {
|