feat(jetbrains): app lifecycle, workspace loading, session management, and welcome UI#8886
Open
feat(jetbrains): app lifecycle, workspace loading, session management, and welcome UI#8886
Conversation
Load providers, agents, commands, and skills when the CLI server is ready. Adds shared DTOs, KiloProjectRpcApi, and a frontend service so the webview can reactively consume project-scoped data. Also fixes FixGeneratedApiTask @InputDirectory -> @OutputDirectory to prevent stale file references after empty wrapper deletion.
… tests Defer initialization from constructors to explicit methods per IntelliJ guidelines. KiloBackendAppService watcher moves into ensureWatcher() called from connect(). KiloBackendProjectService gets start() + a create() test factory with injectable deps. Adds 25 tests: 11 for project service lifecycle, error handling, and parallel load safety; 14 for project-level API model serialization.
Add KiloBackendSessionManager owned by KiloBackendAppService — started after Ready with a pre-connected API client, stopped on disconnect. Includes session CRUD, live SSE status tracking, worktree directory overrides, and KiloSessionRpcApi for frontend consumption. Also adds SSE event watching to both app and project services with per-event logging, and improves startup log messages.
…orkspace Move KiloBackendWorkspace, KiloBackendWorkspaceManager, and KiloBackendProjectService into backend/workspace/ package. Rename KiloProjectState to KiloWorkspaceState and shared DTOs accordingly (KiloWorkspaceStateDto, KiloWorkspaceStatusDto, KiloWorkspaceLoadProgressDto). Project is a private case of workspace — all directory-scoped types now live in the workspace package.
Move all status rendering from KiloToolWindowFactory into a reusable KiloWelcomeUi component that watches both app and workspace state. Shows two-section progress (App: config/notifications/profile, Workspace: providers/agents/commands/skills) and keeps all details visible after loading completes instead of replacing them with just 'Connected'.
…sing env vars Fix 6 race conditions in the JetBrains plugin backend: - Synchronize load() cancel-and-replace in AppService and Workspace (RC-1, RC-5, RC-6) - Use atomic StateFlow.update for session status map (RC-2) - Replace getOrPut with computeIfAbsent for workspace creation (RC-3) - Reset heartbeat timestamp on SSE reconnect (RC-4) - Start sub-managers before advertising Ready state Add 8 missing env vars (KILOCODE_FEATURE, KILO_EDITOR_NAME, KILO_APP_VERSION, KILO_MACHINE_ID, KILO_DISABLE_CLAUDE_CODE, KILOCODE_EDITOR_NAME) for telemetry and gateway attribution parity with the VS Code extension. Add 11 new tests covering concurrency, lifecycle, and reconnection scenarios.
…provider deserialization - Fix blank tool window by creating CoroutineScope manually instead of retrieving it via project.service<CoroutineScope>() which throws - Gate workspace RPC state flow on app Ready via flatMapLatest to prevent IllegalStateException when workspace manager isn't started yet - Include LoadProgress in Ready state DTO so the UI shows loaded data - Add 'active' to model status enum in OpenAPI spec (server returns it) - Add default values for non-nullable primitives in generated API models and enable coerceInputValues/explicitNulls=false in JSON deserializer to prevent MissingFieldException on dynamically added models
…ed layout Replace HTML-based rendering with Swing icon+label rows using platform icons (TestPassed/TestFailed/TestNotRan/AnimatedIcon/Warning) as status indicators. All rows are left-aligned within centered section blocks. Status label uses primary color, progress rows use secondary. Profile row shows login state (Logged in / Not logged in with warning). Remove CLI version row — version now shown in status label text.
...lo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/app/KiloBackendConnectionService.kt
Show resolved
Hide resolved
...ages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/rpc/KiloSessionRpcApiImpl.kt
Show resolved
Hide resolved
...ages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/rpc/KiloSessionRpcApiImpl.kt
Outdated
Show resolved
Hide resolved
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (19 files)
Reviewed by gpt-5.4-20260305 · 2,600,809 tokens |
- Add ensureActive() in monitorProcess() to prevent stale process monitor from racing fresh connections during intentional restarts - Refactor load() to use local variables, assigning to shared fields only after ensureActive() to eliminate NPE race with clear() - Refactor fetchProfile() to return FetchResult instead of throwing, making all fetchers use consistent result types - Seed session statuses in list() so first load/reconnect gets current status instead of empty map - Use stored worktree directory in session get/delete to fix lookups for sessions created in worktrees - Make KiloBackendCliManager.process @volatile and update KDoc to document that exited() is called off-mutex from IO dispatcher
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Completes the JetBrains plugin backend with full app lifecycle orchestration, workspace data loading, session management, and a Swing-based welcome UI with real-time progress indicators. Fixes 6 race conditions found during analysis, adds 11 concurrency tests, and adds missing env vars for telemetry/gateway parity with the VS Code extension.
Review Feedback Addressed
Addresses review comments from both this PR and #8849:
KiloBackendConnectionService): AddedensureActive()afterproc.waitFor()inmonitorProcess()to prevent stale monitor from setting error state and scheduling reconnect during intentional restartsKiloBackendAppService): Refactoredload()to use local variables for fetched data, assigning to shared instance fields only afterensureActive()— eliminates the race whereclear()nulls fields while the loader coroutine runs (from feat(jetbrains): backend architecture, OpenAPI client, and test suite #8849 review)KiloBackendAppService): RefactoredfetchProfile()to returnFetchResultinstead of throwing, making all three fetchers follow the same result-type pattern and eliminating the mixed exceptions/result-types smell (from feat(jetbrains): backend architecture, OpenAPI client, and test suite #8849 review)KiloBackendSessionManager):list()now callsseed(dir)before building the response so statuses are populated on first load/reconnectKiloSessionRpcApiImpl):get()anddelete()now look up the stored worktree directory viagetDirectory()before querying the CLI APIKiloBackendCliManager): Madeprocess@Volatileand updated KDoc to document thatexited()is called off-mutex from IO dispatcher (from feat(jetbrains): backend architecture, OpenAPI client, and test suite #8849 review)Temporary test UI
New Components
Backend components
KiloBackendAppServicebackend/.../app/KiloBackendSessionManagerbackend/.../app/KiloBackendWorkspaceManagerbackend/.../workspace/computeIfAbsent. CreatesKiloBackendWorkspaceinstances on demand.KiloBackendWorkspacebackend/.../workspace/KiloAppRpcApiImplbackend/.../rpc/KiloAppStatetoKiloAppStateDtoincluding load progress in Ready state.KiloProjectRpcApiImplbackend/.../rpc/flatMapLatest— emits PENDING until app is ready.KiloSessionRpcApiImplbackend/.../rpc/FixGeneratedApiTaskbuild-tasks/coerceInputValues/explicitNulls=false, fixes boolean enums, AnySerializer, etc.Frontend components
KiloWelcomeUifrontend/.../client/KiloAppServicefrontend/.../client/MutableStateFlow, async version fetch, watcher pattern.KiloProjectServicefrontend/.../client/KiloSessionServicefrontend/.../client/Race Conditions Found and Fixed
KiloBackendAppService.load()synchronized(loadLock)+ensureActive()KiloBackendSessionManager_statuses.update(CAS loop)KiloBackendWorkspaceManager.get()getOrPutnot atomiccomputeIfAbsentKiloBackendConnectionServicelastEventinstartSse()KiloBackendAppService.clear()KiloBackendWorkspace.load()synchronized+ensureActive()patternTest Coverage
101 backend tests total (0 failures).
Other Fixes
"active"to model status enum in OpenAPI specFixGeneratedApiTask: primitive defaults +coerceInputValues/explicitNulls=falseKiloBackendCliManager