From 46b611f70f6cb21652d7066986e8703c3c032462 Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Thu, 10 Apr 2025 21:53:07 +0300 Subject: [PATCH 01/10] chore: changelog sections got messed up by the merge algorithm --- CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3db69cb..a1d68b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,15 +5,12 @@ ### Fixed - SSH connection to a Workspace is no longer established only once +- authorization wizard automatically goes to a previous screen when an error is encountered during connection to Coder deployment ### Changed - action buttons on the token input step were swapped to achieve better keyboard navigation -### Fixed - -- authorization wizard automatically goes to a previous screen when an error is encountered during connection to Coder deployment - ## 0.1.3 - 2025-04-09 ### Fixed From e6ff89bcf05d8265cf7d868e5af11216ae77fc92 Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Thu, 10 Apr 2025 21:53:57 +0300 Subject: [PATCH 02/10] chore: next version is 0.1.4 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index d69a4d7..438b864 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ -version=0.1.3 +version=0.1.4 group=com.coder.toolbox name=coder-toolbox From a6ce4fbac9a2a47e42dc577e314ef0f193b9dcd9 Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Fri, 11 Apr 2025 00:06:40 +0300 Subject: [PATCH 03/10] doc: initial guide to the plugin The following topics are covered: - documentation on how to install the plugin - URI handling documentation - release procedure - resolves #64 P.S: Some of the topics were copied without shame from the old Coder Gateway plugin. --- README.md | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 103 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6823fae..47a8af1 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,107 @@ -# Toolbox Gateway plugin sample +# Coder Toolbox plugin -To load plugin into the provided Toolbox App, run `./gradlew build copyPlugin` +[!["Join us onDiscord"](https://img.shields.io/badge/join-us%20on%20Discord-gray.svg?longCache=true&logo=discord&colorB=purple)](https://discord.gg/coder) +[![Twitter Follow](https://img.shields.io/twitter/follow/CoderHQ?label=%40CoderHQ&style=social)](https://twitter.com/coderhq) +[![Coder Toolbox Plugin Build](https://github.com/coder/coder-jetbrains-toolbox/actions/workflows/build.yml/badge.svg)](https://github.com/coder/coder-jetbrains-toolbox/actions/workflows/build.yml) -or put files in the following directory: +Connects your JetBrains IDE to Coder workspaces -* Windows: `%LocalAppData%/JetBrains/Toolbox/cache/plugins/plugin-id` -* macOS: `~/Library/Caches/JetBrains/Toolbox/plugins/plugin-id` -* Linux: `~/.local/share/JetBrains/Toolbox/plugins/plugin-id` +## Getting Started -Put all required .jar files (do not include any dependencies already included with the Toolbox App to avoid possible resolution conflicts), -`extensions.json` and `icon.svg` in this directory. +To install this plugin using JetBrains Toolbox, follow the steps below. + +1. Install [JetBrains Toolbox](https://www.jetbrains.com/toolbox-app/). Make sure it's the `2.6.0.40284` release or + above. +2. Launch the Toolbox app and sign in with your JetBrains account (if needed). + +### Install Coder plugin via URI + +You can quickly install the plugin using this JetBrains hyperlink. + +👉 [Install plugin](jetbrains://gateway/com.coder.toolbox) + +This will open JetBrains Toolbox and prompt you to install the Coder Toolbox plugin automatically. + +Alternatively, you can paste `jetbrains://gateway/com.coder.toolbox` into a browser. + +### Manual install + +There are two ways Coder Toolbox plugin can be installed. The first option is to manually download the plugin +artifact from [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/26968-coder/versions) +or from [Coder's Github Release page](https://github.com/coder/coder-jetbrains-toolbox/releases). + +The next step is to copy the zip content to one of the following locations, depending on your OS: + +* Windows: `%LocalAppData%/JetBrains/Toolbox/cache/plugins/com.coder.toolbox` +* macOS: `~/Library/Caches/JetBrains/Toolbox/plugins/com.coder.toolbox` +* Linux: `~/.local/share/JetBrains/Toolbox/plugins/com.coder.toolbox` + +Alternatively, you can install it using the _Gradle_ tasks included in the project: + +```shell + +./gradlew cleanAll build copyPlugin +``` + +Make sure Toolbox is closed before running the command. + +## Connect to a Coder Workspace via JetBrains Toolbox URI + +You can use specially crafted JetBrains Gateway URIs to automatically: + +1. Open Toolbox + +2. Install the Coder Toolbox plugin (if not already installed) + +3. Connect to a specific Coder deployment using a URL and a token. + +4. Select a running workspace + +5. Install a specified JetBrains IDE on that Workspace + +6. Open a project folder directly in the remote IDE + +### Example URIs + +```text +jetbrains://gateway/com.coder.toolbox?url=https%3A%2F%2Fdev.coder.com&token=abaC5SbSpP-J2qGpajkdreR9jBdcekXS2&workspace=bobiverse-bob&ide_product_code=GO&ide_build_number=241.23774.119&folder=%2Fhome%2Fcoder%2Fworkspace%2Fhello-world-rs + +jetbrains://gateway/com.coder.toolbox?url=https%3A%2F%2Fj5gj2r1so5nbi.pit-1.try.coder.app%2F&token=gqEirOoI1U-FfCQ6uj8iOLtybBIk99rr8&workspace=bobiverse-bill&ide_product_code=RR&ide_build_number=243.26053.17&folder=%2Fhome%2Fcoder%2Fworkspace%2Fhello-world-rs +``` + +### URI Breakdown + +```text +jetbrains://gateway/com.coder.toolbox + ?url=http(s):// + &token= + &workspace= + &ide_product_code= + &ide_build_number= + &folder= +``` + +| Query param | Description | Mandatory | +|------------------|--------------------------------------------------------------------------------|-----------| +| url | Your Coder deployment URL (encoded) | Yes | +| token | Coder authentication token | Yes | +| workspace | Name of the Coder workspace to connect to. Agent name should not be included. | Yes | +| ide_product_code | JetBrains IDE product code (e.g., GO for GoLand, RR for Rider) | No | +| ide_build_number | Specific build number of the JetBrains IDE to install on the workspace | No | +| folder | Absolute path to the project folder to open in the remote IDE (URL-encoded) | No | + +If `ide_product_code` and `ide_build_number` is missing, Toolbox will only open and highlight the workspace environment +page. +Coder Toolbox will attempt to start the workspace if it’s not already running; however, for the most reliable +experience, it’s recommended to ensure the workspace is running prior to initiating the connection. + +If the agent is down, or we can't resolve an agent for the workspace. + +## Releasing + +1. Check that the changelog lists all the important changes. +2. Update the gradle.properties version. +3. Publish the resulting draft release after validating it. +4. Merge the resulting changelog PR. + +## `main` vs `eap` branch \ No newline at end of file From d1ebe43840286a40809da3e45d3992833ead37f9 Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Fri, 11 Apr 2025 00:09:10 +0300 Subject: [PATCH 04/10] fix: improve error reporting when an agent can't be resolved - uri handling tries to automatically resolve a workspace agent. - right now an exception is raised if the agent is missing or there are multiple agents for a workspace. - instead we provide a nice human-readable error notification --- .../coder/toolbox/util/CoderProtocolHandler.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt b/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt index c8b8e51..b027c97 100644 --- a/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt +++ b/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt @@ -123,7 +123,19 @@ open class CoderProtocolHandler( } // TODO: Show a dropdown and ask for an agent if missing. - val agent = getMatchingAgent(params, workspace) + val agent: WorkspaceAgent + try { + agent = getMatchingAgent(params, workspace) + } catch (e: IllegalArgumentException) { + context.logger.error(e, "Can't resolve an agent for workspace $workspaceName from $deploymentURL") + context.showErrorPopup( + MissingArgumentException( + "Can't handle URI because we can't resolve an agent for workspace $workspaceName from $deploymentURL", + e + ) + ) + return + } val status = WorkspaceAndAgentStatus.from(workspace, agent) if (!status.ready()) { @@ -265,7 +277,7 @@ internal fun resolveRedirects(url: URL): URL { * The name is ignored if the ID is set. If neither was supplied and the * workspace has only one agent, return that. Otherwise throw an error. * - * @throws [MissingArgumentException, IllegalArgumentException] + * @throws [IllegalArgumentException] */ internal fun getMatchingAgent( parameters: Map, From 88f4cb06be585a653a53068e7cab3ebb6d45d55b Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Fri, 11 Apr 2025 00:26:07 +0300 Subject: [PATCH 05/10] doc: fix misleading documentation around agents --- README.md | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 47a8af1..259c7af 100644 --- a/README.md +++ b/README.md @@ -64,9 +64,9 @@ You can use specially crafted JetBrains Gateway URIs to automatically: ### Example URIs ```text -jetbrains://gateway/com.coder.toolbox?url=https%3A%2F%2Fdev.coder.com&token=abaC5SbSpP-J2qGpajkdreR9jBdcekXS2&workspace=bobiverse-bob&ide_product_code=GO&ide_build_number=241.23774.119&folder=%2Fhome%2Fcoder%2Fworkspace%2Fhello-world-rs +jetbrains://gateway/com.coder.toolbox?url=https%3A%2F%2Fdev.coder.com&token=zeoX4SbSpP-j2qGpajkdwxR9jBdcekXS2&workspace=bobiverse-bob&agent=dev&ide_product_code=GO&ide_build_number=241.23774.119&folder=%2Fhome%2Fcoder%2Fworkspace%2Fhello-world-rs -jetbrains://gateway/com.coder.toolbox?url=https%3A%2F%2Fj5gj2r1so5nbi.pit-1.try.coder.app%2F&token=gqEirOoI1U-FfCQ6uj8iOLtybBIk99rr8&workspace=bobiverse-bill&ide_product_code=RR&ide_build_number=243.26053.17&folder=%2Fhome%2Fcoder%2Fworkspace%2Fhello-world-rs +jetbrains://gateway/com.coder.toolbox?url=https%3A%2F%2Fj5gj2r1so5nbi.pit-1.try.coder.app%2F&token=gqEirOoI1U-FfCQ6uj8iOLtybBIk99rr8&workspace=bobiverse-riker&agent=dev&ide_product_code=RR&ide_build_number=243.26053.17&folder=%2Fhome%2Fcoder%2Fworkspace%2Fhello-world-rs ``` ### URI Breakdown @@ -76,32 +76,35 @@ jetbrains://gateway/com.coder.toolbox ?url=http(s):// &token= &workspace= + &agent/agent_id= &ide_product_code= &ide_build_number= &folder= ``` -| Query param | Description | Mandatory | -|------------------|--------------------------------------------------------------------------------|-----------| -| url | Your Coder deployment URL (encoded) | Yes | -| token | Coder authentication token | Yes | -| workspace | Name of the Coder workspace to connect to. Agent name should not be included. | Yes | -| ide_product_code | JetBrains IDE product code (e.g., GO for GoLand, RR for Rider) | No | -| ide_build_number | Specific build number of the JetBrains IDE to install on the workspace | No | -| folder | Absolute path to the project folder to open in the remote IDE (URL-encoded) | No | +| Query param | Description | Mandatory | +|------------------|------------------------------------------------------------------------------|-----------| +| url | Your Coder deployment URL (encoded) | Yes | +| token | Coder authentication token | Yes | +| workspace | Name of the Coder workspace to connect to. | Yes | +| agent | Name of the agent associated with the workspace | No | +| agent_id | ID of the agent associated with the workspace | No | +| ide_product_code | JetBrains IDE product code (e.g., GO for GoLand, RR for Rider) | No | +| ide_build_number | Specific build number of the JetBrains IDE to install on the workspace | No | +| folder | Absolute path to the project folder to open in the remote IDE (URL-encoded) | No | + +If only a single agent is available, specifying an agent name or ID is optional. However, if multiple agents exist, +you must provide either the name or ID to target a specific one. Note that this version of the Coder Toolbox plugin +does not automatically start agents if they are offline, so please ensure the selected agent is running before +proceeding. If `ide_product_code` and `ide_build_number` is missing, Toolbox will only open and highlight the workspace environment -page. -Coder Toolbox will attempt to start the workspace if it’s not already running; however, for the most reliable +page. Coder Toolbox will attempt to start the workspace if it’s not already running; however, for the most reliable experience, it’s recommended to ensure the workspace is running prior to initiating the connection. -If the agent is down, or we can't resolve an agent for the workspace. - ## Releasing 1. Check that the changelog lists all the important changes. 2. Update the gradle.properties version. 3. Publish the resulting draft release after validating it. -4. Merge the resulting changelog PR. - -## `main` vs `eap` branch \ No newline at end of file +4. Merge the resulting changelog PR. \ No newline at end of file From 4bcf3d223b764d738a65bc22040939b2aa8b0f1f Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Fri, 11 Apr 2025 00:29:24 +0300 Subject: [PATCH 06/10] impl: rename `project_path` query param to `folder` --- CHANGELOG.md | 1 + .../com/coder/toolbox/util/CoderProtocolHandler.kt | 6 +++--- src/main/kotlin/com/coder/toolbox/util/LinkMap.kt | 11 ++--------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1d68b3..acf8504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Changed - action buttons on the token input step were swapped to achieve better keyboard navigation +- URI `project_path` query parameter was renamed to `folder` ## 0.1.3 - 2025-04-09 diff --git a/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt b/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt index b027c97..7ed4ef6 100644 --- a/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt +++ b/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt @@ -169,7 +169,7 @@ open class CoderProtocolHandler( context.envPageManager.showEnvironmentPage(environmentId, false) val productCode = params.ideProductCode() val buildNumber = params.ideBuildNumber() - val projectPath = params.projectPath() + val projectFolder = params.projectFolder() if (!productCode.isNullOrBlank() && !buildNumber.isNullOrBlank()) { context.cs.launch { val ideVersion = "$productCode-$buildNumber" @@ -179,7 +179,7 @@ open class CoderProtocolHandler( } job.join() context.logger.info("launching $ideVersion on $environmentId") - context.ideOrchestrator.connectToIde(environmentId, ideVersion, projectPath) + context.ideOrchestrator.connectToIde(environmentId, ideVersion, projectFolder) } } } @@ -275,7 +275,7 @@ internal fun resolveRedirects(url: URL): URL { /** * Return the agent matching the provided agent ID or name in the parameters. * The name is ignored if the ID is set. If neither was supplied and the - * workspace has only one agent, return that. Otherwise throw an error. + * workspace has only one agent, return that. Otherwise, throw an error. * * @throws [IllegalArgumentException] */ diff --git a/src/main/kotlin/com/coder/toolbox/util/LinkMap.kt b/src/main/kotlin/com/coder/toolbox/util/LinkMap.kt index 9e2ef49..8e275f7 100644 --- a/src/main/kotlin/com/coder/toolbox/util/LinkMap.kt +++ b/src/main/kotlin/com/coder/toolbox/util/LinkMap.kt @@ -1,7 +1,5 @@ package com.coder.toolbox.util -// These are keys that we support in our Gateway links and must not be changed. -private const val TYPE = "type" const val URL = "url" const val TOKEN = "token" const val WORKSPACE = "workspace" @@ -9,12 +7,7 @@ const val AGENT_NAME = "agent" const val AGENT_ID = "agent_id" private const val IDE_PRODUCT_CODE = "ide_product_code" private const val IDE_BUILD_NUMBER = "ide_build_number" -private const val PROJECT_PATH = "project_path" - -// Helper functions for reading from the map. Prefer these to directly -// interacting with the map. - -fun Map.isCoder(): Boolean = this[TYPE] == "coder" +private const val FOLDER = "folder" fun Map.url() = this[URL] @@ -30,4 +23,4 @@ fun Map.ideProductCode() = this[IDE_PRODUCT_CODE] fun Map.ideBuildNumber() = this[IDE_BUILD_NUMBER] -fun Map.projectPath() = this[PROJECT_PATH] +fun Map.projectFolder() = this[FOLDER] From 1be61f10c156ac2069063eab51f2295a3651996d Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Fri, 11 Apr 2025 00:38:21 +0300 Subject: [PATCH 07/10] fix: plugin install uri - the existing uri handling asks for url, workspace name and so on each time a coder toolbox URI is executed. - however there are cases where users simply want to install the plugin via jetbrains://gatway/com.coder.toolbox - in that case there is no point to ask for the coder deployment details. --- .../kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt b/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt index 7ed4ef6..a0f030c 100644 --- a/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt +++ b/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt @@ -43,6 +43,10 @@ open class CoderProtocolHandler( reInitialize: suspend (CoderRestClient, CoderCLIManager) -> Unit ) { val params = uri.toQueryParameters() + if (params.isEmpty()) { + // probably a plugin installation scenario + return + } val deploymentURL = params.url() ?: askUrl() if (deploymentURL.isNullOrBlank()) { From b6570ee0250b7579763089a9cf8d247bca9a4d7b Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Fri, 11 Apr 2025 01:20:33 +0300 Subject: [PATCH 08/10] fix: drop support for agent name --- README.md | 7 ++- .../toolbox/util/CoderProtocolHandler.kt | 10 +---- .../kotlin/com/coder/toolbox/util/LinkMap.kt | 2 - .../com/coder/toolbox/util/LinkHandlerTest.kt | 45 +++++++++++-------- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 259c7af..ded75c8 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ jetbrains://gateway/com.coder.toolbox ?url=http(s):// &token= &workspace= - &agent/agent_id= + &agent_id= &ide_product_code= &ide_build_number= &folder= @@ -87,14 +87,13 @@ jetbrains://gateway/com.coder.toolbox | url | Your Coder deployment URL (encoded) | Yes | | token | Coder authentication token | Yes | | workspace | Name of the Coder workspace to connect to. | Yes | -| agent | Name of the agent associated with the workspace | No | | agent_id | ID of the agent associated with the workspace | No | | ide_product_code | JetBrains IDE product code (e.g., GO for GoLand, RR for Rider) | No | | ide_build_number | Specific build number of the JetBrains IDE to install on the workspace | No | | folder | Absolute path to the project folder to open in the remote IDE (URL-encoded) | No | -If only a single agent is available, specifying an agent name or ID is optional. However, if multiple agents exist, -you must provide either the name or ID to target a specific one. Note that this version of the Coder Toolbox plugin +If only a single agent is available, specifying an agent ID is optional. However, if multiple agents exist, +you must provide either the ID to target a specific one. Note that this version of the Coder Toolbox plugin does not automatically start agents if they are offline, so please ensure the selected agent is running before proceeding. diff --git a/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt b/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt index a0f030c..90bfa6b 100644 --- a/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt +++ b/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt @@ -278,8 +278,6 @@ internal fun resolveRedirects(url: URL): URL { /** * Return the agent matching the provided agent ID or name in the parameters. - * The name is ignored if the ID is set. If neither was supplied and the - * workspace has only one agent, return that. Otherwise, throw an error. * * @throws [IllegalArgumentException] */ @@ -297,8 +295,6 @@ internal fun getMatchingAgent( val agent = if (!parameters.agentID().isNullOrBlank()) { agents.firstOrNull { it.id.toString() == parameters.agentID() } - } else if (!parameters.agentName().isNullOrBlank()) { - agents.firstOrNull { it.name == parameters.agentName() } } else if (agents.size == 1) { agents.first() } else { @@ -308,13 +304,9 @@ internal fun getMatchingAgent( if (agent == null) { if (!parameters.agentID().isNullOrBlank()) { throw IllegalArgumentException("The workspace \"${workspace.name}\" does not have an agent with ID \"${parameters.agentID()}\"") - } else if (!parameters.agentName().isNullOrBlank()) { - throw IllegalArgumentException( - "The workspace \"${workspace.name}\"does not have an agent named \"${parameters.agentName()}\"", - ) } else { throw MissingArgumentException( - "Unable to determine which agent to connect to; one of \"$AGENT_NAME\" or \"$AGENT_ID\" must be set because the workspace \"${workspace.name}\" has more than one agent", + "Unable to determine which agent to connect to; \"$AGENT_ID\" must be set because the workspace \"${workspace.name}\" has more than one agent", ) } } diff --git a/src/main/kotlin/com/coder/toolbox/util/LinkMap.kt b/src/main/kotlin/com/coder/toolbox/util/LinkMap.kt index 8e275f7..1135227 100644 --- a/src/main/kotlin/com/coder/toolbox/util/LinkMap.kt +++ b/src/main/kotlin/com/coder/toolbox/util/LinkMap.kt @@ -15,8 +15,6 @@ fun Map.token() = this[TOKEN] fun Map.workspace() = this[WORKSPACE] -fun Map.agentName() = this[AGENT_NAME] - fun Map.agentID() = this[AGENT_ID] fun Map.ideProductCode() = this[IDE_PRODUCT_CODE] diff --git a/src/test/kotlin/com/coder/toolbox/util/LinkHandlerTest.kt b/src/test/kotlin/com/coder/toolbox/util/LinkHandlerTest.kt index 61ecc65..bb87151 100644 --- a/src/test/kotlin/com/coder/toolbox/util/LinkHandlerTest.kt +++ b/src/test/kotlin/com/coder/toolbox/util/LinkHandlerTest.kt @@ -54,16 +54,21 @@ internal class LinkHandlerTest { val tests = listOf( - Pair(mapOf("agent" to "agent_name"), "9a920eee-47fb-4571-9501-e4b3120c12f2"), - Pair(mapOf("agent_id" to "9a920eee-47fb-4571-9501-e4b3120c12f2"), "9a920eee-47fb-4571-9501-e4b3120c12f2"), - Pair(mapOf("agent" to "agent_name_2"), "fb3daea4-da6b-424d-84c7-36b90574cfef"), - Pair(mapOf("agent_id" to "fb3daea4-da6b-424d-84c7-36b90574cfef"), "fb3daea4-da6b-424d-84c7-36b90574cfef"), - Pair(mapOf("agent" to "agent_name_3"), "b0e4c54d-9ba9-4413-8512-11ca1e826a24"), - Pair(mapOf("agent_id" to "b0e4c54d-9ba9-4413-8512-11ca1e826a24"), "b0e4c54d-9ba9-4413-8512-11ca1e826a24"), + Pair( + mapOf("agent_id" to "9a920eee-47fb-4571-9501-e4b3120c12f2"), + "9a920eee-47fb-4571-9501-e4b3120c12f2" + ), + Pair( + mapOf("agent_id" to "fb3daea4-da6b-424d-84c7-36b90574cfef"), + "fb3daea4-da6b-424d-84c7-36b90574cfef" + ), + Pair( + mapOf("agent_id" to "b0e4c54d-9ba9-4413-8512-11ca1e826a24"), + "b0e4c54d-9ba9-4413-8512-11ca1e826a24" + ), // Prefer agent_id. Pair( mapOf( - "agent" to "agent_name", "agent_id" to "b0e4c54d-9ba9-4413-8512-11ca1e826a24", ), "b0e4c54d-9ba9-4413-8512-11ca1e826a24", @@ -81,15 +86,14 @@ internal class LinkHandlerTest { val tests = listOf( Triple(emptyMap(), MissingArgumentException::class, "Unable to determine"), - Triple(mapOf("agent" to ""), MissingArgumentException::class, "Unable to determine"), Triple(mapOf("agent_id" to ""), MissingArgumentException::class, "Unable to determine"), - Triple(mapOf("agent" to null), MissingArgumentException::class, "Unable to determine"), Triple(mapOf("agent_id" to null), MissingArgumentException::class, "Unable to determine"), - Triple(mapOf("agent" to "ws"), IllegalArgumentException::class, "agent named"), - Triple(mapOf("agent" to "ws.agent_name"), IllegalArgumentException::class, "agent named"), - Triple(mapOf("agent" to "agent_name_4"), IllegalArgumentException::class, "agent named"), Triple(mapOf("agent_id" to "not-a-uuid"), IllegalArgumentException::class, "agent with ID"), - Triple(mapOf("agent_id" to "ceaa7bcf-1612-45d7-b484-2e0da9349168"), IllegalArgumentException::class, "agent with ID"), + Triple( + mapOf("agent_id" to "ceaa7bcf-1612-45d7-b484-2e0da9349168"), + IllegalArgumentException::class, + "agent with ID" + ), // Will ignore agent if agent_id is set even if agent matches. Triple( mapOf( @@ -139,10 +143,11 @@ internal class LinkHandlerTest { val ws = DataGen.workspace("ws", agents = oneAgent) val tests = listOf( - Triple(mapOf("agent" to "ws"), IllegalArgumentException::class, "agent named"), - Triple(mapOf("agent" to "ws.agent_name_3"), IllegalArgumentException::class, "agent named"), - Triple(mapOf("agent" to "agent_name_4"), IllegalArgumentException::class, "agent named"), - Triple(mapOf("agent_id" to "ceaa7bcf-1612-45d7-b484-2e0da9349168"), IllegalArgumentException::class, "agent with ID"), + Triple( + mapOf("agent_id" to "ceaa7bcf-1612-45d7-b484-2e0da9349168"), + IllegalArgumentException::class, + "agent with ID" + ), ) tests.forEach { @@ -166,7 +171,11 @@ internal class LinkHandlerTest { Triple(mapOf("agent" to null), IllegalArgumentException::class, "has no agents"), Triple(mapOf("agent_id" to null), IllegalArgumentException::class, "has no agents"), Triple(mapOf("agent" to "agent_name"), IllegalArgumentException::class, "has no agents"), - Triple(mapOf("agent_id" to "9a920eee-47fb-4571-9501-e4b3120c12f2"), IllegalArgumentException::class, "has no agents"), + Triple( + mapOf("agent_id" to "9a920eee-47fb-4571-9501-e4b3120c12f2"), + IllegalArgumentException::class, + "has no agents" + ), ) tests.forEach { From e410d4101d4e18dda4f5703190a3c08606f5cf27 Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Fri, 11 Apr 2025 01:25:01 +0300 Subject: [PATCH 09/10] fix: install location in Windows --- README.md | 2 +- build.gradle.kts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ded75c8..7a65a03 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ or from [Coder's Github Release page](https://github.com/coder/coder-jetbrains-t The next step is to copy the zip content to one of the following locations, depending on your OS: -* Windows: `%LocalAppData%/JetBrains/Toolbox/cache/plugins/com.coder.toolbox` +* Windows: `%LocalAppData%/JetBrains/Toolbox/plugins/com.coder.toolbox` * macOS: `~/Library/Caches/JetBrains/Toolbox/plugins/com.coder.toolbox` * Linux: `~/.local/share/JetBrains/Toolbox/plugins/com.coder.toolbox` diff --git a/build.gradle.kts b/build.gradle.kts index e715675..9c81da9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -191,8 +191,10 @@ private fun getPluginInstallDir(): Path { } / "JetBrains" / "Toolbox" val pluginsDir = when { - SystemInfoRt.isWindows -> toolboxCachesDir / "cache" - SystemInfoRt.isLinux || SystemInfoRt.isMac -> toolboxCachesDir + SystemInfoRt.isWindows || + SystemInfoRt.isLinux || + SystemInfoRt.isMac -> toolboxCachesDir + else -> error("Unknown os") } / "plugins" From b872be26dbd2bba6dc044f438523e7dc43b342e4 Mon Sep 17 00:00:00 2001 From: Faur Ioan-Aurel Date: Fri, 11 Apr 2025 02:12:20 +0300 Subject: [PATCH 10/10] impl: show plugin main page when uri handling - regardless of query params being present --- src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt b/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt index 90bfa6b..de79422 100644 --- a/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt +++ b/src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt @@ -42,6 +42,7 @@ open class CoderProtocolHandler( shouldWaitForAutoLogin: Boolean, reInitialize: suspend (CoderRestClient, CoderCLIManager) -> Unit ) { + context.popupPluginMainPage() val params = uri.toQueryParameters() if (params.isEmpty()) { // probably a plugin installation scenario