@@ -225,41 +225,37 @@ export function MCP({ initialServerId }: MCPProps) {
225225 > ( { } )
226226 const [ expandedTools , setExpandedTools ] = useState < Set < string > > ( ( ) => new Set ( ) )
227227
228- const startOauthForServer = useCallback (
229- async ( serverId : string ) => {
230- setConnectingOauthServers ( ( prev ) => new Set ( prev ) . add ( serverId ) )
231- const clear = ( ) => {
232- const existing = oauthPopupIntervalsRef . current . get ( serverId )
233- if ( existing !== undefined ) {
234- window . clearInterval ( existing )
235- oauthPopupIntervalsRef . current . delete ( serverId )
236- }
237- setConnectingOauthServers ( ( prev ) => {
238- const next = new Set ( prev )
239- next . delete ( serverId )
240- return next
241- } )
228+ const startOauthForServer = async ( serverId : string ) => {
229+ setConnectingOauthServers ( ( prev ) => new Set ( prev ) . add ( serverId ) )
230+ const clear = ( ) => {
231+ const existing = oauthPopupIntervalsRef . current . get ( serverId )
232+ if ( existing !== undefined ) {
233+ window . clearInterval ( existing )
234+ oauthPopupIntervalsRef . current . delete ( serverId )
242235 }
243- try {
244- const result = await startOauthMutation . mutateAsync ( { serverId, workspaceId } )
245- if ( result . status === 'already_authorized' ) {
246- clear ( )
247- return
248- }
249- const { popup } = result
250- const interval = window . setInterval ( ( ) => {
251- if ( popup . closed ) clear ( )
252- } , 500 )
253- oauthPopupIntervalsRef . current . set ( serverId , interval )
254- } catch ( e ) {
236+ setConnectingOauthServers ( ( prev ) => {
237+ const next = new Set ( prev )
238+ next . delete ( serverId )
239+ return next
240+ } )
241+ }
242+ try {
243+ const result = await startOauthMutation . mutateAsync ( { serverId, workspaceId } )
244+ if ( result . status === 'already_authorized' ) {
255245 clear ( )
256- logger . error ( 'Failed to start MCP OAuth' , e )
257- toast . error ( toError ( e ) . message || 'Failed to start authorization' )
246+ return
258247 }
259- } ,
260- // eslint-disable-next-line react-hooks/exhaustive-deps -- mutateAsync is stable
261- [ workspaceId ]
262- )
248+ const { popup } = result
249+ const interval = window . setInterval ( ( ) => {
250+ if ( popup . closed ) clear ( )
251+ } , 500 )
252+ oauthPopupIntervalsRef . current . set ( serverId , interval )
253+ } catch ( e ) {
254+ clear ( )
255+ logger . error ( 'Failed to start MCP OAuth' , e )
256+ toast . error ( toError ( e ) . message || 'Failed to start authorization' )
257+ }
258+ }
263259
264260 const handleRemoveServer = useCallback ( ( serverId : string , serverName : string ) => {
265261 setServerToDelete ( { id : serverId , name : serverName } )
0 commit comments