Skip to content

Commit eb0d42e

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(selectors): refresh workspace environment after copilot secrets
1 parent aeaa7ec commit eb0d42e

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/hooks/stream/handle-tool-event.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ describe('tool events (dispatch → model + side effects)', () => {
118118
{
119119
scope: 'personal',
120120
output: { scope: 'personal' },
121-
environmentQueryKey: environmentKeys.personal(),
121+
environmentQueryKeys: [environmentKeys.personal(), environmentKeys.workspaces()],
122122
},
123123
{
124124
scope: 'workspace',
125125
output: { scope: 'workspace', workspaceId: 'workspace-from-result' },
126-
environmentQueryKey: environmentKeys.workspace('workspace-from-result'),
126+
environmentQueryKeys: [environmentKeys.workspace('workspace-from-result')],
127127
},
128128
])(
129129
'refreshes the $scope environment before selector caches after Copilot saves secrets',
130-
async ({ output, environmentQueryKey }) => {
130+
async ({ output, environmentQueryKeys }) => {
131131
const deps = makeStreamLoopDeps()
132132
const invalidateQueries = vi.mocked(deps.queryClient.invalidateQueries)
133133
invalidateQueries.mockResolvedValue(undefined)
@@ -139,9 +139,11 @@ describe('tool events (dispatch → model + side effects)', () => {
139139
toolResult('environment-1', true, SetEnvironmentVariables.id, output)
140140
)
141141

142-
await vi.waitFor(() => expect(invalidateQueries).toHaveBeenCalledTimes(5))
142+
await vi.waitFor(() =>
143+
expect(invalidateQueries).toHaveBeenCalledTimes(environmentQueryKeys.length + 4)
144+
)
143145
expect(invalidateQueries.mock.calls.map(([filters]) => filters?.queryKey)).toEqual([
144-
environmentQueryKey,
146+
...environmentQueryKeys,
145147
environmentDependentSelectorKeys.primary,
146148
environmentDependentSelectorKeys.dynamicDetails,
147149
environmentDependentSelectorKeys.workflowDetails,

apps/sim/app/workspace/[workspaceId]/home/hooks/stream/handle-tool-event.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ function runToolResultSideEffects(ctx: StreamLoopContext, node: ToolNode): void
8484

8585
void (async () => {
8686
if (isPersonal) {
87-
await deps.queryClient.invalidateQueries({ queryKey: environmentKeys.personal() })
87+
await Promise.all([
88+
deps.queryClient.invalidateQueries({ queryKey: environmentKeys.personal() }),
89+
deps.queryClient.invalidateQueries({ queryKey: environmentKeys.workspaces() }),
90+
])
8891
} else {
8992
await deps.queryClient.invalidateQueries({
9093
queryKey: environmentKeys.workspace(workspaceId),

0 commit comments

Comments
 (0)