@@ -11,7 +11,7 @@ import { EyeIcon, type LucideIcon } from "lucide-react";
1111import type * as Context from "effect/Context" ;
1212import * as Effect from "effect/Effect" ;
1313import * as Schema from "effect/Schema" ;
14- import { type ReactNode , useCallback , useEffect , useState } from "react" ;
14+ import { type ReactNode , useEffect , useState } from "react" ;
1515
1616import { PrimaryEnvironmentHttpClient } from "~/environments/primary/httpClient" ;
1717import { runPrimaryHttp } from "~/lib/runtime" ;
@@ -116,30 +116,27 @@ export function ConnectAgentSurface() {
116116 } ;
117117 } , [ authorization ] ) ;
118118
119- const decide = useCallback (
120- async ( choice : "approve" | "deny" ) => {
121- if ( loaded . status !== "ready" ) return ;
122- setPending ( choice ) ;
123- setErrorMessage ( "" ) ;
124- const { csrfToken } = loaded . details ;
125- const decision : AuthMcpApprovalDecision =
126- choice === "deny"
127- ? { _tag : "deny" }
128- : csrfToken !== undefined && oneClickApproves ( loaded . details , access )
129- ? { _tag : "browser-session" , access, csrfToken }
130- : { _tag : "pairing-code" , access, code : pairingCode . trim ( ) } ;
131- const answer = await runApproval ( ( client ) =>
132- client . mcpOAuth . decision ( { payload : { authorization, decision } } ) ,
133- ) ;
134- if ( answer . kind === "redirect" ) {
135- window . location . replace ( answer . url ) ;
136- return ;
137- }
138- setPending ( null ) ;
139- setErrorMessage ( answer . kind === "error" ? answer . message : "The sign-in could not continue." ) ;
140- } ,
141- [ access , authorization , loaded , pairingCode ] ,
142- ) ;
119+ const decide = async ( choice : "approve" | "deny" ) => {
120+ if ( loaded . status !== "ready" ) return ;
121+ setPending ( choice ) ;
122+ setErrorMessage ( "" ) ;
123+ const { csrfToken } = loaded . details ;
124+ const decision : AuthMcpApprovalDecision =
125+ choice === "deny"
126+ ? { _tag : "deny" }
127+ : csrfToken !== undefined && oneClickApproves ( loaded . details , access )
128+ ? { _tag : "browser-session" , access, csrfToken }
129+ : { _tag : "pairing-code" , access, code : pairingCode . trim ( ) } ;
130+ const answer = await runApproval ( ( client ) =>
131+ client . mcpOAuth . decision ( { payload : { authorization, decision } } ) ,
132+ ) ;
133+ if ( answer . kind === "redirect" ) {
134+ window . location . replace ( answer . url ) ;
135+ return ;
136+ }
137+ setPending ( null ) ;
138+ setErrorMessage ( answer . kind === "error" ? answer . message : "The sign-in could not continue." ) ;
139+ } ;
143140
144141 if ( loaded . status === "loading" ) {
145142 return (
0 commit comments