Skip to content

Commit 0e0dc51

Browse files
committed
Fix context hydration race condition when ingesting expert context from the website
1 parent 860968b commit 0e0dc51

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

frontend/src/store/modules/product/expert/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ const actions = {
243243
}
244244
},
245245

246-
hydrateClient ({
246+
async hydrateClient ({
247247
dispatch,
248248
state,
249249
rootGetters
@@ -255,10 +255,19 @@ const actions = {
255255
return Promise.resolve()
256256
}
257257

258+
// todo this need to be removed when we have https://github.com/FlowFuse/flowfuse/issues/6520 part of
259+
// https://github.com/FlowFuse/flowfuse/issues/6519 as it's a hacky workaround to the expert drawer opening up
260+
// before we have a team loaded
261+
while (!rootGetters['account/team']) {
262+
await new Promise(resolve => setTimeout(resolve, 1000))
263+
}
264+
258265
return expertApi
259266
.chat({
260267
history: state[state.agentMode].context,
261-
context: {},
268+
context: {
269+
teamId: rootGetters['account/team'].id
270+
},
262271
sessionId: state[state.agentMode].sessionId
263272
})
264273
.then((response) => {

frontend/src/store/modules/product/expert/operator-agent/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ const actions = {
5555
commit('SET_SELECTED_CAPABILITIES', selectedCapabilities)
5656
},
5757
async getCapabilities ({ commit, rootGetters, state }) {
58+
// todo this need to be removed when we have https://github.com/FlowFuse/flowfuse/issues/6520 part of
59+
// https://github.com/FlowFuse/flowfuse/issues/6519 as it's a hacky workaround to the expert drawer opening up
60+
// before we have a team loaded
61+
while (!rootGetters['account/team']) {
62+
await new Promise(resolve => setTimeout(resolve, 1000))
63+
}
64+
5865
const payload = {
5966
context: {
6067
teamId: rootGetters['account/team'].id

0 commit comments

Comments
 (0)