Skip to content

feat(jetbrains): add Agent Behavior settings - #11553

Merged
kirillk merged 53 commits into
mainfrom
beneficial-auroraceratops
Jul 2, 2026
Merged

feat(jetbrains): add Agent Behavior settings#11553
kirillk merged 53 commits into
mainfrom
beneficial-auroraceratops

Conversation

@kirillk

@kirillk kirillk commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What changed

This PR adds native JetBrains settings for agent behavior and stabilizes the full settings apply/persist/reload lifecycle.

Features implemented

  • Add an Agent Behavior settings section with child pages for Agents and MCP Servers.
  • Add Agents settings for choosing the default agent, creating agents, importing/exporting agent files, editing agent metadata/prompt/model settings, and staging create/edit/delete changes until Apply or OK.
  • Add MCP Servers settings for viewing configured/runtime servers, adding and editing local or remote MCP configs, editing environment variables/headers, removing servers, and running connect/disconnect/authenticate actions.
  • Add backend RPC support for agent behavior settings, including agent creation/removal, skills/commands, MCP config/status/actions, Claude Code compatibility, and CLI-backed config persistence.
  • Stabilize Models, Providers, Agents, and MCP settings writes so Apply clears synchronously, stale reloads do not reopen old values, and persisted config is reloaded from the CLI before returning to the UI.
  • Improve settings list infrastructure with shared draft/list primitives, retained renderer actions/badges, common toolbar actions, root/Agent Behavior navigation links, and localized strings.
  • Restrict unsupported native/generated agent removal/export actions and return client errors for expected agent removal failures.

Agent removal deduplication

  • De-duplicate custom agent removal onto the CLI endpoint (POST /kilocode/agent/remove) so VS Code Settings and JetBrains both use the same removal implementation.
  • Keep the CLI as the source of truth for deleting .md agents, removing inline kilo.json/kilo.jsonc agent entries, clearing default_agent, and handling legacy .kilocodemodes entries.
  • Remove the VS Code Settings client-side fallback instead of re-implementing config/file edits in the extension; failures now refresh from the authoritative agent list rather than silently patching local state.
  • Leave Marketplace panel uninstall out of scope because it has a separate scope-specific install/uninstall lifecycle.

Demos

Agents settings

Screen Shot 2026-07-01 at 8 21 09 PM

Agents settings walkthrough

GIF Recording 2026-07-01 at 8 22 02 PM

MCP settings

Screen Shot 2026-07-01 at 8 21 31 PM

MCP settings walkthrough

GIF Recording 2026-07-01 at 8 23 21 PM

Validation

  • ./gradlew typecheck
  • ./gradlew test
  • bun run typecheck from packages/opencode
  • bun test ./test/kilocode/agent-remove.test.ts ./test/kilocode/recall-search.test.ts ./test/server/httpapi-exercise/index.ts from packages/opencode
  • root bun run typecheck
  • push hook bun turbo typecheck

kirillk added 30 commits June 17, 2026 13:03
…tops

# Conflicts:
#	packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/model/ModelPicker.kt
Render all settings list rows at the same height by deriving a fixed cell
height from the tallest rendered row, so agent rows without descriptions
match described rows.

Consolidate the standalone Delete button/label strings into a single
common.delete key (localized in all bundles) and drop the orphaned
history.delete.text and duplicate agent delete keys.
@kilo-code-bot

kilo-code-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Incremental review

This pass reviewed only the diff since the previous review (3d4a5ac3..de94694d), a single commit:

  • chore: update kilo-vscode visual regression baselines (de94694d9) — updates the CI-generated screenshot baseline packages/kilo-docs/public/img/screenshot-tests/kilo-vscode/visual-regression/agentmanager/pr-badge-checks-pending-chromium-linux.png only. No source or test code changed in this increment.

Per this repo's review rules, visual regression snapshots are CI-generated baselines and out of scope for review, so there is no reviewable code change in this increment.

All previously-flagged findings on files not touched in this increment remain visible as their own inline comments and are unchanged by this pass.

Files Reviewed (1 file, incremental)
  • packages/kilo-docs/public/img/screenshot-tests/kilo-vscode/visual-regression/agentmanager/pr-badge-checks-pending-chromium-linux.png (binary baseline, out of scope)
