Skip to content

fix(jetbrains): clean up restartless unload - #11278

Merged
kirillk merged 2 commits into
mainfrom
towering-talk
Jun 16, 2026
Merged

fix(jetbrains): clean up restartless unload#11278
kirillk merged 2 commits into
mainfrom
towering-talk

Conversation

@kirillk

@kirillk kirillk commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add backend and frontend dynamic plugin unload listeners for Kilo cleanup.
  • Stop backend runtime/CLI resources idempotently before unload and avoid retaining CLI reader threads.
  • Close frontend Kilo UI/editor surfaces and clear VFS/editor registries during unload.

Validation

  • ./gradlew :backend:test --tests ai.kilocode.backend.app.KiloBackendAppServiceTest --tests ai.kilocode.client.session.ui.attachment.AttachmentEditorKindTest
  • ./gradlew :frontend:test --tests ai.kilocode.client.session.ui.attachment.AttachmentEditorKindTest
  • bun run typecheck

@kirillk
kirillk marked this pull request as ready for review June 15, 2026 20:32
@kilo-code-bot

kilo-code-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found (previous issue resolved) | Recommendation: Merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 0
Resolved Issue

The previous SUGGESTION about the spurious "CLI stderr reader failed" warning has been fixed by the second commit (dfd3440). The new closing field tracks which process is being intentionally cleaned up, and the stderr reader thread now checks closing !== proc before logging the warning.

Other Observations (not in diff)
File Issue
KiloVirtualFileSystem.kt Uses a companion-object singleton (local) rather than an IntelliJ @Service. Across restartless plugin updates, the old classloader's singleton persists even though clear() is called on unload. Consider converting to an IntelliJ service that gets properly disposed by the platform.
Files Reviewed (14 files)
  • .changeset/jetbrains-restartless-unload.md - Changeset
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/app/KiloBackendAppService.kt - Shutdown idempotency
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/cli/KiloBackendCliManager.kt - Stream cleanup + stderr warning fix (updated)
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/plugin/KiloBackendDynamicPluginListener.kt - New backend unload listener
  • packages/kilo-jetbrains/backend/src/main/resources/kilo.jetbrains.backend.xml - Listener registration
  • packages/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/app/KiloBackendAppServiceTest.kt - Shutdown idempotency test
  • packages/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/testing/FakeCliServer.kt - Stop/dispose counters
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/KiloToolWindowFactory.kt - Service extraction
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/plugin/KiloFrontendDynamicPluginListener.kt - New frontend unload cleanup
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/attachment/AttachmentEditorKind.kt - Unregister function
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/vfs/KiloEditorKindRegistry.kt - clear() method
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/vfs/KiloVirtualFileKindRegistry.kt - clear() method
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/vfs/KiloVirtualFileSystem.kt - clear() method
  • packages/kilo-jetbrains/frontend/src/main/resources/kilo.jetbrains.frontend.xml - Listener registration
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/attachment/AttachmentEditorKindTest.kt - Clear test

Fix these issues in Kilo Cloud

Previous Review Summary (commit 62e42c1)

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

Previous review (commit 62e42c1)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

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

SUGGESTION

File Line Issue
packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/cli/KiloBackendCliManager.kt 170 Spurious "CLI stderr reader failed" warning when stderr stream is intentionally closed by cleanup()
Other Observations (not in diff)
File Issue
KiloVirtualFileSystem.kt Uses a companion-object singleton (local) rather than an IntelliJ @Service. Across restartless plugin updates, the old classloader's singleton persists even though clear() is called on unload. Consider converting to an IntelliJ service that gets properly disposed by the platform.
Files Reviewed (14 files)
  • .changeset/jetbrains-restartless-unload.md - New changeset
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/app/KiloBackendAppService.kt - Shutdown idempotency
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/cli/KiloBackendCliManager.kt - Stream cleanup + stderr thread tracking (1 issue)
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/plugin/KiloBackendDynamicPluginListener.kt - New backend unload listener
  • packages/kilo-jetbrains/backend/src/main/resources/kilo.jetbrains.backend.xml - Listener registration
  • packages/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/app/KiloBackendAppServiceTest.kt - Shutdown idempotency test
  • packages/kilo-jetbrains/backend/src/test/kotlin/ai/kilocode/backend/testing/FakeCliServer.kt - Stop/dispose counters
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/KiloToolWindowFactory.kt - Service extraction
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/plugin/KiloFrontendDynamicPluginListener.kt - New frontend unload cleanup
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/session/ui/attachment/AttachmentEditorKind.kt - Unregister function
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/vfs/KiloEditorKindRegistry.kt - clear() method
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/vfs/KiloVirtualFileKindRegistry.kt - clear() method
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/vfs/KiloVirtualFileSystem.kt - clear() method
  • packages/kilo-jetbrains/frontend/src/main/resources/kilo.jetbrains.frontend.xml - Listener registration
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/session/ui/attachment/AttachmentEditorKindTest.kt - Clear test

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4-pro-20260423 · 306,735 tokens

Review guidance: REVIEW.md from base branch main

@kirillk
kirillk marked this pull request as draft June 15, 2026 21:02
@kirillk
kirillk marked this pull request as ready for review June 15, 2026 22:43
@kirillk
kirillk merged commit 17ed51d into main Jun 16, 2026
20 checks passed
@kirillk
kirillk deleted the towering-talk branch June 16, 2026 03:19
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
fix(jetbrains): clean up restartless unload
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