@@ -18,6 +18,7 @@ import kotlinx.coroutines.launch
1818import kotlinx.coroutines.yield
1919import okhttp3.OkHttpClient
2020import java.net.HttpURLConnection
21+ import java.net.URI
2122import java.net.URL
2223
2324open class CoderProtocolHandler (
@@ -35,19 +36,19 @@ open class CoderProtocolHandler(
3536 * connectable state.
3637 */
3738 suspend fun handle (
38- parameters : Map < String , String > ,
39+ uri : URI ,
3940 onReinitialize : suspend (CoderRestClient , CoderCLIManager ) -> Unit
4041 ) {
41- val deploymentURL =
42- parameters.url() ? : dialogUi.ask(
43- context.i18n.ptrl(" Deployment URL" ),
44- context.i18n.ptrl(" Enter the full URL of your Coder deployment" )
45- )
42+ val params = uri.toQueryParameters()
43+
44+ val deploymentURL = params.url() ? : askUrl()
4645 if (deploymentURL.isNullOrBlank()) {
47- throw MissingArgumentException (" Query parameter \" $URL \" is missing" )
46+ context.logger.error(" Query parameter \" $URL \" is missing from URI $uri " )
47+ context.ui.showErrorInfoPopup(MissingArgumentException (" Can't handle URI because query parameter \" $URL \" is missing" ))
48+ return
4849 }
4950
50- val queryTokenRaw = parameters .token()
51+ val queryTokenRaw = params .token()
5152 val queryToken = if (! queryTokenRaw.isNullOrBlank()) {
5253 Pair (queryTokenRaw, Source .QUERY )
5354 } else {
@@ -61,7 +62,7 @@ open class CoderProtocolHandler(
6162
6263 // TODO: Show a dropdown and ask for the workspace if missing.
6364 val workspaceName =
64- parameters .workspace() ? : throw MissingArgumentException (" Query parameter \" $WORKSPACE \" is missing" )
65+ params .workspace() ? : throw MissingArgumentException (" Query parameter \" $WORKSPACE \" is missing" )
6566
6667 val workspaces = restClient.workspaces()
6768 val workspace =
@@ -99,7 +100,7 @@ open class CoderProtocolHandler(
99100 }
100101
101102 // TODO: Show a dropdown and ask for an agent if missing.
102- val agent = getMatchingAgent(parameters , workspace)
103+ val agent = getMatchingAgent(params , workspace)
103104 val status = WorkspaceAndAgentStatus .from(workspace, agent)
104105
105106 if (status.pending()) {
@@ -147,6 +148,15 @@ open class CoderProtocolHandler(
147148 }
148149 }
149150
151+ private suspend fun askUrl (): String? {
152+ context.ui.showWindow()
153+ context.envPageManager.showPluginEnvironmentsPage(false )
154+ return dialogUi.ask(
155+ context.i18n.ptrl(" Deployment URL" ),
156+ context.i18n.ptrl(" Enter the full URL of your Coder deployment" )
157+ )
158+ }
159+
150160 /* *
151161 * Return an authenticated Coder CLI, asking for the token as long as it
152162 * continues to result in an authentication failure and token authentication
0 commit comments