Previous Review Summaries (9 snapshots, latest commit 3d4a5ac)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 3d4a5ac)

Status: No Issues Found | Recommendation: Merge

Incremental review

This pass reviewed only the diff since the previous review (d5f19658..3d4a5ac3), 5 files / ~58 changed lines:

  • KiloBackendWorkspace.kt — moves startWatchingGlobalSseEvents() to run before the workspace state flips to Ready (closes the window where an SSE global.disposed/server.instance.disposed event could arrive before the watcher was attached and be silently missed), and wraps fetchProviders/fetchAgents/fetchCommands/fetchSkills in withContext(Dispatchers.IO) with explicit CancellationException rethrow, matching this package's guidance to keep blocking HTTP calls off the default dispatcher. Both changes are correctness/hygiene improvements with no new issues.
  • KiloBackendWorkspaceTest.kt — adds a wait for Ready state (loaded(first)) before the concurrency test's finally block tears down the mock server, fixing a race where the background load coroutine could still be running when the HTTP client was shut down.
  • visual-regression.spec.mts / visual-regression.spec.ts — adds a document.fonts.ready + rAF settle step and disables animation/transition (not just their duration/delay) before capturing screenshots; agent-manager.css adds a prefers-reduced-motion rule for the PR badge, which is why agentmanager--pr-badge-checks-pending was removed from the skip list. These are visual-regression/CI-baseline concerns, out of scope per this repo's review rules.

No new bugs, correctness, security, or performance issues found in this increment. No new changeset needed — the existing staged-agent-settings.md changeset already covers this work.

Pre-existing, still-active findings from the earlier full review on files not touched in this increment (e.g. KiloAgentBehaviorRpcApiImpl.kt, SettingsListPanel.kt, MockCliServer.kt, FakeAppRpcApi.kt) remain visible as their own inline comments and are unchanged by this pass.

Files Reviewed (5 files, incremental)
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/workspace/KiloBackendWorkspace.kt
  • packages/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/workspace/KiloBackendWorkspaceTest.kt
  • packages/kilo-vscode/tests/visual-regression.spec.mts
  • packages/kilo-vscode/tests/visual-regression.spec.ts
  • packages/kilo-vscode/webview-ui/agent-manager/agent-manager.css

Previous review (commit d5f1965)

Status: No Issues Found | Recommendation: Merge

Incremental review

