@asgard-js/react 0.0.42-canary.1 → 0.0.42-canary.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgard-js/react",
3
- "version": "0.0.42-canary.1",
3
+ "version": "0.0.42-canary.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -158,41 +158,64 @@ export const Chatbot = forwardRef(function Chatbot(
158
158
  }
159
159
  };
160
160
 
161
- return (
162
- <AsgardAppInitializationContextProvider
163
- enabled={enableLoadConfigFromService}
164
- config={config}
165
- asyncInitializers={asyncInitializers}
166
- loadingComponent={loadingComponent}
167
- >
168
- <AsgardThemeContextProvider theme={theme}>
169
- <AsgardServiceContextProvider
170
- parentRef={ref}
171
- avatar={avatar}
172
- config={config}
173
- customChannelId={customChannelId}
174
- initMessages={initMessages}
175
- onSseMessage={onSseMessage}
176
- onAuthError={onAuthError}
177
- botTypingPlaceholder={botTypingPlaceholder}
178
- inputPlaceholder={inputPlaceholder}
179
- >
180
- <ChatbotContainer
181
- fullScreen={fullScreen}
182
- className={className}
183
- style={style}
161
+ // Don't initialize SSE connection when explicitly needing API key or in error state
162
+ if (authState !== 'needApiKey' && authState !== 'error') {
163
+ return (
164
+ <AsgardAppInitializationContextProvider
165
+ enabled={enableLoadConfigFromService}
166
+ config={config}
167
+ asyncInitializers={asyncInitializers}
168
+ loadingComponent={loadingComponent}
169
+ >
170
+ <AsgardThemeContextProvider theme={theme}>
171
+ <AsgardServiceContextProvider
172
+ parentRef={ref}
173
+ avatar={avatar}
174
+ config={config}
175
+ customChannelId={customChannelId}
176
+ initMessages={initMessages}
177
+ onSseMessage={onSseMessage}
178
+ onAuthError={onAuthError}
179
+ botTypingPlaceholder={botTypingPlaceholder}
180
+ inputPlaceholder={inputPlaceholder}
184
181
  >
185
- <ChatbotHeader
186
- title={title}
187
- onReset={onReset}
188
- onClose={onClose}
189
- customActions={customActions}
190
- maintainConnectionWhenClosed={maintainConnectionWhenClosed}
191
- />
192
- {renderContent()}
193
- </ChatbotContainer>
194
- </AsgardServiceContextProvider>
195
- </AsgardThemeContextProvider>
196
- </AsgardAppInitializationContextProvider>
182
+ <ChatbotContainer
183
+ fullScreen={fullScreen}
184
+ className={className}
185
+ style={style}
186
+ >
187
+ <ChatbotHeader
188
+ title={title}
189
+ onReset={onReset}
190
+ onClose={onClose}
191
+ customActions={customActions}
192
+ maintainConnectionWhenClosed={maintainConnectionWhenClosed}
193
+ />
194
+ {renderContent()}
195
+ </ChatbotContainer>
196
+ </AsgardServiceContextProvider>
197
+ </AsgardThemeContextProvider>
198
+ </AsgardAppInitializationContextProvider>
199
+ );
200
+ }
201
+
202
+ // For non-authenticated states, render without AsgardServiceContextProvider
203
+ return (
204
+ <AsgardThemeContextProvider theme={theme}>
205
+ <ChatbotContainer
206
+ fullScreen={fullScreen}
207
+ className={className}
208
+ style={style}
209
+ >
210
+ <ChatbotHeader
211
+ title={title}
212
+ onReset={onReset}
213
+ onClose={onClose}
214
+ customActions={customActions}
215
+ maintainConnectionWhenClosed={maintainConnectionWhenClosed}
216
+ />
217
+ {renderContent()}
218
+ </ChatbotContainer>
219
+ </AsgardThemeContextProvider>
197
220
  );
198
221
  });