-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(jetbrains): improve CLI recovery and config paths #11850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4454800
fix(jetbrains): float connection status above prompt
kirillk 057dc97
fix(jetbrains): show CLI recovery popup from retry
kirillk d4db9c9
fix(jetbrains): refresh config action paths
kirillk 02c1177
chore(jetbrains): address config action review
kirillk d5f9e53
fix(jetbrains): address recovery review feedback
kirillk 2a75b6c
fix(jetbrains): remove test-only recovery accessor
kirillk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@kilocode/kilo-jetbrains": patch | ||
| --- | ||
|
|
||
| Show resolved JetBrains config file paths, float connection status above the prompt, and offer retry, restart, and reinstall recovery actions from connection errors. JetBrains now opens the same global config directory used by the CLI; macOS and Windows users who previously created global config from JetBrains may need to move files from the old platform-specific location to `~/.config/kilo`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 8 additions & 10 deletions
18
packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/cli/KiloCliConfigPath.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,21 @@ | ||
| package ai.kilocode.backend.cli | ||
|
|
||
| import com.intellij.openapi.util.SystemInfo | ||
| import java.io.File | ||
|
|
||
| internal object KiloCliConfigPath { | ||
| private const val APP = "kilo" | ||
|
|
||
| fun resolve(env: Map<String, String>): File { | ||
| env["KILO_CONFIG_DIR"]?.takeIf { it.isNotBlank() }?.let { return File(it) } | ||
| env["XDG_CONFIG_HOME"]?.takeIf { it.isNotBlank() }?.let { return File(it, "kilo") } | ||
| return File(defaultRoot(), "kilo") | ||
| env["XDG_CONFIG_HOME"]?.takeIf { it.isNotBlank() }?.let { return File(it, APP) } | ||
| return File(File(home(env), ".config"), APP) | ||
| } | ||
|
|
||
| fun legacySettingsFile(env: Map<String, String>): File = File(resolve(env), "legacy-settings.json") | ||
|
|
||
| private fun defaultRoot(): File { | ||
| if (SystemInfo.isWindows) { | ||
| val app = System.getenv("APPDATA")?.takeIf { it.isNotBlank() } | ||
| if (app != null) return File(app) | ||
| } | ||
| if (SystemInfo.isMac) return File(System.getProperty("user.home"), "Library/Application Support") | ||
| return File(System.getProperty("user.home"), ".config") | ||
| private fun home(env: Map<String, String>): String { | ||
| return env["HOME"]?.takeIf { it.isNotBlank() } | ||
| ?: env["USERPROFILE"]?.takeIf { it.isNotBlank() } | ||
| ?: System.getProperty("user.home") | ||
| } | ||
| } | ||
80 changes: 80 additions & 0 deletions
80
...s/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/cli/KiloCliConfigPathTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| package ai.kilocode.backend.cli | ||
|
|
||
| import kotlin.test.Test | ||
| import kotlin.test.assertEquals | ||
| import java.io.File | ||
| import java.nio.file.Files | ||
|
|
||
| class KiloCliConfigPathTest { | ||
|
|
||
| @Test | ||
| fun `kilo config dir overrides XDG config home`() { | ||
| val dir = Files.createTempDirectory("kilo-config-dir").toFile() | ||
| val xdg = Files.createTempDirectory("kilo-xdg-config").toFile() | ||
|
|
||
| val path = KiloCliConfigPath.resolve( | ||
| mapOf( | ||
| "KILO_CONFIG_DIR" to dir.absolutePath, | ||
| "XDG_CONFIG_HOME" to xdg.absolutePath, | ||
| ), | ||
| ) | ||
|
|
||
| assertEquals(dir.absoluteFile, path.absoluteFile) | ||
| } | ||
|
|
||
| @Test | ||
| fun `XDG config home resolves to kilo subdirectory`() { | ||
| val xdg = Files.createTempDirectory("kilo-xdg-config").toFile() | ||
|
|
||
| val path = KiloCliConfigPath.resolve(mapOf("XDG_CONFIG_HOME" to xdg.absolutePath)) | ||
|
|
||
| assertEquals(File(xdg, "kilo").absoluteFile, path.absoluteFile) | ||
| } | ||
|
|
||
| @Test | ||
| fun `default config home matches CLI xdg fallback`() { | ||
| val home = Files.createTempDirectory("kilo-home").toFile() | ||
|
|
||
| val path = KiloCliConfigPath.resolve(mapOf("HOME" to home.absolutePath)) | ||
|
|
||
| assertEquals(File(File(home, ".config"), "kilo").absoluteFile, path.absoluteFile) | ||
| } | ||
|
|
||
| @Test | ||
| fun `USERPROFILE backs up HOME for default config home`() { | ||
| val home = Files.createTempDirectory("kilo-userprofile").toFile() | ||
|
|
||
| val path = KiloCliConfigPath.resolve( | ||
| mapOf( | ||
| "HOME" to "", | ||
| "USERPROFILE" to home.absolutePath, | ||
| ), | ||
| ) | ||
|
|
||
| assertEquals(File(File(home, ".config"), "kilo").absoluteFile, path.absoluteFile) | ||
| } | ||
|
|
||
| @Test | ||
| fun `blank config env values are ignored`() { | ||
| val home = Files.createTempDirectory("kilo-home").toFile() | ||
|
|
||
| val path = KiloCliConfigPath.resolve( | ||
| mapOf( | ||
| "KILO_CONFIG_DIR" to " ", | ||
| "XDG_CONFIG_HOME" to "", | ||
| "HOME" to home.absolutePath, | ||
| ), | ||
| ) | ||
|
|
||
| assertEquals(File(File(home, ".config"), "kilo").absoluteFile, path.absoluteFile) | ||
| } | ||
|
|
||
| @Test | ||
| fun `legacy settings file resolves under global config dir`() { | ||
| val home = Files.createTempDirectory("kilo-home").toFile() | ||
|
|
||
| val path = KiloCliConfigPath.legacySettingsFile(mapOf("HOME" to home.absolutePath)) | ||
|
|
||
| assertEquals(File(File(File(home, ".config"), "kilo"), "legacy-settings.json").absoluteFile, path.absoluteFile) | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
...ilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/actions/ActionEventWorkspace.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package ai.kilocode.client.actions | ||
|
|
||
| import ai.kilocode.client.session.SessionManager | ||
| import com.intellij.openapi.actionSystem.AnActionEvent | ||
|
|
||
| internal fun AnActionEvent.workspaceDirectory(): String? { | ||
| return getData(SessionManager.WORKSPACE_KEY)?.directory ?: project?.basePath | ||
| } |
9 changes: 9 additions & 0 deletions
9
...es/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/actions/KiloActionPlaces.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package ai.kilocode.client.actions | ||
|
|
||
| import com.intellij.openapi.actionSystem.ActionPlaces | ||
|
|
||
| internal object KiloActionPlaces { | ||
| const val CONNECTION_RETRY = "Kilo.ConnectionRetry" | ||
|
|
||
| fun connectionRetryPopup() = ActionPlaces.getActionGroupPopupPlace(CONNECTION_RETRY) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.