Skip to content

fix(jetbrains): skip git and gh probes for removed worktrees - #13525

Merged
kirillk merged 3 commits into
mainfrom
hidden-meadow
Aug 28, 2026
Merged

fix(jetbrains): skip git and gh probes for removed worktrees#13525
kirillk merged 3 commits into
mainfrom
hidden-meadow

Conversation

@kirillk

@kirillk kirillk commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Issue

No linked issue — reported from a user log where the JetBrains Agent Manager claimed git was not installed on a machine with a working git.

Context

When a worktree directory no longer exists, the backend still spawned git/gh with that directory as the working directory. IntelliJ fails the spawn with Cannot start a process, the working directory '...' does not exist, and the probe classified that as GIT_MISSING:

gh probe result reason=availability value=GIT_MISSING exit=-1 ms=0 stderr=Cannot start a process, the working directory '/Users/.../.kilo/worktrees/snappy-hedgehog' does not exist

That surfaced a sticky "Git is not installed" notification/banner and pushed the probe loop into its slow 60s backoff, even though nothing was wrong with the environment.

A gone directory is normal: a frame or session can still be rooted at a worktree that was deleted (removal does not close that window), a worktree can be deleted outside the plugin (rm -rf, terminal git worktree remove), and git keeps the entry in worktree list as prunable until someone prunes.

Implementation

All in KiloWorktreeRpcApiImpl:

  • New sync(root) reconciles git metadata with the disk before any probe: bails out when root itself is gone, prunes when any listed entry is prunable or its checkout is missing, re-lists, and drops entries without a directory. stats() and prStatus() now source their worktrees from it, and in prStatus() the sync runs before ghAvailable() so a deleted worktree is pruned rather than probed.
  • ghAvailable() and probeGh() check the directory first and return OK without caching, so a dead directory reports nothing instead of poisoning the shared ghCache for every caller.
  • branchStatus() returns an empty DTO for a missing directory instead of running git there.
  • New badDir() covers the residual race where the directory disappears between the check and the spawn: a working-directory spawn failure is no longer evidence that git is uninstalled.

Deliberately not in scope: the frontend still polls project.basePath for a project opened on a deleted worktree. This PR makes those probes harmless; stopping them (closing or rerouting such a project/session on removal) is a separate change.

Screenshots / Video

N/A — no visual changes; the user-visible effect is the absence of a false notification.

How to Test

Manual/local verification

  • ./gradlew typecheck from packages/kilo-jetbrains/ — passed (agent)
  • ./gradlew :backend:test from packages/kilo-jetbrains/ — passed (agent), including four new tests: stats prunes and drops a worktree deleted from disk, ghStatus/prStatus on a removed directory report OK, and badDir distinguishes a dead working directory from a missing git binary

Reviewer test steps

  1. Open a repo in the IDE and create a worktree from the Agent Manager
  2. Open that worktree as its own project, then delete the worktree directory from a terminal (rm -rf .kilo/worktrees/<name>)
  3. Confirm no "Git is not installed" notification or banner appears in either window, and the idea.log shows gh probe skipped ... missing=true / worktree sync skipped instead of value=GIT_MISSING
  4. Back in the main project, confirm git worktree list --porcelain no longer lists the deleted worktree after a stats refresh

Blocked checks and substitute verification

  • None

Checklist

  • Issue linked above, or exception explained
  • Tests/verification described
  • Screenshots/video included for visual changes, or marked N/A
  • Changeset considered for user-facing changes
  • I personally reviewed the diff and can explain the changes, including any AI-assisted work.

Get in Touch

N/A

@kilo-code-bot

kilo-code-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/rpc/KiloWorktreeRpcApiImpl.kt
  • packages/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/rpc/KiloWorktreeRpcApiImplTest.kt
Previous Review Summaries (2 snapshots, latest commit 835c9f1)

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

Previous review (commit 835c9f1)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/rpc/KiloWorktreeRpcApiImpl.kt
  • packages/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/rpc/KiloWorktreeRpcApiImplTest.kt

Previous review (commit 66e6871)

Status: 1 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/rpc/KiloWorktreeRpcApiImpl.kt 194 prStatus returns OK when git is missing, which can clear a real GIT_MISSING banner
Files Reviewed (3 files)
  • .changeset/worktree-probe-missing-dir.md - 0 issues
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/rpc/KiloWorktreeRpcApiImpl.kt - 1 issue
  • packages/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/rpc/KiloWorktreeRpcApiImplTest.kt - 0 issues

Fix these issues in Kilo Cloud


Reviewed by grok-4.6 · Input: 151.2K · Output: 8.1K · Cached: 306.7K

Review guidance: REVIEW.md from base branch main

@kirillk
kirillk merged commit 3ce6875 into main Aug 28, 2026
24 checks passed
@kirillk
kirillk deleted the hidden-meadow branch August 28, 2026 14:28
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