Skip to content

feat(jetbrains): app lifecycle, workspace loading, session management, and welcome UI#8886

Open
kirillk wants to merge 15 commits intomainfrom
pie-parmesan
Open

feat(jetbrains): app lifecycle, workspace loading, session management, and welcome UI#8886
kirillk wants to merge 15 commits intomainfrom
pie-parmesan

Conversation

@kirillk
Copy link
Copy Markdown
Contributor

@kirillk kirillk commented Apr 14, 2026

Depends on #8849 — must be merged first (project service, connection service, CLI manager foundation).

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:

Temporary test UI

Screen Shot 2026-04-13 at 10 18 11 PM

New Components

Backend components

Component File Purpose
KiloBackendAppService backend/.../app/ Top-level orchestrator. Owns CLI lifecycle, loads config/profile/notifications, starts session and workspace managers. Serializes all lifecycle ops via Mutex.
KiloBackendSessionManager backend/.../app/ Session CRUD (list, create, delete, abort) + real-time status tracking via SSE. Atomic status map updates.
KiloBackendWorkspaceManager backend/.../workspace/ Per-directory workspace cache using computeIfAbsent. Creates KiloBackendWorkspace instances on demand.
KiloBackendWorkspace backend/.../workspace/ Loads providers, agents, commands, skills with 3x retry. Watches SSE for reload events.
KiloAppRpcApiImpl backend/.../rpc/ Maps KiloAppState to KiloAppStateDto including load progress in Ready state.
KiloProjectRpcApiImpl backend/.../rpc/ Gates workspace state flow on app Ready via flatMapLatest — emits PENDING until app is ready.
KiloSessionRpcApiImpl backend/.../rpc/ Session operations exposed via RPC.
FixGeneratedApiTask build-tasks/ Post-processes OpenAPI-generated Kotlin: adds primitive defaults, enables coerceInputValues/explicitNulls=false, fixes boolean enums, AnySerializer, etc.

Frontend components

Component File Purpose
KiloWelcomeUi frontend/.../client/ Swing panel with icon+label status rows.
KiloAppService frontend/.../client/ App-level state via MutableStateFlow, async version fetch, watcher pattern.
KiloProjectService frontend/.../client/ Project-scoped workspace state via durable RPC flow.
KiloSessionService frontend/.../client/ Session operations (list, create, delete, abort, status).

Race Conditions Found and Fixed

ID Severity Location Issue Fix
RC-1 High KiloBackendAppService.load() Cancel-and-replace without synchronization synchronized(loadLock) + ensureActive()
RC-2 Medium KiloBackendSessionManager Non-atomic status updates _statuses.update (CAS loop)
RC-3 Medium KiloBackendWorkspaceManager.get() getOrPut not atomic computeIfAbsent
RC-4 Medium KiloBackendConnectionService Heartbeat kills fresh SSE via stale timestamp Reset lastEvent in startSse()
RC-5 Medium KiloBackendAppService.clear() In-flight loader survives cancellation Combined with RC-1 fix
RC-6 Medium KiloBackendWorkspace.load() Same cancel-and-replace as RC-1 Same synchronized + ensureActive() pattern

Test Coverage

101 backend tests total (0 failures).

Other Fixes

  • Added "active" to model status enum in OpenAPI spec
  • FixGeneratedApiTask: primitive defaults + coerceInputValues/explicitNulls=false
  • Added 8 missing env vars to KiloBackendCliManager

kirillk added 9 commits April 13, 2026 12:19
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.
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Apr 14, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (19 files)
  • packages/kilo-jetbrains/backend/src/main/kotlin/ai/kilocode/backend/app/KiloBackendAppService.kt
  • packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx
  • packages/kilo-vscode/webview-ui/agent-manager/DiffPanel.tsx
  • packages/kilo-vscode/webview-ui/agent-manager/FullScreenDiffView.tsx
  • packages/kilo-vscode/webview-ui/src/components/chat/ChatView.tsx
  • packages/kilo-vscode/webview-ui/src/components/chat/MessageList.tsx
  • packages/kilo-vscode/webview-ui/src/components/chat/TaskHeader.tsx
  • packages/kilo-vscode/webview-ui/src/components/chat/TaskToolExpanded.tsx
  • packages/kilo-vscode/webview-ui/src/stories/composite.stories.tsx
  • packages/kilo-vscode/webview-ui/src/types/messages.ts
  • packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts
  • packages/opencode/src/cli/cmd/tui/app.tsx
  • packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
  • packages/ui/src/pierre/index.ts
  • packages/kilo-docs/pages/kiloclaw/control-ui/exec-approvals.md
  • packages/kilo-docs/pages/kiloclaw/development-tools/google.md
  • packages/kilo-docs/pages/kiloclaw/end-to-end.md
  • packages/kilo-docs/pages/kiloclaw/suggested-configuration.md
  • packages/kilo-docs/source-links.md

Reviewed by gpt-5.4-20260305 · 2,600,809 tokens

kirillk added 6 commits April 14, 2026 09:23
- 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
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.

1 participant