Conversation
Kilo-managed agent worktrees live under <project>/.kilo/worktrees, inside the project directory. IntelliJ indexing follows the workspace model rather than git, so it indexed every worktree checkout as part of the containing project, doubling scan time and surfacing duplicate results in Search Everywhere / Go to File. Register a DirectoryIndexExcludePolicy that excludes <project.basePath>/.kilo/worktrees from the containing project's index. A new "Index agent worktrees" toggle in Kilo Settings -> Advanced (off by default) lets users opt back in; flipping it reindexes every open project via ProjectRootManagerEx.makeRootsChange. Opening a worktree as its own project always indexes it fully, since exclusions are per-project. To make that the common case when a file link is opened from a worktree session, KiloWorkspaceRpcApiImpl.project() now prefers the open project with the longest matching base path instead of the first one, so a managed worktree file routes to the worktree's own frame (full IDE features) when it is open, instead of always landing in the main checkout with degraded highlighting.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Previous Review Summary (commit de5bdbe)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit de5bdbe)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (17 files)
Reviewed by grok-4.6 · Input: 98.3K · Output: 10.9K · Cached: 559.2K Review guidance: REVIEW.md from base branch |
Two bugs found in review of the settings toggle: The save was launched on the configurable's own scope, which disposeUIResources() cancels. Since OK runs apply() then disposeUIResources(), the RPC and the reindex it triggers could be cancelled before they ran, so Apply worked but OK often silently did nothing. Move the write behind KiloAppService.setIndexWorktreesAsync, which launches on the app-lifetime scope, mirroring applyLogConfigAsync. The initial value is fetched asynchronously, and refreshIndexWorktrees overwrote the control unconditionally. A slow split-mode fetch landing after the user flipped the switch discarded their choice and cleared isModified. Track whether the user touched the toggle and skip the refresh in that case; resetForm() clears the flag so a later fetch can still populate a pristine form. Both paths now have regression tests, each verified to fail against the previous behavior. The dispose test gates the save inside the fake RPC so the dispose provably happens while the call is in flight rather than racing the coroutine's first dispatch.
|
Addressed both review findings in f608dd9. 1. OK could cancel the save (WARNING). 2. A late fetch could discard the user's toggle (SUGGESTION). Verification — both regression tests were confirmed to fail against the previous behavior before the fixes were restored:
The dispose test gates the save inside
|
Issue
No linked issue. This came out of an ad hoc investigation into why indexing felt slow with several Agent Manager worktrees open in one IntelliJ frame (findings recorded in a local
intellij.md, not filed as a GitHub issue).Context
Kilo-managed agent worktrees live under
<project>/.kilo/worktrees, inside the project directory. IntelliJ indexing follows the workspace model, not git, so.git/info/exclude(where Agent Manager already hides worktrees from git) is never consulted by the indexer. Every worktree checkout was indexed like any other project file, which can double scan time on a project with active worktrees and produces duplicate hits in Search Everywhere / Go to File.Implementation
DirectoryIndexExcludePolicy(KiloWorktreeExcludePolicy, backend module) that excludes<project.basePath>/.kilo/worktreesfrom the containing project's index. This is the legacy-but-still-supported exclusion API; the modernWorkspaceFileIndexContributorreplacement has no usable project-scoped entity (ProjectRootEntityis@ApiStatus.Internal, and the content-root-scoped variant would register per content root).KiloWorktreeIndexSettings(PropertiesComponent-backed, default off) so it can be turned back on. Added a "Index agent worktrees" toggle to Kilo Settings → Advanced; flipping it round-trips over a newindexWorktrees()/setIndexWorktrees()pair onKiloAppRpcApiand firesProjectRootManagerEx.makeRootsChange(RESCAN_DEPENDENCIES_IF_NEEDED)for every open project so the change takes effect without a restart.KiloWorkspaceRpcApiImpl.project()now prefers the open project whose base path is the longest match instead of just the first one. A worktree file opened via a Kilo session file link, diff "Open File", or@-mention now routes to the worktree's own frame (full IDE features) when it's open, instead of always landing in the main checkout..kilo/worktreesliteral into a sharedWORKTREE_STORAGEconstant reused by the existingisManagedWorktreeStoragescoping check.Screenshots / Video
N/A — settings toggle only; no new visual surface beyond one row on an existing settings page.
How to Test
Manual/local verification
./gradlew typecheckand./gradlew testfrompackages/kilo-jetbrains/(all three modules) — see below.isModified().Reviewer test steps
.kilo/worktrees/<slug>..kilo/worktreesrenders in the excluded-folder color while.kilo/kilo.jsonc,.kilo/commands, etc. render normally..kilo/worktrees/...hit shows up.Blocked checks and substitute verification
./gradlew runIde) for steps 2–5 above in this session; substitute verification was the automated test suite below plus manual code/API review against the localintellij-communitycheckout referenced in the implementation notes (DirectoryIndexExcludePolicy,RootsChangeRescanningInfo,ProjectRootManagerEx.makeRootsChangesignatures).Executed by the agent:
./gradlew typecheckfrompackages/kilo-jetbrains/—BUILD SUCCESSFUL../gradlew testfrompackages/kilo-jetbrains/—BUILD SUCCESSFUL, 0 failures across all three modules (895 backend tests, 3747 frontend tests, 9 shared tests), including new coverage:KiloWorktreeExcludePolicyTest(exclusion URL derives fromproject.basePath; empty when the setting is on; empty for the default project with no base path)KiloAppRpcApiImplIndexWorktreesTest(setting persists and round-trips through the RPC methods)WorkspacePathScopingTestadditions for the newdeepest()project-matching helperAdvancedConfigurableTestadditions for the async fetch, dirty-tracking, and apply-only-when-changed behavior of the new toggleChecklist
Get in Touch