Skip to content

An open-source, faster Devin alternative

TypeScript

Merge remote-tracking branch 'origin/feat/flue-managed-slack' into feat/repository-first-onboarding

Igor Zalutski4452aa34c983
diff --cc web/src/api/slack-schemas.test.ts
index 6a5543ce,8fd4dcc4..e7444f1c
--- a/web/src/api/slack-schemas.test.ts
+++ b/web/src/api/slack-schemas.test.ts
@@@ -44,29 -39,16 +44,42 @@@ describe('managed Slack response schema
).toThrow()
})
+ it('sends the exact deployment as structured OAuth return context', async () => {
+ let captured: RequestInit | undefined
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn((_input: string | URL | Request, init?: RequestInit) => {
+ captured = init
+ return Promise.resolve(
+ Response.json({
+ mode: 'managed',
+ status: 'pending',
+ authorize_url: 'https://slack.com/oauth/v2/authorize?state=opaque',
+ expires_at: '2026-07-16T18:10:00Z',
+ }),
+ )
+ }),
+ )
+
+ await authorizeManagedSlack('agt_example', 'dep_first')
+
+ expect(captured?.method).toBe('POST')
+ expect(captured?.body).toEqual(expect.any(String))
+ expect(JSON.parse(captured?.body as string)).toEqual({
+ return_deployment_id: 'dep_first',
+ })
+ })
++
+ it('accepts an idempotent active response from authorize', () => {
+ expect(
+ ManagedSlackAuthorizeResponseSchema.parse({
+ mode: 'managed',
+ status: 'active',
+ workspace: { id: 'T1', name: 'Acme' },
+ app: { id: 'A1', handle: 'OpenComputer' },
+ open_url: 'https://slack.com/app_redirect?app=A1&team=T1',
+ connected_at: '2026-07-16T18:10:00Z',
+ }),
+ ).toMatchObject({ mode: 'managed', status: 'active' })
+ })
})
diff --cc web/src/pages/AgentDeployment.tsx
index 94b33798,00c89efc..00f715f3
--- a/web/src/pages/AgentDeployment.tsx
+++ b/web/src/pages/AgentDeployment.tsx
@@@ -427,39 -387,6 +427,43 @@@ export default function AgentDeployment
void navigate(`/agents/${agentId}/deployments/${deployment.id}`)
},
})
+ const authorizeManagedSlackMutation = useMutation({
+ mutationFn: () => authorizeManagedSlack(agentId, deploymentId),
- onSuccess: ({ authorize_url }) => {
- window.location.assign(authorize_url)
++ onSuccess: (result) => {
++ if ('authorize_url' in result) {
++ window.location.assign(result.authorize_url)
++ return
++ }
++ queryClient.setQueryData(['slack', 'managed', agentId], result)
+ },
+ onError: (error) =>
+ notifyError("Couldn't start the Slack connection.", error),
+ })
+ const unlinkChangedSourceMutation = useMutation({
+ mutationFn: () => unlinkDeploymentSource(agentId),
+ onSuccess: () => {
+ const source = changedSourceQuery.data
+ void queryClient.invalidateQueries({
+ queryKey: ['agent-deploy-source', agentId],
+ })
+ void queryClient.invalidateQueries({ queryKey: ['agent', agentId] })
+ notifySuccess(
+ 'Repository source unlinked. Existing revisions are unchanged.',
+ )
+ if (source) {
+ void navigate('/agents/new', {
+ state: {
+ repositoryImport: {
+ repo: source.repo_id,
+ path: source.path,
+ productionRef: source.production_ref,
+ },
+ },
+ })
+ }
+ },
+ onError: (error) => notifyError("Couldn't unlink the repository.", error),
+ })
const terminal = deploymentQuery.data?.terminal ?? false
const refetchLogs = logsQuery.refetch