This pass reviewed only the diff since the previous review (e1379b04d5..d5f19658). After excluding a merge-from-main sync (which brought in unrelated model-usage.ts / read-only-bash-exec-flag commits that are already part of the PR's base and net out to no diff against base), the only PR-authored change in this increment is:

  • fix(vscode): tidy agent removal refresh (0e57f82f71) — collapses the duplicated cache-clear/refetch/requirements.clear() calls in KiloProvider.handleRemoveAgent's success/error/catch branches into a single shared tail. This is a behavior-preserving refactor with no functional change from the version reviewed previously.

The rest of the incremental diff (agent/index.ts read-only-bash blocklist restructuring, model-usage.ts, ask-agent-permissions.test.ts) originates from merging origin/main and is already contained in the PR's current base commit, so it isn't new PR content and was excluded from this pass. removeConfigAgent in packages/opencode/src/kilocode/agent/index.ts and its regression test (agent-remove.test.ts) predate the previous review and are unchanged in this increment.

No new bugs, correctness, security, or performance issues found. No new changeset needed — the existing staged-agent-settings.md changeset already covers this work, and this increment's only change is a non-behavioral refactor.

Files Reviewed (2 files, incremental)
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/opencode/src/kilocode/agent/index.ts (verified restructuring is merge-from-main noise, not new PR content)

Previous review (commit e1379b0)

Status: No Issues Found | Recommendation: Merge

Incremental review

This pass reviewed only the diff since the previous review (c8e66ae6eb..e1379b04d5). The change is a focused cleanup:

  • fix(vscode): rely on CLI agent removal (e1379b04d5) — removes the client-side kilo.json/.md fallback from KiloProvider.handleRemoveAgent, making it rely solely on the client.kilocode.removeAgent CLI endpoint. Error and success paths each clear the agents cache, refetch, and clear requirements, mirroring the existing removeSkillViaCli convention already used elsewhere in this file. The now-unused removeAgent helper in remove-config-item.ts is deleted, and its two associated unit tests (remove-config-item.test.ts) and the structural assertion in marketplace-panel-arch.test.ts are removed/updated accordingly.

Verified no stale references to the deleted remove-config-item.ts removeAgent export remain anywhere in packages/kilo-vscode/. A changeset for this PR (staged-agent-settings.md) already exists from an earlier commit, so no new changeset is needed for this diff. No new bugs, correctness, security, or performance issues found in the incremental diff.

Files Reviewed (4 files, incremental)
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/src/kilo-provider/remove-config-item.ts
  • packages/kilo-vscode/tests/unit/remove-config-item.test.ts
  • packages/kilo-vscode/tests/unit/marketplace-panel-arch.test.ts

Previous review (commit c8e66ae)

Status: No Issues Found | Recommendation: Merge

Incremental review

This pass reviewed only the diff since the previous review (094fed0e2..c8e66ae6eb). Filtering out unrelated commits picked up by a main merge (2bc1b045e0, already-merged upstream content) and a non-code revert (8cdbf8a530), the only real content change is:

  • fix(jetbrains): adapt model details badges (c8e66ae6eb) — updates ModelDetailsPanel.kt's tag-badge rendering to the FilledBadgeIcon(text, UiStyle.Badge.Style) constructor and UiStyle.Badge.Primary/Secondary styles that came in from the main merge, replacing the removed UiStyle.Colors.badgeBg()/activityBadgeBg() helpers. The new TagStyle wrapper preserves the original per-index background rotation and foreground color; behavior is equivalent to before the merge.

All previously-flagged issues on this PR have author replies marking them addressed, and none remain on current diff lines. No new bugs, correctness, security, or performance issues found in the incremental diff.

Files Reviewed (1 file, incremental)
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/model/ModelDetailsPanel.kt

Previous review (commit 094fed0)

Status: No Issues Found | Recommendation: Merge

Incremental review

This pass reviewed only the diff since the previous review (193e52cf..094fed0e2), 2 commits:

  • test(jetbrains): share list mouse event helper — extracts the previously-flagged duplicated fire(list, event) helper out of AgentsSettingsUiTest.kt, McpEditDialogTest.kt, McpSettingsUiTest.kt, and SettingsListViewTest.kt into a new shared ai.kilocode.client.testing.fire in MouseEvents.kt, with all four call sites updated to import it. This resolves the SUGGESTION from the previous review pass (the fix was already acknowledged in the author's reply on that thread).
  • chore: update local agent and run configs — removes stray local agent-workflow files (.kilo/agent/upstream-merge.md, .opencode/agent/duplicate-pr.md, .opencode/agent/triage.md) and renames/cleans up a local JetBrains run configuration (Run IDE Backend + Frontend.run.xml). No product code changes.

All previously-flagged issues on this PR have author replies marking them addressed, and none remain on current diff lines. No new bugs, correctness, security, or performance issues found in the incremental diff.

Files Reviewed (5 files, incremental)
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/agents/AgentsSettingsUiTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/agents/McpEditDialogTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/agents/McpSettingsUiTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/base/SettingsListViewTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/testing/MouseEvents.kt (new)

Previous review (commit 193e52c)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1

Incremental review

This pass reviewed only the diff since the previous review (03629b59..193e52cf), a single commit titled "fix: repair agent behavior CI failures" touching 5 files (~51 insertions, 11 deletions):

  • AgentsSettingsUiTest.kt, McpEditDialogTest.kt, McpSettingsUiTest.kt, SettingsListViewTest.kt — each replaces list.dispatchEvent(mouse(...)) with a new fire(list, event) helper that looks up the single ai.kilocode.* mouse listener on the JBList and invokes mousePressed/mouseReleased/mouseClicked on it directly, working around AWT event dispatch not running synchronously in the headless CI test runner. The logic is sound and fixes a real CI flake, but the identical fire() helper is now duplicated verbatim across all four files rather than living in the existing shared ai.kilocode.client.testing package.
  • packages/opencode/src/kilocode/agent/index.tsremoveConfigAgent now dynamically imports KilocodeConfigOverlay (await import("@/kilocode/config/overlay")) instead of a static top-level import, consistent with the commit's CI-failure-repair intent (likely avoiding a module-load-order/circular-import issue surfaced in CI). Behavior is unchanged; the config-overlay-based target resolution addressed in the previous review is preserved.

No bugs or correctness issues found in the changed lines.

Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/agents/AgentsSettingsUiTest.kt 479 fire() test helper duplicated identically across 4 test files instead of being extracted to the shared testing package
Files Reviewed (5 files, incremental)
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/agents/AgentsSettingsUiTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/agents/McpEditDialogTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/agents/McpSettingsUiTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/base/SettingsListViewTest.kt
  • packages/opencode/src/kilocode/agent/index.ts

Fix these issues in Kilo Cloud

Previous review (commit 03629b5)

Status: No Issues Found | Recommendation: Merge

Incremental review

This pass reviewed only the diff since the previous review (e2ba2562..03629b59), a single-file, 14-line change:

  • packages/opencode/src/kilocode/agent/index.tsremoveConfigAgent now resolves the actual loaded global/project config files via KilocodeConfigOverlay.globalTarget() / projectTarget({ directory }) instead of scanning every candidate filename across input.dirs. This correctly addresses the earlier reviewer comment asking the removal path to use the config overlay's target resolution rather than a directory scan. The call site (input.directory) and the shared Set dedup are consistent with the new signature, and the unrelated .md-file scan (input.dirs) and .kilocodemodes cleanup below are untouched by this change.

No new issues were introduced by this commit.

Files Reviewed (1 file, incremental)
  • packages/opencode/src/kilocode/agent/index.ts

Previous review (commit e2ba256)

Status: No Issues Found | Recommendation: Merge

Incremental review

This pass reviewed only the diff since the previous review (8cb93ea2..e2ba2562), which addresses every previously-flagged finding:

  • CRITICAL throw inside Effect.tryPromise catch (kilocode.ts) → now uses Effect.catch/Effect.die so the request no longer hangs.
  • KiloBackendAppService.updateConfig race-guard return value and post-patch refetch failure → now returns the committed _appState and falls back gracefully instead of throwing.
  • MCP stale cache entry on scope change (KiloAgentBehaviorRpcApiImpl.saveMcpOverride) → now clears both scope keys before writing, with a new regression test.
  • Secret-leaking response-body logging on MCP/config patch failures → removed.
  • Import-name regex stricter than create-name regex → now shares AGENT_ID.
  • applyDraft() silent no-op when change()/saved() diverge → state.start(force = true) now makes change() authoritative, with a new test.
  • Reload timeout swallowed silently → now calls showError(...) like sibling branches.
  • ProvidersSettingsUi.activate() missing disabledRows = busy → added.
  • setClaudeCodeCompat fallback echoing the requested value on failure → now falls back to false.
  • mergeConfig shallow merge (test mock) → now deep-merges recursively.
  • Boolean-parsing inconsistency (== "true" vs flagOrNull) → now uses flagOrNull.
  • configUpdateReturnStale unused → now exercised by a new test.
  • Catch-parameter shadowing (OpenSettingsAction) → renamed to err.

No new issues were introduced by this fix commit; the accompanying test additions (MCP scope-migration case, stale-config-update case, diverging saved()/change() case, valid-name round-trip case) correctly exercise the fixed behavior.

Files Reviewed (17 files, incremental)
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/app/KiloBackendAppService.kt
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/cli/KiloCliDataParser.kt
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/rpc/KiloAgentBehaviorRpcApiImpl.kt
  • packages/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/rpc/KiloAgentBehaviorRpcApiImplTest.kt
  • packages/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/testing/MockCliServer.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/actions/OpenSettingsAction.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/app/KiloAgentBehaviorService.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/settings/agents/AgentCreateState.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/settings/agents/AgentImport.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/settings/base/BaseSettingsUi.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/settings/base/SettingsDraftState.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/settings/base/SettingsListPanel.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/settings/providers/ProvidersSettingsUi.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/agents/AgentImportTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/base/BaseSettingsUiTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/models/ModelsSettingsUiTest.kt
  • packages/opencode/src/kilocode/server/httpapi/handlers/kilocode.ts

Previous review (commit 8cb93ea)

Status: 14 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 9
SUGGESTION 4
Issue Details (click to expand)

CRITICAL

File Line Issue
packages/opencode/src/kilocode/server/httpapi/handlers/kilocode.ts 59 throw inside an Effect.tryPromise catch hangs the removeAgent request instead of failing it

WARNING

File Line Issue
packages/kilo-jetbrains/backend/.../KiloBackendAppService.kt 278 Returned KiloAppState ignores the new race guard and can reflect uncommitted state
packages/kilo-jetbrains/backend/.../KiloBackendAppService.kt 270 Post-patch config refetch failure now throws even though the mutation already succeeded
packages/kilo-jetbrains/backend/.../KiloAgentBehaviorRpcApiImpl.kt 193 Stale cache entry can linger when an MCP server's scope changes
packages/kilo-jetbrains/backend/.../KiloAgentBehaviorRpcApiImpl.kt 164 Full response body logged on failure for MCP requests may leak secrets
packages/kilo-jetbrains/frontend/.../AgentImport.kt 102 Import name regex stricter than create-name regex, breaking export/import round trips
packages/kilo-jetbrains/frontend/.../BaseSettingsUi.kt 151 applyDraft() can silently no-op when change()/saved() diverge
packages/kilo-jetbrains/frontend/.../SettingsListPanel.kt 211 Reload timeout swallowed without showError, unlike sibling failure branches
packages/kilo-jetbrains/frontend/.../ProvidersSettingsUi.kt 474 activate() omits disabledRows = busy, unlike the other two call sites
packages/kilo-jetbrains/frontend/.../KiloAgentBehaviorService.kt 67 setClaudeCodeCompat fallback echoes the requested value on RPC failure instead of a neutral signal

SUGGESTION

File Line Issue
packages/kilo-jetbrains/backend/.../MockCliServer.kt 440 mergeConfig shallow-merges, masking real nested-merge regressions in tests
packages/kilo-jetbrains/backend/.../KiloCliDataParser.kt 658 Inconsistent boolean-parsing convention (== "true" vs existing flagOrNull helper)
packages/kilo-jetbrains/frontend/.../FakeAppRpcApi.kt 43 configUpdateReturnStale flag added but never exercised by a test
packages/kilo-jetbrains/frontend/.../OpenSettingsAction.kt 28 Catch parameter shadows outer actionPerformed event parameter name
Files Reviewed (100+ files)

All files changed in the PR were reviewed, sharded across 6 parallel passes covering: backend core lifecycle (KiloAppState, KiloBackendAppService, KiloBackendCliManager, KiloClaudeCompatSettings, KiloCliDataParser), backend RPC (KiloAgentBehaviorRpcApiImpl, KiloAppRpcApiImpl), frontend Agents settings (AgentsConfigurable, AgentCreateDialog, AgentEditDialog, AgentImport/AgentExport, AgentCreateState/AgentSettingsState), MCP settings + shared settings base infra (McpConfigurable, McpEditDialog, SettingsDraftState, SettingsListPanel, BaseSettingsUi, etc.), misc frontend (Models/Providers stabilization, session UI touches), and shared DTOs/parser + opencode CLI-side changes (KiloCliParser, kilocode.ts handler, agent/index.ts, related tests).

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5-20260630 · Input: 26 · Output: 4.3K · Cached: 850.6K

Review guidance: REVIEW.md from base branch main

@kirillk

kirillk commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the bot review findings in e2ba256. Replied on each fixed thread. Validation run before/while pushing: targeted JetBrains tests, packages/opencode typecheck, packages/kilo-jetbrains typecheck, opencode annotation check, diff whitespace check, and push hook bun turbo typecheck all passed.

@kirillk
kirillk requested a review from catrielmuller July 2, 2026 12:04
@kirillk
kirillk enabled auto-merge July 2, 2026 19:05
@kirillk
kirillk merged commit ad56c22 into main Jul 2, 2026
31 of 32 checks passed
@kirillk
kirillk deleted the beneficial-auroraceratops branch July 2, 2026 19:06
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…tops

feat(jetbrains): add Agent Behavior settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants